index-CMTqTaab.js 3.3 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729
  1. function Yse(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 c_=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ml(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var HA={exports:{}},rb={};var XU;function Zse(){if(XU)return rb;XU=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 rb.Fragment=e,rb.jsx=n,rb.jsxs=n,rb}var YU;function Qse(){return YU||(YU=1,HA.exports=Zse()),HA.exports}var s=Qse(),VA={exports:{}},gn={};var ZU;function Jse(){if(ZU)return gn;ZU=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"),m=Symbol.iterator;function p(z){return z===null||typeof z!="object"?null:(z=m&&z[m]||z["@@iterator"],typeof z=="function"?z:null)}var b={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},v=Object.assign,x={};function y(z,H,Z){this.props=z,this.context=H,this.refs=x,this.updater=Z||b}y.prototype.isReactComponent={},y.prototype.setState=function(z,H){if(typeof z!="object"&&typeof z!="function"&&z!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,z,H,"setState")},y.prototype.forceUpdate=function(z){this.updater.enqueueForceUpdate(this,z,"forceUpdate")};function S(){}S.prototype=y.prototype;function M(z,H,Z){this.props=z,this.context=H,this.refs=x,this.updater=Z||b}var N=M.prototype=new S;N.constructor=M,v(N,y.prototype),N.isPureReactComponent=!0;var A=Array.isArray;function k(){}var C={H:null,A:null,T:null,S:null},D=Object.prototype.hasOwnProperty;function T(z,H,Z){var ee=Z.ref;return{$$typeof:t,type:z,key:H,ref:ee!==void 0?ee:null,props:Z}}function R(z,H){return T(z.type,H,z.props)}function U(z){return typeof z=="object"&&z!==null&&z.$$typeof===t}function L(z){var H={"=":"=0",":":"=2"};return"$"+z.replace(/[=:]/g,function(Z){return H[Z]})}var q=/\/+/g;function j(z,H){return typeof z=="object"&&z!==null&&z.key!=null?L(""+z.key):H.toString(36)}function W(z){switch(z.status){case"fulfilled":return z.value;case"rejected":throw z.reason;default:switch(typeof z.status=="string"?z.then(k,k):(z.status="pending",z.then(function(H){z.status==="pending"&&(z.status="fulfilled",z.value=H)},function(H){z.status==="pending"&&(z.status="rejected",z.reason=H)})),z.status){case"fulfilled":return z.value;case"rejected":throw z.reason}}throw z}function K(z,H,Z,ee,he){var fe=typeof z;(fe==="undefined"||fe==="boolean")&&(z=null);var oe=!1;if(z===null)oe=!0;else switch(fe){case"bigint":case"string":case"number":oe=!0;break;case"object":switch(z.$$typeof){case t:case e:oe=!0;break;case d:return oe=z._init,K(oe(z._payload),H,Z,ee,he)}}if(oe)return he=he(z),oe=ee===""?"."+j(z,0):ee,A(he)?(Z="",oe!=null&&(Z=oe.replace(q,"$&/")+"/"),K(he,H,Z,"",function(Se){return Se})):he!=null&&(U(he)&&(he=R(he,Z+(he.key==null||z&&z.key===he.key?"":(""+he.key).replace(q,"$&/")+"/")+oe)),H.push(he)),1;oe=0;var Ne=ee===""?".":ee+":";if(A(z))for(var ge=0;ge<z.length;ge++)ee=z[ge],fe=Ne+j(ee,ge),oe+=K(ee,H,Z,fe,he);else if(ge=p(z),typeof ge=="function")for(z=ge.call(z),ge=0;!(ee=z.next()).done;)ee=ee.value,fe=Ne+j(ee,ge++),oe+=K(ee,H,Z,fe,he);else if(fe==="object"){if(typeof z.then=="function")return K(W(z),H,Z,ee,he);throw H=String(z),Error("Objects are not valid as a React child (found: "+(H==="[object Object]"?"object with keys {"+Object.keys(z).join(", ")+"}":H)+"). If you meant to render a collection of children, use an array instead.")}return oe}function V(z,H,Z){if(z==null)return z;var ee=[],he=0;return K(z,ee,"","",function(fe){return H.call(Z,fe,he++)}),ee}function J(z){if(z._status===-1){var H=z._result;H=H(),H.then(function(Z){(z._status===0||z._status===-1)&&(z._status=1,z._result=Z)},function(Z){(z._status===0||z._status===-1)&&(z._status=2,z._result=Z)}),z._status===-1&&(z._status=0,z._result=H)}if(z._status===1)return z._result.default;throw z._result}var ne=typeof reportError=="function"?reportError:function(z){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var H=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof z=="object"&&z!==null&&typeof z.message=="string"?String(z.message):String(z),error:z});if(!window.dispatchEvent(H))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",z);return}console.error(z)},te={map:V,forEach:function(z,H,Z){V(z,function(){H.apply(this,arguments)},Z)},count:function(z){var H=0;return V(z,function(){H++}),H},toArray:function(z){return V(z,function(H){return H})||[]},only:function(z){if(!U(z))throw Error("React.Children.only expected to receive a single React element child.");return z}};return gn.Activity=f,gn.Children=te,gn.Component=y,gn.Fragment=n,gn.Profiler=i,gn.PureComponent=M,gn.StrictMode=r,gn.Suspense=c,gn.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=C,gn.__COMPILER_RUNTIME={__proto__:null,c:function(z){return C.H.useMemoCache(z)}},gn.cache=function(z){return function(){return z.apply(null,arguments)}},gn.cacheSignal=function(){return null},gn.cloneElement=function(z,H,Z){if(z==null)throw Error("The argument must be a React element, but you passed "+z+".");var ee=v({},z.props),he=z.key;if(H!=null)for(fe in H.key!==void 0&&(he=""+H.key),H)!D.call(H,fe)||fe==="key"||fe==="__self"||fe==="__source"||fe==="ref"&&H.ref===void 0||(ee[fe]=H[fe]);var fe=arguments.length-2;if(fe===1)ee.children=Z;else if(1<fe){for(var oe=Array(fe),Ne=0;Ne<fe;Ne++)oe[Ne]=arguments[Ne+2];ee.children=oe}return T(z.type,he,ee)},gn.createContext=function(z){return z={$$typeof:o,_currentValue:z,_currentValue2:z,_threadCount:0,Provider:null,Consumer:null},z.Provider=z,z.Consumer={$$typeof:a,_context:z},z},gn.createElement=function(z,H,Z){var ee,he={},fe=null;if(H!=null)for(ee in H.key!==void 0&&(fe=""+H.key),H)D.call(H,ee)&&ee!=="key"&&ee!=="__self"&&ee!=="__source"&&(he[ee]=H[ee]);var oe=arguments.length-2;if(oe===1)he.children=Z;else if(1<oe){for(var Ne=Array(oe),ge=0;ge<oe;ge++)Ne[ge]=arguments[ge+2];he.children=Ne}if(z&&z.defaultProps)for(ee in oe=z.defaultProps,oe)he[ee]===void 0&&(he[ee]=oe[ee]);return T(z,fe,he)},gn.createRef=function(){return{current:null}},gn.forwardRef=function(z){return{$$typeof:l,render:z}},gn.isValidElement=U,gn.lazy=function(z){return{$$typeof:d,_payload:{_status:-1,_result:z},_init:J}},gn.memo=function(z,H){return{$$typeof:u,type:z,compare:H===void 0?null:H}},gn.startTransition=function(z){var H=C.T,Z={};C.T=Z;try{var ee=z(),he=C.S;he!==null&&he(Z,ee),typeof ee=="object"&&ee!==null&&typeof ee.then=="function"&&ee.then(k,ne)}catch(fe){ne(fe)}finally{H!==null&&Z.types!==null&&(H.types=Z.types),C.T=H}},gn.unstable_useCacheRefresh=function(){return C.H.useCacheRefresh()},gn.use=function(z){return C.H.use(z)},gn.useActionState=function(z,H,Z){return C.H.useActionState(z,H,Z)},gn.useCallback=function(z,H){return C.H.useCallback(z,H)},gn.useContext=function(z){return C.H.useContext(z)},gn.useDebugValue=function(){},gn.useDeferredValue=function(z,H){return C.H.useDeferredValue(z,H)},gn.useEffect=function(z,H){return C.H.useEffect(z,H)},gn.useEffectEvent=function(z){return C.H.useEffectEvent(z)},gn.useId=function(){return C.H.useId()},gn.useImperativeHandle=function(z,H,Z){return C.H.useImperativeHandle(z,H,Z)},gn.useInsertionEffect=function(z,H){return C.H.useInsertionEffect(z,H)},gn.useLayoutEffect=function(z,H){return C.H.useLayoutEffect(z,H)},gn.useMemo=function(z,H){return C.H.useMemo(z,H)},gn.useOptimistic=function(z,H){return C.H.useOptimistic(z,H)},gn.useReducer=function(z,H,Z){return C.H.useReducer(z,H,Z)},gn.useRef=function(z){return C.H.useRef(z)},gn.useState=function(z){return C.H.useState(z)},gn.useSyncExternalStore=function(z,H,Z){return C.H.useSyncExternalStore(z,H,Z)},gn.useTransition=function(){return C.H.useTransition()},gn.version="19.2.3",gn}var QU;function Vg(){return QU||(QU=1,VA.exports=Jse()),VA.exports}var w=Vg();const Ur=ml(w),eoe=Yse({__proto__:null,default:Ur},[w]);var GA={exports:{}},ib={},WA={exports:{}},qA={};var JU;function toe(){return JU||(JU=1,(function(t){function e(K,V){var J=K.length;K.push(V);e:for(;0<J;){var ne=J-1>>>1,te=K[ne];if(0<i(te,V))K[ne]=V,K[J]=te,J=ne;else break e}}function n(K){return K.length===0?null:K[0]}function r(K){if(K.length===0)return null;var V=K[0],J=K.pop();if(J!==V){K[0]=J;e:for(var ne=0,te=K.length,z=te>>>1;ne<z;){var H=2*(ne+1)-1,Z=K[H],ee=H+1,he=K[ee];if(0>i(Z,J))ee<te&&0>i(he,Z)?(K[ne]=he,K[ee]=J,ne=ee):(K[ne]=Z,K[H]=J,ne=H);else if(ee<te&&0>i(he,J))K[ne]=he,K[ee]=J,ne=ee;else break e}}return V}function i(K,V){var J=K.sortIndex-V.sortIndex;return J!==0?J:K.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,m=3,p=!1,b=!1,v=!1,x=!1,y=typeof setTimeout=="function"?setTimeout:null,S=typeof clearTimeout=="function"?clearTimeout:null,M=typeof setImmediate<"u"?setImmediate:null;function N(K){for(var V=n(u);V!==null;){if(V.callback===null)r(u);else if(V.startTime<=K)r(u),V.sortIndex=V.expirationTime,e(c,V);else break;V=n(u)}}function A(K){if(v=!1,N(K),!b)if(n(c)!==null)b=!0,k||(k=!0,L());else{var V=n(u);V!==null&&W(A,V.startTime-K)}}var k=!1,C=-1,D=5,T=-1;function R(){return x?!0:!(t.unstable_now()-T<D)}function U(){if(x=!1,k){var K=t.unstable_now();T=K;var V=!0;try{e:{b=!1,v&&(v=!1,S(C),C=-1),p=!0;var J=m;try{t:{for(N(K),f=n(c);f!==null&&!(f.expirationTime>K&&R());){var ne=f.callback;if(typeof ne=="function"){f.callback=null,m=f.priorityLevel;var te=ne(f.expirationTime<=K);if(K=t.unstable_now(),typeof te=="function"){f.callback=te,N(K),V=!0;break t}f===n(c)&&r(c),N(K)}else r(c);f=n(c)}if(f!==null)V=!0;else{var z=n(u);z!==null&&W(A,z.startTime-K),V=!1}}break e}finally{f=null,m=J,p=!1}V=void 0}}finally{V?L():k=!1}}}var L;if(typeof M=="function")L=function(){M(U)};else if(typeof MessageChannel<"u"){var q=new MessageChannel,j=q.port2;q.port1.onmessage=U,L=function(){j.postMessage(null)}}else L=function(){y(U,0)};function W(K,V){C=y(function(){K(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(K){K.callback=null},t.unstable_forceFrameRate=function(K){0>K||125<K?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):D=0<K?Math.floor(1e3/K):5},t.unstable_getCurrentPriorityLevel=function(){return m},t.unstable_next=function(K){switch(m){case 1:case 2:case 3:var V=3;break;default:V=m}var J=m;m=V;try{return K()}finally{m=J}},t.unstable_requestPaint=function(){x=!0},t.unstable_runWithPriority=function(K,V){switch(K){case 1:case 2:case 3:case 4:case 5:break;default:K=3}var J=m;m=K;try{return V()}finally{m=J}},t.unstable_scheduleCallback=function(K,V,J){var ne=t.unstable_now();switch(typeof J=="object"&&J!==null?(J=J.delay,J=typeof J=="number"&&0<J?ne+J:ne):J=ne,K){case 1:var te=-1;break;case 2:te=250;break;case 5:te=1073741823;break;case 4:te=1e4;break;default:te=5e3}return te=J+te,K={id:d++,callback:V,priorityLevel:K,startTime:J,expirationTime:te,sortIndex:-1},J>ne?(K.sortIndex=J,e(u,K),n(c)===null&&K===n(u)&&(v?(S(C),C=-1):v=!0,W(A,J-ne))):(K.sortIndex=te,e(c,K),b||p||(b=!0,k||(k=!0,L()))),K},t.unstable_shouldYield=R,t.unstable_wrapCallback=function(K){var V=m;return function(){var J=m;m=V;try{return K.apply(this,arguments)}finally{m=J}}}})(qA)),qA}var ez;function noe(){return ez||(ez=1,WA.exports=toe()),WA.exports}var KA={exports:{}},Ca={};var tz;function roe(){if(tz)return Ca;tz=1;var t=Vg();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 Ca.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,Ca.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)},Ca.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()}},Ca.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))},Ca.prefetchDNS=function(c){typeof c=="string"&&r.d.D(c)},Ca.preinit=function(c,u){if(typeof c=="string"&&u&&typeof u.as=="string"){var d=u.as,f=l(d,u.crossOrigin),m=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:m,fetchPriority:p}):d==="script"&&r.d.X(c,{crossOrigin:f,integrity:m,fetchPriority:p,nonce:typeof u.nonce=="string"?u.nonce:void 0})}},Ca.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)},Ca.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})}},Ca.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)},Ca.requestFormReset=function(c){r.d.r(c)},Ca.unstable_batchedUpdates=function(c,u){return c(u)},Ca.useFormState=function(c,u,d){return o.H.useFormState(c,u,d)},Ca.useFormStatus=function(){return o.H.useHostTransitionStatus()},Ca.version="19.2.3",Ca}var nz;function pq(){if(nz)return KA.exports;nz=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(),KA.exports=roe(),KA.exports}var rz;function ioe(){if(rz)return ib;rz=1;var t=noe(),e=Vg(),n=pq();function r(h){var g="https://react.dev/errors/"+h;if(1<arguments.length){g+="?args[]="+encodeURIComponent(arguments[1]);for(var _=2;_<arguments.length;_++)g+="&args[]="+encodeURIComponent(arguments[_])}return"Minified React error #"+h+"; visit "+g+" 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 g=h,_=h;if(h.alternate)for(;g.return;)g=g.return;else{h=g;do g=h,(g.flags&4098)!==0&&(_=g.return),h=g.return;while(h)}return g.tag===3?_:null}function o(h){if(h.tag===13){var g=h.memoizedState;if(g===null&&(h=h.alternate,h!==null&&(g=h.memoizedState)),g!==null)return g.dehydrated}return null}function l(h){if(h.tag===31){var g=h.memoizedState;if(g===null&&(h=h.alternate,h!==null&&(g=h.memoizedState)),g!==null)return g.dehydrated}return null}function c(h){if(a(h)!==h)throw Error(r(188))}function u(h){var g=h.alternate;if(!g){if(g=a(h),g===null)throw Error(r(188));return g!==h?null:h}for(var _=h,E=g;;){var P=_.return;if(P===null)break;var F=P.alternate;if(F===null){if(E=P.return,E!==null){_=E;continue}break}if(P.child===F.child){for(F=P.child;F;){if(F===_)return c(P),h;if(F===E)return c(P),g;F=F.sibling}throw Error(r(188))}if(_.return!==E.return)_=P,E=F;else{for(var Q=!1,xe=P.child;xe;){if(xe===_){Q=!0,_=P,E=F;break}if(xe===E){Q=!0,E=P,_=F;break}xe=xe.sibling}if(!Q){for(xe=F.child;xe;){if(xe===_){Q=!0,_=F,E=P;break}if(xe===E){Q=!0,E=F,_=P;break}xe=xe.sibling}if(!Q)throw Error(r(189))}}if(_.alternate!==E)throw Error(r(190))}if(_.tag!==3)throw Error(r(188));return _.stateNode.current===_?h:g}function d(h){var g=h.tag;if(g===5||g===26||g===27||g===6)return h;for(h=h.child;h!==null;){if(g=d(h),g!==null)return g;h=h.sibling}return null}var f=Object.assign,m=Symbol.for("react.element"),p=Symbol.for("react.transitional.element"),b=Symbol.for("react.portal"),v=Symbol.for("react.fragment"),x=Symbol.for("react.strict_mode"),y=Symbol.for("react.profiler"),S=Symbol.for("react.consumer"),M=Symbol.for("react.context"),N=Symbol.for("react.forward_ref"),A=Symbol.for("react.suspense"),k=Symbol.for("react.suspense_list"),C=Symbol.for("react.memo"),D=Symbol.for("react.lazy"),T=Symbol.for("react.activity"),R=Symbol.for("react.memo_cache_sentinel"),U=Symbol.iterator;function L(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 j(h){if(h==null)return null;if(typeof h=="function")return h.$$typeof===q?null:h.displayName||h.name||null;if(typeof h=="string")return h;switch(h){case v:return"Fragment";case y:return"Profiler";case x:return"StrictMode";case A:return"Suspense";case k:return"SuspenseList";case T:return"Activity"}if(typeof h=="object")switch(h.$$typeof){case b:return"Portal";case M:return h.displayName||"Context";case S:return(h._context.displayName||"Context")+".Consumer";case N:var g=h.render;return h=h.displayName,h||(h=g.displayName||g.name||"",h=h!==""?"ForwardRef("+h+")":"ForwardRef"),h;case C:return g=h.displayName||null,g!==null?g:j(h.type)||"Memo";case D:g=h._payload,h=h._init;try{return j(h(g))}catch{}}return null}var W=Array.isArray,K=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,J={pending:!1,data:null,method:null,action:null},ne=[],te=-1;function z(h){return{current:h}}function H(h){0>te||(h.current=ne[te],ne[te]=null,te--)}function Z(h,g){te++,ne[te]=h.current,h.current=g}var ee=z(null),he=z(null),fe=z(null),oe=z(null);function Ne(h,g){switch(Z(fe,g),Z(he,h),Z(ee,null),g.nodeType){case 9:case 11:h=(h=g.documentElement)&&(h=h.namespaceURI)?bU(h):0;break;default:if(h=g.tagName,g=g.namespaceURI)g=bU(g),h=yU(g,h);else switch(h){case"svg":h=1;break;case"math":h=2;break;default:h=0}}H(ee),Z(ee,h)}function ge(){H(ee),H(he),H(fe)}function Se(h){h.memoizedState!==null&&Z(oe,h);var g=ee.current,_=yU(g,h.type);g!==_&&(Z(he,h),Z(ee,_))}function Re(h){he.current===h&&(H(ee),H(he)),oe.current===h&&(H(oe),Jx._currentValue=J)}var de,Qe;function G(h){if(de===void 0)try{throw Error()}catch(_){var g=_.stack.trim().match(/\n( *(at )?)/);de=g&&g[1]||"",Qe=-1<_.stack.indexOf(`
  2. at`)?" (<anonymous>)":-1<_.stack.indexOf("@")?"@unknown:0:0":""}return`
  3. `+de+h+Qe}var ie=!1;function X(h,g){if(!h||ie)return"";ie=!0;var _=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var E={DetermineComponentFrameRoot:function(){try{if(g){var _t=function(){throw Error()};if(Object.defineProperty(_t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(_t,[])}catch(ht){var ot=ht}Reflect.construct(h,[],_t)}else{try{_t.call()}catch(ht){ot=ht}h.call(_t.prototype)}}else{try{throw Error()}catch(ht){ot=ht}(_t=h())&&typeof _t.catch=="function"&&_t.catch(function(){})}}catch(ht){if(ht&&ot&&typeof ht.stack=="string")return[ht.stack,ot.stack]}return[null,null]}};E.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var P=Object.getOwnPropertyDescriptor(E.DetermineComponentFrameRoot,"name");P&&P.configurable&&Object.defineProperty(E.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var F=E.DetermineComponentFrameRoot(),Q=F[0],xe=F[1];if(Q&&xe){var Pe=Q.split(`
  4. `),at=xe.split(`
  5. `);for(P=E=0;E<Pe.length&&!Pe[E].includes("DetermineComponentFrameRoot");)E++;for(;P<at.length&&!at[P].includes("DetermineComponentFrameRoot");)P++;if(E===Pe.length||P===at.length)for(E=Pe.length-1,P=at.length-1;1<=E&&0<=P&&Pe[E]!==at[P];)P--;for(;1<=E&&0<=P;E--,P--)if(Pe[E]!==at[P]){if(E!==1||P!==1)do if(E--,P--,0>P||Pe[E]!==at[P]){var bt=`
  6. `+Pe[E].replace(" at new "," at ");return h.displayName&&bt.includes("<anonymous>")&&(bt=bt.replace("<anonymous>",h.displayName)),bt}while(1<=E&&0<=P);break}}}finally{ie=!1,Error.prepareStackTrace=_}return(_=h?h.displayName||h.name:"")?G(_):""}function $(h,g){switch(h.tag){case 26:case 27:case 5:return G(h.type);case 16:return G("Lazy");case 13:return h.child!==g&&g!==null?G("Suspense Fallback"):G("Suspense");case 19:return G("SuspenseList");case 0:case 15:return X(h.type,!1);case 11:return X(h.type.render,!1);case 1:return X(h.type,!0);case 31:return G("Activity");default:return""}}function I(h){try{var g="",_=null;do g+=$(h,_),_=h,h=h.return;while(h);return g}catch(E){return`
  7. Error generating stack: `+E.message+`
  8. `+E.stack}}var ce=Object.prototype.hasOwnProperty,Ee=t.unstable_scheduleCallback,Ie=t.unstable_cancelCallback,le=t.unstable_shouldYield,B=t.unstable_requestPaint,O=t.unstable_now,Y=t.unstable_getCurrentPriorityLevel,pe=t.unstable_ImmediatePriority,we=t.unstable_UserBlockingPriority,ae=t.unstable_NormalPriority,ke=t.unstable_LowPriority,De=t.unstable_IdlePriority,Ke=t.log,et=t.unstable_setDisableYieldValue,Ye=null,se=null;function ye(h){if(typeof Ke=="function"&&et(h),se&&typeof se.setStrictMode=="function")try{se.setStrictMode(Ye,h)}catch{}}var Ce=Math.clz32?Math.clz32:re,Ue=Math.log,dt=Math.LN2;function re(h){return h>>>=0,h===0?32:31-(Ue(h)/dt|0)|0}var Fe=256,ve=262144,$e=4194304;function Le(h){var g=h&42;if(g!==0)return g;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 Ae(h,g,_){var E=h.pendingLanes;if(E===0)return 0;var P=0,F=h.suspendedLanes,Q=h.pingedLanes;h=h.warmLanes;var xe=E&134217727;return xe!==0?(E=xe&~F,E!==0?P=Le(E):(Q&=xe,Q!==0?P=Le(Q):_||(_=xe&~h,_!==0&&(P=Le(_))))):(xe=E&~F,xe!==0?P=Le(xe):Q!==0?P=Le(Q):_||(_=E&~h,_!==0&&(P=Le(_)))),P===0?0:g!==0&&g!==P&&(g&F)===0&&(F=P&-P,_=g&-g,F>=_||F===32&&(_&4194048)!==0)?g:P}function Ge(h,g){return(h.pendingLanes&~(h.suspendedLanes&~h.pingedLanes)&g)===0}function it(h,g){switch(h){case 1:case 2:case 4:case 8:case 64:return g+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 g+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 Ot(){var h=$e;return $e<<=1,($e&62914560)===0&&($e=4194304),h}function kt(h){for(var g=[],_=0;31>_;_++)g.push(h);return g}function on(h,g){h.pendingLanes|=g,g!==268435456&&(h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0)}function Ut(h,g,_,E,P,F){var Q=h.pendingLanes;h.pendingLanes=_,h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0,h.expiredLanes&=_,h.entangledLanes&=_,h.errorRecoveryDisabledLanes&=_,h.shellSuspendCounter=0;var xe=h.entanglements,Pe=h.expirationTimes,at=h.hiddenUpdates;for(_=Q&~_;0<_;){var bt=31-Ce(_),_t=1<<bt;xe[bt]=0,Pe[bt]=-1;var ot=at[bt];if(ot!==null)for(at[bt]=null,bt=0;bt<ot.length;bt++){var ht=ot[bt];ht!==null&&(ht.lane&=-536870913)}_&=~_t}E!==0&&yn(h,E,0),F!==0&&P===0&&h.tag!==0&&(h.suspendedLanes|=F&~(Q&~g))}function yn(h,g,_){h.pendingLanes|=g,h.suspendedLanes&=~g;var E=31-Ce(g);h.entangledLanes|=g,h.entanglements[E]=h.entanglements[E]|1073741824|_&261930}function xt(h,g){var _=h.entangledLanes|=g;for(h=h.entanglements;_;){var E=31-Ce(_),P=1<<E;P&g|h[E]&g&&(h[E]|=g),_&=~P}}function Yt(h,g){var _=g&-g;return _=(_&42)!==0?1:sn(_),(_&(h.suspendedLanes|g))!==0?0:_}function sn(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 Tt(h){return h&=-h,2<h?8<h?(h&134217727)!==0?32:268435456:8:2}function Cn(){var h=V.p;return h!==0?h:(h=window.event,h===void 0?32:$U(h.type))}function Cr(h,g){var _=V.p;try{return V.p=h,g()}finally{V.p=_}}var er=Math.random().toString(36).slice(2),Un="__reactFiber$"+er,yr="__reactProps$"+er,Ci="__reactContainer$"+er,gi="__reactEvents$"+er,_e="__reactListeners$"+er,Je="__reactHandles$"+er,Ze="__reactResources$"+er,lt="__reactMarker$"+er;function st(h){delete h[Un],delete h[yr],delete h[gi],delete h[_e],delete h[Je]}function Pt(h){var g=h[Un];if(g)return g;for(var _=h.parentNode;_;){if(g=_[Ci]||_[Un]){if(_=g.alternate,g.child!==null||_!==null&&_.child!==null)for(h=NU(h);h!==null;){if(_=h[Un])return _;h=NU(h)}return g}h=_,_=h.parentNode}return null}function Bt(h){if(h=h[Un]||h[Ci]){var g=h.tag;if(g===5||g===6||g===13||g===31||g===26||g===27||g===3)return h}return null}function Ht(h){var g=h.tag;if(g===5||g===26||g===27||g===6)return h.stateNode;throw Error(r(33))}function Jt(h){var g=h[Ze];return g||(g=h[Ze]={hoistableStyles:new Map,hoistableScripts:new Map}),g}function ue(h){h[lt]=!0}var je=new Set,Ve={};function We(h,g){He(h,g),He(h+"Capture",g)}function He(h,g){for(Ve[h]=g,h=0;h<g.length;h++)je.add(g[h])}var wt=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]*$"),Dt={},Et={};function St(h){return ce.call(Et,h)?!0:ce.call(Dt,h)?!1:wt.test(h)?Et[h]=!0:(Dt[h]=!0,!1)}function Mt(h,g,_){if(St(g))if(_===null)h.removeAttribute(g);else{switch(typeof _){case"undefined":case"function":case"symbol":h.removeAttribute(g);return;case"boolean":var E=g.toLowerCase().slice(0,5);if(E!=="data-"&&E!=="aria-"){h.removeAttribute(g);return}}h.setAttribute(g,""+_)}}function Oe(h,g,_){if(_===null)h.removeAttribute(g);else{switch(typeof _){case"undefined":case"function":case"symbol":case"boolean":h.removeAttribute(g);return}h.setAttribute(g,""+_)}}function gt(h,g,_,E){if(E===null)h.removeAttribute(_);else{switch(typeof E){case"undefined":case"function":case"symbol":case"boolean":h.removeAttribute(_);return}h.setAttributeNS(g,_,""+E)}}function Rt(h){switch(typeof h){case"bigint":case"boolean":case"number":case"string":case"undefined":return h;case"object":return h;default:return""}}function ct(h){var g=h.type;return(h=h.nodeName)&&h.toLowerCase()==="input"&&(g==="checkbox"||g==="radio")}function Zt(h,g,_){var E=Object.getOwnPropertyDescriptor(h.constructor.prototype,g);if(!h.hasOwnProperty(g)&&typeof E<"u"&&typeof E.get=="function"&&typeof E.set=="function"){var P=E.get,F=E.set;return Object.defineProperty(h,g,{configurable:!0,get:function(){return P.call(this)},set:function(Q){_=""+Q,F.call(this,Q)}}),Object.defineProperty(h,g,{enumerable:E.enumerable}),{getValue:function(){return _},setValue:function(Q){_=""+Q},stopTracking:function(){h._valueTracker=null,delete h[g]}}}}function Kt(h){if(!h._valueTracker){var g=ct(h)?"checked":"value";h._valueTracker=Zt(h,g,""+h[g])}}function be(h){if(!h)return!1;var g=h._valueTracker;if(!g)return!0;var _=g.getValue(),E="";return h&&(E=ct(h)?h.checked?"true":"false":h.value),h=E,h!==_?(g.setValue(h),!0):!1}function ut(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 It=/[\n"\\]/g;function yt(h){return h.replace(It,function(g){return"\\"+g.charCodeAt(0).toString(16)+" "})}function Xt(h,g,_,E,P,F,Q,xe){h.name="",Q!=null&&typeof Q!="function"&&typeof Q!="symbol"&&typeof Q!="boolean"?h.type=Q:h.removeAttribute("type"),g!=null?Q==="number"?(g===0&&h.value===""||h.value!=g)&&(h.value=""+Rt(g)):h.value!==""+Rt(g)&&(h.value=""+Rt(g)):Q!=="submit"&&Q!=="reset"||h.removeAttribute("value"),g!=null?cn(h,Q,Rt(g)):_!=null?cn(h,Q,Rt(_)):E!=null&&h.removeAttribute("value"),P==null&&F!=null&&(h.defaultChecked=!!F),P!=null&&(h.checked=P&&typeof P!="function"&&typeof P!="symbol"),xe!=null&&typeof xe!="function"&&typeof xe!="symbol"&&typeof xe!="boolean"?h.name=""+Rt(xe):h.removeAttribute("name")}function tr(h,g,_,E,P,F,Q,xe){if(F!=null&&typeof F!="function"&&typeof F!="symbol"&&typeof F!="boolean"&&(h.type=F),g!=null||_!=null){if(!(F!=="submit"&&F!=="reset"||g!=null)){Kt(h);return}_=_!=null?""+Rt(_):"",g=g!=null?""+Rt(g):_,xe||g===h.value||(h.value=g),h.defaultValue=g}E=E??P,E=typeof E!="function"&&typeof E!="symbol"&&!!E,h.checked=xe?h.checked:!!E,h.defaultChecked=!!E,Q!=null&&typeof Q!="function"&&typeof Q!="symbol"&&typeof Q!="boolean"&&(h.name=Q),Kt(h)}function cn(h,g,_){g==="number"&&ut(h.ownerDocument)===h||h.defaultValue===""+_||(h.defaultValue=""+_)}function ki(h,g,_,E){if(h=h.options,g){g={};for(var P=0;P<_.length;P++)g["$"+_[P]]=!0;for(_=0;_<h.length;_++)P=g.hasOwnProperty("$"+h[_].value),h[_].selected!==P&&(h[_].selected=P),P&&E&&(h[_].defaultSelected=!0)}else{for(_=""+Rt(_),g=null,P=0;P<h.length;P++){if(h[P].value===_){h[P].selected=!0,E&&(h[P].defaultSelected=!0);return}g!==null||h[P].disabled||(g=h[P])}g!==null&&(g.selected=!0)}}function $n(h,g,_){if(g!=null&&(g=""+Rt(g),g!==h.value&&(h.value=g),_==null)){h.defaultValue!==g&&(h.defaultValue=g);return}h.defaultValue=_!=null?""+Rt(_):""}function ui(h,g,_,E){if(g==null){if(E!=null){if(_!=null)throw Error(r(92));if(W(E)){if(1<E.length)throw Error(r(93));E=E[0]}_=E}_==null&&(_=""),g=_}_=Rt(g),h.defaultValue=_,E=h.textContent,E===_&&E!==""&&E!==null&&(h.value=E),Kt(h)}function vr(h,g){if(g){var _=h.firstChild;if(_&&_===h.lastChild&&_.nodeType===3){_.nodeValue=g;return}}h.textContent=g}var Zn=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 kr(h,g,_){var E=g.indexOf("--")===0;_==null||typeof _=="boolean"||_===""?E?h.setProperty(g,""):g==="float"?h.cssFloat="":h[g]="":E?h.setProperty(g,_):typeof _!="number"||_===0||Zn.has(g)?g==="float"?h.cssFloat=_:h[g]=(""+_).trim():h[g]=_+"px"}function to(h,g,_){if(g!=null&&typeof g!="object")throw Error(r(62));if(h=h.style,_!=null){for(var E in _)!_.hasOwnProperty(E)||g!=null&&g.hasOwnProperty(E)||(E.indexOf("--")===0?h.setProperty(E,""):E==="float"?h.cssFloat="":h[E]="");for(var P in g)E=g[P],g.hasOwnProperty(P)&&_[P]!==E&&kr(h,P,E)}else for(var F in g)g.hasOwnProperty(F)&&kr(h,F,g[F])}function jr(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 Wie=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"]]),qie=/^[\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 ev(h){return qie.test(""+h)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":h}function fc(){}var zN=null;function BN(h){return h=h.target||h.srcElement||window,h.correspondingUseElement&&(h=h.correspondingUseElement),h.nodeType===3?h.parentNode:h}var pm=null,gm=null;function xI(h){var g=Bt(h);if(g&&(h=g.stateNode)){var _=h[yr]||null;e:switch(h=g.stateNode,g.type){case"input":if(Xt(h,_.value,_.defaultValue,_.defaultValue,_.checked,_.defaultChecked,_.type,_.name),g=_.name,_.type==="radio"&&g!=null){for(_=h;_.parentNode;)_=_.parentNode;for(_=_.querySelectorAll('input[name="'+yt(""+g)+'"][type="radio"]'),g=0;g<_.length;g++){var E=_[g];if(E!==h&&E.form===h.form){var P=E[yr]||null;if(!P)throw Error(r(90));Xt(E,P.value,P.defaultValue,P.defaultValue,P.checked,P.defaultChecked,P.type,P.name)}}for(g=0;g<_.length;g++)E=_[g],E.form===h.form&&be(E)}break e;case"textarea":$n(h,_.value,_.defaultValue);break e;case"select":g=_.value,g!=null&&ki(h,!!_.multiple,g,!1)}}}var $N=!1;function bI(h,g,_){if($N)return h(g,_);$N=!0;try{var E=h(g);return E}finally{if($N=!1,(pm!==null||gm!==null)&&(Bv(),pm&&(g=pm,h=gm,gm=pm=null,xI(g),h)))for(g=0;g<h.length;g++)xI(h[g])}}function gx(h,g){var _=h.stateNode;if(_===null)return null;var E=_[yr]||null;if(E===null)return null;_=E[g];e:switch(g){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(E=!E.disabled)||(h=h.type,E=!(h==="button"||h==="input"||h==="select"||h==="textarea")),h=!E;break e;default:h=!1}if(h)return null;if(_&&typeof _!="function")throw Error(r(231,g,typeof _));return _}var mc=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),HN=!1;if(mc)try{var xx={};Object.defineProperty(xx,"passive",{get:function(){HN=!0}}),window.addEventListener("test",xx,xx),window.removeEventListener("test",xx,xx)}catch{HN=!1}var Cu=null,VN=null,tv=null;function yI(){if(tv)return tv;var h,g=VN,_=g.length,E,P="value"in Cu?Cu.value:Cu.textContent,F=P.length;for(h=0;h<_&&g[h]===P[h];h++);var Q=_-h;for(E=1;E<=Q&&g[_-E]===P[F-E];E++);return tv=P.slice(h,1<E?1-E:void 0)}function nv(h){var g=h.keyCode;return"charCode"in h?(h=h.charCode,h===0&&g===13&&(h=13)):h=g,h===10&&(h=13),32<=h||h===13?h:0}function rv(){return!0}function vI(){return!1}function ss(h){function g(_,E,P,F,Q){this._reactName=_,this._targetInst=P,this.type=E,this.nativeEvent=F,this.target=Q,this.currentTarget=null;for(var xe in h)h.hasOwnProperty(xe)&&(_=h[xe],this[xe]=_?_(F):F[xe]);return this.isDefaultPrevented=(F.defaultPrevented!=null?F.defaultPrevented:F.returnValue===!1)?rv:vI,this.isPropagationStopped=vI,this}return f(g.prototype,{preventDefault:function(){this.defaultPrevented=!0;var _=this.nativeEvent;_&&(_.preventDefault?_.preventDefault():typeof _.returnValue!="unknown"&&(_.returnValue=!1),this.isDefaultPrevented=rv)},stopPropagation:function(){var _=this.nativeEvent;_&&(_.stopPropagation?_.stopPropagation():typeof _.cancelBubble!="unknown"&&(_.cancelBubble=!0),this.isPropagationStopped=rv)},persist:function(){},isPersistent:rv}),g}var yh={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(h){return h.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},iv=ss(yh),bx=f({},yh,{view:0,detail:0}),Kie=ss(bx),GN,WN,yx,av=f({},bx,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:KN,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!==yx&&(yx&&h.type==="mousemove"?(GN=h.screenX-yx.screenX,WN=h.screenY-yx.screenY):WN=GN=0,yx=h),GN)},movementY:function(h){return"movementY"in h?h.movementY:WN}}),_I=ss(av),Xie=f({},av,{dataTransfer:0}),Yie=ss(Xie),Zie=f({},bx,{relatedTarget:0}),qN=ss(Zie),Qie=f({},yh,{animationName:0,elapsedTime:0,pseudoElement:0}),Jie=ss(Qie),eae=f({},yh,{clipboardData:function(h){return"clipboardData"in h?h.clipboardData:window.clipboardData}}),tae=ss(eae),nae=f({},yh,{data:0}),wI=ss(nae),rae={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},iae={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"},aae={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function sae(h){var g=this.nativeEvent;return g.getModifierState?g.getModifierState(h):(h=aae[h])?!!g[h]:!1}function KN(){return sae}var oae=f({},bx,{key:function(h){if(h.key){var g=rae[h.key]||h.key;if(g!=="Unidentified")return g}return h.type==="keypress"?(h=nv(h),h===13?"Enter":String.fromCharCode(h)):h.type==="keydown"||h.type==="keyup"?iae[h.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:KN,charCode:function(h){return h.type==="keypress"?nv(h):0},keyCode:function(h){return h.type==="keydown"||h.type==="keyup"?h.keyCode:0},which:function(h){return h.type==="keypress"?nv(h):h.type==="keydown"||h.type==="keyup"?h.keyCode:0}}),lae=ss(oae),cae=f({},av,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),SI=ss(cae),uae=f({},bx,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:KN}),dae=ss(uae),hae=f({},yh,{propertyName:0,elapsedTime:0,pseudoElement:0}),fae=ss(hae),mae=f({},av,{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}),pae=ss(mae),gae=f({},yh,{newState:0,oldState:0}),xae=ss(gae),bae=[9,13,27,32],XN=mc&&"CompositionEvent"in window,vx=null;mc&&"documentMode"in document&&(vx=document.documentMode);var yae=mc&&"TextEvent"in window&&!vx,MI=mc&&(!XN||vx&&8<vx&&11>=vx),EI=" ",NI=!1;function AI(h,g){switch(h){case"keyup":return bae.indexOf(g.keyCode)!==-1;case"keydown":return g.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function TI(h){return h=h.detail,typeof h=="object"&&"data"in h?h.data:null}var xm=!1;function vae(h,g){switch(h){case"compositionend":return TI(g);case"keypress":return g.which!==32?null:(NI=!0,EI);case"textInput":return h=g.data,h===EI&&NI?null:h;default:return null}}function _ae(h,g){if(xm)return h==="compositionend"||!XN&&AI(h,g)?(h=yI(),tv=VN=Cu=null,xm=!1,h):null;switch(h){case"paste":return null;case"keypress":if(!(g.ctrlKey||g.altKey||g.metaKey)||g.ctrlKey&&g.altKey){if(g.char&&1<g.char.length)return g.char;if(g.which)return String.fromCharCode(g.which)}return null;case"compositionend":return MI&&g.locale!=="ko"?null:g.data;default:return null}}var wae={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 CI(h){var g=h&&h.nodeName&&h.nodeName.toLowerCase();return g==="input"?!!wae[h.type]:g==="textarea"}function kI(h,g,_,E){pm?gm?gm.push(E):gm=[E]:pm=E,g=Kv(g,"onChange"),0<g.length&&(_=new iv("onChange","change",null,_,E),h.push({event:_,listeners:g}))}var _x=null,wx=null;function Sae(h){hU(h,0)}function sv(h){var g=Ht(h);if(be(g))return h}function jI(h,g){if(h==="change")return g}var PI=!1;if(mc){var YN;if(mc){var ZN="oninput"in document;if(!ZN){var RI=document.createElement("div");RI.setAttribute("oninput","return;"),ZN=typeof RI.oninput=="function"}YN=ZN}else YN=!1;PI=YN&&(!document.documentMode||9<document.documentMode)}function DI(){_x&&(_x.detachEvent("onpropertychange",OI),wx=_x=null)}function OI(h){if(h.propertyName==="value"&&sv(wx)){var g=[];kI(g,wx,h,BN(h)),bI(Sae,g)}}function Mae(h,g,_){h==="focusin"?(DI(),_x=g,wx=_,_x.attachEvent("onpropertychange",OI)):h==="focusout"&&DI()}function Eae(h){if(h==="selectionchange"||h==="keyup"||h==="keydown")return sv(wx)}function Nae(h,g){if(h==="click")return sv(g)}function Aae(h,g){if(h==="input"||h==="change")return sv(g)}function Tae(h,g){return h===g&&(h!==0||1/h===1/g)||h!==h&&g!==g}var Cs=typeof Object.is=="function"?Object.is:Tae;function Sx(h,g){if(Cs(h,g))return!0;if(typeof h!="object"||h===null||typeof g!="object"||g===null)return!1;var _=Object.keys(h),E=Object.keys(g);if(_.length!==E.length)return!1;for(E=0;E<_.length;E++){var P=_[E];if(!ce.call(g,P)||!Cs(h[P],g[P]))return!1}return!0}function LI(h){for(;h&&h.firstChild;)h=h.firstChild;return h}function II(h,g){var _=LI(h);h=0;for(var E;_;){if(_.nodeType===3){if(E=h+_.textContent.length,h<=g&&E>=g)return{node:_,offset:g-h};h=E}e:{for(;_;){if(_.nextSibling){_=_.nextSibling;break e}_=_.parentNode}_=void 0}_=LI(_)}}function FI(h,g){return h&&g?h===g?!0:h&&h.nodeType===3?!1:g&&g.nodeType===3?FI(h,g.parentNode):"contains"in h?h.contains(g):h.compareDocumentPosition?!!(h.compareDocumentPosition(g)&16):!1:!1}function UI(h){h=h!=null&&h.ownerDocument!=null&&h.ownerDocument.defaultView!=null?h.ownerDocument.defaultView:window;for(var g=ut(h.document);g instanceof h.HTMLIFrameElement;){try{var _=typeof g.contentWindow.location.href=="string"}catch{_=!1}if(_)h=g.contentWindow;else break;g=ut(h.document)}return g}function QN(h){var g=h&&h.nodeName&&h.nodeName.toLowerCase();return g&&(g==="input"&&(h.type==="text"||h.type==="search"||h.type==="tel"||h.type==="url"||h.type==="password")||g==="textarea"||h.contentEditable==="true")}var Cae=mc&&"documentMode"in document&&11>=document.documentMode,bm=null,JN=null,Mx=null,e2=!1;function zI(h,g,_){var E=_.window===_?_.document:_.nodeType===9?_:_.ownerDocument;e2||bm==null||bm!==ut(E)||(E=bm,"selectionStart"in E&&QN(E)?E={start:E.selectionStart,end:E.selectionEnd}:(E=(E.ownerDocument&&E.ownerDocument.defaultView||window).getSelection(),E={anchorNode:E.anchorNode,anchorOffset:E.anchorOffset,focusNode:E.focusNode,focusOffset:E.focusOffset}),Mx&&Sx(Mx,E)||(Mx=E,E=Kv(JN,"onSelect"),0<E.length&&(g=new iv("onSelect","select",null,g,_),h.push({event:g,listeners:E}),g.target=bm)))}function vh(h,g){var _={};return _[h.toLowerCase()]=g.toLowerCase(),_["Webkit"+h]="webkit"+g,_["Moz"+h]="moz"+g,_}var ym={animationend:vh("Animation","AnimationEnd"),animationiteration:vh("Animation","AnimationIteration"),animationstart:vh("Animation","AnimationStart"),transitionrun:vh("Transition","TransitionRun"),transitionstart:vh("Transition","TransitionStart"),transitioncancel:vh("Transition","TransitionCancel"),transitionend:vh("Transition","TransitionEnd")},t2={},BI={};mc&&(BI=document.createElement("div").style,"AnimationEvent"in window||(delete ym.animationend.animation,delete ym.animationiteration.animation,delete ym.animationstart.animation),"TransitionEvent"in window||delete ym.transitionend.transition);function _h(h){if(t2[h])return t2[h];if(!ym[h])return h;var g=ym[h],_;for(_ in g)if(g.hasOwnProperty(_)&&_ in BI)return t2[h]=g[_];return h}var $I=_h("animationend"),HI=_h("animationiteration"),VI=_h("animationstart"),kae=_h("transitionrun"),jae=_h("transitionstart"),Pae=_h("transitioncancel"),GI=_h("transitionend"),WI=new Map,n2="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(" ");n2.push("scrollEnd");function Uo(h,g){WI.set(h,g),We(g,[h])}var ov=typeof reportError=="function"?reportError:function(h){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var g=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(g))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",h);return}console.error(h)},no=[],vm=0,r2=0;function lv(){for(var h=vm,g=r2=vm=0;g<h;){var _=no[g];no[g++]=null;var E=no[g];no[g++]=null;var P=no[g];no[g++]=null;var F=no[g];if(no[g++]=null,E!==null&&P!==null){var Q=E.pending;Q===null?P.next=P:(P.next=Q.next,Q.next=P),E.pending=P}F!==0&&qI(_,P,F)}}function cv(h,g,_,E){no[vm++]=h,no[vm++]=g,no[vm++]=_,no[vm++]=E,r2|=E,h.lanes|=E,h=h.alternate,h!==null&&(h.lanes|=E)}function i2(h,g,_,E){return cv(h,g,_,E),uv(h)}function wh(h,g){return cv(h,null,null,g),uv(h)}function qI(h,g,_){h.lanes|=_;var E=h.alternate;E!==null&&(E.lanes|=_);for(var P=!1,F=h.return;F!==null;)F.childLanes|=_,E=F.alternate,E!==null&&(E.childLanes|=_),F.tag===22&&(h=F.stateNode,h===null||h._visibility&1||(P=!0)),h=F,F=F.return;return h.tag===3?(F=h.stateNode,P&&g!==null&&(P=31-Ce(_),h=F.hiddenUpdates,E=h[P],E===null?h[P]=[g]:E.push(g),g.lane=_|536870912),F):null}function uv(h){if(50<Wx)throw Wx=0,fA=null,Error(r(185));for(var g=h.return;g!==null;)h=g,g=h.return;return h.tag===3?h.stateNode:null}var _m={};function Rae(h,g,_,E){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=g,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=E,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ks(h,g,_,E){return new Rae(h,g,_,E)}function a2(h){return h=h.prototype,!(!h||!h.isReactComponent)}function pc(h,g){var _=h.alternate;return _===null?(_=ks(h.tag,g,h.key,h.mode),_.elementType=h.elementType,_.type=h.type,_.stateNode=h.stateNode,_.alternate=h,h.alternate=_):(_.pendingProps=g,_.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,g=h.dependencies,_.dependencies=g===null?null:{lanes:g.lanes,firstContext:g.firstContext},_.sibling=h.sibling,_.index=h.index,_.ref=h.ref,_.refCleanup=h.refCleanup,_}function KI(h,g){h.flags&=65011714;var _=h.alternate;return _===null?(h.childLanes=0,h.lanes=g,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,g=_.dependencies,h.dependencies=g===null?null:{lanes:g.lanes,firstContext:g.firstContext}),h}function dv(h,g,_,E,P,F){var Q=0;if(E=h,typeof h=="function")a2(h)&&(Q=1);else if(typeof h=="string")Q=Fse(h,_,ee.current)?26:h==="html"||h==="head"||h==="body"?27:5;else e:switch(h){case T:return h=ks(31,_,g,P),h.elementType=T,h.lanes=F,h;case v:return Sh(_.children,P,F,g);case x:Q=8,P|=24;break;case y:return h=ks(12,_,g,P|2),h.elementType=y,h.lanes=F,h;case A:return h=ks(13,_,g,P),h.elementType=A,h.lanes=F,h;case k:return h=ks(19,_,g,P),h.elementType=k,h.lanes=F,h;default:if(typeof h=="object"&&h!==null)switch(h.$$typeof){case M:Q=10;break e;case S:Q=9;break e;case N:Q=11;break e;case C:Q=14;break e;case D:Q=16,E=null;break e}Q=29,_=Error(r(130,h===null?"null":typeof h,"")),E=null}return g=ks(Q,_,g,P),g.elementType=h,g.type=E,g.lanes=F,g}function Sh(h,g,_,E){return h=ks(7,h,E,g),h.lanes=_,h}function s2(h,g,_){return h=ks(6,h,null,g),h.lanes=_,h}function XI(h){var g=ks(18,null,null,0);return g.stateNode=h,g}function o2(h,g,_){return g=ks(4,h.children!==null?h.children:[],h.key,g),g.lanes=_,g.stateNode={containerInfo:h.containerInfo,pendingChildren:null,implementation:h.implementation},g}var YI=new WeakMap;function ro(h,g){if(typeof h=="object"&&h!==null){var _=YI.get(h);return _!==void 0?_:(g={value:h,source:g,stack:I(g)},YI.set(h,g),g)}return{value:h,source:g,stack:I(g)}}var wm=[],Sm=0,hv=null,Ex=0,io=[],ao=0,ku=null,vl=1,_l="";function gc(h,g){wm[Sm++]=Ex,wm[Sm++]=hv,hv=h,Ex=g}function ZI(h,g,_){io[ao++]=vl,io[ao++]=_l,io[ao++]=ku,ku=h;var E=vl;h=_l;var P=32-Ce(E)-1;E&=~(1<<P),_+=1;var F=32-Ce(g)+P;if(30<F){var Q=P-P%5;F=(E&(1<<Q)-1).toString(32),E>>=Q,P-=Q,vl=1<<32-Ce(g)+P|_<<P|E,_l=F+h}else vl=1<<F|_<<P|E,_l=h}function l2(h){h.return!==null&&(gc(h,1),ZI(h,1,0))}function c2(h){for(;h===hv;)hv=wm[--Sm],wm[Sm]=null,Ex=wm[--Sm],wm[Sm]=null;for(;h===ku;)ku=io[--ao],io[ao]=null,_l=io[--ao],io[ao]=null,vl=io[--ao],io[ao]=null}function QI(h,g){io[ao++]=vl,io[ao++]=_l,io[ao++]=ku,vl=g.id,_l=g.overflow,ku=h}var la=null,Pr=null,Ln=!1,ju=null,so=!1,u2=Error(r(519));function Pu(h){var g=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Nx(ro(g,h)),u2}function JI(h){var g=h.stateNode,_=h.type,E=h.memoizedProps;switch(g[Un]=h,g[yr]=E,_){case"dialog":jn("cancel",g),jn("close",g);break;case"iframe":case"object":case"embed":jn("load",g);break;case"video":case"audio":for(_=0;_<Kx.length;_++)jn(Kx[_],g);break;case"source":jn("error",g);break;case"img":case"image":case"link":jn("error",g),jn("load",g);break;case"details":jn("toggle",g);break;case"input":jn("invalid",g),tr(g,E.value,E.defaultValue,E.checked,E.defaultChecked,E.type,E.name,!0);break;case"select":jn("invalid",g);break;case"textarea":jn("invalid",g),ui(g,E.value,E.defaultValue,E.children)}_=E.children,typeof _!="string"&&typeof _!="number"&&typeof _!="bigint"||g.textContent===""+_||E.suppressHydrationWarning===!0||gU(g.textContent,_)?(E.popover!=null&&(jn("beforetoggle",g),jn("toggle",g)),E.onScroll!=null&&jn("scroll",g),E.onScrollEnd!=null&&jn("scrollend",g),E.onClick!=null&&(g.onclick=fc),g=!0):g=!1,g||Pu(h,!0)}function eF(h){for(la=h.return;la;)switch(la.tag){case 5:case 31:case 13:so=!1;return;case 27:case 3:so=!0;return;default:la=la.return}}function Mm(h){if(h!==la)return!1;if(!Ln)return eF(h),Ln=!0,!1;var g=h.tag,_;if((_=g!==3&&g!==27)&&((_=g===5)&&(_=h.type,_=!(_!=="form"&&_!=="button")||TA(h.type,h.memoizedProps)),_=!_),_&&Pr&&Pu(h),eF(h),g===13){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));Pr=EU(h)}else if(g===31){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));Pr=EU(h)}else g===27?(g=Pr,Wu(h.type)?(h=RA,RA=null,Pr=h):Pr=g):Pr=la?lo(h.stateNode.nextSibling):null;return!0}function Mh(){Pr=la=null,Ln=!1}function d2(){var h=ju;return h!==null&&(ds===null?ds=h:ds.push.apply(ds,h),ju=null),h}function Nx(h){ju===null?ju=[h]:ju.push(h)}var h2=z(null),Eh=null,xc=null;function Ru(h,g,_){Z(h2,g._currentValue),g._currentValue=_}function bc(h){h._currentValue=h2.current,H(h2)}function f2(h,g,_){for(;h!==null;){var E=h.alternate;if((h.childLanes&g)!==g?(h.childLanes|=g,E!==null&&(E.childLanes|=g)):E!==null&&(E.childLanes&g)!==g&&(E.childLanes|=g),h===_)break;h=h.return}}function m2(h,g,_,E){var P=h.child;for(P!==null&&(P.return=h);P!==null;){var F=P.dependencies;if(F!==null){var Q=P.child;F=F.firstContext;e:for(;F!==null;){var xe=F;F=P;for(var Pe=0;Pe<g.length;Pe++)if(xe.context===g[Pe]){F.lanes|=_,xe=F.alternate,xe!==null&&(xe.lanes|=_),f2(F.return,_,h),E||(Q=null);break e}F=xe.next}}else if(P.tag===18){if(Q=P.return,Q===null)throw Error(r(341));Q.lanes|=_,F=Q.alternate,F!==null&&(F.lanes|=_),f2(Q,_,h),Q=null}else Q=P.child;if(Q!==null)Q.return=P;else for(Q=P;Q!==null;){if(Q===h){Q=null;break}if(P=Q.sibling,P!==null){P.return=Q.return,Q=P;break}Q=Q.return}P=Q}}function Em(h,g,_,E){h=null;for(var P=g,F=!1;P!==null;){if(!F){if((P.flags&524288)!==0)F=!0;else if((P.flags&262144)!==0)break}if(P.tag===10){var Q=P.alternate;if(Q===null)throw Error(r(387));if(Q=Q.memoizedProps,Q!==null){var xe=P.type;Cs(P.pendingProps.value,Q.value)||(h!==null?h.push(xe):h=[xe])}}else if(P===oe.current){if(Q=P.alternate,Q===null)throw Error(r(387));Q.memoizedState.memoizedState!==P.memoizedState.memoizedState&&(h!==null?h.push(Jx):h=[Jx])}P=P.return}h!==null&&m2(g,h,_,E),g.flags|=262144}function fv(h){for(h=h.firstContext;h!==null;){if(!Cs(h.context._currentValue,h.memoizedValue))return!0;h=h.next}return!1}function Nh(h){Eh=h,xc=null,h=h.dependencies,h!==null&&(h.firstContext=null)}function ca(h){return tF(Eh,h)}function mv(h,g){return Eh===null&&Nh(h),tF(h,g)}function tF(h,g){var _=g._currentValue;if(g={context:g,memoizedValue:_,next:null},xc===null){if(h===null)throw Error(r(308));xc=g,h.dependencies={lanes:0,firstContext:g},h.flags|=524288}else xc=xc.next=g;return _}var Dae=typeof AbortController<"u"?AbortController:function(){var h=[],g=this.signal={aborted:!1,addEventListener:function(_,E){h.push(E)}};this.abort=function(){g.aborted=!0,h.forEach(function(_){return _()})}},Oae=t.unstable_scheduleCallback,Lae=t.unstable_NormalPriority,xi={$$typeof:M,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function p2(){return{controller:new Dae,data:new Map,refCount:0}}function Ax(h){h.refCount--,h.refCount===0&&Oae(Lae,function(){h.controller.abort()})}var Tx=null,g2=0,Nm=0,Am=null;function Iae(h,g){if(Tx===null){var _=Tx=[];g2=0,Nm=yA(),Am={status:"pending",value:void 0,then:function(E){_.push(E)}}}return g2++,g.then(nF,nF),g}function nF(){if(--g2===0&&Tx!==null){Am!==null&&(Am.status="fulfilled");var h=Tx;Tx=null,Nm=0,Am=null;for(var g=0;g<h.length;g++)(0,h[g])()}}function Fae(h,g){var _=[],E={status:"pending",value:null,reason:null,then:function(P){_.push(P)}};return h.then(function(){E.status="fulfilled",E.value=g;for(var P=0;P<_.length;P++)(0,_[P])(g)},function(P){for(E.status="rejected",E.reason=P,P=0;P<_.length;P++)(0,_[P])(void 0)}),E}var rF=K.S;K.S=function(h,g){z5=O(),typeof g=="object"&&g!==null&&typeof g.then=="function"&&Iae(h,g),rF!==null&&rF(h,g)};var Ah=z(null);function x2(){var h=Ah.current;return h!==null?h:_r.pooledCache}function pv(h,g){g===null?Z(Ah,Ah.current):Z(Ah,g.pool)}function iF(){var h=x2();return h===null?null:{parent:xi._currentValue,pool:h}}var Tm=Error(r(460)),b2=Error(r(474)),gv=Error(r(542)),xv={then:function(){}};function aF(h){return h=h.status,h==="fulfilled"||h==="rejected"}function sF(h,g,_){switch(_=h[_],_===void 0?h.push(g):_!==g&&(g.then(fc,fc),g=_),g.status){case"fulfilled":return g.value;case"rejected":throw h=g.reason,lF(h),h;default:if(typeof g.status=="string")g.then(fc,fc);else{if(h=_r,h!==null&&100<h.shellSuspendCounter)throw Error(r(482));h=g,h.status="pending",h.then(function(E){if(g.status==="pending"){var P=g;P.status="fulfilled",P.value=E}},function(E){if(g.status==="pending"){var P=g;P.status="rejected",P.reason=E}})}switch(g.status){case"fulfilled":return g.value;case"rejected":throw h=g.reason,lF(h),h}throw Ch=g,Tm}}function Th(h){try{var g=h._init;return g(h._payload)}catch(_){throw _!==null&&typeof _=="object"&&typeof _.then=="function"?(Ch=_,Tm):_}}var Ch=null;function oF(){if(Ch===null)throw Error(r(459));var h=Ch;return Ch=null,h}function lF(h){if(h===Tm||h===gv)throw Error(r(483))}var Cm=null,Cx=0;function bv(h){var g=Cx;return Cx+=1,Cm===null&&(Cm=[]),sF(Cm,h,g)}function kx(h,g){g=g.props.ref,h.ref=g!==void 0?g:null}function yv(h,g){throw g.$$typeof===m?Error(r(525)):(h=Object.prototype.toString.call(g),Error(r(31,h==="[object Object]"?"object with keys {"+Object.keys(g).join(", ")+"}":h)))}function cF(h){function g(Xe,ze){if(h){var rt=Xe.deletions;rt===null?(Xe.deletions=[ze],Xe.flags|=16):rt.push(ze)}}function _(Xe,ze){if(!h)return null;for(;ze!==null;)g(Xe,ze),ze=ze.sibling;return null}function E(Xe){for(var ze=new Map;Xe!==null;)Xe.key!==null?ze.set(Xe.key,Xe):ze.set(Xe.index,Xe),Xe=Xe.sibling;return ze}function P(Xe,ze){return Xe=pc(Xe,ze),Xe.index=0,Xe.sibling=null,Xe}function F(Xe,ze,rt){return Xe.index=rt,h?(rt=Xe.alternate,rt!==null?(rt=rt.index,rt<ze?(Xe.flags|=67108866,ze):rt):(Xe.flags|=67108866,ze)):(Xe.flags|=1048576,ze)}function Q(Xe){return h&&Xe.alternate===null&&(Xe.flags|=67108866),Xe}function xe(Xe,ze,rt,vt){return ze===null||ze.tag!==6?(ze=s2(rt,Xe.mode,vt),ze.return=Xe,ze):(ze=P(ze,rt),ze.return=Xe,ze)}function Pe(Xe,ze,rt,vt){var tn=rt.type;return tn===v?bt(Xe,ze,rt.props.children,vt,rt.key):ze!==null&&(ze.elementType===tn||typeof tn=="object"&&tn!==null&&tn.$$typeof===D&&Th(tn)===ze.type)?(ze=P(ze,rt.props),kx(ze,rt),ze.return=Xe,ze):(ze=dv(rt.type,rt.key,rt.props,null,Xe.mode,vt),kx(ze,rt),ze.return=Xe,ze)}function at(Xe,ze,rt,vt){return ze===null||ze.tag!==4||ze.stateNode.containerInfo!==rt.containerInfo||ze.stateNode.implementation!==rt.implementation?(ze=o2(rt,Xe.mode,vt),ze.return=Xe,ze):(ze=P(ze,rt.children||[]),ze.return=Xe,ze)}function bt(Xe,ze,rt,vt,tn){return ze===null||ze.tag!==7?(ze=Sh(rt,Xe.mode,vt,tn),ze.return=Xe,ze):(ze=P(ze,rt),ze.return=Xe,ze)}function _t(Xe,ze,rt){if(typeof ze=="string"&&ze!==""||typeof ze=="number"||typeof ze=="bigint")return ze=s2(""+ze,Xe.mode,rt),ze.return=Xe,ze;if(typeof ze=="object"&&ze!==null){switch(ze.$$typeof){case p:return rt=dv(ze.type,ze.key,ze.props,null,Xe.mode,rt),kx(rt,ze),rt.return=Xe,rt;case b:return ze=o2(ze,Xe.mode,rt),ze.return=Xe,ze;case D:return ze=Th(ze),_t(Xe,ze,rt)}if(W(ze)||L(ze))return ze=Sh(ze,Xe.mode,rt,null),ze.return=Xe,ze;if(typeof ze.then=="function")return _t(Xe,bv(ze),rt);if(ze.$$typeof===M)return _t(Xe,mv(Xe,ze),rt);yv(Xe,ze)}return null}function ot(Xe,ze,rt,vt){var tn=ze!==null?ze.key:null;if(typeof rt=="string"&&rt!==""||typeof rt=="number"||typeof rt=="bigint")return tn!==null?null:xe(Xe,ze,""+rt,vt);if(typeof rt=="object"&&rt!==null){switch(rt.$$typeof){case p:return rt.key===tn?Pe(Xe,ze,rt,vt):null;case b:return rt.key===tn?at(Xe,ze,rt,vt):null;case D:return rt=Th(rt),ot(Xe,ze,rt,vt)}if(W(rt)||L(rt))return tn!==null?null:bt(Xe,ze,rt,vt,null);if(typeof rt.then=="function")return ot(Xe,ze,bv(rt),vt);if(rt.$$typeof===M)return ot(Xe,ze,mv(Xe,rt),vt);yv(Xe,rt)}return null}function ht(Xe,ze,rt,vt,tn){if(typeof vt=="string"&&vt!==""||typeof vt=="number"||typeof vt=="bigint")return Xe=Xe.get(rt)||null,xe(ze,Xe,""+vt,tn);if(typeof vt=="object"&&vt!==null){switch(vt.$$typeof){case p:return Xe=Xe.get(vt.key===null?rt:vt.key)||null,Pe(ze,Xe,vt,tn);case b:return Xe=Xe.get(vt.key===null?rt:vt.key)||null,at(ze,Xe,vt,tn);case D:return vt=Th(vt),ht(Xe,ze,rt,vt,tn)}if(W(vt)||L(vt))return Xe=Xe.get(rt)||null,bt(ze,Xe,vt,tn,null);if(typeof vt.then=="function")return ht(Xe,ze,rt,bv(vt),tn);if(vt.$$typeof===M)return ht(Xe,ze,rt,mv(ze,vt),tn);yv(ze,vt)}return null}function qt(Xe,ze,rt,vt){for(var tn=null,Gn=null,Qt=ze,vn=ze=0,On=null;Qt!==null&&vn<rt.length;vn++){Qt.index>vn?(On=Qt,Qt=null):On=Qt.sibling;var Wn=ot(Xe,Qt,rt[vn],vt);if(Wn===null){Qt===null&&(Qt=On);break}h&&Qt&&Wn.alternate===null&&g(Xe,Qt),ze=F(Wn,ze,vn),Gn===null?tn=Wn:Gn.sibling=Wn,Gn=Wn,Qt=On}if(vn===rt.length)return _(Xe,Qt),Ln&&gc(Xe,vn),tn;if(Qt===null){for(;vn<rt.length;vn++)Qt=_t(Xe,rt[vn],vt),Qt!==null&&(ze=F(Qt,ze,vn),Gn===null?tn=Qt:Gn.sibling=Qt,Gn=Qt);return Ln&&gc(Xe,vn),tn}for(Qt=E(Qt);vn<rt.length;vn++)On=ht(Qt,Xe,vn,rt[vn],vt),On!==null&&(h&&On.alternate!==null&&Qt.delete(On.key===null?vn:On.key),ze=F(On,ze,vn),Gn===null?tn=On:Gn.sibling=On,Gn=On);return h&&Qt.forEach(function(Zu){return g(Xe,Zu)}),Ln&&gc(Xe,vn),tn}function an(Xe,ze,rt,vt){if(rt==null)throw Error(r(151));for(var tn=null,Gn=null,Qt=ze,vn=ze=0,On=null,Wn=rt.next();Qt!==null&&!Wn.done;vn++,Wn=rt.next()){Qt.index>vn?(On=Qt,Qt=null):On=Qt.sibling;var Zu=ot(Xe,Qt,Wn.value,vt);if(Zu===null){Qt===null&&(Qt=On);break}h&&Qt&&Zu.alternate===null&&g(Xe,Qt),ze=F(Zu,ze,vn),Gn===null?tn=Zu:Gn.sibling=Zu,Gn=Zu,Qt=On}if(Wn.done)return _(Xe,Qt),Ln&&gc(Xe,vn),tn;if(Qt===null){for(;!Wn.done;vn++,Wn=rt.next())Wn=_t(Xe,Wn.value,vt),Wn!==null&&(ze=F(Wn,ze,vn),Gn===null?tn=Wn:Gn.sibling=Wn,Gn=Wn);return Ln&&gc(Xe,vn),tn}for(Qt=E(Qt);!Wn.done;vn++,Wn=rt.next())Wn=ht(Qt,Xe,vn,Wn.value,vt),Wn!==null&&(h&&Wn.alternate!==null&&Qt.delete(Wn.key===null?vn:Wn.key),ze=F(Wn,ze,vn),Gn===null?tn=Wn:Gn.sibling=Wn,Gn=Wn);return h&&Qt.forEach(function(Xse){return g(Xe,Xse)}),Ln&&gc(Xe,vn),tn}function hr(Xe,ze,rt,vt){if(typeof rt=="object"&&rt!==null&&rt.type===v&&rt.key===null&&(rt=rt.props.children),typeof rt=="object"&&rt!==null){switch(rt.$$typeof){case p:e:{for(var tn=rt.key;ze!==null;){if(ze.key===tn){if(tn=rt.type,tn===v){if(ze.tag===7){_(Xe,ze.sibling),vt=P(ze,rt.props.children),vt.return=Xe,Xe=vt;break e}}else if(ze.elementType===tn||typeof tn=="object"&&tn!==null&&tn.$$typeof===D&&Th(tn)===ze.type){_(Xe,ze.sibling),vt=P(ze,rt.props),kx(vt,rt),vt.return=Xe,Xe=vt;break e}_(Xe,ze);break}else g(Xe,ze);ze=ze.sibling}rt.type===v?(vt=Sh(rt.props.children,Xe.mode,vt,rt.key),vt.return=Xe,Xe=vt):(vt=dv(rt.type,rt.key,rt.props,null,Xe.mode,vt),kx(vt,rt),vt.return=Xe,Xe=vt)}return Q(Xe);case b:e:{for(tn=rt.key;ze!==null;){if(ze.key===tn)if(ze.tag===4&&ze.stateNode.containerInfo===rt.containerInfo&&ze.stateNode.implementation===rt.implementation){_(Xe,ze.sibling),vt=P(ze,rt.children||[]),vt.return=Xe,Xe=vt;break e}else{_(Xe,ze);break}else g(Xe,ze);ze=ze.sibling}vt=o2(rt,Xe.mode,vt),vt.return=Xe,Xe=vt}return Q(Xe);case D:return rt=Th(rt),hr(Xe,ze,rt,vt)}if(W(rt))return qt(Xe,ze,rt,vt);if(L(rt)){if(tn=L(rt),typeof tn!="function")throw Error(r(150));return rt=tn.call(rt),an(Xe,ze,rt,vt)}if(typeof rt.then=="function")return hr(Xe,ze,bv(rt),vt);if(rt.$$typeof===M)return hr(Xe,ze,mv(Xe,rt),vt);yv(Xe,rt)}return typeof rt=="string"&&rt!==""||typeof rt=="number"||typeof rt=="bigint"?(rt=""+rt,ze!==null&&ze.tag===6?(_(Xe,ze.sibling),vt=P(ze,rt),vt.return=Xe,Xe=vt):(_(Xe,ze),vt=s2(rt,Xe.mode,vt),vt.return=Xe,Xe=vt),Q(Xe)):_(Xe,ze)}return function(Xe,ze,rt,vt){try{Cx=0;var tn=hr(Xe,ze,rt,vt);return Cm=null,tn}catch(Qt){if(Qt===Tm||Qt===gv)throw Qt;var Gn=ks(29,Qt,null,Xe.mode);return Gn.lanes=vt,Gn.return=Xe,Gn}}}var kh=cF(!0),uF=cF(!1),Du=!1;function y2(h){h.updateQueue={baseState:h.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function v2(h,g){h=h.updateQueue,g.updateQueue===h&&(g.updateQueue={baseState:h.baseState,firstBaseUpdate:h.firstBaseUpdate,lastBaseUpdate:h.lastBaseUpdate,shared:h.shared,callbacks:null})}function Ou(h){return{lane:h,tag:0,payload:null,callback:null,next:null}}function Lu(h,g,_){var E=h.updateQueue;if(E===null)return null;if(E=E.shared,(Qn&2)!==0){var P=E.pending;return P===null?g.next=g:(g.next=P.next,P.next=g),E.pending=g,g=uv(h),qI(h,null,_),g}return cv(h,E,g,_),uv(h)}function jx(h,g,_){if(g=g.updateQueue,g!==null&&(g=g.shared,(_&4194048)!==0)){var E=g.lanes;E&=h.pendingLanes,_|=E,g.lanes=_,xt(h,_)}}function _2(h,g){var _=h.updateQueue,E=h.alternate;if(E!==null&&(E=E.updateQueue,_===E)){var P=null,F=null;if(_=_.firstBaseUpdate,_!==null){do{var Q={lane:_.lane,tag:_.tag,payload:_.payload,callback:null,next:null};F===null?P=F=Q:F=F.next=Q,_=_.next}while(_!==null);F===null?P=F=g:F=F.next=g}else P=F=g;_={baseState:E.baseState,firstBaseUpdate:P,lastBaseUpdate:F,shared:E.shared,callbacks:E.callbacks},h.updateQueue=_;return}h=_.lastBaseUpdate,h===null?_.firstBaseUpdate=g:h.next=g,_.lastBaseUpdate=g}var w2=!1;function Px(){if(w2){var h=Am;if(h!==null)throw h}}function Rx(h,g,_,E){w2=!1;var P=h.updateQueue;Du=!1;var F=P.firstBaseUpdate,Q=P.lastBaseUpdate,xe=P.shared.pending;if(xe!==null){P.shared.pending=null;var Pe=xe,at=Pe.next;Pe.next=null,Q===null?F=at:Q.next=at,Q=Pe;var bt=h.alternate;bt!==null&&(bt=bt.updateQueue,xe=bt.lastBaseUpdate,xe!==Q&&(xe===null?bt.firstBaseUpdate=at:xe.next=at,bt.lastBaseUpdate=Pe))}if(F!==null){var _t=P.baseState;Q=0,bt=at=Pe=null,xe=F;do{var ot=xe.lane&-536870913,ht=ot!==xe.lane;if(ht?(Dn&ot)===ot:(E&ot)===ot){ot!==0&&ot===Nm&&(w2=!0),bt!==null&&(bt=bt.next={lane:0,tag:xe.tag,payload:xe.payload,callback:null,next:null});e:{var qt=h,an=xe;ot=g;var hr=_;switch(an.tag){case 1:if(qt=an.payload,typeof qt=="function"){_t=qt.call(hr,_t,ot);break e}_t=qt;break e;case 3:qt.flags=qt.flags&-65537|128;case 0:if(qt=an.payload,ot=typeof qt=="function"?qt.call(hr,_t,ot):qt,ot==null)break e;_t=f({},_t,ot);break e;case 2:Du=!0}}ot=xe.callback,ot!==null&&(h.flags|=64,ht&&(h.flags|=8192),ht=P.callbacks,ht===null?P.callbacks=[ot]:ht.push(ot))}else ht={lane:ot,tag:xe.tag,payload:xe.payload,callback:xe.callback,next:null},bt===null?(at=bt=ht,Pe=_t):bt=bt.next=ht,Q|=ot;if(xe=xe.next,xe===null){if(xe=P.shared.pending,xe===null)break;ht=xe,xe=ht.next,ht.next=null,P.lastBaseUpdate=ht,P.shared.pending=null}}while(!0);bt===null&&(Pe=_t),P.baseState=Pe,P.firstBaseUpdate=at,P.lastBaseUpdate=bt,F===null&&(P.shared.lanes=0),Bu|=Q,h.lanes=Q,h.memoizedState=_t}}function dF(h,g){if(typeof h!="function")throw Error(r(191,h));h.call(g)}function hF(h,g){var _=h.callbacks;if(_!==null)for(h.callbacks=null,h=0;h<_.length;h++)dF(_[h],g)}var km=z(null),vv=z(0);function fF(h,g){h=Ac,Z(vv,h),Z(km,g),Ac=h|g.baseLanes}function S2(){Z(vv,Ac),Z(km,km.current)}function M2(){Ac=vv.current,H(km),H(vv)}var js=z(null),oo=null;function Iu(h){var g=h.alternate;Z(di,di.current&1),Z(js,h),oo===null&&(g===null||km.current!==null||g.memoizedState!==null)&&(oo=h)}function E2(h){Z(di,di.current),Z(js,h),oo===null&&(oo=h)}function mF(h){h.tag===22?(Z(di,di.current),Z(js,h),oo===null&&(oo=h)):Fu()}function Fu(){Z(di,di.current),Z(js,js.current)}function Ps(h){H(js),oo===h&&(oo=null),H(di)}var di=z(0);function _v(h){for(var g=h;g!==null;){if(g.tag===13){var _=g.memoizedState;if(_!==null&&(_=_.dehydrated,_===null||jA(_)||PA(_)))return g}else if(g.tag===19&&(g.memoizedProps.revealOrder==="forwards"||g.memoizedProps.revealOrder==="backwards"||g.memoizedProps.revealOrder==="unstable_legacy-backwards"||g.memoizedProps.revealOrder==="together")){if((g.flags&128)!==0)return g}else if(g.child!==null){g.child.return=g,g=g.child;continue}if(g===h)break;for(;g.sibling===null;){if(g.return===null||g.return===h)return null;g=g.return}g.sibling.return=g.return,g=g.sibling}return null}var yc=0,bn=null,ur=null,bi=null,wv=!1,jm=!1,jh=!1,Sv=0,Dx=0,Pm=null,Uae=0;function Zr(){throw Error(r(321))}function N2(h,g){if(g===null)return!1;for(var _=0;_<g.length&&_<h.length;_++)if(!Cs(h[_],g[_]))return!1;return!0}function A2(h,g,_,E,P,F){return yc=F,bn=g,g.memoizedState=null,g.updateQueue=null,g.lanes=0,K.H=h===null||h.memoizedState===null?ZF:$2,jh=!1,F=_(E,P),jh=!1,jm&&(F=gF(g,_,E,P)),pF(h),F}function pF(h){K.H=Ix;var g=ur!==null&&ur.next!==null;if(yc=0,bi=ur=bn=null,wv=!1,Dx=0,Pm=null,g)throw Error(r(300));h===null||yi||(h=h.dependencies,h!==null&&fv(h)&&(yi=!0))}function gF(h,g,_,E){bn=h;var P=0;do{if(jm&&(Pm=null),Dx=0,jm=!1,25<=P)throw Error(r(301));if(P+=1,bi=ur=null,h.updateQueue!=null){var F=h.updateQueue;F.lastEffect=null,F.events=null,F.stores=null,F.memoCache!=null&&(F.memoCache.index=0)}K.H=QF,F=g(_,E)}while(jm);return F}function zae(){var h=K.H,g=h.useState()[0];return g=typeof g.then=="function"?Ox(g):g,h=h.useState()[0],(ur!==null?ur.memoizedState:null)!==h&&(bn.flags|=1024),g}function T2(){var h=Sv!==0;return Sv=0,h}function C2(h,g,_){g.updateQueue=h.updateQueue,g.flags&=-2053,h.lanes&=~_}function k2(h){if(wv){for(h=h.memoizedState;h!==null;){var g=h.queue;g!==null&&(g.pending=null),h=h.next}wv=!1}yc=0,bi=ur=bn=null,jm=!1,Dx=Sv=0,Pm=null}function Ga(){var h={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return bi===null?bn.memoizedState=bi=h:bi=bi.next=h,bi}function hi(){if(ur===null){var h=bn.alternate;h=h!==null?h.memoizedState:null}else h=ur.next;var g=bi===null?bn.memoizedState:bi.next;if(g!==null)bi=g,ur=h;else{if(h===null)throw bn.alternate===null?Error(r(467)):Error(r(310));ur=h,h={memoizedState:ur.memoizedState,baseState:ur.baseState,baseQueue:ur.baseQueue,queue:ur.queue,next:null},bi===null?bn.memoizedState=bi=h:bi=bi.next=h}return bi}function Mv(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Ox(h){var g=Dx;return Dx+=1,Pm===null&&(Pm=[]),h=sF(Pm,h,g),g=bn,(bi===null?g.memoizedState:bi.next)===null&&(g=g.alternate,K.H=g===null||g.memoizedState===null?ZF:$2),h}function Ev(h){if(h!==null&&typeof h=="object"){if(typeof h.then=="function")return Ox(h);if(h.$$typeof===M)return ca(h)}throw Error(r(438,String(h)))}function j2(h){var g=null,_=bn.updateQueue;if(_!==null&&(g=_.memoCache),g==null){var E=bn.alternate;E!==null&&(E=E.updateQueue,E!==null&&(E=E.memoCache,E!=null&&(g={data:E.data.map(function(P){return P.slice()}),index:0})))}if(g==null&&(g={data:[],index:0}),_===null&&(_=Mv(),bn.updateQueue=_),_.memoCache=g,_=g.data[g.index],_===void 0)for(_=g.data[g.index]=Array(h),E=0;E<h;E++)_[E]=R;return g.index++,_}function vc(h,g){return typeof g=="function"?g(h):g}function Nv(h){var g=hi();return P2(g,ur,h)}function P2(h,g,_){var E=h.queue;if(E===null)throw Error(r(311));E.lastRenderedReducer=_;var P=h.baseQueue,F=E.pending;if(F!==null){if(P!==null){var Q=P.next;P.next=F.next,F.next=Q}g.baseQueue=P=F,E.pending=null}if(F=h.baseState,P===null)h.memoizedState=F;else{g=P.next;var xe=Q=null,Pe=null,at=g,bt=!1;do{var _t=at.lane&-536870913;if(_t!==at.lane?(Dn&_t)===_t:(yc&_t)===_t){var ot=at.revertLane;if(ot===0)Pe!==null&&(Pe=Pe.next={lane:0,revertLane:0,gesture:null,action:at.action,hasEagerState:at.hasEagerState,eagerState:at.eagerState,next:null}),_t===Nm&&(bt=!0);else if((yc&ot)===ot){at=at.next,ot===Nm&&(bt=!0);continue}else _t={lane:0,revertLane:at.revertLane,gesture:null,action:at.action,hasEagerState:at.hasEagerState,eagerState:at.eagerState,next:null},Pe===null?(xe=Pe=_t,Q=F):Pe=Pe.next=_t,bn.lanes|=ot,Bu|=ot;_t=at.action,jh&&_(F,_t),F=at.hasEagerState?at.eagerState:_(F,_t)}else ot={lane:_t,revertLane:at.revertLane,gesture:at.gesture,action:at.action,hasEagerState:at.hasEagerState,eagerState:at.eagerState,next:null},Pe===null?(xe=Pe=ot,Q=F):Pe=Pe.next=ot,bn.lanes|=_t,Bu|=_t;at=at.next}while(at!==null&&at!==g);if(Pe===null?Q=F:Pe.next=xe,!Cs(F,h.memoizedState)&&(yi=!0,bt&&(_=Am,_!==null)))throw _;h.memoizedState=F,h.baseState=Q,h.baseQueue=Pe,E.lastRenderedState=F}return P===null&&(E.lanes=0),[h.memoizedState,E.dispatch]}function R2(h){var g=hi(),_=g.queue;if(_===null)throw Error(r(311));_.lastRenderedReducer=h;var E=_.dispatch,P=_.pending,F=g.memoizedState;if(P!==null){_.pending=null;var Q=P=P.next;do F=h(F,Q.action),Q=Q.next;while(Q!==P);Cs(F,g.memoizedState)||(yi=!0),g.memoizedState=F,g.baseQueue===null&&(g.baseState=F),_.lastRenderedState=F}return[F,E]}function xF(h,g,_){var E=bn,P=hi(),F=Ln;if(F){if(_===void 0)throw Error(r(407));_=_()}else _=g();var Q=!Cs((ur||P).memoizedState,_);if(Q&&(P.memoizedState=_,yi=!0),P=P.queue,L2(vF.bind(null,E,P,h),[h]),P.getSnapshot!==g||Q||bi!==null&&bi.memoizedState.tag&1){if(E.flags|=2048,Rm(9,{destroy:void 0},yF.bind(null,E,P,_,g),null),_r===null)throw Error(r(349));F||(yc&127)!==0||bF(E,g,_)}return _}function bF(h,g,_){h.flags|=16384,h={getSnapshot:g,value:_},g=bn.updateQueue,g===null?(g=Mv(),bn.updateQueue=g,g.stores=[h]):(_=g.stores,_===null?g.stores=[h]:_.push(h))}function yF(h,g,_,E){g.value=_,g.getSnapshot=E,_F(g)&&wF(h)}function vF(h,g,_){return _(function(){_F(g)&&wF(h)})}function _F(h){var g=h.getSnapshot;h=h.value;try{var _=g();return!Cs(h,_)}catch{return!0}}function wF(h){var g=wh(h,2);g!==null&&hs(g,h,2)}function D2(h){var g=Ga();if(typeof h=="function"){var _=h;if(h=_(),jh){ye(!0);try{_()}finally{ye(!1)}}}return g.memoizedState=g.baseState=h,g.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:vc,lastRenderedState:h},g}function SF(h,g,_,E){return h.baseState=_,P2(h,ur,typeof E=="function"?E:vc)}function Bae(h,g,_,E,P){if(Cv(h))throw Error(r(485));if(h=g.action,h!==null){var F={payload:P,action:h,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(Q){F.listeners.push(Q)}};K.T!==null?_(!0):F.isTransition=!1,E(F),_=g.pending,_===null?(F.next=g.pending=F,MF(g,F)):(F.next=_.next,g.pending=_.next=F)}}function MF(h,g){var _=g.action,E=g.payload,P=h.state;if(g.isTransition){var F=K.T,Q={};K.T=Q;try{var xe=_(P,E),Pe=K.S;Pe!==null&&Pe(Q,xe),EF(h,g,xe)}catch(at){O2(h,g,at)}finally{F!==null&&Q.types!==null&&(F.types=Q.types),K.T=F}}else try{F=_(P,E),EF(h,g,F)}catch(at){O2(h,g,at)}}function EF(h,g,_){_!==null&&typeof _=="object"&&typeof _.then=="function"?_.then(function(E){NF(h,g,E)},function(E){return O2(h,g,E)}):NF(h,g,_)}function NF(h,g,_){g.status="fulfilled",g.value=_,AF(g),h.state=_,g=h.pending,g!==null&&(_=g.next,_===g?h.pending=null:(_=_.next,g.next=_,MF(h,_)))}function O2(h,g,_){var E=h.pending;if(h.pending=null,E!==null){E=E.next;do g.status="rejected",g.reason=_,AF(g),g=g.next;while(g!==E)}h.action=null}function AF(h){h=h.listeners;for(var g=0;g<h.length;g++)(0,h[g])()}function TF(h,g){return g}function CF(h,g){if(Ln){var _=_r.formState;if(_!==null){e:{var E=bn;if(Ln){if(Pr){t:{for(var P=Pr,F=so;P.nodeType!==8;){if(!F){P=null;break t}if(P=lo(P.nextSibling),P===null){P=null;break t}}F=P.data,P=F==="F!"||F==="F"?P:null}if(P){Pr=lo(P.nextSibling),E=P.data==="F!";break e}}Pu(E)}E=!1}E&&(g=_[0])}}return _=Ga(),_.memoizedState=_.baseState=g,E={pending:null,lanes:0,dispatch:null,lastRenderedReducer:TF,lastRenderedState:g},_.queue=E,_=KF.bind(null,bn,E),E.dispatch=_,E=D2(!1),F=B2.bind(null,bn,!1,E.queue),E=Ga(),P={state:g,dispatch:null,action:h,pending:null},E.queue=P,_=Bae.bind(null,bn,P,F,_),P.dispatch=_,E.memoizedState=h,[g,_,!1]}function kF(h){var g=hi();return jF(g,ur,h)}function jF(h,g,_){if(g=P2(h,g,TF)[0],h=Nv(vc)[0],typeof g=="object"&&g!==null&&typeof g.then=="function")try{var E=Ox(g)}catch(Q){throw Q===Tm?gv:Q}else E=g;g=hi();var P=g.queue,F=P.dispatch;return _!==g.memoizedState&&(bn.flags|=2048,Rm(9,{destroy:void 0},$ae.bind(null,P,_),null)),[E,F,h]}function $ae(h,g){h.action=g}function PF(h){var g=hi(),_=ur;if(_!==null)return jF(g,_,h);hi(),g=g.memoizedState,_=hi();var E=_.queue.dispatch;return _.memoizedState=h,[g,E,!1]}function Rm(h,g,_,E){return h={tag:h,create:_,deps:E,inst:g,next:null},g=bn.updateQueue,g===null&&(g=Mv(),bn.updateQueue=g),_=g.lastEffect,_===null?g.lastEffect=h.next=h:(E=_.next,_.next=h,h.next=E,g.lastEffect=h),h}function RF(){return hi().memoizedState}function Av(h,g,_,E){var P=Ga();bn.flags|=h,P.memoizedState=Rm(1|g,{destroy:void 0},_,E===void 0?null:E)}function Tv(h,g,_,E){var P=hi();E=E===void 0?null:E;var F=P.memoizedState.inst;ur!==null&&E!==null&&N2(E,ur.memoizedState.deps)?P.memoizedState=Rm(g,F,_,E):(bn.flags|=h,P.memoizedState=Rm(1|g,F,_,E))}function DF(h,g){Av(8390656,8,h,g)}function L2(h,g){Tv(2048,8,h,g)}function Hae(h){bn.flags|=4;var g=bn.updateQueue;if(g===null)g=Mv(),bn.updateQueue=g,g.events=[h];else{var _=g.events;_===null?g.events=[h]:_.push(h)}}function OF(h){var g=hi().memoizedState;return Hae({ref:g,nextImpl:h}),function(){if((Qn&2)!==0)throw Error(r(440));return g.impl.apply(void 0,arguments)}}function LF(h,g){return Tv(4,2,h,g)}function IF(h,g){return Tv(4,4,h,g)}function FF(h,g){if(typeof g=="function"){h=h();var _=g(h);return function(){typeof _=="function"?_():g(null)}}if(g!=null)return h=h(),g.current=h,function(){g.current=null}}function UF(h,g,_){_=_!=null?_.concat([h]):null,Tv(4,4,FF.bind(null,g,h),_)}function I2(){}function zF(h,g){var _=hi();g=g===void 0?null:g;var E=_.memoizedState;return g!==null&&N2(g,E[1])?E[0]:(_.memoizedState=[h,g],h)}function BF(h,g){var _=hi();g=g===void 0?null:g;var E=_.memoizedState;if(g!==null&&N2(g,E[1]))return E[0];if(E=h(),jh){ye(!0);try{h()}finally{ye(!1)}}return _.memoizedState=[E,g],E}function F2(h,g,_){return _===void 0||(yc&1073741824)!==0&&(Dn&261930)===0?h.memoizedState=g:(h.memoizedState=_,h=$5(),bn.lanes|=h,Bu|=h,_)}function $F(h,g,_,E){return Cs(_,g)?_:km.current!==null?(h=F2(h,_,E),Cs(h,g)||(yi=!0),h):(yc&42)===0||(yc&1073741824)!==0&&(Dn&261930)===0?(yi=!0,h.memoizedState=_):(h=$5(),bn.lanes|=h,Bu|=h,g)}function HF(h,g,_,E,P){var F=V.p;V.p=F!==0&&8>F?F:8;var Q=K.T,xe={};K.T=xe,B2(h,!1,g,_);try{var Pe=P(),at=K.S;if(at!==null&&at(xe,Pe),Pe!==null&&typeof Pe=="object"&&typeof Pe.then=="function"){var bt=Fae(Pe,E);Lx(h,g,bt,Os(h))}else Lx(h,g,E,Os(h))}catch(_t){Lx(h,g,{then:function(){},status:"rejected",reason:_t},Os())}finally{V.p=F,Q!==null&&xe.types!==null&&(Q.types=xe.types),K.T=Q}}function Vae(){}function U2(h,g,_,E){if(h.tag!==5)throw Error(r(476));var P=VF(h).queue;HF(h,P,g,J,_===null?Vae:function(){return GF(h),_(E)})}function VF(h){var g=h.memoizedState;if(g!==null)return g;g={memoizedState:J,baseState:J,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vc,lastRenderedState:J},next:null};var _={};return g.next={memoizedState:_,baseState:_,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vc,lastRenderedState:_},next:null},h.memoizedState=g,h=h.alternate,h!==null&&(h.memoizedState=g),g}function GF(h){var g=VF(h);g.next===null&&(g=h.alternate.memoizedState),Lx(h,g.next.queue,{},Os())}function z2(){return ca(Jx)}function WF(){return hi().memoizedState}function qF(){return hi().memoizedState}function Gae(h){for(var g=h.return;g!==null;){switch(g.tag){case 24:case 3:var _=Os();h=Ou(_);var E=Lu(g,h,_);E!==null&&(hs(E,g,_),jx(E,g,_)),g={cache:p2()},h.payload=g;return}g=g.return}}function Wae(h,g,_){var E=Os();_={lane:E,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null},Cv(h)?XF(g,_):(_=i2(h,g,_,E),_!==null&&(hs(_,h,E),YF(_,g,E)))}function KF(h,g,_){var E=Os();Lx(h,g,_,E)}function Lx(h,g,_,E){var P={lane:E,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null};if(Cv(h))XF(g,P);else{var F=h.alternate;if(h.lanes===0&&(F===null||F.lanes===0)&&(F=g.lastRenderedReducer,F!==null))try{var Q=g.lastRenderedState,xe=F(Q,_);if(P.hasEagerState=!0,P.eagerState=xe,Cs(xe,Q))return cv(h,g,P,0),_r===null&&lv(),!1}catch{}if(_=i2(h,g,P,E),_!==null)return hs(_,h,E),YF(_,g,E),!0}return!1}function B2(h,g,_,E){if(E={lane:2,revertLane:yA(),gesture:null,action:E,hasEagerState:!1,eagerState:null,next:null},Cv(h)){if(g)throw Error(r(479))}else g=i2(h,_,E,2),g!==null&&hs(g,h,2)}function Cv(h){var g=h.alternate;return h===bn||g!==null&&g===bn}function XF(h,g){jm=wv=!0;var _=h.pending;_===null?g.next=g:(g.next=_.next,_.next=g),h.pending=g}function YF(h,g,_){if((_&4194048)!==0){var E=g.lanes;E&=h.pendingLanes,_|=E,g.lanes=_,xt(h,_)}}var Ix={readContext:ca,use:Ev,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};Ix.useEffectEvent=Zr;var ZF={readContext:ca,use:Ev,useCallback:function(h,g){return Ga().memoizedState=[h,g===void 0?null:g],h},useContext:ca,useEffect:DF,useImperativeHandle:function(h,g,_){_=_!=null?_.concat([h]):null,Av(4194308,4,FF.bind(null,g,h),_)},useLayoutEffect:function(h,g){return Av(4194308,4,h,g)},useInsertionEffect:function(h,g){Av(4,2,h,g)},useMemo:function(h,g){var _=Ga();g=g===void 0?null:g;var E=h();if(jh){ye(!0);try{h()}finally{ye(!1)}}return _.memoizedState=[E,g],E},useReducer:function(h,g,_){var E=Ga();if(_!==void 0){var P=_(g);if(jh){ye(!0);try{_(g)}finally{ye(!1)}}}else P=g;return E.memoizedState=E.baseState=P,h={pending:null,lanes:0,dispatch:null,lastRenderedReducer:h,lastRenderedState:P},E.queue=h,h=h.dispatch=Wae.bind(null,bn,h),[E.memoizedState,h]},useRef:function(h){var g=Ga();return h={current:h},g.memoizedState=h},useState:function(h){h=D2(h);var g=h.queue,_=KF.bind(null,bn,g);return g.dispatch=_,[h.memoizedState,_]},useDebugValue:I2,useDeferredValue:function(h,g){var _=Ga();return F2(_,h,g)},useTransition:function(){var h=D2(!1);return h=HF.bind(null,bn,h.queue,!0,!1),Ga().memoizedState=h,[!1,h]},useSyncExternalStore:function(h,g,_){var E=bn,P=Ga();if(Ln){if(_===void 0)throw Error(r(407));_=_()}else{if(_=g(),_r===null)throw Error(r(349));(Dn&127)!==0||bF(E,g,_)}P.memoizedState=_;var F={value:_,getSnapshot:g};return P.queue=F,DF(vF.bind(null,E,F,h),[h]),E.flags|=2048,Rm(9,{destroy:void 0},yF.bind(null,E,F,_,g),null),_},useId:function(){var h=Ga(),g=_r.identifierPrefix;if(Ln){var _=_l,E=vl;_=(E&~(1<<32-Ce(E)-1)).toString(32)+_,g="_"+g+"R_"+_,_=Sv++,0<_&&(g+="H"+_.toString(32)),g+="_"}else _=Uae++,g="_"+g+"r_"+_.toString(32)+"_";return h.memoizedState=g},useHostTransitionStatus:z2,useFormState:CF,useActionState:CF,useOptimistic:function(h){var g=Ga();g.memoizedState=g.baseState=h;var _={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return g.queue=_,g=B2.bind(null,bn,!0,_),_.dispatch=g,[h,g]},useMemoCache:j2,useCacheRefresh:function(){return Ga().memoizedState=Gae.bind(null,bn)},useEffectEvent:function(h){var g=Ga(),_={impl:h};return g.memoizedState=_,function(){if((Qn&2)!==0)throw Error(r(440));return _.impl.apply(void 0,arguments)}}},$2={readContext:ca,use:Ev,useCallback:zF,useContext:ca,useEffect:L2,useImperativeHandle:UF,useInsertionEffect:LF,useLayoutEffect:IF,useMemo:BF,useReducer:Nv,useRef:RF,useState:function(){return Nv(vc)},useDebugValue:I2,useDeferredValue:function(h,g){var _=hi();return $F(_,ur.memoizedState,h,g)},useTransition:function(){var h=Nv(vc)[0],g=hi().memoizedState;return[typeof h=="boolean"?h:Ox(h),g]},useSyncExternalStore:xF,useId:WF,useHostTransitionStatus:z2,useFormState:kF,useActionState:kF,useOptimistic:function(h,g){var _=hi();return SF(_,ur,h,g)},useMemoCache:j2,useCacheRefresh:qF};$2.useEffectEvent=OF;var QF={readContext:ca,use:Ev,useCallback:zF,useContext:ca,useEffect:L2,useImperativeHandle:UF,useInsertionEffect:LF,useLayoutEffect:IF,useMemo:BF,useReducer:R2,useRef:RF,useState:function(){return R2(vc)},useDebugValue:I2,useDeferredValue:function(h,g){var _=hi();return ur===null?F2(_,h,g):$F(_,ur.memoizedState,h,g)},useTransition:function(){var h=R2(vc)[0],g=hi().memoizedState;return[typeof h=="boolean"?h:Ox(h),g]},useSyncExternalStore:xF,useId:WF,useHostTransitionStatus:z2,useFormState:PF,useActionState:PF,useOptimistic:function(h,g){var _=hi();return ur!==null?SF(_,ur,h,g):(_.baseState=h,[h,_.queue.dispatch])},useMemoCache:j2,useCacheRefresh:qF};QF.useEffectEvent=OF;function H2(h,g,_,E){g=h.memoizedState,_=_(E,g),_=_==null?g:f({},g,_),h.memoizedState=_,h.lanes===0&&(h.updateQueue.baseState=_)}var V2={enqueueSetState:function(h,g,_){h=h._reactInternals;var E=Os(),P=Ou(E);P.payload=g,_!=null&&(P.callback=_),g=Lu(h,P,E),g!==null&&(hs(g,h,E),jx(g,h,E))},enqueueReplaceState:function(h,g,_){h=h._reactInternals;var E=Os(),P=Ou(E);P.tag=1,P.payload=g,_!=null&&(P.callback=_),g=Lu(h,P,E),g!==null&&(hs(g,h,E),jx(g,h,E))},enqueueForceUpdate:function(h,g){h=h._reactInternals;var _=Os(),E=Ou(_);E.tag=2,g!=null&&(E.callback=g),g=Lu(h,E,_),g!==null&&(hs(g,h,_),jx(g,h,_))}};function JF(h,g,_,E,P,F,Q){return h=h.stateNode,typeof h.shouldComponentUpdate=="function"?h.shouldComponentUpdate(E,F,Q):g.prototype&&g.prototype.isPureReactComponent?!Sx(_,E)||!Sx(P,F):!0}function e5(h,g,_,E){h=g.state,typeof g.componentWillReceiveProps=="function"&&g.componentWillReceiveProps(_,E),typeof g.UNSAFE_componentWillReceiveProps=="function"&&g.UNSAFE_componentWillReceiveProps(_,E),g.state!==h&&V2.enqueueReplaceState(g,g.state,null)}function Ph(h,g){var _=g;if("ref"in g){_={};for(var E in g)E!=="ref"&&(_[E]=g[E])}if(h=h.defaultProps){_===g&&(_=f({},_));for(var P in h)_[P]===void 0&&(_[P]=h[P])}return _}function t5(h){ov(h)}function n5(h){console.error(h)}function r5(h){ov(h)}function kv(h,g){try{var _=h.onUncaughtError;_(g.value,{componentStack:g.stack})}catch(E){setTimeout(function(){throw E})}}function i5(h,g,_){try{var E=h.onCaughtError;E(_.value,{componentStack:_.stack,errorBoundary:g.tag===1?g.stateNode:null})}catch(P){setTimeout(function(){throw P})}}function G2(h,g,_){return _=Ou(_),_.tag=3,_.payload={element:null},_.callback=function(){kv(h,g)},_}function a5(h){return h=Ou(h),h.tag=3,h}function s5(h,g,_,E){var P=_.type.getDerivedStateFromError;if(typeof P=="function"){var F=E.value;h.payload=function(){return P(F)},h.callback=function(){i5(g,_,E)}}var Q=_.stateNode;Q!==null&&typeof Q.componentDidCatch=="function"&&(h.callback=function(){i5(g,_,E),typeof P!="function"&&($u===null?$u=new Set([this]):$u.add(this));var xe=E.stack;this.componentDidCatch(E.value,{componentStack:xe!==null?xe:""})})}function qae(h,g,_,E,P){if(_.flags|=32768,E!==null&&typeof E=="object"&&typeof E.then=="function"){if(g=_.alternate,g!==null&&Em(g,_,P,!0),_=js.current,_!==null){switch(_.tag){case 31:case 13:return oo===null?$v():_.alternate===null&&Qr===0&&(Qr=3),_.flags&=-257,_.flags|=65536,_.lanes=P,E===xv?_.flags|=16384:(g=_.updateQueue,g===null?_.updateQueue=new Set([E]):g.add(E),gA(h,E,P)),!1;case 22:return _.flags|=65536,E===xv?_.flags|=16384:(g=_.updateQueue,g===null?(g={transitions:null,markerInstances:null,retryQueue:new Set([E])},_.updateQueue=g):(_=g.retryQueue,_===null?g.retryQueue=new Set([E]):_.add(E)),gA(h,E,P)),!1}throw Error(r(435,_.tag))}return gA(h,E,P),$v(),!1}if(Ln)return g=js.current,g!==null?((g.flags&65536)===0&&(g.flags|=256),g.flags|=65536,g.lanes=P,E!==u2&&(h=Error(r(422),{cause:E}),Nx(ro(h,_)))):(E!==u2&&(g=Error(r(423),{cause:E}),Nx(ro(g,_))),h=h.current.alternate,h.flags|=65536,P&=-P,h.lanes|=P,E=ro(E,_),P=G2(h.stateNode,E,P),_2(h,P),Qr!==4&&(Qr=2)),!1;var F=Error(r(520),{cause:E});if(F=ro(F,_),Gx===null?Gx=[F]:Gx.push(F),Qr!==4&&(Qr=2),g===null)return!0;E=ro(E,_),_=g;do{switch(_.tag){case 3:return _.flags|=65536,h=P&-P,_.lanes|=h,h=G2(_.stateNode,E,h),_2(_,h),!1;case 1:if(g=_.type,F=_.stateNode,(_.flags&128)===0&&(typeof g.getDerivedStateFromError=="function"||F!==null&&typeof F.componentDidCatch=="function"&&($u===null||!$u.has(F))))return _.flags|=65536,P&=-P,_.lanes|=P,P=a5(P),s5(P,h,_,E),_2(_,P),!1}_=_.return}while(_!==null);return!1}var W2=Error(r(461)),yi=!1;function ua(h,g,_,E){g.child=h===null?uF(g,null,_,E):kh(g,h.child,_,E)}function o5(h,g,_,E,P){_=_.render;var F=g.ref;if("ref"in E){var Q={};for(var xe in E)xe!=="ref"&&(Q[xe]=E[xe])}else Q=E;return Nh(g),E=A2(h,g,_,Q,F,P),xe=T2(),h!==null&&!yi?(C2(h,g,P),_c(h,g,P)):(Ln&&xe&&l2(g),g.flags|=1,ua(h,g,E,P),g.child)}function l5(h,g,_,E,P){if(h===null){var F=_.type;return typeof F=="function"&&!a2(F)&&F.defaultProps===void 0&&_.compare===null?(g.tag=15,g.type=F,c5(h,g,F,E,P)):(h=dv(_.type,null,E,g,g.mode,P),h.ref=g.ref,h.return=g,g.child=h)}if(F=h.child,!eA(h,P)){var Q=F.memoizedProps;if(_=_.compare,_=_!==null?_:Sx,_(Q,E)&&h.ref===g.ref)return _c(h,g,P)}return g.flags|=1,h=pc(F,E),h.ref=g.ref,h.return=g,g.child=h}function c5(h,g,_,E,P){if(h!==null){var F=h.memoizedProps;if(Sx(F,E)&&h.ref===g.ref)if(yi=!1,g.pendingProps=E=F,eA(h,P))(h.flags&131072)!==0&&(yi=!0);else return g.lanes=h.lanes,_c(h,g,P)}return q2(h,g,_,E,P)}function u5(h,g,_,E){var P=E.children,F=h!==null?h.memoizedState:null;if(h===null&&g.stateNode===null&&(g.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),E.mode==="hidden"){if((g.flags&128)!==0){if(F=F!==null?F.baseLanes|_:_,h!==null){for(E=g.child=h.child,P=0;E!==null;)P=P|E.lanes|E.childLanes,E=E.sibling;E=P&~F}else E=0,g.child=null;return d5(h,g,F,_,E)}if((_&536870912)!==0)g.memoizedState={baseLanes:0,cachePool:null},h!==null&&pv(g,F!==null?F.cachePool:null),F!==null?fF(g,F):S2(),mF(g);else return E=g.lanes=536870912,d5(h,g,F!==null?F.baseLanes|_:_,_,E)}else F!==null?(pv(g,F.cachePool),fF(g,F),Fu(),g.memoizedState=null):(h!==null&&pv(g,null),S2(),Fu());return ua(h,g,P,_),g.child}function Fx(h,g){return h!==null&&h.tag===22||g.stateNode!==null||(g.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),g.sibling}function d5(h,g,_,E,P){var F=x2();return F=F===null?null:{parent:xi._currentValue,pool:F},g.memoizedState={baseLanes:_,cachePool:F},h!==null&&pv(g,null),S2(),mF(g),h!==null&&Em(h,g,E,!0),g.childLanes=P,null}function jv(h,g){return g=Rv({mode:g.mode,children:g.children},h.mode),g.ref=h.ref,h.child=g,g.return=h,g}function h5(h,g,_){return kh(g,h.child,null,_),h=jv(g,g.pendingProps),h.flags|=2,Ps(g),g.memoizedState=null,h}function Kae(h,g,_){var E=g.pendingProps,P=(g.flags&128)!==0;if(g.flags&=-129,h===null){if(Ln){if(E.mode==="hidden")return h=jv(g,E),g.lanes=536870912,Fx(null,h);if(E2(g),(h=Pr)?(h=MU(h,so),h=h!==null&&h.data==="&"?h:null,h!==null&&(g.memoizedState={dehydrated:h,treeContext:ku!==null?{id:vl,overflow:_l}:null,retryLane:536870912,hydrationErrors:null},_=XI(h),_.return=g,g.child=_,la=g,Pr=null)):h=null,h===null)throw Pu(g);return g.lanes=536870912,null}return jv(g,E)}var F=h.memoizedState;if(F!==null){var Q=F.dehydrated;if(E2(g),P)if(g.flags&256)g.flags&=-257,g=h5(h,g,_);else if(g.memoizedState!==null)g.child=h.child,g.flags|=128,g=null;else throw Error(r(558));else if(yi||Em(h,g,_,!1),P=(_&h.childLanes)!==0,yi||P){if(E=_r,E!==null&&(Q=Yt(E,_),Q!==0&&Q!==F.retryLane))throw F.retryLane=Q,wh(h,Q),hs(E,h,Q),W2;$v(),g=h5(h,g,_)}else h=F.treeContext,Pr=lo(Q.nextSibling),la=g,Ln=!0,ju=null,so=!1,h!==null&&QI(g,h),g=jv(g,E),g.flags|=4096;return g}return h=pc(h.child,{mode:E.mode,children:E.children}),h.ref=g.ref,g.child=h,h.return=g,h}function Pv(h,g){var _=g.ref;if(_===null)h!==null&&h.ref!==null&&(g.flags|=4194816);else{if(typeof _!="function"&&typeof _!="object")throw Error(r(284));(h===null||h.ref!==_)&&(g.flags|=4194816)}}function q2(h,g,_,E,P){return Nh(g),_=A2(h,g,_,E,void 0,P),E=T2(),h!==null&&!yi?(C2(h,g,P),_c(h,g,P)):(Ln&&E&&l2(g),g.flags|=1,ua(h,g,_,P),g.child)}function f5(h,g,_,E,P,F){return Nh(g),g.updateQueue=null,_=gF(g,E,_,P),pF(h),E=T2(),h!==null&&!yi?(C2(h,g,F),_c(h,g,F)):(Ln&&E&&l2(g),g.flags|=1,ua(h,g,_,F),g.child)}function m5(h,g,_,E,P){if(Nh(g),g.stateNode===null){var F=_m,Q=_.contextType;typeof Q=="object"&&Q!==null&&(F=ca(Q)),F=new _(E,F),g.memoizedState=F.state!==null&&F.state!==void 0?F.state:null,F.updater=V2,g.stateNode=F,F._reactInternals=g,F=g.stateNode,F.props=E,F.state=g.memoizedState,F.refs={},y2(g),Q=_.contextType,F.context=typeof Q=="object"&&Q!==null?ca(Q):_m,F.state=g.memoizedState,Q=_.getDerivedStateFromProps,typeof Q=="function"&&(H2(g,_,Q,E),F.state=g.memoizedState),typeof _.getDerivedStateFromProps=="function"||typeof F.getSnapshotBeforeUpdate=="function"||typeof F.UNSAFE_componentWillMount!="function"&&typeof F.componentWillMount!="function"||(Q=F.state,typeof F.componentWillMount=="function"&&F.componentWillMount(),typeof F.UNSAFE_componentWillMount=="function"&&F.UNSAFE_componentWillMount(),Q!==F.state&&V2.enqueueReplaceState(F,F.state,null),Rx(g,E,F,P),Px(),F.state=g.memoizedState),typeof F.componentDidMount=="function"&&(g.flags|=4194308),E=!0}else if(h===null){F=g.stateNode;var xe=g.memoizedProps,Pe=Ph(_,xe);F.props=Pe;var at=F.context,bt=_.contextType;Q=_m,typeof bt=="object"&&bt!==null&&(Q=ca(bt));var _t=_.getDerivedStateFromProps;bt=typeof _t=="function"||typeof F.getSnapshotBeforeUpdate=="function",xe=g.pendingProps!==xe,bt||typeof F.UNSAFE_componentWillReceiveProps!="function"&&typeof F.componentWillReceiveProps!="function"||(xe||at!==Q)&&e5(g,F,E,Q),Du=!1;var ot=g.memoizedState;F.state=ot,Rx(g,E,F,P),Px(),at=g.memoizedState,xe||ot!==at||Du?(typeof _t=="function"&&(H2(g,_,_t,E),at=g.memoizedState),(Pe=Du||JF(g,_,Pe,E,ot,at,Q))?(bt||typeof F.UNSAFE_componentWillMount!="function"&&typeof F.componentWillMount!="function"||(typeof F.componentWillMount=="function"&&F.componentWillMount(),typeof F.UNSAFE_componentWillMount=="function"&&F.UNSAFE_componentWillMount()),typeof F.componentDidMount=="function"&&(g.flags|=4194308)):(typeof F.componentDidMount=="function"&&(g.flags|=4194308),g.memoizedProps=E,g.memoizedState=at),F.props=E,F.state=at,F.context=Q,E=Pe):(typeof F.componentDidMount=="function"&&(g.flags|=4194308),E=!1)}else{F=g.stateNode,v2(h,g),Q=g.memoizedProps,bt=Ph(_,Q),F.props=bt,_t=g.pendingProps,ot=F.context,at=_.contextType,Pe=_m,typeof at=="object"&&at!==null&&(Pe=ca(at)),xe=_.getDerivedStateFromProps,(at=typeof xe=="function"||typeof F.getSnapshotBeforeUpdate=="function")||typeof F.UNSAFE_componentWillReceiveProps!="function"&&typeof F.componentWillReceiveProps!="function"||(Q!==_t||ot!==Pe)&&e5(g,F,E,Pe),Du=!1,ot=g.memoizedState,F.state=ot,Rx(g,E,F,P),Px();var ht=g.memoizedState;Q!==_t||ot!==ht||Du||h!==null&&h.dependencies!==null&&fv(h.dependencies)?(typeof xe=="function"&&(H2(g,_,xe,E),ht=g.memoizedState),(bt=Du||JF(g,_,bt,E,ot,ht,Pe)||h!==null&&h.dependencies!==null&&fv(h.dependencies))?(at||typeof F.UNSAFE_componentWillUpdate!="function"&&typeof F.componentWillUpdate!="function"||(typeof F.componentWillUpdate=="function"&&F.componentWillUpdate(E,ht,Pe),typeof F.UNSAFE_componentWillUpdate=="function"&&F.UNSAFE_componentWillUpdate(E,ht,Pe)),typeof F.componentDidUpdate=="function"&&(g.flags|=4),typeof F.getSnapshotBeforeUpdate=="function"&&(g.flags|=1024)):(typeof F.componentDidUpdate!="function"||Q===h.memoizedProps&&ot===h.memoizedState||(g.flags|=4),typeof F.getSnapshotBeforeUpdate!="function"||Q===h.memoizedProps&&ot===h.memoizedState||(g.flags|=1024),g.memoizedProps=E,g.memoizedState=ht),F.props=E,F.state=ht,F.context=Pe,E=bt):(typeof F.componentDidUpdate!="function"||Q===h.memoizedProps&&ot===h.memoizedState||(g.flags|=4),typeof F.getSnapshotBeforeUpdate!="function"||Q===h.memoizedProps&&ot===h.memoizedState||(g.flags|=1024),E=!1)}return F=E,Pv(h,g),E=(g.flags&128)!==0,F||E?(F=g.stateNode,_=E&&typeof _.getDerivedStateFromError!="function"?null:F.render(),g.flags|=1,h!==null&&E?(g.child=kh(g,h.child,null,P),g.child=kh(g,null,_,P)):ua(h,g,_,P),g.memoizedState=F.state,h=g.child):h=_c(h,g,P),h}function p5(h,g,_,E){return Mh(),g.flags|=256,ua(h,g,_,E),g.child}var K2={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function X2(h){return{baseLanes:h,cachePool:iF()}}function Y2(h,g,_){return h=h!==null?h.childLanes&~_:0,g&&(h|=Ds),h}function g5(h,g,_){var E=g.pendingProps,P=!1,F=(g.flags&128)!==0,Q;if((Q=F)||(Q=h!==null&&h.memoizedState===null?!1:(di.current&2)!==0),Q&&(P=!0,g.flags&=-129),Q=(g.flags&32)!==0,g.flags&=-33,h===null){if(Ln){if(P?Iu(g):Fu(),(h=Pr)?(h=MU(h,so),h=h!==null&&h.data!=="&"?h:null,h!==null&&(g.memoizedState={dehydrated:h,treeContext:ku!==null?{id:vl,overflow:_l}:null,retryLane:536870912,hydrationErrors:null},_=XI(h),_.return=g,g.child=_,la=g,Pr=null)):h=null,h===null)throw Pu(g);return PA(h)?g.lanes=32:g.lanes=536870912,null}var xe=E.children;return E=E.fallback,P?(Fu(),P=g.mode,xe=Rv({mode:"hidden",children:xe},P),E=Sh(E,P,_,null),xe.return=g,E.return=g,xe.sibling=E,g.child=xe,E=g.child,E.memoizedState=X2(_),E.childLanes=Y2(h,Q,_),g.memoizedState=K2,Fx(null,E)):(Iu(g),Z2(g,xe))}var Pe=h.memoizedState;if(Pe!==null&&(xe=Pe.dehydrated,xe!==null)){if(F)g.flags&256?(Iu(g),g.flags&=-257,g=Q2(h,g,_)):g.memoizedState!==null?(Fu(),g.child=h.child,g.flags|=128,g=null):(Fu(),xe=E.fallback,P=g.mode,E=Rv({mode:"visible",children:E.children},P),xe=Sh(xe,P,_,null),xe.flags|=2,E.return=g,xe.return=g,E.sibling=xe,g.child=E,kh(g,h.child,null,_),E=g.child,E.memoizedState=X2(_),E.childLanes=Y2(h,Q,_),g.memoizedState=K2,g=Fx(null,E));else if(Iu(g),PA(xe)){if(Q=xe.nextSibling&&xe.nextSibling.dataset,Q)var at=Q.dgst;Q=at,E=Error(r(419)),E.stack="",E.digest=Q,Nx({value:E,source:null,stack:null}),g=Q2(h,g,_)}else if(yi||Em(h,g,_,!1),Q=(_&h.childLanes)!==0,yi||Q){if(Q=_r,Q!==null&&(E=Yt(Q,_),E!==0&&E!==Pe.retryLane))throw Pe.retryLane=E,wh(h,E),hs(Q,h,E),W2;jA(xe)||$v(),g=Q2(h,g,_)}else jA(xe)?(g.flags|=192,g.child=h.child,g=null):(h=Pe.treeContext,Pr=lo(xe.nextSibling),la=g,Ln=!0,ju=null,so=!1,h!==null&&QI(g,h),g=Z2(g,E.children),g.flags|=4096);return g}return P?(Fu(),xe=E.fallback,P=g.mode,Pe=h.child,at=Pe.sibling,E=pc(Pe,{mode:"hidden",children:E.children}),E.subtreeFlags=Pe.subtreeFlags&65011712,at!==null?xe=pc(at,xe):(xe=Sh(xe,P,_,null),xe.flags|=2),xe.return=g,E.return=g,E.sibling=xe,g.child=E,Fx(null,E),E=g.child,xe=h.child.memoizedState,xe===null?xe=X2(_):(P=xe.cachePool,P!==null?(Pe=xi._currentValue,P=P.parent!==Pe?{parent:Pe,pool:Pe}:P):P=iF(),xe={baseLanes:xe.baseLanes|_,cachePool:P}),E.memoizedState=xe,E.childLanes=Y2(h,Q,_),g.memoizedState=K2,Fx(h.child,E)):(Iu(g),_=h.child,h=_.sibling,_=pc(_,{mode:"visible",children:E.children}),_.return=g,_.sibling=null,h!==null&&(Q=g.deletions,Q===null?(g.deletions=[h],g.flags|=16):Q.push(h)),g.child=_,g.memoizedState=null,_)}function Z2(h,g){return g=Rv({mode:"visible",children:g},h.mode),g.return=h,h.child=g}function Rv(h,g){return h=ks(22,h,null,g),h.lanes=0,h}function Q2(h,g,_){return kh(g,h.child,null,_),h=Z2(g,g.pendingProps.children),h.flags|=2,g.memoizedState=null,h}function x5(h,g,_){h.lanes|=g;var E=h.alternate;E!==null&&(E.lanes|=g),f2(h.return,g,_)}function J2(h,g,_,E,P,F){var Q=h.memoizedState;Q===null?h.memoizedState={isBackwards:g,rendering:null,renderingStartTime:0,last:E,tail:_,tailMode:P,treeForkCount:F}:(Q.isBackwards=g,Q.rendering=null,Q.renderingStartTime=0,Q.last=E,Q.tail=_,Q.tailMode=P,Q.treeForkCount=F)}function b5(h,g,_){var E=g.pendingProps,P=E.revealOrder,F=E.tail;E=E.children;var Q=di.current,xe=(Q&2)!==0;if(xe?(Q=Q&1|2,g.flags|=128):Q&=1,Z(di,Q),ua(h,g,E,_),E=Ln?Ex:0,!xe&&h!==null&&(h.flags&128)!==0)e:for(h=g.child;h!==null;){if(h.tag===13)h.memoizedState!==null&&x5(h,_,g);else if(h.tag===19)x5(h,_,g);else if(h.child!==null){h.child.return=h,h=h.child;continue}if(h===g)break e;for(;h.sibling===null;){if(h.return===null||h.return===g)break e;h=h.return}h.sibling.return=h.return,h=h.sibling}switch(P){case"forwards":for(_=g.child,P=null;_!==null;)h=_.alternate,h!==null&&_v(h)===null&&(P=_),_=_.sibling;_=P,_===null?(P=g.child,g.child=null):(P=_.sibling,_.sibling=null),J2(g,!1,P,_,F,E);break;case"backwards":case"unstable_legacy-backwards":for(_=null,P=g.child,g.child=null;P!==null;){if(h=P.alternate,h!==null&&_v(h)===null){g.child=P;break}h=P.sibling,P.sibling=_,_=P,P=h}J2(g,!0,_,null,F,E);break;case"together":J2(g,!1,null,null,void 0,E);break;default:g.memoizedState=null}return g.child}function _c(h,g,_){if(h!==null&&(g.dependencies=h.dependencies),Bu|=g.lanes,(_&g.childLanes)===0)if(h!==null){if(Em(h,g,_,!1),(_&g.childLanes)===0)return null}else return null;if(h!==null&&g.child!==h.child)throw Error(r(153));if(g.child!==null){for(h=g.child,_=pc(h,h.pendingProps),g.child=_,_.return=g;h.sibling!==null;)h=h.sibling,_=_.sibling=pc(h,h.pendingProps),_.return=g;_.sibling=null}return g.child}function eA(h,g){return(h.lanes&g)!==0?!0:(h=h.dependencies,!!(h!==null&&fv(h)))}function Xae(h,g,_){switch(g.tag){case 3:Ne(g,g.stateNode.containerInfo),Ru(g,xi,h.memoizedState.cache),Mh();break;case 27:case 5:Se(g);break;case 4:Ne(g,g.stateNode.containerInfo);break;case 10:Ru(g,g.type,g.memoizedProps.value);break;case 31:if(g.memoizedState!==null)return g.flags|=128,E2(g),null;break;case 13:var E=g.memoizedState;if(E!==null)return E.dehydrated!==null?(Iu(g),g.flags|=128,null):(_&g.child.childLanes)!==0?g5(h,g,_):(Iu(g),h=_c(h,g,_),h!==null?h.sibling:null);Iu(g);break;case 19:var P=(h.flags&128)!==0;if(E=(_&g.childLanes)!==0,E||(Em(h,g,_,!1),E=(_&g.childLanes)!==0),P){if(E)return b5(h,g,_);g.flags|=128}if(P=g.memoizedState,P!==null&&(P.rendering=null,P.tail=null,P.lastEffect=null),Z(di,di.current),E)break;return null;case 22:return g.lanes=0,u5(h,g,_,g.pendingProps);case 24:Ru(g,xi,h.memoizedState.cache)}return _c(h,g,_)}function y5(h,g,_){if(h!==null)if(h.memoizedProps!==g.pendingProps)yi=!0;else{if(!eA(h,_)&&(g.flags&128)===0)return yi=!1,Xae(h,g,_);yi=(h.flags&131072)!==0}else yi=!1,Ln&&(g.flags&1048576)!==0&&ZI(g,Ex,g.index);switch(g.lanes=0,g.tag){case 16:e:{var E=g.pendingProps;if(h=Th(g.elementType),g.type=h,typeof h=="function")a2(h)?(E=Ph(h,E),g.tag=1,g=m5(null,g,h,E,_)):(g.tag=0,g=q2(null,g,h,E,_));else{if(h!=null){var P=h.$$typeof;if(P===N){g.tag=11,g=o5(null,g,h,E,_);break e}else if(P===C){g.tag=14,g=l5(null,g,h,E,_);break e}}throw g=j(h)||h,Error(r(306,g,""))}}return g;case 0:return q2(h,g,g.type,g.pendingProps,_);case 1:return E=g.type,P=Ph(E,g.pendingProps),m5(h,g,E,P,_);case 3:e:{if(Ne(g,g.stateNode.containerInfo),h===null)throw Error(r(387));E=g.pendingProps;var F=g.memoizedState;P=F.element,v2(h,g),Rx(g,E,null,_);var Q=g.memoizedState;if(E=Q.cache,Ru(g,xi,E),E!==F.cache&&m2(g,[xi],_,!0),Px(),E=Q.element,F.isDehydrated)if(F={element:E,isDehydrated:!1,cache:Q.cache},g.updateQueue.baseState=F,g.memoizedState=F,g.flags&256){g=p5(h,g,E,_);break e}else if(E!==P){P=ro(Error(r(424)),g),Nx(P),g=p5(h,g,E,_);break e}else for(h=g.stateNode.containerInfo,h.nodeType===9?h=h.body:h=h.nodeName==="HTML"?h.ownerDocument.body:h,Pr=lo(h.firstChild),la=g,Ln=!0,ju=null,so=!0,_=uF(g,null,E,_),g.child=_;_;)_.flags=_.flags&-3|4096,_=_.sibling;else{if(Mh(),E===P){g=_c(h,g,_);break e}ua(h,g,E,_)}g=g.child}return g;case 26:return Pv(h,g),h===null?(_=kU(g.type,null,g.pendingProps,null))?g.memoizedState=_:Ln||(_=g.type,h=g.pendingProps,E=Xv(fe.current).createElement(_),E[Un]=g,E[yr]=h,da(E,_,h),ue(E),g.stateNode=E):g.memoizedState=kU(g.type,h.memoizedProps,g.pendingProps,h.memoizedState),null;case 27:return Se(g),h===null&&Ln&&(E=g.stateNode=AU(g.type,g.pendingProps,fe.current),la=g,so=!0,P=Pr,Wu(g.type)?(RA=P,Pr=lo(E.firstChild)):Pr=P),ua(h,g,g.pendingProps.children,_),Pv(h,g),h===null&&(g.flags|=4194304),g.child;case 5:return h===null&&Ln&&((P=E=Pr)&&(E=Ese(E,g.type,g.pendingProps,so),E!==null?(g.stateNode=E,la=g,Pr=lo(E.firstChild),so=!1,P=!0):P=!1),P||Pu(g)),Se(g),P=g.type,F=g.pendingProps,Q=h!==null?h.memoizedProps:null,E=F.children,TA(P,F)?E=null:Q!==null&&TA(P,Q)&&(g.flags|=32),g.memoizedState!==null&&(P=A2(h,g,zae,null,null,_),Jx._currentValue=P),Pv(h,g),ua(h,g,E,_),g.child;case 6:return h===null&&Ln&&((h=_=Pr)&&(_=Nse(_,g.pendingProps,so),_!==null?(g.stateNode=_,la=g,Pr=null,h=!0):h=!1),h||Pu(g)),null;case 13:return g5(h,g,_);case 4:return Ne(g,g.stateNode.containerInfo),E=g.pendingProps,h===null?g.child=kh(g,null,E,_):ua(h,g,E,_),g.child;case 11:return o5(h,g,g.type,g.pendingProps,_);case 7:return ua(h,g,g.pendingProps,_),g.child;case 8:return ua(h,g,g.pendingProps.children,_),g.child;case 12:return ua(h,g,g.pendingProps.children,_),g.child;case 10:return E=g.pendingProps,Ru(g,g.type,E.value),ua(h,g,E.children,_),g.child;case 9:return P=g.type._context,E=g.pendingProps.children,Nh(g),P=ca(P),E=E(P),g.flags|=1,ua(h,g,E,_),g.child;case 14:return l5(h,g,g.type,g.pendingProps,_);case 15:return c5(h,g,g.type,g.pendingProps,_);case 19:return b5(h,g,_);case 31:return Kae(h,g,_);case 22:return u5(h,g,_,g.pendingProps);case 24:return Nh(g),E=ca(xi),h===null?(P=x2(),P===null&&(P=_r,F=p2(),P.pooledCache=F,F.refCount++,F!==null&&(P.pooledCacheLanes|=_),P=F),g.memoizedState={parent:E,cache:P},y2(g),Ru(g,xi,P)):((h.lanes&_)!==0&&(v2(h,g),Rx(g,null,null,_),Px()),P=h.memoizedState,F=g.memoizedState,P.parent!==E?(P={parent:E,cache:E},g.memoizedState=P,g.lanes===0&&(g.memoizedState=g.updateQueue.baseState=P),Ru(g,xi,E)):(E=F.cache,Ru(g,xi,E),E!==P.cache&&m2(g,[xi],_,!0))),ua(h,g,g.pendingProps.children,_),g.child;case 29:throw g.pendingProps}throw Error(r(156,g.tag))}function wc(h){h.flags|=4}function tA(h,g,_,E,P){if((g=(h.mode&32)!==0)&&(g=!1),g){if(h.flags|=16777216,(P&335544128)===P)if(h.stateNode.complete)h.flags|=8192;else if(W5())h.flags|=8192;else throw Ch=xv,b2}else h.flags&=-16777217}function v5(h,g){if(g.type!=="stylesheet"||(g.state.loading&4)!==0)h.flags&=-16777217;else if(h.flags|=16777216,!OU(g))if(W5())h.flags|=8192;else throw Ch=xv,b2}function Dv(h,g){g!==null&&(h.flags|=4),h.flags&16384&&(g=h.tag!==22?Ot():536870912,h.lanes|=g,Im|=g)}function Ux(h,g){if(!Ln)switch(h.tailMode){case"hidden":g=h.tail;for(var _=null;g!==null;)g.alternate!==null&&(_=g),g=g.sibling;_===null?h.tail=null:_.sibling=null;break;case"collapsed":_=h.tail;for(var E=null;_!==null;)_.alternate!==null&&(E=_),_=_.sibling;E===null?g||h.tail===null?h.tail=null:h.tail.sibling=null:E.sibling=null}}function Rr(h){var g=h.alternate!==null&&h.alternate.child===h.child,_=0,E=0;if(g)for(var P=h.child;P!==null;)_|=P.lanes|P.childLanes,E|=P.subtreeFlags&65011712,E|=P.flags&65011712,P.return=h,P=P.sibling;else for(P=h.child;P!==null;)_|=P.lanes|P.childLanes,E|=P.subtreeFlags,E|=P.flags,P.return=h,P=P.sibling;return h.subtreeFlags|=E,h.childLanes=_,g}function Yae(h,g,_){var E=g.pendingProps;switch(c2(g),g.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Rr(g),null;case 1:return Rr(g),null;case 3:return _=g.stateNode,E=null,h!==null&&(E=h.memoizedState.cache),g.memoizedState.cache!==E&&(g.flags|=2048),bc(xi),ge(),_.pendingContext&&(_.context=_.pendingContext,_.pendingContext=null),(h===null||h.child===null)&&(Mm(g)?wc(g):h===null||h.memoizedState.isDehydrated&&(g.flags&256)===0||(g.flags|=1024,d2())),Rr(g),null;case 26:var P=g.type,F=g.memoizedState;return h===null?(wc(g),F!==null?(Rr(g),v5(g,F)):(Rr(g),tA(g,P,null,E,_))):F?F!==h.memoizedState?(wc(g),Rr(g),v5(g,F)):(Rr(g),g.flags&=-16777217):(h=h.memoizedProps,h!==E&&wc(g),Rr(g),tA(g,P,h,E,_)),null;case 27:if(Re(g),_=fe.current,P=g.type,h!==null&&g.stateNode!=null)h.memoizedProps!==E&&wc(g);else{if(!E){if(g.stateNode===null)throw Error(r(166));return Rr(g),null}h=ee.current,Mm(g)?JI(g):(h=AU(P,E,_),g.stateNode=h,wc(g))}return Rr(g),null;case 5:if(Re(g),P=g.type,h!==null&&g.stateNode!=null)h.memoizedProps!==E&&wc(g);else{if(!E){if(g.stateNode===null)throw Error(r(166));return Rr(g),null}if(F=ee.current,Mm(g))JI(g);else{var Q=Xv(fe.current);switch(F){case 1:F=Q.createElementNS("http://www.w3.org/2000/svg",P);break;case 2:F=Q.createElementNS("http://www.w3.org/1998/Math/MathML",P);break;default:switch(P){case"svg":F=Q.createElementNS("http://www.w3.org/2000/svg",P);break;case"math":F=Q.createElementNS("http://www.w3.org/1998/Math/MathML",P);break;case"script":F=Q.createElement("div"),F.innerHTML="<script><\/script>",F=F.removeChild(F.firstChild);break;case"select":F=typeof E.is=="string"?Q.createElement("select",{is:E.is}):Q.createElement("select"),E.multiple?F.multiple=!0:E.size&&(F.size=E.size);break;default:F=typeof E.is=="string"?Q.createElement(P,{is:E.is}):Q.createElement(P)}}F[Un]=g,F[yr]=E;e:for(Q=g.child;Q!==null;){if(Q.tag===5||Q.tag===6)F.appendChild(Q.stateNode);else if(Q.tag!==4&&Q.tag!==27&&Q.child!==null){Q.child.return=Q,Q=Q.child;continue}if(Q===g)break e;for(;Q.sibling===null;){if(Q.return===null||Q.return===g)break e;Q=Q.return}Q.sibling.return=Q.return,Q=Q.sibling}g.stateNode=F;e:switch(da(F,P,E),P){case"button":case"input":case"select":case"textarea":E=!!E.autoFocus;break e;case"img":E=!0;break e;default:E=!1}E&&wc(g)}}return Rr(g),tA(g,g.type,h===null?null:h.memoizedProps,g.pendingProps,_),null;case 6:if(h&&g.stateNode!=null)h.memoizedProps!==E&&wc(g);else{if(typeof E!="string"&&g.stateNode===null)throw Error(r(166));if(h=fe.current,Mm(g)){if(h=g.stateNode,_=g.memoizedProps,E=null,P=la,P!==null)switch(P.tag){case 27:case 5:E=P.memoizedProps}h[Un]=g,h=!!(h.nodeValue===_||E!==null&&E.suppressHydrationWarning===!0||gU(h.nodeValue,_)),h||Pu(g,!0)}else h=Xv(h).createTextNode(E),h[Un]=g,g.stateNode=h}return Rr(g),null;case 31:if(_=g.memoizedState,h===null||h.memoizedState!==null){if(E=Mm(g),_!==null){if(h===null){if(!E)throw Error(r(318));if(h=g.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(557));h[Un]=g}else Mh(),(g.flags&128)===0&&(g.memoizedState=null),g.flags|=4;Rr(g),h=!1}else _=d2(),h!==null&&h.memoizedState!==null&&(h.memoizedState.hydrationErrors=_),h=!0;if(!h)return g.flags&256?(Ps(g),g):(Ps(g),null);if((g.flags&128)!==0)throw Error(r(558))}return Rr(g),null;case 13:if(E=g.memoizedState,h===null||h.memoizedState!==null&&h.memoizedState.dehydrated!==null){if(P=Mm(g),E!==null&&E.dehydrated!==null){if(h===null){if(!P)throw Error(r(318));if(P=g.memoizedState,P=P!==null?P.dehydrated:null,!P)throw Error(r(317));P[Un]=g}else Mh(),(g.flags&128)===0&&(g.memoizedState=null),g.flags|=4;Rr(g),P=!1}else P=d2(),h!==null&&h.memoizedState!==null&&(h.memoizedState.hydrationErrors=P),P=!0;if(!P)return g.flags&256?(Ps(g),g):(Ps(g),null)}return Ps(g),(g.flags&128)!==0?(g.lanes=_,g):(_=E!==null,h=h!==null&&h.memoizedState!==null,_&&(E=g.child,P=null,E.alternate!==null&&E.alternate.memoizedState!==null&&E.alternate.memoizedState.cachePool!==null&&(P=E.alternate.memoizedState.cachePool.pool),F=null,E.memoizedState!==null&&E.memoizedState.cachePool!==null&&(F=E.memoizedState.cachePool.pool),F!==P&&(E.flags|=2048)),_!==h&&_&&(g.child.flags|=8192),Dv(g,g.updateQueue),Rr(g),null);case 4:return ge(),h===null&&SA(g.stateNode.containerInfo),Rr(g),null;case 10:return bc(g.type),Rr(g),null;case 19:if(H(di),E=g.memoizedState,E===null)return Rr(g),null;if(P=(g.flags&128)!==0,F=E.rendering,F===null)if(P)Ux(E,!1);else{if(Qr!==0||h!==null&&(h.flags&128)!==0)for(h=g.child;h!==null;){if(F=_v(h),F!==null){for(g.flags|=128,Ux(E,!1),h=F.updateQueue,g.updateQueue=h,Dv(g,h),g.subtreeFlags=0,h=_,_=g.child;_!==null;)KI(_,h),_=_.sibling;return Z(di,di.current&1|2),Ln&&gc(g,E.treeForkCount),g.child}h=h.sibling}E.tail!==null&&O()>Uv&&(g.flags|=128,P=!0,Ux(E,!1),g.lanes=4194304)}else{if(!P)if(h=_v(F),h!==null){if(g.flags|=128,P=!0,h=h.updateQueue,g.updateQueue=h,Dv(g,h),Ux(E,!0),E.tail===null&&E.tailMode==="hidden"&&!F.alternate&&!Ln)return Rr(g),null}else 2*O()-E.renderingStartTime>Uv&&_!==536870912&&(g.flags|=128,P=!0,Ux(E,!1),g.lanes=4194304);E.isBackwards?(F.sibling=g.child,g.child=F):(h=E.last,h!==null?h.sibling=F:g.child=F,E.last=F)}return E.tail!==null?(h=E.tail,E.rendering=h,E.tail=h.sibling,E.renderingStartTime=O(),h.sibling=null,_=di.current,Z(di,P?_&1|2:_&1),Ln&&gc(g,E.treeForkCount),h):(Rr(g),null);case 22:case 23:return Ps(g),M2(),E=g.memoizedState!==null,h!==null?h.memoizedState!==null!==E&&(g.flags|=8192):E&&(g.flags|=8192),E?(_&536870912)!==0&&(g.flags&128)===0&&(Rr(g),g.subtreeFlags&6&&(g.flags|=8192)):Rr(g),_=g.updateQueue,_!==null&&Dv(g,_.retryQueue),_=null,h!==null&&h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(_=h.memoizedState.cachePool.pool),E=null,g.memoizedState!==null&&g.memoizedState.cachePool!==null&&(E=g.memoizedState.cachePool.pool),E!==_&&(g.flags|=2048),h!==null&&H(Ah),null;case 24:return _=null,h!==null&&(_=h.memoizedState.cache),g.memoizedState.cache!==_&&(g.flags|=2048),bc(xi),Rr(g),null;case 25:return null;case 30:return null}throw Error(r(156,g.tag))}function Zae(h,g){switch(c2(g),g.tag){case 1:return h=g.flags,h&65536?(g.flags=h&-65537|128,g):null;case 3:return bc(xi),ge(),h=g.flags,(h&65536)!==0&&(h&128)===0?(g.flags=h&-65537|128,g):null;case 26:case 27:case 5:return Re(g),null;case 31:if(g.memoizedState!==null){if(Ps(g),g.alternate===null)throw Error(r(340));Mh()}return h=g.flags,h&65536?(g.flags=h&-65537|128,g):null;case 13:if(Ps(g),h=g.memoizedState,h!==null&&h.dehydrated!==null){if(g.alternate===null)throw Error(r(340));Mh()}return h=g.flags,h&65536?(g.flags=h&-65537|128,g):null;case 19:return H(di),null;case 4:return ge(),null;case 10:return bc(g.type),null;case 22:case 23:return Ps(g),M2(),h!==null&&H(Ah),h=g.flags,h&65536?(g.flags=h&-65537|128,g):null;case 24:return bc(xi),null;case 25:return null;default:return null}}function _5(h,g){switch(c2(g),g.tag){case 3:bc(xi),ge();break;case 26:case 27:case 5:Re(g);break;case 4:ge();break;case 31:g.memoizedState!==null&&Ps(g);break;case 13:Ps(g);break;case 19:H(di);break;case 10:bc(g.type);break;case 22:case 23:Ps(g),M2(),h!==null&&H(Ah);break;case 24:bc(xi)}}function zx(h,g){try{var _=g.updateQueue,E=_!==null?_.lastEffect:null;if(E!==null){var P=E.next;_=P;do{if((_.tag&h)===h){E=void 0;var F=_.create,Q=_.inst;E=F(),Q.destroy=E}_=_.next}while(_!==P)}}catch(xe){sr(g,g.return,xe)}}function Uu(h,g,_){try{var E=g.updateQueue,P=E!==null?E.lastEffect:null;if(P!==null){var F=P.next;E=F;do{if((E.tag&h)===h){var Q=E.inst,xe=Q.destroy;if(xe!==void 0){Q.destroy=void 0,P=g;var Pe=_,at=xe;try{at()}catch(bt){sr(P,Pe,bt)}}}E=E.next}while(E!==F)}}catch(bt){sr(g,g.return,bt)}}function w5(h){var g=h.updateQueue;if(g!==null){var _=h.stateNode;try{hF(g,_)}catch(E){sr(h,h.return,E)}}}function S5(h,g,_){_.props=Ph(h.type,h.memoizedProps),_.state=h.memoizedState;try{_.componentWillUnmount()}catch(E){sr(h,g,E)}}function Bx(h,g){try{var _=h.ref;if(_!==null){switch(h.tag){case 26:case 27:case 5:var E=h.stateNode;break;case 30:E=h.stateNode;break;default:E=h.stateNode}typeof _=="function"?h.refCleanup=_(E):_.current=E}}catch(P){sr(h,g,P)}}function wl(h,g){var _=h.ref,E=h.refCleanup;if(_!==null)if(typeof E=="function")try{E()}catch(P){sr(h,g,P)}finally{h.refCleanup=null,h=h.alternate,h!=null&&(h.refCleanup=null)}else if(typeof _=="function")try{_(null)}catch(P){sr(h,g,P)}else _.current=null}function M5(h){var g=h.type,_=h.memoizedProps,E=h.stateNode;try{e:switch(g){case"button":case"input":case"select":case"textarea":_.autoFocus&&E.focus();break e;case"img":_.src?E.src=_.src:_.srcSet&&(E.srcset=_.srcSet)}}catch(P){sr(h,h.return,P)}}function nA(h,g,_){try{var E=h.stateNode;yse(E,h.type,_,g),E[yr]=g}catch(P){sr(h,h.return,P)}}function E5(h){return h.tag===5||h.tag===3||h.tag===26||h.tag===27&&Wu(h.type)||h.tag===4}function rA(h){e:for(;;){for(;h.sibling===null;){if(h.return===null||E5(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&&Wu(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 iA(h,g,_){var E=h.tag;if(E===5||E===6)h=h.stateNode,g?(_.nodeType===9?_.body:_.nodeName==="HTML"?_.ownerDocument.body:_).insertBefore(h,g):(g=_.nodeType===9?_.body:_.nodeName==="HTML"?_.ownerDocument.body:_,g.appendChild(h),_=_._reactRootContainer,_!=null||g.onclick!==null||(g.onclick=fc));else if(E!==4&&(E===27&&Wu(h.type)&&(_=h.stateNode,g=null),h=h.child,h!==null))for(iA(h,g,_),h=h.sibling;h!==null;)iA(h,g,_),h=h.sibling}function Ov(h,g,_){var E=h.tag;if(E===5||E===6)h=h.stateNode,g?_.insertBefore(h,g):_.appendChild(h);else if(E!==4&&(E===27&&Wu(h.type)&&(_=h.stateNode),h=h.child,h!==null))for(Ov(h,g,_),h=h.sibling;h!==null;)Ov(h,g,_),h=h.sibling}function N5(h){var g=h.stateNode,_=h.memoizedProps;try{for(var E=h.type,P=g.attributes;P.length;)g.removeAttributeNode(P[0]);da(g,E,_),g[Un]=h,g[yr]=_}catch(F){sr(h,h.return,F)}}var Sc=!1,vi=!1,aA=!1,A5=typeof WeakSet=="function"?WeakSet:Set,Gi=null;function Qae(h,g){if(h=h.containerInfo,NA=n_,h=UI(h),QN(h)){if("selectionStart"in h)var _={start:h.selectionStart,end:h.selectionEnd};else e:{_=(_=h.ownerDocument)&&_.defaultView||window;var E=_.getSelection&&_.getSelection();if(E&&E.rangeCount!==0){_=E.anchorNode;var P=E.anchorOffset,F=E.focusNode;E=E.focusOffset;try{_.nodeType,F.nodeType}catch{_=null;break e}var Q=0,xe=-1,Pe=-1,at=0,bt=0,_t=h,ot=null;t:for(;;){for(var ht;_t!==_||P!==0&&_t.nodeType!==3||(xe=Q+P),_t!==F||E!==0&&_t.nodeType!==3||(Pe=Q+E),_t.nodeType===3&&(Q+=_t.nodeValue.length),(ht=_t.firstChild)!==null;)ot=_t,_t=ht;for(;;){if(_t===h)break t;if(ot===_&&++at===P&&(xe=Q),ot===F&&++bt===E&&(Pe=Q),(ht=_t.nextSibling)!==null)break;_t=ot,ot=_t.parentNode}_t=ht}_=xe===-1||Pe===-1?null:{start:xe,end:Pe}}else _=null}_=_||{start:0,end:0}}else _=null;for(AA={focusedElem:h,selectionRange:_},n_=!1,Gi=g;Gi!==null;)if(g=Gi,h=g.child,(g.subtreeFlags&1028)!==0&&h!==null)h.return=g,Gi=h;else for(;Gi!==null;){switch(g=Gi,F=g.alternate,h=g.flags,g.tag){case 0:if((h&4)!==0&&(h=g.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&&F!==null){h=void 0,_=g,P=F.memoizedProps,F=F.memoizedState,E=_.stateNode;try{var qt=Ph(_.type,P);h=E.getSnapshotBeforeUpdate(qt,F),E.__reactInternalSnapshotBeforeUpdate=h}catch(an){sr(_,_.return,an)}}break;case 3:if((h&1024)!==0){if(h=g.stateNode.containerInfo,_=h.nodeType,_===9)kA(h);else if(_===1)switch(h.nodeName){case"HEAD":case"HTML":case"BODY":kA(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=g.sibling,h!==null){h.return=g.return,Gi=h;break}Gi=g.return}}function T5(h,g,_){var E=_.flags;switch(_.tag){case 0:case 11:case 15:Ec(h,_),E&4&&zx(5,_);break;case 1:if(Ec(h,_),E&4)if(h=_.stateNode,g===null)try{h.componentDidMount()}catch(Q){sr(_,_.return,Q)}else{var P=Ph(_.type,g.memoizedProps);g=g.memoizedState;try{h.componentDidUpdate(P,g,h.__reactInternalSnapshotBeforeUpdate)}catch(Q){sr(_,_.return,Q)}}E&64&&w5(_),E&512&&Bx(_,_.return);break;case 3:if(Ec(h,_),E&64&&(h=_.updateQueue,h!==null)){if(g=null,_.child!==null)switch(_.child.tag){case 27:case 5:g=_.child.stateNode;break;case 1:g=_.child.stateNode}try{hF(h,g)}catch(Q){sr(_,_.return,Q)}}break;case 27:g===null&&E&4&&N5(_);case 26:case 5:Ec(h,_),g===null&&E&4&&M5(_),E&512&&Bx(_,_.return);break;case 12:Ec(h,_);break;case 31:Ec(h,_),E&4&&j5(h,_);break;case 13:Ec(h,_),E&4&&P5(h,_),E&64&&(h=_.memoizedState,h!==null&&(h=h.dehydrated,h!==null&&(_=ose.bind(null,_),Ase(h,_))));break;case 22:if(E=_.memoizedState!==null||Sc,!E){g=g!==null&&g.memoizedState!==null||vi,P=Sc;var F=vi;Sc=E,(vi=g)&&!F?Nc(h,_,(_.subtreeFlags&8772)!==0):Ec(h,_),Sc=P,vi=F}break;case 30:break;default:Ec(h,_)}}function C5(h){var g=h.alternate;g!==null&&(h.alternate=null,C5(g)),h.child=null,h.deletions=null,h.sibling=null,h.tag===5&&(g=h.stateNode,g!==null&&st(g)),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 Ir=null,ls=!1;function Mc(h,g,_){for(_=_.child;_!==null;)k5(h,g,_),_=_.sibling}function k5(h,g,_){if(se&&typeof se.onCommitFiberUnmount=="function")try{se.onCommitFiberUnmount(Ye,_)}catch{}switch(_.tag){case 26:vi||wl(_,g),Mc(h,g,_),_.memoizedState?_.memoizedState.count--:_.stateNode&&(_=_.stateNode,_.parentNode.removeChild(_));break;case 27:vi||wl(_,g);var E=Ir,P=ls;Wu(_.type)&&(Ir=_.stateNode,ls=!1),Mc(h,g,_),Yx(_.stateNode),Ir=E,ls=P;break;case 5:vi||wl(_,g);case 6:if(E=Ir,P=ls,Ir=null,Mc(h,g,_),Ir=E,ls=P,Ir!==null)if(ls)try{(Ir.nodeType===9?Ir.body:Ir.nodeName==="HTML"?Ir.ownerDocument.body:Ir).removeChild(_.stateNode)}catch(F){sr(_,g,F)}else try{Ir.removeChild(_.stateNode)}catch(F){sr(_,g,F)}break;case 18:Ir!==null&&(ls?(h=Ir,wU(h.nodeType===9?h.body:h.nodeName==="HTML"?h.ownerDocument.body:h,_.stateNode),Gm(h)):wU(Ir,_.stateNode));break;case 4:E=Ir,P=ls,Ir=_.stateNode.containerInfo,ls=!0,Mc(h,g,_),Ir=E,ls=P;break;case 0:case 11:case 14:case 15:Uu(2,_,g),vi||Uu(4,_,g),Mc(h,g,_);break;case 1:vi||(wl(_,g),E=_.stateNode,typeof E.componentWillUnmount=="function"&&S5(_,g,E)),Mc(h,g,_);break;case 21:Mc(h,g,_);break;case 22:vi=(E=vi)||_.memoizedState!==null,Mc(h,g,_),vi=E;break;default:Mc(h,g,_)}}function j5(h,g){if(g.memoizedState===null&&(h=g.alternate,h!==null&&(h=h.memoizedState,h!==null))){h=h.dehydrated;try{Gm(h)}catch(_){sr(g,g.return,_)}}}function P5(h,g){if(g.memoizedState===null&&(h=g.alternate,h!==null&&(h=h.memoizedState,h!==null&&(h=h.dehydrated,h!==null))))try{Gm(h)}catch(_){sr(g,g.return,_)}}function Jae(h){switch(h.tag){case 31:case 13:case 19:var g=h.stateNode;return g===null&&(g=h.stateNode=new A5),g;case 22:return h=h.stateNode,g=h._retryCache,g===null&&(g=h._retryCache=new A5),g;default:throw Error(r(435,h.tag))}}function Lv(h,g){var _=Jae(h);g.forEach(function(E){if(!_.has(E)){_.add(E);var P=lse.bind(null,h,E);E.then(P,P)}})}function cs(h,g){var _=g.deletions;if(_!==null)for(var E=0;E<_.length;E++){var P=_[E],F=h,Q=g,xe=Q;e:for(;xe!==null;){switch(xe.tag){case 27:if(Wu(xe.type)){Ir=xe.stateNode,ls=!1;break e}break;case 5:Ir=xe.stateNode,ls=!1;break e;case 3:case 4:Ir=xe.stateNode.containerInfo,ls=!0;break e}xe=xe.return}if(Ir===null)throw Error(r(160));k5(F,Q,P),Ir=null,ls=!1,F=P.alternate,F!==null&&(F.return=null),P.return=null}if(g.subtreeFlags&13886)for(g=g.child;g!==null;)R5(g,h),g=g.sibling}var zo=null;function R5(h,g){var _=h.alternate,E=h.flags;switch(h.tag){case 0:case 11:case 14:case 15:cs(g,h),us(h),E&4&&(Uu(3,h,h.return),zx(3,h),Uu(5,h,h.return));break;case 1:cs(g,h),us(h),E&512&&(vi||_===null||wl(_,_.return)),E&64&&Sc&&(h=h.updateQueue,h!==null&&(E=h.callbacks,E!==null&&(_=h.shared.hiddenCallbacks,h.shared.hiddenCallbacks=_===null?E:_.concat(E))));break;case 26:var P=zo;if(cs(g,h),us(h),E&512&&(vi||_===null||wl(_,_.return)),E&4){var F=_!==null?_.memoizedState:null;if(E=h.memoizedState,_===null)if(E===null)if(h.stateNode===null){e:{E=h.type,_=h.memoizedProps,P=P.ownerDocument||P;t:switch(E){case"title":F=P.getElementsByTagName("title")[0],(!F||F[lt]||F[Un]||F.namespaceURI==="http://www.w3.org/2000/svg"||F.hasAttribute("itemprop"))&&(F=P.createElement(E),P.head.insertBefore(F,P.querySelector("head > title"))),da(F,E,_),F[Un]=h,ue(F),E=F;break e;case"link":var Q=RU("link","href",P).get(E+(_.href||""));if(Q){for(var xe=0;xe<Q.length;xe++)if(F=Q[xe],F.getAttribute("href")===(_.href==null||_.href===""?null:_.href)&&F.getAttribute("rel")===(_.rel==null?null:_.rel)&&F.getAttribute("title")===(_.title==null?null:_.title)&&F.getAttribute("crossorigin")===(_.crossOrigin==null?null:_.crossOrigin)){Q.splice(xe,1);break t}}F=P.createElement(E),da(F,E,_),P.head.appendChild(F);break;case"meta":if(Q=RU("meta","content",P).get(E+(_.content||""))){for(xe=0;xe<Q.length;xe++)if(F=Q[xe],F.getAttribute("content")===(_.content==null?null:""+_.content)&&F.getAttribute("name")===(_.name==null?null:_.name)&&F.getAttribute("property")===(_.property==null?null:_.property)&&F.getAttribute("http-equiv")===(_.httpEquiv==null?null:_.httpEquiv)&&F.getAttribute("charset")===(_.charSet==null?null:_.charSet)){Q.splice(xe,1);break t}}F=P.createElement(E),da(F,E,_),P.head.appendChild(F);break;default:throw Error(r(468,E))}F[Un]=h,ue(F),E=F}h.stateNode=E}else DU(P,h.type,h.stateNode);else h.stateNode=PU(P,E,h.memoizedProps);else F!==E?(F===null?_.stateNode!==null&&(_=_.stateNode,_.parentNode.removeChild(_)):F.count--,E===null?DU(P,h.type,h.stateNode):PU(P,E,h.memoizedProps)):E===null&&h.stateNode!==null&&nA(h,h.memoizedProps,_.memoizedProps)}break;case 27:cs(g,h),us(h),E&512&&(vi||_===null||wl(_,_.return)),_!==null&&E&4&&nA(h,h.memoizedProps,_.memoizedProps);break;case 5:if(cs(g,h),us(h),E&512&&(vi||_===null||wl(_,_.return)),h.flags&32){P=h.stateNode;try{vr(P,"")}catch(qt){sr(h,h.return,qt)}}E&4&&h.stateNode!=null&&(P=h.memoizedProps,nA(h,P,_!==null?_.memoizedProps:P)),E&1024&&(aA=!0);break;case 6:if(cs(g,h),us(h),E&4){if(h.stateNode===null)throw Error(r(162));E=h.memoizedProps,_=h.stateNode;try{_.nodeValue=E}catch(qt){sr(h,h.return,qt)}}break;case 3:if(Qv=null,P=zo,zo=Yv(g.containerInfo),cs(g,h),zo=P,us(h),E&4&&_!==null&&_.memoizedState.isDehydrated)try{Gm(g.containerInfo)}catch(qt){sr(h,h.return,qt)}aA&&(aA=!1,D5(h));break;case 4:E=zo,zo=Yv(h.stateNode.containerInfo),cs(g,h),us(h),zo=E;break;case 12:cs(g,h),us(h);break;case 31:cs(g,h),us(h),E&4&&(E=h.updateQueue,E!==null&&(h.updateQueue=null,Lv(h,E)));break;case 13:cs(g,h),us(h),h.child.flags&8192&&h.memoizedState!==null!=(_!==null&&_.memoizedState!==null)&&(Fv=O()),E&4&&(E=h.updateQueue,E!==null&&(h.updateQueue=null,Lv(h,E)));break;case 22:P=h.memoizedState!==null;var Pe=_!==null&&_.memoizedState!==null,at=Sc,bt=vi;if(Sc=at||P,vi=bt||Pe,cs(g,h),vi=bt,Sc=at,us(h),E&8192)e:for(g=h.stateNode,g._visibility=P?g._visibility&-2:g._visibility|1,P&&(_===null||Pe||Sc||vi||Rh(h)),_=null,g=h;;){if(g.tag===5||g.tag===26){if(_===null){Pe=_=g;try{if(F=Pe.stateNode,P)Q=F.style,typeof Q.setProperty=="function"?Q.setProperty("display","none","important"):Q.display="none";else{xe=Pe.stateNode;var _t=Pe.memoizedProps.style,ot=_t!=null&&_t.hasOwnProperty("display")?_t.display:null;xe.style.display=ot==null||typeof ot=="boolean"?"":(""+ot).trim()}}catch(qt){sr(Pe,Pe.return,qt)}}}else if(g.tag===6){if(_===null){Pe=g;try{Pe.stateNode.nodeValue=P?"":Pe.memoizedProps}catch(qt){sr(Pe,Pe.return,qt)}}}else if(g.tag===18){if(_===null){Pe=g;try{var ht=Pe.stateNode;P?SU(ht,!0):SU(Pe.stateNode,!1)}catch(qt){sr(Pe,Pe.return,qt)}}}else if((g.tag!==22&&g.tag!==23||g.memoizedState===null||g===h)&&g.child!==null){g.child.return=g,g=g.child;continue}if(g===h)break e;for(;g.sibling===null;){if(g.return===null||g.return===h)break e;_===g&&(_=null),g=g.return}_===g&&(_=null),g.sibling.return=g.return,g=g.sibling}E&4&&(E=h.updateQueue,E!==null&&(_=E.retryQueue,_!==null&&(E.retryQueue=null,Lv(h,_))));break;case 19:cs(g,h),us(h),E&4&&(E=h.updateQueue,E!==null&&(h.updateQueue=null,Lv(h,E)));break;case 30:break;case 21:break;default:cs(g,h),us(h)}}function us(h){var g=h.flags;if(g&2){try{for(var _,E=h.return;E!==null;){if(E5(E)){_=E;break}E=E.return}if(_==null)throw Error(r(160));switch(_.tag){case 27:var P=_.stateNode,F=rA(h);Ov(h,F,P);break;case 5:var Q=_.stateNode;_.flags&32&&(vr(Q,""),_.flags&=-33);var xe=rA(h);Ov(h,xe,Q);break;case 3:case 4:var Pe=_.stateNode.containerInfo,at=rA(h);iA(h,at,Pe);break;default:throw Error(r(161))}}catch(bt){sr(h,h.return,bt)}h.flags&=-3}g&4096&&(h.flags&=-4097)}function D5(h){if(h.subtreeFlags&1024)for(h=h.child;h!==null;){var g=h;D5(g),g.tag===5&&g.flags&1024&&g.stateNode.reset(),h=h.sibling}}function Ec(h,g){if(g.subtreeFlags&8772)for(g=g.child;g!==null;)T5(h,g.alternate,g),g=g.sibling}function Rh(h){for(h=h.child;h!==null;){var g=h;switch(g.tag){case 0:case 11:case 14:case 15:Uu(4,g,g.return),Rh(g);break;case 1:wl(g,g.return);var _=g.stateNode;typeof _.componentWillUnmount=="function"&&S5(g,g.return,_),Rh(g);break;case 27:Yx(g.stateNode);case 26:case 5:wl(g,g.return),Rh(g);break;case 22:g.memoizedState===null&&Rh(g);break;case 30:Rh(g);break;default:Rh(g)}h=h.sibling}}function Nc(h,g,_){for(_=_&&(g.subtreeFlags&8772)!==0,g=g.child;g!==null;){var E=g.alternate,P=h,F=g,Q=F.flags;switch(F.tag){case 0:case 11:case 15:Nc(P,F,_),zx(4,F);break;case 1:if(Nc(P,F,_),E=F,P=E.stateNode,typeof P.componentDidMount=="function")try{P.componentDidMount()}catch(at){sr(E,E.return,at)}if(E=F,P=E.updateQueue,P!==null){var xe=E.stateNode;try{var Pe=P.shared.hiddenCallbacks;if(Pe!==null)for(P.shared.hiddenCallbacks=null,P=0;P<Pe.length;P++)dF(Pe[P],xe)}catch(at){sr(E,E.return,at)}}_&&Q&64&&w5(F),Bx(F,F.return);break;case 27:N5(F);case 26:case 5:Nc(P,F,_),_&&E===null&&Q&4&&M5(F),Bx(F,F.return);break;case 12:Nc(P,F,_);break;case 31:Nc(P,F,_),_&&Q&4&&j5(P,F);break;case 13:Nc(P,F,_),_&&Q&4&&P5(P,F);break;case 22:F.memoizedState===null&&Nc(P,F,_),Bx(F,F.return);break;case 30:break;default:Nc(P,F,_)}g=g.sibling}}function sA(h,g){var _=null;h!==null&&h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(_=h.memoizedState.cachePool.pool),h=null,g.memoizedState!==null&&g.memoizedState.cachePool!==null&&(h=g.memoizedState.cachePool.pool),h!==_&&(h!=null&&h.refCount++,_!=null&&Ax(_))}function oA(h,g){h=null,g.alternate!==null&&(h=g.alternate.memoizedState.cache),g=g.memoizedState.cache,g!==h&&(g.refCount++,h!=null&&Ax(h))}function Bo(h,g,_,E){if(g.subtreeFlags&10256)for(g=g.child;g!==null;)O5(h,g,_,E),g=g.sibling}function O5(h,g,_,E){var P=g.flags;switch(g.tag){case 0:case 11:case 15:Bo(h,g,_,E),P&2048&&zx(9,g);break;case 1:Bo(h,g,_,E);break;case 3:Bo(h,g,_,E),P&2048&&(h=null,g.alternate!==null&&(h=g.alternate.memoizedState.cache),g=g.memoizedState.cache,g!==h&&(g.refCount++,h!=null&&Ax(h)));break;case 12:if(P&2048){Bo(h,g,_,E),h=g.stateNode;try{var F=g.memoizedProps,Q=F.id,xe=F.onPostCommit;typeof xe=="function"&&xe(Q,g.alternate===null?"mount":"update",h.passiveEffectDuration,-0)}catch(Pe){sr(g,g.return,Pe)}}else Bo(h,g,_,E);break;case 31:Bo(h,g,_,E);break;case 13:Bo(h,g,_,E);break;case 23:break;case 22:F=g.stateNode,Q=g.alternate,g.memoizedState!==null?F._visibility&2?Bo(h,g,_,E):$x(h,g):F._visibility&2?Bo(h,g,_,E):(F._visibility|=2,Dm(h,g,_,E,(g.subtreeFlags&10256)!==0||!1)),P&2048&&sA(Q,g);break;case 24:Bo(h,g,_,E),P&2048&&oA(g.alternate,g);break;default:Bo(h,g,_,E)}}function Dm(h,g,_,E,P){for(P=P&&((g.subtreeFlags&10256)!==0||!1),g=g.child;g!==null;){var F=h,Q=g,xe=_,Pe=E,at=Q.flags;switch(Q.tag){case 0:case 11:case 15:Dm(F,Q,xe,Pe,P),zx(8,Q);break;case 23:break;case 22:var bt=Q.stateNode;Q.memoizedState!==null?bt._visibility&2?Dm(F,Q,xe,Pe,P):$x(F,Q):(bt._visibility|=2,Dm(F,Q,xe,Pe,P)),P&&at&2048&&sA(Q.alternate,Q);break;case 24:Dm(F,Q,xe,Pe,P),P&&at&2048&&oA(Q.alternate,Q);break;default:Dm(F,Q,xe,Pe,P)}g=g.sibling}}function $x(h,g){if(g.subtreeFlags&10256)for(g=g.child;g!==null;){var _=h,E=g,P=E.flags;switch(E.tag){case 22:$x(_,E),P&2048&&sA(E.alternate,E);break;case 24:$x(_,E),P&2048&&oA(E.alternate,E);break;default:$x(_,E)}g=g.sibling}}var Hx=8192;function Om(h,g,_){if(h.subtreeFlags&Hx)for(h=h.child;h!==null;)L5(h,g,_),h=h.sibling}function L5(h,g,_){switch(h.tag){case 26:Om(h,g,_),h.flags&Hx&&h.memoizedState!==null&&Use(_,zo,h.memoizedState,h.memoizedProps);break;case 5:Om(h,g,_);break;case 3:case 4:var E=zo;zo=Yv(h.stateNode.containerInfo),Om(h,g,_),zo=E;break;case 22:h.memoizedState===null&&(E=h.alternate,E!==null&&E.memoizedState!==null?(E=Hx,Hx=16777216,Om(h,g,_),Hx=E):Om(h,g,_));break;default:Om(h,g,_)}}function I5(h){var g=h.alternate;if(g!==null&&(h=g.child,h!==null)){g.child=null;do g=h.sibling,h.sibling=null,h=g;while(h!==null)}}function Vx(h){var g=h.deletions;if((h.flags&16)!==0){if(g!==null)for(var _=0;_<g.length;_++){var E=g[_];Gi=E,U5(E,h)}I5(h)}if(h.subtreeFlags&10256)for(h=h.child;h!==null;)F5(h),h=h.sibling}function F5(h){switch(h.tag){case 0:case 11:case 15:Vx(h),h.flags&2048&&Uu(9,h,h.return);break;case 3:Vx(h);break;case 12:Vx(h);break;case 22:var g=h.stateNode;h.memoizedState!==null&&g._visibility&2&&(h.return===null||h.return.tag!==13)?(g._visibility&=-3,Iv(h)):Vx(h);break;default:Vx(h)}}function Iv(h){var g=h.deletions;if((h.flags&16)!==0){if(g!==null)for(var _=0;_<g.length;_++){var E=g[_];Gi=E,U5(E,h)}I5(h)}for(h=h.child;h!==null;){switch(g=h,g.tag){case 0:case 11:case 15:Uu(8,g,g.return),Iv(g);break;case 22:_=g.stateNode,_._visibility&2&&(_._visibility&=-3,Iv(g));break;default:Iv(g)}h=h.sibling}}function U5(h,g){for(;Gi!==null;){var _=Gi;switch(_.tag){case 0:case 11:case 15:Uu(8,_,g);break;case 23:case 22:if(_.memoizedState!==null&&_.memoizedState.cachePool!==null){var E=_.memoizedState.cachePool.pool;E!=null&&E.refCount++}break;case 24:Ax(_.memoizedState.cache)}if(E=_.child,E!==null)E.return=_,Gi=E;else e:for(_=h;Gi!==null;){E=Gi;var P=E.sibling,F=E.return;if(C5(E),E===_){Gi=null;break e}if(P!==null){P.return=F,Gi=P;break e}Gi=F}}}var ese={getCacheForType:function(h){var g=ca(xi),_=g.data.get(h);return _===void 0&&(_=h(),g.data.set(h,_)),_},cacheSignal:function(){return ca(xi).controller.signal}},tse=typeof WeakMap=="function"?WeakMap:Map,Qn=0,_r=null,kn=null,Dn=0,ar=0,Rs=null,zu=!1,Lm=!1,lA=!1,Ac=0,Qr=0,Bu=0,Dh=0,cA=0,Ds=0,Im=0,Gx=null,ds=null,uA=!1,Fv=0,z5=0,Uv=1/0,zv=null,$u=null,ji=0,Hu=null,Fm=null,Tc=0,dA=0,hA=null,B5=null,Wx=0,fA=null;function Os(){return(Qn&2)!==0&&Dn!==0?Dn&-Dn:K.T!==null?yA():Cn()}function $5(){if(Ds===0)if((Dn&536870912)===0||Ln){var h=ve;ve<<=1,(ve&3932160)===0&&(ve=262144),Ds=h}else Ds=536870912;return h=js.current,h!==null&&(h.flags|=32),Ds}function hs(h,g,_){(h===_r&&(ar===2||ar===9)||h.cancelPendingCommit!==null)&&(Um(h,0),Vu(h,Dn,Ds,!1)),on(h,_),((Qn&2)===0||h!==_r)&&(h===_r&&((Qn&2)===0&&(Dh|=_),Qr===4&&Vu(h,Dn,Ds,!1)),Sl(h))}function H5(h,g,_){if((Qn&6)!==0)throw Error(r(327));var E=!_&&(g&127)===0&&(g&h.expiredLanes)===0||Ge(h,g),P=E?ise(h,g):pA(h,g,!0),F=E;do{if(P===0){Lm&&!E&&Vu(h,g,0,!1);break}else{if(_=h.current.alternate,F&&!nse(_)){P=pA(h,g,!1),F=!1;continue}if(P===2){if(F=g,h.errorRecoveryDisabledLanes&F)var Q=0;else Q=h.pendingLanes&-536870913,Q=Q!==0?Q:Q&536870912?536870912:0;if(Q!==0){g=Q;e:{var xe=h;P=Gx;var Pe=xe.current.memoizedState.isDehydrated;if(Pe&&(Um(xe,Q).flags|=256),Q=pA(xe,Q,!1),Q!==2){if(lA&&!Pe){xe.errorRecoveryDisabledLanes|=F,Dh|=F,P=4;break e}F=ds,ds=P,F!==null&&(ds===null?ds=F:ds.push.apply(ds,F))}P=Q}if(F=!1,P!==2)continue}}if(P===1){Um(h,0),Vu(h,g,0,!0);break}e:{switch(E=h,F=P,F){case 0:case 1:throw Error(r(345));case 4:if((g&4194048)!==g)break;case 6:Vu(E,g,Ds,!zu);break e;case 2:ds=null;break;case 3:case 5:break;default:throw Error(r(329))}if((g&62914560)===g&&(P=Fv+300-O(),10<P)){if(Vu(E,g,Ds,!zu),Ae(E,0,!0)!==0)break e;Tc=g,E.timeoutHandle=vU(V5.bind(null,E,_,ds,zv,uA,g,Ds,Dh,Im,zu,F,"Throttled",-0,0),P);break e}V5(E,_,ds,zv,uA,g,Ds,Dh,Im,zu,F,null,-0,0)}}break}while(!0);Sl(h)}function V5(h,g,_,E,P,F,Q,xe,Pe,at,bt,_t,ot,ht){if(h.timeoutHandle=-1,_t=g.subtreeFlags,_t&8192||(_t&16785408)===16785408){_t={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:fc},L5(g,F,_t);var qt=(F&62914560)===F?Fv-O():(F&4194048)===F?z5-O():0;if(qt=zse(_t,qt),qt!==null){Tc=F,h.cancelPendingCommit=qt(Q5.bind(null,h,g,F,_,E,P,Q,xe,Pe,bt,_t,null,ot,ht)),Vu(h,F,Q,!at);return}}Q5(h,g,F,_,E,P,Q,xe,Pe)}function nse(h){for(var g=h;;){var _=g.tag;if((_===0||_===11||_===15)&&g.flags&16384&&(_=g.updateQueue,_!==null&&(_=_.stores,_!==null)))for(var E=0;E<_.length;E++){var P=_[E],F=P.getSnapshot;P=P.value;try{if(!Cs(F(),P))return!1}catch{return!1}}if(_=g.child,g.subtreeFlags&16384&&_!==null)_.return=g,g=_;else{if(g===h)break;for(;g.sibling===null;){if(g.return===null||g.return===h)return!0;g=g.return}g.sibling.return=g.return,g=g.sibling}}return!0}function Vu(h,g,_,E){g&=~cA,g&=~Dh,h.suspendedLanes|=g,h.pingedLanes&=~g,E&&(h.warmLanes|=g),E=h.expirationTimes;for(var P=g;0<P;){var F=31-Ce(P),Q=1<<F;E[F]=-1,P&=~Q}_!==0&&yn(h,_,g)}function Bv(){return(Qn&6)===0?(qx(0),!1):!0}function mA(){if(kn!==null){if(ar===0)var h=kn.return;else h=kn,xc=Eh=null,k2(h),Cm=null,Cx=0,h=kn;for(;h!==null;)_5(h.alternate,h),h=h.return;kn=null}}function Um(h,g){var _=h.timeoutHandle;_!==-1&&(h.timeoutHandle=-1,wse(_)),_=h.cancelPendingCommit,_!==null&&(h.cancelPendingCommit=null,_()),Tc=0,mA(),_r=h,kn=_=pc(h.current,null),Dn=g,ar=0,Rs=null,zu=!1,Lm=Ge(h,g),lA=!1,Im=Ds=cA=Dh=Bu=Qr=0,ds=Gx=null,uA=!1,(g&8)!==0&&(g|=g&32);var E=h.entangledLanes;if(E!==0)for(h=h.entanglements,E&=g;0<E;){var P=31-Ce(E),F=1<<P;g|=h[P],E&=~F}return Ac=g,lv(),_}function G5(h,g){bn=null,K.H=Ix,g===Tm||g===gv?(g=oF(),ar=3):g===b2?(g=oF(),ar=4):ar=g===W2?8:g!==null&&typeof g=="object"&&typeof g.then=="function"?6:1,Rs=g,kn===null&&(Qr=1,kv(h,ro(g,h.current)))}function W5(){var h=js.current;return h===null?!0:(Dn&4194048)===Dn?oo===null:(Dn&62914560)===Dn||(Dn&536870912)!==0?h===oo:!1}function q5(){var h=K.H;return K.H=Ix,h===null?Ix:h}function K5(){var h=K.A;return K.A=ese,h}function $v(){Qr=4,zu||(Dn&4194048)!==Dn&&js.current!==null||(Lm=!0),(Bu&134217727)===0&&(Dh&134217727)===0||_r===null||Vu(_r,Dn,Ds,!1)}function pA(h,g,_){var E=Qn;Qn|=2;var P=q5(),F=K5();(_r!==h||Dn!==g)&&(zv=null,Um(h,g)),g=!1;var Q=Qr;e:do try{if(ar!==0&&kn!==null){var xe=kn,Pe=Rs;switch(ar){case 8:mA(),Q=6;break e;case 3:case 2:case 9:case 6:js.current===null&&(g=!0);var at=ar;if(ar=0,Rs=null,zm(h,xe,Pe,at),_&&Lm){Q=0;break e}break;default:at=ar,ar=0,Rs=null,zm(h,xe,Pe,at)}}rse(),Q=Qr;break}catch(bt){G5(h,bt)}while(!0);return g&&h.shellSuspendCounter++,xc=Eh=null,Qn=E,K.H=P,K.A=F,kn===null&&(_r=null,Dn=0,lv()),Q}function rse(){for(;kn!==null;)X5(kn)}function ise(h,g){var _=Qn;Qn|=2;var E=q5(),P=K5();_r!==h||Dn!==g?(zv=null,Uv=O()+500,Um(h,g)):Lm=Ge(h,g);e:do try{if(ar!==0&&kn!==null){g=kn;var F=Rs;t:switch(ar){case 1:ar=0,Rs=null,zm(h,g,F,1);break;case 2:case 9:if(aF(F)){ar=0,Rs=null,Y5(g);break}g=function(){ar!==2&&ar!==9||_r!==h||(ar=7),Sl(h)},F.then(g,g);break e;case 3:ar=7;break e;case 4:ar=5;break e;case 7:aF(F)?(ar=0,Rs=null,Y5(g)):(ar=0,Rs=null,zm(h,g,F,7));break;case 5:var Q=null;switch(kn.tag){case 26:Q=kn.memoizedState;case 5:case 27:var xe=kn;if(Q?OU(Q):xe.stateNode.complete){ar=0,Rs=null;var Pe=xe.sibling;if(Pe!==null)kn=Pe;else{var at=xe.return;at!==null?(kn=at,Hv(at)):kn=null}break t}}ar=0,Rs=null,zm(h,g,F,5);break;case 6:ar=0,Rs=null,zm(h,g,F,6);break;case 8:mA(),Qr=6;break e;default:throw Error(r(462))}}ase();break}catch(bt){G5(h,bt)}while(!0);return xc=Eh=null,K.H=E,K.A=P,Qn=_,kn!==null?0:(_r=null,Dn=0,lv(),Qr)}function ase(){for(;kn!==null&&!le();)X5(kn)}function X5(h){var g=y5(h.alternate,h,Ac);h.memoizedProps=h.pendingProps,g===null?Hv(h):kn=g}function Y5(h){var g=h,_=g.alternate;switch(g.tag){case 15:case 0:g=f5(_,g,g.pendingProps,g.type,void 0,Dn);break;case 11:g=f5(_,g,g.pendingProps,g.type.render,g.ref,Dn);break;case 5:k2(g);default:_5(_,g),g=kn=KI(g,Ac),g=y5(_,g,Ac)}h.memoizedProps=h.pendingProps,g===null?Hv(h):kn=g}function zm(h,g,_,E){xc=Eh=null,k2(g),Cm=null,Cx=0;var P=g.return;try{if(qae(h,P,g,_,Dn)){Qr=1,kv(h,ro(_,h.current)),kn=null;return}}catch(F){if(P!==null)throw kn=P,F;Qr=1,kv(h,ro(_,h.current)),kn=null;return}g.flags&32768?(Ln||E===1?h=!0:Lm||(Dn&536870912)!==0?h=!1:(zu=h=!0,(E===2||E===9||E===3||E===6)&&(E=js.current,E!==null&&E.tag===13&&(E.flags|=16384))),Z5(g,h)):Hv(g)}function Hv(h){var g=h;do{if((g.flags&32768)!==0){Z5(g,zu);return}h=g.return;var _=Yae(g.alternate,g,Ac);if(_!==null){kn=_;return}if(g=g.sibling,g!==null){kn=g;return}kn=g=h}while(g!==null);Qr===0&&(Qr=5)}function Z5(h,g){do{var _=Zae(h.alternate,h);if(_!==null){_.flags&=32767,kn=_;return}if(_=h.return,_!==null&&(_.flags|=32768,_.subtreeFlags=0,_.deletions=null),!g&&(h=h.sibling,h!==null)){kn=h;return}kn=h=_}while(h!==null);Qr=6,kn=null}function Q5(h,g,_,E,P,F,Q,xe,Pe){h.cancelPendingCommit=null;do Vv();while(ji!==0);if((Qn&6)!==0)throw Error(r(327));if(g!==null){if(g===h.current)throw Error(r(177));if(F=g.lanes|g.childLanes,F|=r2,Ut(h,_,F,Q,xe,Pe),h===_r&&(kn=_r=null,Dn=0),Fm=g,Hu=h,Tc=_,dA=F,hA=P,B5=E,(g.subtreeFlags&10256)!==0||(g.flags&10256)!==0?(h.callbackNode=null,h.callbackPriority=0,cse(ae,function(){return rU(),null})):(h.callbackNode=null,h.callbackPriority=0),E=(g.flags&13878)!==0,(g.subtreeFlags&13878)!==0||E){E=K.T,K.T=null,P=V.p,V.p=2,Q=Qn,Qn|=4;try{Qae(h,g,_)}finally{Qn=Q,V.p=P,K.T=E}}ji=1,J5(),eU(),tU()}}function J5(){if(ji===1){ji=0;var h=Hu,g=Fm,_=(g.flags&13878)!==0;if((g.subtreeFlags&13878)!==0||_){_=K.T,K.T=null;var E=V.p;V.p=2;var P=Qn;Qn|=4;try{R5(g,h);var F=AA,Q=UI(h.containerInfo),xe=F.focusedElem,Pe=F.selectionRange;if(Q!==xe&&xe&&xe.ownerDocument&&FI(xe.ownerDocument.documentElement,xe)){if(Pe!==null&&QN(xe)){var at=Pe.start,bt=Pe.end;if(bt===void 0&&(bt=at),"selectionStart"in xe)xe.selectionStart=at,xe.selectionEnd=Math.min(bt,xe.value.length);else{var _t=xe.ownerDocument||document,ot=_t&&_t.defaultView||window;if(ot.getSelection){var ht=ot.getSelection(),qt=xe.textContent.length,an=Math.min(Pe.start,qt),hr=Pe.end===void 0?an:Math.min(Pe.end,qt);!ht.extend&&an>hr&&(Q=hr,hr=an,an=Q);var Xe=II(xe,an),ze=II(xe,hr);if(Xe&&ze&&(ht.rangeCount!==1||ht.anchorNode!==Xe.node||ht.anchorOffset!==Xe.offset||ht.focusNode!==ze.node||ht.focusOffset!==ze.offset)){var rt=_t.createRange();rt.setStart(Xe.node,Xe.offset),ht.removeAllRanges(),an>hr?(ht.addRange(rt),ht.extend(ze.node,ze.offset)):(rt.setEnd(ze.node,ze.offset),ht.addRange(rt))}}}}for(_t=[],ht=xe;ht=ht.parentNode;)ht.nodeType===1&&_t.push({element:ht,left:ht.scrollLeft,top:ht.scrollTop});for(typeof xe.focus=="function"&&xe.focus(),xe=0;xe<_t.length;xe++){var vt=_t[xe];vt.element.scrollLeft=vt.left,vt.element.scrollTop=vt.top}}n_=!!NA,AA=NA=null}finally{Qn=P,V.p=E,K.T=_}}h.current=g,ji=2}}function eU(){if(ji===2){ji=0;var h=Hu,g=Fm,_=(g.flags&8772)!==0;if((g.subtreeFlags&8772)!==0||_){_=K.T,K.T=null;var E=V.p;V.p=2;var P=Qn;Qn|=4;try{T5(h,g.alternate,g)}finally{Qn=P,V.p=E,K.T=_}}ji=3}}function tU(){if(ji===4||ji===3){ji=0,B();var h=Hu,g=Fm,_=Tc,E=B5;(g.subtreeFlags&10256)!==0||(g.flags&10256)!==0?ji=5:(ji=0,Fm=Hu=null,nU(h,h.pendingLanes));var P=h.pendingLanes;if(P===0&&($u=null),Tt(_),g=g.stateNode,se&&typeof se.onCommitFiberRoot=="function")try{se.onCommitFiberRoot(Ye,g,void 0,(g.current.flags&128)===128)}catch{}if(E!==null){g=K.T,P=V.p,V.p=2,K.T=null;try{for(var F=h.onRecoverableError,Q=0;Q<E.length;Q++){var xe=E[Q];F(xe.value,{componentStack:xe.stack})}}finally{K.T=g,V.p=P}}(Tc&3)!==0&&Vv(),Sl(h),P=h.pendingLanes,(_&261930)!==0&&(P&42)!==0?h===fA?Wx++:(Wx=0,fA=h):Wx=0,qx(0)}}function nU(h,g){(h.pooledCacheLanes&=g)===0&&(g=h.pooledCache,g!=null&&(h.pooledCache=null,Ax(g)))}function Vv(){return J5(),eU(),tU(),rU()}function rU(){if(ji!==5)return!1;var h=Hu,g=dA;dA=0;var _=Tt(Tc),E=K.T,P=V.p;try{V.p=32>_?32:_,K.T=null,_=hA,hA=null;var F=Hu,Q=Tc;if(ji=0,Fm=Hu=null,Tc=0,(Qn&6)!==0)throw Error(r(331));var xe=Qn;if(Qn|=4,F5(F.current),O5(F,F.current,Q,_),Qn=xe,qx(0,!1),se&&typeof se.onPostCommitFiberRoot=="function")try{se.onPostCommitFiberRoot(Ye,F)}catch{}return!0}finally{V.p=P,K.T=E,nU(h,g)}}function iU(h,g,_){g=ro(_,g),g=G2(h.stateNode,g,2),h=Lu(h,g,2),h!==null&&(on(h,2),Sl(h))}function sr(h,g,_){if(h.tag===3)iU(h,h,_);else for(;g!==null;){if(g.tag===3){iU(g,h,_);break}else if(g.tag===1){var E=g.stateNode;if(typeof g.type.getDerivedStateFromError=="function"||typeof E.componentDidCatch=="function"&&($u===null||!$u.has(E))){h=ro(_,h),_=a5(2),E=Lu(g,_,2),E!==null&&(s5(_,E,g,h),on(E,2),Sl(E));break}}g=g.return}}function gA(h,g,_){var E=h.pingCache;if(E===null){E=h.pingCache=new tse;var P=new Set;E.set(g,P)}else P=E.get(g),P===void 0&&(P=new Set,E.set(g,P));P.has(_)||(lA=!0,P.add(_),h=sse.bind(null,h,g,_),g.then(h,h))}function sse(h,g,_){var E=h.pingCache;E!==null&&E.delete(g),h.pingedLanes|=h.suspendedLanes&_,h.warmLanes&=~_,_r===h&&(Dn&_)===_&&(Qr===4||Qr===3&&(Dn&62914560)===Dn&&300>O()-Fv?(Qn&2)===0&&Um(h,0):cA|=_,Im===Dn&&(Im=0)),Sl(h)}function aU(h,g){g===0&&(g=Ot()),h=wh(h,g),h!==null&&(on(h,g),Sl(h))}function ose(h){var g=h.memoizedState,_=0;g!==null&&(_=g.retryLane),aU(h,_)}function lse(h,g){var _=0;switch(h.tag){case 31:case 13:var E=h.stateNode,P=h.memoizedState;P!==null&&(_=P.retryLane);break;case 19:E=h.stateNode;break;case 22:E=h.stateNode._retryCache;break;default:throw Error(r(314))}E!==null&&E.delete(g),aU(h,_)}function cse(h,g){return Ee(h,g)}var Gv=null,Bm=null,xA=!1,Wv=!1,bA=!1,Gu=0;function Sl(h){h!==Bm&&h.next===null&&(Bm===null?Gv=Bm=h:Bm=Bm.next=h),Wv=!0,xA||(xA=!0,dse())}function qx(h,g){if(!bA&&Wv){bA=!0;do for(var _=!1,E=Gv;E!==null;){if(h!==0){var P=E.pendingLanes;if(P===0)var F=0;else{var Q=E.suspendedLanes,xe=E.pingedLanes;F=(1<<31-Ce(42|h)+1)-1,F&=P&~(Q&~xe),F=F&201326741?F&201326741|1:F?F|2:0}F!==0&&(_=!0,cU(E,F))}else F=Dn,F=Ae(E,E===_r?F:0,E.cancelPendingCommit!==null||E.timeoutHandle!==-1),(F&3)===0||Ge(E,F)||(_=!0,cU(E,F));E=E.next}while(_);bA=!1}}function use(){sU()}function sU(){Wv=xA=!1;var h=0;Gu!==0&&_se()&&(h=Gu);for(var g=O(),_=null,E=Gv;E!==null;){var P=E.next,F=oU(E,g);F===0?(E.next=null,_===null?Gv=P:_.next=P,P===null&&(Bm=_)):(_=E,(h!==0||(F&3)!==0)&&(Wv=!0)),E=P}ji!==0&&ji!==5||qx(h),Gu!==0&&(Gu=0)}function oU(h,g){for(var _=h.suspendedLanes,E=h.pingedLanes,P=h.expirationTimes,F=h.pendingLanes&-62914561;0<F;){var Q=31-Ce(F),xe=1<<Q,Pe=P[Q];Pe===-1?((xe&_)===0||(xe&E)!==0)&&(P[Q]=it(xe,g)):Pe<=g&&(h.expiredLanes|=xe),F&=~xe}if(g=_r,_=Dn,_=Ae(h,h===g?_:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),E=h.callbackNode,_===0||h===g&&(ar===2||ar===9)||h.cancelPendingCommit!==null)return E!==null&&E!==null&&Ie(E),h.callbackNode=null,h.callbackPriority=0;if((_&3)===0||Ge(h,_)){if(g=_&-_,g===h.callbackPriority)return g;switch(E!==null&&Ie(E),Tt(_)){case 2:case 8:_=we;break;case 32:_=ae;break;case 268435456:_=De;break;default:_=ae}return E=lU.bind(null,h),_=Ee(_,E),h.callbackPriority=g,h.callbackNode=_,g}return E!==null&&E!==null&&Ie(E),h.callbackPriority=2,h.callbackNode=null,2}function lU(h,g){if(ji!==0&&ji!==5)return h.callbackNode=null,h.callbackPriority=0,null;var _=h.callbackNode;if(Vv()&&h.callbackNode!==_)return null;var E=Dn;return E=Ae(h,h===_r?E:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),E===0?null:(H5(h,E,g),oU(h,O()),h.callbackNode!=null&&h.callbackNode===_?lU.bind(null,h):null)}function cU(h,g){if(Vv())return null;H5(h,g,!0)}function dse(){Sse(function(){(Qn&6)!==0?Ee(pe,use):sU()})}function yA(){if(Gu===0){var h=Nm;h===0&&(h=Fe,Fe<<=1,(Fe&261888)===0&&(Fe=256)),Gu=h}return Gu}function uU(h){return h==null||typeof h=="symbol"||typeof h=="boolean"?null:typeof h=="function"?h:ev(""+h)}function dU(h,g){var _=g.ownerDocument.createElement("input");return _.name=g.name,_.value=g.value,h.id&&_.setAttribute("form",h.id),g.parentNode.insertBefore(_,g),h=new FormData(h),_.parentNode.removeChild(_),h}function hse(h,g,_,E,P){if(g==="submit"&&_&&_.stateNode===P){var F=uU((P[yr]||null).action),Q=E.submitter;Q&&(g=(g=Q[yr]||null)?uU(g.formAction):Q.getAttribute("formAction"),g!==null&&(F=g,Q=null));var xe=new iv("action","action",null,E,P);h.push({event:xe,listeners:[{instance:null,listener:function(){if(E.defaultPrevented){if(Gu!==0){var Pe=Q?dU(P,Q):new FormData(P);U2(_,{pending:!0,data:Pe,method:P.method,action:F},null,Pe)}}else typeof F=="function"&&(xe.preventDefault(),Pe=Q?dU(P,Q):new FormData(P),U2(_,{pending:!0,data:Pe,method:P.method,action:F},F,Pe))},currentTarget:P}]})}}for(var vA=0;vA<n2.length;vA++){var _A=n2[vA],fse=_A.toLowerCase(),mse=_A[0].toUpperCase()+_A.slice(1);Uo(fse,"on"+mse)}Uo($I,"onAnimationEnd"),Uo(HI,"onAnimationIteration"),Uo(VI,"onAnimationStart"),Uo("dblclick","onDoubleClick"),Uo("focusin","onFocus"),Uo("focusout","onBlur"),Uo(kae,"onTransitionRun"),Uo(jae,"onTransitionStart"),Uo(Pae,"onTransitionCancel"),Uo(GI,"onTransitionEnd"),He("onMouseEnter",["mouseout","mouseover"]),He("onMouseLeave",["mouseout","mouseover"]),He("onPointerEnter",["pointerout","pointerover"]),He("onPointerLeave",["pointerout","pointerover"]),We("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),We("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),We("onBeforeInput",["compositionend","keypress","textInput","paste"]),We("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),We("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),We("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Kx="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(" "),pse=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Kx));function hU(h,g){g=(g&4)!==0;for(var _=0;_<h.length;_++){var E=h[_],P=E.event;E=E.listeners;e:{var F=void 0;if(g)for(var Q=E.length-1;0<=Q;Q--){var xe=E[Q],Pe=xe.instance,at=xe.currentTarget;if(xe=xe.listener,Pe!==F&&P.isPropagationStopped())break e;F=xe,P.currentTarget=at;try{F(P)}catch(bt){ov(bt)}P.currentTarget=null,F=Pe}else for(Q=0;Q<E.length;Q++){if(xe=E[Q],Pe=xe.instance,at=xe.currentTarget,xe=xe.listener,Pe!==F&&P.isPropagationStopped())break e;F=xe,P.currentTarget=at;try{F(P)}catch(bt){ov(bt)}P.currentTarget=null,F=Pe}}}}function jn(h,g){var _=g[gi];_===void 0&&(_=g[gi]=new Set);var E=h+"__bubble";_.has(E)||(fU(g,h,2,!1),_.add(E))}function wA(h,g,_){var E=0;g&&(E|=4),fU(_,h,E,g)}var qv="_reactListening"+Math.random().toString(36).slice(2);function SA(h){if(!h[qv]){h[qv]=!0,je.forEach(function(_){_!=="selectionchange"&&(pse.has(_)||wA(_,!1,h),wA(_,!0,h))});var g=h.nodeType===9?h:h.ownerDocument;g===null||g[qv]||(g[qv]=!0,wA("selectionchange",!1,g))}}function fU(h,g,_,E){switch($U(g)){case 2:var P=Hse;break;case 8:P=Vse;break;default:P=FA}_=P.bind(null,g,_,h),P=void 0,!HN||g!=="touchstart"&&g!=="touchmove"&&g!=="wheel"||(P=!0),E?P!==void 0?h.addEventListener(g,_,{capture:!0,passive:P}):h.addEventListener(g,_,!0):P!==void 0?h.addEventListener(g,_,{passive:P}):h.addEventListener(g,_,!1)}function MA(h,g,_,E,P){var F=E;if((g&1)===0&&(g&2)===0&&E!==null)e:for(;;){if(E===null)return;var Q=E.tag;if(Q===3||Q===4){var xe=E.stateNode.containerInfo;if(xe===P)break;if(Q===4)for(Q=E.return;Q!==null;){var Pe=Q.tag;if((Pe===3||Pe===4)&&Q.stateNode.containerInfo===P)return;Q=Q.return}for(;xe!==null;){if(Q=Pt(xe),Q===null)return;if(Pe=Q.tag,Pe===5||Pe===6||Pe===26||Pe===27){E=F=Q;continue e}xe=xe.parentNode}}E=E.return}bI(function(){var at=F,bt=BN(_),_t=[];e:{var ot=WI.get(h);if(ot!==void 0){var ht=iv,qt=h;switch(h){case"keypress":if(nv(_)===0)break e;case"keydown":case"keyup":ht=lae;break;case"focusin":qt="focus",ht=qN;break;case"focusout":qt="blur",ht=qN;break;case"beforeblur":case"afterblur":ht=qN;break;case"click":if(_.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ht=_I;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ht=Yie;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ht=dae;break;case $I:case HI:case VI:ht=Jie;break;case GI:ht=fae;break;case"scroll":case"scrollend":ht=Kie;break;case"wheel":ht=pae;break;case"copy":case"cut":case"paste":ht=tae;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ht=SI;break;case"toggle":case"beforetoggle":ht=xae}var an=(g&4)!==0,hr=!an&&(h==="scroll"||h==="scrollend"),Xe=an?ot!==null?ot+"Capture":null:ot;an=[];for(var ze=at,rt;ze!==null;){var vt=ze;if(rt=vt.stateNode,vt=vt.tag,vt!==5&&vt!==26&&vt!==27||rt===null||Xe===null||(vt=gx(ze,Xe),vt!=null&&an.push(Xx(ze,vt,rt))),hr)break;ze=ze.return}0<an.length&&(ot=new ht(ot,qt,null,_,bt),_t.push({event:ot,listeners:an}))}}if((g&7)===0){e:{if(ot=h==="mouseover"||h==="pointerover",ht=h==="mouseout"||h==="pointerout",ot&&_!==zN&&(qt=_.relatedTarget||_.fromElement)&&(Pt(qt)||qt[Ci]))break e;if((ht||ot)&&(ot=bt.window===bt?bt:(ot=bt.ownerDocument)?ot.defaultView||ot.parentWindow:window,ht?(qt=_.relatedTarget||_.toElement,ht=at,qt=qt?Pt(qt):null,qt!==null&&(hr=a(qt),an=qt.tag,qt!==hr||an!==5&&an!==27&&an!==6)&&(qt=null)):(ht=null,qt=at),ht!==qt)){if(an=_I,vt="onMouseLeave",Xe="onMouseEnter",ze="mouse",(h==="pointerout"||h==="pointerover")&&(an=SI,vt="onPointerLeave",Xe="onPointerEnter",ze="pointer"),hr=ht==null?ot:Ht(ht),rt=qt==null?ot:Ht(qt),ot=new an(vt,ze+"leave",ht,_,bt),ot.target=hr,ot.relatedTarget=rt,vt=null,Pt(bt)===at&&(an=new an(Xe,ze+"enter",qt,_,bt),an.target=rt,an.relatedTarget=hr,vt=an),hr=vt,ht&&qt)t:{for(an=gse,Xe=ht,ze=qt,rt=0,vt=Xe;vt;vt=an(vt))rt++;vt=0;for(var tn=ze;tn;tn=an(tn))vt++;for(;0<rt-vt;)Xe=an(Xe),rt--;for(;0<vt-rt;)ze=an(ze),vt--;for(;rt--;){if(Xe===ze||ze!==null&&Xe===ze.alternate){an=Xe;break t}Xe=an(Xe),ze=an(ze)}an=null}else an=null;ht!==null&&mU(_t,ot,ht,an,!1),qt!==null&&hr!==null&&mU(_t,hr,qt,an,!0)}}e:{if(ot=at?Ht(at):window,ht=ot.nodeName&&ot.nodeName.toLowerCase(),ht==="select"||ht==="input"&&ot.type==="file")var Gn=jI;else if(CI(ot))if(PI)Gn=Aae;else{Gn=Eae;var Qt=Mae}else ht=ot.nodeName,!ht||ht.toLowerCase()!=="input"||ot.type!=="checkbox"&&ot.type!=="radio"?at&&jr(at.elementType)&&(Gn=jI):Gn=Nae;if(Gn&&(Gn=Gn(h,at))){kI(_t,Gn,_,bt);break e}Qt&&Qt(h,ot,at),h==="focusout"&&at&&ot.type==="number"&&at.memoizedProps.value!=null&&cn(ot,"number",ot.value)}switch(Qt=at?Ht(at):window,h){case"focusin":(CI(Qt)||Qt.contentEditable==="true")&&(bm=Qt,JN=at,Mx=null);break;case"focusout":Mx=JN=bm=null;break;case"mousedown":e2=!0;break;case"contextmenu":case"mouseup":case"dragend":e2=!1,zI(_t,_,bt);break;case"selectionchange":if(Cae)break;case"keydown":case"keyup":zI(_t,_,bt)}var vn;if(XN)e:{switch(h){case"compositionstart":var On="onCompositionStart";break e;case"compositionend":On="onCompositionEnd";break e;case"compositionupdate":On="onCompositionUpdate";break e}On=void 0}else xm?AI(h,_)&&(On="onCompositionEnd"):h==="keydown"&&_.keyCode===229&&(On="onCompositionStart");On&&(MI&&_.locale!=="ko"&&(xm||On!=="onCompositionStart"?On==="onCompositionEnd"&&xm&&(vn=yI()):(Cu=bt,VN="value"in Cu?Cu.value:Cu.textContent,xm=!0)),Qt=Kv(at,On),0<Qt.length&&(On=new wI(On,h,null,_,bt),_t.push({event:On,listeners:Qt}),vn?On.data=vn:(vn=TI(_),vn!==null&&(On.data=vn)))),(vn=yae?vae(h,_):_ae(h,_))&&(On=Kv(at,"onBeforeInput"),0<On.length&&(Qt=new wI("onBeforeInput","beforeinput",null,_,bt),_t.push({event:Qt,listeners:On}),Qt.data=vn)),hse(_t,h,at,_,bt)}hU(_t,g)})}function Xx(h,g,_){return{instance:h,listener:g,currentTarget:_}}function Kv(h,g){for(var _=g+"Capture",E=[];h!==null;){var P=h,F=P.stateNode;if(P=P.tag,P!==5&&P!==26&&P!==27||F===null||(P=gx(h,_),P!=null&&E.unshift(Xx(h,P,F)),P=gx(h,g),P!=null&&E.push(Xx(h,P,F))),h.tag===3)return E;h=h.return}return[]}function gse(h){if(h===null)return null;do h=h.return;while(h&&h.tag!==5&&h.tag!==27);return h||null}function mU(h,g,_,E,P){for(var F=g._reactName,Q=[];_!==null&&_!==E;){var xe=_,Pe=xe.alternate,at=xe.stateNode;if(xe=xe.tag,Pe!==null&&Pe===E)break;xe!==5&&xe!==26&&xe!==27||at===null||(Pe=at,P?(at=gx(_,F),at!=null&&Q.unshift(Xx(_,at,Pe))):P||(at=gx(_,F),at!=null&&Q.push(Xx(_,at,Pe)))),_=_.return}Q.length!==0&&h.push({event:g,listeners:Q})}var xse=/\r\n?/g,bse=/\u0000|\uFFFD/g;function pU(h){return(typeof h=="string"?h:""+h).replace(xse,`
  9. `).replace(bse,"")}function gU(h,g){return g=pU(g),pU(h)===g}function dr(h,g,_,E,P,F){switch(_){case"children":typeof E=="string"?g==="body"||g==="textarea"&&E===""||vr(h,E):(typeof E=="number"||typeof E=="bigint")&&g!=="body"&&vr(h,""+E);break;case"className":Oe(h,"class",E);break;case"tabIndex":Oe(h,"tabindex",E);break;case"dir":case"role":case"viewBox":case"width":case"height":Oe(h,_,E);break;case"style":to(h,E,F);break;case"data":if(g!=="object"){Oe(h,"data",E);break}case"src":case"href":if(E===""&&(g!=="a"||_!=="href")){h.removeAttribute(_);break}if(E==null||typeof E=="function"||typeof E=="symbol"||typeof E=="boolean"){h.removeAttribute(_);break}E=ev(""+E),h.setAttribute(_,E);break;case"action":case"formAction":if(typeof E=="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 F=="function"&&(_==="formAction"?(g!=="input"&&dr(h,g,"name",P.name,P,null),dr(h,g,"formEncType",P.formEncType,P,null),dr(h,g,"formMethod",P.formMethod,P,null),dr(h,g,"formTarget",P.formTarget,P,null)):(dr(h,g,"encType",P.encType,P,null),dr(h,g,"method",P.method,P,null),dr(h,g,"target",P.target,P,null)));if(E==null||typeof E=="symbol"||typeof E=="boolean"){h.removeAttribute(_);break}E=ev(""+E),h.setAttribute(_,E);break;case"onClick":E!=null&&(h.onclick=fc);break;case"onScroll":E!=null&&jn("scroll",h);break;case"onScrollEnd":E!=null&&jn("scrollend",h);break;case"dangerouslySetInnerHTML":if(E!=null){if(typeof E!="object"||!("__html"in E))throw Error(r(61));if(_=E.__html,_!=null){if(P.children!=null)throw Error(r(60));h.innerHTML=_}}break;case"multiple":h.multiple=E&&typeof E!="function"&&typeof E!="symbol";break;case"muted":h.muted=E&&typeof E!="function"&&typeof E!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(E==null||typeof E=="function"||typeof E=="boolean"||typeof E=="symbol"){h.removeAttribute("xlink:href");break}_=ev(""+E),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":E!=null&&typeof E!="function"&&typeof E!="symbol"?h.setAttribute(_,""+E):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":E&&typeof E!="function"&&typeof E!="symbol"?h.setAttribute(_,""):h.removeAttribute(_);break;case"capture":case"download":E===!0?h.setAttribute(_,""):E!==!1&&E!=null&&typeof E!="function"&&typeof E!="symbol"?h.setAttribute(_,E):h.removeAttribute(_);break;case"cols":case"rows":case"size":case"span":E!=null&&typeof E!="function"&&typeof E!="symbol"&&!isNaN(E)&&1<=E?h.setAttribute(_,E):h.removeAttribute(_);break;case"rowSpan":case"start":E==null||typeof E=="function"||typeof E=="symbol"||isNaN(E)?h.removeAttribute(_):h.setAttribute(_,E);break;case"popover":jn("beforetoggle",h),jn("toggle",h),Mt(h,"popover",E);break;case"xlinkActuate":gt(h,"http://www.w3.org/1999/xlink","xlink:actuate",E);break;case"xlinkArcrole":gt(h,"http://www.w3.org/1999/xlink","xlink:arcrole",E);break;case"xlinkRole":gt(h,"http://www.w3.org/1999/xlink","xlink:role",E);break;case"xlinkShow":gt(h,"http://www.w3.org/1999/xlink","xlink:show",E);break;case"xlinkTitle":gt(h,"http://www.w3.org/1999/xlink","xlink:title",E);break;case"xlinkType":gt(h,"http://www.w3.org/1999/xlink","xlink:type",E);break;case"xmlBase":gt(h,"http://www.w3.org/XML/1998/namespace","xml:base",E);break;case"xmlLang":gt(h,"http://www.w3.org/XML/1998/namespace","xml:lang",E);break;case"xmlSpace":gt(h,"http://www.w3.org/XML/1998/namespace","xml:space",E);break;case"is":Mt(h,"is",E);break;case"innerText":case"textContent":break;default:(!(2<_.length)||_[0]!=="o"&&_[0]!=="O"||_[1]!=="n"&&_[1]!=="N")&&(_=Wie.get(_)||_,Mt(h,_,E))}}function EA(h,g,_,E,P,F){switch(_){case"style":to(h,E,F);break;case"dangerouslySetInnerHTML":if(E!=null){if(typeof E!="object"||!("__html"in E))throw Error(r(61));if(_=E.__html,_!=null){if(P.children!=null)throw Error(r(60));h.innerHTML=_}}break;case"children":typeof E=="string"?vr(h,E):(typeof E=="number"||typeof E=="bigint")&&vr(h,""+E);break;case"onScroll":E!=null&&jn("scroll",h);break;case"onScrollEnd":E!=null&&jn("scrollend",h);break;case"onClick":E!=null&&(h.onclick=fc);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Ve.hasOwnProperty(_))e:{if(_[0]==="o"&&_[1]==="n"&&(P=_.endsWith("Capture"),g=_.slice(2,P?_.length-7:void 0),F=h[yr]||null,F=F!=null?F[_]:null,typeof F=="function"&&h.removeEventListener(g,F,P),typeof E=="function")){typeof F!="function"&&F!==null&&(_ in h?h[_]=null:h.hasAttribute(_)&&h.removeAttribute(_)),h.addEventListener(g,E,P);break e}_ in h?h[_]=E:E===!0?h.setAttribute(_,""):Mt(h,_,E)}}}function da(h,g,_){switch(g){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":jn("error",h),jn("load",h);var E=!1,P=!1,F;for(F in _)if(_.hasOwnProperty(F)){var Q=_[F];if(Q!=null)switch(F){case"src":E=!0;break;case"srcSet":P=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,g));default:dr(h,g,F,Q,_,null)}}P&&dr(h,g,"srcSet",_.srcSet,_,null),E&&dr(h,g,"src",_.src,_,null);return;case"input":jn("invalid",h);var xe=F=Q=P=null,Pe=null,at=null;for(E in _)if(_.hasOwnProperty(E)){var bt=_[E];if(bt!=null)switch(E){case"name":P=bt;break;case"type":Q=bt;break;case"checked":Pe=bt;break;case"defaultChecked":at=bt;break;case"value":F=bt;break;case"defaultValue":xe=bt;break;case"children":case"dangerouslySetInnerHTML":if(bt!=null)throw Error(r(137,g));break;default:dr(h,g,E,bt,_,null)}}tr(h,F,xe,Pe,at,Q,P,!1);return;case"select":jn("invalid",h),E=Q=F=null;for(P in _)if(_.hasOwnProperty(P)&&(xe=_[P],xe!=null))switch(P){case"value":F=xe;break;case"defaultValue":Q=xe;break;case"multiple":E=xe;default:dr(h,g,P,xe,_,null)}g=F,_=Q,h.multiple=!!E,g!=null?ki(h,!!E,g,!1):_!=null&&ki(h,!!E,_,!0);return;case"textarea":jn("invalid",h),F=P=E=null;for(Q in _)if(_.hasOwnProperty(Q)&&(xe=_[Q],xe!=null))switch(Q){case"value":E=xe;break;case"defaultValue":P=xe;break;case"children":F=xe;break;case"dangerouslySetInnerHTML":if(xe!=null)throw Error(r(91));break;default:dr(h,g,Q,xe,_,null)}ui(h,E,P,F);return;case"option":for(Pe in _)_.hasOwnProperty(Pe)&&(E=_[Pe],E!=null)&&(Pe==="selected"?h.selected=E&&typeof E!="function"&&typeof E!="symbol":dr(h,g,Pe,E,_,null));return;case"dialog":jn("beforetoggle",h),jn("toggle",h),jn("cancel",h),jn("close",h);break;case"iframe":case"object":jn("load",h);break;case"video":case"audio":for(E=0;E<Kx.length;E++)jn(Kx[E],h);break;case"image":jn("error",h),jn("load",h);break;case"details":jn("toggle",h);break;case"embed":case"source":case"link":jn("error",h),jn("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(at in _)if(_.hasOwnProperty(at)&&(E=_[at],E!=null))switch(at){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,g));default:dr(h,g,at,E,_,null)}return;default:if(jr(g)){for(bt in _)_.hasOwnProperty(bt)&&(E=_[bt],E!==void 0&&EA(h,g,bt,E,_,void 0));return}}for(xe in _)_.hasOwnProperty(xe)&&(E=_[xe],E!=null&&dr(h,g,xe,E,_,null))}function yse(h,g,_,E){switch(g){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var P=null,F=null,Q=null,xe=null,Pe=null,at=null,bt=null;for(ht in _){var _t=_[ht];if(_.hasOwnProperty(ht)&&_t!=null)switch(ht){case"checked":break;case"value":break;case"defaultValue":Pe=_t;default:E.hasOwnProperty(ht)||dr(h,g,ht,null,E,_t)}}for(var ot in E){var ht=E[ot];if(_t=_[ot],E.hasOwnProperty(ot)&&(ht!=null||_t!=null))switch(ot){case"type":F=ht;break;case"name":P=ht;break;case"checked":at=ht;break;case"defaultChecked":bt=ht;break;case"value":Q=ht;break;case"defaultValue":xe=ht;break;case"children":case"dangerouslySetInnerHTML":if(ht!=null)throw Error(r(137,g));break;default:ht!==_t&&dr(h,g,ot,ht,E,_t)}}Xt(h,Q,xe,Pe,at,bt,F,P);return;case"select":ht=Q=xe=ot=null;for(F in _)if(Pe=_[F],_.hasOwnProperty(F)&&Pe!=null)switch(F){case"value":break;case"multiple":ht=Pe;default:E.hasOwnProperty(F)||dr(h,g,F,null,E,Pe)}for(P in E)if(F=E[P],Pe=_[P],E.hasOwnProperty(P)&&(F!=null||Pe!=null))switch(P){case"value":ot=F;break;case"defaultValue":xe=F;break;case"multiple":Q=F;default:F!==Pe&&dr(h,g,P,F,E,Pe)}g=xe,_=Q,E=ht,ot!=null?ki(h,!!_,ot,!1):!!E!=!!_&&(g!=null?ki(h,!!_,g,!0):ki(h,!!_,_?[]:"",!1));return;case"textarea":ht=ot=null;for(xe in _)if(P=_[xe],_.hasOwnProperty(xe)&&P!=null&&!E.hasOwnProperty(xe))switch(xe){case"value":break;case"children":break;default:dr(h,g,xe,null,E,P)}for(Q in E)if(P=E[Q],F=_[Q],E.hasOwnProperty(Q)&&(P!=null||F!=null))switch(Q){case"value":ot=P;break;case"defaultValue":ht=P;break;case"children":break;case"dangerouslySetInnerHTML":if(P!=null)throw Error(r(91));break;default:P!==F&&dr(h,g,Q,P,E,F)}$n(h,ot,ht);return;case"option":for(var qt in _)ot=_[qt],_.hasOwnProperty(qt)&&ot!=null&&!E.hasOwnProperty(qt)&&(qt==="selected"?h.selected=!1:dr(h,g,qt,null,E,ot));for(Pe in E)ot=E[Pe],ht=_[Pe],E.hasOwnProperty(Pe)&&ot!==ht&&(ot!=null||ht!=null)&&(Pe==="selected"?h.selected=ot&&typeof ot!="function"&&typeof ot!="symbol":dr(h,g,Pe,ot,E,ht));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 an in _)ot=_[an],_.hasOwnProperty(an)&&ot!=null&&!E.hasOwnProperty(an)&&dr(h,g,an,null,E,ot);for(at in E)if(ot=E[at],ht=_[at],E.hasOwnProperty(at)&&ot!==ht&&(ot!=null||ht!=null))switch(at){case"children":case"dangerouslySetInnerHTML":if(ot!=null)throw Error(r(137,g));break;default:dr(h,g,at,ot,E,ht)}return;default:if(jr(g)){for(var hr in _)ot=_[hr],_.hasOwnProperty(hr)&&ot!==void 0&&!E.hasOwnProperty(hr)&&EA(h,g,hr,void 0,E,ot);for(bt in E)ot=E[bt],ht=_[bt],!E.hasOwnProperty(bt)||ot===ht||ot===void 0&&ht===void 0||EA(h,g,bt,ot,E,ht);return}}for(var Xe in _)ot=_[Xe],_.hasOwnProperty(Xe)&&ot!=null&&!E.hasOwnProperty(Xe)&&dr(h,g,Xe,null,E,ot);for(_t in E)ot=E[_t],ht=_[_t],!E.hasOwnProperty(_t)||ot===ht||ot==null&&ht==null||dr(h,g,_t,ot,E,ht)}function xU(h){switch(h){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function vse(){if(typeof performance.getEntriesByType=="function"){for(var h=0,g=0,_=performance.getEntriesByType("resource"),E=0;E<_.length;E++){var P=_[E],F=P.transferSize,Q=P.initiatorType,xe=P.duration;if(F&&xe&&xU(Q)){for(Q=0,xe=P.responseEnd,E+=1;E<_.length;E++){var Pe=_[E],at=Pe.startTime;if(at>xe)break;var bt=Pe.transferSize,_t=Pe.initiatorType;bt&&xU(_t)&&(Pe=Pe.responseEnd,Q+=bt*(Pe<xe?1:(xe-at)/(Pe-at)))}if(--E,g+=8*(F+Q)/(P.duration/1e3),h++,10<h)break}}if(0<h)return g/h/1e6}return navigator.connection&&(h=navigator.connection.downlink,typeof h=="number")?h:5}var NA=null,AA=null;function Xv(h){return h.nodeType===9?h:h.ownerDocument}function bU(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 yU(h,g){if(h===0)switch(g){case"svg":return 1;case"math":return 2;default:return 0}return h===1&&g==="foreignObject"?0:h}function TA(h,g){return h==="textarea"||h==="noscript"||typeof g.children=="string"||typeof g.children=="number"||typeof g.children=="bigint"||typeof g.dangerouslySetInnerHTML=="object"&&g.dangerouslySetInnerHTML!==null&&g.dangerouslySetInnerHTML.__html!=null}var CA=null;function _se(){var h=window.event;return h&&h.type==="popstate"?h===CA?!1:(CA=h,!0):(CA=null,!1)}var vU=typeof setTimeout=="function"?setTimeout:void 0,wse=typeof clearTimeout=="function"?clearTimeout:void 0,_U=typeof Promise=="function"?Promise:void 0,Sse=typeof queueMicrotask=="function"?queueMicrotask:typeof _U<"u"?function(h){return _U.resolve(null).then(h).catch(Mse)}:vU;function Mse(h){setTimeout(function(){throw h})}function Wu(h){return h==="head"}function wU(h,g){var _=g,E=0;do{var P=_.nextSibling;if(h.removeChild(_),P&&P.nodeType===8)if(_=P.data,_==="/$"||_==="/&"){if(E===0){h.removeChild(P),Gm(g);return}E--}else if(_==="$"||_==="$?"||_==="$~"||_==="$!"||_==="&")E++;else if(_==="html")Yx(h.ownerDocument.documentElement);else if(_==="head"){_=h.ownerDocument.head,Yx(_);for(var F=_.firstChild;F;){var Q=F.nextSibling,xe=F.nodeName;F[lt]||xe==="SCRIPT"||xe==="STYLE"||xe==="LINK"&&F.rel.toLowerCase()==="stylesheet"||_.removeChild(F),F=Q}}else _==="body"&&Yx(h.ownerDocument.body);_=P}while(_);Gm(g)}function SU(h,g){var _=h;h=0;do{var E=_.nextSibling;if(_.nodeType===1?g?(_._stashedDisplay=_.style.display,_.style.display="none"):(_.style.display=_._stashedDisplay||"",_.getAttribute("style")===""&&_.removeAttribute("style")):_.nodeType===3&&(g?(_._stashedText=_.nodeValue,_.nodeValue=""):_.nodeValue=_._stashedText||""),E&&E.nodeType===8)if(_=E.data,_==="/$"){if(h===0)break;h--}else _!=="$"&&_!=="$?"&&_!=="$~"&&_!=="$!"||h++;_=E}while(_)}function kA(h){var g=h.firstChild;for(g&&g.nodeType===10&&(g=g.nextSibling);g;){var _=g;switch(g=g.nextSibling,_.nodeName){case"HTML":case"HEAD":case"BODY":kA(_),st(_);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(_.rel.toLowerCase()==="stylesheet")continue}h.removeChild(_)}}function Ese(h,g,_,E){for(;h.nodeType===1;){var P=_;if(h.nodeName.toLowerCase()!==g.toLowerCase()){if(!E&&(h.nodeName!=="INPUT"||h.type!=="hidden"))break}else if(E){if(!h[lt])switch(g){case"meta":if(!h.hasAttribute("itemprop"))break;return h;case"link":if(F=h.getAttribute("rel"),F==="stylesheet"&&h.hasAttribute("data-precedence"))break;if(F!==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(F=h.getAttribute("src"),(F!==(P.src==null?null:P.src)||h.getAttribute("type")!==(P.type==null?null:P.type)||h.getAttribute("crossorigin")!==(P.crossOrigin==null?null:P.crossOrigin))&&F&&h.hasAttribute("async")&&!h.hasAttribute("itemprop"))break;return h;default:return h}}else if(g==="input"&&h.type==="hidden"){var F=P.name==null?null:""+P.name;if(P.type==="hidden"&&h.getAttribute("name")===F)return h}else return h;if(h=lo(h.nextSibling),h===null)break}return null}function Nse(h,g,_){if(g==="")return null;for(;h.nodeType!==3;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!_||(h=lo(h.nextSibling),h===null))return null;return h}function MU(h,g){for(;h.nodeType!==8;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!g||(h=lo(h.nextSibling),h===null))return null;return h}function jA(h){return h.data==="$?"||h.data==="$~"}function PA(h){return h.data==="$!"||h.data==="$?"&&h.ownerDocument.readyState!=="loading"}function Ase(h,g){var _=h.ownerDocument;if(h.data==="$~")h._reactRetry=g;else if(h.data!=="$?"||_.readyState!=="loading")g();else{var E=function(){g(),_.removeEventListener("DOMContentLoaded",E)};_.addEventListener("DOMContentLoaded",E),h._reactRetry=E}}function lo(h){for(;h!=null;h=h.nextSibling){var g=h.nodeType;if(g===1||g===3)break;if(g===8){if(g=h.data,g==="$"||g==="$!"||g==="$?"||g==="$~"||g==="&"||g==="F!"||g==="F")break;if(g==="/$"||g==="/&")return null}}return h}var RA=null;function EU(h){h=h.nextSibling;for(var g=0;h;){if(h.nodeType===8){var _=h.data;if(_==="/$"||_==="/&"){if(g===0)return lo(h.nextSibling);g--}else _!=="$"&&_!=="$!"&&_!=="$?"&&_!=="$~"&&_!=="&"||g++}h=h.nextSibling}return null}function NU(h){h=h.previousSibling;for(var g=0;h;){if(h.nodeType===8){var _=h.data;if(_==="$"||_==="$!"||_==="$?"||_==="$~"||_==="&"){if(g===0)return h;g--}else _!=="/$"&&_!=="/&"||g++}h=h.previousSibling}return null}function AU(h,g,_){switch(g=Xv(_),h){case"html":if(h=g.documentElement,!h)throw Error(r(452));return h;case"head":if(h=g.head,!h)throw Error(r(453));return h;case"body":if(h=g.body,!h)throw Error(r(454));return h;default:throw Error(r(451))}}function Yx(h){for(var g=h.attributes;g.length;)h.removeAttributeNode(g[0]);st(h)}var co=new Map,TU=new Set;function Yv(h){return typeof h.getRootNode=="function"?h.getRootNode():h.nodeType===9?h:h.ownerDocument}var Cc=V.d;V.d={f:Tse,r:Cse,D:kse,C:jse,L:Pse,m:Rse,X:Ose,S:Dse,M:Lse};function Tse(){var h=Cc.f(),g=Bv();return h||g}function Cse(h){var g=Bt(h);g!==null&&g.tag===5&&g.type==="form"?GF(g):Cc.r(h)}var $m=typeof document>"u"?null:document;function CU(h,g,_){var E=$m;if(E&&typeof g=="string"&&g){var P=yt(g);P='link[rel="'+h+'"][href="'+P+'"]',typeof _=="string"&&(P+='[crossorigin="'+_+'"]'),TU.has(P)||(TU.add(P),h={rel:h,crossOrigin:_,href:g},E.querySelector(P)===null&&(g=E.createElement("link"),da(g,"link",h),ue(g),E.head.appendChild(g)))}}function kse(h){Cc.D(h),CU("dns-prefetch",h,null)}function jse(h,g){Cc.C(h,g),CU("preconnect",h,g)}function Pse(h,g,_){Cc.L(h,g,_);var E=$m;if(E&&h&&g){var P='link[rel="preload"][as="'+yt(g)+'"]';g==="image"&&_&&_.imageSrcSet?(P+='[imagesrcset="'+yt(_.imageSrcSet)+'"]',typeof _.imageSizes=="string"&&(P+='[imagesizes="'+yt(_.imageSizes)+'"]')):P+='[href="'+yt(h)+'"]';var F=P;switch(g){case"style":F=Hm(h);break;case"script":F=Vm(h)}co.has(F)||(h=f({rel:"preload",href:g==="image"&&_&&_.imageSrcSet?void 0:h,as:g},_),co.set(F,h),E.querySelector(P)!==null||g==="style"&&E.querySelector(Zx(F))||g==="script"&&E.querySelector(Qx(F))||(g=E.createElement("link"),da(g,"link",h),ue(g),E.head.appendChild(g)))}}function Rse(h,g){Cc.m(h,g);var _=$m;if(_&&h){var E=g&&typeof g.as=="string"?g.as:"script",P='link[rel="modulepreload"][as="'+yt(E)+'"][href="'+yt(h)+'"]',F=P;switch(E){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":F=Vm(h)}if(!co.has(F)&&(h=f({rel:"modulepreload",href:h},g),co.set(F,h),_.querySelector(P)===null)){switch(E){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(_.querySelector(Qx(F)))return}E=_.createElement("link"),da(E,"link",h),ue(E),_.head.appendChild(E)}}}function Dse(h,g,_){Cc.S(h,g,_);var E=$m;if(E&&h){var P=Jt(E).hoistableStyles,F=Hm(h);g=g||"default";var Q=P.get(F);if(!Q){var xe={loading:0,preload:null};if(Q=E.querySelector(Zx(F)))xe.loading=5;else{h=f({rel:"stylesheet",href:h,"data-precedence":g},_),(_=co.get(F))&&DA(h,_);var Pe=Q=E.createElement("link");ue(Pe),da(Pe,"link",h),Pe._p=new Promise(function(at,bt){Pe.onload=at,Pe.onerror=bt}),Pe.addEventListener("load",function(){xe.loading|=1}),Pe.addEventListener("error",function(){xe.loading|=2}),xe.loading|=4,Zv(Q,g,E)}Q={type:"stylesheet",instance:Q,count:1,state:xe},P.set(F,Q)}}}function Ose(h,g){Cc.X(h,g);var _=$m;if(_&&h){var E=Jt(_).hoistableScripts,P=Vm(h),F=E.get(P);F||(F=_.querySelector(Qx(P)),F||(h=f({src:h,async:!0},g),(g=co.get(P))&&OA(h,g),F=_.createElement("script"),ue(F),da(F,"link",h),_.head.appendChild(F)),F={type:"script",instance:F,count:1,state:null},E.set(P,F))}}function Lse(h,g){Cc.M(h,g);var _=$m;if(_&&h){var E=Jt(_).hoistableScripts,P=Vm(h),F=E.get(P);F||(F=_.querySelector(Qx(P)),F||(h=f({src:h,async:!0,type:"module"},g),(g=co.get(P))&&OA(h,g),F=_.createElement("script"),ue(F),da(F,"link",h),_.head.appendChild(F)),F={type:"script",instance:F,count:1,state:null},E.set(P,F))}}function kU(h,g,_,E){var P=(P=fe.current)?Yv(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"?(g=Hm(_.href),_=Jt(P).hoistableStyles,E=_.get(g),E||(E={type:"style",instance:null,count:0,state:null},_.set(g,E)),E):{type:"void",instance:null,count:0,state:null};case"link":if(_.rel==="stylesheet"&&typeof _.href=="string"&&typeof _.precedence=="string"){h=Hm(_.href);var F=Jt(P).hoistableStyles,Q=F.get(h);if(Q||(P=P.ownerDocument||P,Q={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},F.set(h,Q),(F=P.querySelector(Zx(h)))&&!F._p&&(Q.instance=F,Q.state.loading=5),co.has(h)||(_={rel:"preload",as:"style",href:_.href,crossOrigin:_.crossOrigin,integrity:_.integrity,media:_.media,hrefLang:_.hrefLang,referrerPolicy:_.referrerPolicy},co.set(h,_),F||Ise(P,h,_,Q.state))),g&&E===null)throw Error(r(528,""));return Q}if(g&&E!==null)throw Error(r(529,""));return null;case"script":return g=_.async,_=_.src,typeof _=="string"&&g&&typeof g!="function"&&typeof g!="symbol"?(g=Vm(_),_=Jt(P).hoistableScripts,E=_.get(g),E||(E={type:"script",instance:null,count:0,state:null},_.set(g,E)),E):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,h))}}function Hm(h){return'href="'+yt(h)+'"'}function Zx(h){return'link[rel="stylesheet"]['+h+"]"}function jU(h){return f({},h,{"data-precedence":h.precedence,precedence:null})}function Ise(h,g,_,E){h.querySelector('link[rel="preload"][as="style"]['+g+"]")?E.loading=1:(g=h.createElement("link"),E.preload=g,g.addEventListener("load",function(){return E.loading|=1}),g.addEventListener("error",function(){return E.loading|=2}),da(g,"link",_),ue(g),h.head.appendChild(g))}function Vm(h){return'[src="'+yt(h)+'"]'}function Qx(h){return"script[async]"+h}function PU(h,g,_){if(g.count++,g.instance===null)switch(g.type){case"style":var E=h.querySelector('style[data-href~="'+yt(_.href)+'"]');if(E)return g.instance=E,ue(E),E;var P=f({},_,{"data-href":_.href,"data-precedence":_.precedence,href:null,precedence:null});return E=(h.ownerDocument||h).createElement("style"),ue(E),da(E,"style",P),Zv(E,_.precedence,h),g.instance=E;case"stylesheet":P=Hm(_.href);var F=h.querySelector(Zx(P));if(F)return g.state.loading|=4,g.instance=F,ue(F),F;E=jU(_),(P=co.get(P))&&DA(E,P),F=(h.ownerDocument||h).createElement("link"),ue(F);var Q=F;return Q._p=new Promise(function(xe,Pe){Q.onload=xe,Q.onerror=Pe}),da(F,"link",E),g.state.loading|=4,Zv(F,_.precedence,h),g.instance=F;case"script":return F=Vm(_.src),(P=h.querySelector(Qx(F)))?(g.instance=P,ue(P),P):(E=_,(P=co.get(F))&&(E=f({},_),OA(E,P)),h=h.ownerDocument||h,P=h.createElement("script"),ue(P),da(P,"link",E),h.head.appendChild(P),g.instance=P);case"void":return null;default:throw Error(r(443,g.type))}else g.type==="stylesheet"&&(g.state.loading&4)===0&&(E=g.instance,g.state.loading|=4,Zv(E,_.precedence,h));return g.instance}function Zv(h,g,_){for(var E=_.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),P=E.length?E[E.length-1]:null,F=P,Q=0;Q<E.length;Q++){var xe=E[Q];if(xe.dataset.precedence===g)F=xe;else if(F!==P)break}F?F.parentNode.insertBefore(h,F.nextSibling):(g=_.nodeType===9?_.head:_,g.insertBefore(h,g.firstChild))}function DA(h,g){h.crossOrigin==null&&(h.crossOrigin=g.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=g.referrerPolicy),h.title==null&&(h.title=g.title)}function OA(h,g){h.crossOrigin==null&&(h.crossOrigin=g.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=g.referrerPolicy),h.integrity==null&&(h.integrity=g.integrity)}var Qv=null;function RU(h,g,_){if(Qv===null){var E=new Map,P=Qv=new Map;P.set(_,E)}else P=Qv,E=P.get(_),E||(E=new Map,P.set(_,E));if(E.has(h))return E;for(E.set(h,null),_=_.getElementsByTagName(h),P=0;P<_.length;P++){var F=_[P];if(!(F[lt]||F[Un]||h==="link"&&F.getAttribute("rel")==="stylesheet")&&F.namespaceURI!=="http://www.w3.org/2000/svg"){var Q=F.getAttribute(g)||"";Q=h+Q;var xe=E.get(Q);xe?xe.push(F):E.set(Q,[F])}}return E}function DU(h,g,_){h=h.ownerDocument||h,h.head.insertBefore(_,g==="title"?h.querySelector("head > title"):null)}function Fse(h,g,_){if(_===1||g.itemProp!=null)return!1;switch(h){case"meta":case"title":return!0;case"style":if(typeof g.precedence!="string"||typeof g.href!="string"||g.href==="")break;return!0;case"link":if(typeof g.rel!="string"||typeof g.href!="string"||g.href===""||g.onLoad||g.onError)break;return g.rel==="stylesheet"?(h=g.disabled,typeof g.precedence=="string"&&h==null):!0;case"script":if(g.async&&typeof g.async!="function"&&typeof g.async!="symbol"&&!g.onLoad&&!g.onError&&g.src&&typeof g.src=="string")return!0}return!1}function OU(h){return!(h.type==="stylesheet"&&(h.state.loading&3)===0)}function Use(h,g,_,E){if(_.type==="stylesheet"&&(typeof E.media!="string"||matchMedia(E.media).matches!==!1)&&(_.state.loading&4)===0){if(_.instance===null){var P=Hm(E.href),F=g.querySelector(Zx(P));if(F){g=F._p,g!==null&&typeof g=="object"&&typeof g.then=="function"&&(h.count++,h=Jv.bind(h),g.then(h,h)),_.state.loading|=4,_.instance=F,ue(F);return}F=g.ownerDocument||g,E=jU(E),(P=co.get(P))&&DA(E,P),F=F.createElement("link"),ue(F);var Q=F;Q._p=new Promise(function(xe,Pe){Q.onload=xe,Q.onerror=Pe}),da(F,"link",E),_.instance=F}h.stylesheets===null&&(h.stylesheets=new Map),h.stylesheets.set(_,g),(g=_.state.preload)&&(_.state.loading&3)===0&&(h.count++,_=Jv.bind(h),g.addEventListener("load",_),g.addEventListener("error",_))}}var LA=0;function zse(h,g){return h.stylesheets&&h.count===0&&t_(h,h.stylesheets),0<h.count||0<h.imgCount?function(_){var E=setTimeout(function(){if(h.stylesheets&&t_(h,h.stylesheets),h.unsuspend){var F=h.unsuspend;h.unsuspend=null,F()}},6e4+g);0<h.imgBytes&&LA===0&&(LA=62500*vse());var P=setTimeout(function(){if(h.waitingForImages=!1,h.count===0&&(h.stylesheets&&t_(h,h.stylesheets),h.unsuspend)){var F=h.unsuspend;h.unsuspend=null,F()}},(h.imgBytes>LA?50:800)+g);return h.unsuspend=_,function(){h.unsuspend=null,clearTimeout(E),clearTimeout(P)}}:null}function Jv(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)t_(this,this.stylesheets);else if(this.unsuspend){var h=this.unsuspend;this.unsuspend=null,h()}}}var e_=null;function t_(h,g){h.stylesheets=null,h.unsuspend!==null&&(h.count++,e_=new Map,g.forEach(Bse,h),e_=null,Jv.call(h))}function Bse(h,g){if(!(g.state.loading&4)){var _=e_.get(h);if(_)var E=_.get(null);else{_=new Map,e_.set(h,_);for(var P=h.querySelectorAll("link[data-precedence],style[data-precedence]"),F=0;F<P.length;F++){var Q=P[F];(Q.nodeName==="LINK"||Q.getAttribute("media")!=="not all")&&(_.set(Q.dataset.precedence,Q),E=Q)}E&&_.set(null,E)}P=g.instance,Q=P.getAttribute("data-precedence"),F=_.get(Q)||E,F===E&&_.set(null,P),_.set(Q,P),this.count++,E=Jv.bind(this),P.addEventListener("load",E),P.addEventListener("error",E),F?F.parentNode.insertBefore(P,F.nextSibling):(h=h.nodeType===9?h.head:h,h.insertBefore(P,h.firstChild)),g.state.loading|=4}}var Jx={$$typeof:M,Provider:null,Consumer:null,_currentValue:J,_currentValue2:J,_threadCount:0};function $se(h,g,_,E,P,F,Q,xe,Pe){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=kt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=kt(0),this.hiddenUpdates=kt(null),this.identifierPrefix=E,this.onUncaughtError=P,this.onCaughtError=F,this.onRecoverableError=Q,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Pe,this.incompleteTransitions=new Map}function LU(h,g,_,E,P,F,Q,xe,Pe,at,bt,_t){return h=new $se(h,g,_,Q,Pe,at,bt,_t,xe),g=1,F===!0&&(g|=24),F=ks(3,null,null,g),h.current=F,F.stateNode=h,g=p2(),g.refCount++,h.pooledCache=g,g.refCount++,F.memoizedState={element:E,isDehydrated:_,cache:g},y2(F),h}function IU(h){return h?(h=_m,h):_m}function FU(h,g,_,E,P,F){P=IU(P),E.context===null?E.context=P:E.pendingContext=P,E=Ou(g),E.payload={element:_},F=F===void 0?null:F,F!==null&&(E.callback=F),_=Lu(h,E,g),_!==null&&(hs(_,h,g),jx(_,h,g))}function UU(h,g){if(h=h.memoizedState,h!==null&&h.dehydrated!==null){var _=h.retryLane;h.retryLane=_!==0&&_<g?_:g}}function IA(h,g){UU(h,g),(h=h.alternate)&&UU(h,g)}function zU(h){if(h.tag===13||h.tag===31){var g=wh(h,67108864);g!==null&&hs(g,h,67108864),IA(h,67108864)}}function BU(h){if(h.tag===13||h.tag===31){var g=Os();g=sn(g);var _=wh(h,g);_!==null&&hs(_,h,g),IA(h,g)}}var n_=!0;function Hse(h,g,_,E){var P=K.T;K.T=null;var F=V.p;try{V.p=2,FA(h,g,_,E)}finally{V.p=F,K.T=P}}function Vse(h,g,_,E){var P=K.T;K.T=null;var F=V.p;try{V.p=8,FA(h,g,_,E)}finally{V.p=F,K.T=P}}function FA(h,g,_,E){if(n_){var P=UA(E);if(P===null)MA(h,g,E,r_,_),HU(h,E);else if(Wse(P,h,g,_,E))E.stopPropagation();else if(HU(h,E),g&4&&-1<Gse.indexOf(h)){for(;P!==null;){var F=Bt(P);if(F!==null)switch(F.tag){case 3:if(F=F.stateNode,F.current.memoizedState.isDehydrated){var Q=Le(F.pendingLanes);if(Q!==0){var xe=F;for(xe.pendingLanes|=2,xe.entangledLanes|=2;Q;){var Pe=1<<31-Ce(Q);xe.entanglements[1]|=Pe,Q&=~Pe}Sl(F),(Qn&6)===0&&(Uv=O()+500,qx(0))}}break;case 31:case 13:xe=wh(F,2),xe!==null&&hs(xe,F,2),Bv(),IA(F,2)}if(F=UA(E),F===null&&MA(h,g,E,r_,_),F===P)break;P=F}P!==null&&E.stopPropagation()}else MA(h,g,E,null,_)}}function UA(h){return h=BN(h),zA(h)}var r_=null;function zA(h){if(r_=null,h=Pt(h),h!==null){var g=a(h);if(g===null)h=null;else{var _=g.tag;if(_===13){if(h=o(g),h!==null)return h;h=null}else if(_===31){if(h=l(g),h!==null)return h;h=null}else if(_===3){if(g.stateNode.current.memoizedState.isDehydrated)return g.tag===3?g.stateNode.containerInfo:null;h=null}else g!==h&&(h=null)}}return r_=h,null}function $U(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(Y()){case pe:return 2;case we:return 8;case ae:case ke:return 32;case De:return 268435456;default:return 32}default:return 32}}var BA=!1,qu=null,Ku=null,Xu=null,eb=new Map,tb=new Map,Yu=[],Gse="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 HU(h,g){switch(h){case"focusin":case"focusout":qu=null;break;case"dragenter":case"dragleave":Ku=null;break;case"mouseover":case"mouseout":Xu=null;break;case"pointerover":case"pointerout":eb.delete(g.pointerId);break;case"gotpointercapture":case"lostpointercapture":tb.delete(g.pointerId)}}function nb(h,g,_,E,P,F){return h===null||h.nativeEvent!==F?(h={blockedOn:g,domEventName:_,eventSystemFlags:E,nativeEvent:F,targetContainers:[P]},g!==null&&(g=Bt(g),g!==null&&zU(g)),h):(h.eventSystemFlags|=E,g=h.targetContainers,P!==null&&g.indexOf(P)===-1&&g.push(P),h)}function Wse(h,g,_,E,P){switch(g){case"focusin":return qu=nb(qu,h,g,_,E,P),!0;case"dragenter":return Ku=nb(Ku,h,g,_,E,P),!0;case"mouseover":return Xu=nb(Xu,h,g,_,E,P),!0;case"pointerover":var F=P.pointerId;return eb.set(F,nb(eb.get(F)||null,h,g,_,E,P)),!0;case"gotpointercapture":return F=P.pointerId,tb.set(F,nb(tb.get(F)||null,h,g,_,E,P)),!0}return!1}function VU(h){var g=Pt(h.target);if(g!==null){var _=a(g);if(_!==null){if(g=_.tag,g===13){if(g=o(_),g!==null){h.blockedOn=g,Cr(h.priority,function(){BU(_)});return}}else if(g===31){if(g=l(_),g!==null){h.blockedOn=g,Cr(h.priority,function(){BU(_)});return}}else if(g===3&&_.stateNode.current.memoizedState.isDehydrated){h.blockedOn=_.tag===3?_.stateNode.containerInfo:null;return}}}h.blockedOn=null}function i_(h){if(h.blockedOn!==null)return!1;for(var g=h.targetContainers;0<g.length;){var _=UA(h.nativeEvent);if(_===null){_=h.nativeEvent;var E=new _.constructor(_.type,_);zN=E,_.target.dispatchEvent(E),zN=null}else return g=Bt(_),g!==null&&zU(g),h.blockedOn=_,!1;g.shift()}return!0}function GU(h,g,_){i_(h)&&_.delete(g)}function qse(){BA=!1,qu!==null&&i_(qu)&&(qu=null),Ku!==null&&i_(Ku)&&(Ku=null),Xu!==null&&i_(Xu)&&(Xu=null),eb.forEach(GU),tb.forEach(GU)}function a_(h,g){h.blockedOn===g&&(h.blockedOn=null,BA||(BA=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,qse)))}var s_=null;function WU(h){s_!==h&&(s_=h,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){s_===h&&(s_=null);for(var g=0;g<h.length;g+=3){var _=h[g],E=h[g+1],P=h[g+2];if(typeof E!="function"){if(zA(E||_)===null)continue;break}var F=Bt(_);F!==null&&(h.splice(g,3),g-=3,U2(F,{pending:!0,data:P,method:_.method,action:E},E,P))}}))}function Gm(h){function g(Pe){return a_(Pe,h)}qu!==null&&a_(qu,h),Ku!==null&&a_(Ku,h),Xu!==null&&a_(Xu,h),eb.forEach(g),tb.forEach(g);for(var _=0;_<Yu.length;_++){var E=Yu[_];E.blockedOn===h&&(E.blockedOn=null)}for(;0<Yu.length&&(_=Yu[0],_.blockedOn===null);)VU(_),_.blockedOn===null&&Yu.shift();if(_=(h.ownerDocument||h).$$reactFormReplay,_!=null)for(E=0;E<_.length;E+=3){var P=_[E],F=_[E+1],Q=P[yr]||null;if(typeof F=="function")Q||WU(_);else if(Q){var xe=null;if(F&&F.hasAttribute("formAction")){if(P=F,Q=F[yr]||null)xe=Q.formAction;else if(zA(P)!==null)continue}else xe=Q.action;typeof xe=="function"?_[E+1]=xe:(_.splice(E,3),E-=3),WU(_)}}}function qU(){function h(F){F.canIntercept&&F.info==="react-transition"&&F.intercept({handler:function(){return new Promise(function(Q){return P=Q})},focusReset:"manual",scroll:"manual"})}function g(){P!==null&&(P(),P=null),E||setTimeout(_,20)}function _(){if(!E&&!navigation.transition){var F=navigation.currentEntry;F&&F.url!=null&&navigation.navigate(F.url,{state:F.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var E=!1,P=null;return navigation.addEventListener("navigate",h),navigation.addEventListener("navigatesuccess",g),navigation.addEventListener("navigateerror",g),setTimeout(_,100),function(){E=!0,navigation.removeEventListener("navigate",h),navigation.removeEventListener("navigatesuccess",g),navigation.removeEventListener("navigateerror",g),P!==null&&(P(),P=null)}}}function $A(h){this._internalRoot=h}o_.prototype.render=$A.prototype.render=function(h){var g=this._internalRoot;if(g===null)throw Error(r(409));var _=g.current,E=Os();FU(_,E,h,g,null,null)},o_.prototype.unmount=$A.prototype.unmount=function(){var h=this._internalRoot;if(h!==null){this._internalRoot=null;var g=h.containerInfo;FU(h.current,2,null,h,null,null),Bv(),g[Ci]=null}};function o_(h){this._internalRoot=h}o_.prototype.unstable_scheduleHydration=function(h){if(h){var g=Cn();h={blockedOn:null,target:h,priority:g};for(var _=0;_<Yu.length&&g!==0&&g<Yu[_].priority;_++);Yu.splice(_,0,h),_===0&&VU(h)}};var KU=e.version;if(KU!=="19.2.3")throw Error(r(527,KU,"19.2.3"));V.findDOMNode=function(h){var g=h._reactInternals;if(g===void 0)throw typeof h.render=="function"?Error(r(188)):(h=Object.keys(h).join(","),Error(r(268,h)));return h=u(g),h=h!==null?d(h):null,h=h===null?null:h.stateNode,h};var Kse={bundleType:0,version:"19.2.3",rendererPackageName:"react-dom",currentDispatcherRef:K,reconcilerVersion:"19.2.3"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var l_=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!l_.isDisabled&&l_.supportsFiber)try{Ye=l_.inject(Kse),se=l_}catch{}}return ib.createRoot=function(h,g){if(!i(h))throw Error(r(299));var _=!1,E="",P=t5,F=n5,Q=r5;return g!=null&&(g.unstable_strictMode===!0&&(_=!0),g.identifierPrefix!==void 0&&(E=g.identifierPrefix),g.onUncaughtError!==void 0&&(P=g.onUncaughtError),g.onCaughtError!==void 0&&(F=g.onCaughtError),g.onRecoverableError!==void 0&&(Q=g.onRecoverableError)),g=LU(h,1,!1,null,null,_,E,null,P,F,Q,qU),h[Ci]=g.current,SA(h),new $A(g)},ib.hydrateRoot=function(h,g,_){if(!i(h))throw Error(r(299));var E=!1,P="",F=t5,Q=n5,xe=r5,Pe=null;return _!=null&&(_.unstable_strictMode===!0&&(E=!0),_.identifierPrefix!==void 0&&(P=_.identifierPrefix),_.onUncaughtError!==void 0&&(F=_.onUncaughtError),_.onCaughtError!==void 0&&(Q=_.onCaughtError),_.onRecoverableError!==void 0&&(xe=_.onRecoverableError),_.formState!==void 0&&(Pe=_.formState)),g=LU(h,1,!0,g,_??null,E,P,Pe,F,Q,xe,qU),g.context=IU(null),_=g.current,E=Os(),E=sn(E),P=Ou(E),P.callback=null,Lu(_,P,E),_=E,g.current.lanes=_,on(g,_),Sl(g),h[Ci]=g.current,SA(h),new o_(g)},ib.version="19.2.3",ib}var iz;function aoe(){if(iz)return GA.exports;iz=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(),GA.exports=ioe(),GA.exports}var soe=aoe();const dn=t=>typeof t=="string",ab=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},az=t=>t==null?"":""+t,ooe=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},loe=/###/g,sz=t=>t&&t.indexOf("###")>-1?t.replace(loe,"."):t,oz=t=>!t||dn(t),Jb=(t,e,n)=>{const r=dn(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(oz(t))return{};const a=sz(r[i]);!t[a]&&n&&(t[a]=new n),Object.prototype.hasOwnProperty.call(t,a)?t=t[a]:t={},++i}return oz(t)?{}:{obj:t,k:sz(r[i])}},lz=(t,e,n)=>{const{obj:r,k:i}=Jb(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=Jb(t,o,Object);for(;l.obj===void 0&&o.length;)a=`${o[o.length-1]}.${a}`,o=o.slice(0,o.length-1),l=Jb(t,o,Object),l?.obj&&typeof l.obj[`${l.k}.${a}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${a}`]=n},coe=(t,e,n,r)=>{const{obj:i,k:a}=Jb(t,e,Object);i[a]=i[a]||[],i[a].push(n)},Sw=(t,e)=>{const{obj:n,k:r}=Jb(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},uoe=(t,e,n)=>{const r=Sw(t,n);return r!==void 0?r:Sw(e,n)},gq=(t,e,n)=>{for(const r in e)r!=="__proto__"&&r!=="constructor"&&(r in t?dn(t[r])||t[r]instanceof String||dn(e[r])||e[r]instanceof String?n&&(t[r]=e[r]):gq(t[r],e[r],n):t[r]=e[r]);return t},Wm=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var doe={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const hoe=t=>dn(t)?t.replace(/[&<>"'\/]/g,e=>doe[e]):t;class foe{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 moe=[" ",",","?","!",";"],poe=new foe(20),goe=(t,e,n)=>{e=e||"",n=n||"";const r=moe.filter(o=>e.indexOf(o)<0&&n.indexOf(o)<0);if(r.length===0)return!0;const i=poe.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},Qj=(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},S0=t=>t?.replace("_","-"),xoe={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 Mw{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||xoe,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:(dn(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new Mw(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new Mw(this.logger,e)}}var Ul=new Mw;let XM=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 cz extends XM{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):dn(r)&&a?l.push(...r.split(a)):l.push(r)));const c=Sw(this.data,l);return!c&&!n&&!r&&e.indexOf(".")>-1&&(e=l[0],n=l[1],r=l.slice(2).join(".")),c||!o||!dn(r)?c:Qj(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),lz(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)(dn(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=Sw(this.data,l)||{};o.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?gq(c,r,a):c={...c,...r},lz(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 xq={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 bq=Symbol("i18next/PATH_KEY");function boe(){const t=[],e=Object.create(null);let n;return e.get=(r,i)=>(n?.revoke?.(),i===bq?t:(t.push(i),n=Proxy.revocable(r,e),n.proxy)),Proxy.revocable(Object.create(null),e).proxy}function Jj(t,e){const{[bq]:n}=t(boe());return n.join(e?.keySeparator??".")}const uz={},XA=t=>!dn(t)&&typeof t!="boolean"&&typeof t!="number";class Ew extends XM{constructor(e,n={}){super(),ooe(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Ul.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=XA(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&&!goe(e,r,i);if(o&&!l){const c=e.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:e,namespaces:dn(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:dn(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=Jj(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,m=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(f?.toLowerCase()==="cimode")return m?a?{res:`${u}${d}${l}`,usedKey:l,exactUsedKey:l,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:`${u}${d}${l}`:a?{res:l,usedKey:l,exactUsedKey:l,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:l;const p=this.resolve(e,i);let b=p?.res;const v=p?.usedKey||l,x=p?.exactUsedKey||l,y=["[object Number]","[object Function]","[object RegExp]"],S=i.joinArrays!==void 0?i.joinArrays:this.options.joinArrays,M=!this.i18nFormat||this.i18nFormat.handleAsObject,N=i.count!==void 0&&!dn(i.count),A=Ew.hasDefaultValue(i),k=N?this.pluralResolver.getSuffix(f,i.count,i):"",C=i.ordinal&&N?this.pluralResolver.getSuffix(f,i.count,{ordinal:!1}):"",D=N&&!i.ordinal&&i.count===0,T=D&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${k}`]||i[`defaultValue${C}`]||i.defaultValue;let R=b;M&&!b&&A&&(R=T);const U=XA(R),L=Object.prototype.toString.apply(R);if(M&&R&&U&&y.indexOf(L)<0&&!(dn(S)&&Array.isArray(R))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const q=this.options.returnedObjectHandler?this.options.returnedObjectHandler(v,R,{...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(R),j=q?[]:{},W=q?x:v;for(const K in R)if(Object.prototype.hasOwnProperty.call(R,K)){const V=`${W}${o}${K}`;A&&!b?j[K]=this.translate(V,{...i,defaultValue:XA(T)?T[K]:void 0,joinArrays:!1,ns:c}):j[K]=this.translate(V,{...i,joinArrays:!1,ns:c}),j[K]===V&&(j[K]=R[K])}b=j}}else if(M&&dn(S)&&Array.isArray(b))b=b.join(S),b&&(b=this.extendTranslation(b,e,i,r));else{let q=!1,j=!1;!this.isValidLookup(b)&&A&&(q=!0,b=T),this.isValidLookup(b)||(j=!0,b=l);const K=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&j?void 0:b,V=A&&T!==b&&this.options.updateMissing;if(j||q||V){if(this.logger.log(V?"updateKey":"missingKey",f,u,l,V?T:b),o){const z=this.resolve(l,{...i,keySeparator:!1});z&&z.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let J=[];const ne=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&ne&&ne[0])for(let z=0;z<ne.length;z++)J.push(ne[z]);else this.options.saveMissingTo==="all"?J=this.languageUtils.toResolveHierarchy(i.lng||this.language):J.push(i.lng||this.language);const te=(z,H,Z)=>{const ee=A&&Z!==b?Z:K;this.options.missingKeyHandler?this.options.missingKeyHandler(z,u,H,ee,V,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(z,u,H,ee,V,i),this.emit("missingKey",z,u,H,b)};this.options.saveMissing&&(this.options.saveMissingPlurals&&N?J.forEach(z=>{const H=this.pluralResolver.getSuffixes(z,i);D&&i[`defaultValue${this.options.pluralSeparator}zero`]&&H.indexOf(`${this.options.pluralSeparator}zero`)<0&&H.push(`${this.options.pluralSeparator}zero`),H.forEach(Z=>{te([z],l+Z,i[`defaultValue${Z}`]||T)})}):te(J,l,T))}b=this.extendTranslation(b,e,i,p,r),j&&b===l&&this.options.appendNamespaceToMissingKey&&(b=`${u}${d}${l}`),(j||q)&&this.options.parseMissingKeyHandler&&(b=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${d}${l}`:l,q?b:void 0,i))}return a?(p.res=b,p.usedParams=this.getUsedParamsDetails(i),p):b}extendTranslation(e,n,r,i,a){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const c=dn(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&&!dn(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),m=f&&f.length;u<m&&(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=dn(o)?[o]:o;return e!=null&&l?.length&&r.applyPostProcessor!==!1&&(e=xq.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 dn(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 m=n.count!==void 0&&!dn(n.count),p=m&&!n.ordinal&&n.count===0,b=n.context!==void 0&&(dn(n.context)||typeof n.context=="number")&&n.context!=="",v=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);f.forEach(x=>{this.isValidLookup(r)||(l=x,!uz[`${v[0]}-${x}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(l)&&(uz[`${v[0]}-${x}`]=!0,this.logger.warn(`key "${i}" for languages "${v.join(", ")}" won't get resolved as namespace "${l}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),v.forEach(y=>{if(this.isValidLookup(r))return;o=y;const S=[d];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(S,d,y,x,n);else{let N;m&&(N=this.pluralResolver.getSuffix(y,n.count,n));const A=`${this.options.pluralSeparator}zero`,k=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(m&&(n.ordinal&&N.indexOf(k)===0&&S.push(d+N.replace(k,this.options.pluralSeparator)),S.push(d+N),p&&S.push(d+A)),b){const C=`${d}${this.options.contextSeparator||"_"}${n.context}`;S.push(C),m&&(n.ordinal&&N.indexOf(k)===0&&S.push(C+N.replace(k,this.options.pluralSeparator)),S.push(C+N),p&&S.push(C+A))}}let M;for(;M=S.pop();)this.isValidLookup(r)||(a=M,r=this.getResource(y,x,M,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&&!dn(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 dz{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Ul.create("languageUtils")}getScriptPartFromCode(e){if(e=S0(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=S0(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(dn(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)),dn(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 dn(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))):dn(e)&&a(this.formatLanguageCode(e)),r.forEach(o=>{i.indexOf(o)<0&&a(this.formatLanguageCode(o))}),i}}const hz={zero:0,one:1,two:2,few:3,many:4,other:5},fz={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class yoe{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=Ul.create("pluralResolver"),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){const r=S0(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!"),fz;if(!e.match(/-|_/))return fz;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)=>hz[i]-hz[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 mz=(t,e,n,r=".",i=!0)=>{let a=uoe(t,e,n);return!a&&i&&dn(n)&&(a=Qj(t,n,r),a===void 0&&(a=Qj(e,n,r))),a},YA=t=>t.replace(/\$/g,"$$$$");class pz{constructor(e={}){this.logger=Ul.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:m,nestingPrefixEscaped:p,nestingSuffix:b,nestingSuffixEscaped:v,nestingOptionsSeparator:x,maxReplaces:y,alwaysFormat:S}=e.interpolation;this.escape=n!==void 0?n:hoe,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=a?Wm(a):o||"{{",this.suffix=l?Wm(l):c||"}}",this.formatSeparator=u||",",this.unescapePrefix=d?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":d||"",this.nestingPrefix=m?Wm(m):p||Wm("$t("),this.nestingSuffix=b?Wm(b):v||Wm(")"),this.nestingOptionsSeparator=x||",",this.maxReplaces=y||1e3,this.alwaysFormat=S!==void 0?S:!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 y=mz(n,c,p,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(y,void 0,r,{...i,...n,interpolationkey:p}):y}const b=p.split(this.formatSeparator),v=b.shift().trim(),x=b.join(this.formatSeparator).trim();return this.format(mz(n,c,v,this.options.keySeparator,this.options.ignoreJSONStructure),x,r,{...i,...n,interpolationkey:v})};this.resetRegExp();const d=i?.missingInterpolationHandler||this.options.missingInterpolationHandler,f=i?.interpolation?.skipOnVariables!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:p=>YA(p)},{regex:this.regexp,safeValue:p=>this.escapeValue?YA(this.escape(p)):YA(p)}].forEach(p=>{for(l=0;a=p.regex.exec(e);){const b=a[1].trim();if(o=u(b),o===void 0)if(typeof d=="function"){const x=d(e,a,i);o=dn(x)?x:""}else if(i&&Object.prototype.hasOwnProperty.call(i,b))o="";else if(f){o=a[0];continue}else this.logger.warn(`missed to pass in variable ${b} for interpolating ${e}`),o="";else!dn(o)&&!this.useRawValueToEscape&&(o=az(o));const v=p.safeValue(o);if(e=e.replace(a[0],v),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 m=`{${f[1]}`;c=f[0],m=this.interpolate(m,o);const p=m.match(/'/g),b=m.match(/"/g);((p?.length??0)%2===0&&!b||b.length%2!==0)&&(m=m.replace(/'/g,'"'));try{o=JSON.parse(m),u&&(o={...u,...o})}catch(v){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,v),`${c}${d}${m}`}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&&!dn(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&&!dn(a))return a;dn(a)||(a=az(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 voe=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}},gz=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(S0(r),i),e[o]=l),l(n)}},_oe=t=>(e,n,r)=>t(S0(n),r)(e);class woe{constructor(e={}){this.logger=Ul.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const r=n.cacheInBuiltFormats?gz:_oe;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()]=gz(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}=voe(c);if(this.formats[u]){let f=l;try{const m=i?.formatParams?.[i.interpolationkey]||{},p=m.locale||m.lng||i.locale||i.lng||r;f=this.formats[u](l,p,{...d,...i,...m})}catch(m){this.logger.warn(m)}return f}else this.logger.warn(`there was no format function for ${u}`);return l},e)}}const Soe=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class Moe extends XM{constructor(e,n,r,i={}){super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=Ul.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 m=`${u}|${f}`;!r.reload&&this.store.hasResourceBundle(u,f)?this.state[m]=2:this.state[m]<0||(this.state[m]===1?o[m]===void 0&&(o[m]=!0):(this.state[m]=1,d=!1,o[m]===void 0&&(o[m]=!0),a[m]===void 0&&(a[m]=!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=>{coe(c.loaded,[a],o),Soe(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();dn(e)&&(e=this.languageUtils.toResolveHierarchy(e)),dn(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 ZA=()=>({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]),dn(t[1])&&(e.defaultValue=t[1]),dn(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}),xz=t=>(dn(t.ns)&&(t.ns=[t.ns]),dn(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),dn(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),u_=()=>{},Eoe=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class e0 extends XM{constructor(e={},n){if(super(),this.options=xz(e),this.services={},this.logger=Ul,this.modules={external:[]},Eoe(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&&(dn(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const r=ZA();this.options={...r,...this.options,...xz(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),typeof this.options.overloadTranslationOptionHandler!="function"&&(this.options.overloadTranslationOptionHandler=r.overloadTranslationOptionHandler),this.options.debug===!0&&typeof console<"u"&&console.warn("i18next is maintained with support from locize.com — consider powering your project with managed localization (AI, CDN, integrations): https://locize.com");const i=u=>u?typeof u=="function"?new u:u:null;if(!this.options.isClone){this.modules.logger?Ul.init(i(this.modules.logger),this.options):Ul.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=woe;const d=new dz(this.options);this.store=new cz(this.options.resources,this.options);const f=this.services;f.logger=Ul,f.resourceStore=this.store,f.languageUtils=d,f.pluralResolver=new yoe(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 pz(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new Moe(i(this.modules.backend),f.resourceStore,f,this.options),f.backendConnector.on("*",(p,...b)=>{this.emit(p,...b)}),this.modules.languageDetector&&(f.languageDetector=i(this.modules.languageDetector),f.languageDetector.init&&f.languageDetector.init(f,this.options.detection,this.options)),this.modules.i18nFormat&&(f.i18nFormat=i(this.modules.i18nFormat),f.i18nFormat.init&&f.i18nFormat.init(this)),this.translator=new Ew(this.services,this.options),this.translator.on("*",(p,...b)=>{this.emit(p,...b)}),this.modules.external.forEach(p=>{p.init&&p.init(this)})}if(this.format=this.options.interpolation.format,n||(n=u_),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=ab(),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=u_){let r=n;const i=dn(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=ab();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=u_),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"&&xq.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=ab();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=dn(l)?l:l&&l[0],u=this.store.hasLanguageSomeTranslations(c)?c:this.services.languageUtils.getBestMatchFromCodes(dn(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=Jj(f,{...this.options,...o})),`${c.keyPrefix}${u}${f}`)):(typeof a=="function"&&(a=Jj(a,{...this.options,...o})),d=c.keyPrefix?`${c.keyPrefix}${u}${a}`:a),this.t(d,c)};return dn(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=ab();return this.options.ns?(dn(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=ab();dn(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 dz(ZA());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 e0(e,n);return r.createInstance=e0.createInstance,r}cloneInstance(e={},n=u_){const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},a=new e0(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 cz(l,i),a.services.resourceStore=a.store}if(e.interpolation){const c={...ZA().interpolation,...this.options.interpolation,...e.interpolation},u={...i,interpolation:c};a.services.interpolator=new pz(u)}return a.translator=new Ew(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 as=e0.createInstance();as.createInstance;as.dir;as.init;as.loadResources;as.reloadResources;as.use;as.changeLanguage;as.getFixedT;as.t;as.exists;as.setDefaultNamespace;as.hasLoadedNamespace;as.loadNamespaces;as.loadLanguages;const Noe=(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);Df(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),t?.services?.logger?.warn?t.services.logger.warn(...i):console?.warn&&console.warn(...i)},bz={},yq=(t,e,n,r)=>{Df(n)&&bz[n]||(Df(n)&&(bz[n]=new Date),Noe(t,e,n,r))},vq=(t,e)=>()=>{if(t.isInitialized)e();else{const n=()=>{setTimeout(()=>{t.off("initialized",n)},0),e()};t.on("initialized",n)}},eP=(t,e,n)=>{t.loadNamespaces(e,vq(t,n))},yz=(t,e,n,r)=>{if(Df(n)&&(n=[n]),t.options.preload&&t.options.preload.indexOf(e)>-1)return eP(t,n,r);n.forEach(i=>{t.options.ns.indexOf(i)<0&&t.options.ns.push(i)}),t.loadLanguages(e,vq(t,r))},Aoe=(t,e,n={})=>!e.languages||!e.languages.length?(yq(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}}),Df=t=>typeof t=="string",Toe=t=>typeof t=="object"&&t!==null,Coe=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,koe={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},joe=t=>koe[t],Poe=t=>t.replace(Coe,joe);let tP={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:Poe,transDefaultProps:void 0};const Roe=(t={})=>{tP={...tP,...t}},Doe=()=>tP;let _q;const Ooe=t=>{_q=t},Loe=()=>_q,Ioe={type:"3rdParty",init(t){Roe(t.options.react),Ooe(t)}},Foe=w.createContext();class Uoe{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 vz;function zoe(){if(vz)return JA;vz=1;var t=Vg();function e(f,m){return f===m&&(f!==0||1/f===1/m)||f!==f&&m!==m}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,i=t.useEffect,a=t.useLayoutEffect,o=t.useDebugValue;function l(f,m){var p=m(),b=r({inst:{value:p,getSnapshot:m}}),v=b[0].inst,x=b[1];return a(function(){v.value=p,v.getSnapshot=m,c(v)&&x({inst:v})},[f,p,m]),i(function(){return c(v)&&x({inst:v}),f(function(){c(v)&&x({inst:v})})},[f]),o(p),p}function c(f){var m=f.getSnapshot;f=f.value;try{var p=m();return!n(f,p)}catch{return!0}}function u(f,m){return m()}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 _z;function wq(){return _z||(_z=1,QA.exports=zoe()),QA.exports}var vD=wq();const Boe=(t,e)=>Df(e)?e:Toe(e)&&Df(e.defaultValue)?e.defaultValue:Array.isArray(t)?t[t.length-1]:t,$oe={t:Boe,ready:!1},Hoe=()=>()=>{},Gg=(t,e={})=>{const{i18n:n}=e,{i18n:r,defaultNS:i}=w.useContext(Foe)||{},a=n||r||Loe();a&&!a.reportNamespaces&&(a.reportNamespaces=new Uoe),a||yq(a,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const o=w.useMemo(()=>({...Doe(),...a?.options?.react,...e}),[a,e]),{useSuspense:l,keyPrefix:c}=o,u=i||a?.options?.defaultNS,d=Df(u)?[u]:u||["translation"],f=w.useMemo(()=>d,d);a?.reportNamespaces?.addUsedNamespaces?.(f);const m=w.useRef(0),p=w.useCallback(T=>{if(!a)return Hoe;const{bindI18n:R,bindI18nStore:U}=o,L=()=>{m.current+=1,T()};return R&&a.on(R,L),U&&a.store.on(U,L),()=>{R&&R.split(" ").forEach(q=>a.off(q,L)),U&&U.split(" ").forEach(q=>a.store.off(q,L))}},[a,o]),b=w.useRef(),v=w.useCallback(()=>{if(!a)return $oe;const T=!!(a.isInitialized||a.initializedStoreOnce)&&f.every(W=>Aoe(W,a,o)),R=e.lng||a.language,U=m.current,L=b.current;if(L&&L.ready===T&&L.lng===R&&L.keyPrefix===c&&L.revision===U)return L;const j={t:a.getFixedT(R,o.nsMode==="fallback"?f:f[0],c),ready:T,lng:R,keyPrefix:c,revision:U};return b.current=j,j},[a,f,c,o,e.lng]),[x,y]=w.useState(0),{t:S,ready:M}=vD.useSyncExternalStore(p,v,v);w.useEffect(()=>{if(a&&!M&&!l){const T=()=>y(R=>R+1);e.lng?yz(a,e.lng,f,T):eP(a,f,T)}},[a,e.lng,f,M,l,x]);const N=a||{},A=w.useRef(null),k=w.useRef(),C=T=>{const R=Object.getOwnPropertyDescriptors(T);R.__original&&delete R.__original;const U=Object.create(Object.getPrototypeOf(T),R);if(!Object.prototype.hasOwnProperty.call(U,"__original"))try{Object.defineProperty(U,"__original",{value:T,writable:!1,enumerable:!1,configurable:!1})}catch{}return U},D=w.useMemo(()=>{const T=N,R=T?.language;let U=T;T&&(A.current&&A.current.__original===T?k.current!==R?(U=C(T),A.current=U,k.current=R):U=A.current:(U=C(T),A.current=U,k.current=R));const L=[S,U,M];return L.t=S,L.i18n=U,L.ready=M,L},[S,N,M,N.resolvedLanguage,N.language,N.languages]);if(a&&l&&!M)throw new Promise(T=>{const R=()=>T();e.lng?yz(a,e.lng,f,R):eP(a,f,R)});return D},{slice:Voe,forEach:Goe}=[];function Woe(t){return Goe.call(Voe.call(arguments,1),e=>{if(e)for(const n in e)t[n]===void 0&&(t[n]=e[n])}),t}function qoe(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 wz=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,Koe=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(!wz.test(r.domain))throw new TypeError("option domain is invalid");a+=`; Domain=${r.domain}`}if(r.path){if(!wz.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},Sz={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=Koe(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 Xoe={name:"cookie",lookup(t){let{lookupCookie:e}=t;if(e&&typeof document<"u")return Sz.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:n,cookieMinutes:r,cookieDomain:i,cookieOptions:a}=e;n&&typeof document<"u"&&Sz.create(n,t,r,i,a)}},Yoe={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}},Zoe={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 qm=null;const Mz=()=>{if(qm!==null)return qm;try{if(qm=typeof window<"u"&&window.localStorage!==null,!qm)return!1;const t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{qm=!1}return qm};var Qoe={name:"localStorage",lookup(t){let{lookupLocalStorage:e}=t;if(e&&Mz())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:n}=e;n&&Mz()&&window.localStorage.setItem(n,t)}};let Km=null;const Ez=()=>{if(Km!==null)return Km;try{if(Km=typeof window<"u"&&window.sessionStorage!==null,!Km)return!1;const t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{Km=!1}return Km};var Joe={name:"sessionStorage",lookup(t){let{lookupSessionStorage:e}=t;if(e&&Ez())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupSessionStorage:n}=e;n&&Ez()&&window.sessionStorage.setItem(n,t)}},ele={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}},tle={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}},nle={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}},rle={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 Sq=!1;try{document.cookie,Sq=!0}catch{}const Mq=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];Sq||Mq.splice(1,1);const ile=()=>({order:Mq,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:t=>t});class Eq{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=Woe(n,this.options||{},ile()),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(Xoe),this.addDetector(Yoe),this.addDetector(Qoe),this.addDetector(Joe),this.addDetector(ele),this.addDetector(tle),this.addDetector(nle),this.addDetector(rle),this.addDetector(Zoe)}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&&!qoe(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)}))}}Eq.type="languageDetector";const ale={nav:{printers:"Printers",archives:"Archives",queue:"Queue",stats:"Statistics",profiles:"Profiles",maintenance:"Maintenance",projects:"Projects",files:"File Manager",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",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?"}},sle={nav:{printers:"Drucker",archives:"Archiv",queue:"Warteschlange",stats:"Statistiken",profiles:"Profile",maintenance:"Wartung",projects:"Projekte",files:"Dateimanager",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",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?"}},ole={en:{translation:ale},de:{translation:sle}};as.use(Eq).use(Ioe).init({resources:ole,fallbackLng:"en",supportedLngs:["en","de"],detection:{order:["localStorage","navigator","htmlTag"],lookupLocalStorage:"bambutrack_language",caches:["localStorage"]},interpolation:{escapeValue:!1},react:{useSuspense:!1}});const Nz=[{code:"en",name:"English",nativeName:"English"},{code:"de",name:"German",nativeName:"Deutsch"}];var Az="popstate";function lle(t={}){function e(r,i){let{pathname:a,search:o,hash:l}=r.location;return nP("",{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:M0(i)}return ule(e,n,null,t)}function Br(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function Ro(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function cle(){return Math.random().toString(36).substring(2,10)}function Tz(t,e){return{usr:t.state,key:t.key,idx:e}}function nP(t,e,n=null,r){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof e=="string"?Wg(e):e,state:n,key:e&&e.key||r||cle()}}function M0({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 Wg(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 ule(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 x=d(),y=x==null?null:x-u;u=x,c&&c({action:l,location:v.location,delta:y})}function m(x,y){l="PUSH";let S=nP(v.location,x,y);u=d()+1;let M=Tz(S,u),N=v.createHref(S);try{o.pushState(M,"",N)}catch(A){if(A instanceof DOMException&&A.name==="DataCloneError")throw A;i.location.assign(N)}a&&c&&c({action:l,location:v.location,delta:1})}function p(x,y){l="REPLACE";let S=nP(v.location,x,y);u=d();let M=Tz(S,u),N=v.createHref(S);o.replaceState(M,"",N),a&&c&&c({action:l,location:v.location,delta:0})}function b(x){return dle(x)}let v={get action(){return l},get location(){return t(i,o)},listen(x){if(c)throw new Error("A history only accepts one active listener");return i.addEventListener(Az,f),c=x,()=>{i.removeEventListener(Az,f),c=null}},createHref(x){return e(i,x)},createURL:b,encodeLocation(x){let y=b(x);return{pathname:y.pathname,search:y.search,hash:y.hash}},push:m,replace:p,go(x){return o.go(x)}};return v}function dle(t,e=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),Br(n,"No window.location.(origin|href) available to create URL");let r=typeof t=="string"?t:M0(t);return r=r.replace(/ $/,"%20"),!e&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function Nq(t,e,n="/"){return hle(t,e,n,!1)}function hle(t,e,n,r){let i=typeof e=="string"?Wg(e):e,a=uu(i.pathname||"/",n);if(a==null)return null;let o=Aq(t);fle(o);let l=null;for(let c=0;l==null&&c<o.length;++c){let u=Mle(a);l=wle(o[c],u,r)}return l}function Aq(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;Br(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=nu([r,d.relativePath]),m=n.concat(d);o.children&&o.children.length>0&&(Br(o.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${f}".`),Aq(o.children,e,m,f,c)),!(o.path==null&&!o.index)&&e.push({path:f,score:vle(f,o.index),routesMeta:m})};return t.forEach((o,l)=>{if(o.path===""||!o.path?.includes("?"))a(o,l);else for(let c of Tq(o.path))a(o,l,!0,c)}),e}function Tq(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=Tq(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 fle(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:_le(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var mle=/^:[\w-]+$/,ple=3,gle=2,xle=1,ble=10,yle=-2,Cz=t=>t==="*";function vle(t,e){let n=t.split("/"),r=n.length;return n.some(Cz)&&(r+=yle),e&&(r+=gle),n.filter(i=>!Cz(i)).reduce((i,a)=>i+(mle.test(a)?ple:a===""?xle:ble),r)}function _le(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 wle(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=Nw({path:c.relativePath,caseSensitive:c.caseSensitive,end:u},d),m=c.route;if(!f&&u&&n&&!r[r.length-1].route.index&&(f=Nw({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},d)),!f)return null;Object.assign(i,f.params),o.push({params:i,pathname:nu([a,f.pathname]),pathnameBase:Tle(nu([a,f.pathnameBase])),route:m}),f.pathnameBase!=="/"&&(a=nu([a,f.pathnameBase]))}return o}function Nw(t,e){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,r]=Sle(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},m)=>{if(d==="*"){let b=l[m]||"";o=a.slice(0,a.length-b.length).replace(/(.)\/+$/,"$1")}const p=l[m];return f&&!p?u[d]=void 0:u[d]=(p||"").replace(/%2F/g,"/"),u},{}),pathname:a,pathnameBase:o,pattern:t}}function Sle(t,e=!1,n=!0){Ro(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 Mle(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return Ro(!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 uu(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 Ele=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function Nle(t,e="/"){let{pathname:n,search:r="",hash:i=""}=typeof t=="string"?Wg(t):t,a;return n?(n=n.replace(/\/\/+/g,"/"),n.startsWith("/")?a=kz(n.substring(1),"/"):a=kz(n,e)):a=e,{pathname:a,search:Cle(r),hash:kle(i)}}function kz(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 eT(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 Ale(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function _D(t){let e=Ale(t);return e.map((n,r)=>r===e.length-1?n.pathname:n.pathnameBase)}function wD(t,e,n,r=!1){let i;typeof t=="string"?i=Wg(t):(i={...t},Br(!i.pathname||!i.pathname.includes("?"),eT("?","pathname","search",i)),Br(!i.pathname||!i.pathname.includes("#"),eT("#","pathname","hash",i)),Br(!i.search||!i.search.includes("#"),eT("#","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 m=o.split("/");for(;m[0]==="..";)m.shift(),f-=1;i.pathname=m.join("/")}l=f>=0?e[f]:"/"}let c=Nle(i,l),u=o&&o!=="/"&&o.endsWith("/"),d=(a||o===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}var nu=t=>t.join("/").replace(/\/\/+/g,"/"),Tle=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),Cle=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,kle=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t,jle=class{constructor(t,e,n,r=!1){this.status=t,this.statusText=e||"",this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function Ple(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}function Rle(t){return t.map(e=>e.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var Cq=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function kq(t,e){let n=t;if(typeof n!="string"||!Ele.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(Cq)try{let a=new URL(window.location.href),o=n.startsWith("//")?new URL(a.protocol+n):new URL(n),l=uu(o.pathname,e);o.origin===a.origin&&l!=null?n=l+o.search+o.hash:i=!0}catch{Ro(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:i,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var jq=["POST","PUT","PATCH","DELETE"];new Set(jq);var Dle=["GET",...jq];new Set(Dle);var qg=w.createContext(null);qg.displayName="DataRouter";var YM=w.createContext(null);YM.displayName="DataRouterState";var Ole=w.createContext(!1),Pq=w.createContext({isTransitioning:!1});Pq.displayName="ViewTransition";var Lle=w.createContext(new Map);Lle.displayName="Fetchers";var Ile=w.createContext(null);Ile.displayName="Await";var eo=w.createContext(null);eo.displayName="Navigation";var gy=w.createContext(null);gy.displayName="Location";var Io=w.createContext({outlet:null,matches:[],isDataRoute:!1});Io.displayName="Route";var SD=w.createContext(null);SD.displayName="RouteError";var Rq="REACT_ROUTER_ERROR",Fle="REDIRECT",Ule="ROUTE_ERROR_RESPONSE";function zle(t){if(t.startsWith(`${Rq}:${Fle}:{`))try{let e=JSON.parse(t.slice(28));if(typeof e=="object"&&e&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.location=="string"&&typeof e.reloadDocument=="boolean"&&typeof e.replace=="boolean")return e}catch{}}function Ble(t){if(t.startsWith(`${Rq}:${Ule}:{`))try{let e=JSON.parse(t.slice(40));if(typeof e=="object"&&e&&typeof e.status=="number"&&typeof e.statusText=="string")return new jle(e.status,e.statusText,e.data)}catch{}}function $le(t,{relative:e}={}){Br(Kg(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=w.useContext(eo),{hash:i,pathname:a,search:o}=xy(t,{relative:e}),l=a;return n!=="/"&&(l=a==="/"?n:nu([n,a])),r.createHref({pathname:l,search:o,hash:i})}function Kg(){return w.useContext(gy)!=null}function lc(){return Br(Kg(),"useLocation() may be used only in the context of a <Router> component."),w.useContext(gy).location}var Dq="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Oq(t){w.useContext(eo).static||w.useLayoutEffect(t)}function pl(){let{isDataRoute:t}=w.useContext(Io);return t?rce():Hle()}function Hle(){Br(Kg(),"useNavigate() may be used only in the context of a <Router> component.");let t=w.useContext(qg),{basename:e,navigator:n}=w.useContext(eo),{matches:r}=w.useContext(Io),{pathname:i}=lc(),a=JSON.stringify(_D(r)),o=w.useRef(!1);return Oq(()=>{o.current=!0}),w.useCallback((c,u={})=>{if(Ro(o.current,Dq),!o.current)return;if(typeof c=="number"){n.go(c);return}let d=wD(c,JSON.parse(a),i,u.relative==="path");t==null&&e!=="/"&&(d.pathname=d.pathname==="/"?e:nu([e,d.pathname])),(u.replace?n.replace:n.push)(d,u.state,u)},[e,n,a,i,t])}var Vle=w.createContext(null);function Gle(t){let e=w.useContext(Io).outlet;return w.useMemo(()=>e&&w.createElement(Vle.Provider,{value:t},e),[e,t])}function MD(){let{matches:t}=w.useContext(Io),e=t[t.length-1];return e?e.params:{}}function xy(t,{relative:e}={}){let{matches:n}=w.useContext(Io),{pathname:r}=lc(),i=JSON.stringify(_D(n));return w.useMemo(()=>wD(t,JSON.parse(i),r,e==="path"),[t,i,r,e])}function Wle(t,e){return Lq(t,e)}function Lq(t,e,n,r,i){Br(Kg(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:a}=w.useContext(eo),{matches:o}=w.useContext(Io),l=o[o.length-1],c=l?l.params:{},u=l?l.pathname:"/",d=l?l.pathnameBase:"/",f=l&&l.route;{let S=f&&f.path||"";Fq(u,!f||S.endsWith("*")||S.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${u}" (under <Route path="${S}">) 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="${S}"> to <Route path="${S==="/"?"*":`${S}/*`}">.`)}let m=lc(),p;if(e){let S=typeof e=="string"?Wg(e):e;Br(d==="/"||S.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 "${S.pathname}" was given in the \`location\` prop.`),p=S}else p=m;let b=p.pathname||"/",v=b;if(d!=="/"){let S=d.replace(/^\//,"").split("/");v="/"+b.replace(/^\//,"").split("/").slice(S.length).join("/")}let x=Nq(t,{pathname:v});Ro(f||x!=null,`No routes matched location "${p.pathname}${p.search}${p.hash}" `),Ro(x==null||x[x.length-1].route.element!==void 0||x[x.length-1].route.Component!==void 0||x[x.length-1].route.lazy!==void 0,`Matched leaf route at location "${p.pathname}${p.search}${p.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let y=Zle(x&&x.map(S=>Object.assign({},S,{params:Object.assign({},c,S.params),pathname:nu([d,a.encodeLocation?a.encodeLocation(S.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:S.pathname]),pathnameBase:S.pathnameBase==="/"?d:nu([d,a.encodeLocation?a.encodeLocation(S.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:S.pathnameBase])})),o,n,r,i);return e&&y?w.createElement(gy.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...p},navigationType:"POP"}},y):y}function qle(){let t=nce(),e=Ple(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=w.createElement(w.Fragment,null,w.createElement("p",null,"💿 Hey developer 👋"),w.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",w.createElement("code",{style:a},"ErrorBoundary")," or"," ",w.createElement("code",{style:a},"errorElement")," prop on your route.")),w.createElement(w.Fragment,null,w.createElement("h2",null,"Unexpected Application Error!"),w.createElement("h3",{style:{fontStyle:"italic"}},e),n?w.createElement("pre",{style:i},n):null,o)}var Kle=w.createElement(qle,null),Iq=class extends w.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(){let t=this.state.error;if(this.context&&typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){const n=Ble(t.digest);n&&(t=n)}let e=t!==void 0?w.createElement(Io.Provider,{value:this.props.routeContext},w.createElement(SD.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?w.createElement(Xle,{error:t},e):e}};Iq.contextType=Ole;var tT=new WeakMap;function Xle({children:t,error:e}){let{basename:n}=w.useContext(eo);if(typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){let r=zle(e.digest);if(r){let i=tT.get(e);if(i)throw i;let a=kq(r.location,n);if(Cq&&!tT.get(e))if(a.isExternal||r.reloadDocument)window.location.href=a.absoluteURL||a.to;else{const o=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(a.to,{replace:r.replace}));throw tT.set(e,o),o}return w.createElement("meta",{httpEquiv:"refresh",content:`0;url=${a.absoluteURL||a.to}`})}}return t}function Yle({routeContext:t,match:e,children:n}){let r=w.useContext(qg);return r&&r.static&&r.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=e.route.id),w.createElement(Io.Provider,{value:t},n)}function Zle(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);Br(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:m,errors:p}=n,b=f.route.loader&&!m.hasOwnProperty(f.route.id)&&(!p||p[f.route.id]===void 0);if(f.route.lazy||b){l=!0,c>=0?a=a.slice(0,c+1):a=[a[0]];break}}}let u=n&&r?(d,f)=>{r(d,{location:n.location,params:n.matches?.[0]?.params??{},unstable_pattern:Rle(n.matches),errorInfo:f})}:void 0;return a.reduceRight((d,f,m)=>{let p,b=!1,v=null,x=null;n&&(p=o&&f.route.id?o[f.route.id]:void 0,v=f.route.errorElement||Kle,l&&(c<0&&m===0?(Fq("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),b=!0,x=null):c===m&&(b=!0,x=f.route.hydrateFallbackElement||null)));let y=e.concat(a.slice(0,m+1)),S=()=>{let M;return p?M=v:b?M=x:f.route.Component?M=w.createElement(f.route.Component,null):f.route.element?M=f.route.element:M=d,w.createElement(Yle,{match:f,routeContext:{outlet:d,matches:y,isDataRoute:n!=null},children:M})};return n&&(f.route.ErrorBoundary||f.route.errorElement||m===0)?w.createElement(Iq,{location:n.location,revalidation:n.revalidation,component:v,error:p,children:S(),routeContext:{outlet:null,matches:y,isDataRoute:!0},onError:u}):S()},null)}function ED(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Qle(t){let e=w.useContext(qg);return Br(e,ED(t)),e}function Jle(t){let e=w.useContext(YM);return Br(e,ED(t)),e}function ece(t){let e=w.useContext(Io);return Br(e,ED(t)),e}function ND(t){let e=ece(t),n=e.matches[e.matches.length-1];return Br(n.route.id,`${t} can only be used on routes that contain a unique "id"`),n.route.id}function tce(){return ND("useRouteId")}function nce(){let t=w.useContext(SD),e=Jle("useRouteError"),n=ND("useRouteError");return t!==void 0?t:e.errors?.[n]}function rce(){let{router:t}=Qle("useNavigate"),e=ND("useNavigate"),n=w.useRef(!1);return Oq(()=>{n.current=!0}),w.useCallback(async(i,a={})=>{Ro(n.current,Dq),n.current&&(typeof i=="number"?await t.navigate(i):await t.navigate(i,{fromRouteId:e,...a}))},[t,e])}var jz={};function Fq(t,e,n){!e&&!jz[t]&&(jz[t]=!0,Ro(!1,n))}w.memo(ice);function ice({routes:t,future:e,state:n,onError:r}){return Lq(t,void 0,n,r,e)}function Aw({to:t,replace:e,state:n,relative:r}){Br(Kg(),"<Navigate> may be used only in the context of a <Router> component.");let{static:i}=w.useContext(eo);Ro(!i,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:a}=w.useContext(Io),{pathname:o}=lc(),l=pl(),c=wD(t,_D(a),o,r==="path"),u=JSON.stringify(c);return w.useEffect(()=>{l(JSON.parse(u),{replace:e,state:n,relative:r})},[l,u,r,e,n]),null}function ace(t){return Gle(t.context)}function Ki(t){Br(!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 sce({basename:t="/",children:e=null,location:n,navigationType:r="POP",navigator:i,static:a=!1,unstable_useTransitions:o}){Br(!Kg(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let l=t.replace(/^\/*/,"/"),c=w.useMemo(()=>({basename:l,navigator:i,static:a,unstable_useTransitions:o,future:{}}),[l,i,a,o]);typeof n=="string"&&(n=Wg(n));let{pathname:u="/",search:d="",hash:f="",state:m=null,key:p="default"}=n,b=w.useMemo(()=>{let v=uu(u,l);return v==null?null:{location:{pathname:v,search:d,hash:f,state:m,key:p},navigationType:r}},[l,u,d,f,m,p,r]);return Ro(b!=null,`<Router basename="${l}"> is not able to match the URL "${u}${d}${f}" because it does not start with the basename, so the <Router> won't render anything.`),b==null?null:w.createElement(eo.Provider,{value:c},w.createElement(gy.Provider,{children:e,value:b}))}function oce({children:t,location:e}){return Wle(rP(t),e)}function rP(t,e=[]){let n=[];return w.Children.forEach(t,(r,i)=>{if(!w.isValidElement(r))return;let a=[...e,i];if(r.type===w.Fragment){n.push.apply(n,rP(r.props.children,a));return}Br(r.type===Ki,`[${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>`),Br(!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=rP(r.props.children,a)),n.push(o)}),n}var X1="get",Y1="application/x-www-form-urlencoded";function ZM(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function lce(t){return ZM(t)&&t.tagName.toLowerCase()==="button"}function cce(t){return ZM(t)&&t.tagName.toLowerCase()==="form"}function uce(t){return ZM(t)&&t.tagName.toLowerCase()==="input"}function dce(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function hce(t,e){return t.button===0&&(!e||e==="_self")&&!dce(t)}function iP(t=""){return new URLSearchParams(typeof t=="string"||Array.isArray(t)||t instanceof URLSearchParams?t:Object.keys(t).reduce((e,n)=>{let r=t[n];return e.concat(Array.isArray(r)?r.map(i=>[n,i]):[[n,r]])},[]))}function fce(t,e){let n=iP(t);return e&&e.forEach((r,i)=>{n.has(i)||e.getAll(i).forEach(a=>{n.append(i,a)})}),n}var d_=null;function mce(){if(d_===null)try{new FormData(document.createElement("form"),0),d_=!1}catch{d_=!0}return d_}var pce=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function nT(t){return t!=null&&!pce.has(t)?(Ro(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Y1}"`),null):t}function gce(t,e){let n,r,i,a,o;if(cce(t)){let l=t.getAttribute("action");r=l?uu(l,e):null,n=t.getAttribute("method")||X1,i=nT(t.getAttribute("enctype"))||Y1,a=new FormData(t)}else if(lce(t)||uce(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?uu(c,e):null,n=t.getAttribute("formmethod")||l.getAttribute("method")||X1,i=nT(t.getAttribute("formenctype"))||nT(l.getAttribute("enctype"))||Y1,a=new FormData(l,t),!mce()){let{name:u,type:d,value:f}=t;if(d==="image"){let m=u?`${u}.`:"";a.append(`${m}x`,"0"),a.append(`${m}y`,"0")}else u&&a.append(u,f)}}else{if(ZM(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=X1,r=null,i=Y1,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 AD(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function xce(t,e,n,r){let i=typeof t=="string"?new URL(t,typeof window>"u"?"server://singlefetch/":window.location.origin):t;return n?i.pathname.endsWith("/")?i.pathname=`${i.pathname}_.${r}`:i.pathname=`${i.pathname}.${r}`:i.pathname==="/"?i.pathname=`_root.${r}`:e&&uu(i.pathname,e)==="/"?i.pathname=`${e.replace(/\/$/,"")}/_root.${r}`:i.pathname=`${i.pathname.replace(/\/$/,"")}.${r}`,i}async function bce(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 yce(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 vce(t,e,n){let r=await Promise.all(t.map(async i=>{let a=e.routes[i.route.id];if(a){let o=await bce(a,n);return o.links?o.links():[]}return[]}));return Mce(r.flat(1).filter(yce).filter(i=>i.rel==="stylesheet"||i.rel==="preload").map(i=>i.rel==="stylesheet"?{...i,rel:"prefetch",as:"style"}:{...i,rel:"prefetch"}))}function Pz(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 _ce(t,e,{includeHydrateFallback:n}={}){return wce(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 wce(t){return[...new Set(t)]}function Sce(t){let e={},n=Object.keys(t).sort();for(let r of n)e[r]=t[r];return e}function Mce(t,e){let n=new Set;return new Set(e),t.reduce((r,i)=>{let a=JSON.stringify(Sce(i));return n.has(a)||(n.add(a),r.push({key:a,link:i})),r},[])}function Uq(){let t=w.useContext(qg);return AD(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function Ece(){let t=w.useContext(YM);return AD(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var TD=w.createContext(void 0);TD.displayName="FrameworkContext";function zq(){let t=w.useContext(TD);return AD(t,"You must render this element inside a <HydratedRouter> element"),t}function Nce(t,e){let n=w.useContext(TD),[r,i]=w.useState(!1),[a,o]=w.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:u,onMouseLeave:d,onTouchStart:f}=e,m=w.useRef(null);w.useEffect(()=>{if(t==="render"&&o(!0),t==="viewport"){let v=y=>{y.forEach(S=>{o(S.isIntersecting)})},x=new IntersectionObserver(v,{threshold:.5});return m.current&&x.observe(m.current),()=>{x.disconnect()}}},[t]),w.useEffect(()=>{if(r){let v=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(v)}}},[r]);let p=()=>{i(!0)},b=()=>{i(!1),o(!1)};return n?t!=="intent"?[a,m,{}]:[a,m,{onFocus:sb(l,p),onBlur:sb(c,b),onMouseEnter:sb(u,p),onMouseLeave:sb(d,b),onTouchStart:sb(f,p)}]:[!1,m,{}]}function sb(t,e){return n=>{t&&t(n),n.defaultPrevented||e(n)}}function Ace({page:t,...e}){let{router:n}=Uq(),r=w.useMemo(()=>Nq(n.routes,t,n.basename),[n.routes,t,n.basename]);return r?w.createElement(Cce,{page:t,matches:r,...e}):null}function Tce(t){let{manifest:e,routeModules:n}=zq(),[r,i]=w.useState([]);return w.useEffect(()=>{let a=!1;return vce(t,e,n).then(o=>{a||i(o)}),()=>{a=!0}},[t,e,n]),r}function Cce({page:t,matches:e,...n}){let r=lc(),{future:i,manifest:a,routeModules:o}=zq(),{basename:l}=Uq(),{loaderData:c,matches:u}=Ece(),d=w.useMemo(()=>Pz(t,e,u,a,r,"data"),[t,e,u,a,r]),f=w.useMemo(()=>Pz(t,e,u,a,r,"assets"),[t,e,u,a,r]),m=w.useMemo(()=>{if(t===r.pathname+r.search+r.hash)return[];let v=new Set,x=!1;if(e.forEach(S=>{let M=a.routes[S.route.id];!M||!M.hasLoader||(!d.some(N=>N.route.id===S.route.id)&&S.route.id in c&&o[S.route.id]?.shouldRevalidate||M.hasClientLoader?x=!0:v.add(S.route.id))}),v.size===0)return[];let y=xce(t,l,i.unstable_trailingSlashAwareDataRequests,"data");return x&&v.size>0&&y.searchParams.set("_routes",e.filter(S=>v.has(S.route.id)).map(S=>S.route.id).join(",")),[y.pathname+y.search]},[l,i.unstable_trailingSlashAwareDataRequests,c,r,a,d,e,t,o]),p=w.useMemo(()=>_ce(f,a),[f,a]),b=Tce(f);return w.createElement(w.Fragment,null,m.map(v=>w.createElement("link",{key:v,rel:"prefetch",as:"fetch",href:v,...n})),p.map(v=>w.createElement("link",{key:v,rel:"modulepreload",href:v,...n})),b.map(({key:v,link:x})=>w.createElement("link",{key:v,nonce:n.nonce,...x,crossOrigin:x.crossOrigin??n.crossOrigin})))}function kce(...t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}var jce=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{jce&&(window.__reactRouterVersion="7.13.0")}catch{}function Pce({basename:t,children:e,unstable_useTransitions:n,window:r}){let i=w.useRef();i.current==null&&(i.current=lle({window:r,v5Compat:!0}));let a=i.current,[o,l]=w.useState({action:a.action,location:a.location}),c=w.useCallback(u=>{n===!1?l(u):w.startTransition(()=>l(u))},[n]);return w.useLayoutEffect(()=>a.listen(c),[a,c]),w.createElement(sce,{basename:t,children:e,location:o.location,navigationType:o.action,navigator:a,unstable_useTransitions:n})}var Bq=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,ps=w.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,unstable_defaultShouldRevalidate:m,...p},b){let{basename:v,unstable_useTransitions:x}=w.useContext(eo),y=typeof u=="string"&&Bq.test(u),S=kq(u,v);u=S.to;let M=$le(u,{relative:i}),[N,A,k]=Nce(r,p),C=Oce(u,{replace:o,state:l,target:c,preventScrollReset:d,relative:i,viewTransition:f,unstable_defaultShouldRevalidate:m,unstable_useTransitions:x});function D(R){e&&e(R),R.defaultPrevented||C(R)}let T=w.createElement("a",{...p,...k,href:S.absoluteURL||M,onClick:S.isExternal||a?e:D,ref:kce(b,A),target:c,"data-discover":!y&&n==="render"?"true":void 0});return N&&!y?w.createElement(w.Fragment,null,T,w.createElement(Ace,{page:M})):T});ps.displayName="Link";var Ob=w.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=xy(o,{relative:u.relative}),m=lc(),p=w.useContext(YM),{navigator:b,basename:v}=w.useContext(eo),x=p!=null&&zce(f)&&l===!0,y=b.encodeLocation?b.encodeLocation(f).pathname:f.pathname,S=m.pathname,M=p&&p.navigation&&p.navigation.location?p.navigation.location.pathname:null;n||(S=S.toLowerCase(),M=M?M.toLowerCase():null,y=y.toLowerCase()),M&&v&&(M=uu(M,v)||M);const N=y!=="/"&&y.endsWith("/")?y.length-1:y.length;let A=S===y||!i&&S.startsWith(y)&&S.charAt(N)==="/",k=M!=null&&(M===y||!i&&M.startsWith(y)&&M.charAt(y.length)==="/"),C={isActive:A,isPending:k,isTransitioning:x},D=A?e:void 0,T;typeof r=="function"?T=r(C):T=[r,A?"active":null,k?"pending":null,x?"transitioning":null].filter(Boolean).join(" ");let R=typeof a=="function"?a(C):a;return w.createElement(ps,{...u,"aria-current":D,className:T,ref:d,style:R,to:o,viewTransition:l},typeof c=="function"?c(C):c)});Ob.displayName="NavLink";var Rce=w.forwardRef(({discover:t="render",fetcherKey:e,navigate:n,reloadDocument:r,replace:i,state:a,method:o=X1,action:l,onSubmit:c,relative:u,preventScrollReset:d,viewTransition:f,unstable_defaultShouldRevalidate:m,...p},b)=>{let{unstable_useTransitions:v}=w.useContext(eo),x=Fce(),y=Uce(l,{relative:u}),S=o.toLowerCase()==="get"?"get":"post",M=typeof l=="string"&&Bq.test(l),N=A=>{if(c&&c(A),A.defaultPrevented)return;A.preventDefault();let k=A.nativeEvent.submitter,C=k?.getAttribute("formmethod")||o,D=()=>x(k||A.currentTarget,{fetcherKey:e,method:C,navigate:n,replace:i,state:a,relative:u,preventScrollReset:d,viewTransition:f,unstable_defaultShouldRevalidate:m});v&&n!==!1?w.startTransition(()=>D()):D()};return w.createElement("form",{ref:b,method:S,action:y,onSubmit:r?c:N,...p,"data-discover":!M&&t==="render"?"true":void 0})});Rce.displayName="Form";function Dce(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function $q(t){let e=w.useContext(qg);return Br(e,Dce(t)),e}function Oce(t,{target:e,replace:n,state:r,preventScrollReset:i,relative:a,viewTransition:o,unstable_defaultShouldRevalidate:l,unstable_useTransitions:c}={}){let u=pl(),d=lc(),f=xy(t,{relative:a});return w.useCallback(m=>{if(hce(m,e)){m.preventDefault();let p=n!==void 0?n:M0(d)===M0(f),b=()=>u(t,{replace:p,state:r,preventScrollReset:i,relative:a,viewTransition:o,unstable_defaultShouldRevalidate:l});c?w.startTransition(()=>b()):b()}},[d,u,f,n,r,e,t,i,a,o,l,c])}function Hq(t){Ro(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let e=w.useRef(iP(t)),n=w.useRef(!1),r=lc(),i=w.useMemo(()=>fce(r.search,n.current?null:e.current),[r.search]),a=pl(),o=w.useCallback((l,c)=>{const u=iP(typeof l=="function"?l(new URLSearchParams(i)):l);n.current=!0,a("?"+u,c)},[a,i]);return[i,o]}var Lce=0,Ice=()=>`__${String(++Lce)}__`;function Fce(){let{router:t}=$q("useSubmit"),{basename:e}=w.useContext(eo),n=tce(),r=t.fetch,i=t.navigate;return w.useCallback(async(a,o={})=>{let{action:l,method:c,encType:u,formData:d,body:f}=gce(a,e);if(o.navigate===!1){let m=o.fetcherKey||Ice();await r(m,n,o.action||l,{unstable_defaultShouldRevalidate:o.unstable_defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:d,body:f,formMethod:o.method||c,formEncType:o.encType||u,flushSync:o.flushSync})}else await i(o.action||l,{unstable_defaultShouldRevalidate:o.unstable_defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:d,body:f,formMethod:o.method||c,formEncType:o.encType||u,replace:o.replace,state:o.state,fromRouteId:n,flushSync:o.flushSync,viewTransition:o.viewTransition})},[r,i,e,n])}function Uce(t,{relative:e}={}){let{basename:n}=w.useContext(eo),r=w.useContext(Io);Br(r,"useFormAction must be used inside a RouteContext");let[i]=r.matches.slice(-1),a={...xy(t||".",{relative:e})},o=lc();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:nu([n,a.pathname])),M0(a)}function zce(t,{relative:e}={}){let n=w.useContext(Pq);Br(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=$q("useViewTransitionState"),i=xy(t,{relative:e});if(!n.isTransitioning)return!1;let a=uu(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=uu(n.nextLocation.pathname,r)||n.nextLocation.pathname;return Nw(i.pathname,o)!=null||Nw(i.pathname,a)!=null}var Yc=pq();const Bce=ml(Yc);var om=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(){}},$ce={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},Hce=class{#t=$ce;#e=!1;setTimeoutProvider(t){this.#t=t}setTimeout(t,e){return this.#t.setTimeout(t,e)}clearTimeout(t){this.#t.clearTimeout(t)}setInterval(t,e){return this.#t.setInterval(t,e)}clearInterval(t){this.#t.clearInterval(t)}},of=new Hce;function Vce(t){setTimeout(t,0)}var Of=typeof window>"u"||"Deno"in globalThis;function Ia(){}function Gce(t,e){return typeof t=="function"?t(e):t}function aP(t){return typeof t=="number"&&t>=0&&t!==1/0}function Vq(t,e){return Math.max(t+(e||0)-Date.now(),0)}function Od(t,e){return typeof t=="function"?t(e):t}function yo(t,e){return typeof t=="function"?t(e):t}function Rz(t,e){const{type:n="all",exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:l}=t;if(o){if(r){if(e.queryHash!==CD(o,e.options))return!1}else if(!E0(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 Dz(t,e){const{exact:n,status:r,predicate:i,mutationKey:a}=t;if(a){if(!e.options.mutationKey)return!1;if(n){if(Lf(e.options.mutationKey)!==Lf(a))return!1}else if(!E0(e.options.mutationKey,a))return!1}return!(r&&e.state.status!==r||i&&!i(e))}function CD(t,e){return(e?.queryKeyHashFn||Lf)(t)}function Lf(t){return JSON.stringify(t,(e,n)=>sP(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function E0(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(n=>E0(t[n],e[n])):!1}var Wce=Object.prototype.hasOwnProperty;function kD(t,e,n=0){if(t===e)return t;if(n>500)return e;const r=Oz(t)&&Oz(e);if(!r&&!(sP(t)&&sP(e)))return e;const a=(r?t:Object.keys(t)).length,o=r?e:Object.keys(e),l=o.length,c=r?new Array(l):{};let u=0;for(let d=0;d<l;d++){const f=r?d:o[d],m=t[f],p=e[f];if(m===p){c[f]=m,(r?d<a:Wce.call(t,f))&&u++;continue}if(m===null||p===null||typeof m!="object"||typeof p!="object"){c[f]=p;continue}const b=kD(m,p,n+1);c[f]=b,b===m&&u++}return a===l&&u===a?t:c}function N0(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 Oz(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function sP(t){if(!Lz(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!Lz(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function Lz(t){return Object.prototype.toString.call(t)==="[object Object]"}function qce(t){return new Promise(e=>{of.setTimeout(e,t)})}function oP(t,e,n){return typeof n.structuralSharing=="function"?n.structuralSharing(t,e):n.structuralSharing!==!1?kD(t,e):e}function Kce(t,e,n=0){const r=[...t,e];return n&&r.length>n?r.slice(1):r}function Xce(t,e,n=0){const r=[e,...t];return n&&r.length>n?r.slice(0,-1):r}var jD=Symbol();function Gq(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===jD?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function PD(t,e){return typeof t=="function"?t(...e):!!t}function Yce(t,e,n){let r=!1,i;return Object.defineProperty(t,"signal",{enumerable:!0,get:()=>(i??=e(),r||(r=!0,i.aborted?n():i.addEventListener("abort",n,{once:!0})),i)}),t}var Zce=class extends om{#t;#e;#n;constructor(){super(),this.#n=t=>{if(!Of&&window.addEventListener){const e=()=>t();return window.addEventListener("visibilitychange",e,!1),()=>{window.removeEventListener("visibilitychange",e)}}}}onSubscribe(){this.#e||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(t){this.#n=t,this.#e?.(),this.#e=t(e=>{typeof e=="boolean"?this.setFocused(e):this.onFocus()})}setFocused(t){this.#t!==t&&(this.#t=t,this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(e=>{e(t)})}isFocused(){return typeof this.#t=="boolean"?this.#t:globalThis.document?.visibilityState!=="hidden"}},RD=new Zce;function lP(){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 Qce=Vce;function Jce(){let t=[],e=0,n=l=>{l()},r=l=>{l()},i=Qce;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 ai=Jce(),eue=class extends om{#t=!0;#e;#n;constructor(){super(),this.#n=t=>{if(!Of&&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.#e||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(t){this.#n=t,this.#e?.(),this.#e=t(this.setOnline.bind(this))}setOnline(t){this.#t!==t&&(this.#t=t,this.listeners.forEach(n=>{n(t)}))}isOnline(){return this.#t}},Tw=new eue;function tue(t){return Math.min(1e3*2**t,3e4)}function Wq(t){return(t??"online")==="online"?Tw.isOnline():!0}var cP=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function qq(t){let e=!1,n=0,r;const i=lP(),a=()=>i.status!=="pending",o=v=>{if(!a()){const x=new cP(v);m(x),t.onCancel?.(x)}},l=()=>{e=!0},c=()=>{e=!1},u=()=>RD.isFocused()&&(t.networkMode==="always"||Tw.isOnline())&&t.canRun(),d=()=>Wq(t.networkMode)&&t.canRun(),f=v=>{a()||(r?.(),i.resolve(v))},m=v=>{a()||(r?.(),i.reject(v))},p=()=>new Promise(v=>{r=x=>{(a()||u())&&v(x)},t.onPause?.()}).then(()=>{r=void 0,a()||t.onContinue?.()}),b=()=>{if(a())return;let v;const x=n===0?t.initialPromise:void 0;try{v=x??t.fn()}catch(y){v=Promise.reject(y)}Promise.resolve(v).then(f).catch(y=>{if(a())return;const S=t.retry??(Of?0:3),M=t.retryDelay??tue,N=typeof M=="function"?M(n,y):M,A=S===!0||typeof S=="number"&&n<S||typeof S=="function"&&S(n,y);if(e||!A){m(y);return}n++,t.onFail?.(n,y),qce(N).then(()=>u()?void 0:p()).then(()=>{e?m(y):b()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:l,continueRetry:c,canStart:d,start:()=>(d()?b():p().then(b),i)}}var Kq=class{#t;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),aP(this.gcTime)&&(this.#t=of.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(Of?1/0:300*1e3))}clearGcTimeout(){this.#t&&(of.clearTimeout(this.#t),this.#t=void 0)}},nue=class extends Kq{#t;#e;#n;#i;#r;#a;#o;constructor(t){super(),this.#o=!1,this.#a=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.#t=Fz(this.options),this.state=t.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#r?.promise}setOptions(t){if(this.options={...this.#a,...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const e=Fz(this.options);e.data!==void 0&&(this.setState(Iz(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(t,e){const n=oP(this.state.data,t,this.options);return this.#s({data:n,type:"success",dataUpdatedAt:e?.updatedAt,manual:e?.manual}),n}setState(t,e){this.#s({type:"setState",state:t,setStateOptions:e})}cancel(t){const e=this.#r?.promise;return this.#r?.cancel(t),e?e.then(Ia).catch(Ia):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#t)}isActive(){return this.observers.some(t=>yo(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===jD||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>Od(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:!Vq(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.#s({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=Gq(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.#e=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==o.fetchOptions?.meta)&&this.#s({type:"fetch",meta:o.fetchOptions?.meta}),this.#r=qq({initialPromise:e?.initialPromise,fn:o.fetchFn,onCancel:l=>{l instanceof cP&&l.revert&&this.setState({...this.#e,fetchStatus:"idle"}),n.abort()},onFail:(l,c)=>{this.#s({type:"failed",failureCount:l,error:c})},onPause:()=>{this.#s({type:"pause"})},onContinue:()=>{this.#s({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 cP){if(l.silent)return this.#r.promise;if(l.revert){if(this.state.data===void 0)throw l;return this.state.data}}throw this.#s({type:"error",error:l}),this.#n.config.onError?.(l,this),this.#n.config.onSettled?.(this.state.data,l,this),l}finally{this.scheduleGc()}}#s(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,...Xq(n.data,this.options),fetchMeta:t.meta??null};case"success":const r={...n,...Iz(t.data,t.dataUpdatedAt),dataUpdateCount:n.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#e=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",isInvalidated:!0};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...t.state}}};this.state=e(this.state),ai.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:t})})}};function Xq(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Wq(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function Iz(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Fz(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 DD=class extends om{constructor(t,e){super(),this.options=e,this.#t=t,this.#s=null,this.#o=lP(),this.bindMethods(),this.setOptions(e)}#t;#e=void 0;#n=void 0;#i=void 0;#r;#a;#o;#s;#m;#d;#h;#c;#u;#l;#f=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#e.addObserver(this),Uz(this.#e,this.options)?this.#p():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return uP(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return uP(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#v(),this.#_(),this.#e.removeObserver(this)}setOptions(t){const e=this.options,n=this.#e;if(this.options=this.#t.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof yo(this.options.enabled,this.#e)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#w(),this.#e.setOptions(this.options),e._defaulted&&!N0(this.options,e)&&this.#t.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const r=this.hasListeners();r&&zz(this.#e,n,this.options,e)&&this.#p(),this.updateResult(),r&&(this.#e!==n||yo(this.options.enabled,this.#e)!==yo(e.enabled,this.#e)||Od(this.options.staleTime,this.#e)!==Od(e.staleTime,this.#e))&&this.#g();const i=this.#x();r&&(this.#e!==n||yo(this.options.enabled,this.#e)!==yo(e.enabled,this.#e)||i!==this.#l)&&this.#b(i)}getOptimisticResult(t){const e=this.#t.getQueryCache().build(this.#t,t),n=this.createResult(e,t);return iue(this,n)&&(this.#i=n,this.#a=this.options,this.#r=this.#e.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.#f.add(t)}getCurrentQuery(){return this.#e}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const e=this.#t.defaultQueryOptions(t),n=this.#t.getQueryCache().build(this.#t,e);return n.fetch().then(()=>this.createResult(n,e))}fetch(t){return this.#p({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#i))}#p(t){this.#w();let e=this.#e.fetch(this.options,t);return t?.throwOnError||(e=e.catch(Ia)),e}#g(){this.#v();const t=Od(this.options.staleTime,this.#e);if(Of||this.#i.isStale||!aP(t))return;const n=Vq(this.#i.dataUpdatedAt,t)+1;this.#c=of.setTimeout(()=>{this.#i.isStale||this.updateResult()},n)}#x(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#b(t){this.#_(),this.#l=t,!(Of||yo(this.options.enabled,this.#e)===!1||!aP(this.#l)||this.#l===0)&&(this.#u=of.setInterval(()=>{(this.options.refetchIntervalInBackground||RD.isFocused())&&this.#p()},this.#l))}#y(){this.#g(),this.#b(this.#x())}#v(){this.#c&&(of.clearTimeout(this.#c),this.#c=void 0)}#_(){this.#u&&(of.clearInterval(this.#u),this.#u=void 0)}createResult(t,e){const n=this.#e,r=this.options,i=this.#i,a=this.#r,o=this.#a,c=t!==n?t.state:this.#n,{state:u}=t;let d={...u},f=!1,m;if(e._optimisticResults){const D=this.hasListeners(),T=!D&&Uz(t,e),R=D&&zz(t,n,e,r);(T||R)&&(d={...d,...Xq(u.data,t.options)}),e._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:p,errorUpdatedAt:b,status:v}=d;m=d.data;let x=!1;if(e.placeholderData!==void 0&&m===void 0&&v==="pending"){let D;i?.isPlaceholderData&&e.placeholderData===o?.placeholderData?(D=i.data,x=!0):D=typeof e.placeholderData=="function"?e.placeholderData(this.#h?.state.data,this.#h):e.placeholderData,D!==void 0&&(v="success",m=oP(i?.data,D,e),f=!0)}if(e.select&&m!==void 0&&!x)if(i&&m===a?.data&&e.select===this.#m)m=this.#d;else try{this.#m=e.select,m=e.select(m),m=oP(i?.data,m,e),this.#d=m,this.#s=null}catch(D){this.#s=D}this.#s&&(p=this.#s,m=this.#d,b=Date.now(),v="error");const y=d.fetchStatus==="fetching",S=v==="pending",M=v==="error",N=S&&y,A=m!==void 0,C={status:v,fetchStatus:d.fetchStatus,isPending:S,isSuccess:v==="success",isError:M,isInitialLoading:N,isLoading:N,data:m,dataUpdatedAt:d.dataUpdatedAt,error:p,errorUpdatedAt:b,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>c.dataUpdateCount||d.errorUpdateCount>c.errorUpdateCount,isFetching:y,isRefetching:y&&!S,isLoadingError:M&&!A,isPaused:d.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:M&&A,isStale:OD(t,e),refetch:this.refetch,promise:this.#o,isEnabled:yo(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const D=C.data!==void 0,T=C.status==="error"&&!D,R=q=>{T?q.reject(C.error):D&&q.resolve(C.data)},U=()=>{const q=this.#o=C.promise=lP();R(q)},L=this.#o;switch(L.status){case"pending":t.queryHash===n.queryHash&&R(L);break;case"fulfilled":(T||C.data!==L.value)&&U();break;case"rejected":(!T||C.error!==L.reason)&&U();break}}return C}updateResult(){const t=this.#i,e=this.createResult(this.#e,this.options);if(this.#r=this.#e.state,this.#a=this.options,this.#r.data!==void 0&&(this.#h=this.#e),N0(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.#f.size)return!0;const a=new Set(i??this.#f);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.#t.getQueryCache().build(this.#t,this.options);if(t===this.#e)return;const e=this.#e;this.#e=t,this.#n=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#S(t){ai.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#i)}),this.#t.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function rue(t,e){return yo(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function Uz(t,e){return rue(t,e)||t.state.data!==void 0&&uP(t,e,e.refetchOnMount)}function uP(t,e,n){if(yo(e.enabled,t)!==!1&&Od(e.staleTime,t)!=="static"){const r=typeof n=="function"?n(t):n;return r==="always"||r!==!1&&OD(t,e)}return!1}function zz(t,e,n,r){return(t!==e||yo(r.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&OD(t,n)}function OD(t,e){return yo(e.enabled,t)!==!1&&t.isStaleByTime(Od(e.staleTime,t))}function iue(t,e){return!N0(t.getCurrentResult(),e)}function Bz(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=b=>{Yce(b,()=>e.signal,()=>d=!0)},m=Gq(e.options,e.fetchOptions),p=async(b,v,x)=>{if(d)return Promise.reject();if(v==null&&b.pages.length)return Promise.resolve(b);const S=(()=>{const k={client:e.client,queryKey:e.queryKey,pageParam:v,direction:x?"backward":"forward",meta:e.options.meta};return f(k),k})(),M=await m(S),{maxPages:N}=e.options,A=x?Xce:Kce;return{pages:A(b.pages,M,N),pageParams:A(b.pageParams,v,N)}};if(i&&a.length){const b=i==="backward",v=b?aue:$z,x={pages:a,pageParams:o},y=v(r,x);l=await p(x,y,b)}else{const b=t??a.length;do{const v=c===0?o[0]??r.initialPageParam:$z(r,l);if(c>0&&v==null)break;l=await p(l,v),c++}while(c<b)}return l};e.options.persister?e.fetchFn=()=>e.options.persister?.(u,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},n):e.fetchFn=u}}}function $z(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 aue(t,{pages:e,pageParams:n}){return e.length>0?t.getPreviousPageParam?.(e[0],e,n[0],n):void 0}var sue=class extends Kq{#t;#e;#n;#i;constructor(t){super(),this.#t=t.client,this.mutationId=t.mutationId,this.#n=t.mutationCache,this.#e=[],this.state=t.state||Yq(),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.#e.includes(t)||(this.#e.push(t),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){this.#e=this.#e.filter(e=>e!==t),this.scheduleGc(),this.#n.notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){this.#e.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.#t,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#i=qq({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}),this.#n.config.onMutate&&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{await this.#n.config.onError?.(a,t,this.state.context,this,n)}catch(o){Promise.reject(o)}try{await this.options.onError?.(a,t,this.state.context,n)}catch(o){Promise.reject(o)}try{await this.#n.config.onSettled?.(void 0,a,this.state.variables,this.state.context,this,n)}catch(o){Promise.reject(o)}try{await this.options.onSettled?.(void 0,a,t,this.state.context,n)}catch(o){Promise.reject(o)}throw this.#r({type:"error",error:a}),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),ai.batch(()=>{this.#e.forEach(n=>{n.onMutationUpdate(t)}),this.#n.notify({mutation:this,type:"updated",action:t})})}};function Yq(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var oue=class extends om{constructor(t={}){super(),this.config=t,this.#t=new Set,this.#e=new Map,this.#n=0}#t;#e;#n;build(t,e,n){const r=new sue({client:t,mutationCache:this,mutationId:++this.#n,options:t.defaultMutationOptions(e),state:n});return this.add(r),r}add(t){this.#t.add(t);const e=h_(t);if(typeof e=="string"){const n=this.#e.get(e);n?n.push(t):this.#e.set(e,[t])}this.notify({type:"added",mutation:t})}remove(t){if(this.#t.delete(t)){const e=h_(t);if(typeof e=="string"){const n=this.#e.get(e);if(n)if(n.length>1){const r=n.indexOf(t);r!==-1&&n.splice(r,1)}else n[0]===t&&this.#e.delete(e)}}this.notify({type:"removed",mutation:t})}canRun(t){const e=h_(t);if(typeof e=="string"){const r=this.#e.get(e)?.find(i=>i.state.status==="pending");return!r||r===t}else return!0}runNext(t){const e=h_(t);return typeof e=="string"?this.#e.get(e)?.find(r=>r!==t&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){ai.batch(()=>{this.#t.forEach(t=>{this.notify({type:"removed",mutation:t})}),this.#t.clear(),this.#e.clear()})}getAll(){return Array.from(this.#t)}find(t){const e={exact:!0,...t};return this.getAll().find(n=>Dz(e,n))}findAll(t={}){return this.getAll().filter(e=>Dz(t,e))}notify(t){ai.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(e=>e.state.isPaused);return ai.batch(()=>Promise.all(t.map(e=>e.continue().catch(Ia))))}};function h_(t){return t.options.scope?.id}var lue=class extends om{#t;#e=void 0;#n;#i;constructor(e,n){super(),this.#t=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.#t.defaultMutationOptions(e),N0(this.options,n)||this.#t.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),n?.mutationKey&&this.options.mutationKey&&Lf(n.mutationKey)!==Lf(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.#a(e)}getCurrentResult(){return this.#e}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#r(),this.#a()}mutate(e,n){return this.#i=n,this.#n?.removeObserver(this),this.#n=this.#t.getMutationCache().build(this.#t,this.options),this.#n.addObserver(this),this.#n.execute(e)}#r(){const e=this.#n?.state??Yq();this.#e={...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset}}#a(e){ai.batch(()=>{if(this.#i&&this.hasListeners()){const n=this.#e.variables,r=this.#e.context,i={client:this.#t,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type==="success"){try{this.#i.onSuccess?.(e.data,n,r,i)}catch(a){Promise.reject(a)}try{this.#i.onSettled?.(e.data,null,n,r,i)}catch(a){Promise.reject(a)}}else if(e?.type==="error"){try{this.#i.onError?.(e.error,n,r,i)}catch(a){Promise.reject(a)}try{this.#i.onSettled?.(void 0,e.error,n,r,i)}catch(a){Promise.reject(a)}}}this.listeners.forEach(n=>{n(this.#e)})})}};function Hz(t,e){const n=new Set(e);return t.filter(r=>!n.has(r))}function cue(t,e,n){const r=t.slice(0);return r[e]=n,r}var uue=class extends om{#t;#e;#n;#i;#r;#a;#o;#s;#m;#d=[];constructor(t,e,n){super(),this.#t=t,this.#i=n,this.#n=[],this.#r=[],this.#e=[],this.setQueries(e)}onSubscribe(){this.listeners.size===1&&this.#r.forEach(t=>{t.subscribe(e=>{this.#l(t,e)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#r.forEach(t=>{t.destroy()})}setQueries(t,e){this.#n=t,this.#i=e,ai.batch(()=>{const n=this.#r,r=this.#u(this.#n);r.forEach(d=>d.observer.setOptions(d.defaultedQueryOptions));const i=r.map(d=>d.observer),a=i.map(d=>d.getCurrentResult()),o=n.length!==i.length,l=i.some((d,f)=>d!==n[f]),c=o||l,u=c?!0:a.some((d,f)=>{const m=this.#e[f];return!m||!N0(d,m)});!c&&!u||(c&&(this.#d=r,this.#r=i),this.#e=a,this.hasListeners()&&(c&&(Hz(n,i).forEach(d=>{d.destroy()}),Hz(i,n).forEach(d=>{d.subscribe(f=>{this.#l(d,f)})})),this.#f()))})}getCurrentResult(){return this.#e}getQueries(){return this.#r.map(t=>t.getCurrentQuery())}getObservers(){return this.#r}getOptimisticResult(t,e){const n=this.#u(t),r=n.map(a=>a.observer.getOptimisticResult(a.defaultedQueryOptions)),i=n.map(a=>a.defaultedQueryOptions.queryHash);return[r,a=>this.#c(a??r,e,i),()=>this.#h(r,n)]}#h(t,e){return e.map((n,r)=>{const i=t[r];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,a=>{e.forEach(o=>{o.observer.trackProp(a)})})})}#c(t,e,n){if(e){const r=this.#m,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((a,o)=>a!==r[o]));return(!this.#a||this.#e!==this.#s||i||e!==this.#o)&&(this.#o=e,this.#s=this.#e,n!==void 0&&(this.#m=n),this.#a=kD(this.#a,e(t))),this.#a}return t}#u(t){const e=new Map;this.#r.forEach(r=>{const i=r.options.queryHash;if(!i)return;const a=e.get(i);a?a.push(r):e.set(i,[r])});const n=[];return t.forEach(r=>{const i=this.#t.defaultQueryOptions(r),o=e.get(i.queryHash)?.shift()??new DD(this.#t,i);n.push({defaultedQueryOptions:i,observer:o})}),n}#l(t,e){const n=this.#r.indexOf(t);n!==-1&&(this.#e=cue(this.#e,n,e),this.#f())}#f(){if(this.hasListeners()){const t=this.#a,e=this.#h(this.#e,this.#d),n=this.#c(e,this.#i?.combine);t!==n&&ai.batch(()=>{this.listeners.forEach(r=>{r(this.#e)})})}}},due=class extends om{constructor(t={}){super(),this.config=t,this.#t=new Map}#t;build(t,e,n){const r=e.queryKey,i=e.queryHash??CD(r,e);let a=this.get(i);return a||(a=new nue({client:t,queryKey:r,queryHash:i,options:t.defaultQueryOptions(e),state:n,defaultOptions:t.getQueryDefaults(r)}),this.add(a)),a}add(t){this.#t.has(t.queryHash)||(this.#t.set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const e=this.#t.get(t.queryHash);e&&(t.destroy(),e===t&&this.#t.delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){ai.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return this.#t.get(t)}getAll(){return[...this.#t.values()]}find(t){const e={exact:!0,...t};return this.getAll().find(n=>Rz(e,n))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(n=>Rz(t,n)):e}notify(t){ai.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){ai.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){ai.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},hue=class{#t;#e;#n;#i;#r;#a;#o;#s;constructor(t={}){this.#t=t.queryCache||new due,this.#e=t.mutationCache||new oue,this.#n=t.defaultOptions||{},this.#i=new Map,this.#r=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=RD.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#t.onFocus())}),this.#s=Tw.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#t.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(t){return this.#t.findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return this.#e.findAll({...t,status:"pending"}).length}getQueryData(t){const e=this.defaultQueryOptions({queryKey:t});return this.#t.get(e.queryHash)?.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),n=this.#t.build(this,e),r=n.state.data;return r===void 0?this.fetchQuery(t):(t.revalidateIfStale&&n.isStaleByTime(Od(e.staleTime,n))&&this.prefetchQuery(e),Promise.resolve(r))}getQueriesData(t){return this.#t.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.#t.get(r.queryHash)?.state.data,o=Gce(e,a);if(o!==void 0)return this.#t.build(this,r).setData(o,{...n,manual:!0})}setQueriesData(t,e,n){return ai.batch(()=>this.#t.findAll(t).map(({queryKey:r})=>[r,this.setQueryData(r,e,n)]))}getQueryState(t){const e=this.defaultQueryOptions({queryKey:t});return this.#t.get(e.queryHash)?.state}removeQueries(t){const e=this.#t;ai.batch(()=>{e.findAll(t).forEach(n=>{e.remove(n)})})}resetQueries(t,e){const n=this.#t;return ai.batch(()=>(n.findAll(t).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const n={revert:!0,...e},r=ai.batch(()=>this.#t.findAll(t).map(i=>i.cancel(n)));return Promise.all(r).then(Ia).catch(Ia)}invalidateQueries(t,e={}){return ai.batch(()=>(this.#t.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=ai.batch(()=>this.#t.findAll(t).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let a=i.fetch(void 0,n);return n.throwOnError||(a=a.catch(Ia)),i.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(Ia)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const n=this.#t.build(this,e);return n.isStaleByTime(Od(e.staleTime,n))?n.fetch(e):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(Ia).catch(Ia)}fetchInfiniteQuery(t){return t.behavior=Bz(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(Ia).catch(Ia)}ensureInfiniteQueryData(t){return t.behavior=Bz(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return Tw.isOnline()?this.#e.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#t}getMutationCache(){return this.#e}getDefaultOptions(){return this.#n}setDefaultOptions(t){this.#n=t}setQueryDefaults(t,e){this.#i.set(Lf(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#i.values()],n={};return e.forEach(r=>{E0(t,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(t,e){this.#r.set(Lf(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#r.values()],n={};return e.forEach(r=>{E0(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=CD(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===jD&&(e.enabled=!1),e}defaultMutationOptions(t){return t?._defaulted?t:{...this.#n.mutations,...t?.mutationKey&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){this.#t.clear(),this.#e.clear()}},Zq=w.createContext(void 0),ln=t=>{const e=w.useContext(Zq);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},fue=({client:t,children:e})=>(w.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),s.jsx(Zq.Provider,{value:t,children:e})),Qq=w.createContext(!1),Jq=()=>w.useContext(Qq);Qq.Provider;function mue(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var pue=w.createContext(mue()),eK=()=>w.useContext(pue),tK=(t,e,n)=>{const r=n?.state.error&&typeof t.throwOnError=="function"?PD(t.throwOnError,[n.state.error,n]):t.throwOnError;(t.suspense||t.experimental_prefetchInRender||r)&&(e.isReset()||(t.retryOnMount=!1))},nK=t=>{w.useEffect(()=>{t.clearReset()},[t])},rK=({result:t,errorResetBoundary:e,throwOnError:n,query:r,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(i&&t.data===void 0||PD(n,[t.error,r])),iK=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))}},aK=(t,e)=>t.isLoading&&t.isFetching&&!e,dP=(t,e)=>t?.suspense&&e.isPending,Cw=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function gue({queries:t,...e},n){const r=ln(),i=Jq(),a=eK(),o=w.useMemo(()=>t.map(v=>{const x=r.defaultQueryOptions(v);return x._optimisticResults=i?"isRestoring":"optimistic",x}),[t,r,i]);o.forEach(v=>{iK(v);const x=r.getQueryCache().get(v.queryHash);tK(v,a,x)}),nK(a);const[l]=w.useState(()=>new uue(r,o,e)),[c,u,d]=l.getOptimisticResult(o,e.combine),f=!i&&e.subscribed!==!1;w.useSyncExternalStore(w.useCallback(v=>f?l.subscribe(ai.batchCalls(v)):Ia,[l,f]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),w.useEffect(()=>{l.setQueries(o,e)},[o,e,l]);const p=c.some((v,x)=>dP(o[x],v))?c.flatMap((v,x)=>{const y=o[x];if(y){const S=new DD(r,y);if(dP(y,v))return Cw(y,S,a);aK(v,i)&&Cw(y,S,a)}return[]}):[];if(p.length>0)throw Promise.all(p);const b=c.find((v,x)=>{const y=o[x];return y&&rK({result:v,errorResetBoundary:a,throwOnError:y.throwOnError,query:r.getQueryCache().get(y.queryHash),suspense:y.suspense})});if(b?.error)throw b.error;return u(d())}function xue(t,e,n){const r=Jq(),i=eK(),a=ln(),o=a.defaultQueryOptions(t);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);const l=a.getQueryCache().get(o.queryHash);o._optimisticResults=r?"isRestoring":"optimistic",iK(o),tK(o,i,l),nK(i);const c=!a.getQueryCache().get(o.queryHash),[u]=w.useState(()=>new e(a,o)),d=u.getOptimisticResult(o),f=!r&&t.subscribed!==!1;if(w.useSyncExternalStore(w.useCallback(m=>{const p=f?u.subscribe(ai.batchCalls(m)):Ia;return u.updateResult(),p},[u,f]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),w.useEffect(()=>{u.setOptions(o)},[o,u]),dP(o,d))throw Cw(o,u,i);if(rK({result:d,errorResetBoundary:i,throwOnError:o.throwOnError,query:l,suspense:o.suspense}))throw d.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,d),o.experimental_prefetchInRender&&!Of&&aK(d,r)&&(c?Cw(o,u,i):l?.promise)?.catch(Ia).finally(()=>{u.updateResult()}),o.notifyOnChangeProps?d:u.trackResult(d)}function ft(t,e){return xue(t,DD)}function pt(t,e){const n=ln(),[r]=w.useState(()=>new lue(n,t));w.useEffect(()=>{r.setOptions(t)},[r,t]);const i=w.useSyncExternalStore(w.useCallback(o=>r.subscribe(ai.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=w.useCallback((o,l)=>{r.mutate(o,l).catch(Ia)},[r]);if(i.error&&PD(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}const sK=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim();const bue=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const yue=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase());const Vz=t=>{const e=yue(t);return e.charAt(0).toUpperCase()+e.slice(1)};var vue={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 _ue=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0;return!1};const wue=w.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:a,iconNode:o,...l},c)=>w.createElement("svg",{ref:c,...vue,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:sK("lucide",i),...!a&&!_ue(l)&&{"aria-hidden":"true"},...l},[...o.map(([u,d])=>w.createElement(u,d)),...Array.isArray(a)?a:[a]]));const qe=(t,e)=>{const n=w.forwardRef(({className:r,...i},a)=>w.createElement(wue,{ref:a,iconNode:e,className:sK(`lucide-${bue(Vz(t))}`,`lucide-${t}`,r),...i}));return n.displayName=Vz(t),n};const Sue=[["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"}]],Mue=qe("air-vent",Sue);const Eue=[["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"}]],Ja=qe("archive",Eue);const Nue=[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M11 4h10",key:"1w87gc"}],["path",{d:"M11 8h7",key:"djye34"}],["path",{d:"M11 12h4",key:"q8tih4"}]],Aue=qe("arrow-down-wide-narrow",Nue);const Tue=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],A0=qe("arrow-down",Tue);const Cue=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],oK=qe("arrow-left",Cue);const kue=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],hP=qe("arrow-right",kue);const jue=[["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"}]],lK=qe("arrow-up-down",jue);const Pue=[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M11 12h4",key:"q8tih4"}],["path",{d:"M11 16h7",key:"uosisv"}],["path",{d:"M11 20h10",key:"jvxblo"}]],Rue=qe("arrow-up-narrow-wide",Pue);const Due=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],hg=qe("arrow-up",Due);const Oue=[["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"}]],vf=qe("bell",Oue);const Lue=[["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"}]],Iue=qe("bold",Lue);const Fue=[["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"}]],Uue=qe("book",Fue);const zue=[["path",{d:"M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z",key:"oz39mx"}]],Bue=qe("bookmark",zue);const $ue=[["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"}]],Bs=qe("box",$ue);const Hue=[["path",{d:"M16 20V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16",key:"jecpp"}],["rect",{width:"20",height:"14",x:"2",y:"6",rx:"2",key:"i6l2r4"}]],cK=qe("briefcase",Hue);const Vue=[["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"}]],QM=qe("bug",Vue);const Gue=[["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"}]],Wue=qe("cable",Gue);const que=[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["line",{x1:"8",x2:"16",y1:"6",y2:"6",key:"x4nwl0"}],["line",{x1:"16",x2:"16",y1:"14",y2:"18",key:"wjye3r"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M8 18h.01",key:"lrp35t"}]],Kue=qe("calculator",que);const Xue=[["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"}]],Yue=qe("calendar-days",Xue);const Zue=[["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"}]],si=qe("calendar",Zue);const Que=[["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"}]],fg=qe("camera",Que);const Jue=[["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"}]],ede=qe("chart-column",Jue);const tde=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Es=qe("check",tde);const nde=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Oi=qe("chevron-down",nde);const rde=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],If=qe("chevron-left",rde);const ide=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Zs=qe("chevron-right",ide);const ade=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],du=qe("chevron-up",ade);const sde=[["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",sde);const ode=[["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"}]],rT=qe("circle-arrow-up",ode);const lde=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Hn=qe("circle-check-big",lde);const cde=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],JM=qe("circle-check",cde);const ude=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],dde=qe("circle-dot",ude);const hde=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],fde=qe("circle-stop",hde);const mde=[["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"}]],za=qe("circle-x",mde);const pde=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],fP=qe("circle",pde);const gde=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Jn=qe("clock",gde);const xde=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],eE=qe("cloud",xde);const bde=[["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"}]],yde=qe("code-xml",bde);const vde=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],uK=qe("code",vde);const _de=[["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"}]],wde=qe("coffee",_de);const Sde=[["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"}]],Mde=qe("cog",Sde);const Ede=[["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"}]],Nde=qe("compass",Ede);const Ade=[["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"}]],il=qe("copy",Ade);const Tde=[["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"}]],f_=qe("cpu",Tde);const Cde=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5v14a9 3 0 0 0 18 0V5",key:"aqi0yr"}]],kde=qe("cylinder",Cde);const jde=[["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"}]],mg=qe("database",jde);const Pde=[["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"}]],mP=qe("dollar-sign",Pde);const Rde=[["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"}]],$r=qe("download",Rde);const Dde=[["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"}]],LD=qe("droplet",Dde);const Ode=[["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"}]],ID=qe("droplets",Ode);const Lde=[["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"}]],Ld=qe("ellipsis-vertical",Lde);const Ide=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],iT=qe("equal",Ide);const Fde=[["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"}]],Gr=qe("external-link",Fde);const Ude=[["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"}]],tE=qe("eye-off",Ude);const zde=[["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"}]],Ff=qe("eye",zde);const Bde=[["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"}]],dK=qe("fan",Bde);const $de=[["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"}]],_f=qe("file-box",$de);const Hde=[["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"}]],kw=qe("file-code",Hde);const Vde=[["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"}]],Gde=qe("file-exclamation-point",Vde);const Wde=[["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"}]],jw=qe("file-spreadsheet",Wde);const qde=[["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"}]],Ya=qe("file-text",qde);const Kde=[["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"}]],nE=qe("file",Kde);const Xde=[["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"}]],Id=qe("film",Xde);const Yde=[["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"}]],Zde=qe("flame",Yde);const Qde=[["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"}]],Ea=qe("folder-kanban",Qde);const Jde=[["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"}]],al=qe("folder-open",Jde);const ehe=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["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"}]],the=qe("folder-plus",ehe);const nhe=[["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"}]],rhe=qe("folder-tree",nhe);const ihe=[["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"}]],hK=qe("folder",ihe);const ahe=[["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"}],["rect",{width:"10",height:"8",x:"7",y:"8",rx:"1",key:"vys8me"}]],she=qe("fullscreen",ahe);const ohe=[["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"}]],rE=qe("funnel",ohe);const lhe=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],iE=qe("gauge",lhe);const che=[["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"}]],uhe=qe("gift",che);const dhe=[["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"}]],Zp=qe("git-compare",dhe);const hhe=[["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"}]],Gz=qe("github",hhe);const fhe=[["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"}]],Fd=qe("globe",fhe);const mhe=[["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"}]],pg=qe("grip-vertical",mhe);const phe=[["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"}]],fK=qe("hand",phe);const ghe=[["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"}]],aE=qe("hard-drive",ghe);const xhe=[["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"}]],bhe=qe("hash",xhe);const yhe=[["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"}]],vhe=qe("headphones",yhe);const _he=[["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"}]],whe=qe("heart",_he);const She=[["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"}]],Pw=qe("history",She);const Mhe=[["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"}]],sE=qe("house",Mhe);const Ehe=[["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"}]],by=qe("image",Ehe);const Nhe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Zl=qe("info",Nhe);const Ahe=[["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"}]],The=qe("italic",Ahe);const Che=[["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"}]],lf=qe("key",Che);const khe=[["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"}]],pP=qe("keyboard",khe);const jhe=[["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"}]],sl=qe("layers",jhe);const Phe=[["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"}]],oE=qe("layout-grid",Phe);const Rhe=[["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"}]],Dhe=qe("link-2-off",Rhe);const Ohe=[["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"}]],Gl=qe("link-2",Ohe);const Lhe=[["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"}]],Xg=qe("link",Lhe);const Ihe=[["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"}]],mK=qe("list-ordered",Ihe);const Fhe=[["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"}]],gP=qe("list-todo",Fhe);const Uhe=[["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"}]],lE=qe("list",Uhe);const zhe=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],mt=qe("loader-circle",zhe);const Bhe=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]],Wz=qe("lock-open",Bhe);const $he=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],aT=qe("lock",$he);const Hhe=[["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"}]],qz=qe("log-in",Hhe);const Vhe=[["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"}]],xP=qe("log-out",Vhe);const Ghe=[["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"}]],Whe=qe("mail",Ghe);const qhe=[["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"}]],Khe=qe("map",qhe);const Xhe=[["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"}]],pK=qe("maximize-2",Xhe);const Yhe=[["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"}]],Zhe=qe("maximize",Yhe);const Qhe=[["path",{d:"M12 12v-2",key:"fwoke6"}],["path",{d:"M12 18v-2",key:"qj6yno"}],["path",{d:"M16 12v-2",key:"heuere"}],["path",{d:"M16 18v-2",key:"s1ct0w"}],["path",{d:"M2 11h1.5",key:"15p63e"}],["path",{d:"M20 18v-2",key:"12ehxp"}],["path",{d:"M20.5 11H22",key:"khsy7a"}],["path",{d:"M4 18v-2",key:"1c3oqr"}],["path",{d:"M8 12v-2",key:"1mwtfd"}],["path",{d:"M8 18v-2",key:"qcmpov"}],["rect",{x:"2",y:"6",width:"20",height:"10",rx:"2",key:"1qcswk"}]],Jhe=qe("memory-stick",Qhe);const efe=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],tfe=qe("menu",efe);const nfe=[["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"}]],gK=qe("minimize-2",nfe);const rfe=[["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"}]],xK=qe("minimize",rfe);const ife=[["path",{d:"M5 12h14",key:"1ays0h"}]],bP=qe("minus",ife);const afe=[["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"}]],sfe=qe("monitor",afe);const ofe=[["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"}]],Rw=qe("moon",ofe);const lfe=[["path",{d:"M18 8L22 12L18 16",key:"1r0oui"}],["path",{d:"M2 12H22",key:"1m8cig"}]],cfe=qe("move-right",lfe);const ufe=[["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"}]],yP=qe("music",ufe);const dfe=[["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"}]],Ql=qe("package",dfe);const hfe=[["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"}]],FD=qe("palette",hfe);const ffe=[["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"}]],UD=qe("pause",ffe);const mfe=[["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"}]],Uf=qe("pen-line",mfe);const pfe=[["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"}]],cE=qe("pen",pfe);const gfe=[["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"}]],Na=qe("pencil",gfe);const xfe=[["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"}]],bfe=qe("phone",xfe);const yfe=[["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"}]],ol=qe("play",yfe);const vfe=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]],Ws=qe("plug",vfe);const _fe=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],rr=qe("plus",_fe);const wfe=[["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"}]],uE=qe("power-off",wfe);const Sfe=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],wu=qe("power",Sfe);const Mfe=[["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"}]],Wr=qe("printer",Mfe);const Efe=[["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"}]],bK=qe("qr-code",Efe);const Nfe=[["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"}]],Ar=qe("refresh-cw",Nfe);const Afe=[["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"}]],lm=qe("rotate-ccw",Afe);const Tfe=[["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"}]],Cfe=qe("ruler",Tfe);const kfe=[["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"}]],bs=qe("save",kfe);const jfe=[["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"}]],Dw=qe("scan-search",jfe);const Pfe=[["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"}]],Rfe=qe("scissors",Pfe);const Dfe=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Sa=qe("search",Dfe);const Ofe=[["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"}]],zD=qe("send",Ofe);const Lfe=[["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"}]],Kh=qe("server",Lfe);const Ife=[["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"}]],Kd=qe("settings-2",Ife);const Ffe=[["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"}]],dE=qe("settings",Ffe);const Ufe=[["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"}]],vP=qe("shield",Ufe);const zfe=[["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"}]],yK=qe("shopping-cart",zfe);const Bfe=[["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"}]],$fe=qe("signal",Bfe);const Hfe=[["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"}]],Vfe=qe("skip-back",Hfe);const Gfe=[["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"}]],Ow=qe("skip-forward",Gfe);const Wfe=[["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"}]],Kz=qe("sliders-vertical",Wfe);const qfe=[["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"}]],T0=qe("sparkles",qfe);const Kfe=[["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"}]],ll=qe("square-check-big",Kfe);const Xfe=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}]],Yfe=qe("square-minus",Xfe);const Zfe=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],cl=qe("square",Zfe);const Qfe=[["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"}]],zf=qe("star",Qfe);const Jfe=[["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"}]],vK=qe("sticky-note",Jfe);const eme=[["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"}]],Xz=qe("sun",eme);const tme=[["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"}]],gg=qe("tag",tme);const nme=[["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"}]],_K=qe("target",nme);const rme=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],wK=qe("terminal",rme);const ime=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],ame=qe("text-align-center",ime);const sme=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],ome=qe("text-align-end",sme);const lme=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],cme=qe("text-align-start",lme);const ume=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],hE=qe("thermometer",ume);const dme=[["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"}]],Ad=qe("timer",dme);const hme=[["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"}]],hn=qe("trash-2",hme);const fme=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],SK=qe("trending-down",fme);const mme=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],MK=qe("trending-up",mme);const pme=[["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"}]],Tn=qe("triangle-alert",pme);const gme=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],xme=qe("underline",gme);const bme=[["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"}]],BD=qe("unlink",bme);const yme=[["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"}]],fi=qe("upload",yme);const vme=[["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"}]],_P=qe("user",vme);const _me=[["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"}]],cf=qe("users",_me);const wme=[["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"}]],$D=qe("video",wme);const Sme=[["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"}]],Mme=qe("volume-2",Sme);const Eme=[["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"}]],Nme=qe("volume-x",Eme);const Ame=[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]],Tme=qe("wand-sparkles",Ame);const Cme=[["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"}]],Yg=qe("wifi-off",Cme);const kme=[["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"}]],Qp=qe("wifi",kme);const jme=[["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"}]],EK=qe("wind",jme);const Pme=[["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"}]],Xd=qe("wrench",Pme);const Rme=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Gt=qe("x",Rme);const Dme=[["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"}]],Bf=qe("zap",Dme);const Ome=[["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"}]],HD=qe("zoom-in",Ome);const Lme=[["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"}]],VD=qe("zoom-out",Lme),xn="/api/v1";let Lw=localStorage.getItem("auth_token");function Lb(t){Lw=t,t?localStorage.setItem("auth_token",t):localStorage.removeItem("auth_token")}function Yz(){return Lw}async function Te(t,e={}){const n={"Content-Type":"application/json",...e.headers};Lw&&(n.Authorization=`Bearer ${Lw}`);const r=await fetch(`${xn}${t}`,{...e,cache:"no-store",headers:n});if(!r.ok){r.status===401&&Lb(null);const a=(await r.json().catch(()=>({}))).detail,o=typeof a=="string"?a:a?JSON.stringify(a):`HTTP ${r.status}`;throw new Error(o)}return await r.json()}const me={getAuthStatus:()=>Te("/auth/status"),setupAuth:t=>Te("/auth/setup",{method:"POST",body:JSON.stringify(t)}),login:t=>Te("/auth/login",{method:"POST",body:JSON.stringify(t)}),logout:()=>Te("/auth/logout",{method:"POST"}),getCurrentUser:()=>Te("/auth/me"),disableAuth:()=>Te("/auth/disable",{method:"POST"}),getUsers:()=>Te("/users/"),getUser:t=>Te(`/users/${t}`),createUser:t=>Te("/users/",{method:"POST",body:JSON.stringify(t)}),updateUser:(t,e)=>Te(`/users/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteUser:t=>Te(`/users/${t}`,{method:"DELETE"}),getPrinters:()=>Te("/printers/"),getPrinter:t=>Te(`/printers/${t}`),createPrinter:t=>Te("/printers/",{method:"POST",body:JSON.stringify(t)}),updatePrinter:(t,e)=>Te(`/printers/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deletePrinter:(t,e=!0)=>Te(`/printers/${t}?delete_archives=${e}`,{method:"DELETE"}),getPrinterStatus:t=>Te(`/printers/${t}/status`),refreshPrinterStatus:t=>Te(`/printers/${t}/refresh-status`,{method:"POST"}),connectPrinter:t=>Te(`/printers/${t}/connect`,{method:"POST"}),disconnectPrinter:t=>Te(`/printers/${t}/disconnect`,{method:"POST"}),testExternalCamera:(t,e,n)=>Te(`/printers/${t}/camera/external/test?url=${encodeURIComponent(e)}&camera_type=${encodeURIComponent(n)}`,{method:"POST"}),stopPrint:t=>Te(`/printers/${t}/print/stop`,{method:"POST"}),pausePrint:t=>Te(`/printers/${t}/print/pause`,{method:"POST"}),resumePrint:t=>Te(`/printers/${t}/print/resume`,{method:"POST"}),setChamberLight:(t,e)=>Te(`/printers/${t}/chamber-light?on=${e}`,{method:"POST"}),getPrintableObjects:t=>Te(`/printers/${t}/print/objects`),skipObjects:(t,e)=>Te(`/printers/${t}/print/skip-objects`,{method:"POST",body:JSON.stringify(e)}),refreshAmsSlot:(t,e,n)=>Te(`/printers/${t}/ams/${e}/slot/${n}/refresh`,{method:"POST"}),enableMQTTLogging:t=>Te(`/printers/${t}/logging/enable`,{method:"POST"}),disableMQTTLogging:t=>Te(`/printers/${t}/logging/disable`,{method:"POST"}),getMQTTLogs:t=>Te(`/printers/${t}/logging`),clearMQTTLogs:t=>Te(`/printers/${t}/logging`,{method:"DELETE"}),getPrinterFiles:(t,e="/")=>Te(`/printers/${t}/files?path=${encodeURIComponent(e)}`),getPrinterFileDownloadUrl:(t,e)=>`${xn}/printers/${t}/files/download?path=${encodeURIComponent(e)}`,downloadPrinterFilesAsZip:async(t,e)=>{const n=await fetch(`${xn}/printers/${t}/files/download-zip`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paths:e})});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.detail||`HTTP ${n.status}`)}return n.blob()},deletePrinterFile:(t,e)=>Te(`/printers/${t}/files?path=${encodeURIComponent(e)}`,{method:"DELETE"}),getPrinterStorage:t=>Te(`/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)),Te(`/archives/?${i}`)},getArchive:t=>Te(`/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)),Te(`/archives/search?${n}`)},rebuildSearchIndex:()=>Te("/archives/search/rebuild-index",{method:"POST"}),updateArchive:(t,e)=>Te(`/archives/${t}`,{method:"PATCH",body:JSON.stringify(e)}),toggleFavorite:t=>Te(`/archives/${t}/favorite`,{method:"POST"}),deleteArchive:t=>Te(`/archives/${t}`,{method:"DELETE"}),getArchiveStats:()=>Te("/archives/stats"),recalculateCosts:()=>Te("/archives/recalculate-costs",{method:"POST"}),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)),Te(`/archives/analysis/failures?${e}`)},compareArchives:t=>Te(`/archives/compare?archive_ids=${t.join(",")}`),findSimilarArchives:(t,e=10)=>Te(`/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(`${xn}/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(`${xn}/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=>Te(`/archives/${t}/duplicates`),backfillContentHashes:()=>Te("/archives/backfill-hashes",{method:"POST"}),getArchiveThumbnail:t=>`${xn}/archives/${t}/thumbnail?v=${Date.now()}`,getArchiveDownload:t=>`${xn}/archives/${t}/download`,getArchiveGcode:t=>`${xn}/archives/${t}/gcode`,getArchivePlatePreview:t=>`${xn}/archives/${t}/plate-preview`,getArchiveTimelapse:t=>`${xn}/archives/${t}/timelapse?v=${Date.now()}`,scanArchiveTimelapse:t=>Te(`/archives/${t}/timelapse/scan`,{method:"POST"}),selectArchiveTimelapse:(t,e)=>Te(`/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(`${xn}/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=>Te(`/archives/${t}/timelapse/info`),getTimelapseThumbnails:(t,e=10)=>Te(`/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(`${xn}/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)=>`${xn}/archives/${t}/photos/${encodeURIComponent(e)}`,uploadArchivePhoto:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${xn}/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)=>Te(`/archives/${t}/photos/${encodeURIComponent(e)}`,{method:"DELETE"}),getSource3mfDownloadUrl:t=>`${xn}/archives/${t}/source`,getSource3mfForSlicer:(t,e)=>`${xn}/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(`${xn}/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=>Te(`/archives/${t}/source`,{method:"DELETE"}),getF3dDownloadUrl:t=>`${xn}/archives/${t}/f3d`,uploadF3d:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${xn}/archives/${t}/f3d`,{method:"POST",body:n});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},deleteF3d:t=>Te(`/archives/${t}/f3d`,{method:"DELETE"}),getArchiveQRCodeUrl:(t,e=200)=>`${xn}/archives/${t}/qrcode?size=${e}`,getArchiveCapabilities:t=>Te(`/archives/${t}/capabilities`),getArchiveProjectPage:t=>Te(`/archives/${t}/project-page`),updateArchiveProjectPage:(t,e)=>Te(`/archives/${t}/project-page`,{method:"PATCH",body:JSON.stringify(e)}),getArchiveProjectImageUrl:(t,e)=>`${xn}/archives/${t}/project-image/${encodeURIComponent(e)}`,getArchiveForSlicer:(t,e)=>`${xn}/archives/${t}/file/${encodeURIComponent(e.endsWith(".3mf")?e:e+".3mf")}`,getArchivePlates:t=>Te(`/archives/${t}/plates`),getArchiveFilamentRequirements:(t,e)=>Te(`/archives/${t}/filament-requirements${e!==void 0?`?plate_id=${e}`:""}`),reprintArchive:(t,e,n)=>Te(`/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?`${xn}/archives/upload?printer_id=${e}`:`${xn}/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?`${xn}/archives/upload-bulk?printer_id=${e}`:`${xn}/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:()=>Te("/settings/"),updateSettings:t=>Te("/settings/",{method:"PUT",body:JSON.stringify(t)}),getMQTTStatus:()=>Te("/settings/mqtt/status"),resetSettings:()=>Te("/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.pending_uploads!==void 0&&e.set("include_pending_uploads",String(t.pending_uploads)),t.access_codes!==void 0&&e.set("include_access_codes",String(t.access_codes)),t.api_keys!==void 0&&e.set("include_api_keys",String(t.api_keys)));const n=`${xn}/settings/backup${e.toString()?"?"+e.toString():""}`,r=await fetch(n);if(!r.ok){const l=await r.text();throw new Error(l||`Backup failed with status ${r.status}`)}const 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=`${xn}/settings/restore${e?"?overwrite=true":""}`;return(await fetch(r,{method:"POST",body:n})).json()},checkFfmpeg:()=>Te("/settings/check-ffmpeg"),getCloudStatus:()=>Te("/cloud/status"),cloudLogin:(t,e,n="global")=>Te("/cloud/login",{method:"POST",body:JSON.stringify({email:t,password:e,region:n})}),cloudVerify:(t,e)=>Te("/cloud/verify",{method:"POST",body:JSON.stringify({email:t,code:e})}),cloudSetToken:t=>Te("/cloud/token",{method:"POST",body:JSON.stringify({access_token:t})}),cloudLogout:()=>Te("/cloud/logout",{method:"POST"}),getCloudSettings:(t="02.04.00.70")=>Te(`/cloud/settings?version=${t}`),getCloudSettingDetail:t=>Te(`/cloud/settings/${t}`),createCloudSetting:t=>Te("/cloud/settings",{method:"POST",body:JSON.stringify(t)}),updateCloudSetting:(t,e)=>Te(`/cloud/settings/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteCloudSetting:t=>Te(`/cloud/settings/${t}`,{method:"DELETE"}),getCloudDevices:()=>Te("/cloud/devices"),getCloudFields:t=>Te(`/cloud/fields/${t}`),getAllCloudFields:()=>Te("/cloud/fields"),getFilamentInfo:t=>Te("/cloud/filament-info",{method:"POST",body:JSON.stringify(t)}),getSmartPlugs:()=>Te("/smart-plugs/"),getSmartPlug:t=>Te(`/smart-plugs/${t}`),getSmartPlugByPrinter:t=>Te(`/smart-plugs/by-printer/${t}`),createSmartPlug:t=>Te("/smart-plugs/",{method:"POST",body:JSON.stringify(t)}),updateSmartPlug:(t,e)=>Te(`/smart-plugs/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteSmartPlug:t=>Te(`/smart-plugs/${t}`,{method:"DELETE"}),controlSmartPlug:(t,e)=>Te(`/smart-plugs/${t}/control`,{method:"POST",body:JSON.stringify({action:e})}),getSmartPlugStatus:t=>Te(`/smart-plugs/${t}/status`),testSmartPlugConnection:(t,e,n)=>Te("/smart-plugs/test-connection",{method:"POST",body:JSON.stringify({ip_address:t,username:e,password:n})}),startTasmotaScan:()=>fetch(`${xn}/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:()=>Te("/smart-plugs/discover/status"),stopTasmotaScan:()=>fetch(`${xn}/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:()=>Te("/smart-plugs/discover/devices"),testHAConnection:(t,e)=>Te("/smart-plugs/ha/test-connection",{method:"POST",body:JSON.stringify({url:t,token:e})}),getHAEntities:t=>{const e=t?`?search=${encodeURIComponent(t)}`:"";return Te(`/smart-plugs/ha/entities${e}`)},getHASensorEntities:()=>Te("/smart-plugs/ha/sensors"),getQueue:(t,e)=>{const n=new URLSearchParams;return t&&n.set("printer_id",String(t)),e&&n.set("status",e),Te(`/queue/?${n}`)},getQueueItem:t=>Te(`/queue/${t}`),addToQueue:t=>Te("/queue/",{method:"POST",body:JSON.stringify(t)}),updateQueueItem:(t,e)=>Te(`/queue/${t}`,{method:"PATCH",body:JSON.stringify(e)}),removeFromQueue:t=>Te(`/queue/${t}`,{method:"DELETE"}),reorderQueue:t=>Te("/queue/reorder",{method:"POST",body:JSON.stringify({items:t})}),cancelQueueItem:t=>Te(`/queue/${t}/cancel`,{method:"POST"}),stopQueueItem:t=>Te(`/queue/${t}/stop`,{method:"POST"}),startQueueItem:t=>Te(`/queue/${t}/start`,{method:"POST"}),getKProfiles:(t,e="0.4")=>Te(`/printers/${t}/kprofiles/?nozzle_diameter=${e}`),setKProfile:(t,e)=>Te(`/printers/${t}/kprofiles/`,{method:"POST",body:JSON.stringify(e)}),deleteKProfile:(t,e)=>Te(`/printers/${t}/kprofiles/`,{method:"DELETE",body:JSON.stringify(e)}),setKProfilesBatch:(t,e)=>Te(`/printers/${t}/kprofiles/batch`,{method:"POST",body:JSON.stringify(e)}),getKProfileNotes:t=>Te(`/printers/${t}/kprofiles/notes`),setKProfileNote:(t,e,n)=>Te(`/printers/${t}/kprofiles/notes`,{method:"PUT",body:JSON.stringify({setting_id:e,note:n})}),deleteKProfileNote:(t,e)=>Te(`/printers/${t}/kprofiles/notes/${encodeURIComponent(e)}`,{method:"DELETE"}),getSlotPresets:t=>Te(`/printers/${t}/slot-presets`),getSlotPreset:(t,e,n)=>Te(`/printers/${t}/slot-presets/${e}/${n}`),saveSlotPreset:(t,e,n,r,i)=>Te(`/printers/${t}/slot-presets/${e}/${n}?preset_id=${encodeURIComponent(r)}&preset_name=${encodeURIComponent(i)}`,{method:"PUT"}),deleteSlotPreset:(t,e,n)=>Te(`/printers/${t}/slot-presets/${e}/${n}`,{method:"DELETE"}),configureAmsSlot:(t,e,n,r)=>{const i=new URLSearchParams({tray_info_idx:r.tray_info_idx,tray_type:r.tray_type,tray_sub_brands:r.tray_sub_brands,tray_color:r.tray_color,nozzle_temp_min:r.nozzle_temp_min.toString(),nozzle_temp_max:r.nozzle_temp_max.toString(),cali_idx:r.cali_idx.toString(),nozzle_diameter:r.nozzle_diameter});return r.setting_id&&i.set("setting_id",r.setting_id),r.kprofile_filament_id&&i.set("kprofile_filament_id",r.kprofile_filament_id),r.kprofile_setting_id&&i.set("kprofile_setting_id",r.kprofile_setting_id),r.k_value!==void 0&&r.k_value>0&&i.set("k_value",r.k_value.toString()),Te(`/printers/${t}/slots/${e}/${n}/configure?${i}`,{method:"POST"})},resetAmsSlot:(t,e,n)=>Te(`/printers/${t}/ams/${e}/tray/${n}/reset`,{method:"POST"}),listFilaments:()=>Te("/filaments/"),getFilament:t=>Te(`/filaments/${t}`),getFilamentsByType:t=>Te(`/filaments/by-type/${t}`),getNotificationProviders:()=>Te("/notifications/"),getNotificationProvider:t=>Te(`/notifications/${t}`),createNotificationProvider:t=>Te("/notifications/",{method:"POST",body:JSON.stringify(t)}),updateNotificationProvider:(t,e)=>Te(`/notifications/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteNotificationProvider:t=>Te(`/notifications/${t}`,{method:"DELETE"}),testNotificationProvider:t=>Te(`/notifications/${t}/test`,{method:"POST"}),testNotificationConfig:t=>Te("/notifications/test-config",{method:"POST",body:JSON.stringify(t)}),testAllNotificationProviders:()=>Te("/notifications/test-all",{method:"POST"}),getNotificationTemplates:()=>Te("/notification-templates"),getNotificationTemplate:t=>Te(`/notification-templates/${t}`),updateNotificationTemplate:(t,e)=>Te(`/notification-templates/${t}`,{method:"PUT",body:JSON.stringify(e)}),resetNotificationTemplate:t=>Te(`/notification-templates/${t}/reset`,{method:"POST"}),getTemplateVariables:()=>Te("/notification-templates/variables"),previewTemplate:t=>Te("/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)),Te(`/notifications/logs?${e}`)},getNotificationLogStats:(t=7)=>Te(`/notifications/logs/stats?days=${t}`),clearNotificationLogs:(t=30)=>Te(`/notifications/logs?older_than_days=${t}`,{method:"DELETE"}),getSpoolmanStatus:()=>Te("/spoolman/status"),connectSpoolman:()=>Te("/spoolman/connect",{method:"POST"}),disconnectSpoolman:()=>Te("/spoolman/disconnect",{method:"POST"}),syncPrinterAms:t=>Te(`/spoolman/sync/${t}`,{method:"POST"}),syncAllPrintersAms:()=>Te("/spoolman/sync-all",{method:"POST"}),getSpoolmanSpools:()=>Te("/spoolman/spools"),getSpoolmanFilaments:()=>Te("/spoolman/filaments"),getUnlinkedSpools:()=>Te("/spoolman/spools/unlinked"),linkSpool:(t,e)=>Te(`/spoolman/spools/${t}/link`,{method:"POST",body:JSON.stringify({tray_uuid:e})}),getVersion:()=>Te("/updates/version"),checkForUpdates:()=>Te("/updates/check"),applyUpdate:()=>Te("/updates/apply",{method:"POST"}),getUpdateStatus:()=>Te("/updates/status"),getMaintenanceTypes:()=>Te("/maintenance/types"),createMaintenanceType:t=>Te("/maintenance/types",{method:"POST",body:JSON.stringify(t)}),updateMaintenanceType:(t,e)=>Te(`/maintenance/types/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteMaintenanceType:t=>Te(`/maintenance/types/${t}`,{method:"DELETE"}),getMaintenanceOverview:()=>Te("/maintenance/overview"),getPrinterMaintenance:t=>Te(`/maintenance/printers/${t}`),updateMaintenanceItem:(t,e)=>Te(`/maintenance/items/${t}`,{method:"PATCH",body:JSON.stringify(e)}),performMaintenance:(t,e)=>Te(`/maintenance/items/${t}/perform`,{method:"POST",body:JSON.stringify({notes:e})}),getMaintenanceHistory:t=>Te(`/maintenance/items/${t}/history`),getMaintenanceSummary:()=>Te("/maintenance/summary"),setPrinterHours:(t,e)=>Te(`/maintenance/printers/${t}/hours?total_hours=${e}`,{method:"PATCH"}),assignMaintenanceType:(t,e)=>Te(`/maintenance/printers/${t}/assign/${e}`,{method:"POST"}),removeMaintenanceItem:t=>Te(`/maintenance/items/${t}`,{method:"DELETE"}),getCameraStreamUrl:(t,e=10)=>`${xn}/printers/${t}/camera/stream?fps=${e}`,getCameraSnapshotUrl:t=>`${xn}/printers/${t}/camera/snapshot`,testCameraConnection:t=>Te(`/printers/${t}/camera/test`),checkPlateEmpty:(t,e)=>{const n=new URLSearchParams;return n.set("use_external",String(e?.useExternal??!1)),n.set("include_debug_image",String(e?.includeDebugImage??!1)),Te(`/printers/${t}/camera/check-plate?${n.toString()}`)},getPlateDetectionStatus:t=>Te(`/printers/${t}/camera/plate-detection/status`),calibratePlateDetection:(t,e)=>{const n=new URLSearchParams;return e?.label&&n.set("label",e.label),n.set("use_external",String(e?.useExternal??!1)),Te(`/printers/${t}/camera/plate-detection/calibrate?${n.toString()}`,{method:"POST"})},deletePlateCalibration:t=>Te(`/printers/${t}/camera/plate-detection/calibrate`,{method:"DELETE"}),getPlateReferences:t=>Te(`/printers/${t}/camera/plate-detection/references`),getPlateReferenceThumbnailUrl:(t,e)=>`${xn}/printers/${t}/camera/plate-detection/references/${e}/thumbnail`,updatePlateReferenceLabel:(t,e,n)=>{const r=new URLSearchParams;return r.set("label",n),Te(`/printers/${t}/camera/plate-detection/references/${e}?${r.toString()}`,{method:"PUT"})},deletePlateReference:(t,e)=>Te(`/printers/${t}/camera/plate-detection/references/${e}`,{method:"DELETE"}),getExternalLinks:()=>Te("/external-links/"),getExternalLink:t=>Te(`/external-links/${t}`),createExternalLink:t=>Te("/external-links/",{method:"POST",body:JSON.stringify(t)}),updateExternalLink:(t,e)=>Te(`/external-links/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteExternalLink:t=>Te(`/external-links/${t}`,{method:"DELETE"}),reorderExternalLinks:t=>Te("/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(`${xn}/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=>Te(`/external-links/${t}/icon`,{method:"DELETE"}),getExternalLinkIconUrl:t=>`${xn}/external-links/${t}/icon`,getProjects:t=>{const e=new URLSearchParams;return t&&e.set("status",t),Te(`/projects/?${e}`)},getProject:t=>Te(`/projects/${t}`),createProject:t=>Te("/projects/",{method:"POST",body:JSON.stringify(t)}),updateProject:(t,e)=>Te(`/projects/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteProject:t=>Te(`/projects/${t}`,{method:"DELETE"}),getProjectArchives:(t,e=100,n=0)=>Te(`/projects/${t}/archives?limit=${e}&offset=${n}`),addArchivesToProject:(t,e)=>Te(`/projects/${t}/add-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),removeArchivesFromProject:(t,e)=>Te(`/projects/${t}/remove-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),addQueueItemsToProject:(t,e)=>Te(`/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(`${xn}/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)=>`${xn}/projects/${t}/attachments/${encodeURIComponent(e)}`,deleteProjectAttachment:(t,e)=>Te(`/projects/${t}/attachments/${encodeURIComponent(e)}`,{method:"DELETE"}),getProjectBOM:t=>Te(`/projects/${t}/bom`),createBOMItem:(t,e)=>Te(`/projects/${t}/bom`,{method:"POST",body:JSON.stringify(e)}),updateBOMItem:(t,e,n)=>Te(`/projects/${t}/bom/${e}`,{method:"PATCH",body:JSON.stringify(n)}),deleteBOMItem:(t,e)=>Te(`/projects/${t}/bom/${e}`,{method:"DELETE"}),getTemplates:()=>Te("/projects/templates/"),createTemplateFromProject:t=>Te(`/projects/${t}/create-template`,{method:"POST"}),createProjectFromTemplate:(t,e)=>Te(`/projects/from-template/${t}${e?`?name=${encodeURIComponent(e)}`:""}`,{method:"POST"}),getProjectTimeline:(t,e=50)=>Te(`/projects/${t}/timeline?limit=${e}`),exportProjectJson:t=>Te(`/projects/${t}/export?format=json`),importProject:t=>Te("/projects/import",{method:"POST",body:JSON.stringify(t)}),getAPIKeys:()=>Te("/api-keys/"),createAPIKey:t=>Te("/api-keys/",{method:"POST",body:JSON.stringify(t)}),updateAPIKey:(t,e)=>Te(`/api-keys/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteAPIKey:t=>Te(`/api-keys/${t}`,{method:"DELETE"}),getAMSHistory:(t,e,n=24)=>Te(`/ams-history/${t}/${e}?hours=${n}`),getSystemInfo:()=>Te("/system/info"),getLibraryFolders:()=>Te("/library/folders"),createLibraryFolder:t=>Te("/library/folders",{method:"POST",body:JSON.stringify(t)}),updateLibraryFolder:(t,e)=>Te(`/library/folders/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteLibraryFolder:t=>Te(`/library/folders/${t}`,{method:"DELETE"}),getLibraryFoldersByProject:t=>Te(`/library/folders/by-project/${t}`),getLibraryFoldersByArchive:t=>Te(`/library/folders/by-archive/${t}`),getLibraryFiles:(t,e=!0)=>{const n=new URLSearchParams;return t!=null&&n.set("folder_id",String(t)),n.set("include_root",String(e)),Te(`/library/files?${n}`)},getLibraryFile:t=>Te(`/library/files/${t}`),uploadLibraryFile:async(t,e)=>{const n=new FormData;n.append("file",t);const r=e?`?folder_id=${e}`:"",i=await fetch(`${xn}/library/files${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()},extractZipFile:async(t,e,n=!0,r=!1)=>{const i=new FormData;i.append("file",t);const a=new URLSearchParams;e&&a.set("folder_id",String(e)),a.set("preserve_structure",String(n)),a.set("create_folder_from_zip",String(r));const o=await fetch(`${xn}/library/files/extract-zip?${a}`,{method:"POST",body:i});if(!o.ok){const l=await o.json().catch(()=>({}));throw new Error(l.detail||`HTTP ${o.status}`)}return o.json()},updateLibraryFile:(t,e)=>Te(`/library/files/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteLibraryFile:t=>Te(`/library/files/${t}`,{method:"DELETE"}),getLibraryFileDownloadUrl:t=>`${xn}/library/files/${t}/download`,getLibraryFileThumbnailUrl:t=>`${xn}/library/files/${t}/thumbnail`,getLibraryFileGcodeUrl:t=>`${xn}/library/files/${t}/gcode`,moveLibraryFiles:(t,e)=>Te("/library/files/move",{method:"POST",body:JSON.stringify({file_ids:t,folder_id:e})}),bulkDeleteLibrary:(t,e)=>Te("/library/bulk-delete",{method:"POST",body:JSON.stringify({file_ids:t,folder_ids:e})}),getLibraryStats:()=>Te("/library/stats"),addLibraryFilesToQueue:t=>Te("/library/files/add-to-queue",{method:"POST",body:JSON.stringify({file_ids:t})}),printLibraryFile:(t,e,n)=>Te(`/library/files/${t}/print?printer_id=${e}`,{method:"POST",body:n?JSON.stringify(n):void 0}),getLibraryFilePlates:t=>Te(`/library/files/${t}/plates`),getLibraryFileFilamentRequirements:(t,e)=>Te(`/library/files/${t}/filament-requirements${e!==void 0?`?plate_id=${e}`:""}`)},Ml={getInfo:()=>Te("/discovery/info"),getStatus:()=>Te("/discovery/status"),startDiscovery:(t=10)=>Te(`/discovery/start?duration=${t}`,{method:"POST"}),stopDiscovery:()=>Te("/discovery/stop",{method:"POST"}),getDiscoveredPrinters:()=>Te("/discovery/printers"),startSubnetScan:(t,e=1)=>Te("/discovery/scan",{method:"POST",body:JSON.stringify({subnet:t,timeout:e})}),getScanStatus:()=>Te("/discovery/scan/status"),stopSubnetScan:()=>Te("/discovery/scan/stop",{method:"POST"})},Z1={getSettings:()=>Te("/settings/virtual-printer"),getModels:()=>Te("/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),Te(`/settings/virtual-printer?${e.toString()}`,{method:"PUT"})}},Fp={list:()=>Te("/pending-uploads/"),getCount:()=>Te("/pending-uploads/count"),get:t=>Te(`/pending-uploads/${t}`),archive:(t,e)=>Te(`/pending-uploads/${t}/archive`,{method:"POST",body:JSON.stringify(e||{})}),discard:t=>Te(`/pending-uploads/${t}`,{method:"DELETE"}),archiveAll:()=>Te("/pending-uploads/archive-all",{method:"POST"}),discardAll:()=>Te("/pending-uploads/discard-all",{method:"DELETE"})},Q1={checkUpdates:()=>Te("/firmware/updates"),checkPrinterUpdate:t=>Te(`/firmware/updates/${t}`),prepareUpload:t=>Te(`/firmware/updates/${t}/prepare`),startUpload:t=>Te(`/firmware/updates/${t}/upload`,{method:"POST"}),getUploadStatus:t=>Te(`/firmware/updates/${t}/upload/status`)},Jp={getDebugLoggingState:()=>Te("/support/debug-logging"),setDebugLogging:t=>Te("/support/debug-logging",{method:"POST",body:JSON.stringify({enabled:t})}),downloadSupportBundle:async()=>{const t=await fetch(`${xn}/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)},getLogs:t=>{const e=new URLSearchParams;t?.limit&&e.set("limit",t.limit.toString()),t?.level&&e.set("level",t.level),t?.search&&e.set("search",t.search);const n=e.toString();return Te(`/support/logs${n?`?${n}`:""}`)},clearLogs:()=>Te("/support/logs",{method:"DELETE"})},NK=w.createContext(void 0);function Ime({children:t}){const[e,n]=w.useState(()=>{const C=localStorage.getItem("theme-mode"),D=localStorage.getItem("theme");return C||D||"dark"}),[r,i]=w.useState(()=>localStorage.getItem("dark-style")||"classic"),[a,o]=w.useState(()=>localStorage.getItem("dark-background")||"neutral"),[l,c]=w.useState(()=>localStorage.getItem("dark-accent")||"green"),[u,d]=w.useState(()=>localStorage.getItem("light-style")||"classic"),[f,m]=w.useState(()=>localStorage.getItem("light-background")||"neutral"),[p,b]=w.useState(()=>localStorage.getItem("light-accent")||"green");w.useEffect(()=>{me.getSettings().then(C=>{C.dark_style&&(i(C.dark_style),localStorage.setItem("dark-style",C.dark_style)),C.dark_background&&(o(C.dark_background),localStorage.setItem("dark-background",C.dark_background)),C.dark_accent&&(c(C.dark_accent),localStorage.setItem("dark-accent",C.dark_accent)),C.light_style&&(d(C.light_style),localStorage.setItem("light-style",C.light_style)),C.light_background&&(m(C.light_background),localStorage.setItem("light-background",C.light_background)),C.light_accent&&(b(C.light_accent),localStorage.setItem("light-accent",C.light_accent))}).catch(()=>{})},[]),w.useEffect(()=>{const C=document.documentElement;C.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"?(C.classList.add("dark"),C.classList.add(`style-${r}`),C.classList.add(`bg-${a}`),C.classList.add(`accent-${l}`)):(C.classList.add(`style-${u}`),C.classList.add(`bg-${f}`),C.classList.add(`accent-${p}`)),localStorage.setItem("theme-mode",e),localStorage.removeItem("theme")},[e,r,a,l,u,f,p]);const v=()=>n(C=>C==="dark"?"light":"dark"),x=C=>n(C),y=C=>{i(C),localStorage.setItem("dark-style",C),me.updateSettings({dark_style:C}).catch(()=>{})},S=C=>{o(C),localStorage.setItem("dark-background",C),me.updateSettings({dark_background:C}).catch(()=>{})},M=C=>{c(C),localStorage.setItem("dark-accent",C),me.updateSettings({dark_accent:C}).catch(()=>{})},N=C=>{d(C),localStorage.setItem("light-style",C),me.updateSettings({light_style:C}).catch(()=>{})},A=C=>{m(C),localStorage.setItem("light-background",C),me.updateSettings({light_background:C}).catch(()=>{})},k=C=>{b(C),localStorage.setItem("light-accent",C),me.updateSettings({light_accent:C}).catch(()=>{})};return s.jsx(NK.Provider,{value:{mode:e,darkStyle:r,darkBackground:a,darkAccent:l,lightStyle:u,lightBackground:f,lightAccent:p,toggleMode:v,setMode:x,setDarkStyle:y,setDarkBackground:S,setDarkAccent:M,setLightStyle:N,setLightBackground:A,setLightAccent:k},children:t})}function oh(){const t=w.useContext(NK);if(!t)throw new Error("useTheme must be used within ThemeProvider");return t}function Nt({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 Er({children:t,className:e=""}){return s.jsx("div",{className:`px-6 py-4 border-b border-bambu-dark-tertiary ${e}`,children:t})}function Ct({children:t,className:e=""}){return s.jsx("div",{className:`p-6 ${e}`,children:t})}function Fme(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 Zz({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 Ume({onClose:t,navItems:e,sidebarItems:n}){const{t:r}=Gg(),i=Fme(n,e,r);return w.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(Nt,{className:"w-full max-w-md",onClick:a=>a.stopPropagation(),children:s.jsxs(Ct,{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(pP,{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(Gt,{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(Gr,{className:"w-3 h-3 text-bambu-gray"})]}),s.jsx("div",{className:"flex gap-1",children:o.keys.map(l=>s.jsx(Zz,{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(Zz,{children:"Esc"})," or click outside to close"]})})]})})})}function Me({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 zn({title:t,message:e,confirmText:n="Confirm",cancelText:r="Cancel",variant:i="default",isLoading:a=!1,loadingText:o,onConfirm:l,onCancel:c}){w.useEffect(()=>{const f=m=>{m.key==="Escape"&&!a&&c()};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[c,a]);const d={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:a?void 0:c,children:s.jsx(Nt,{className:"w-full max-w-md",onClick:f=>f.stopPropagation(),children:s.jsxs(Ct,{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 ${d.icon}`,children:s.jsx(Tn,{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(Me,{variant:"secondary",onClick:c,className:"flex-1",disabled:a,children:r}),s.jsx(Me,{onClick:l,className:`flex-1 ${d.button}`,disabled:a,children:a?s.jsxs(s.Fragment,{children:[s.jsx(mt,{className:"w-4 h-4 mr-2 animate-spin"}),o||"Processing..."]}):n})]})]})})})}function zme({plug:t}){const e=ln(),[n,r]=w.useState(null),{data:i,isLoading:a}=ft({queryKey:["smart-plug-status",t.id],queryFn:()=>me.getSmartPlugStatus(t.id),refetchInterval:1e4}),o=pt({mutationFn:f=>me.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(Ws,{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(mt,{className:"w-3 h-3 text-bambu-gray animate-spin"}):c?s.jsxs(s.Fragment,{children:[s.jsx(Qp,{className:"w-3 h-3 text-status-ok"}),s.jsx("span",{className:l?"text-status-ok":"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(Bf,{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(Yg,{className:"w-3 h-3 text-status-error"}),s.jsx("span",{className:"text-status-error",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(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(wu,{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(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(uE,{className:"w-4 h-4"})})]})]}),n&&s.jsx(zn,{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 Qz({onClose:t}){const{data:e,isLoading:n}=ft({queryKey:["smart-plugs"],queryFn:me.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(Ws,{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(mt,{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(Ws,{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(zme,{plug:i},i.id))})})]})}const AK=[{name:"globe",icon:Fd},{name:"link",icon:Xg},{name:"external-link",icon:Gr},{name:"book",icon:Uue},{name:"file-text",icon:Ya},{name:"home",icon:sE},{name:"star",icon:zf},{name:"heart",icon:whe},{name:"bookmark",icon:Bue},{name:"shopping-cart",icon:yK},{name:"music",icon:yP},{name:"video",icon:$D},{name:"image",icon:by},{name:"camera",icon:fg},{name:"map",icon:Khe},{name:"compass",icon:Nde},{name:"coffee",icon:wde},{name:"gift",icon:uhe},{name:"wrench",icon:Xd},{name:"zap",icon:Bf},{name:"cloud",icon:eE},{name:"database",icon:mg},{name:"folder",icon:hK},{name:"mail",icon:Whe},{name:"phone",icon:bfe},{name:"user",icon:_P},{name:"users",icon:cf},{name:"server",icon:Kh},{name:"terminal",icon:wK},{name:"code",icon:uK}];function fE(t){return AK.find(n=>n.name===t)?.icon||Xg}function Bme({value:t,onChange:e}){const[n,r]=w.useState(!1),i=fE(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:AK.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 Jz=768;function TK(){const[t,e]=w.useState(()=>typeof window<"u"?window.innerWidth<Jz:!1);return w.useEffect(()=>{const n=window.matchMedia(`(max-width: ${Jz-1}px)`),r=i=>{e(i.matches)};return e(n.matches),n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),t}const CK=w.createContext(void 0);function $me({children:t}){const[e,n]=w.useState(null),[r,i]=w.useState(!1),[a,o]=w.useState(!1),[l,c]=w.useState(!0),u=w.useRef(!1),d=w.useRef(!0),f=async()=>{try{const x=await me.getAuthStatus();if(!d.current)return;if(i(x.auth_enabled),o(x.requires_setup),x.auth_enabled)if(Yz())try{const S=await me.getCurrentUser();if(!d.current)return;n(S)}catch{if(Lb(null),!d.current)return;n(null)}else n(null);else n(null)}catch{if(!d.current)return;i(!1),n(null)}finally{d.current&&c(!1)}};w.useEffect(()=>(d.current=!0,f(),()=>{d.current=!1}),[]),w.useEffect(()=>{if(!l&&a&&!r){const x=window.location.pathname;x!=="/setup"&&!x.startsWith("/camera/")&&!u.current&&(u.current=!0,window.location.href="/setup")}else a||(u.current=!1)},[l,a,r]);const m=async(x,y)=>{const S=await me.login({username:x,password:y});Lb(S.access_token),n(S.user)},p=()=>{Lb(null),n(null),me.logout().catch(()=>{}),window.location.href="/login"},b=async()=>{if(r&&Yz())try{const x=await me.getCurrentUser();d.current&&n(x)}catch{Lb(null),d.current&&n(null)}},v=async()=>{await f()};return s.jsx(CK.Provider,{value:{user:e,authEnabled:r,requiresSetup:a,loading:l,login:m,logout:p,refreshUser:b,refreshAuth:v},children:t})}function lh(){const t=w.useContext(CK);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t}const C0=[{id:"printers",to:"/",icon:Wr,labelKey:"nav.printers"},{id:"archives",to:"/archives",icon:Ja,labelKey:"nav.archives"},{id:"queue",to:"/queue",icon:si,labelKey:"nav.queue"},{id:"stats",to:"/stats",icon:ede,labelKey:"nav.stats"},{id:"profiles",to:"/profiles",icon:eE,labelKey:"nav.profiles"},{id:"maintenance",to:"/maintenance",icon:Xd,labelKey:"nav.maintenance"},{id:"projects",to:"/projects",icon:Ea,labelKey:"nav.projects"},{id:"files",to:"/files",icon:al,labelKey:"nav.files"},{id:"settings",to:"/settings",icon:dE,labelKey:"nav.settings"}];function Hme(){const t=localStorage.getItem("sidebarOrder");if(t)try{return JSON.parse(t)}catch{return C0.map(e=>e.id)}return C0.map(e=>e.id)}function Vme(t){localStorage.setItem("sidebarOrder",JSON.stringify(t))}function sT(t){return t.startsWith("ext-")}function kK(){return localStorage.getItem("defaultView")||"/"}function Gme(t){localStorage.setItem("defaultView",t)}function Wme(){const t=pl(),e=lc(),{mode:n,toggleMode:r}=oh(),{t:i}=Gg(),a=TK(),{user:o,authEnabled:l,logout:c}=lh(),[u,d]=w.useState(()=>localStorage.getItem("sidebarExpanded")!=="false"),[f,m]=w.useState(!1),[p,b]=w.useState(!1),[v,x]=w.useState(!1),[y,S]=w.useState(Hme),[M,N]=w.useState(null),[A,k]=w.useState(null),C=w.useRef(!1),[D,T]=w.useState(()=>sessionStorage.getItem("dismissedUpdateVersion")),[R,U]=w.useState(null),{data:L}=ft({queryKey:["version"],queryFn:me.getVersion,staleTime:1/0}),{data:q}=ft({queryKey:["settings"],queryFn:me.getSettings,staleTime:300*1e3}),{data:j}=ft({queryKey:["updateCheck"],queryFn:me.checkForUpdates,enabled:q?.check_updates!==!1,staleTime:3600*1e3,refetchInterval:3600*1e3}),{data:W}=ft({queryKey:["external-links"],queryFn:me.getExternalLinks}),{data:K}=ft({queryKey:["smart-plugs"],queryFn:me.getSmartPlugs,staleTime:30*1e3}),V=K?.some(X=>X.show_in_switchbar)??!1,{data:J}=ft({queryKey:["debugLogging"],queryFn:Jp.getDebugLoggingState,staleTime:60*1e3,refetchInterval:60*1e3}),{data:ne}=ft({queryKey:["queue","pending"],queryFn:()=>me.getQueue(void 0,"pending"),staleTime:5*1e3,refetchInterval:5*1e3,refetchOnWindowFocus:!0}),te=ne?.length??0,{data:z}=ft({queryKey:["pending-uploads","count"],queryFn:Fp.getCount,staleTime:5*1e3,refetchInterval:5*1e3,refetchOnWindowFocus:!0}),H=z?.count??0,[Z,ee]=w.useState(null);w.useEffect(()=>{if(!J?.enabled||!J.enabled_at){ee(null);return}const X=new Date(J.enabled_at).getTime(),$=()=>{ee(Math.floor((Date.now()-X)/1e3))};$();const I=setInterval($,1e3);return()=>clearInterval(I)},[J?.enabled,J?.enabled_at]);const he=w.useMemo(()=>new Map(C0.map(X=>[X.id,X])),[]),fe=w.useMemo(()=>new Map((W||[]).map(X=>[`ext-${X.id}`,X])),[W]),oe=(()=>{const X=[],$=new Set,I=l&&o?.role==="user";for(const ce of y)I&&ce==="settings"||(he.has(ce)||fe.has(ce))&&(X.push(ce),$.add(ce));for(const ce of C0)I&&ce.id==="settings"||$.has(ce.id)||(X.push(ce.id),$.add(ce.id));for(const ce of W||[]){const Ee=`ext-${ce.id}`;$.has(Ee)||(X.push(Ee),$.add(Ee))}return X})(),Ne=(X,$)=>{N($),X.dataTransfer.effectAllowed="move",X.dataTransfer.setData("text/plain",$)},ge=(X,$)=>{X.preventDefault(),X.dataTransfer.dropEffect="move",k($)},Se=()=>{k(null)},Re=(X,$)=>{if(X.preventDefault(),M===null||M===$){N(null),k(null);return}const I=[...oe],ce=I.indexOf(M),Ee=I.indexOf($);if(ce===-1||Ee===-1){N(null),k(null);return}I.splice(ce,1),I.splice(Ee,0,M),S(I),Vme(I),N(null),k(null)},de=()=>{N(null),k(null)},Qe=j?.update_available&&j.latest_version&&j.latest_version!==D,G=()=>{j?.latest_version&&(sessionStorage.setItem("dismissedUpdateVersion",j.latest_version),T(j.latest_version))};w.useEffect(()=>{if(!C.current&&e.pathname==="/"){const X=kK();X!=="/"&&(C.current=!0,t(X,{replace:!0}))}},[e.pathname,t]),w.useEffect(()=>{localStorage.setItem("sidebarExpanded",String(u))},[u]),w.useEffect(()=>{a&&m(!1)},[e.pathname,a]),w.useEffect(()=>{const X=$=>{const I=$.detail;U({printer_id:I.printer_id,printer_name:I.printer_name,message:I.message})};return window.addEventListener("plate-not-empty",X),()=>window.removeEventListener("plate-not-empty",X)},[]);const ie=w.useCallback(X=>{const $=X.target;if(!($.tagName==="INPUT"||$.tagName==="TEXTAREA"||$.isContentEditable)&&!X.metaKey&&!X.ctrlKey&&!X.altKey){const I=parseInt(X.key);if(I>=1&&I<=oe.length&&I<=9){const ce=oe[I-1];if(X.preventDefault(),sT(ce)){const Ee=ce.replace("ext-","");t(`/external/${Ee}`)}else{const Ee=he.get(ce);Ee&&t(Ee.to)}return}switch(X.key){case"?":X.preventDefault(),b(!0);break;case"Escape":b(!1);break}}},[t,oe,he]);return w.useEffect(()=>(document.addEventListener("keydown",ie),()=>document.removeEventListener("keydown",ie)),[ie]),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:()=>m(!0),className:"p-2 -ml-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors","aria-label":"Open menu",children:s.jsx(tfe,{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&&f&&s.jsx("div",{className:"fixed inset-0 bg-black/60 z-40 transition-opacity",onClick:()=>m(!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 ${f?"translate-x-0":"-translate-x-full"}`:`fixed inset-y-0 left-0 z-30 ${u?"w-64":"w-16"}`}`,children:[s.jsx("div",{className:`border-b border-bambu-dark-tertiary flex items-center justify-center ${a||u?"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||u?"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:oe.map(X=>{if(sT(X)){const I=fe.get(X);if(!I)return null;const ce=I.custom_icon?null:fE(I.icon);return s.jsx("li",{draggable:!0,onDragStart:Ee=>Ne(Ee,X),onDragOver:Ee=>ge(Ee,X),onDragLeave:Se,onDrop:Ee=>Re(Ee,X),onDragEnd:de,className:`relative ${M===X?"opacity-50":""} ${A===X&&M!==X?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:s.jsxs(Ob,{to:`/external/${I.id}`,className:({isActive:Ee})=>`flex items-center ${a||u?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${Ee?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!a&&!u?I.name:void 0,children:[u&&!a&&s.jsx(pg,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),I.custom_icon?s.jsx("img",{src:`/api/v1/external-links/${I.id}/icon`,alt:"",className:`w-5 h-5 flex-shrink-0 ${n==="dark"?"invert opacity-[0.65]":"opacity-60"}`}):ce&&s.jsx(ce,{className:"w-5 h-5 flex-shrink-0"}),(a||u)&&s.jsx("span",{children:I.name})]})},X)}else{const I=he.get(X);if(!I)return null;const{to:ce,icon:Ee,labelKey:Ie}=I,le=X==="queue"&&te>0,B=X==="archives"&&H>0,O=le?te:B?H:0,Y=le||B;return s.jsx("li",{draggable:!0,onDragStart:pe=>Ne(pe,X),onDragOver:pe=>ge(pe,X),onDragLeave:Se,onDrop:pe=>Re(pe,X),onDragEnd:de,className:`relative ${M===X?"opacity-50":""} ${A===X&&M!==X?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:s.jsxs(Ob,{to:ce,className:({isActive:pe})=>`flex items-center ${a||u?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${pe?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!a&&!u?i(Ie):void 0,children:[u&&!a&&s.jsx(pg,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),s.jsxs("div",{className:"relative",children:[s.jsx(Ee,{className:"w-5 h-5 flex-shrink-0"}),Y&&s.jsx("span",{className:`absolute -top-1.5 -right-1.5 min-w-[18px] h-[18px] px-1 flex items-center justify-center text-[10px] font-bold rounded-full ${B?"bg-blue-500 text-white":"bg-yellow-500 text-black"}`,children:O>99?"99+":O})]}),(a||u)&&s.jsx("span",{children:i(Ie)})]})},X)}})})}),!a&&s.jsx("button",{onClick:()=>d(!u),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(u?"nav.collapseSidebar":"nav.expandSidebar"),children:u?s.jsx(If,{className:"w-5 h-5"}):s.jsx(Zs,{className:"w-5 h-5"})}),s.jsx("div",{className:"p-2 border-t border-bambu-dark-tertiary",children:a||u?s.jsxs("div",{className:"flex flex-col gap-2 px-2",children:[s.jsxs("div",{className:"flex items-center justify-center gap-1",children:[V&&s.jsxs("div",{className:"relative",children:[s.jsx("button",{onMouseEnter:()=>x(!0),className:`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${v?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.smartSwitches",{defaultValue:"Smart Switches"}),children:s.jsx(Ws,{className:"w-5 h-5"})}),v&&s.jsx(Qz,{onClose:()=>x(!1)})]}),s.jsx(Ob,{to:"/system",className:({isActive:X})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${X?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:s.jsx(Zl,{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(Gz,{className:"w-5 h-5"})}),s.jsx("button",{onClick:()=>b(!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(pP,{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(Xz,{className:"w-5 h-5"}):s.jsx(Rw,{className:"w-5 h-5"})}),l&&o&&s.jsx("button",{onClick:c,className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.logout",{defaultValue:"Logout"}),children:s.jsx(xP,{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",L?.version||"..."]}),j?.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:j.latest_version}),children:[s.jsx(rT,{className:"w-4 h-4"}),s.jsx("span",{children:i("nav.update")})]})]})]}):s.jsxs("div",{className:"flex flex-col items-center gap-1",children:[j?.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:j.latest_version}),children:s.jsx(rT,{className:"w-5 h-5"})}),V&&s.jsxs("div",{className:"relative",children:[s.jsx("button",{onMouseEnter:()=>x(!0),className:`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${v?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.smartSwitches",{defaultValue:"Smart Switches"}),children:s.jsx(Ws,{className:"w-5 h-5"})}),v&&s.jsx(Qz,{onClose:()=>x(!1)})]}),s.jsx(Ob,{to:"/system",className:({isActive:X})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${X?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:s.jsx(Zl,{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(Gz,{className:"w-5 h-5"})}),s.jsx("button",{onClick:()=>b(!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(pP,{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(Xz,{className:"w-5 h-5"}):s.jsx(Rw,{className:"w-5 h-5"})}),l&&o&&s.jsx("button",{onClick:c,className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.logout",{defaultValue:"Logout"}),children:s.jsx(xP,{className:"w-5 h-5"})})]})})]}),s.jsxs("main",{className:`flex-1 bg-bambu-dark overflow-auto transition-all duration-300 ${a?"mt-14":u?"ml-64":"ml-16"}`,children:[J?.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(QM,{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"}),Z!==null&&s.jsxs("span",{className:"text-amber-300/70 ml-2",children:["(",Math.floor(Z/60),"m ",Z%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"})})]})}),Qe&&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(rT,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{children:i("nav.updateAvailableBanner",{version:j?.latest_version,defaultValue:`Version ${j?.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:G,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:i("common.dismiss",{defaultValue:"Dismiss"}),children:s.jsx(Gt,{className:"w-4 h-4"})})]}),s.jsx(ace,{})]}),p&&s.jsx(Ume,{onClose:()=>b(!1),sidebarItems:oe.map(X=>{if(sT(X)){const $=fe.get(X);return $?{type:"external",label:$.name}:null}else{const $=he.get(X);return $?{type:"nav",label:$.labelKey,labelKey:$.labelKey}:null}}).filter(Boolean)}),R&&s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[100] p-4",children:s.jsx("div",{className:"bg-bambu-dark-secondary border-2 border-yellow-500 rounded-xl shadow-2xl max-w-md w-full animate-in fade-in zoom-in duration-200",children:s.jsxs("div",{className:"p-6 text-center",children:[s.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-yellow-500/20 flex items-center justify-center",children:s.jsx("svg",{className:"w-10 h-10 text-yellow-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),s.jsx("h2",{className:"text-xl font-bold text-yellow-400 mb-2",children:"Print Paused!"}),s.jsx("p",{className:"text-lg text-white mb-2",children:R.printer_name}),s.jsx("p",{className:"text-bambu-gray mb-6",children:"Objects detected on build plate. The print has been automatically paused. Please clear the plate and resume the print."}),s.jsx("button",{onClick:()=>U(null),className:"w-full py-3 px-6 bg-yellow-500 hover:bg-yellow-600 text-black font-semibold rounded-lg transition-colors",children:"I Understand"})]})})})]})}function t0(t,e="system"){return e==="12h"?t.hour12=!0:e==="24h"&&(t.hour12=!1),t}function Si(t){return t?t.endsWith("Z")||/[+-]\d{2}:\d{2}$/.test(t)?new Date(t):new Date(t+"Z"):null}function xg(t,e){const n=Si(t);if(!n)return"";const r={year:"numeric",month:"short",day:"numeric"};return n.toLocaleDateString(void 0,e??r)}function bg(t,e="system",n){const r=Si(t);if(!r)return"";const a=t0(n??{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"},e);return r.toLocaleString(void 0,a)}function qme(t,e="system",n){const i=t0({...{hour:"2-digit",minute:"2-digit"},...n},e);return t.toLocaleTimeString([],i)}const jK=w.createContext(void 0);function Yn(){const t=w.useContext(jK);if(!t)throw new Error("useToast must be used within a ToastProvider");return t}const Kme={success:s.jsx(Hn,{className:"w-5 h-5 text-green-400"}),error:s.jsx(za,{className:"w-5 h-5 text-red-400"}),warning:s.jsx(aa,{className:"w-5 h-5 text-yellow-400"}),info:s.jsx(Zl,{className:"w-5 h-5 text-blue-400"}),loading:s.jsx(mt,{className:"w-5 h-5 text-bambu-green animate-spin"})},Xme={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 Yme({children:t}){const[e,n]=w.useState([]),r=w.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=w.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=w.useCallback(o=>{n(l=>l.filter(c=>c.id!==o))},[]);return s.jsxs(jK.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 ${Xme[o.type]}`,children:[Kme[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(Gt,{className:"w-4 h-4"})})]},o.id))})]})}function Zme(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 eB(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 Qme(t,e){if(e)return hK;switch(t.toLowerCase().split(".").pop()||""){case"3mf":return _f;case"gcode":return Ya;case"mp4":case"avi":return Id;case"png":case"jpg":case"jpeg":return by;default:return nE}}const Jme=[{value:"name-asc",label:"Name (A-Z)"},{value:"name-desc",label:"Name (Z-A)"},{value:"size-asc",label:"Size (smallest)"},{value:"size-desc",label:"Size (largest)"},{value:"date-asc",label:"Date (oldest)"},{value:"date-desc",label:"Date (newest)"}];function epe({printerId:t,printerName:e,onClose:n}){const{showToast:r}=Yn(),i=ln(),[a,o]=w.useState("/"),[l,c]=w.useState(new Set),[u,d]=w.useState(""),[f,m]=w.useState([]),[p,b]=w.useState("name-asc"),[v,x]=w.useState(null);w.useEffect(()=>{const j=W=>{W.key==="Escape"&&n()};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[n]);const{data:y,isLoading:S,refetch:M}=ft({queryKey:["printerFiles",t,a],queryFn:()=>me.getPrinterFiles(t,a)}),{data:N}=ft({queryKey:["printerStorage",t],queryFn:()=>me.getPrinterStorage(t),staleTime:3e4}),A=pt({mutationFn:async j=>{for(const W of j)await me.deletePrinterFile(t,W)},onSuccess:()=>{r(`Deleted ${f.length} file${f.length>1?"s":""}`),i.invalidateQueries({queryKey:["printerFiles",t]}),c(new Set),m([])},onError:j=>{r(`Delete failed: ${j.message}`,"error")}}),k=j=>{o(j),c(new Set)},C=()=>{if(a==="/")return;const j=a.split("/").filter(Boolean);j.pop(),o(j.length?"/"+j.join("/"):"/"),c(new Set)},D=(j,W)=>{W.stopPropagation(),c(K=>{const V=new Set(K);return V.has(j)?V.delete(j):V.add(j),V})},T=()=>{if(!y?.files)return;const j=y.files.filter(W=>!W.is_directory&&(!u||W.name.toLowerCase().includes(u.toLowerCase()))).map(W=>W.path);c(new Set(j))},R=()=>{c(new Set)},U=async()=>{if(l.size===0)return;const j=Array.from(l);if(j.length===1){window.open(me.getPrinterFileDownloadUrl(t,j[0]),"_blank"),c(new Set);return}x({current:0,total:j.length});try{const W=await me.downloadPrinterFilesAsZip(t,j),K=URL.createObjectURL(W),V=document.createElement("a");V.href=K,V.download=`${e.replace(/[^a-zA-Z0-9]/g,"_")}-files.zip`,document.body.appendChild(V),V.click(),document.body.removeChild(V),URL.revokeObjectURL(K),r(`Downloaded ${j.length} files as ZIP`),c(new Set)}catch(W){r(`Download failed: ${W instanceof Error?W.message:"Unknown error"}`,"error")}finally{x(null)}},L=()=>{l.size!==0&&m(Array.from(l))},q=[{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:j=>j.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(aE,{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:[N&&(N.used_bytes!=null||N.free_bytes!=null)&&s.jsxs("div",{className:"text-sm text-bambu-gray flex items-center gap-2",children:[N.used_bytes!=null&&s.jsxs("span",{children:["Used: ",eB(N.used_bytes)]}),N.used_bytes!=null&&N.free_bytes!=null&&s.jsx("span",{className:"text-bambu-dark-tertiary",children:"|"}),N.free_bytes!=null&&s.jsxs("span",{children:["Free: ",eB(N.free_bytes)]})]}),s.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Gt,{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:[q.map(j=>s.jsx("button",{onClick:()=>{k(j.path),d("")},className:`px-3 py-1 text-sm rounded-full transition-colors ${a===j.path?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:j.label},j.path)),s.jsx("div",{className:"flex-1"}),s.jsxs("div",{className:"relative",children:[s.jsx(Sa,{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:j=>d(j.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.jsxs("div",{className:"relative flex items-center gap-1",children:[s.jsx(lK,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("select",{value:p,onChange:j=>b(j.target.value),className:"appearance-none bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm py-1.5 pl-2 pr-6 focus:border-bambu-green focus:outline-none cursor-pointer",children:Jme.map(j=>s.jsx("option",{value:j.value,children:j.label},j.value))})]}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>M(),disabled:S,children:s.jsx(Ar,{className:`w-4 h-4 ${S?"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:C,disabled:a==="/",className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-50 disabled:cursor-not-allowed",children:s.jsx(If,{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:S?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(mt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):y?.files?.length?s.jsx("div",{className:"space-y-1",children:[...y.files].filter(j=>!u||j.name.toLowerCase().includes(u.toLowerCase())).sort((j,W)=>{if(j.is_directory&&!W.is_directory)return-1;if(!j.is_directory&&W.is_directory)return 1;switch(p){case"name-asc":return j.name.localeCompare(W.name);case"name-desc":return W.name.localeCompare(j.name);case"size-asc":return j.size-W.size;case"size-desc":return W.size-j.size;case"date-asc":{const K=j.mtime?new Date(j.mtime).getTime():0,V=W.mtime?new Date(W.mtime).getTime():0;return K-V}case"date-desc":{const K=j.mtime?new Date(j.mtime).getTime():0;return(W.mtime?new Date(W.mtime).getTime():0)-K}default:return j.name.localeCompare(W.name)}}).map(j=>{const W=Qme(j.name,j.is_directory),K=l.has(j.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:()=>{j.is_directory&&k(j.path)},children:[j.is_directory?null:s.jsx("button",{onClick:V=>D(j.path,V),className:"flex-shrink-0 text-bambu-gray hover:text-white",children:K?s.jsx(ll,{className:"w-5 h-5 text-bambu-green"}):s.jsx(cl,{className:"w-5 h-5"})}),s.jsx(W,{className:`w-5 h-5 flex-shrink-0 ${j.is_directory?"text-bambu-green":"text-bambu-gray"}`}),s.jsx("span",{className:"flex-1 text-white truncate",children:j.name}),!j.is_directory&&s.jsx("span",{className:"text-sm text-bambu-gray",children:Zme(j.size)}),j.is_directory&&s.jsx(If,{className:"w-4 h-4 text-bambu-gray rotate-180"})]},j.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.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("div",{className:"text-sm text-bambu-gray",children:l.size>0?`${l.size} selected`:u?`${y?.files?.filter(j=>j.name.toLowerCase().includes(u.toLowerCase())).length||0} of ${y?.files?.length||0} items`:`${y?.files?.length||0} items`}),y?.files?.some(j=>!j.is_directory)&&s.jsx("div",{className:"flex items-center gap-2",children:l.size>0?s.jsxs("button",{onClick:R,className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors",children:[s.jsx(Yfe,{className:"w-4 h-4"}),"Deselect All"]}):s.jsxs("button",{onClick:T,className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors",children:[s.jsx(ll,{className:"w-4 h-4"}),"Select All"]})})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Me,{variant:"secondary",disabled:l.size===0||v!==null,onClick:U,children:v?s.jsxs(s.Fragment,{children:[s.jsx(mt,{className:"w-4 h-4 animate-spin"}),v.current,"/",v.total]}):s.jsxs(s.Fragment,{children:[s.jsx($r,{className:"w-4 h-4"}),"Download",l.size>1?` (${l.size})`:""]})}),s.jsxs(Me,{variant:"secondary",disabled:l.size===0||A.isPending,onClick:L,className:"text-red-400 hover:text-red-300",children:[A.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(hn,{className:"w-4 h-4"}),"Delete",l.size>1?` (${l.size})`:""]})]})]})]}),f.length>0&&s.jsx(zn,{title:f.length>1?`Delete ${f.length} Files`:"Delete File",message:f.length>1?`Delete ${f.length} selected files? This cannot be undone.`:`Delete "${f[0].split("/").pop()}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{A.mutate(f)},onCancel:()=>m([])})]})}const tpe="embeddedCameraState_",tB=5,npe=2e3,rpe=3e4,ipe=5e3,oT={x:window.innerWidth-420,y:20,width:400,height:300};function ape({printerId:t,printerName:e,viewerIndex:n=0,onClose:r}){const i=`${tpe}${t}`,a=()=>{try{const ye=localStorage.getItem(i);if(ye){const Ce=JSON.parse(ye);return{x:Math.min(Math.max(0,Ce.x),window.innerWidth-100),y:Math.min(Math.max(0,Ce.y),window.innerHeight-100),width:Math.max(200,Math.min(Ce.width,window.innerWidth-20)),height:Math.max(150,Math.min(Ce.height,window.innerHeight-20))}}}catch{}const se=n*30;return{...oT,x:Math.max(0,oT.x-se),y:Math.max(0,oT.y+se)}},[o,l]=w.useState(a),[c,u]=w.useState(!1),[d,f]=w.useState(!1),[m,p]=w.useState({x:0,y:0}),[b,v]=w.useState(!1),[x,y]=w.useState(!1),[S,M]=w.useState(1),[N,A]=w.useState({x:0,y:0}),[k,C]=w.useState(!1),[D,T]=w.useState({x:0,y:0}),[R,U]=w.useState(null),[L,q]=w.useState(null),[j,W]=w.useState(!1),[K,V]=w.useState(!0),[J,ne]=w.useState(Date.now()),[te,z]=w.useState(0),[H,Z]=w.useState(!1),[ee,he]=w.useState(0),fe=w.useRef(null),oe=w.useRef(null),Ne=w.useRef(null),ge=w.useRef(null),Se=w.useRef(null),{data:Re}=ft({queryKey:["printer",t],queryFn:()=>me.getPrinter(t),enabled:t>0});w.useEffect(()=>{const se=setTimeout(()=>{localStorage.setItem(i,JSON.stringify(o))},500);return()=>clearTimeout(se)},[o,i]);const de=w.useRef(!1);w.useEffect(()=>{de.current=!1;const se=`/api/v1/printers/${t}/camera/stop`,ye=()=>{t>0&&!de.current&&(de.current=!0,navigator.sendBeacon(se))},Ce=oe.current;return()=>{Ce&&(Ce.src=""),ye(),Ne.current&&clearTimeout(Ne.current),ge.current&&clearInterval(ge.current),Se.current&&clearInterval(Se.current)}},[t]),w.useEffect(()=>{if(K){const se=setTimeout(()=>V(!1),3e3);return()=>clearTimeout(se)}},[K,J]);const Qe=w.useCallback(()=>{if(te>=tB){Z(!1),W(!0);return}const se=Math.min(npe*Math.pow(2,te),rpe);Z(!0),he(Math.ceil(se/1e3)),ge.current=setInterval(()=>{he(ye=>ye<=1?(ge.current&&clearInterval(ge.current),0):ye-1)},1e3),Ne.current=setTimeout(()=>{z(ye=>ye+1),Z(!1),V(!0),W(!1),oe.current&&(oe.current.src=""),ne(Date.now())},se)},[te]);w.useEffect(()=>{if(K||H||b){Se.current&&(clearInterval(Se.current),Se.current=null);return}return Se.current=setInterval(async()=>{try{const se=await fetch(`/api/v1/printers/${t}/camera/status`);if(se.ok){const ye=await se.json();(ye.stalled||!ye.active&&!j)&&(Se.current&&(clearInterval(Se.current),Se.current=null),V(!1),Qe())}}catch{}},ipe),()=>{Se.current&&(clearInterval(Se.current),Se.current=null)}},[K,j,H,b,t,Qe]),w.useEffect(()=>{const se=()=>{const ye=!!document.fullscreenElement;y(ye),ye||(M(1),A({x:0,y:0}))};return document.addEventListener("fullscreenchange",se),()=>document.removeEventListener("fullscreenchange",se)},[]);const G=()=>{fe.current&&(document.fullscreenElement?document.exitFullscreen():fe.current.requestFullscreen())},ie=()=>{M(se=>Math.min(se+.5,4))},X=()=>{M(se=>{const ye=Math.max(se-.5,1);return ye===1&&A({x:0,y:0}),ye})},$=se=>{se.preventDefault(),se.deltaY<0?ie():X()},I=se=>{S>1&&(se.preventDefault(),C(!0),T({x:se.clientX-N.x,y:se.clientY-N.y}))},ce=w.useCallback(()=>{if(!fe.current||!oe.current)return{x:200,y:150};const se=fe.current.getBoundingClientRect(),ye=se.width*(S-1)/2,Ce=se.height*(S-1)/2;return{x:Math.max(50,ye),y:Math.max(50,Ce)}},[S]),Ee=se=>{if(k&&S>1){const ye=se.clientX-D.x,Ce=se.clientY-D.y,Ue=ce();A({x:Math.max(-Ue.x,Math.min(Ue.x,ye)),y:Math.max(-Ue.y,Math.min(Ue.y,Ce))})}},Ie=()=>{C(!1)},le=se=>{if(se.length<2)return 0;const ye=se[0].clientX-se[1].clientX,Ce=se[0].clientY-se[1].clientY;return Math.sqrt(ye*ye+Ce*Ce)},B=se=>se.length<2?{x:se[0].clientX,y:se[0].clientY}:{x:(se[0].clientX+se[1].clientX)/2,y:(se[0].clientY+se[1].clientY)/2},O=se=>{se.touches.length===2?(se.preventDefault(),U(le(se.touches)),q(B(se.touches))):se.touches.length===1&&S>1&&(se.preventDefault(),C(!0),T({x:se.touches[0].clientX-N.x,y:se.touches[0].clientY-N.y}))},Y=se=>{if(se.touches.length===2&&R!==null){se.preventDefault();const ye=le(se.touches),Ce=ye/R;M(dt=>{const re=Math.max(1,Math.min(4,dt*Ce));return re===1&&A({x:0,y:0}),re}),U(ye);const Ue=B(se.touches);if(L){const dt=ce();A(re=>({x:Math.max(-dt.x,Math.min(dt.x,re.x+(Ue.x-L.x))),y:Math.max(-dt.y,Math.min(dt.y,re.y+(Ue.y-L.y)))}))}q(Ue)}else if(se.touches.length===1&&k&&S>1){se.preventDefault();const ye=se.touches[0].clientX-D.x,Ce=se.touches[0].clientY-D.y,Ue=ce();A({x:Math.max(-Ue.x,Math.min(Ue.x,ye)),y:Math.max(-Ue.y,Math.min(Ue.y,Ce))})}},pe=se=>{se.touches.length<2&&(U(null),q(null)),se.touches.length===0&&C(!1)},we=()=>{M(1),A({x:0,y:0})},ae=()=>{V(!1),te<tB?Qe():W(!0)},ke=()=>{V(!1),W(!1),z(0),Z(!1),Ne.current&&clearTimeout(Ne.current),ge.current&&clearInterval(ge.current)},De=()=>{V(!0),W(!1),z(0),Z(!1),Ne.current&&clearTimeout(Ne.current),ge.current&&clearInterval(ge.current),fetch(`/api/v1/printers/${t}/camera/stop`).catch(()=>{}),oe.current&&(oe.current.src=""),setTimeout(()=>ne(Date.now()),100)},Ke=se=>{se.target.closest(".no-drag")||(u(!0),p({x:se.clientX-o.x,y:se.clientY-o.y}))},et=se=>{se.stopPropagation(),f(!0)};w.useEffect(()=>{const se=Ce=>{if(c)l(Ue=>({...Ue,x:Math.max(0,Math.min(Ce.clientX-m.x,window.innerWidth-Ue.width)),y:Math.max(0,Math.min(Ce.clientY-m.y,window.innerHeight-Ue.height))}));else if(d&&fe.current){const Ue=fe.current.getBoundingClientRect();l(dt=>({...dt,width:Math.max(200,Math.min(Ce.clientX-Ue.left,window.innerWidth-dt.x-10)),height:Math.max(150,Math.min(Ce.clientY-Ue.top,window.innerHeight-dt.y-10))}))}},ye=()=>{u(!1),f(!1)};if(c||d)return document.addEventListener("mousemove",se),document.addEventListener("mouseup",ye),()=>{document.removeEventListener("mousemove",se),document.removeEventListener("mouseup",ye)}},[c,d,m]);const Ye=`/api/v1/printers/${t}/camera/stream?fps=10&t=${J}`;return s.jsxs("div",{ref:fe,className:`${x?"fixed inset-0 z-[100]":"fixed z-50 rounded-lg shadow-2xl border border-bambu-dark-tertiary"} bg-bambu-dark-secondary overflow-hidden`,style:x?void 0:{left:o.x,top:o.y,width:b?200:o.width,height:b?40:o.height,cursor:c?"grabbing":"default"},children:[s.jsxs("div",{className:"flex items-center justify-between px-3 py-2 bg-bambu-dark border-b border-bambu-dark-tertiary cursor-grab active:cursor-grabbing",onMouseDown:Ke,children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-white truncate",children:[s.jsx(pg,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"truncate",children:Re?.name||e})]}),s.jsxs("div",{className:"flex items-center gap-1 no-drag",children:[s.jsx("button",{onClick:De,disabled:K||H,className:"p-1 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:"Refresh stream",children:s.jsx(Ar,{className:`w-3.5 h-3.5 text-bambu-gray ${K?"animate-spin":""}`})}),s.jsx("button",{onClick:G,className:"p-1 hover:bg-bambu-dark-tertiary rounded",title:x?"Exit fullscreen":"Fullscreen",children:x?s.jsx(xK,{className:"w-3.5 h-3.5 text-bambu-gray"}):s.jsx(she,{className:"w-3.5 h-3.5 text-bambu-gray"})}),s.jsx("button",{onClick:()=>v(!b),className:"p-1 hover:bg-bambu-dark-tertiary rounded",title:b?"Expand":"Minimize",children:b?s.jsx(pK,{className:"w-3.5 h-3.5 text-bambu-gray"}):s.jsx(gK,{className:"w-3.5 h-3.5 text-bambu-gray"})}),s.jsx("button",{onClick:r,className:"p-1 hover:bg-red-500/20 rounded",title:"Close",children:s.jsx(Gt,{className:"w-3.5 h-3.5 text-bambu-gray hover:text-red-400"})})]})]}),!b&&s.jsxs("div",{className:"relative w-full bg-black flex items-center justify-center overflow-hidden h-[calc(100%-40px)]",onWheel:$,onMouseMove:Ee,onMouseUp:Ie,onMouseLeave:Ie,onTouchStart:O,onTouchMove:Y,onTouchEnd:pe,style:{touchAction:"none"},children:[K&&!H&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:s.jsx(Ar,{className:"w-6 h-6 text-bambu-gray animate-spin"})}),H&&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-2",children:[s.jsx(Yg,{className:"w-6 h-6 text-orange-400 mx-auto mb-2"}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:["Reconnecting in ",ee,"s..."]})]})}),j&&!H&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black z-10",children:s.jsxs("div",{className:"text-center p-2",children:[s.jsx(Tn,{className:"w-6 h-6 text-orange-400 mx-auto mb-2"}),s.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Camera unavailable"}),s.jsx("button",{onClick:De,className:"px-2 py-1 text-xs bg-bambu-green text-white rounded hover:bg-bambu-green/80",children:"Retry"})]})}),s.jsx("img",{ref:oe,src:Ye,alt:"Camera stream",className:"max-w-full max-h-full object-contain select-none",style:{transform:`scale(${S}) translate(${N.x/S}px, ${N.y/S}px)`,cursor:S>1?k?"grabbing":"grab":"default"},onError:ae,onLoad:ke,onMouseDown:I,draggable:!1},J),s.jsxs("div",{className:"absolute bottom-2 left-2 flex items-center gap-1 bg-black/60 rounded px-1.5 py-1 no-drag",children:[s.jsx("button",{onClick:X,disabled:S<=1,className:"p-1 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom out",children:s.jsx(VD,{className:"w-3.5 h-3.5 text-white"})}),s.jsxs("button",{onClick:we,className:"px-1.5 py-0.5 text-xs text-white hover:bg-white/10 rounded min-w-[32px]",title:"Reset zoom",children:[Math.round(S*100),"%"]}),s.jsx("button",{onClick:ie,disabled:S>=4,className:"p-1 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom in",children:s.jsx(HD,{className:"w-3.5 h-3.5 text-white"})})]}),!x&&s.jsx("div",{className:"absolute bottom-0 right-0 w-6 h-6 cursor-se-resize no-drag hover:bg-white/10 rounded-tl transition-colors",onMouseDown:et,title:"Drag to resize",children:s.jsx("svg",{className:"w-6 h-6 text-bambu-gray/70 hover:text-bambu-gray",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M22 22H20V20H22V22ZM22 18H20V16H22V18ZM18 22H16V20H18V22ZM22 14H20V12H22V14ZM18 18H16V16H18V18ZM14 22H12V20H14V22ZM22 10H20V8H22V10ZM18 14H16V12H18V14ZM14 18H12V16H14V18ZM10 22H8V20H10V22Z"})})})]})]})}function spe({printerId:t,printerName:e,onClose:n}){const r=ln(),[i,a]=w.useState(!0),[o,l]=w.useState(new Set),[c,u]=w.useState(""),[d,f]=w.useState("all"),m=w.useRef(null),{data:p,isLoading:b,refetch:v}=ft({queryKey:["mqtt-logs",t],queryFn:()=>me.getMQTTLogs(t),refetchInterval:1e3}),x=pt({mutationFn:()=>me.enableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),y=pt({mutationFn:()=>me.disableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),S=pt({mutationFn:()=>me.clearMQTTLogs(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}});w.useEffect(()=>{const T=R=>{R.key==="Escape"&&n()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[n]),w.useEffect(()=>{i&&m.current&&(m.current.scrollTop=m.current.scrollHeight)},[p?.logs,i]);const M=T=>{l(R=>{const U=new Set(R);return U.has(T)?U.delete(T):U.add(T),U})},N=T=>new Date(T).toLocaleTimeString("en-US",{hour12:!1,fractionalSecondDigits:3}),A=(T,R)=>{if(T==null)return"<empty>";const U=typeof T=="string"?JSON.parse(T):T,L=JSON.stringify(U,null,R?2:0);return!R&&L.length>100?L.substring(0,100)+"...":L},k=p?.logging_enabled??!1,C=w.useMemo(()=>p?.logs??[],[p?.logs]),D=w.useMemo(()=>C.filter(T=>{if(d!=="all"&&T.direction!==d)return!1;if(c.trim()){const R=c.toLowerCase(),U=T.topic.toLowerCase().includes(R),q=JSON.stringify(T.payload).toLowerCase().includes(R);return U||q}return!0}),[C,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(Gt,{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:[k?s.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>y.mutate(),disabled:y.isPending,children:[s.jsx(cl,{className:"w-4 h-4"}),"Stop"]}):s.jsxs(Me,{size:"sm",onClick:()=>x.mutate(),disabled:x.isPending,children:[s.jsx(ol,{className:"w-4 h-4"}),"Start Logging"]}),s.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>S.mutate(),disabled:S.isPending||C.length===0,children:[s.jsx(hn,{className:"w-4 h-4"}),"Clear"]}),s.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>v(),disabled:b,children:s.jsx(Ar,{className:`w-4 h-4 ${b?"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:T=>a(T.target.checked),className:"rounded border-bambu-dark-tertiary"}),"Auto-scroll"]}),s.jsxs("span",{className:"text-sm text-bambu-gray",children:[D.length,"/",C.length]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(Sa,{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:T=>u(T.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(Gt,{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(A0,{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(hg,{className:"w-3 h-3"}),"Out"]})]})]})]}),s.jsx("div",{ref:m,className:"flex-1 overflow-auto p-4 font-mono text-xs bg-black min-h-[400px]",children:C.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"}),!k&&s.jsx("p",{className:"text-sm",children:'Click "Start Logging" to begin capturing MQTT messages'})]}):D.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:D.map((T,R)=>{const U=o.has(R),L=T.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:()=>M(R),children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:"text-bambu-gray shrink-0",children:N(T.timestamp)}),s.jsx("span",{className:`shrink-0 ${L?"text-blue-400":"text-green-400"}`,title:L?"Incoming":"Outgoing",children:L?s.jsx(A0,{className:"w-3 h-3"}):s.jsx(hg,{className:"w-3 h-3"})}),s.jsx("span",{className:"text-purple-400 shrink-0",children:T.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(T.payload,!0)}):s.jsx("pre",{className:"mt-1 text-white/80 truncate",children:A(T.payload,!1)})]},R)})})}),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:k?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(Me,{variant:"secondary",onClick:n,children:"Close"})]})]})})}const wP={"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 ope(t){switch(t){case 1:return{label:"Fatal",color:"text-red-500",bgColor:"bg-red-500/20",Icon:Tn};case 2:return{label:"Serious",color:"text-red-400",bgColor:"bg-red-500/15",Icon:Tn};case 3:return{label:"Warning",color:"text-orange-400",bgColor:"bg-orange-500/20",Icon:aa};default:return{label:"Info",color:"text-blue-400",bgColor:"bg-blue-500/20",Icon:Zl}}}function SP(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 lpe(t){return t.filter(e=>{const n=parseInt(e.code.replace("0x",""),16)||0,r=SP(e.attr,n);return wP[r]!==void 0})}function cpe(){return"https://wiki.bambulab.com/en/hms/home"}function upe({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=SP(i.attr,a);return wP[o]!==void 0});return w.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(Tn,{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(Gt,{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}=ope(i.severity),d=parseInt(i.code.replace("0x",""),16)||0,f=SP(i.attr,d),m=wP[f],p=cpe(),b=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:["[",b,"]"]}),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:m}),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(Gr,{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 dpe(t){if(!t)return"ASAP";const e=Si(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 hpe({printerId:t}){const{data:e}=ft({queryKey:["queue",t,"pending"],queryFn:()=>me.getQueue(t,"pending"),refetchInterval:3e4}),n=e?.[0],r=e?.length||0;return r===0?null:s.jsx(ps,{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(si,{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(Jn,{className:"w-3 h-3"}),dpe(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(Zs,{className:"w-4 h-4 text-bambu-gray"})]})]})})}function PK(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=PK(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function Bn(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=PK(t))&&(r&&(r+=" "),r+=e);return r}var fpe=["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 GD(t){if(typeof t!="string")return!1;var e=fpe;return e.includes(t)}var mpe=["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"],ppe=new Set(mpe);function RK(t){return typeof t!="string"?!1:ppe.has(t)}function DK(t){return typeof t=="string"&&t.startsWith("data-")}function ts(t){if(typeof t!="object"||t===null)return{};var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(RK(n)||DK(n))&&(e[n]=t[n]);return e}function $f(t){if(t==null)return null;if(w.isValidElement(t)&&typeof t.props=="object"&&t.props!==null){var e=t.props;return ts(e)}return typeof t=="object"&&!Array.isArray(t)?ts(t):null}function Aa(t){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(RK(n)||DK(n)||GD(n))&&(e[n]=t[n]);return e}function gpe(t){return t==null?null:w.isValidElement(t)?Aa(t.props):typeof t=="object"&&!Array.isArray(t)?Aa(t):null}var xpe=["children","width","height","viewBox","className","style","title","desc"];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 bpe(t,e){if(t==null)return{};var n,r,i=ype(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 ype(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 WD=w.forwardRef((t,e)=>{var{children:n,width:r,height:i,viewBox:a,className:o,style:l,title:c,desc:u}=t,d=bpe(t,xpe),f=a||{width:r,height:i,x:0,y:0},m=Bn("recharts-surface",o);return w.createElement("svg",MP({},Aa(d),{className:m,width:r,height:i,style:l,viewBox:"".concat(f.x," ").concat(f.y," ").concat(f.width," ").concat(f.height),ref:e}),w.createElement("title",null,c),w.createElement("desc",null,u),n)}),vpe=["children","className"];function EP(){return EP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},EP.apply(null,arguments)}function _pe(t,e){if(t==null)return{};var n,r,i=wpe(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 wpe(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 qr=w.forwardRef((t,e)=>{var{children:n,className:r}=t,i=_pe(t,vpe),a=Bn("recharts-layer",r);return w.createElement("g",EP({className:a},Aa(i),{ref:e}),n)}),OK=w.createContext(null),Spe=()=>w.useContext(OK);function Nr(t){return function(){return t}}const LK=Math.cos,Iw=Math.sin,gl=Math.sqrt,Fw=Math.PI,mE=2*Fw,NP=Math.PI,AP=2*NP,Xh=1e-6,Mpe=AP-Xh;function IK(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}function Epe(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return IK;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 Npe{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=e==null?IK:Epe(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,m=d*d+f*f;if(this._x1===null)this._append`M${this._x1=e},${this._y1=n}`;else if(m>Xh)if(!(Math.abs(f*c-u*d)>Xh)||!a)this._append`L${this._x1=e},${this._y1=n}`;else{let p=r-o,b=i-l,v=c*c+u*u,x=p*p+b*b,y=Math.sqrt(v),S=Math.sqrt(m),M=a*Math.tan((NP-Math.acos((v+m-x)/(2*y*S)))/2),N=M/S,A=M/y;Math.abs(N-1)>Xh&&this._append`L${e+N*d},${n+N*f}`,this._append`A${a},${a},0,0,${+(f*p>d*b)},${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,m=o?i-a:a-i;this._x1===null?this._append`M${u},${d}`:(Math.abs(this._x1-u)>Xh||Math.abs(this._y1-d)>Xh)&&this._append`L${u},${d}`,r&&(m<0&&(m=m%AP+AP),m>Mpe?this._append`A${r},${r},0,1,${f},${e-l},${n-c}A${r},${r},0,1,${f},${this._x1=u},${this._y1=d}`:m>Xh&&this._append`A${r},${r},0,${+(m>=NP)},${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 qD(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 Npe(e)}function KD(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function FK(t){this._context=t}FK.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 pE(t){return new FK(t)}function UK(t){return t[0]}function zK(t){return t[1]}function BK(t,e){var n=Nr(!0),r=null,i=pE,a=null,o=qD(l);t=typeof t=="function"?t:t===void 0?UK:Nr(t),e=typeof e=="function"?e:e===void 0?zK:Nr(e);function l(c){var u,d=(c=KD(c)).length,f,m=!1,p;for(r==null&&(a=i(p=o())),u=0;u<=d;++u)!(u<d&&n(f=c[u],u,c))===m&&((m=!m)?a.lineStart():a.lineEnd()),m&&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:Nr(+c),l):t},l.y=function(c){return arguments.length?(e=typeof c=="function"?c:Nr(+c),l):e},l.defined=function(c){return arguments.length?(n=typeof c=="function"?c:Nr(!!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 m_(t,e,n){var r=null,i=Nr(!0),a=null,o=pE,l=null,c=qD(u);t=typeof t=="function"?t:t===void 0?UK:Nr(+t),e=typeof e=="function"?e:Nr(e===void 0?0:+e),n=typeof n=="function"?n:n===void 0?zK:Nr(+n);function u(f){var m,p,b,v=(f=KD(f)).length,x,y=!1,S,M=new Array(v),N=new Array(v);for(a==null&&(l=o(S=c())),m=0;m<=v;++m){if(!(m<v&&i(x=f[m],m,f))===y)if(y=!y)p=m,l.areaStart(),l.lineStart();else{for(l.lineEnd(),l.lineStart(),b=m-1;b>=p;--b)l.point(M[b],N[b]);l.lineEnd(),l.areaEnd()}y&&(M[m]=+t(x,m,f),N[m]=+e(x,m,f),l.point(r?+r(x,m,f):M[m],n?+n(x,m,f):N[m]))}if(S)return l=null,S+""||null}function d(){return BK().defined(i).curve(o).context(a)}return u.x=function(f){return arguments.length?(t=typeof f=="function"?f:Nr(+f),r=null,u):t},u.x0=function(f){return arguments.length?(t=typeof f=="function"?f:Nr(+f),u):t},u.x1=function(f){return arguments.length?(r=f==null?null:typeof f=="function"?f:Nr(+f),u):r},u.y=function(f){return arguments.length?(e=typeof f=="function"?f:Nr(+f),n=null,u):e},u.y0=function(f){return arguments.length?(e=typeof f=="function"?f:Nr(+f),u):e},u.y1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:Nr(+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:Nr(!!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 $K{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 Ape(t){return new $K(t,!0)}function Tpe(t){return new $K(t,!1)}const XD={draw(t,e){const n=gl(e/Fw);t.moveTo(n,0),t.arc(0,0,n,0,mE)}},Cpe={draw(t,e){const n=gl(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()}},HK=gl(1/3),kpe=HK*2,jpe={draw(t,e){const n=gl(e/kpe),r=n*HK;t.moveTo(0,-n),t.lineTo(r,0),t.lineTo(0,n),t.lineTo(-r,0),t.closePath()}},Ppe={draw(t,e){const n=gl(e),r=-n/2;t.rect(r,r,n,n)}},Rpe=.8908130915292852,VK=Iw(Fw/10)/Iw(7*Fw/10),Dpe=Iw(mE/10)*VK,Ope=-LK(mE/10)*VK,Lpe={draw(t,e){const n=gl(e*Rpe),r=Dpe*n,i=Ope*n;t.moveTo(0,-n),t.lineTo(r,i);for(let a=1;a<5;++a){const o=mE*a/5,l=LK(o),c=Iw(o);t.lineTo(c*n,-l*n),t.lineTo(l*r-c*i,c*r+l*i)}t.closePath()}},lT=gl(3),Ipe={draw(t,e){const n=-gl(e/(lT*3));t.moveTo(0,n*2),t.lineTo(-lT*n,-n),t.lineTo(lT*n,-n),t.closePath()}},uo=-.5,ho=gl(3)/2,TP=1/gl(12),Fpe=(TP/2+1)*3,Upe={draw(t,e){const n=gl(e/Fpe),r=n/2,i=n*TP,a=r,o=n*TP+n,l=-a,c=o;t.moveTo(r,i),t.lineTo(a,o),t.lineTo(l,c),t.lineTo(uo*r-ho*i,ho*r+uo*i),t.lineTo(uo*a-ho*o,ho*a+uo*o),t.lineTo(uo*l-ho*c,ho*l+uo*c),t.lineTo(uo*r+ho*i,uo*i-ho*r),t.lineTo(uo*a+ho*o,uo*o-ho*a),t.lineTo(uo*l+ho*c,uo*c-ho*l),t.closePath()}};function zpe(t,e){let n=null,r=qD(i);t=typeof t=="function"?t:Nr(t||XD),e=typeof e=="function"?e:Nr(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:Nr(a),i):t},i.size=function(a){return arguments.length?(e=typeof a=="function"?a:Nr(+a),i):e},i.context=function(a){return arguments.length?(n=a??null,i):n},i}function Uw(){}function zw(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 GK(t){this._context=t}GK.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:zw(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:zw(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function Bpe(t){return new GK(t)}function WK(t){this._context=t}WK.prototype={areaStart:Uw,areaEnd:Uw,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:zw(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function $pe(t){return new WK(t)}function qK(t){this._context=t}qK.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:zw(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function Hpe(t){return new qK(t)}function KK(t){this._context=t}KK.prototype={areaStart:Uw,areaEnd:Uw,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 Vpe(t){return new KK(t)}function nB(t){return t<0?-1:1}function rB(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(nB(a)+nB(o))*Math.min(Math.abs(a),Math.abs(o),.5*Math.abs(l))||0}function iB(t,e){var n=t._x1-t._x0;return n?(3*(t._y1-t._y0)/n-e)/2:e}function cT(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 Bw(t){this._context=t}Bw.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:cT(this,this._t0,iB(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,cT(this,iB(this,n=rB(this,t,e)),n);break;default:cT(this,this._t0,n=rB(this,t,e));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e,this._t0=n}}};function XK(t){this._context=new YK(t)}(XK.prototype=Object.create(Bw.prototype)).point=function(t,e){Bw.prototype.point.call(this,e,t)};function YK(t){this._context=t}YK.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 Gpe(t){return new Bw(t)}function Wpe(t){return new XK(t)}function ZK(t){this._context=t}ZK.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=aB(t),i=aB(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 aB(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 qpe(t){return new ZK(t)}function gE(t,e){this._context=t,this._t=e}gE.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 Kpe(t){return new gE(t,.5)}function Xpe(t){return new gE(t,0)}function Ype(t){return new gE(t,1)}function Hf(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 CP(t){for(var e=t.length,n=new Array(e);--e>=0;)n[e]=e;return n}function Zpe(t,e){return t[e]}function Qpe(t){const e=[];return e.key=t,e}function Jpe(){var t=Nr([]),e=CP,n=Hf,r=Zpe;function i(a){var o=Array.from(t.apply(this,arguments),Qpe),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=KD(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:Nr(Array.from(a)),i):t},i.value=function(a){return arguments.length?(r=typeof a=="function"?a:Nr(+a),i):r},i.order=function(a){return arguments.length?(e=a==null?CP:typeof a=="function"?a:Nr(Array.from(a)),i):e},i.offset=function(a){return arguments.length?(n=a??Hf,i):n},i}function ege(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}Hf(t,e)}}function tge(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}Hf(t,e)}}function nge(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,m=d[r-1][1]||0,p=(f-m)/2,b=0;b<l;++b){var v=t[e[b]],x=v[r][1]||0,y=v[r-1][1]||0;p+=x-y}c+=f,u+=p*f}i[r-1][1]+=i[r-1][0]=n,c&&(n-=u/c)}i[r-1][1]+=i[r-1][0]=n,Hf(t,e)}}var uT={},dT={},sB;function rge(){return sB||(sB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==="__proto__"}t.isUnsafeProperty=e})(dT)),dT}var hT={},oB;function QK(){return oB||(oB=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})(hT)),hT}var fT={},lB;function YD(){return lB||(lB=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})(fT)),fT}var mT={},pT={},cB;function ige(){return cB||(cB=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})(pT)),pT}var uB;function ZD(){return uB||(uB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=ige(),n=YD();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})(mT)),mT}var dB;function QD(){return dB||(dB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=rge(),n=QK(),r=YD(),i=ZD();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})(uT)),uT}var gT,hB;function age(){return hB||(hB=1,gT=QD().get),gT}var sge=age();const Vf=ml(sge);var oge=4;function Td(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:oge,n=10**e,r=Math.round(t*n)/n;return Object.is(r,-0)?0:r}function ni(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return t.reduce((i,a,o)=>{var l=n[o-1];return typeof l=="string"?i+l+a:l!==void 0?i+Td(l)+a:i+a},"")}var ea=t=>t===0?0:t>0?1:-1,ul=t=>typeof t=="number"&&t!=+t,Gf=t=>typeof t=="string"&&t.indexOf("%")===t.length-1,zt=t=>(typeof t=="number"||t instanceof Number)&&!ul(t),Do=t=>zt(t)||typeof t=="string",lge=0,k0=t=>{var e=++lge;return"".concat(t||"").concat(e)},Ba=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(!zt(e)&&typeof e!="string")return r;var a;if(Gf(e)){if(n==null)return r;var o=e.indexOf("%");a=n*parseFloat(e.slice(0,o))/100}else a=+e;return ul(a)&&(a=r),i&&n!=null&&a>n&&(a=n),a},JK=t=>{if(!Array.isArray(t))return!1;for(var e=t.length,n={},r=0;r<e;r++)if(!n[String(t[r])])n[String(t[r])]=!0;else return!0;return!1};function nr(t,e,n){return zt(t)&&zt(e)?Td(t+n*(e-t)):e}function eX(t,e,n){if(!(!t||!t.length))return t.find(r=>r&&(typeof e=="function"?e(r):Vf(r,e))===n)}var Hr=t=>t===null||typeof t>"u",yy=t=>Hr(t)?t:"".concat(t.charAt(0).toUpperCase()).concat(t.slice(1));function ys(t){return t!=null}function ch(){}var cge=["type","size","sizeType"];function kP(){return kP=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},kP.apply(null,arguments)}function fB(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?fB(Object(n),!0).forEach(function(r){uge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):fB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function uge(t,e,n){return(e=dge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function dge(t){var e=hge(t,"string");return typeof e=="symbol"?e:e+""}function hge(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 fge(t,e){if(t==null)return{};var n,r,i=mge(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 mge(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 tX={symbolCircle:XD,symbolCross:Cpe,symbolDiamond:jpe,symbolSquare:Ppe,symbolStar:Lpe,symbolTriangle:Ipe,symbolWye:Upe},pge=Math.PI/180,gge=t=>{var e="symbol".concat(yy(t));return tX[e]||XD},xge=(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*pge;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}},bge=(t,e)=>{tX["symbol".concat(yy(t))]=e},JD=t=>{var{type:e="circle",size:n=64,sizeType:r="area"}=t,i=fge(t,cge),a=mB(mB({},i),{},{type:e,size:n,sizeType:r}),o="circle";typeof e=="string"&&(o=e);var l=()=>{var m=gge(o),p=zpe().type(m).size(xge(n,r,o)),b=p();if(b!==null)return b},{className:c,cx:u,cy:d}=a,f=Aa(a);return zt(u)&&zt(d)&&zt(n)?w.createElement("path",kP({},f,{className:Bn("recharts-symbols",c),transform:"translate(".concat(u,", ").concat(d,")"),d:l()})):null};JD.registerSymbol=bge;var nX=t=>"radius"in t&&"startAngle"in t&&"endAngle"in t,eO=(t,e)=>{if(!t||typeof t=="function"||typeof t=="boolean")return null;var n=t;if(w.isValidElement(t)&&(n=t.props),typeof n!="object"&&typeof n!="function")return null;var r={};return Object.keys(n).forEach(i=>{GD(i)&&(r[i]=(a=>n[i](n,a)))}),r},yge=(t,e,n)=>r=>(t(e,n,r),null),vy=(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];GD(i)&&typeof a=="function"&&(r||(r={}),r[i]=yge(a,e,n))}),r};function pB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function vge(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?pB(Object(n),!0).forEach(function(r){_ge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):pB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function _ge(t,e,n){return(e=wge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function wge(t){var e=Sge(t,"string");return typeof e=="symbol"?e:e+""}function Sge(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Kr(t,e){var n=vge({},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 $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 gB(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 Mge(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?gB(Object(n),!0).forEach(function(r){Ege(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):gB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Ege(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=Age(t,"string");return typeof e=="symbol"?e:e+""}function Age(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 xo=32,Tge={align:"center",iconSize:14,inactiveColor:"#ccc",layout:"horizontal",verticalAlign:"middle"};function Cge(t){var{data:e,iconType:n,inactiveColor:r}=t,i=xo/2,a=xo/6,o=xo/3,l=e.inactive?r:e.color,c=n??e.type;if(c==="none")return null;if(c==="plainline"){var u;return w.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:xo,y2:i,className:"recharts-legend-icon"})}if(c==="line")return w.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(xo,"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 w.createElement("path",{stroke:"none",fill:l,d:"M0,".concat(xo/8,"h").concat(xo,"v").concat(xo*3/4,"h").concat(-xo,"z"),className:"recharts-legend-icon"});if(w.isValidElement(e.legendIcon)){var d=Mge({},e);return delete d.legendIcon,w.cloneElement(e.legendIcon,d)}return w.createElement(JD,{fill:l,cx:i,cy:i,size:xo,sizeType:"diameter",type:c})}function kge(t){var{payload:e,iconSize:n,layout:r,formatter:i,inactiveColor:a,iconType:o}=t,l={x:0,y:0,width:xo,height:xo},c={display:r==="horizontal"?"inline-block":"block",marginRight:10},u={display:"inline-block",verticalAlign:"middle",marginRight:4};return e.map((d,f)=>{var m=d.formatter||i,p=Bn({"recharts-legend-item":!0,["legend-item-".concat(f)]:!0,inactive:d.inactive});if(d.type==="none")return null;var b=d.inactive?a:d.color,v=m?m(d.value,d,f):d.value;return w.createElement("li",$w({className:p,style:c,key:"legend-item-".concat(f)},vy(t,d,f)),w.createElement(WD,{width:n,height:n,viewBox:l,style:u,"aria-label":"".concat(v," legend icon")},w.createElement(Cge,{data:d,iconType:o,inactiveColor:a})),w.createElement("span",{className:"recharts-legend-item-text",style:{color:b}},v))})}var jge=t=>{var e=Kr(t,Tge),{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 w.createElement("ul",{className:"recharts-default-legend",style:a},w.createElement(kge,$w({},e,{payload:n})))},xT={},bT={},xB;function Pge(){return xB||(xB=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,a,n);i.has(l)||i.set(l,o)}return Array.from(i.values())}t.uniqBy=e})(bT)),bT}var yT={},bB;function Rge(){return bB||(bB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r){return function(...i){return n.apply(this,i.slice(0,r))}}t.ary=e})(yT)),yT}var vT={},yB;function rX(){return yB||(yB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n}t.identity=e})(vT)),vT}var _T={},wT={},ST={},vB;function Dge(){return vB||(vB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Number.isSafeInteger(n)&&n>=0}t.isLength=e})(ST)),ST}var _B;function tO(){return _B||(_B=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Dge();function n(r){return r!=null&&typeof r!="function"&&e.isLength(r.length)}t.isArrayLike=n})(wT)),wT}var MT={},wB;function Oge(){return wB||(wB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="object"&&n!==null}t.isObjectLike=e})(MT)),MT}var SB;function Lge(){return SB||(SB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=tO(),n=Oge();function r(i){return n.isObjectLike(i)&&e.isArrayLike(i)}t.isArrayLikeObject=r})(_T)),_T}var ET={},NT={},MB;function Ige(){return MB||(MB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=QD();function n(r){return function(i){return e.get(i,r)}}t.property=n})(NT)),NT}var AT={},TT={},CT={},kT={},EB;function iX(){return EB||(EB=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})(kT)),kT}var jT={},NB;function aX(){return NB||(NB=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})(jT)),jT}var PT={},AB;function sX(){return AB||(AB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r){return n===r||Number.isNaN(n)&&Number.isNaN(r)}t.isEqualsSameValueZero=e})(PT)),PT}var TB;function Fge(){return TB||(TB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=iX(),n=aX(),r=sX();function i(d,f,m){return typeof m!="function"?i(d,f,()=>{}):a(d,f,function p(b,v,x,y,S,M){const N=m(b,v,x,y,S,M);return N!==void 0?!!N:a(b,v,p,M)},new Map)}function a(d,f,m,p){if(f===d)return!0;switch(typeof f){case"object":return o(d,f,m,p);case"function":return Object.keys(f).length>0?a(d,{...f},m,p):r.isEqualsSameValueZero(d,f);default:return e.isObject(d)?typeof f=="string"?f==="":!0:r.isEqualsSameValueZero(d,f)}}function o(d,f,m,p){if(f==null)return!0;if(Array.isArray(f))return c(d,f,m,p);if(f instanceof Map)return l(d,f,m,p);if(f instanceof Set)return u(d,f,m,p);const b=Object.keys(f);if(d==null||n.isPrimitive(d))return b.length===0;if(b.length===0)return!0;if(p?.has(f))return p.get(f)===d;p?.set(f,d);try{for(let v=0;v<b.length;v++){const x=b[v];if(!n.isPrimitive(d)&&!(x in d)||f[x]===void 0&&d[x]!==void 0||f[x]===null&&d[x]!==null||!m(d[x],f[x],x,d,f,p))return!1}return!0}finally{p?.delete(f)}}function l(d,f,m,p){if(f.size===0)return!0;if(!(d instanceof Map))return!1;for(const[b,v]of f.entries()){const x=d.get(b);if(m(x,v,b,d,f,p)===!1)return!1}return!0}function c(d,f,m,p){if(f.length===0)return!0;if(!Array.isArray(d))return!1;const b=new Set;for(let v=0;v<f.length;v++){const x=f[v];let y=!1;for(let S=0;S<d.length;S++){if(b.has(S))continue;const M=d[S];let N=!1;if(m(M,x,v,d,f,p)&&(N=!0),N){b.add(S),y=!0;break}}if(!y)return!1}return!0}function u(d,f,m,p){return f.size===0?!0:d instanceof Set?c([...d],[...f],m,p):!1}t.isMatchWith=i,t.isSetMatch=u})(CT)),CT}var CB;function oX(){return CB||(CB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Fge();function n(r,i){return e.isMatchWith(r,i,()=>{})}t.isMatch=n})(TT)),TT}var RT={},DT={},OT={},kB;function Uge(){return kB||(kB=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})(OT)),OT}var LT={},jB;function nO(){return jB||(jB=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})(LT)),LT}var IT={},PB;function lX(){return PB||(PB=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]",m="[object ArrayBuffer]",p="[object Object]",b="[object Error]",v="[object DataView]",x="[object Uint8Array]",y="[object Uint8ClampedArray]",S="[object Uint16Array]",M="[object Uint32Array]",N="[object BigUint64Array]",A="[object Int8Array]",k="[object Int16Array]",C="[object Int32Array]",D="[object BigInt64Array]",T="[object Float32Array]",R="[object Float64Array]";t.argumentsTag=a,t.arrayBufferTag=m,t.arrayTag=d,t.bigInt64ArrayTag=D,t.bigUint64ArrayTag=N,t.booleanTag=i,t.dataViewTag=v,t.dateTag=l,t.errorTag=b,t.float32ArrayTag=T,t.float64ArrayTag=R,t.functionTag=f,t.int16ArrayTag=k,t.int32ArrayTag=C,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=S,t.uint32ArrayTag=M,t.uint8ArrayTag=x,t.uint8ClampedArrayTag=y})(IT)),IT}var FT={},RB;function zge(){return RB||(RB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}t.isTypedArray=e})(FT)),FT}var DB;function cX(){return DB||(DB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Uge(),n=nO(),r=lX(),i=aX(),a=zge();function o(d,f){return l(d,void 0,d,new Map,f)}function l(d,f,m,p=new Map,b=void 0){const v=b?.(d,f,m,p);if(v!==void 0)return v;if(i.isPrimitive(d))return d;if(p.has(d))return p.get(d);if(Array.isArray(d)){const x=new Array(d.length);p.set(d,x);for(let y=0;y<d.length;y++)x[y]=l(d[y],y,m,p,b);return Object.hasOwn(d,"index")&&(x.index=d.index),Object.hasOwn(d,"input")&&(x.input=d.input),x}if(d instanceof Date)return new Date(d.getTime());if(d instanceof RegExp){const x=new RegExp(d.source,d.flags);return x.lastIndex=d.lastIndex,x}if(d instanceof Map){const x=new Map;p.set(d,x);for(const[y,S]of d)x.set(y,l(S,y,m,p,b));return x}if(d instanceof Set){const x=new Set;p.set(d,x);for(const y of d)x.add(l(y,void 0,m,p,b));return x}if(typeof Buffer<"u"&&Buffer.isBuffer(d))return d.subarray();if(a.isTypedArray(d)){const x=new(Object.getPrototypeOf(d)).constructor(d.length);p.set(d,x);for(let y=0;y<d.length;y++)x[y]=l(d[y],y,m,p,b);return x}if(d instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&d instanceof SharedArrayBuffer)return d.slice(0);if(d instanceof DataView){const x=new DataView(d.buffer.slice(0),d.byteOffset,d.byteLength);return p.set(d,x),c(x,d,m,p,b),x}if(typeof File<"u"&&d instanceof File){const x=new File([d],d.name,{type:d.type});return p.set(d,x),c(x,d,m,p,b),x}if(typeof Blob<"u"&&d instanceof Blob){const x=new Blob([d],{type:d.type});return p.set(d,x),c(x,d,m,p,b),x}if(d instanceof Error){const x=new d.constructor;return p.set(d,x),x.message=d.message,x.name=d.name,x.stack=d.stack,x.cause=d.cause,c(x,d,m,p,b),x}if(d instanceof Boolean){const x=new Boolean(d.valueOf());return p.set(d,x),c(x,d,m,p,b),x}if(d instanceof Number){const x=new Number(d.valueOf());return p.set(d,x),c(x,d,m,p,b),x}if(d instanceof String){const x=new String(d.valueOf());return p.set(d,x),c(x,d,m,p,b),x}if(typeof d=="object"&&u(d)){const x=Object.create(Object.getPrototypeOf(d));return p.set(d,x),c(x,d,m,p,b),x}return d}function c(d,f,m=d,p,b){const v=[...Object.keys(f),...e.getSymbols(f)];for(let x=0;x<v.length;x++){const y=v[x],S=Object.getOwnPropertyDescriptor(d,y);(S==null||S.writable)&&(d[y]=l(f[y],y,m,p,b))}}function u(d){switch(n.getTag(d)){case r.argumentsTag:case r.arrayTag:case r.arrayBufferTag:case r.dataViewTag:case r.booleanTag:case r.dateTag:case r.float32ArrayTag:case r.float64ArrayTag:case r.int8ArrayTag:case r.int16ArrayTag:case r.int32ArrayTag:case r.mapTag:case r.numberTag:case r.objectTag:case r.regexpTag:case r.setTag:case r.stringTag:case r.symbolTag:case r.uint8ArrayTag:case r.uint8ClampedArrayTag:case r.uint16ArrayTag:case r.uint32ArrayTag:return!0;default:return!1}}t.cloneDeepWith=o,t.cloneDeepWithImpl=l,t.copyProperties=c})(DT)),DT}var OB;function Bge(){return OB||(OB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=cX();function n(r){return e.cloneDeepWithImpl(r,void 0,r,new Map,void 0)}t.cloneDeep=n})(RT)),RT}var LB;function $ge(){return LB||(LB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=oX(),n=Bge();function r(i){return i=n.cloneDeep(i),a=>e.isMatch(a,i)}t.matches=r})(AT)),AT}var UT={},zT={},BT={},IB;function Hge(){return IB||(IB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=cX(),n=nO(),r=lX();function i(a,o){return e.cloneDeepWith(a,(l,c,u,d)=>{const f=o?.(l,c,u,d);if(f!==void 0)return f;if(typeof a=="object"){if(n.getTag(a)===r.objectTag&&typeof a.constructor!="function"){const m={};return d.set(a,m),e.copyProperties(m,a,u,d),m}switch(Object.prototype.toString.call(a)){case r.numberTag:case r.stringTag:case r.booleanTag:{const m=new a.constructor(a?.valueOf());return e.copyProperties(m,a),m}case r.argumentsTag:{const m={};return e.copyProperties(m,a),m.length=a.length,m[Symbol.iterator]=a[Symbol.iterator],m}default:return}}})}t.cloneDeepWith=i})(BT)),BT}var FB;function Vge(){return FB||(FB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Hge();function n(r){return e.cloneDeepWith(r)}t.cloneDeep=n})(zT)),zT}var $T={},HT={},UB;function uX(){return UB||(UB=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})(HT)),HT}var VT={},zB;function Gge(){return zB||(zB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=nO();function n(r){return r!==null&&typeof r=="object"&&e.getTag(r)==="[object Arguments]"}t.isArguments=n})(VT)),VT}var BB;function Wge(){return BB||(BB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=QK(),n=uX(),r=Gge(),i=ZD();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})($T)),$T}var $B;function qge(){return $B||($B=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=oX(),n=YD(),r=Vge(),i=QD(),a=Wge();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})(UT)),UT}var HB;function Kge(){return HB||(HB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=rX(),n=Ige(),r=$ge(),i=qge();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})(ET)),ET}var VB;function Xge(){return VB||(VB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Pge(),n=Rge(),r=rX(),i=Lge(),a=Kge();function o(l,c=r.identity){return i.isArrayLikeObject(l)?e.uniqBy(Array.from(l),n.ary(a.iteratee(c),1)):[]}t.uniqBy=o})(xT)),xT}var GT,GB;function Yge(){return GB||(GB=1,GT=Xge().uniqBy),GT}var Zge=Yge();const WB=ml(Zge);function dX(t,e,n){return e===!0?WB(t,n):typeof e=="function"?WB(t,e):t}var WT={exports:{}},qT={};var qB;function Qge(){if(qB)return qT;qB=1;var t=Vg(),e=wq();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 qT.useSyncExternalStoreWithSelector=function(u,d,f,m,p){var b=a(null);if(b.current===null){var v={hasValue:!1,value:null};b.current=v}else v=b.current;b=l(function(){function y(k){if(!S){if(S=!0,M=k,k=m(k),p!==void 0&&v.hasValue){var C=v.value;if(p(C,k))return N=C}return N=k}if(C=N,r(M,k))return C;var D=m(k);return p!==void 0&&p(C,D)?(M=k,C):(M=k,N=D)}var S=!1,M,N,A=f===void 0?null:f;return[function(){return y(d())},A===null?void 0:function(){return y(A())}]},[d,f,m,p]);var x=i(u,b[0],b[1]);return o(function(){v.hasValue=!0,v.value=x},[x]),c(x),x},qT}var KB;function Jge(){return KB||(KB=1,WT.exports=Qge()),WT.exports}var hX=Jge(),rO=w.createContext(null),exe=t=>t,Mr=()=>{var t=w.useContext(rO);return t?t.store.dispatch:exe},J1=()=>{},txe=()=>J1,nxe=(t,e)=>t===e;function Vt(t){var e=w.useContext(rO),n=w.useMemo(()=>e?r=>{if(r!=null)return t(r)}:J1,[e,t]);return hX.useSyncExternalStoreWithSelector(e?e.subscription.addNestedSub:txe,e?e.store.getState:J1,e?e.store.getState:J1,n,nxe)}function rxe(t,e=`expected a function, instead received ${typeof t}`){if(typeof t!="function")throw new TypeError(e)}function ixe(t,e=`expected an object, instead received ${typeof t}`){if(typeof t!="object")throw new TypeError(e)}function axe(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 XB=t=>Array.isArray(t)?t:[t];function sxe(t){const e=Array.isArray(t[0])?t[0]:t;return axe(e,"createSelector expects all input-selectors to be functions, but received the following types: "),e}function oxe(t,e){const n=[],{length:r}=t;for(let i=0;i<r;i++)n.push(t[i].apply(null,e));return n}var lxe=class{constructor(t){this.value=t}deref(){return this.value}},cxe=typeof WeakRef<"u"?WeakRef:lxe,uxe=0,YB=1;function p_(){return{s:uxe,v:void 0,o:null,p:null}}function fX(t,e={}){let n=p_();const{resultEqualityCheck:r}=e;let i,a=0;function o(){let l=n;const{length:c}=arguments;for(let f=0,m=c;f<m;f++){const p=arguments[f];if(typeof p=="function"||typeof p=="object"&&p!==null){let b=l.o;b===null&&(l.o=b=new WeakMap);const v=b.get(p);v===void 0?(l=p_(),b.set(p,l)):l=v}else{let b=l.p;b===null&&(l.p=b=new Map);const v=b.get(p);v===void 0?(l=p_(),b.set(p,l)):l=v}}const u=l;let d;if(l.s===YB)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 cxe(d):d}return u.s=YB,u.v=d,d}return o.clearCache=()=>{n=p_(),o.resetResultsCount()},o.resultsCount=()=>a,o.resetResultsCount=()=>{a=0},o}function dxe(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()),rxe(u,`createSelector expects an output function after the inputs, but received: [${typeof u}]`);const d={...n,...c},{memoize:f,memoizeOptions:m=[],argsMemoize:p=fX,argsMemoizeOptions:b=[]}=d,v=XB(m),x=XB(b),y=sxe(i),S=f(function(){return a++,u.apply(null,arguments)},...v),M=p(function(){o++;const A=oxe(y,arguments);return l=S.apply(null,A),l},...x);return Object.assign(M,{resultFunc:u,memoizedResultFunc:S,dependencies:y,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>l,recomputations:()=>a,resetRecomputations:()=>{a=0},memoize:f,argsMemoize:p})};return Object.assign(r,{withTypes:()=>r}),r}var tt=dxe(fX),hxe=Object.assign((t,e=tt)=>{ixe(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:()=>hxe}),KT={},XT={},YT={},ZB;function fxe(){return ZB||(ZB=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})(YT)),YT}var ZT={},QT={},QB;function mX(){return QB||(QB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="symbol"||n instanceof Symbol}t.isSymbol=e})(QT)),QT}var JB;function mxe(){return JB||(JB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=mX(),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})(ZT)),ZT}var e8;function pxe(){return e8||(e8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=fxe(),n=mxe(),r=ZD();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,b)=>{let v=p;for(let x=0;x<b.length&&v!=null;++x)v=v[b[x]];return v},d=(p,b)=>b==null||p==null?b:typeof p=="object"&&"key"in p?Object.hasOwn(b,p.key)?b[p.key]:u(b,p.path):typeof p=="function"?p(b):Array.isArray(p)?u(b,p):typeof b=="object"?b[p]:b,f=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(b=>d(b,p))})).slice().sort((p,b)=>{for(let v=0;v<f.length;v++){const x=e.compareValues(p.criteria[v],b.criteria[v],l[v]);if(x!==0)return x}return 0}).map(p=>p.original)}t.orderBy=i})(XT)),XT}var JT={},t8;function gxe(){return t8||(t8=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})(JT)),JT}var eC={},n8;function pX(){return n8||(n8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=uX(),n=tO(),r=iX(),i=sX();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.isEqualsSameValueZero(c[l],o):!1}t.isIterateeCall=a})(eC)),eC}var r8;function xxe(){return r8||(r8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=pxe(),n=gxe(),r=pX();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})(KT)),KT}var tC,i8;function bxe(){return i8||(i8=1,tC=xxe().sortBy),tC}var yxe=bxe();const xE=ml(yxe);var gX=t=>t.legend.settings,vxe=t=>t.legend.size,_xe=t=>t.legend.payload,wxe=tt([_xe,gX],(t,e)=>{var{itemSorter:n}=e,r=t.flat(1);return n?xE(r,n):r});function Sxe(){return Vt(wxe)}var g_=1;function xX(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],[e,n]=w.useState({height:0,left:0,top:0,width:0}),r=w.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)>g_||Math.abs(o.left-e.left)>g_||Math.abs(o.top-e.top)>g_||Math.abs(o.width-e.width)>g_)&&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 pa(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 Mxe=typeof Symbol=="function"&&Symbol.observable||"@@observable",a8=Mxe,nC=()=>Math.random().toString(36).substring(7).split("").join("."),Exe={INIT:`@@redux/INIT${nC()}`,REPLACE:`@@redux/REPLACE${nC()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${nC()}`},Hw=Exe;function iO(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 bX(t,e,n){if(typeof t!="function")throw new Error(pa(2));if(typeof e=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(pa(0));if(typeof e=="function"&&typeof n>"u"&&(n=e,e=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(pa(1));return n(bX)(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((x,y)=>{o.set(y,x)}))}function d(){if(c)throw new Error(pa(3));return i}function f(x){if(typeof x!="function")throw new Error(pa(4));if(c)throw new Error(pa(5));let y=!0;u();const S=l++;return o.set(S,x),function(){if(y){if(c)throw new Error(pa(6));y=!1,u(),o.delete(S),a=null}}}function m(x){if(!iO(x))throw new Error(pa(7));if(typeof x.type>"u")throw new Error(pa(8));if(typeof x.type!="string")throw new Error(pa(17));if(c)throw new Error(pa(9));try{c=!0,i=r(i,x)}finally{c=!1}return(a=o).forEach(S=>{S()}),x}function p(x){if(typeof x!="function")throw new Error(pa(10));r=x,m({type:Hw.REPLACE})}function b(){const x=f;return{subscribe(y){if(typeof y!="object"||y===null)throw new Error(pa(11));function S(){const N=y;N.next&&N.next(d())}return S(),{unsubscribe:x(S)}},[a8](){return this}}}return m({type:Hw.INIT}),{dispatch:m,subscribe:f,getState:d,replaceReducer:p,[a8]:b}}function Nxe(t){Object.keys(t).forEach(e=>{const n=t[e];if(typeof n(void 0,{type:Hw.INIT})>"u")throw new Error(pa(12));if(typeof n(void 0,{type:Hw.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(pa(13))})}function yX(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{Nxe(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],m=n[f],p=o[f],b=m(p,l);if(typeof b>"u")throw l&&l.type,new Error(pa(14));u[f]=b,c=c||b!==p}return c=c||r.length!==Object.keys(o).length,c?u:o}}function Vw(...t){return t.length===0?e=>e:t.length===1?t[0]:t.reduce((e,n)=>(...r)=>e(n(...r)))}function Axe(...t){return e=>(n,r)=>{const i=e(n,r);let a=()=>{throw new Error(pa(15))};const o={getState:i.getState,dispatch:(c,...u)=>a(c,...u)},l=t.map(c=>c(o));return a=Vw(...l)(i.dispatch),{...i,dispatch:a}}}function vX(t){return iO(t)&&"type"in t&&typeof t.type=="string"}var _X=Symbol.for("immer-nothing"),s8=Symbol.for("immer-draftable"),ns=Symbol.for("immer-state");function Xo(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var Gs=Object,yg=Gs.getPrototypeOf,Gw="constructor",bE="prototype",jP="configurable",Ww="enumerable",ew="writable",j0="value",hu=t=>!!t&&!!t[ns];function dl(t){return t?wX(t)||vE(t)||!!t[s8]||!!t[Gw]?.[s8]||_E(t)||wE(t):!1}var Txe=Gs[bE][Gw].toString(),o8=new WeakMap;function wX(t){if(!t||!aO(t))return!1;const e=yg(t);if(e===null||e===Gs[bE])return!0;const n=Gs.hasOwnProperty.call(e,Gw)&&e[Gw];if(n===Object)return!0;if(!Up(n))return!1;let r=o8.get(n);return r===void 0&&(r=Function.toString.call(n),o8.set(n,r)),r===Txe}function yE(t,e,n=!0){_y(t)===0?(n?Reflect.ownKeys(t):Gs.keys(t)).forEach(i=>{e(i,t[i],t)}):t.forEach((r,i)=>e(i,r,t))}function _y(t){const e=t[ns];return e?e.type_:vE(t)?1:_E(t)?2:wE(t)?3:0}var l8=(t,e,n=_y(t))=>n===2?t.has(e):Gs[bE].hasOwnProperty.call(t,e),PP=(t,e,n=_y(t))=>n===2?t.get(e):t[e],qw=(t,e,n,r=_y(t))=>{r===2?t.set(e,n):r===3?t.add(n):t[e]=n};function Cxe(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}var vE=Array.isArray,_E=t=>t instanceof Map,wE=t=>t instanceof Set,aO=t=>typeof t=="object",Up=t=>typeof t=="function",rC=t=>typeof t=="boolean";function kxe(t){const e=+t;return Number.isInteger(e)&&String(e)===t}var Wc=t=>t.copy_||t.base_,sO=t=>t.modified_?t.copy_:t.base_;function RP(t,e){if(_E(t))return new Map(t);if(wE(t))return new Set(t);if(vE(t))return Array[bE].slice.call(t);const n=wX(t);if(e===!0||e==="class_only"&&!n){const r=Gs.getOwnPropertyDescriptors(t);delete r[ns];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const o=i[a],l=r[o];l[ew]===!1&&(l[ew]=!0,l[jP]=!0),(l.get||l.set)&&(r[o]={[jP]:!0,[ew]:!0,[Ww]:l[Ww],[j0]:t[o]})}return Gs.create(yg(t),r)}else{const r=yg(t);if(r!==null&&n)return{...t};const i=Gs.create(r);return Gs.assign(i,t)}}function oO(t,e=!1){return SE(t)||hu(t)||!dl(t)||(_y(t)>1&&Gs.defineProperties(t,{set:x_,add:x_,clear:x_,delete:x_}),Gs.freeze(t),e&&yE(t,(n,r)=>{oO(r,!0)},!1)),t}function jxe(){Xo(2)}var x_={[j0]:jxe};function SE(t){return t===null||!aO(t)?!0:Gs.isFrozen(t)}var Kw="MapSet",DP="Patches",c8="ArrayMethods",SX={};function Wf(t){const e=SX[t];return e||Xo(0,t),e}var u8=t=>!!SX[t],P0,MX=()=>P0,Pxe=(t,e)=>({drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:u8(Kw)?Wf(Kw):void 0,arrayMethodsPlugin_:u8(c8)?Wf(c8):void 0});function d8(t,e){e&&(t.patchPlugin_=Wf(DP),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function OP(t){LP(t),t.drafts_.forEach(Rxe),t.drafts_=null}function LP(t){t===P0&&(P0=t.parent_)}var h8=t=>P0=Pxe(P0,t);function Rxe(t){const e=t[ns];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function f8(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];if(t!==void 0&&t!==n){n[ns].modified_&&(OP(e),Xo(4)),dl(t)&&(t=m8(e,t));const{patchPlugin_:i}=e;i&&i.generateReplacementPatches_(n[ns].base_,t,e)}else t=m8(e,n);return Dxe(e,t,!0),OP(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==_X?t:void 0}function m8(t,e){if(SE(e))return e;const n=e[ns];if(!n)return Xw(e,t.handledSet_,t);if(!ME(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);AX(n,t)}return n.copy_}function Dxe(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&oO(e,n)}function EX(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var ME=(t,e)=>t.scope_===e,Oxe=[];function NX(t,e,n,r){const i=Wc(t),a=t.type_;if(r!==void 0&&PP(i,r,a)===e){qw(i,r,n,a);return}if(!t.draftLocations_){const l=t.draftLocations_=new Map;yE(i,(c,u)=>{if(hu(u)){const d=l.get(u)||[];d.push(c),l.set(u,d)}})}const o=t.draftLocations_.get(e)??Oxe;for(const l of o)qw(i,l,n,a)}function Lxe(t,e,n){t.callbacks_.push(function(i){const a=e;if(!a||!ME(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const o=sO(a);NX(t,a.draft_??a,o,n),AX(a,i)})}function AX(t,e){if(t.modified_&&!t.finalized_&&(t.type_===3||t.type_===1&&t.allIndicesReassigned_||(t.assigned_?.size??0)>0)){const{patchPlugin_:r}=e;if(r){const i=r.getPath(t);i&&r.generatePatches_(t,i,e)}EX(t)}}function Ixe(t,e,n){const{scope_:r}=t;if(hu(n)){const i=n[ns];ME(i,r)&&i.callbacks_.push(function(){tw(t);const o=sO(i);NX(t,n,o,e)})}else dl(n)&&t.callbacks_.push(function(){const a=Wc(t);t.type_===3?a.has(n)&&Xw(n,r.handledSet_,r):PP(a,e,t.type_)===n&&r.drafts_.length>1&&(t.assigned_.get(e)??!1)===!0&&t.copy_&&Xw(PP(t.copy_,e,t.type_),r.handledSet_,r)})}function Xw(t,e,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||hu(t)||e.has(t)||!dl(t)||SE(t)||(e.add(t),yE(t,(r,i)=>{if(hu(i)){const a=i[ns];if(ME(a,n)){const o=sO(a);qw(t,r,o,t.type_),EX(a)}}else dl(i)&&Xw(i,e,n)})),t}function Fxe(t,e){const n=vE(t),r={type_:n?1:0,scope_:e?e.scope_:MX(),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=Yw;n&&(i=[r],a=R0);const{revoke:o,proxy:l}=Proxy.revocable(i,a);return r.draft_=l,r.revoke_=o,[l,r]}var Yw={get(t,e){if(e===ns)return t;let n=t.scope_.arrayMethodsPlugin_;const r=t.type_===1&&typeof e=="string";if(r&&n?.isArrayOperationMethod(e))return n.createMethodInterceptor(t,e);const i=Wc(t);if(!l8(i,e,t.type_))return Uxe(t,i,e);const a=i[e];if(t.finalized_||!dl(a)||r&&t.operationMethod&&n?.isMutatingArrayMethod(t.operationMethod)&&kxe(e))return a;if(a===iC(t.base_,e)){tw(t);const o=t.type_===1?+e:e,l=FP(t.scope_,a,t,o);return t.copy_[o]=l}return a},has(t,e){return e in Wc(t)},ownKeys(t){return Reflect.ownKeys(Wc(t))},set(t,e,n){const r=TX(Wc(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=iC(Wc(t),e),a=i?.[ns];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_.set(e,!1),!0;if(Cxe(n,i)&&(n!==void 0||l8(t.base_,e,t.type_)))return!0;tw(t),IP(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),Ixe(t,e,n)),!0},deleteProperty(t,e){return tw(t),iC(t.base_,e)!==void 0||e in t.base_?(t.assigned_.set(e,!1),IP(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&&{[ew]:!0,[jP]:t.type_!==1||e!=="length",[Ww]:r[Ww],[j0]:n[e]}},defineProperty(){Xo(11)},getPrototypeOf(t){return yg(t.base_)},setPrototypeOf(){Xo(12)}},R0={};for(let t in Yw){let e=Yw[t];R0[t]=function(){const n=arguments;return n[0]=n[0][0],e.apply(this,n)}}R0.deleteProperty=function(t,e){return R0.set.call(this,t,e,void 0)};R0.set=function(t,e,n){return Yw.set.call(this,t[0],e,n,t[0])};function iC(t,e){const n=t[ns];return(n?Wc(n):t)[e]}function Uxe(t,e,n){const r=TX(e,n);return r?j0 in r?r[j0]:r.get?.call(t.draft_):void 0}function TX(t,e){if(!(e in t))return;let n=yg(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=yg(n)}}function IP(t){t.modified_||(t.modified_=!0,t.parent_&&IP(t.parent_))}function tw(t){t.copy_||(t.assigned_=new Map,t.copy_=RP(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var zxe=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(n,r,i)=>{if(Up(n)&&!Up(r)){const o=r;r=n;const l=this;return function(u=o,...d){return l.produce(u,f=>r.call(this,f,...d))}}Up(r)||Xo(6),i!==void 0&&!Up(i)&&Xo(7);let a;if(dl(n)){const o=h8(this),l=FP(o,n,void 0);let c=!0;try{a=r(l),c=!1}finally{c?OP(o):LP(o)}return d8(o,i),f8(a,o)}else if(!n||!aO(n)){if(a=r(n),a===void 0&&(a=n),a===_X&&(a=void 0),this.autoFreeze_&&oO(a,!0),i){const o=[],l=[];Wf(DP).generateReplacementPatches_(n,a,{patches_:o,inversePatches_:l}),i(o,l)}return a}else Xo(1,n)},this.produceWithPatches=(n,r)=>{if(Up(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]},rC(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),rC(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),rC(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){dl(e)||Xo(8),hu(e)&&(e=rl(e));const n=h8(this),r=FP(n,e,void 0);return r[ns].isManual_=!0,LP(n),r}finishDraft(e,n){const r=e&&e[ns];(!r||!r.isManual_)&&Xo(9);const{scope_:i}=r;return d8(i,n),f8(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=Wf(DP).applyPatches_;return hu(e)?i(e,n):this.produce(e,a=>i(a,n))}};function FP(t,e,n,r){const[i,a]=_E(e)?Wf(Kw).proxyMap_(e,n):wE(e)?Wf(Kw).proxySet_(e,n):Fxe(e,n);return(n?.scope_??MX()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?Lxe(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 rl(t){return hu(t)||Xo(10,t),CX(t)}function CX(t){if(!dl(t)||SE(t))return t;const e=t[ns];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=RP(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=RP(t,!0);return yE(n,(i,a)=>{qw(n,i,CX(a))},r),e&&(e.finalized_=!1),n}var Bxe=new zxe,kX=Bxe.produce;function jX(t){return({dispatch:n,getState:r})=>i=>a=>typeof a=="function"?a(n,r,t):i(a)}var $xe=jX(),Hxe=jX,Vxe=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?Vw:Vw.apply(null,arguments)};function Oo(t,e){function n(...r){if(e){let i=e(...r);if(!i)throw new Error(qs(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=>vX(r)&&r.type===t,n}var PX=class Ib extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,Ib.prototype)}static get[Symbol.species](){return Ib}concat(...e){return super.concat.apply(this,e)}prepend(...e){return e.length===1&&Array.isArray(e[0])?new Ib(...e[0].concat(this)):new Ib(...e.concat(this))}};function p8(t){return dl(t)?kX(t,()=>{}):t}function b_(t,e,n){return t.has(e)?t.get(e):t.set(e,n(e)).get(e)}function Gxe(t){return typeof t=="boolean"}var Wxe=()=>function(e){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:i=!0,actionCreatorCheck:a=!0}=e??{};let o=new PX;return n&&(Gxe(n)?o.push($xe):o.push(Hxe(n.extraArgument))),o},RX="RTK_autoBatch",Fr=()=>t=>({payload:t,meta:{[RX]:!0}}),g8=t=>e=>{setTimeout(e,t)},DX=(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:g8(10):t.type==="callback"?t.queueNotification:g8(t.timeout),u=()=>{o=!1,a&&(a=!1,l.forEach(d=>d()))};return Object.assign({},r,{subscribe(d){const f=()=>i&&d(),m=r.subscribe(f);return l.add(d),()=>{m(),l.delete(d)}},dispatch(d){try{return i=!d?.meta?.[RX],a=!i,a&&(o||(o=!0,c(u))),r.dispatch(d)}finally{i=!0}}})},qxe=t=>function(n){const{autoBatch:r=!0}=n??{};let i=new PX(t);return r&&i.push(DX(typeof r=="object"?r:void 0)),i};function Kxe(t){const e=Wxe(),{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(iO(n))l=yX(n);else throw new Error(qs(1));let c;typeof r=="function"?c=r(e):c=e();let u=Vw;i&&(u=Vxe({trace:!1,...typeof i=="object"&&i}));const d=Axe(...c),f=qxe(d);let m=typeof o=="function"?o(f):f();const p=u(...m);return bX(l,a,p)}function OX(t){const e={},n=[];let r;const i={addCase(a,o){const l=typeof a=="string"?a:a.type;if(!l)throw new Error(qs(28));if(l in e)throw new Error(qs(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 Xxe(t){return typeof t=="function"}function Yxe(t,e){let[n,r,i]=OX(e),a;if(Xxe(t))a=()=>p8(t());else{const l=p8(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(hu(d)){const p=f(d,c);return p===void 0?d:p}else{if(dl(d))return kX(d,m=>f(m,c));{const m=f(d,c);if(m===void 0){if(d===null)return d;throw Error("A case reducer on a non-draftable value must not return undefined")}return m}}return d},l)}return o.getInitialState=a,o}var Zxe="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",Qxe=(t=21)=>{let e="",n=t;for(;n--;)e+=Zxe[Math.random()*64|0];return e},Jxe=Symbol.for("rtk-slice-createasyncthunk");function ebe(t,e){return`${t}/${e}`}function tbe({creators:t}={}){const e=t?.asyncThunk?.[Jxe];return function(r){const{name:i,reducerPath:a=i}=r;if(!i)throw new Error(qs(11));const o=(typeof r.reducers=="function"?r.reducers(rbe()):r.reducers)||{},l=Object.keys(o),c={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},u={addCase(M,N){const A=typeof M=="string"?M:M.type;if(!A)throw new Error(qs(12));if(A in c.sliceCaseReducersByType)throw new Error(qs(13));return c.sliceCaseReducersByType[A]=N,u},addMatcher(M,N){return c.sliceMatchers.push({matcher:M,reducer:N}),u},exposeAction(M,N){return c.actionCreators[M]=N,u},exposeCaseReducer(M,N){return c.sliceCaseReducersByName[M]=N,u}};l.forEach(M=>{const N=o[M],A={reducerName:M,type:ebe(i,M),createNotation:typeof r.reducers=="function"};abe(N)?obe(A,N,u,e):ibe(A,N,u)});function d(){const[M={},N=[],A=void 0]=typeof r.extraReducers=="function"?OX(r.extraReducers):[r.extraReducers],k={...M,...c.sliceCaseReducersByType};return Yxe(r.initialState,C=>{for(let D in k)C.addCase(D,k[D]);for(let D of c.sliceMatchers)C.addMatcher(D.matcher,D.reducer);for(let D of N)C.addMatcher(D.matcher,D.reducer);A&&C.addDefaultCase(A)})}const f=M=>M,m=new Map,p=new WeakMap;let b;function v(M,N){return b||(b=d()),b(M,N)}function x(){return b||(b=d()),b.getInitialState()}function y(M,N=!1){function A(C){let D=C[M];return typeof D>"u"&&N&&(D=b_(p,A,x)),D}function k(C=f){const D=b_(m,N,()=>new WeakMap);return b_(D,C,()=>{const T={};for(const[R,U]of Object.entries(r.selectors??{}))T[R]=nbe(U,C,()=>b_(p,C,x),N);return T})}return{reducerPath:M,getSelectors:k,get selectors(){return k(A)},selectSlice:A}}const S={name:i,reducer:v,actions:c.actionCreators,caseReducers:c.sliceCaseReducersByName,getInitialState:x,...y(a),injectInto(M,{reducerPath:N,...A}={}){const k=N??a;return M.inject({reducerPath:k,reducer:v},A),{...S,...y(k,!0)}}};return S}}function nbe(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 Ns=tbe();function rbe(){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 ibe({type:t,reducerName:e,createNotation:n},r,i){let a,o;if("reducer"in r){if(n&&!sbe(r))throw new Error(qs(17));a=r.reducer,o=r.prepare}else a=r;i.addCase(t,a).exposeCaseReducer(e,a).exposeAction(e,o?Oo(t,o):Oo(t))}function abe(t){return t._reducerDefinitionType==="asyncThunk"}function sbe(t){return t._reducerDefinitionType==="reducerWithPrepare"}function obe({type:t,reducerName:e},n,r,i){if(!i)throw new Error(qs(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||y_,pending:l||y_,rejected:c||y_,settled:u||y_})}function y_(){}var lbe="task",LX="listener",IX="completed",lO="cancelled",cbe=`task-${lO}`,ube=`task-${IX}`,UP=`${LX}-${lO}`,dbe=`${LX}-${IX}`,EE=class{constructor(t){this.code=t,this.message=`${lbe} ${lO} (reason: ${t})`}name="TaskAbortError";message},cO=(t,e)=>{if(typeof t!="function")throw new TypeError(qs(32))},Zw=()=>{},FX=(t,e=Zw)=>(t.catch(e),t),UX=(t,e)=>(t.addEventListener("abort",e,{once:!0}),()=>t.removeEventListener("abort",e)),wf=t=>{if(t.aborted)throw new EE(t.reason)};function zX(t,e){let n=Zw;return new Promise((r,i)=>{const a=()=>i(new EE(t.reason));if(t.aborted){a();return}n=UX(t,a),e.finally(()=>n()).then(r,i)}).finally(()=>{n=Zw})}var hbe=async(t,e)=>{try{return await Promise.resolve(),{status:"ok",value:await t()}}catch(n){return{status:n instanceof EE?"cancelled":"rejected",error:n}}finally{e?.()}},Qw=t=>e=>FX(zX(t,e).then(n=>(wf(t),n))),BX=t=>{const e=Qw(t);return n=>e(new Promise(r=>setTimeout(r,n)))},{assign:eg}=Object,x8={},NE="listenerMiddleware",fbe=(t,e)=>{const n=r=>UX(t,()=>r.abort(t.reason));return(r,i)=>{cO(r);const a=new AbortController;n(a);const o=hbe(async()=>{wf(t),wf(a.signal);const l=await r({pause:Qw(a.signal),delay:BX(a.signal),signal:a.signal});return wf(a.signal),l},()=>a.abort(ube));return i?.autoJoin&&e.push(o.catch(Zw)),{result:Qw(t)(o),cancel(){a.abort(cbe)}}}},mbe=(t,e)=>{const n=async(r,i)=>{wf(e);let a=()=>{};const l=[new Promise((c,u)=>{let d=t({predicate:r,effect:(f,m)=>{m.unsubscribe(),c([f,m.getState(),m.getOriginalState()])}});a=()=>{d(),u()}})];i!=null&&l.push(new Promise(c=>setTimeout(c,i,null)));try{const c=await zX(e,Promise.race(l));return wf(e),c}finally{a()}};return(r,i)=>FX(n(r,i))},$X=t=>{let{type:e,actionCreator:n,matcher:r,predicate:i,effect:a}=t;if(e)i=Oo(e).match;else if(n)e=n.type,i=n.match;else if(r)i=r;else if(!i)throw new Error(qs(21));return cO(a),{predicate:i,type:e,effect:a}},HX=eg(t=>{const{type:e,predicate:n,effect:r}=$X(t);return{id:Qxe(),effect:r,type:e,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(qs(22))}}},{withTypes:()=>HX}),b8=(t,e)=>{const{type:n,effect:r,predicate:i}=$X(e);return Array.from(t.values()).find(a=>(typeof n=="string"?a.type===n:a.predicate===i)&&a.effect===r)},zP=t=>{t.pending.forEach(e=>{e.abort(UP)})},pbe=(t,e)=>()=>{for(const n of e.keys())zP(n);t.clear()},y8=(t,e,n)=>{try{t(e,n)}catch(r){setTimeout(()=>{throw r},0)}},VX=eg(Oo(`${NE}/add`),{withTypes:()=>VX}),gbe=Oo(`${NE}/removeAll`),GX=eg(Oo(`${NE}/remove`),{withTypes:()=>GX}),xbe=(...t)=>{console.error(`${NE}/error`,...t)},wy=(t={})=>{const e=new Map,n=new Map,r=p=>{const b=n.get(p)??0;n.set(p,b+1)},i=p=>{const b=n.get(p)??1;b===1?n.delete(p):n.set(p,b-1)},{extra:a,onError:o=xbe}=t;cO(o);const l=p=>(p.unsubscribe=()=>e.delete(p.id),e.set(p.id,p),b=>{p.unsubscribe(),b?.cancelActive&&zP(p)}),c=p=>{const b=b8(e,p)??HX(p);return l(b)};eg(c,{withTypes:()=>c});const u=p=>{const b=b8(e,p);return b&&(b.unsubscribe(),p.cancelActive&&zP(b)),!!b};eg(u,{withTypes:()=>u});const d=async(p,b,v,x)=>{const y=new AbortController,S=mbe(c,y.signal),M=[];try{p.pending.add(y),r(p),await Promise.resolve(p.effect(b,eg({},v,{getOriginalState:x,condition:(N,A)=>S(N,A).then(Boolean),take:S,delay:BX(y.signal),pause:Qw(y.signal),extra:a,signal:y.signal,fork:fbe(y.signal,M),unsubscribe:p.unsubscribe,subscribe:()=>{e.set(p.id,p)},cancelActiveListeners:()=>{p.pending.forEach((N,A,k)=>{N!==y&&(N.abort(UP),k.delete(N))})},cancel:()=>{y.abort(UP),p.pending.delete(y)},throwIfCancelled:()=>{wf(y.signal)}})))}catch(N){N instanceof EE||y8(o,N,{raisedBy:"effect"})}finally{await Promise.all(M),y.abort(dbe),i(p),p.pending.delete(y)}},f=pbe(e,n);return{middleware:p=>b=>v=>{if(!vX(v))return b(v);if(VX.match(v))return c(v.payload);if(gbe.match(v)){f();return}if(GX.match(v))return u(v.payload);let x=p.getState();const y=()=>{if(x===x8)throw new Error(qs(23));return x};let S;try{if(S=b(v),e.size>0){const M=p.getState(),N=Array.from(e.values());for(const A of N){let k=!1;try{k=A.predicate(v,M,x)}catch(C){k=!1,y8(o,C,{raisedBy:"predicate"})}k&&d(A,v,p,y)}}}finally{x=x8}return S},startListening:c,stopListening:u,clearListeners:f}};function qs(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 bbe={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},WX=Ns({name:"chartLayout",initialState:bbe,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:ybe,setLayout:vbe,setChartSize:_be,setScale:wbe}=WX.actions,Sbe=WX.reducer;function qX(t,e,n){return Array.isArray(t)&&t&&e+n!==0?t.slice(e,n+1):t}function pn(t){return Number.isFinite(t)}function Jl(t){return typeof t=="number"&&t>0&&Number.isFinite(t)}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 Gp(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){Mbe(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 Mbe(t,e,n){return(e=Ebe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Ebe(t){var e=Nbe(t,"string");return typeof e=="symbol"?e:e+""}function Nbe(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 ir(t,e,n){return Hr(t)||Hr(e)?n:Do(e)?Vf(t,e,n):typeof e=="function"?e(t):n}var Abe=(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"&&zt(t[a]))return Gp(Gp({},t),{},{[a]:t[a]+(r||0)});if((l==="horizontal"||l==="vertical"&&a==="center")&&o!=="middle"&&zt(t[o]))return Gp(Gp({},t),{},{[o]:t[o]+(i||0)})}return t},xl=(t,e)=>t==="horizontal"&&e==="xAxis"||t==="vertical"&&e==="yAxis"||t==="centric"&&e==="angleAxis"||t==="radial"&&e==="radiusAxis",KX=(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},XX=(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:m,axisType:p}=t;if(!o)return null;var b=l==="scaleBand"&&o.bandwidth?o.bandwidth()/2:2,v=i==="category"&&o.bandwidth?o.bandwidth()/b:0;if(v=p==="angleAxis"&&a&&a.length>=2?ea(a[0]-a[1])*2*v:v,f||m){var x=(f||m||[]).map((y,S)=>{var M=r?r.indexOf(y):y,N=o.map(M);return pn(N)?{coordinate:N+v,value:y,offset:v,index:S}:null}).filter(ys);return x}return c&&u?u.map((y,S)=>{var M=o.map(y);return pn(M)?{coordinate:M+v,value:y,index:S,offset:v}:null}).filter(ys):o.ticks&&d!=null?o.ticks(d).map((y,S)=>{var M=o.map(y);return pn(M)?{coordinate:M+v,value:y,index:S,offset:v}:null}).filter(ys):o.domain().map((y,S)=>{var M=o.map(y);return pn(M)?{coordinate:M+v,value:r?r[y]:y,index:S,offset:v}:null}).filter(ys)},Tbe=(t,e)=>{if(!e||e.length!==2||!zt(e[0])||!zt(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(!zt(t[0])||t[0]<n)&&(i[0]=n),(!zt(t[1])||t[1]>r)&&(i[1]=r),i[0]>r&&(i[0]=r),i[1]<n&&(i[1]=n),i},Cbe=t=>{var e,n=t.length;if(!(n<=0)){var r=(e=t[0])===null||e===void 0?void 0:e.length;if(!(r==null||r<=0))for(var i=0;i<r;++i)for(var a=0,o=0,l=0;l<n;++l){var c=t[l],u=c?.[i];if(u!=null){var d=u[1],f=u[0],m=ul(d)?f:d;m>=0?(u[0]=a,a+=m,u[1]=a):(u[0]=o,o+=m,u[1]=o)}}}},kbe=t=>{var e,n=t.length;if(!(n<=0)){var r=(e=t[0])===null||e===void 0?void 0:e.length;if(!(r==null||r<=0))for(var i=0;i<r;++i)for(var a=0,o=0;o<n;++o){var l=t[o],c=l?.[i];if(c!=null){var u=ul(c[1])?c[0]:c[1];u>=0?(c[0]=a,a+=u,c[1]=a):(c[0]=0,c[1]=0)}}}},jbe={sign:Cbe,expand:ege,none:Hf,silhouette:tge,wiggle:nge,positive:kbe},Pbe=(t,e,n)=>{var r,i=(r=jbe[n])!==null&&r!==void 0?r:Hf,a=Jpe().keys(e).value((l,c)=>Number(ir(l,c,0))).order(CP).offset(i),o=a(t);return o.forEach((l,c)=>{l.forEach((u,d)=>{var f=ir(t[d],e[c],0);Array.isArray(f)&&f.length===2&&zt(f[0])&&zt(f[1])&&(u[0]=f[0],u[1]=f[1])})}),o};function YX(t){return t==null?void 0:String(t)}function Jw(t){var{axis:e,ticks:n,bandSize:r,entry:i,index:a,dataKey:o}=t;if(e.type==="category"){if(!e.allowDuplicatedCategory&&e.dataKey&&!Hr(i[e.dataKey])){var l=eX(n,"value",i[e.dataKey]);if(l)return l.coordinate+r/2}return n!=null&&n[a]?n[a].coordinate+r/2:null}var c=ir(i,Hr(o)?e.dataKey:o),u=e.scale.map(c);return zt(u)?u:null}var _8=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=ir(a,e.dataKey,e.scale.domain()[o]);if(Hr(l))return null;var c=e.scale.map(l);return zt(c)?c-i/2+r:null},Rbe=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]},Dbe=t=>{var e=t.flat(2).filter(zt);return[Math.min(...e),Math.max(...e)]},Obe=t=>[t[0]===1/0?0:t[0],t[1]===-1/0?0:t[1]],Lbe=(t,e,n)=>{if(t!=null)return Obe(Object.keys(t).reduce((r,i)=>{var a=t[i];if(!a)return r;var{stackedData:o}=a,l=o.reduce((c,u)=>{var d=qX(u,e,n),f=Dbe(d);return!pn(f[0])||!pn(f[1])?c:[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]))},w8=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,S8=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,Yd=(t,e,n)=>{if(t&&t.scale&&t.scale.bandwidth){var r=t.scale.bandwidth();if(!n||r>0)return r}if(t&&e&&e.length>=2){for(var i=xE(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 M8(t){var{tooltipEntrySettings:e,dataKey:n,payload:r,value:i,name:a}=t;return Gp(Gp({},e),{},{dataKey:n,payload:r,value:i,name:a})}function uh(t,e){if(t)return String(t);if(typeof e=="string")return e}var Ibe=(t,e)=>{if(e==="horizontal")return t.chartX;if(e==="vertical")return t.chartY},Fbe=(t,e)=>e==="centric"?t.angle:t.radius,Su=t=>t.layout.width,Mu=t=>t.layout.height,Ube=t=>t.layout.scale,ZX=t=>t.layout.margin,AE=tt(t=>t.cartesianAxis.xAxis,t=>Object.values(t)),TE=tt(t=>t.cartesianAxis.yAxis,t=>Object.values(t)),QX="data-recharts-item-index",JX="data-recharts-item-id",Sy=60;function E8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function v_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?E8(Object(n),!0).forEach(function(r){zbe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):E8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function zbe(t,e,n){return(e=Bbe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Bbe(t){var e=$be(t,"string");return typeof e=="symbol"?e:e+""}function $be(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 Hbe=t=>t.brush.height;function Vbe(t){var e=TE(t);return e.reduce((n,r)=>{if(r.orientation==="left"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:Sy;return n+i}return n},0)}function Gbe(t){var e=TE(t);return e.reduce((n,r)=>{if(r.orientation==="right"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:Sy;return n+i}return n},0)}function Wbe(t){var e=AE(t);return e.reduce((n,r)=>r.orientation==="top"&&!r.mirror&&!r.hide?n+r.height:n,0)}function qbe(t){var e=AE(t);return e.reduce((n,r)=>r.orientation==="bottom"&&!r.mirror&&!r.hide?n+r.height:n,0)}var zi=tt([Su,Mu,ZX,Hbe,Vbe,Gbe,Wbe,qbe,gX,vxe],(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},m=v_(v_({},f),d),p=m.bottom;m.bottom+=r,m=Abe(m,c,u);var b=t-m.left-m.right,v=e-m.top-m.bottom;return v_(v_({brushBottom:p},m),{},{width:Math.max(b,0),height:Math.max(v,0)})}),Kbe=tt(zi,t=>({x:t.left,y:t.top,width:t.width,height:t.height})),uO=tt(Su,Mu,(t,e)=>({x:0,y:0,width:t,height:e})),Xbe=w.createContext(null),Bi=()=>w.useContext(Xbe)!=null,CE=t=>t.brush,kE=tt([CE,zi,ZX],(t,e,n)=>({height:t.height,x:zt(t.x)?t.x:e.left,y:zt(t.y)?t.y:e.top+e.height+e.brushBottom-(n?.bottom||0),width:zt(t.width)?t.width:e.width})),aC={},sC={},oC={},N8;function Ybe(){return N8||(N8=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(),v()};let m=null;const p=()=>{m!=null&&clearTimeout(m),m=setTimeout(()=>{m=null,f()},r)},b=()=>{m!==null&&(clearTimeout(m),m=null)},v=()=>{b(),o=void 0,l=null},x=()=>{d()},y=function(...S){if(i?.aborted)return;o=this,l=S;const M=m==null;p(),c&&M&&d()};return y.schedule=p,y.cancel=v,y.flush=x,i?.addEventListener("abort",v,{once:!0}),y}t.debounce=e})(oC)),oC}var A8;function Zbe(){return A8||(A8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Ybe();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 m=e.debounce(function(...v){d=r.apply(this,v),f=null},i,{edges:u}),p=function(...v){return c!=null&&(f===null&&(f=Date.now()),Date.now()-f>=c)?(d=r.apply(this,v),f=Date.now(),m.cancel(),m.schedule(),d):(m.apply(this,v),d)},b=()=>(m.flush(),d);return p.cancel=m.cancel,p.flush=b,p}t.debounce=n})(sC)),sC}var T8;function Qbe(){return T8||(T8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Zbe();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})(aC)),aC}var lC,C8;function Jbe(){return C8||(C8=1,lC=Qbe().throttle),lC}var e0e=Jbe();const t0e=ml(e0e);var eS=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++]))}},zl={width:"100%",height:"100%",debounce:0,minWidth:0,initialDimension:{width:-1,height:-1}},eY=(t,e,n)=>{var{width:r=zl.width,height:i=zl.height,aspect:a,maxHeight:o}=n,l=Gf(r)?t:Number(r),c=Gf(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}},n0e={width:0,height:0,overflow:"visible"},r0e={width:0,overflowX:"visible"},i0e={height:0,overflowY:"visible"},a0e={},s0e=t=>{var{width:e,height:n}=t,r=Gf(e),i=Gf(n);return r&&i?n0e:r?r0e:i?i0e:a0e};function o0e(t){var{width:e,height:n,aspect:r}=t,i=e,a=n;return i===void 0&&a===void 0?(i=zl.width,a=zl.height):i===void 0?i=r&&r>0?void 0:zl.width:a===void 0&&(a=r&&r>0?void 0:zl.height),{width:i,height:a}}function BP(){return BP=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},BP.apply(null,arguments)}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 j8(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){l0e(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 l0e(t,e,n){return(e=c0e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function c0e(t){var e=u0e(t,"string");return typeof e=="symbol"?e:e+""}function u0e(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 tY=w.createContext(zl.initialDimension);function d0e(t){return Jl(t.width)&&Jl(t.height)}function nY(t){var{children:e,width:n,height:r}=t,i=w.useMemo(()=>({width:n,height:r}),[n,r]);return d0e(i)?w.createElement(tY.Provider,{value:i},e):null}var dO=()=>w.useContext(tY),h0e=w.forwardRef((t,e)=>{var{aspect:n,initialDimension:r=zl.initialDimension,width:i,height:a,minWidth:o=zl.minWidth,minHeight:l,maxHeight:c,children:u,debounce:d=zl.debounce,id:f,className:m,onResize:p,style:b={}}=t,v=w.useRef(null),x=w.useRef();x.current=p,w.useImperativeHandle(e,()=>v.current);var[y,S]=w.useState({containerWidth:r.width,containerHeight:r.height}),M=w.useCallback((D,T)=>{S(R=>{var U=Math.round(D),L=Math.round(T);return R.containerWidth===U&&R.containerHeight===L?R:{containerWidth:U,containerHeight:L}})},[]);w.useEffect(()=>{if(v.current==null||typeof ResizeObserver>"u")return ch;var D=L=>{var q,j=L[0];if(j!=null){var{width:W,height:K}=j.contentRect;M(W,K),(q=x.current)===null||q===void 0||q.call(x,W,K)}};d>0&&(D=t0e(D,d,{trailing:!0,leading:!1}));var T=new ResizeObserver(D),{width:R,height:U}=v.current.getBoundingClientRect();return M(R,U),T.observe(v.current),()=>{T.disconnect()}},[M,d]);var{containerWidth:N,containerHeight:A}=y;eS(!n||n>0,"The aspect(%s) must be greater than zero.",n);var{calculatedWidth:k,calculatedHeight:C}=eY(N,A,{width:i,height:a,aspect:n,maxHeight:c});return eS(k!=null&&k>0||C!=null&&C>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.`,k,C,i,a,o,l,n),w.createElement("div",{id:f?"".concat(f):void 0,className:Bn("recharts-responsive-container",m),style:j8(j8({},b),{},{width:i,height:a,minWidth:o,minHeight:l,maxHeight:c}),ref:v},w.createElement("div",{style:s0e({width:i,height:a})},w.createElement(nY,{width:k,height:C},u)))}),nw=w.forwardRef((t,e)=>{var n=dO();if(Jl(n.width)&&Jl(n.height))return t.children;var{width:r,height:i}=o0e({width:t.width,height:t.height,aspect:t.aspect}),{calculatedWidth:a,calculatedHeight:o}=eY(void 0,void 0,{width:r,height:i,aspect:t.aspect,maxHeight:t.maxHeight});return zt(a)&&zt(o)?w.createElement(nY,{width:a,height:o},t.children):w.createElement(h0e,BP({},t,{width:r,height:i,ref:e}))});function hO(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 My=()=>{var t,e=Bi(),n=Vt(Kbe),r=Vt(kE),i=(t=Vt(CE))===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}},f0e={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},rY=()=>{var t;return(t=Vt(zi))!==null&&t!==void 0?t:f0e},fO=()=>Vt(Su),mO=()=>Vt(Mu),m0e=()=>Vt(t=>t.layout.margin),Fn=t=>t.layout.layoutType,dh=()=>Vt(Fn),pO=()=>{var t=dh();if(t==="horizontal"||t==="vertical")return t},iY=t=>{var e=t.layout.layoutType;if(e==="centric"||e==="radial")return e},p0e=()=>{var t=dh();return t!==void 0},Ey=t=>{var e=Mr(),n=Bi(),{width:r,height:i}=t,a=dO(),o=r,l=i;return a&&(o=a.width>0?a.width:r,l=a.height>0?a.height:i),w.useEffect(()=>{!n&&Jl(o)&&Jl(l)&&e(_be({width:o,height:l}))},[e,n,o,l]),null},aY=Symbol.for("immer-nothing"),P8=Symbol.for("immer-draftable"),Qs=Symbol.for("immer-state");function Yo(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var D0=Object.getPrototypeOf;function vg(t){return!!t&&!!t[Qs]}function qf(t){return t?sY(t)||Array.isArray(t)||!!t[P8]||!!t.constructor?.[P8]||Ny(t)||PE(t):!1}var g0e=Object.prototype.constructor.toString(),R8=new WeakMap;function sY(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=R8.get(n);return r===void 0&&(r=Function.toString.call(n),R8.set(n,r)),r===g0e}function tS(t,e,n=!0){jE(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 jE(t){const e=t[Qs];return e?e.type_:Array.isArray(t)?1:Ny(t)?2:PE(t)?3:0}function $P(t,e){return jE(t)===2?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function oY(t,e,n){const r=jE(t);r===2?t.set(e,n):r===3?t.add(n):t[e]=n}function x0e(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}function Ny(t){return t instanceof Map}function PE(t){return t instanceof Set}function Yh(t){return t.copy_||t.base_}function HP(t,e){if(Ny(t))return new Map(t);if(PE(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=sY(t);if(e===!0||e==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(t);delete r[Qs];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(D0(t),r)}else{const r=D0(t);if(r!==null&&n)return{...t};const i=Object.create(r);return Object.assign(i,t)}}function gO(t,e=!1){return RE(t)||vg(t)||!qf(t)||(jE(t)>1&&Object.defineProperties(t,{set:__,add:__,clear:__,delete:__}),Object.freeze(t),e&&Object.values(t).forEach(n=>gO(n,!0))),t}function b0e(){Yo(2)}var __={value:b0e};function RE(t){return t===null||typeof t!="object"?!0:Object.isFrozen(t)}var y0e={};function Kf(t){const e=y0e[t];return e||Yo(0,t),e}var O0;function lY(){return O0}function v0e(t,e){return{drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function D8(t,e){e&&(Kf("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function VP(t){GP(t),t.drafts_.forEach(_0e),t.drafts_=null}function GP(t){t===O0&&(O0=t.parent_)}function O8(t){return O0=v0e(O0,t)}function _0e(t){const e=t[Qs];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function L8(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];return t!==void 0&&t!==n?(n[Qs].modified_&&(VP(e),Yo(4)),qf(t)&&(t=nS(e,t),e.parent_||rS(e,t)),e.patches_&&Kf("Patches").generateReplacementPatches_(n[Qs].base_,t,e.patches_,e.inversePatches_)):t=nS(e,n,[]),VP(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==aY?t:void 0}function nS(t,e,n){if(RE(e))return e;const r=t.immer_.shouldUseStrictIteration(),i=e[Qs];if(!i)return tS(e,(a,o)=>I8(t,i,e,a,o,n),r),e;if(i.scope_!==t)return e;if(!i.modified_)return rS(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),tS(o,(c,u)=>I8(t,i,a,c,u,n,l),r),rS(t,a,!1),n&&t.patches_&&Kf("Patches").generatePatches_(i,n,t.patches_,t.inversePatches_)}return i.copy_}function I8(t,e,n,r,i,a,o){if(i==null||typeof i!="object"&&!o)return;const l=RE(i);if(!(l&&!o)){if(vg(i)){const c=a&&e&&e.type_!==3&&!$P(e.assigned_,r)?a.concat(r):void 0,u=nS(t,i,c);if(oY(n,r,u),vg(u))t.canAutoFreeze_=!1;else return}else o&&n.add(i);if(qf(i)&&!l){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1||e&&e.base_&&e.base_[r]===i&&l)return;nS(t,i),(!e||!e.scope_.parent_)&&typeof r!="symbol"&&(Ny(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&rS(t,i)}}}function rS(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&gO(e,n)}function w0e(t,e){const n=Array.isArray(t),r={type_:n?1:0,scope_:e?e.scope_:lY(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,a=xO;n&&(i=[r],a=L0);const{revoke:o,proxy:l}=Proxy.revocable(i,a);return r.draft_=l,r.revoke_=o,l}var xO={get(t,e){if(e===Qs)return t;const n=Yh(t);if(!$P(n,e))return S0e(t,n,e);const r=n[e];return t.finalized_||!qf(r)?r:r===cC(t.base_,e)?(uC(t),t.copy_[e]=qP(r,t)):r},has(t,e){return e in Yh(t)},ownKeys(t){return Reflect.ownKeys(Yh(t))},set(t,e,n){const r=cY(Yh(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=cC(Yh(t),e),a=i?.[Qs];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(x0e(n,i)&&(n!==void 0||$P(t.base_,e)))return!0;uC(t),WP(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 cC(t.base_,e)!==void 0||e in t.base_?(t.assigned_[e]=!1,uC(t),WP(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=Yh(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{writable:!0,configurable:t.type_!==1||e!=="length",enumerable:r.enumerable,value:n[e]}},defineProperty(){Yo(11)},getPrototypeOf(t){return D0(t.base_)},setPrototypeOf(){Yo(12)}},L0={};tS(xO,(t,e)=>{L0[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});L0.deleteProperty=function(t,e){return L0.set.call(this,t,e,void 0)};L0.set=function(t,e,n){return xO.set.call(this,t[0],e,n,t[0])};function cC(t,e){const n=t[Qs];return(n?Yh(n):t)[e]}function S0e(t,e,n){const r=cY(e,n);return r?"value"in r?r.value:r.get?.call(t.draft_):void 0}function cY(t,e){if(!(e in t))return;let n=D0(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=D0(n)}}function WP(t){t.modified_||(t.modified_=!0,t.parent_&&WP(t.parent_))}function uC(t){t.copy_||(t.copy_=HP(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var M0e=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"&&Yo(6),r!==void 0&&typeof r!="function"&&Yo(7);let i;if(qf(e)){const a=O8(this),o=qP(e,void 0);let l=!0;try{i=n(o),l=!1}finally{l?VP(a):GP(a)}return D8(a,r),L8(i,a)}else if(!e||typeof e!="object"){if(i=n(e),i===void 0&&(i=e),i===aY&&(i=void 0),this.autoFreeze_&&gO(i,!0),r){const a=[],o=[];Kf("Patches").generateReplacementPatches_(e,i,a,o),r(a,o)}return i}else Yo(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){qf(t)||Yo(8),vg(t)&&(t=E0e(t));const e=O8(this),n=qP(t,void 0);return n[Qs].isManual_=!0,GP(e),n}finishDraft(t,e){const n=t&&t[Qs];(!n||!n.isManual_)&&Yo(9);const{scope_:r}=n;return D8(r,e),L8(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=Kf("Patches").applyPatches_;return vg(t)?r(t,e):this.produce(t,i=>r(i,e))}};function qP(t,e){const n=Ny(t)?Kf("MapSet").proxyMap_(t,e):PE(t)?Kf("MapSet").proxySet_(t,e):w0e(t,e);return(e?e.scope_:lY()).drafts_.push(n),n}function E0e(t){return vg(t)||Yo(10,t),uY(t)}function uY(t){if(!qf(t)||RE(t))return t;const e=t[Qs];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=HP(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=HP(t,!0);return tS(n,(i,a)=>{oY(n,i,uY(a))},r),e&&(e.finalized_=!1),n}var N0e=new M0e;N0e.produce;var A0e={settings:{layout:"horizontal",align:"center",verticalAlign:"middle",itemSorter:"value"},size:{width:0,height:0},payload:[]},dY=Ns({name:"legend",initialState:A0e,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:Fr()},replaceLegendPayload:{reducer(t,e){var{prev:n,next:r}=e.payload,i=rl(t).payload.indexOf(n);i>-1&&(t.payload[i]=r)},prepare:Fr()},removeLegendPayload:{reducer(t,e){var n=rl(t).payload.indexOf(e.payload);n>-1&&t.payload.splice(n,1)},prepare:Fr()}}}),{setLegendSize:F8,setLegendSettings:T0e,addLegendPayload:hY,replaceLegendPayload:fY,removeLegendPayload:mY}=dY.actions,C0e=dY.reducer,k0e=["contextPayload"];function KP(){return KP=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},KP.apply(null,arguments)}function U8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function _g(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){j0e(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 j0e(t,e,n){return(e=P0e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function P0e(t){var e=R0e(t,"string");return typeof e=="symbol"?e:e+""}function R0e(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 D0e(t,e){if(t==null)return{};var n,r,i=O0e(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 O0e(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 L0e(t){return t.value}function I0e(t){var{contextPayload:e}=t,n=D0e(t,k0e),r=dX(e,t.payloadUniqBy,L0e),i=_g(_g({},n),{},{payload:r});return w.isValidElement(t.content)?w.cloneElement(t.content,i):typeof t.content=="function"?w.createElement(t.content,i):w.createElement(jge,i)}function F0e(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}),_g(_g({},u),d)}function U0e(t){var e=Mr();return w.useEffect(()=>{e(T0e(t))},[e,t]),null}function z0e(t){var e=Mr();return w.useEffect(()=>(e(F8(t)),()=>{e(F8({width:0,height:0}))}),[e,t]),null}function B0e(t,e,n,r){return t==="vertical"&&e!=null?{height:e}:t==="horizontal"?{width:n||r}:null}var $0e={align:"center",iconSize:14,inactiveColor:"#ccc",itemSorter:"value",layout:"horizontal",verticalAlign:"bottom"};function bO(t){var e=Kr(t,$0e),n=Sxe(),r=Spe(),i=m0e(),{width:a,height:o,wrapperStyle:l,portal:c}=e,[u,d]=xX([n]),f=fO(),m=mO();if(f==null||m==null)return null;var p=f-(i?.left||0)-(i?.right||0),b=B0e(e.layout,o,a,p),v=c?l:_g(_g({position:"absolute",width:b?.width||a||"auto",height:b?.height||o||"auto"},F0e(l,e,i,f,m,u)),l),x=c??r;if(x==null||n==null)return null;var y=w.createElement("div",{className:"recharts-legend-wrapper",style:v,ref:d},w.createElement(U0e,{layout:e.layout,align:e.align,verticalAlign:e.verticalAlign,itemSorter:e.itemSorter}),!c&&w.createElement(z0e,{width:u.width,height:u.height}),w.createElement(I0e,KP({},e,b,{margin:i,chartWidth:f,chartHeight:m,contextPayload:n})));return Yc.createPortal(y,x)}bO.displayName="Legend";function XP(){return XP=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},XP.apply(null,arguments)}function z8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ob(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?z8(Object(n),!0).forEach(function(r){H0e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):z8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function H0e(t,e,n){return(e=V0e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function V0e(t){var e=G0e(t,"string");return typeof e=="symbol"?e:e+""}function G0e(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 W0e(t){return Array.isArray(t)&&Do(t[0])&&Do(t[1])?t.join(" ~ "):t}var Xm={separator:" : ",contentStyle:{margin:0,padding:10,backgroundColor:"#fff",border:"1px solid #ccc",whiteSpace:"nowrap"},itemStyle:{display:"block",paddingTop:4,paddingBottom:4,color:"#000"},labelStyle:{},accessibilityLayer:!1},q0e=t=>{var{separator:e=Xm.separator,contentStyle:n,itemStyle:r,labelStyle:i=Xm.labelStyle,payload:a,formatter:o,itemSorter:l,wrapperClassName:c,labelClassName:u,label:d,labelFormatter:f,accessibilityLayer:m=Xm.accessibilityLayer}=t,p=()=>{if(a&&a.length){var A={padding:0,margin:0},k=(l?xE(a,l):a).map((C,D)=>{if(C.type==="none")return null;var T=C.formatter||o||W0e,{value:R,name:U}=C,L=R,q=U;if(T){var j=T(R,U,C,D,a);if(Array.isArray(j))[L,q]=j;else if(j!=null)L=j;else return null}var W=ob(ob({},Xm.itemStyle),{},{color:C.color||Xm.itemStyle.color},r);return w.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(D),style:W},Do(q)?w.createElement("span",{className:"recharts-tooltip-item-name"},q):null,Do(q)?w.createElement("span",{className:"recharts-tooltip-item-separator"},e):null,w.createElement("span",{className:"recharts-tooltip-item-value"},L),w.createElement("span",{className:"recharts-tooltip-item-unit"},C.unit||""))});return w.createElement("ul",{className:"recharts-tooltip-item-list",style:A},k)}return null},b=ob(ob({},Xm.contentStyle),n),v=ob({margin:0},i),x=!Hr(d),y=x?d:"",S=Bn("recharts-default-tooltip",c),M=Bn("recharts-tooltip-label",u);x&&f&&a!==void 0&&a!==null&&(y=f(d,a));var N=m?{role:"status","aria-live":"assertive"}:{};return w.createElement("div",XP({className:S,style:b},N),w.createElement("p",{className:M,style:v},w.isValidElement(y)?y:"".concat(y)),p())},lb="recharts-tooltip-wrapper",K0e={visibility:"hidden"};function X0e(t){var{coordinate:e,translateX:n,translateY:r}=t;return Bn(lb,{["".concat(lb,"-right")]:zt(n)&&e&&zt(e.x)&&n>=e.x,["".concat(lb,"-left")]:zt(n)&&e&&zt(e.x)&&n<e.x,["".concat(lb,"-bottom")]:zt(r)&&e&&zt(e.y)&&r>=e.y,["".concat(lb,"-top")]:zt(r)&&e&&zt(e.y)&&r<e.y})}function B8(t){var{allowEscapeViewBox:e,coordinate:n,key:r,offset:i,position:a,reverseDirection:o,tooltipDimension:l,viewBox:c,viewBoxDimension:u}=t;if(a&&zt(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 m=c[r];if(m==null)return 0;if(o[r]){var p=d,b=m;return p<b?Math.max(f,m):Math.max(d,m)}if(u==null)return 0;var v=f+l,x=m+u;return v>x?Math.max(d,m):Math.max(f,m)}function Y0e(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 Z0e(t){var{allowEscapeViewBox:e,coordinate:n,offsetTop:r,offsetLeft:i,position:a,reverseDirection:o,tooltipBox:l,useTranslate3d:c,viewBox:u}=t,d,f,m;return l.height>0&&l.width>0&&n?(f=B8({allowEscapeViewBox:e,coordinate:n,key:"x",offset:i,position:a,reverseDirection:o,tooltipDimension:l.width,viewBox:u,viewBoxDimension:u.width}),m=B8({allowEscapeViewBox:e,coordinate:n,key:"y",offset:r,position:a,reverseDirection:o,tooltipDimension:l.height,viewBox:u,viewBoxDimension:u.height}),d=Y0e({translateX:f,translateY:m,useTranslate3d:c})):d=K0e,{cssProperties:d,cssClasses:X0e({translateX:f,translateY:m,coordinate:n})}}function $8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function w_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?$8(Object(n),!0).forEach(function(r){YP(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):$8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function YP(t,e,n){return(e=Q0e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Q0e(t){var e=J0e(t,"string");return typeof e=="symbol"?e:e+""}function J0e(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 eye extends w.PureComponent{constructor(){super(...arguments),YP(this,"state",{dismissed:!1,dismissedAtCoordinate:{x:0,y:0}}),YP(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:m,viewBox:p,wrapperStyle:b,lastBoundingBox:v,innerRef:x,hasPortalFromProps:y}=this.props,S=typeof u=="number"?u:u.x,M=typeof u=="number"?u:u.y,{cssClasses:N,cssProperties:A}=Z0e({allowEscapeViewBox:n,coordinate:o,offsetLeft:S,offsetTop:M,position:d,reverseDirection:f,tooltipBox:{height:v.height,width:v.width},useTranslate3d:m,viewBox:p}),k=y?{}:w_(w_({transition:c&&e?"transform ".concat(r,"ms ").concat(i):void 0},A),{},{pointerEvents:"none",visibility:!this.state.dismissed&&e&&l?"visible":"hidden",position:"absolute",top:0,left:0}),C=w_(w_({},k),{},{visibility:!this.state.dismissed&&e&&l?"visible":"hidden"},b);return w.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",tabIndex:-1,className:N,style:C,ref:x},a)}}var pY=()=>{var t;return(t=Vt(e=>e.rootProps.accessibilityLayer))!==null&&t!==void 0?t:!0};function ZP(){return ZP=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},ZP.apply(null,arguments)}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 V8(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){tye(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 tye(t,e,n){return(e=nye(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function nye(t){var e=rye(t,"string");return typeof e=="symbol"?e:e+""}function rye(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 G8={curveBasisClosed:$pe,curveBasisOpen:Hpe,curveBasis:Bpe,curveBumpX:Ape,curveBumpY:Tpe,curveLinearClosed:Vpe,curveLinear:pE,curveMonotoneX:Gpe,curveMonotoneY:Wpe,curveNatural:qpe,curveStep:Kpe,curveStepAfter:Ype,curveStepBefore:Xpe},iS=t=>pn(t.x)&&pn(t.y),W8=t=>t.base!=null&&iS(t.base)&&iS(t),cb=t=>t.x,ub=t=>t.y,iye=(t,e)=>{if(typeof t=="function")return t;var n="curve".concat(yy(t));if((n==="curveMonotone"||n==="curveBump")&&e){var r=G8["".concat(n).concat(e==="vertical"?"Y":"X")];if(r)return r}return G8[n]||pE},q8={connectNulls:!1,type:"linear"},aye=t=>{var{type:e=q8.type,points:n=[],baseLine:r,layout:i,connectNulls:a=q8.connectNulls}=t,o=iye(e,i),l=a?n.filter(iS):n;if(Array.isArray(r)){var c,u=n.map((b,v)=>V8(V8({},b),{},{base:r[v]}));i==="vertical"?c=m_().y(ub).x1(cb).x0(b=>b.base.x):c=m_().x(cb).y1(ub).y0(b=>b.base.y);var d=c.defined(W8).curve(o),f=a?u.filter(W8):u;return d(f)}var m;i==="vertical"&&zt(r)?m=m_().y(ub).x1(cb).x0(r):zt(r)?m=m_().x(cb).y1(ub).y0(r):m=BK().x(cb).y(ub);var p=m.defined(iS).curve(o);return p(l)},tg=t=>{var{className:e,points:n,path:r,pathRef:i}=t,a=dh();if((!n||!n.length)&&!r)return null;var o={type:t.type,points:t.points,baseLine:t.baseLine,layout:t.layout||a,connectNulls:t.connectNulls},l=n&&n.length?aye(o):r;return w.createElement("path",ZP({},ts(t),eO(t),{className:Bn("recharts-curve",e),d:l===null?void 0:l,ref:i}))},sye=["x","y","top","left","width","height","className"];function QP(){return QP=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},QP.apply(null,arguments)}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 oye(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){lye(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 lye(t,e,n){return(e=cye(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function cye(t){var e=uye(t,"string");return typeof e=="symbol"?e:e+""}function uye(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 dye(t,e){if(t==null)return{};var n,r,i=hye(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 hye(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 fye=(t,e,n,r,i,a)=>"M".concat(t,",").concat(i,"v").concat(r,"M").concat(a,",").concat(e,"h").concat(n),mye=t=>{var{x:e=0,y:n=0,top:r=0,left:i=0,width:a=0,height:o=0,className:l}=t,c=dye(t,sye),u=oye({x:e,y:n,top:r,left:i,width:a,height:o},c);return!zt(e)||!zt(n)||!zt(a)||!zt(o)||!zt(r)||!zt(i)?null:w.createElement("path",QP({},Aa(u),{className:Bn("recharts-cross",l),d:fye(e,n,a,o,r,i)}))};function pye(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 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){gye(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 gye(t,e,n){return(e=xye(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function xye(t){var e=bye(t,"string");return typeof e=="symbol"?e:e+""}function bye(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 yye=t=>t.replace(/([A-Z])/g,e=>"-".concat(e.toLowerCase())),gY=(t,e,n)=>t.map(r=>"".concat(yye(r)," ").concat(e,"ms ").concat(n)).join(","),vye=(t,e)=>[Object.keys(t),Object.keys(e)].reduce((n,r)=>n.filter(i=>r.includes(i))),I0=(t,e)=>Object.keys(e).reduce((n,r)=>Y8(Y8({},n),{},{[r]:t(r,e[r])}),{});function Z8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Ri(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Z8(Object(n),!0).forEach(function(r){_ye(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Z8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function _ye(t,e,n){return(e=wye(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function wye(t){var e=Sye(t,"string");return typeof e=="symbol"?e:e+""}function Sye(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 aS=(t,e,n)=>t+(e-t)*n,JP=t=>{var{from:e,to:n}=t;return e!==n},xY=(t,e,n)=>{var r=I0((i,a)=>{if(JP(a)){var[o,l]=t(a.from,a.to,a.velocity);return Ri(Ri({},a),{},{from:o,velocity:l})}return a},e);return n<1?I0((i,a)=>JP(a)&&r[i]!=null?Ri(Ri({},a),{},{velocity:aS(a.velocity,r[i].velocity,n),from:aS(a.from,r[i].from,n)}):a,e):xY(t,r,n-1)};function Mye(t,e,n,r,i,a){var o,l=r.reduce((m,p)=>Ri(Ri({},m),{},{[p]:{from:t[p],velocity:0,to:e[p]}}),{}),c=()=>I0((m,p)=>p.from,l),u=()=>!Object.values(l).filter(JP).length,d=null,f=m=>{o||(o=m);var p=m-o,b=p/n.dt;l=xY(n,l,b),i(Ri(Ri(Ri({},t),e),c())),o=m,u()||(d=a.setTimeout(f))};return()=>(d=a.setTimeout(f),()=>{var m;(m=d)===null||m===void 0||m()})}function Eye(t,e,n,r,i,a,o){var l=null,c=i.reduce((f,m)=>{var p=t[m],b=e[m];return p==null||b==null?f:Ri(Ri({},f),{},{[m]:[p,b]})},{}),u,d=f=>{u||(u=f);var m=(f-u)/r,p=I0((v,x)=>aS(...x,n(m)),c);if(a(Ri(Ri(Ri({},t),e),p)),m<1)l=o.setTimeout(d);else{var b=I0((v,x)=>aS(...x,n(1)),c);a(Ri(Ri(Ri({},t),e),b))}};return()=>(l=o.setTimeout(d),()=>{var f;(f=l)===null||f===void 0||f()})}const Nye=(t,e,n,r,i,a)=>{var o=vye(t,e);return n==null?()=>(i(Ri(Ri({},t),e)),()=>{}):n.isStepper===!0?Mye(t,e,n,o,i,a):Eye(t,e,n,r,o,i,a)};var sS=1e-4,bY=(t,e)=>[0,3*t,3*e-6*t,3*t-3*e+1],yY=(t,e)=>t.map((n,r)=>n*e**r).reduce((n,r)=>n+r),Q8=(t,e)=>n=>{var r=bY(t,e);return yY(r,n)},Aye=(t,e)=>n=>{var r=bY(t,e),i=[...r.map((a,o)=>a*o).slice(1),0];return yY(i,n)},Tye=t=>{var e,n=t.split("(");if(n.length!==2||n[0]!=="cubic-bezier")return null;var r=(e=n[1])===null||e===void 0||(e=e.split(")")[0])===null||e===void 0?void 0:e.split(",");if(r==null||r.length!==4)return null;var i=r.map(a=>parseFloat(a));return[i[0],i[1],i[2],i[3]]},Cye=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=Tye(n[0]);if(i)return i}}return n.length===4?n:[0,0,1,1]},kye=(t,e,n,r)=>{var i=Q8(t,n),a=Q8(e,r),o=Aye(t,n),l=u=>u>1?1:u<0?0:u,c=u=>{for(var d=u>1?1:u,f=d,m=0;m<8;++m){var p=i(f)-d,b=o(f);if(Math.abs(p-d)<sS||b<sS)return a(f);f=l(f-p/b)}return a(f)};return c.isStepper=!1,c},J8=function(){return kye(...Cye(...arguments))},jye=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,m=c*i/1e3+o;return Math.abs(m-l)<sS&&Math.abs(f)<sS?[l,0]:[m,f]};return a.isStepper=!0,a.dt=i,a},Pye=t=>{if(typeof t=="string")switch(t){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return J8(t);case"spring":return jye();default:if(t.split("(")[0]==="cubic-bezier")return J8(t)}return typeof t=="function"?t:null};function Rye(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 Dye{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 Oye(){return Rye(new Dye)}var Lye=w.createContext(Oye);function Iye(t,e){var n=w.useContext(Lye);return w.useMemo(()=>e??n(t),[t,e,n])}var Fye=()=>!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout),Ay={isSsr:Fye()},Uye={begin:0,duration:1e3,easing:"ease",isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},e6={t:0},dC={t:1};function Zg(t){var e=Kr(t,Uye),{isActive:n,canBegin:r,duration:i,easing:a,begin:o,onAnimationEnd:l,onAnimationStart:c,children:u}=e,d=n==="auto"?!Ay.isSsr:n,f=Iye(e.animationId,e.animationManager),[m,p]=w.useState(d?e6:dC),b=w.useRef(null);return w.useEffect(()=>{d||p(dC)},[d]),w.useEffect(()=>{if(!d||!r)return ch;var v=Nye(e6,dC,Pye(a),i,p,f.getTimeoutController()),x=()=>{b.current=v()};return f.start([c,o,x,i,l]),()=>{f.stop(),b.current&&b.current(),l()}},[d,r,i,a,o,c,l,f]),u(m.t)}function Qg(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"animation-",n=w.useRef(k0(e)),r=w.useRef(t);return r.current!==t&&(n.current=k0(e),r.current=t),n.current}var zye=["radius"],Bye=["radius"],t6,n6,r6,i6,a6,s6,o6,l6,c6,u6;function d6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function h6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?d6(Object(n),!0).forEach(function(r){$ye(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):d6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function $ye(t,e,n){return(e=Hye(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Hye(t){var e=Vye(t,"string");return typeof e=="symbol"?e:e+""}function Vye(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 oS(){return oS=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},oS.apply(null,arguments)}function f6(t,e){if(t==null)return{};var n,r,i=Gye(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 Gye(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 El(t,e){return e||(e=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}var m6=(t,e,n,r,i)=>{var a=Td(n),o=Td(r),l=Math.min(Math.abs(a)/2,Math.abs(o)/2),c=o>=0?1:-1,u=a>=0?1:-1,d=o>=0&&a>=0||o<0&&a<0?1:0,f;if(l>0&&Array.isArray(i)){for(var m=[0,0,0,0],p=0,b=4;p<b;p++){var v,x=(v=i[p])!==null&&v!==void 0?v:0;m[p]=x>l?l:x}f=ni(t6||(t6=El(["M",",",""])),t,e+c*m[0]),m[0]>0&&(f+=ni(n6||(n6=El(["A ",",",",0,0,",",",",",""])),m[0],m[0],d,t+u*m[0],e)),f+=ni(r6||(r6=El(["L ",",",""])),t+n-u*m[1],e),m[1]>0&&(f+=ni(i6||(i6=El(["A ",",",",0,0,",`,
  17. `,",",""])),m[1],m[1],d,t+n,e+c*m[1])),f+=ni(a6||(a6=El(["L ",",",""])),t+n,e+r-c*m[2]),m[2]>0&&(f+=ni(s6||(s6=El(["A ",",",",0,0,",`,
  18. `,",",""])),m[2],m[2],d,t+n-u*m[2],e+r)),f+=ni(o6||(o6=El(["L ",",",""])),t+u*m[3],e+r),m[3]>0&&(f+=ni(l6||(l6=El(["A ",",",",0,0,",`,
  19. `,",",""])),m[3],m[3],d,t,e+r-c*m[3])),f+="Z"}else if(l>0&&i===+i&&i>0){var y=Math.min(l,i);f=ni(c6||(c6=El(["M ",",",`
  20. A `,",",",0,0,",",",",",`
  21. L `,",",`
  22. A `,",",",0,0,",",",",",`
  23. L `,",",`
  24. A `,",",",0,0,",",",",",`
  25. L `,",",`
  26. A `,",",",0,0,",",",","," Z"])),t,e+c*y,y,y,d,t+u*y,e,t+n-u*y,e,y,y,d,t+n,e+c*y,t+n,e+r-c*y,y,y,d,t+n-u*y,e+r,t+u*y,e+r,y,y,d,t,e+r-c*y)}else f=ni(u6||(u6=El(["M ",","," h "," v "," h "," Z"])),t,e,n,r,-n);return f},p6={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},vY=t=>{var e=Kr(t,p6),n=w.useRef(null),[r,i]=w.useState(-1);w.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:m,animationBegin:p,isAnimationActive:b,isUpdateAnimationActive:v}=e,x=w.useRef(l),y=w.useRef(c),S=w.useRef(a),M=w.useRef(o),N=w.useMemo(()=>({x:a,y:o,width:l,height:c,radius:u}),[a,o,l,c,u]),A=Qg(N,"rectangle-");if(a!==+a||o!==+o||l!==+l||c!==+c||l===0||c===0)return null;var k=Bn("recharts-rectangle",d);if(!v){var C=Aa(e),{radius:D}=C,T=f6(C,zye);return w.createElement("path",oS({},T,{x:Td(a),y:Td(o),width:Td(l),height:Td(c),radius:typeof u=="number"?u:void 0,className:k,d:m6(a,o,l,c,u)}))}var R=x.current,U=y.current,L=S.current,q=M.current,j="0px ".concat(r===-1?1:r,"px"),W="".concat(r,"px 0px"),K=gY(["strokeDasharray"],m,typeof f=="string"?f:p6.animationEasing);return w.createElement(Zg,{animationId:A,key:A,canBegin:r>0,duration:m,easing:f,isActive:v,begin:p},V=>{var J=nr(R,l,V),ne=nr(U,c,V),te=nr(L,a,V),z=nr(q,o,V);n.current&&(x.current=J,y.current=ne,S.current=te,M.current=z);var H;b?V>0?H={transition:K,strokeDasharray:W}:H={strokeDasharray:j}:H={strokeDasharray:W};var Z=Aa(e),{radius:ee}=Z,he=f6(Z,Bye);return w.createElement("path",oS({},he,{radius:typeof u=="number"?u:void 0,className:k,d:m6(te,z,J,ne,u),ref:n,style:h6(h6({},H),e.style)}))})};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 x6(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){Wye(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 Wye(t,e,n){return(e=qye(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function qye(t){var e=Kye(t,"string");return typeof e=="symbol"?e:e+""}function Kye(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 lS=Math.PI/180,Xye=t=>t*180/Math.PI,Ei=(t,e,n,r)=>({x:t+Math.cos(-lS*r)*n,y:e+Math.sin(-lS*r)*n}),_Y=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},Yye=(t,e)=>{var{x:n,y:r}=t,{x:i,y:a}=e;return Math.sqrt((n-i)**2+(r-a)**2)},Zye=(t,e)=>{var{x:n,y:r}=t,{cx:i,cy:a}=e,o=Yye({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:Xye(c),angleInRadian:c}},Qye=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}},Jye=(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},eve=(t,e)=>{var{chartX:n,chartY:r}=t,{radius:i,angle:a}=Zye({x:n,y:r},e),{innerRadius:o,outerRadius:l}=e;if(i<o||i>l||i===0)return null;var{startAngle:c,endAngle:u}=Qye(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?x6(x6({},e),{},{radius:i,angle:Jye(d,e)}):null};function wY(t){var{cx:e,cy:n,radius:r,startAngle:i,endAngle:a}=t,o=Ei(e,n,r,i),l=Ei(e,n,r,a);return{points:[o,l],cx:e,cy:n,radius:r,startAngle:i,endAngle:a}}var b6,y6,v6,_6,w6,S6,M6;function e3(){return e3=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},e3.apply(null,arguments)}function uf(t,e){return e||(e=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}var tve=(t,e)=>{var n=ea(e-t),r=Math.min(Math.abs(e-t),359.999);return n*r},S_=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)/lS,f=c?i:i+a*d,m=Ei(e,n,u,f),p=Ei(e,n,r,f),b=c?i-a*d:i,v=Ei(e,n,u*Math.cos(d*lS),b);return{center:m,circleTangency:p,lineTangency:v,theta:d}},SY=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:a,endAngle:o}=t,l=tve(a,o),c=a+l,u=Ei(e,n,i,a),d=Ei(e,n,i,c),f=ni(b6||(b6=uf(["M ",",",`
  27. A `,",",`,0,
  28. `,",",`,
  29. `,",",`
  30. `])),u.x,u.y,i,i,+(Math.abs(l)>180),+(a>c),d.x,d.y);if(r>0){var m=Ei(e,n,r,a),p=Ei(e,n,r,c);f+=ni(y6||(y6=uf(["L ",",",`
  31. A `,",",`,0,
  32. `,",",`,
  33. `,","," Z"])),p.x,p.y,r,r,+(Math.abs(l)>180),+(a<=c),m.x,m.y)}else f+=ni(v6||(v6=uf(["L ",","," Z"])),e,n);return f},nve=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,cornerRadius:a,forceCornerRadius:o,cornerIsExternal:l,startAngle:c,endAngle:u}=t,d=ea(u-c),{circleTangency:f,lineTangency:m,theta:p}=S_({cx:e,cy:n,radius:i,angle:c,sign:d,cornerRadius:a,cornerIsExternal:l}),{circleTangency:b,lineTangency:v,theta:x}=S_({cx:e,cy:n,radius:i,angle:u,sign:-d,cornerRadius:a,cornerIsExternal:l}),y=l?Math.abs(c-u):Math.abs(c-u)-p-x;if(y<0)return o?ni(_6||(_6=uf(["M ",",",`
  34. a`,",",",0,0,1,",`,0
  35. a`,",",",0,0,1,",`,0
  36. `])),m.x,m.y,a,a,a*2,a,a,-a*2):SY({cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:c,endAngle:u});var S=ni(w6||(w6=uf(["M ",",",`
  37. A`,",",",0,0,",",",",",`
  38. A`,",",",0,",",",",",",",`
  39. A`,",",",0,0,",",",",",`
  40. `])),m.x,m.y,a,a,+(d<0),f.x,f.y,i,i,+(y>180),+(d<0),b.x,b.y,a,a,+(d<0),v.x,v.y);if(r>0){var{circleTangency:M,lineTangency:N,theta:A}=S_({cx:e,cy:n,radius:r,angle:c,sign:d,isExternal:!0,cornerRadius:a,cornerIsExternal:l}),{circleTangency:k,lineTangency:C,theta:D}=S_({cx:e,cy:n,radius:r,angle:u,sign:-d,isExternal:!0,cornerRadius:a,cornerIsExternal:l}),T=l?Math.abs(c-u):Math.abs(c-u)-A-D;if(T<0&&a===0)return"".concat(S,"L").concat(e,",").concat(n,"Z");S+=ni(S6||(S6=uf(["L",",",`
  41. A`,",",",0,0,",",",",",`
  42. A`,",",",0,",",",",",",",`
  43. A`,",",",0,0,",",",",","Z"])),C.x,C.y,a,a,+(d<0),k.x,k.y,r,r,+(T>180),+(d>0),M.x,M.y,a,a,+(d<0),N.x,N.y)}else S+=ni(M6||(M6=uf(["L",",","Z"])),e,n);return S},rve={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},MY=t=>{var e=Kr(t,rve),{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 m=Bn("recharts-sector",f),p=a-i,b=Ba(o,p,0,!0),v;return b>0&&Math.abs(u-d)<360?v=nve({cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:Math.min(b,p/2),forceCornerRadius:l,cornerIsExternal:c,startAngle:u,endAngle:d}):v=SY({cx:n,cy:r,innerRadius:i,outerRadius:a,startAngle:u,endAngle:d}),w.createElement("path",e3({},Aa(e),{className:m,d:v}))};function ive(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(nX(e)){if(t==="centric"){var{cx:r,cy:i,innerRadius:a,outerRadius:o,angle:l}=e,c=Ei(r,i,a,l),u=Ei(r,i,o,l);return[{x:c.x,y:c.y},{x:u.x,y:u.y}]}return wY(e)}}var hC={},fC={},mC={},E6;function ave(){return E6||(E6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=mX();function n(r){return e.isSymbol(r)?NaN:Number(r)}t.toNumber=n})(mC)),mC}var N6;function sve(){return N6||(N6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=ave();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})(fC)),fC}var A6;function ove(){return A6||(A6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=pX(),n=sve();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})(hC)),hC}var pC,T6;function lve(){return T6||(T6=1,pC=ove().range),pC}var cve=lve();const EY=ml(cve);function Ud(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function uve(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function yO(t){let e,n,r;t.length!==2?(e=Ud,n=(l,c)=>Ud(t(l),c),r=(l,c)=>t(l)-c):(e=t===Ud||t===uve?t:dve,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 dve(){return 0}function NY(t){return t===null?NaN:+t}function*hve(t,e){for(let n of t)n!=null&&(n=+n)>=n&&(yield n)}const fve=yO(Ud),Ty=fve.right;yO(NY).center;class C6 extends Map{constructor(e,n=gve){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(k6(this,e))}has(e){return super.has(k6(this,e))}set(e,n){return super.set(mve(this,e),n)}delete(e){return super.delete(pve(this,e))}}function k6({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function mve({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}function pve({_intern:t,_key:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}function gve(t){return t!==null&&typeof t=="object"?t.valueOf():t}function xve(t=Ud){if(t===Ud)return AY;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 AY(t,e){return(t==null||!(t>=t))-(e==null||!(e>=e))||(t<e?-1:t>e?1:0)}const bve=Math.sqrt(50),yve=Math.sqrt(10),vve=Math.sqrt(2);function cS(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>=bve?10:a>=yve?5:a>=vve?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?cS(t,e,n*2):[l,c,u]}function t3(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?cS(e,t,n):cS(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 n3(t,e,n){return e=+e,t=+t,n=+n,cS(t,e,n)[2]}function r3(t,e,n){e=+e,t=+t,n=+n;const r=e<t,i=r?n3(e,t,n):n3(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}function j6(t,e){let n;for(const r of t)r!=null&&(n<r||n===void 0&&r>=r)&&(n=r);return n}function P6(t,e){let n;for(const r of t)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);return n}function TY(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?AY:xve(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),m=.5*Math.sqrt(d*f*(c-f)/c)*(u-c/2<0?-1:1),p=Math.max(n,Math.floor(e-u*f/c+m)),b=Math.min(r,Math.floor(e+(c-u)*f/c+m));TY(t,e,p,b,i)}const a=t[e];let o=n,l=r;for(db(t,n,e),i(t[r],a)>0&&db(t,n,r);o<l;){for(db(t,o,l),++o,--l;i(t[o],a)<0;)++o;for(;i(t[l],a)>0;)--l}i(t[n],a)===0?db(t,n,l):(++l,db(t,l,r)),l<=e&&(n=l+1),e<=l&&(r=l-1)}return t}function db(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function _ve(t,e,n){if(t=Float64Array.from(hve(t)),!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return P6(t);if(e>=1)return j6(t);var r,i=(r-1)*e,a=Math.floor(i),o=j6(TY(t,a).subarray(0,a+1)),l=P6(t.subarray(a+1));return o+(l-o)*(i-a)}}function wve(t,e,n=NY){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 Sve(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 Fo(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function Eu(t,e){switch(arguments.length){case 0:break;case 1:{typeof t=="function"?this.interpolator(t):this.range(t);break}default:{this.domain(t),typeof e=="function"?this.interpolator(e):this.range(e);break}}return this}const i3=Symbol("implicit");function vO(){var t=new C6,e=[],n=[],r=i3;function i(a){let o=t.get(a);if(o===void 0){if(r!==i3)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 C6;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 vO(e,n).unknown(r)},Fo.apply(i,arguments),i}function _O(){var t=vO().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 m=e().length,p=i<r,b=p?i:r,v=p?r:i;a=(v-b)/Math.max(1,m-c+u*2),l&&(a=Math.floor(a)),b+=(v-b-a*(m-c))*d,o=a*(1-c),l&&(b=Math.round(b),o=Math.round(o));var x=Sve(m).map(function(y){return b+a*y});return n(p?x.reverse():x)}return t.domain=function(m){return arguments.length?(e(m),f()):e()},t.range=function(m){return arguments.length?([r,i]=m,r=+r,i=+i,f()):[r,i]},t.rangeRound=function(m){return[r,i]=m,r=+r,i=+i,l=!0,f()},t.bandwidth=function(){return o},t.step=function(){return a},t.round=function(m){return arguments.length?(l=!!m,f()):l},t.padding=function(m){return arguments.length?(c=Math.min(1,u=+m),f()):c},t.paddingInner=function(m){return arguments.length?(c=Math.min(1,m),f()):c},t.paddingOuter=function(m){return arguments.length?(u=+m,f()):u},t.align=function(m){return arguments.length?(d=Math.max(0,Math.min(1,m)),f()):d},t.copy=function(){return _O(e(),[r,i]).round(l).paddingInner(c).paddingOuter(u).align(d)},Fo.apply(f(),arguments)}function CY(t){var e=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,delete t.paddingOuter,t.copy=function(){return CY(e())},t}function Mve(){return CY(_O.apply(null,arguments).paddingInner(1))}function wO(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function kY(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function Cy(){}var F0=.7,uS=1/F0,ng="\\s*([+-]?\\d+)\\s*",U0="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Wl="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Eve=/^#([0-9a-f]{3,8})$/,Nve=new RegExp(`^rgb\\(${ng},${ng},${ng}\\)$`),Ave=new RegExp(`^rgb\\(${Wl},${Wl},${Wl}\\)$`),Tve=new RegExp(`^rgba\\(${ng},${ng},${ng},${U0}\\)$`),Cve=new RegExp(`^rgba\\(${Wl},${Wl},${Wl},${U0}\\)$`),kve=new RegExp(`^hsl\\(${U0},${Wl},${Wl}\\)$`),jve=new RegExp(`^hsla\\(${U0},${Wl},${Wl},${U0}\\)$`),R6={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};wO(Cy,z0,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:D6,formatHex:D6,formatHex8:Pve,formatHsl:Rve,formatRgb:O6,toString:O6});function D6(){return this.rgb().formatHex()}function Pve(){return this.rgb().formatHex8()}function Rve(){return jY(this).formatHsl()}function O6(){return this.rgb().formatRgb()}function z0(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=Eve.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?L6(e):n===3?new vs(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?M_(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?M_(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=Nve.exec(t))?new vs(e[1],e[2],e[3],1):(e=Ave.exec(t))?new vs(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Tve.exec(t))?M_(e[1],e[2],e[3],e[4]):(e=Cve.exec(t))?M_(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=kve.exec(t))?U6(e[1],e[2]/100,e[3]/100,1):(e=jve.exec(t))?U6(e[1],e[2]/100,e[3]/100,e[4]):R6.hasOwnProperty(t)?L6(R6[t]):t==="transparent"?new vs(NaN,NaN,NaN,0):null}function L6(t){return new vs(t>>16&255,t>>8&255,t&255,1)}function M_(t,e,n,r){return r<=0&&(t=e=n=NaN),new vs(t,e,n,r)}function Dve(t){return t instanceof Cy||(t=z0(t)),t?(t=t.rgb(),new vs(t.r,t.g,t.b,t.opacity)):new vs}function a3(t,e,n,r){return arguments.length===1?Dve(t):new vs(t,e,n,r??1)}function vs(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}wO(vs,a3,kY(Cy,{brighter(t){return t=t==null?uS:Math.pow(uS,t),new vs(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?F0:Math.pow(F0,t),new vs(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new vs(Sf(this.r),Sf(this.g),Sf(this.b),dS(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:I6,formatHex:I6,formatHex8:Ove,formatRgb:F6,toString:F6}));function I6(){return`#${df(this.r)}${df(this.g)}${df(this.b)}`}function Ove(){return`#${df(this.r)}${df(this.g)}${df(this.b)}${df((isNaN(this.opacity)?1:this.opacity)*255)}`}function F6(){const t=dS(this.opacity);return`${t===1?"rgb(":"rgba("}${Sf(this.r)}, ${Sf(this.g)}, ${Sf(this.b)}${t===1?")":`, ${t})`}`}function dS(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Sf(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function df(t){return t=Sf(t),(t<16?"0":"")+t.toString(16)}function U6(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Zo(t,e,n,r)}function jY(t){if(t instanceof Zo)return new Zo(t.h,t.s,t.l,t.opacity);if(t instanceof Cy||(t=z0(t)),!t)return new Zo;if(t instanceof Zo)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 Zo(o,l,c,t.opacity)}function Lve(t,e,n,r){return arguments.length===1?jY(t):new Zo(t,e,n,r??1)}function Zo(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}wO(Zo,Lve,kY(Cy,{brighter(t){return t=t==null?uS:Math.pow(uS,t),new Zo(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?F0:Math.pow(F0,t),new Zo(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 vs(gC(t>=240?t-240:t+120,i,r),gC(t,i,r),gC(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new Zo(z6(this.h),E_(this.s),E_(this.l),dS(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=dS(this.opacity);return`${t===1?"hsl(":"hsla("}${z6(this.h)}, ${E_(this.s)*100}%, ${E_(this.l)*100}%${t===1?")":`, ${t})`}`}}));function z6(t){return t=(t||0)%360,t<0?t+360:t}function E_(t){return Math.max(0,Math.min(1,t||0))}function gC(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 SO=t=>()=>t;function Ive(t,e){return function(n){return t+n*e}}function Fve(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 Uve(t){return(t=+t)==1?PY:function(e,n){return n-e?Fve(e,n,t):SO(isNaN(e)?n:e)}}function PY(t,e){var n=e-t;return n?Ive(t,n):SO(isNaN(t)?e:t)}const B6=(function t(e){var n=Uve(e);function r(i,a){var o=n((i=a3(i)).r,(a=a3(a)).r),l=n(i.g,a.g),c=n(i.b,a.b),u=PY(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 zve(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 Bve(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function $ve(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]=Jg(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 Hve(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function hS(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function Vve(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]=Jg(t[i],e[i]):r[i]=e[i];return function(a){for(i in n)r[i]=n[i](a);return r}}var s3=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,xC=new RegExp(s3.source,"g");function Gve(t){return function(){return t}}function Wve(t){return function(e){return t(e)+""}}function qve(t,e){var n=s3.lastIndex=xC.lastIndex=0,r,i,a,o=-1,l=[],c=[];for(t=t+"",e=e+"";(r=s3.exec(t))&&(i=xC.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:hS(r,i)})),n=xC.lastIndex;return n<e.length&&(a=e.slice(n),l[o]?l[o]+=a:l[++o]=a),l.length<2?c[0]?Wve(c[0].x):Gve(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 Jg(t,e){var n=typeof e,r;return e==null||n==="boolean"?SO(e):(n==="number"?hS:n==="string"?(r=z0(e))?(e=r,B6):qve:e instanceof z0?B6:e instanceof Date?Hve:Bve(e)?zve:Array.isArray(e)?$ve:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?Vve:hS)(t,e)}function MO(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}function Kve(t,e){e===void 0&&(e=t,t=Jg);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 Xve(t){return function(){return t}}function fS(t){return+t}var $6=[0,1];function Za(t){return t}function o3(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:Xve(isNaN(e)?NaN:.5)}function Yve(t,e){var n;return t>e&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function Zve(t,e,n){var r=t[0],i=t[1],a=e[0],o=e[1];return i<r?(r=o3(i,r),a=n(o,a)):(r=o3(r,i),a=n(a,o)),function(l){return a(r(l))}}function Qve(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]=o3(t[o],t[o+1]),a[o]=n(e[o],e[o+1]);return function(l){var c=Ty(t,l,1,r)-1;return a[c](i[c](l))}}function ky(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function DE(){var t=$6,e=$6,n=Jg,r,i,a,o=Za,l,c,u;function d(){var m=Math.min(t.length,e.length);return o!==Za&&(o=Yve(t[0],t[m-1])),l=m>2?Qve:Zve,c=u=null,f}function f(m){return m==null||isNaN(m=+m)?a:(c||(c=l(t.map(r),e,n)))(r(o(m)))}return f.invert=function(m){return o(i((u||(u=l(e,t.map(r),hS)))(m)))},f.domain=function(m){return arguments.length?(t=Array.from(m,fS),d()):t.slice()},f.range=function(m){return arguments.length?(e=Array.from(m),d()):e.slice()},f.rangeRound=function(m){return e=Array.from(m),n=MO,d()},f.clamp=function(m){return arguments.length?(o=m?!0:Za,d()):o!==Za},f.interpolate=function(m){return arguments.length?(n=m,d()):n},f.unknown=function(m){return arguments.length?(a=m,f):a},function(m,p){return r=m,i=p,d()}}function EO(){return DE()(Za,Za)}function Jve(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function mS(t,e){if(!isFinite(t)||t===0)return null;var n=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"),r=t.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+t.slice(n+1)]}function wg(t){return t=mS(Math.abs(t)),t?t[1]:NaN}function e_e(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 t_e(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var n_e=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function B0(t){if(!(e=n_e.exec(t)))throw new Error("invalid format: "+t);var e;return new NO({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]})}B0.prototype=NO.prototype;function NO(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+""}NO.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 r_e(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 pS;function i_e(t,e){var n=mS(t,e);if(!n)return pS=void 0,t.toPrecision(e);var r=n[0],i=n[1],a=i-(pS=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")+mS(t,Math.max(0,e+a-1))[0]}function H6(t,e){var n=mS(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 V6={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:Jve,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)=>H6(t*100,e),r:H6,s:i_e,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function G6(t){return t}var W6=Array.prototype.map,q6=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function a_e(t){var e=t.grouping===void 0||t.thousands===void 0?G6:e_e(W6.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?G6:t_e(W6.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,m){f=B0(f);var p=f.fill,b=f.align,v=f.sign,x=f.symbol,y=f.zero,S=f.width,M=f.comma,N=f.precision,A=f.trim,k=f.type;k==="n"?(M=!0,k="g"):V6[k]||(N===void 0&&(N=12),A=!0,k="g"),(y||p==="0"&&b==="=")&&(y=!0,p="0",b="=");var C=(m&&m.prefix!==void 0?m.prefix:"")+(x==="$"?n:x==="#"&&/[boxX]/.test(k)?"0"+k.toLowerCase():""),D=(x==="$"?r:/[%p]/.test(k)?o:"")+(m&&m.suffix!==void 0?m.suffix:""),T=V6[k],R=/[defgprs%]/.test(k);N=N===void 0?6:/[gprs]/.test(k)?Math.max(1,Math.min(21,N)):Math.max(0,Math.min(20,N));function U(L){var q=C,j=D,W,K,V;if(k==="c")j=T(L)+j,L="";else{L=+L;var J=L<0||1/L<0;if(L=isNaN(L)?c:T(Math.abs(L),N),A&&(L=r_e(L)),J&&+L==0&&v!=="+"&&(J=!1),q=(J?v==="("?v:l:v==="-"||v==="("?"":v)+q,j=(k==="s"&&!isNaN(L)&&pS!==void 0?q6[8+pS/3]:"")+j+(J&&v==="("?")":""),R){for(W=-1,K=L.length;++W<K;)if(V=L.charCodeAt(W),48>V||V>57){j=(V===46?i+L.slice(W+1):L.slice(W))+j,L=L.slice(0,W);break}}}M&&!y&&(L=e(L,1/0));var ne=q.length+L.length+j.length,te=ne<S?new Array(S-ne+1).join(p):"";switch(M&&y&&(L=e(te+L,te.length?S-j.length:1/0),te=""),b){case"<":L=q+L+j+te;break;case"=":L=q+te+L+j;break;case"^":L=te.slice(0,ne=te.length>>1)+q+L+j+te.slice(ne);break;default:L=te+q+L+j;break}return a(L)}return U.toString=function(){return f+""},U}function d(f,m){var p=Math.max(-8,Math.min(8,Math.floor(wg(m)/3)))*3,b=Math.pow(10,-p),v=u((f=B0(f),f.type="f",f),{suffix:q6[8+p/3]});return function(x){return v(b*x)}}return{format:u,formatPrefix:d}}var N_,AO,RY;s_e({thousands:",",grouping:[3],currency:["$",""]});function s_e(t){return N_=a_e(t),AO=N_.format,RY=N_.formatPrefix,N_}function o_e(t){return Math.max(0,-wg(Math.abs(t)))}function l_e(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(wg(e)/3)))*3-wg(Math.abs(t)))}function c_e(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,wg(e)-wg(t))+1}function DY(t,e,n,r){var i=r3(t,e,n),a;switch(r=B0(r??",f"),r.type){case"s":{var o=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(a=l_e(i,o))&&(r.precision=a),RY(r,o)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(a=c_e(i,Math.max(Math.abs(t),Math.abs(e))))&&(r.precision=a-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(a=o_e(i))&&(r.precision=a-(r.type==="%")*2);break}}return AO(r)}function hh(t){var e=t.domain;return t.ticks=function(n){var r=e();return t3(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var i=e();return DY(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=n3(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 OY(){var t=EO();return t.copy=function(){return ky(t,OY())},Fo.apply(t,arguments),hh(t)}function LY(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,fS),n):t.slice()},n.unknown=function(r){return arguments.length?(e=r,n):e},n.copy=function(){return LY(t).unknown(e)},t=arguments.length?Array.from(t,fS):[0,1],hh(n)}function IY(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 K6(t){return Math.log(t)}function X6(t){return Math.exp(t)}function u_e(t){return-Math.log(-t)}function d_e(t){return-Math.exp(-t)}function h_e(t){return isFinite(t)?+("1e"+t):t<0?0:t}function f_e(t){return t===10?h_e:t===Math.E?Math.exp:e=>Math.pow(t,e)}function m_e(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 Y6(t){return(e,n)=>-t(-e,n)}function TO(t){const e=t(K6,X6),n=e.domain;let r=10,i,a;function o(){return i=m_e(r),a=f_e(r),n()[0]<0?(i=Y6(i),a=Y6(a),t(u_e,d_e)):t(K6,X6),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 m=i(u),p=i(d),b,v;const x=l==null?10:+l;let y=[];if(!(r%1)&&p-m<x){if(m=Math.floor(m),p=Math.ceil(p),u>0){for(;m<=p;++m)for(b=1;b<r;++b)if(v=m<0?b/a(-m):b*a(m),!(v<u)){if(v>d)break;y.push(v)}}else for(;m<=p;++m)for(b=r-1;b>=1;--b)if(v=m>0?b/a(-m):b*a(m),!(v<u)){if(v>d)break;y.push(v)}y.length*2<x&&(y=t3(u,d,x))}else y=t3(m,p,Math.min(p-m,x)).map(a);return f?y.reverse():y},e.tickFormat=(l,c)=>{if(l==null&&(l=10),c==null&&(c=r===10?"s":","),typeof c!="function"&&(!(r%1)&&(c=B0(c)).precision==null&&(c.trim=!0),c=AO(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(IY(n(),{floor:l=>a(Math.floor(i(l))),ceil:l=>a(Math.ceil(i(l)))})),e}function FY(){const t=TO(DE()).domain([1,10]);return t.copy=()=>ky(t,FY()).base(t.base()),Fo.apply(t,arguments),t}function Z6(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function Q6(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function CO(t){var e=1,n=t(Z6(e),Q6(e));return n.constant=function(r){return arguments.length?t(Z6(e=+r),Q6(e)):e},hh(n)}function UY(){var t=CO(DE());return t.copy=function(){return ky(t,UY()).constant(t.constant())},Fo.apply(t,arguments)}function J6(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function p_e(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function g_e(t){return t<0?-t*t:t*t}function kO(t){var e=t(Za,Za),n=1;function r(){return n===1?t(Za,Za):n===.5?t(p_e,g_e):t(J6(n),J6(1/n))}return e.exponent=function(i){return arguments.length?(n=+i,r()):n},hh(e)}function jO(){var t=kO(DE());return t.copy=function(){return ky(t,jO()).exponent(t.exponent())},Fo.apply(t,arguments),t}function x_e(){return jO.apply(null,arguments).exponent(.5)}function e$(t){return Math.sign(t)*t*t}function b_e(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function zY(){var t=EO(),e=[0,1],n=!1,r;function i(a){var o=b_e(t(a));return isNaN(o)?r:n?Math.round(o):o}return i.invert=function(a){return t.invert(e$(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,fS)).map(e$)),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 zY(t.domain(),e).round(n).clamp(t.clamp()).unknown(r)},Fo.apply(i,arguments),hh(i)}function BY(){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]=wve(t,o/l);return a}function a(o){return o==null||isNaN(o=+o)?r:e[Ty(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(Ud),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 BY().domain(t).range(e).unknown(r)},Fo.apply(a,arguments)}function $Y(){var t=0,e=1,n=1,r=[.5],i=[0,1],a;function o(c){return c!=null&&c<=c?i[Ty(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 $Y().domain([t,e]).range(i).unknown(a)},Fo.apply(hh(o),arguments)}function HY(){var t=[.5],e=[0,1],n,r=1;function i(a){return a!=null&&a<=a?e[Ty(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 HY().domain(t).range(e).unknown(n)},Fo.apply(i,arguments)}const bC=new Date,yC=new Date;function $i(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=>$i(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)=>(bC.setTime(+a),yC.setTime(+o),t(bC),t(yC),Math.floor(n(bC,yC))),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 gS=$i(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);gS.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?$i(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):gS);gS.range;const Zc=1e3,To=Zc*60,Qc=To*60,fu=Qc*24,PO=fu*7,t$=fu*30,vC=fu*365,hf=$i(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*Zc)},(t,e)=>(e-t)/Zc,t=>t.getUTCSeconds());hf.range;const RO=$i(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Zc)},(t,e)=>{t.setTime(+t+e*To)},(t,e)=>(e-t)/To,t=>t.getMinutes());RO.range;const DO=$i(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*To)},(t,e)=>(e-t)/To,t=>t.getUTCMinutes());DO.range;const OO=$i(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Zc-t.getMinutes()*To)},(t,e)=>{t.setTime(+t+e*Qc)},(t,e)=>(e-t)/Qc,t=>t.getHours());OO.range;const LO=$i(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*Qc)},(t,e)=>(e-t)/Qc,t=>t.getUTCHours());LO.range;const jy=$i(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*To)/fu,t=>t.getDate()-1);jy.range;const OE=$i(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/fu,t=>t.getUTCDate()-1);OE.range;const VY=$i(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/fu,t=>Math.floor(t/fu));VY.range;function cm(t){return $i(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())*To)/PO)}const LE=cm(0),xS=cm(1),y_e=cm(2),v_e=cm(3),Sg=cm(4),__e=cm(5),w_e=cm(6);LE.range;xS.range;y_e.range;v_e.range;Sg.range;__e.range;w_e.range;function um(t){return $i(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)/PO)}const IE=um(0),bS=um(1),S_e=um(2),M_e=um(3),Mg=um(4),E_e=um(5),N_e=um(6);IE.range;bS.range;S_e.range;M_e.range;Mg.range;E_e.range;N_e.range;const IO=$i(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());IO.range;const FO=$i(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());FO.range;const mu=$i(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());mu.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:$i(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)});mu.range;const pu=$i(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());pu.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:$i(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)});pu.range;function GY(t,e,n,r,i,a){const o=[[hf,1,Zc],[hf,5,5*Zc],[hf,15,15*Zc],[hf,30,30*Zc],[a,1,To],[a,5,5*To],[a,15,15*To],[a,30,30*To],[i,1,Qc],[i,3,3*Qc],[i,6,6*Qc],[i,12,12*Qc],[r,1,fu],[r,2,2*fu],[n,1,PO],[e,1,t$],[e,3,3*t$],[t,1,vC]];function l(u,d,f){const m=d<u;m&&([u,d]=[d,u]);const p=f&&typeof f.range=="function"?f:c(u,d,f),b=p?p.range(u,+d+1):[];return m?b.reverse():b}function c(u,d,f){const m=Math.abs(d-u)/f,p=yO(([,,x])=>x).right(o,m);if(p===o.length)return t.every(r3(u/vC,d/vC,f));if(p===0)return gS.every(Math.max(r3(u,d,f),1));const[b,v]=o[m/o[p-1][2]<o[p][2]/m?p-1:p];return b.every(v)}return[l,c]}const[A_e,T_e]=GY(pu,FO,IE,VY,LO,DO),[C_e,k_e]=GY(mu,IO,LE,jy,OO,RO);function _C(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 wC(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 hb(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function j_e(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=fb(i),d=mb(i),f=fb(a),m=mb(a),p=fb(o),b=mb(o),v=fb(l),x=mb(l),y=fb(c),S=mb(c),M={a:V,A:J,b:ne,B:te,c:null,d:o$,e:o$,f:e1e,g:u1e,G:h1e,H:Z_e,I:Q_e,j:J_e,L:WY,m:t1e,M:n1e,p:z,q:H,Q:u$,s:d$,S:r1e,u:i1e,U:a1e,V:s1e,w:o1e,W:l1e,x:null,X:null,y:c1e,Y:d1e,Z:f1e,"%":c$},N={a:Z,A:ee,b:he,B:fe,c:null,d:l$,e:l$,f:x1e,g:A1e,G:C1e,H:m1e,I:p1e,j:g1e,L:KY,m:b1e,M:y1e,p:oe,q:Ne,Q:u$,s:d$,S:v1e,u:_1e,U:w1e,V:S1e,w:M1e,W:E1e,x:null,X:null,y:N1e,Y:T1e,Z:k1e,"%":c$},A={a:R,A:U,b:L,B:q,c:j,d:a$,e:a$,f:q_e,g:i$,G:r$,H:s$,I:s$,j:H_e,L:W_e,m:$_e,M:V_e,p:T,q:B_e,Q:X_e,s:Y_e,S:G_e,u:L_e,U:I_e,V:F_e,w:O_e,W:U_e,x:W,X:K,y:i$,Y:r$,Z:z_e,"%":K_e};M.x=k(n,M),M.X=k(r,M),M.c=k(e,M),N.x=k(n,N),N.X=k(r,N),N.c=k(e,N);function k(ge,Se){return function(Re){var de=[],Qe=-1,G=0,ie=ge.length,X,$,I;for(Re instanceof Date||(Re=new Date(+Re));++Qe<ie;)ge.charCodeAt(Qe)===37&&(de.push(ge.slice(G,Qe)),($=n$[X=ge.charAt(++Qe)])!=null?X=ge.charAt(++Qe):$=X==="e"?" ":"0",(I=Se[X])&&(X=I(Re,$)),de.push(X),G=Qe+1);return de.push(ge.slice(G,Qe)),de.join("")}}function C(ge,Se){return function(Re){var de=hb(1900,void 0,1),Qe=D(de,ge,Re+="",0),G,ie;if(Qe!=Re.length)return null;if("Q"in de)return new Date(de.Q);if("s"in de)return new Date(de.s*1e3+("L"in de?de.L:0));if(Se&&!("Z"in de)&&(de.Z=0),"p"in de&&(de.H=de.H%12+de.p*12),de.m===void 0&&(de.m="q"in de?de.q:0),"V"in de){if(de.V<1||de.V>53)return null;"w"in de||(de.w=1),"Z"in de?(G=wC(hb(de.y,0,1)),ie=G.getUTCDay(),G=ie>4||ie===0?bS.ceil(G):bS(G),G=OE.offset(G,(de.V-1)*7),de.y=G.getUTCFullYear(),de.m=G.getUTCMonth(),de.d=G.getUTCDate()+(de.w+6)%7):(G=_C(hb(de.y,0,1)),ie=G.getDay(),G=ie>4||ie===0?xS.ceil(G):xS(G),G=jy.offset(G,(de.V-1)*7),de.y=G.getFullYear(),de.m=G.getMonth(),de.d=G.getDate()+(de.w+6)%7)}else("W"in de||"U"in de)&&("w"in de||(de.w="u"in de?de.u%7:"W"in de?1:0),ie="Z"in de?wC(hb(de.y,0,1)).getUTCDay():_C(hb(de.y,0,1)).getDay(),de.m=0,de.d="W"in de?(de.w+6)%7+de.W*7-(ie+5)%7:de.w+de.U*7-(ie+6)%7);return"Z"in de?(de.H+=de.Z/100|0,de.M+=de.Z%100,wC(de)):_C(de)}}function D(ge,Se,Re,de){for(var Qe=0,G=Se.length,ie=Re.length,X,$;Qe<G;){if(de>=ie)return-1;if(X=Se.charCodeAt(Qe++),X===37){if(X=Se.charAt(Qe++),$=A[X in n$?Se.charAt(Qe++):X],!$||(de=$(ge,Re,de))<0)return-1}else if(X!=Re.charCodeAt(de++))return-1}return de}function T(ge,Se,Re){var de=u.exec(Se.slice(Re));return de?(ge.p=d.get(de[0].toLowerCase()),Re+de[0].length):-1}function R(ge,Se,Re){var de=p.exec(Se.slice(Re));return de?(ge.w=b.get(de[0].toLowerCase()),Re+de[0].length):-1}function U(ge,Se,Re){var de=f.exec(Se.slice(Re));return de?(ge.w=m.get(de[0].toLowerCase()),Re+de[0].length):-1}function L(ge,Se,Re){var de=y.exec(Se.slice(Re));return de?(ge.m=S.get(de[0].toLowerCase()),Re+de[0].length):-1}function q(ge,Se,Re){var de=v.exec(Se.slice(Re));return de?(ge.m=x.get(de[0].toLowerCase()),Re+de[0].length):-1}function j(ge,Se,Re){return D(ge,e,Se,Re)}function W(ge,Se,Re){return D(ge,n,Se,Re)}function K(ge,Se,Re){return D(ge,r,Se,Re)}function V(ge){return o[ge.getDay()]}function J(ge){return a[ge.getDay()]}function ne(ge){return c[ge.getMonth()]}function te(ge){return l[ge.getMonth()]}function z(ge){return i[+(ge.getHours()>=12)]}function H(ge){return 1+~~(ge.getMonth()/3)}function Z(ge){return o[ge.getUTCDay()]}function ee(ge){return a[ge.getUTCDay()]}function he(ge){return c[ge.getUTCMonth()]}function fe(ge){return l[ge.getUTCMonth()]}function oe(ge){return i[+(ge.getUTCHours()>=12)]}function Ne(ge){return 1+~~(ge.getUTCMonth()/3)}return{format:function(ge){var Se=k(ge+="",M);return Se.toString=function(){return ge},Se},parse:function(ge){var Se=C(ge+="",!1);return Se.toString=function(){return ge},Se},utcFormat:function(ge){var Se=k(ge+="",N);return Se.toString=function(){return ge},Se},utcParse:function(ge){var Se=C(ge+="",!0);return Se.toString=function(){return ge},Se}}}var n$={"-":"",_:" ",0:"0"},sa=/^\s*\d+/,P_e=/^%/,R_e=/[\\^$*+?|[\]().{}]/g;function Xn(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 D_e(t){return t.replace(R_e,"\\$&")}function fb(t){return new RegExp("^(?:"+t.map(D_e).join("|")+")","i")}function mb(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function O_e(t,e,n){var r=sa.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function L_e(t,e,n){var r=sa.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function I_e(t,e,n){var r=sa.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function F_e(t,e,n){var r=sa.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function U_e(t,e,n){var r=sa.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function r$(t,e,n){var r=sa.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function i$(t,e,n){var r=sa.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function z_e(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 B_e(t,e,n){var r=sa.exec(e.slice(n,n+1));return r?(t.q=r[0]*3-3,n+r[0].length):-1}function $_e(t,e,n){var r=sa.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function a$(t,e,n){var r=sa.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function H_e(t,e,n){var r=sa.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function s$(t,e,n){var r=sa.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function V_e(t,e,n){var r=sa.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function G_e(t,e,n){var r=sa.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function W_e(t,e,n){var r=sa.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function q_e(t,e,n){var r=sa.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function K_e(t,e,n){var r=P_e.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function X_e(t,e,n){var r=sa.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function Y_e(t,e,n){var r=sa.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function o$(t,e){return Xn(t.getDate(),e,2)}function Z_e(t,e){return Xn(t.getHours(),e,2)}function Q_e(t,e){return Xn(t.getHours()%12||12,e,2)}function J_e(t,e){return Xn(1+jy.count(mu(t),t),e,3)}function WY(t,e){return Xn(t.getMilliseconds(),e,3)}function e1e(t,e){return WY(t,e)+"000"}function t1e(t,e){return Xn(t.getMonth()+1,e,2)}function n1e(t,e){return Xn(t.getMinutes(),e,2)}function r1e(t,e){return Xn(t.getSeconds(),e,2)}function i1e(t){var e=t.getDay();return e===0?7:e}function a1e(t,e){return Xn(LE.count(mu(t)-1,t),e,2)}function qY(t){var e=t.getDay();return e>=4||e===0?Sg(t):Sg.ceil(t)}function s1e(t,e){return t=qY(t),Xn(Sg.count(mu(t),t)+(mu(t).getDay()===4),e,2)}function o1e(t){return t.getDay()}function l1e(t,e){return Xn(xS.count(mu(t)-1,t),e,2)}function c1e(t,e){return Xn(t.getFullYear()%100,e,2)}function u1e(t,e){return t=qY(t),Xn(t.getFullYear()%100,e,2)}function d1e(t,e){return Xn(t.getFullYear()%1e4,e,4)}function h1e(t,e){var n=t.getDay();return t=n>=4||n===0?Sg(t):Sg.ceil(t),Xn(t.getFullYear()%1e4,e,4)}function f1e(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+Xn(e/60|0,"0",2)+Xn(e%60,"0",2)}function l$(t,e){return Xn(t.getUTCDate(),e,2)}function m1e(t,e){return Xn(t.getUTCHours(),e,2)}function p1e(t,e){return Xn(t.getUTCHours()%12||12,e,2)}function g1e(t,e){return Xn(1+OE.count(pu(t),t),e,3)}function KY(t,e){return Xn(t.getUTCMilliseconds(),e,3)}function x1e(t,e){return KY(t,e)+"000"}function b1e(t,e){return Xn(t.getUTCMonth()+1,e,2)}function y1e(t,e){return Xn(t.getUTCMinutes(),e,2)}function v1e(t,e){return Xn(t.getUTCSeconds(),e,2)}function _1e(t){var e=t.getUTCDay();return e===0?7:e}function w1e(t,e){return Xn(IE.count(pu(t)-1,t),e,2)}function XY(t){var e=t.getUTCDay();return e>=4||e===0?Mg(t):Mg.ceil(t)}function S1e(t,e){return t=XY(t),Xn(Mg.count(pu(t),t)+(pu(t).getUTCDay()===4),e,2)}function M1e(t){return t.getUTCDay()}function E1e(t,e){return Xn(bS.count(pu(t)-1,t),e,2)}function N1e(t,e){return Xn(t.getUTCFullYear()%100,e,2)}function A1e(t,e){return t=XY(t),Xn(t.getUTCFullYear()%100,e,2)}function T1e(t,e){return Xn(t.getUTCFullYear()%1e4,e,4)}function C1e(t,e){var n=t.getUTCDay();return t=n>=4||n===0?Mg(t):Mg.ceil(t),Xn(t.getUTCFullYear()%1e4,e,4)}function k1e(){return"+0000"}function c$(){return"%"}function u$(t){return+t}function d$(t){return Math.floor(+t/1e3)}var Ym,YY,ZY;j1e({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 j1e(t){return Ym=j_e(t),YY=Ym.format,Ym.parse,ZY=Ym.utcFormat,Ym.utcParse,Ym}function P1e(t){return new Date(t)}function R1e(t){return t instanceof Date?+t:+new Date(+t)}function UO(t,e,n,r,i,a,o,l,c,u){var d=EO(),f=d.invert,m=d.domain,p=u(".%L"),b=u(":%S"),v=u("%I:%M"),x=u("%I %p"),y=u("%a %d"),S=u("%b %d"),M=u("%B"),N=u("%Y");function A(k){return(c(k)<k?p:l(k)<k?b:o(k)<k?v:a(k)<k?x:r(k)<k?i(k)<k?y:S:n(k)<k?M:N)(k)}return d.invert=function(k){return new Date(f(k))},d.domain=function(k){return arguments.length?m(Array.from(k,R1e)):m().map(P1e)},d.ticks=function(k){var C=m();return t(C[0],C[C.length-1],k??10)},d.tickFormat=function(k,C){return C==null?A:u(C)},d.nice=function(k){var C=m();return(!k||typeof k.range!="function")&&(k=e(C[0],C[C.length-1],k??10)),k?m(IY(C,k)):d},d.copy=function(){return ky(d,UO(t,e,n,r,i,a,o,l,c,u))},d}function D1e(){return Fo.apply(UO(C_e,k_e,mu,IO,LE,jy,OO,RO,hf,YY).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function O1e(){return Fo.apply(UO(A_e,T_e,pu,FO,IE,OE,LO,DO,hf,ZY).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function FE(){var t=0,e=1,n,r,i,a,o=Za,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(m){var p,b;return arguments.length?([p,b]=m,o=f(p,b),u):[o(0),o(1)]}}return u.range=d(Jg),u.rangeRound=d(MO),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 fh(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function QY(){var t=hh(FE()(Za));return t.copy=function(){return fh(t,QY())},Eu.apply(t,arguments)}function JY(){var t=TO(FE()).domain([1,10]);return t.copy=function(){return fh(t,JY()).base(t.base())},Eu.apply(t,arguments)}function eZ(){var t=CO(FE());return t.copy=function(){return fh(t,eZ()).constant(t.constant())},Eu.apply(t,arguments)}function zO(){var t=kO(FE());return t.copy=function(){return fh(t,zO()).exponent(t.exponent())},Eu.apply(t,arguments)}function L1e(){return zO.apply(null,arguments).exponent(.5)}function tZ(){var t=[],e=Za;function n(r){if(r!=null&&!isNaN(r=+r))return e((Ty(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(Ud),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)=>_ve(t,a/r))},n.copy=function(){return tZ(e).domain(t)},Eu.apply(n,arguments)}function UE(){var t=0,e=.5,n=1,r=1,i,a,o,l,c,u=Za,d,f=!1,m;function p(v){return isNaN(v=+v)?m:(v=.5+((v=+d(v))-a)*(r*v<r*a?l:c),u(f?Math.max(0,Math.min(1,v)):v))}p.domain=function(v){return arguments.length?([t,e,n]=v,i=d(t=+t),a=d(e=+e),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(v){return arguments.length?(f=!!v,p):f},p.interpolator=function(v){return arguments.length?(u=v,p):u};function b(v){return function(x){var y,S,M;return arguments.length?([y,S,M]=x,u=Kve(v,[y,S,M]),p):[u(0),u(.5),u(1)]}}return p.range=b(Jg),p.rangeRound=b(MO),p.unknown=function(v){return arguments.length?(m=v,p):m},function(v){return d=v,i=v(t),a=v(e),o=v(n),l=i===a?0:.5/(a-i),c=a===o?0:.5/(o-a),r=a<i?-1:1,p}}function nZ(){var t=hh(UE()(Za));return t.copy=function(){return fh(t,nZ())},Eu.apply(t,arguments)}function rZ(){var t=TO(UE()).domain([.1,1,10]);return t.copy=function(){return fh(t,rZ()).base(t.base())},Eu.apply(t,arguments)}function iZ(){var t=CO(UE());return t.copy=function(){return fh(t,iZ()).constant(t.constant())},Eu.apply(t,arguments)}function BO(){var t=kO(UE());return t.copy=function(){return fh(t,BO()).exponent(t.exponent())},Eu.apply(t,arguments)}function I1e(){return BO.apply(null,arguments).exponent(.5)}const Fb=Object.freeze(Object.defineProperty({__proto__:null,scaleBand:_O,scaleDiverging:nZ,scaleDivergingLog:rZ,scaleDivergingPow:BO,scaleDivergingSqrt:I1e,scaleDivergingSymlog:iZ,scaleIdentity:LY,scaleImplicit:i3,scaleLinear:OY,scaleLog:FY,scaleOrdinal:vO,scalePoint:Mve,scalePow:jO,scaleQuantile:BY,scaleQuantize:$Y,scaleRadial:zY,scaleSequential:QY,scaleSequentialLog:JY,scaleSequentialPow:zO,scaleSequentialQuantile:tZ,scaleSequentialSqrt:L1e,scaleSequentialSymlog:eZ,scaleSqrt:x_e,scaleSymlog:UY,scaleThreshold:HY,scaleTime:D1e,scaleUtc:O1e,tickFormat:DY},Symbol.toStringTag,{value:"Module"}));var Nu=t=>t.chartData,zE=tt([Nu],t=>{var e=t.chartData!=null?t.chartData.length-1:0;return{chartData:t.chartData,computedData:t.computedData,dataEndIndex:e,dataStartIndex:0}}),$O=(t,e,n,r)=>r?zE(t):Nu(t),aZ=(t,e,n)=>n?zE(t):Nu(t);function gu(t){if(Array.isArray(t)&&t.length===2){var[e,n]=t;if(pn(e)&&pn(n))return!0}return!1}function h$(t,e,n){return n?t:[Math.min(t[0],e[0]),Math.max(t[1],e[1])]}function sZ(t,e){if(e&&typeof t!="function"&&Array.isArray(t)&&t.length===2){var[n,r]=t,i,a;if(pn(n))i=n;else if(typeof n=="function")return;if(pn(r))a=r;else if(typeof r=="function")return;var o=[i,a];if(gu(o))return o}}function F1e(t,e,n){if(!(!n&&e==null)){if(typeof t=="function"&&e!=null)try{var r=t(e,n);if(gu(r))return h$(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(zt(i))o=i;else if(typeof i=="function")try{e!=null&&(o=i(e?.[0]))}catch{}else if(typeof i=="string"&&w8.test(i)){var c=w8.exec(i);if(c==null||c[1]==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(zt(a))l=a;else if(typeof a=="function")try{e!=null&&(l=a(e?.[1]))}catch{}else if(typeof a=="string"&&S8.test(a)){var d=S8.exec(a);if(d==null||d[1]==null||e==null)l=void 0;else{var f=+d[1];l=e[1]+f}}else l=e?.[1];var m=[o,l];if(gu(m))return e==null?m:h$(m,e,n)}}}var ex=1e9,U1e={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},VO,zr=!0,Lo="[DecimalError] ",Mf=Lo+"Invalid argument: ",HO=Lo+"Exponent out of range: ",tx=Math.floor,Zh=Math.pow,z1e=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,$s,Zi=1e7,Lr=7,oZ=9007199254740991,yS=tx(oZ/Lr),Wt={};Wt.absoluteValue=Wt.abs=function(){var t=new this.constructor(this);return t.s&&(t.s=1),t};Wt.comparedTo=Wt.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};Wt.decimalPlaces=Wt.dp=function(){var t=this,e=t.d.length-1,n=(e-t.e)*Lr;if(e=t.d[e],e)for(;e%10==0;e/=10)n--;return n<0?0:n};Wt.dividedBy=Wt.div=function(t){return ru(this,new this.constructor(t))};Wt.dividedToIntegerBy=Wt.idiv=function(t){var e=this,n=e.constructor;return Sr(ru(e,new n(t),0,1),n.precision)};Wt.equals=Wt.eq=function(t){return!this.cmp(t)};Wt.exponent=function(){return Ai(this)};Wt.greaterThan=Wt.gt=function(t){return this.cmp(t)>0};Wt.greaterThanOrEqualTo=Wt.gte=function(t){return this.cmp(t)>=0};Wt.isInteger=Wt.isint=function(){return this.e>this.d.length-2};Wt.isNegative=Wt.isneg=function(){return this.s<0};Wt.isPositive=Wt.ispos=function(){return this.s>0};Wt.isZero=function(){return this.s===0};Wt.lessThan=Wt.lt=function(t){return this.cmp(t)<0};Wt.lessThanOrEqualTo=Wt.lte=function(t){return this.cmp(t)<1};Wt.logarithm=Wt.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($s))throw Error(Lo+"NaN");if(n.s<1)throw Error(Lo+(n.s?"NaN":"-Infinity"));return n.eq($s)?new r(0):(zr=!1,e=ru($0(n,a),$0(t,a),a),zr=!0,Sr(e,i))};Wt.minus=Wt.sub=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?uZ(e,t):lZ(e,(t.s=-t.s,t))};Wt.modulo=Wt.mod=function(t){var e,n=this,r=n.constructor,i=r.precision;if(t=new r(t),!t.s)throw Error(Lo+"NaN");return n.s?(zr=!1,e=ru(n,t,0,1).times(t),zr=!0,n.minus(e)):Sr(new r(n),i)};Wt.naturalExponential=Wt.exp=function(){return cZ(this)};Wt.naturalLogarithm=Wt.ln=function(){return $0(this)};Wt.negated=Wt.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};Wt.plus=Wt.add=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?lZ(e,t):uZ(e,(t.s=-t.s,t))};Wt.precision=Wt.sd=function(t){var e,n,r,i=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(Mf+t);if(e=Ai(i)+1,r=i.d.length-1,n=r*Lr+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};Wt.squareRoot=Wt.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(Lo+"NaN")}for(t=Ai(l),zr=!1,i=Math.sqrt(+l),i==0||i==1/0?(e=Bl(l.d),(e.length+t)%2==0&&(e+="0"),i=Math.sqrt(e),t=tx((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(ru(l,a,o+2)).times(.5),Bl(a.d).slice(0,o)===(e=Bl(r.d)).slice(0,o)){if(e=e.slice(o-3,o+1),i==o&&e=="4999"){if(Sr(a,n+1,0),a.times(a).eq(l)){r=a;break}}else if(e!="9999")break;o+=4}return zr=!0,Sr(r,n)};Wt.times=Wt.mul=function(t){var e,n,r,i,a,o,l,c,u,d=this,f=d.constructor,m=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=m.length,u=p.length,c<u&&(a=m,m=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]*m[i-r-1]+e,a[i--]=l%Zi|0,e=l/Zi|0;a[i]=(a[i]+e)%Zi|0}for(;!a[--o];)a.pop();return e?++n:a.shift(),t.d=a,t.e=n,zr?Sr(t,f.precision):t};Wt.toDecimalPlaces=Wt.todp=function(t,e){var n=this,r=n.constructor;return n=new r(n),t===void 0?n:(ec(t,0,ex),e===void 0?e=r.rounding:ec(e,0,8),Sr(n,t+Ai(n)+1,e))};Wt.toExponential=function(t,e){var n,r=this,i=r.constructor;return t===void 0?n=Xf(r,!0):(ec(t,0,ex),e===void 0?e=i.rounding:ec(e,0,8),r=Sr(new i(r),t+1,e),n=Xf(r,!0,t+1)),n};Wt.toFixed=function(t,e){var n,r,i=this,a=i.constructor;return t===void 0?Xf(i):(ec(t,0,ex),e===void 0?e=a.rounding:ec(e,0,8),r=Sr(new a(i),t+Ai(i)+1,e),n=Xf(r.abs(),!1,t+Ai(r)+1),i.isneg()&&!i.isZero()?"-"+n:n)};Wt.toInteger=Wt.toint=function(){var t=this,e=t.constructor;return Sr(new e(t),Ai(t)+1,e.rounding)};Wt.toNumber=function(){return+this};Wt.toPower=Wt.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($s);if(l=new c(l),!l.s){if(t.s<1)throw Error(Lo+"Infinity");return l}if(l.eq($s))return l;if(r=c.precision,t.eq($s))return Sr(l,r);if(e=t.e,n=t.d.length-1,o=e>=n,a=l.s,o){if((n=d<0?-d:d)<=oZ){for(i=new c($s),e=Math.ceil(r/Lr+4),zr=!1;n%2&&(i=i.times(l),m$(i.d,e)),n=tx(n/2),n!==0;)l=l.times(l),m$(l.d,e);return zr=!0,t.s<0?new c($s).div(i):Sr(i,r)}}else if(a<0)throw Error(Lo+"NaN");return a=a<0&&t.d[Math.max(e,n)]&1?-1:1,l.s=1,zr=!1,i=t.times($0(l,r+u)),zr=!0,i=cZ(i),i.s=a,i};Wt.toPrecision=function(t,e){var n,r,i=this,a=i.constructor;return t===void 0?(n=Ai(i),r=Xf(i,n<=a.toExpNeg||n>=a.toExpPos)):(ec(t,1,ex),e===void 0?e=a.rounding:ec(e,0,8),i=Sr(new a(i),t,e),n=Ai(i),r=Xf(i,t<=n||n<=a.toExpNeg,t)),r};Wt.toSignificantDigits=Wt.tosd=function(t,e){var n=this,r=n.constructor;return t===void 0?(t=r.precision,e=r.rounding):(ec(t,1,ex),e===void 0?e=r.rounding:ec(e,0,8)),Sr(new r(n),t,e)};Wt.toString=Wt.valueOf=Wt.val=Wt.toJSON=Wt[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,e=Ai(t),n=t.constructor;return Xf(t,e<=n.toExpNeg||e>=n.toExpPos)};function lZ(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)),zr?Sr(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/Lr),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)/Zi|0,c[a]%=Zi;for(n&&(c.unshift(n),++i),l=c.length;c[--l]==0;)c.pop();return e.d=c,e.e=i,zr?Sr(e,f):e}function ec(t,e,n){if(t!==~~t||t<e||t>n)throw Error(Mf+t)}function Bl(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=Lr-r.length,n&&(a+=pd(n)),a+=r;o=t[e],r=o+"",n=Lr-r.length,n&&(a+=pd(n))}else if(o===0)return"0";for(;o%10===0;)o/=10;return a+o}var ru=(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%Zi|0,o=a/Zi|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*Zi+r[a]-i[a];for(;!r[0]&&r.length>1;)r.shift()}return function(r,i,a,o){var l,c,u,d,f,m,p,b,v,x,y,S,M,N,A,k,C,D,T=r.constructor,R=r.s==i.s?1:-1,U=r.d,L=i.d;if(!r.s)return new T(r);if(!i.s)throw Error(Lo+"Division by zero");for(c=r.e-i.e,C=L.length,A=U.length,p=new T(R),b=p.d=[],u=0;L[u]==(U[u]||0);)++u;if(L[u]>(U[u]||0)&&--c,a==null?S=a=T.precision:o?S=a+(Ai(r)-Ai(i))+1:S=a,S<0)return new T(0);if(S=S/Lr+2|0,u=0,C==1)for(d=0,L=L[0],S++;(u<A||d)&&S--;u++)M=d*Zi+(U[u]||0),b[u]=M/L|0,d=M%L|0;else{for(d=Zi/(L[0]+1)|0,d>1&&(L=t(L,d),U=t(U,d),C=L.length,A=U.length),N=C,v=U.slice(0,C),x=v.length;x<C;)v[x++]=0;D=L.slice(),D.unshift(0),k=L[0],L[1]>=Zi/2&&++k;do d=0,l=e(L,v,C,x),l<0?(y=v[0],C!=x&&(y=y*Zi+(v[1]||0)),d=y/k|0,d>1?(d>=Zi&&(d=Zi-1),f=t(L,d),m=f.length,x=v.length,l=e(f,v,m,x),l==1&&(d--,n(f,C<m?D:L,m))):(d==0&&(l=d=1),f=L.slice()),m=f.length,m<x&&f.unshift(0),n(v,f,x),l==-1&&(x=v.length,l=e(L,v,C,x),l<1&&(d++,n(v,C<x?D:L,x))),x=v.length):l===0&&(d++,v=[0]),b[u++]=d,l&&v[0]?v[x++]=U[N]||0:(v=[U[N]],x=1);while((N++<A||v[0]!==void 0)&&S--)}return b[0]||b.shift(),p.e=c,Sr(p,o?a+Ai(p)+1:a)}})();function cZ(t,e){var n,r,i,a,o,l,c=0,u=0,d=t.constructor,f=d.precision;if(Ai(t)>16)throw Error(HO+Ai(t));if(!t.s)return new d($s);for(zr=!1,l=f,o=new d(.03125);t.abs().gte(.1);)t=t.times(o),u+=5;for(r=Math.log(Zh(2,u))/Math.LN10*2+5|0,l+=r,n=i=a=new d($s),d.precision=l;;){if(i=Sr(i.times(t),l),n=n.times(++c),o=a.plus(ru(i,n,l)),Bl(o.d).slice(0,l)===Bl(a.d).slice(0,l)){for(;u--;)a=Sr(a.times(a),l);return d.precision=f,e==null?(zr=!0,Sr(a,f)):a}a=o}}function Ai(t){for(var e=t.e*Lr,n=t.d[0];n>=10;n/=10)e++;return e}function SC(t,e,n){if(e>t.LN10.sd())throw zr=!0,n&&(t.precision=n),Error(Lo+"LN10 precision limit exceeded");return Sr(new t(t.LN10),e)}function pd(t){for(var e="";t--;)e+="0";return e}function $0(t,e){var n,r,i,a,o,l,c,u,d,f=1,m=10,p=t,b=p.d,v=p.constructor,x=v.precision;if(p.s<1)throw Error(Lo+(p.s?"NaN":"-Infinity"));if(p.eq($s))return new v(0);if(e==null?(zr=!1,u=x):u=e,p.eq(10))return e==null&&(zr=!0),SC(v,u);if(u+=m,v.precision=u,n=Bl(b),r=n.charAt(0),a=Ai(p),Math.abs(a)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)p=p.times(t),n=Bl(p.d),r=n.charAt(0),f++;a=Ai(p),r>1?(p=new v("0."+n),a++):p=new v(r+"."+n.slice(1))}else return c=SC(v,u+2,x).times(a+""),p=$0(new v(r+"."+n.slice(1)),u-m).plus(c),v.precision=x,e==null?(zr=!0,Sr(p,x)):p;for(l=o=p=ru(p.minus($s),p.plus($s),u),d=Sr(p.times(p),u),i=3;;){if(o=Sr(o.times(d),u),c=l.plus(ru(o,new v(i),u)),Bl(c.d).slice(0,u)===Bl(l.d).slice(0,u))return l=l.times(2),a!==0&&(l=l.plus(SC(v,u+2,x).times(a+""))),l=ru(l,new v(f),u),v.precision=x,e==null?(zr=!0,Sr(l,x)):l;l=c,i+=2}}function f$(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=tx(n/Lr),t.d=[],r=(n+1)%Lr,n<0&&(r+=Lr),r<i){for(r&&t.d.push(+e.slice(0,r)),i-=Lr;r<i;)t.d.push(+e.slice(r,r+=Lr));e=e.slice(r),r=Lr-e.length}else r-=i;for(;r--;)e+="0";if(t.d.push(+e),zr&&(t.e>yS||t.e<-yS))throw Error(HO+n)}else t.s=0,t.e=0,t.d=[0];return t}function Sr(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+=Lr,i=e,u=f[d=0];else{if(d=Math.ceil((r+1)/Lr),a=f.length,d>=a)return t;for(u=a=f[d],o=1;a>=10;a/=10)o++;r%=Lr,i=r-Lr+o}if(n!==void 0&&(a=Zh(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/Zh(10,o-i):0:f[d-1])%10&1||n==(t.s<0?8:7))),e<1||!f[0])return c?(a=Ai(t),f.length=1,e=e-a-1,f[0]=Zh(10,(Lr-e%Lr)%Lr),t.e=tx(-e/Lr)||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=Zh(10,Lr-r),f[d]=i>0?(u/Zh(10,o-i)%Zh(10,i)|0)*a:0),c)for(;;)if(d==0){(f[0]+=a)==Zi&&(f[0]=1,++t.e);break}else{if(f[d]+=a,f[d]!=Zi)break;f[d--]=0,a=1}for(r=f.length;f[--r]===0;)f.pop();if(zr&&(t.e>yS||t.e<-yS))throw Error(HO+Ai(t));return t}function uZ(t,e){var n,r,i,a,o,l,c,u,d,f,m=t.constructor,p=m.precision;if(!t.s||!e.s)return e.s?e.s=-e.s:e=new m(t),zr?Sr(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/Lr),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]=Zi-1;--c[a],c[i]+=Zi}c[i]-=f[i]}for(;c[--l]===0;)c.pop();for(;c[0]===0;c.shift())--r;return c[0]?(e.d=c,e.e=r,zr?Sr(e,p):e):new m(0)}function Xf(t,e,n){var r,i=Ai(t),a=Bl(t.d),o=a.length;return e?(n&&(r=n-o)>0?a=a.charAt(0)+"."+a.slice(1)+pd(r):o>1&&(a=a.charAt(0)+"."+a.slice(1)),a=a+(i<0?"e":"e+")+i):i<0?(a="0."+pd(-i-1)+a,n&&(r=n-o)>0&&(a+=pd(r))):i>=o?(a+=pd(i+1-o),n&&(r=n-i-1)>0&&(a=a+"."+pd(r))):((r=i+1)<o&&(a=a.slice(0,r)+"."+a.slice(r)),n&&(r=n-o)>0&&(i+1===o&&(a+="."),a+=pd(r))),t.s<0?"-"+a:a}function m$(t,e){if(t.length>e)return t.length=e,!0}function dZ(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(Mf+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 f$(o,a.toString())}else if(typeof a!="string")throw Error(Mf+a);if(a.charCodeAt(0)===45?(a=a.slice(1),o.s=-1):o.s=1,z1e.test(a))f$(o,a);else throw Error(Mf+a)}if(i.prototype=Wt,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=dZ,i.config=i.set=B1e,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 B1e(t){if(!t||typeof t!="object")throw Error(Lo+"Object expected");var e,n,r,i=["precision",1,ex,"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(tx(r)===r&&r>=i[e+1]&&r<=i[e+2])this[n]=r;else throw Error(Mf+n+": "+r);if((r=t[n="LN10"])!==void 0)if(r==Math.LN10)this[n]=new this(r);else throw Error(Mf+n+": "+r);return this}var VO=dZ(U1e);$s=new VO(1);const cr=VO;function hZ(t){var e;return t===0?e=1:e=Math.floor(new cr(t).abs().log(10).toNumber())+1,e}function fZ(t,e,n){for(var r=new cr(t),i=0,a=[];r.lt(e)&&i<1e5;)a.push(r.toNumber()),r=r.add(n),i++;return a}var mZ=t=>{var[e,n]=t,[r,i]=[e,n];return e>n&&([r,i]=[n,e]),[r,i]},pZ=(t,e,n)=>{if(t.lte(0))return new cr(0);var r=hZ(t.toNumber()),i=new cr(10).pow(r),a=t.div(i),o=r!==1?.05:.1,l=new cr(Math.ceil(a.div(o).toNumber())).add(n).mul(o),c=l.mul(i);return e?new cr(c.toNumber()):new cr(Math.ceil(c.toNumber()))},$1e=(t,e,n)=>{var r=new cr(1),i=new cr(t);if(!i.isint()&&n){var a=Math.abs(t);a<1?(r=new cr(10).pow(hZ(t)-1),i=new cr(Math.floor(i.div(r).toNumber())).mul(r)):a>1&&(i=new cr(Math.floor(t)))}else t===0?i=new cr(Math.floor((e-1)/2)):n||(i=new cr(Math.floor(t)));for(var o=Math.floor((e-1)/2),l=[],c=0;c<e;c++)l.push(i.add(new cr(c-o).mul(r)).toNumber());return l},gZ=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 cr(0),tickMin:new cr(0),tickMax:new cr(0)};var o=pZ(new cr(n).sub(e).div(r-1),i,a),l;e<=0&&n>=0?l=new cr(0):(l=new cr(e).add(n).div(2),l=l.sub(new cr(l).mod(o)));var c=Math.ceil(l.sub(e).div(o).toNumber()),u=Math.ceil(new cr(n).sub(l).div(o).toNumber()),d=c+u+1;return d>r?gZ(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 cr(c).mul(o)),tickMax:l.add(new cr(u).mul(o))})},H1e=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]=mZ([n,r]);if(l===-1/0||c===1/0){var u=c===1/0?[l,...Array(i-1).fill(1/0)]:[...Array(i-1).fill(-1/0),c];return n>r?u.reverse():u}if(l===c)return $1e(l,i,a);var{step:d,tickMin:f,tickMax:m}=gZ(l,c,o,a,0),p=fZ(f,m.add(new cr(.1).mul(d)),d);return n>r?p.reverse():p},V1e=function(e,n){var[r,i]=e,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,[o,l]=mZ([r,i]);if(o===-1/0||l===1/0)return[r,i];if(o===l)return[o];var c=Math.max(n,2),u=pZ(new cr(l).sub(o).div(c-1),a,0),d=[...fZ(new cr(o),new cr(l),u),l];return a===!1&&(d=d.map(f=>Math.round(f))),r>i?d.reverse():d},xZ=t=>t.rootProps.maxBarSize,G1e=t=>t.rootProps.barGap,bZ=t=>t.rootProps.barCategoryGap,W1e=t=>t.rootProps.barSize,Py=t=>t.rootProps.stackOffset,yZ=t=>t.rootProps.reverseStackOrder,GO=t=>t.options.chartName,WO=t=>t.rootProps.syncId,vZ=t=>t.rootProps.syncMethod,qO=t=>t.options.eventEmitter,q1e=t=>t.rootProps.baseValue,oi={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},Oh={allowDecimals:!1,allowDataOverflow:!1,angleAxisId:0,reversed:!1,scale:"auto",tick:!0,type:"auto"},Nl={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!0,includeHidden:!1,radiusAxisId:0,reversed:!1,scale:"auto",tick:!0,tickCount:5,type:"auto"},BE=(t,e)=>{if(!(!t||!e))return t!=null&&t.reversed?[e[1],e[0]]:e};function $E(t,e,n){if(n!=="auto")return n;if(t!=null)return xl(t,e)?"category":"number"}function p$(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 vS(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?p$(Object(n),!0).forEach(function(r){K1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):p$(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)}var g$={allowDataOverflow:Oh.allowDataOverflow,allowDecimals:Oh.allowDecimals,allowDuplicatedCategory:!1,dataKey:void 0,domain:void 0,id:Oh.angleAxisId,includeHidden:!1,name:void 0,reversed:Oh.reversed,scale:Oh.scale,tick:Oh.tick,tickCount:void 0,ticks:void 0,type:Oh.type,unit:void 0},x$={allowDataOverflow:Nl.allowDataOverflow,allowDecimals:Nl.allowDecimals,allowDuplicatedCategory:Nl.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:Nl.radiusAxisId,includeHidden:Nl.includeHidden,name:void 0,reversed:Nl.reversed,scale:Nl.scale,tick:Nl.tick,tickCount:Nl.tickCount,ticks:void 0,type:Nl.type,unit:void 0},Z1e=(t,e)=>{if(e!=null)return t.polarAxis.angleAxis[e]},KO=tt([Z1e,iY],(t,e)=>{var n;if(t!=null)return t;var r=(n=$E(e,"angleAxis",g$.type))!==null&&n!==void 0?n:"category";return vS(vS({},g$),{},{type:r})}),Q1e=(t,e)=>t.polarAxis.radiusAxis[e],XO=tt([Q1e,iY],(t,e)=>{var n;if(t!=null)return t;var r=(n=$E(e,"radiusAxis",x$.type))!==null&&n!==void 0?n:"category";return vS(vS({},x$),{},{type:r})}),HE=t=>t.polarOptions,YO=tt([Su,Mu,zi],_Y),_Z=tt([HE,YO],(t,e)=>{if(t!=null)return Ba(t.innerRadius,e,0)}),wZ=tt([HE,YO],(t,e)=>{if(t!=null)return Ba(t.outerRadius,e,e*.8)}),J1e=t=>{if(t==null)return[0,0];var{startAngle:e,endAngle:n}=t;return[e,n]},SZ=tt([HE],J1e);tt([KO,SZ],BE);var MZ=tt([YO,_Z,wZ],(t,e,n)=>{if(!(t==null||e==null||n==null))return[e,n]});tt([XO,MZ],BE);var EZ=tt([Fn,HE,_Z,wZ,Su,Mu],(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:Ba(o,i,i/2),cy:Ba(l,a,a/2),innerRadius:n,outerRadius:r,startAngle:c,endAngle:u,clockWise:!1}}}),Xr=(t,e)=>e,Ry=(t,e,n)=>n;function VE(t){return t?.id}function NZ(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=VE(l);u.forEach((f,m)=>{var p=a==null||i?m:String(ir(f,a,null)),b=ir(f,l.dataKey,0),v;o.has(p)?v=o.get(p):v={},Object.assign(v,{[d]:b}),o.set(p,v)})}}),Array.from(o.values())}function GE(t){return"stackId"in t&&t.stackId!=null&&t.dataKey!=null}var WE=(t,e)=>t===e?!0:t==null||e==null?!1:t[0]===e[0]&&t[1]===e[1];function qE(t,e){return Array.isArray(t)&&Array.isArray(e)&&t.length===0&&e.length===0?!0:t===e}function ewe(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 oa=t=>{var e=Fn(t);return e==="horizontal"?"xAxis":e==="vertical"?"yAxis":e==="centric"?"angleAxis":"radiusAxis"},nx=t=>t.tooltip.settings.axisId;function twe(t){if(t in Fb)return Fb[t]();var e="scale".concat(yy(t));if(e in Fb)return Fb[e]()}function b$(t){var e=t.ticks,n=t.bandwidth,r=t.range(),i=[Math.min(...r),Math.max(...r)];return{domain:()=>t.domain(),range:(function(a){function o(){return a.apply(this,arguments)}return o.toString=function(){return a.toString()},o})(()=>i),rangeMin:()=>i[0],rangeMax:()=>i[1],isInRange(a){var o=i[0],l=i[1];return o<=l?a>=o&&a<=l:a>=l&&a<=o},bandwidth:n?()=>n.call(t):void 0,ticks:e?a=>e.call(t,a):void 0,map:(a,o)=>{var l=t(a);if(l!=null){if(t.bandwidth&&o!==null&&o!==void 0&&o.position){var c=t.bandwidth();switch(o.position){case"middle":l+=c/2;break;case"end":l+=c;break}}return l}}}}function y$(t,e,n){if(typeof t=="function")return b$(t.copy().domain(e).range(n));if(t!=null){var r=twe(t);if(r!=null)return r.domain(e).range(n),b$(r)}}var AZ=(t,e)=>{if(e!=null)switch(t){case"linear":{if(!gu(e)){for(var n,r,i=0;i<e.length;i++){var a=e[i];pn(a)&&((n===void 0||a<n)&&(n=a),(r===void 0||a>r)&&(r=a))}return n!==void 0&&r!==void 0?[n,r]:void 0}return e}default:return e}};function v$(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 _S(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?v$(Object(n),!0).forEach(function(r){nwe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):v$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function nwe(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=iwe(t,"string");return typeof e=="symbol"?e:e+""}function iwe(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 l3=[0,"auto"],Xi={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},TZ=(t,e)=>t.cartesianAxis.xAxis[e],cc=(t,e)=>{var n=TZ(t,e);return n??Xi},Yi={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:l3,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:Sy},CZ=(t,e)=>t.cartesianAxis.yAxis[e],uc=(t,e)=>{var n=CZ(t,e);return n??Yi},awe={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:""},ZO=(t,e)=>{var n=t.cartesianAxis.zAxis[e];return n??awe},ci=(t,e,n)=>{switch(e){case"xAxis":return cc(t,n);case"yAxis":return uc(t,n);case"zAxis":return ZO(t,n);case"angleAxis":return KO(t,n);case"radiusAxis":return XO(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},swe=(t,e,n)=>{switch(e){case"xAxis":return cc(t,n);case"yAxis":return uc(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},rx=(t,e,n)=>{switch(e){case"xAxis":return cc(t,n);case"yAxis":return uc(t,n);case"angleAxis":return KO(t,n);case"radiusAxis":return XO(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},kZ=t=>t.graphicalItems.cartesianItems.some(e=>e.type==="bar")||t.graphicalItems.polarItems.some(e=>e.type==="radialBar");function QO(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 Dy=t=>t.graphicalItems.cartesianItems,owe=tt([Xr,Ry],QO),JO=(t,e,n)=>t.filter(n).filter(r=>e?.includeHidden===!0?!0:!r.hide),Oy=tt([Dy,ci,owe],JO,{memoizeOptions:{resultEqualityCheck:qE}}),jZ=tt([Oy],t=>t.filter(e=>e.type==="area"||e.type==="bar").filter(GE)),PZ=t=>t.filter(e=>!("stackId"in e)||e.stackId===void 0),lwe=tt([Oy],PZ),e4=t=>t.map(e=>e.data).filter(Boolean).flat(1),cwe=tt([Oy],e4,{memoizeOptions:{resultEqualityCheck:qE}}),t4=(t,e)=>{var{chartData:n=[],dataStartIndex:r,dataEndIndex:i}=e;return t.length>0?t:n.slice(r,i+1)},n4=tt([cwe,$O],t4),r4=(t,e,n)=>e?.dataKey!=null?t.map(r=>({value:ir(r,e.dataKey)})):n.length>0?n.map(r=>r.dataKey).flatMap(r=>t.map(i=>({value:ir(i,r)}))):t.map(r=>({value:r})),KE=tt([n4,ci,Oy],r4);function RZ(t,e){switch(t){case"xAxis":return e.direction==="x";case"yAxis":return e.direction==="y";default:return!1}}function rw(t){if(Do(t)||t instanceof Date){var e=Number(t);if(pn(e))return e}}function _$(t){if(Array.isArray(t)){var e=[rw(t[0]),rw(t[1])];return gu(e)?e:void 0}var n=rw(t);if(n!=null)return[n,n]}function xu(t){return t.map(rw).filter(ys)}function uwe(t,e,n){return!n||typeof e!="number"||ul(e)?[]:n.length?xu(n.flatMap(r=>{var i=ir(t,r.dataKey),a,o;if(Array.isArray(i)?[a,o]=i:a=o=i,!(!pn(a)||!pn(o)))return[e-a,e+o]})):[]}var Hi=t=>{var e=oa(t),n=nx(t);return rx(t,e,n)},Ly=tt([Hi],t=>t?.dataKey),dwe=tt([jZ,$O,Hi],NZ),DZ=(t,e,n,r)=>{var i={},a=e.reduce((o,l)=>{if(l.stackId==null)return o;var c=o[l.stackId];return c==null&&(c=[]),c.push(l),o[l.stackId]=c,o},i);return Object.fromEntries(Object.entries(a).map(o=>{var[l,c]=o,u=r?[...c].reverse():c,d=u.map(VE);return[l,{stackedData:Pbe(t,d,n),graphicalItems:u}]}))},wS=tt([dwe,jZ,Py,yZ],DZ),OZ=(t,e,n,r)=>{var{dataStartIndex:i,dataEndIndex:a}=e;if(r==null&&n!=="zAxis"){var o=Lbe(t,i,a);if(!(o!=null&&o[0]===0&&o[1]===0))return o}},hwe=tt([ci],t=>t.allowDataOverflow),i4=t=>{var e;if(t==null||!("domain"in t))return l3;if(t.domain!=null)return t.domain;if("ticks"in t&&t.ticks!=null){if(t.type==="number"){var n=xu(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:l3},a4=tt([ci],i4),s4=tt([a4,hwe],sZ),fwe=tt([wS,Nu,Xr,s4],OZ,{memoizeOptions:{resultEqualityCheck:WE}}),XE=t=>t.errorBars,mwe=(t,e,n)=>t.flatMap(r=>e[r.id]).filter(Boolean).filter(r=>RZ(n,r)),SS=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]}},o4=(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(y=>RZ(i,y)),m=ir(l,(d=e.dataKey)!==null&&d!==void 0?d:c.dataKey),p=uwe(l,m,f);if(p.length>=2){var b=Math.min(...p),v=Math.max(...p);(a==null||b<a)&&(a=b),(o==null||v>o)&&(o=v)}var x=_$(m);x!=null&&(a=a==null?x[0]:Math.min(a,x[0]),o=o==null?x[1]:Math.max(o,x[1]))})}),e?.dataKey!=null&&t.forEach(l=>{var c=_$(ir(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]))}),pn(a)&&pn(o))return[a,o]},pwe=tt([n4,ci,lwe,XE,Xr],o4,{memoizeOptions:{resultEqualityCheck:WE}});function gwe(t){var{value:e}=t;if(Do(e)||e instanceof Date)return e}var xwe=(t,e,n)=>{var r=t.map(gwe).filter(i=>i!=null);return n&&(e.dataKey==null||e.allowDuplicatedCategory&&JK(r))?EY(0,t.length):e.allowDuplicatedCategory?r:Array.from(new Set(r))},LZ=t=>t.referenceElements.dots,ix=(t,e,n)=>t.filter(r=>r.ifOverflow==="extendDomain").filter(r=>e==="xAxis"?r.xAxisId===n:r.yAxisId===n),bwe=tt([LZ,Xr,Ry],ix),IZ=t=>t.referenceElements.areas,ywe=tt([IZ,Xr,Ry],ix),FZ=t=>t.referenceElements.lines,vwe=tt([FZ,Xr,Ry],ix),UZ=(t,e)=>{if(t!=null){var n=xu(t.map(r=>e==="xAxis"?r.x:r.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]}},_we=tt(bwe,Xr,UZ),zZ=(t,e)=>{if(t!=null){var n=xu(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)]}},wwe=tt([ywe,Xr],zZ);function Swe(t){var e;if(t.x!=null)return xu([t.x]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.x);return n==null||n.length===0?[]:xu(n)}function Mwe(t){var e;if(t.y!=null)return xu([t.y]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.y);return n==null||n.length===0?[]:xu(n)}var BZ=(t,e)=>{if(t!=null){var n=t.flatMap(r=>e==="xAxis"?Swe(r):Mwe(r));if(n.length!==0)return[Math.min(...n),Math.max(...n)]}},Ewe=tt([vwe,Xr],BZ),Nwe=tt(_we,Ewe,wwe,(t,e,n)=>SS(t,n,e)),l4=(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?SS(r,a,i):SS(a,i);return F1e(e,u,t.allowDataOverflow)},Awe=tt([ci,a4,s4,fwe,pwe,Nwe,Fn,Xr],l4,{memoizeOptions:{resultEqualityCheck:WE}}),Twe=[0,1],c4=(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=xl(e,a);if(u&&l==null){var d;return EY(0,(d=n?.length)!==null&&d!==void 0?d:0)}return c==="category"?xwe(r,t,u):i==="expand"?Twe:o}},u4=tt([ci,Fn,n4,KE,Py,Xr,Awe],c4);function Cwe(t){return t in Fb}var $Z=(t,e,n)=>{if(t!=null){var{scale:r,type:i}=t;if(r==="auto")return i==="category"&&n&&(n.indexOf("LineChart")>=0||n.indexOf("AreaChart")>=0||n.indexOf("ComposedChart")>=0&&!e)?"point":i==="category"?"band":"linear";if(typeof r=="string"){var a="scale".concat(yy(r));return Cwe(a)?a:"point"}}},mh=tt([ci,kZ,GO],$Z);function d4(t,e,n,r){if(!(n==null||r==null))return typeof t.scale=="function"?y$(t.scale,n,r):y$(e,n,r)}var h4=(t,e,n)=>{var r=i4(e);if(!(n!=="auto"&&n!=="linear")){if(e!=null&&e.tickCount&&Array.isArray(r)&&(r[0]==="auto"||r[1]==="auto")&&gu(t))return H1e(t,e.tickCount,e.allowDecimals);if(e!=null&&e.tickCount&&e.type==="number"&&gu(t))return V1e(t,e.tickCount,e.allowDecimals)}},f4=tt([u4,rx,mh],h4),m4=(t,e,n,r)=>{if(r!=="angleAxis"&&t?.type==="number"&&gu(e)&&Array.isArray(n)&&n.length>0){var i,a,o=e[0],l=(i=n[0])!==null&&i!==void 0?i:0,c=e[1],u=(a=n[n.length-1])!==null&&a!==void 0?a:0;return[Math.min(o,l),Math.max(c,u)]}return e},kwe=tt([ci,u4,f4,Xr],m4),jwe=tt(KE,ci,(t,e)=>{if(!(!e||e.type!=="number")){var n=1/0,r=Array.from(xu(t.map(f=>f.value))).sort((f,m)=>f-m),i=r[0],a=r[r.length-1];if(i==null||a==null)return 1/0;var o=a-i;if(o===0)return 1/0;for(var l=0;l<r.length-1;l++){var c=r[l],u=r[l+1];if(!(c==null||u==null)){var d=u-c;n=Math.min(n,d)}}return n/o}}),HZ=tt(jwe,Fn,bZ,zi,(t,e,n,r,i)=>i,(t,e,n,r,i)=>{if(!pn(t))return 0;var a=e==="vertical"?r.height:r.width;if(i==="gap")return t*a/2;if(i==="no-gap"){var o=Ba(n,t*a),l=t*a/2;return l-o-(l-o)/a*o}return 0}),Pwe=(t,e,n)=>{var r=cc(t,e);return r==null||typeof r.padding!="string"?0:HZ(t,"xAxis",e,n,r.padding)},Rwe=(t,e,n)=>{var r=uc(t,e);return r==null||typeof r.padding!="string"?0:HZ(t,"yAxis",e,n,r.padding)},Dwe=tt(cc,Pwe,(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}}),Owe=tt(uc,Rwe,(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}}),Lwe=tt([zi,Dwe,kE,CE,(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]}),Iwe=tt([zi,Fn,Owe,kE,CE,(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]}),Iy=(t,e,n,r)=>{var i;switch(e){case"xAxis":return Lwe(t,n,r);case"yAxis":return Iwe(t,n,r);case"zAxis":return(i=ZO(t,n))===null||i===void 0?void 0:i.range;case"angleAxis":return SZ(t);case"radiusAxis":return MZ(t,n);default:return}},VZ=tt([ci,Iy],BE),Fwe=tt([mh,kwe],AZ),Eg=tt([ci,mh,Fwe,VZ],d4);tt([Oy,XE,Xr],mwe);function GZ(t,e){return t.id<e.id?-1:t.id>e.id?1:0}var YE=(t,e)=>e,ZE=(t,e,n)=>n,Uwe=tt(AE,YE,ZE,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(GZ)),zwe=tt(TE,YE,ZE,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(GZ)),WZ=(t,e)=>({width:t.width,height:e.height}),Bwe=(t,e)=>{var n=typeof e.width=="number"?e.width:Sy;return{width:n,height:t.height}},qZ=tt(zi,cc,WZ),$we=(t,e,n)=>{switch(e){case"top":return t.top;case"bottom":return n-t.bottom;default:return 0}},Hwe=(t,e,n)=>{switch(e){case"left":return t.left;case"right":return n-t.right;default:return 0}},Vwe=tt(Mu,zi,Uwe,YE,ZE,(t,e,n,r,i)=>{var a={},o;return n.forEach(l=>{var c=WZ(e,l);o==null&&(o=$we(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}),Gwe=tt(Su,zi,zwe,YE,ZE,(t,e,n,r,i)=>{var a={},o;return n.forEach(l=>{var c=Bwe(e,l);o==null&&(o=Hwe(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}),Wwe=(t,e)=>{var n=cc(t,e);if(n!=null)return Vwe(t,n.orientation,n.mirror)},qwe=tt([zi,cc,Wwe,(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}}}),Kwe=(t,e)=>{var n=uc(t,e);if(n!=null)return Gwe(t,n.orientation,n.mirror)},Xwe=tt([zi,uc,Kwe,(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}}}),KZ=tt(zi,uc,(t,e)=>{var n=typeof e.width=="number"?e.width:Sy;return{width:n,height:t.height}}),w$=(t,e,n)=>{switch(e){case"xAxis":return qZ(t,n).width;case"yAxis":return KZ(t,n).height;default:return}},XZ=(t,e,n,r)=>{if(n!=null){var{allowDuplicatedCategory:i,type:a,dataKey:o}=n,l=xl(t,r),c=e.map(u=>u.value);if(o&&l&&a==="category"&&i&&JK(c))return c}},p4=tt([Fn,KE,ci,Xr],XZ),YZ=(t,e,n,r)=>{if(!(n==null||n.dataKey==null)){var{type:i,scale:a}=n,o=xl(t,r);if(o&&(i==="number"||a!=="auto"))return e.map(l=>l.value)}},g4=tt([Fn,KE,rx,Xr],YZ),S$=tt([Fn,swe,mh,Eg,p4,g4,Iy,f4,Xr],(t,e,n,r,i,a,o,l,c)=>{if(e!=null){var u=xl(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}}}),Ywe=(t,e,n,r,i,a,o,l,c)=>{if(!(e==null||r==null)){var u=xl(t,c),{type:d,ticks:f,tickCount:m}=e,p=n==="scaleBand"&&typeof r.bandwidth=="function"?r.bandwidth()/2:2,b=d==="category"&&r.bandwidth?r.bandwidth()/p:0;b=c==="angleAxis"&&a!=null&&a.length>=2?ea(a[0]-a[1])*2*b:b;var v=f||i;return v?v.map((x,y)=>{var S=o?o.indexOf(x):x,M=r.map(S);return pn(M)?{index:y,coordinate:M+b,value:x,offset:b}:null}).filter(ys):u&&l?l.map((x,y)=>{var S=r.map(x);return pn(S)?{coordinate:S+b,value:x,index:y,offset:b}:null}).filter(ys):r.ticks?r.ticks(m).map((x,y)=>{var S=r.map(x);return pn(S)?{coordinate:S+b,value:x,index:y,offset:b}:null}).filter(ys):r.domain().map((x,y)=>{var S=r.map(x);return pn(S)?{coordinate:S+b,value:o?o[x]:x,index:y,offset:b}:null}).filter(ys)}},ZZ=tt([Fn,rx,mh,Eg,f4,Iy,p4,g4,Xr],Ywe),Zwe=(t,e,n,r,i,a,o)=>{if(!(e==null||n==null||r==null||r[0]===r[1])){var l=xl(t,o),{tickCount:c}=e,u=0;return u=o==="angleAxis"&&r?.length>=2?ea(r[0]-r[1])*2*u:u,l&&a?a.map((d,f)=>{var m=n.map(d);return pn(m)?{coordinate:m+u,value:d,index:f,offset:u}:null}).filter(ys):n.ticks?n.ticks(c).map((d,f)=>{var m=n.map(d);return pn(m)?{coordinate:m+u,value:d,index:f,offset:u}:null}).filter(ys):n.domain().map((d,f)=>{var m=n.map(d);return pn(m)?{coordinate:m+u,value:i?i[d]:d,index:f,offset:u}:null}).filter(ys)}},tc=tt([Fn,rx,Eg,Iy,p4,g4,Xr],Zwe),nc=tt(ci,Eg,(t,e)=>{if(!(t==null||e==null))return _S(_S({},t),{},{scale:e})}),Qwe=tt([ci,mh,u4,VZ],d4);tt((t,e,n)=>ZO(t,n),Qwe,(t,e)=>{if(!(t==null||e==null))return _S(_S({},t),{},{scale:e})});var Jwe=tt([Fn,AE,TE],(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}}),QZ=t=>t.options.defaultTooltipEventType,JZ=t=>t.options.validateTooltipEventTypes;function eQ(t,e,n){if(t==null)return e;var r=t?"axis":"item";return n==null?e:n.includes(r)?r:e}function x4(t,e){var n=QZ(t),r=JZ(t);return eQ(e,n,r)}function eSe(t){return Vt(e=>x4(e,t))}var tQ=(t,e)=>{var n,r=Number(e);if(!(ul(r)||e==null))return r>=0?t==null||(n=t[r])===null||n===void 0?void 0:n.value:void 0},tSe=t=>t.tooltip.settings,Sd={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},nSe={itemInteraction:{click:Sd,hover:Sd},axisInteraction:{click:Sd,hover:Sd},keyboardInteraction:Sd,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}},nQ=Ns({name:"tooltip",initialState:nSe,reducers:{addTooltipEntrySettings:{reducer(t,e){t.tooltipItemPayloads.push(e.payload)},prepare:Fr()},replaceTooltipEntrySettings:{reducer(t,e){var{prev:n,next:r}=e.payload,i=rl(t).tooltipItemPayloads.indexOf(n);i>-1&&(t.tooltipItemPayloads[i]=r)},prepare:Fr()},removeTooltipEntrySettings:{reducer(t,e){var n=rl(t).tooltipItemPayloads.indexOf(e.payload);n>-1&&t.tooltipItemPayloads.splice(n,1)},prepare:Fr()},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}}}),{addTooltipEntrySettings:rSe,replaceTooltipEntrySettings:iSe,removeTooltipEntrySettings:aSe,setTooltipSettingsState:sSe,setActiveMouseOverItemIndex:rQ,mouseLeaveItem:oSe,mouseLeaveChart:iQ,setActiveClickItemIndex:lSe,setMouseOverAxisIndex:aQ,setMouseClickAxisIndex:cSe,setSyncInteraction:c3,setKeyboardInteraction:u3}=nQ.actions,uSe=nQ.reducer;function M$(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 A_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?M$(Object(n),!0).forEach(function(r){dSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):M$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function dSe(t,e,n){return(e=hSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function hSe(t){var e=fSe(t,"string");return typeof e=="symbol"?e:e+""}function fSe(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 mSe(t,e,n){return e==="axis"?n==="click"?t.axisInteraction.click:t.axisInteraction.hover:n==="click"?t.itemInteraction.click:t.itemInteraction.hover}function pSe(t){return t.index!=null}var sQ=(t,e,n,r)=>{if(e==null)return Sd;var i=mSe(t,e,n);if(i==null)return Sd;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(pSe(i)){if(a)return A_(A_({},i),{},{active:!0})}else if(r!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:r,graphicalItemId:void 0};return A_(A_({},Sd),{},{coordinate:i.coordinate})};function gSe(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 xSe(t,e){var n=gSe(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 bSe(t,e,n){if(n==null||e==null)return!0;var r=ir(t,e);return r==null||!gu(n)?!0:xSe(r,n)}var b4=(t,e,n,r)=>{var i=t?.index;if(i==null)return null;var a=Number(i);if(!pn(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||bSe(u,n,r)?String(c):null},oQ=(t,e,n,r,i,a,o)=>{if(a!=null){var l=o[0],c=l?.getPosition(a);if(c!=null)return c;var u=i?.[Number(a)];if(u)return n==="horizontal"?{x:u.coordinate,y:(r.top+e)/2}:{x:(r.left+t)/2,y:u.coordinate}}},lQ=(t,e,n,r)=>{if(e==="axis")return t.tooltipItemPayloads;if(t.tooltipItemPayloads.length===0)return[];var i;if(n==="hover"?i=t.itemInteraction.hover.graphicalItemId:i=t.itemInteraction.click.graphicalItemId,i==null&&r!=null){var a=t.tooltipItemPayloads[0];return a!=null?[a]:[]}return t.tooltipItemPayloads.filter(o=>{var l;return((l=o.settings)===null||l===void 0?void 0:l.graphicalItemId)===i})},cQ=t=>t.options.tooltipPayloadSearcher,ax=t=>t.tooltip;function E$(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 N$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?E$(Object(n),!0).forEach(function(r){ySe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):E$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function ySe(t,e,n){return(e=vSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function vSe(t){var e=_Se(t,"string");return typeof e=="symbol"?e:e+""}function _Se(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 wSe(t,e){return t??e}var uQ=(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((m,p)=>{var b,{dataDefinedOnItem:v,settings:x}=p,y=wSe(v,l),S=Array.isArray(y)?qX(y,u,d):y,M=(b=x?.dataKey)!==null&&b!==void 0?b:r,N=x?.nameKey,A;if(r&&Array.isArray(S)&&!Array.isArray(S[0])&&o==="axis"?A=eX(S,r,i):A=a(S,e,c,N),Array.isArray(A))A.forEach(C=>{var D=N$(N$({},x),{},{name:C.name,unit:C.unit,color:void 0,fill:void 0});m.push(M8({tooltipEntrySettings:D,dataKey:C.dataKey,payload:C.payload,value:ir(C.payload,C.dataKey),name:C.name}))});else{var k;m.push(M8({tooltipEntrySettings:x,dataKey:M,payload:A,value:ir(A,M),name:(k=ir(A,N))!==null&&k!==void 0?k:x?.name}))}return m},f)}},y4=tt([Hi,kZ,GO],$Z),SSe=tt([t=>t.graphicalItems.cartesianItems,t=>t.graphicalItems.polarItems],(t,e)=>[...t,...e]),MSe=tt([oa,nx],QO),sx=tt([SSe,Hi,MSe],JO,{memoizeOptions:{resultEqualityCheck:qE}}),ESe=tt([sx],t=>t.filter(GE)),NSe=tt([sx],e4,{memoizeOptions:{resultEqualityCheck:qE}}),ox=tt([NSe,Nu],t4),ASe=tt([ESe,Nu,Hi],NZ),v4=tt([ox,Hi,sx],r4),dQ=tt([Hi],i4),TSe=tt([Hi],t=>t.allowDataOverflow),hQ=tt([dQ,TSe],sZ),CSe=tt([sx],t=>t.filter(GE)),kSe=tt([ASe,CSe,Py,yZ],DZ),jSe=tt([kSe,Nu,oa,hQ],OZ),PSe=tt([sx],PZ),RSe=tt([ox,Hi,PSe,XE,oa],o4,{memoizeOptions:{resultEqualityCheck:WE}}),DSe=tt([LZ,oa,nx],ix),OSe=tt([DSe,oa],UZ),LSe=tt([IZ,oa,nx],ix),ISe=tt([LSe,oa],zZ),FSe=tt([FZ,oa,nx],ix),USe=tt([FSe,oa],BZ),zSe=tt([OSe,USe,ISe],SS),BSe=tt([Hi,dQ,hQ,jSe,RSe,zSe,Fn,oa],l4),Fy=tt([Hi,Fn,ox,v4,Py,oa,BSe],c4),$Se=tt([Fy,Hi,y4],h4),HSe=tt([Hi,Fy,$Se,oa],m4),fQ=t=>{var e=oa(t),n=nx(t),r=!1;return Iy(t,e,n,r)},mQ=tt([Hi,fQ],BE),pQ=tt([Hi,y4,HSe,mQ],d4),VSe=tt([Fn,v4,Hi,oa],XZ),GSe=tt([Fn,v4,Hi,oa],YZ),WSe=(t,e,n,r,i,a,o,l)=>{if(e){var{type:c}=e,u=xl(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?ea(i[0]-i[1])*2*f:f,u&&o?o.map((m,p)=>{var b=r.map(m);return pn(b)?{coordinate:b+f,value:m,index:p,offset:f}:null}).filter(ys):r.domain().map((m,p)=>{var b=r.map(m);return pn(b)?{coordinate:b+f,value:a?a[m]:m,index:p,offset:f}:null}).filter(ys)}}},Au=tt([Fn,Hi,y4,pQ,fQ,VSe,GSe,oa],WSe),_4=tt([QZ,JZ,tSe],(t,e,n)=>eQ(n.shared,t,e)),gQ=t=>t.tooltip.settings.trigger,w4=t=>t.tooltip.settings.defaultIndex,Uy=tt([ax,_4,gQ,w4],sQ),Zd=tt([Uy,ox,Ly,Fy],b4),xQ=tt([Au,Zd],tQ),S4=tt([Uy],t=>{if(t)return t.dataKey}),qSe=tt([Uy],t=>{if(t)return t.graphicalItemId}),bQ=tt([ax,_4,gQ,w4],lQ),KSe=tt([Su,Mu,Fn,zi,Au,w4,bQ],oQ),XSe=tt([Uy,KSe],(t,e)=>t!=null&&t.coordinate?t.coordinate:e),YSe=tt([Uy],t=>{var e;return(e=t?.active)!==null&&e!==void 0?e:!1}),ZSe=tt([bQ,Zd,Nu,Ly,xQ,cQ,_4],uQ),QSe=tt([ZSe],t=>{if(t!=null){var e=t.map(n=>n.payload).filter(n=>n!=null);return Array.from(new Set(e))}});function A$(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 T$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?A$(Object(n),!0).forEach(function(r){JSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):A$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function JSe(t,e,n){return(e=eMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function eMe(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)}var nMe=()=>Vt(Hi),rMe=()=>{var t=nMe(),e=Vt(Au),n=Vt(pQ);return Yd(!t||!n?void 0:T$(T$({},t),{},{scale:n}),e)};function C$(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 Zm(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?C$(Object(n),!0).forEach(function(r){iMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):C$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function iMe(t,e,n){return(e=aMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function aMe(t){var e=sMe(t,"string");return typeof e=="symbol"?e:e+""}function sMe(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 oMe=(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}},lMe=(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 Zm(Zm(Zm({},r),Ei(r.cx,r.cy,o,a)),{},{angle:a,radius:o})}var l=i.coordinate,{angle:c}=r;return Zm(Zm(Zm({},r),Ei(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 cMe(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 yQ=(t,e,n,r,i)=>{var a,o=(a=e?.length)!==null&&a!==void 0?a:0;if(o<=1||t==null)return 0;if(r==="angleAxis"&&i!=null&&Math.abs(Math.abs(i[1]-i[0])-360)<=1e-6)for(var l=0;l<o;l++){var c,u,d,f,m,p=l>0?(c=n[l-1])===null||c===void 0?void 0:c.coordinate:(u=n[o-1])===null||u===void 0?void 0:u.coordinate,b=(d=n[l])===null||d===void 0?void 0:d.coordinate,v=l>=o-1?(f=n[0])===null||f===void 0?void 0:f.coordinate:(m=n[l+1])===null||m===void 0?void 0:m.coordinate,x=void 0;if(!(p==null||b==null||v==null))if(ea(b-p)!==ea(v-b)){var y=[];if(ea(v-b)===ea(i[1]-i[0])){x=v;var S=b+i[1]-i[0];y[0]=Math.min(S,(S+p)/2),y[1]=Math.max(S,(S+p)/2)}else{x=p;var M=v+i[1]-i[0];y[0]=Math.min(b,(M+b)/2),y[1]=Math.max(b,(M+b)/2)}var N=[Math.min(b,(x+b)/2),Math.max(b,(x+b)/2)];if(t>N[0]&&t<=N[1]||t>=y[0]&&t<=y[1]){var A;return(A=n[l])===null||A===void 0?void 0:A.index}}else{var k=Math.min(p,v),C=Math.max(p,v);if(t>(k+b)/2&&t<=(C+b)/2){var D;return(D=n[l])===null||D===void 0?void 0:D.index}}}else if(e)for(var T=0;T<o;T++){var R=e[T];if(R!=null){var U=e[T+1],L=e[T-1];if(T===0&&U!=null&&t<=(R.coordinate+U.coordinate)/2||T===o-1&&L!=null&&t>(R.coordinate+L.coordinate)/2||T>0&&T<o-1&&L!=null&&U!=null&&t>(R.coordinate+L.coordinate)/2&&t<=(R.coordinate+U.coordinate)/2)return R.index}}return-1},vQ=()=>Vt(GO),M4=(t,e)=>e,_Q=(t,e,n)=>n,E4=(t,e,n,r)=>r,uMe=tt(Au,t=>xE(t,e=>e.coordinate)),N4=tt([ax,M4,_Q,E4],sQ),A4=tt([N4,ox,Ly,Fy],b4),dMe=(t,e,n)=>{if(e!=null){var r=ax(t);return e==="axis"?n==="hover"?r.axisInteraction.hover.dataKey:r.axisInteraction.click.dataKey:n==="hover"?r.itemInteraction.hover.dataKey:r.itemInteraction.click.dataKey}},wQ=tt([ax,M4,_Q,E4],lQ),MS=tt([Su,Mu,Fn,zi,Au,E4,wQ],oQ),hMe=tt([N4,MS],(t,e)=>{var n;return(n=t.coordinate)!==null&&n!==void 0?n:e}),SQ=tt([Au,A4],tQ),fMe=tt([wQ,A4,Nu,Ly,SQ,cQ,M4],uQ),mMe=tt([N4,A4],(t,e)=>({isActive:t.active&&e!=null,activeIndex:e})),pMe=(t,e,n,r,i,a,o)=>{if(!(!t||!n||!r||!i)&&cMe(t,o)){var l=Ibe(t,e),c=yQ(l,a,i,n,r),u=oMe(e,i,c,t);return{activeIndex:String(c),activeCoordinate:u}}},gMe=(t,e,n,r,i,a,o)=>{if(!(!t||!r||!i||!a||!n)){var l=eve(t,n);if(l){var c=Fbe(l,e),u=yQ(c,o,a,r,i),d=lMe(e,a,u,l);return{activeIndex:String(u),activeCoordinate:d}}}},xMe=(t,e,n,r,i,a,o,l)=>{if(!(!t||!e||!r||!i||!a))return e==="horizontal"||e==="vertical"?pMe(t,e,r,i,a,o,l):gMe(t,e,n,r,i,a,o)},bMe=tt(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.panoramaElement:r.element}}),yMe=tt(t=>t.zIndex.zIndexMap,t=>{var e=Object.keys(t).map(r=>parseInt(r,10)).concat(Object.values(oi)),n=Array.from(new Set(e));return n.sort((r,i)=>r-i)},{memoizeOptions:{resultEqualityCheck:ewe}});function k$(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 j$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?k$(Object(n),!0).forEach(function(r){vMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):k$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function vMe(t,e,n){return(e=_Me(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function _Me(t){var e=wMe(t,"string");return typeof e=="symbol"?e:e+""}function wMe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var SMe={},MMe={zIndexMap:Object.values(oi).reduce((t,e)=>j$(j$({},t),{},{[e]:{element:void 0,panoramaElement:void 0,consumers:0}}),SMe)},EMe=new Set(Object.values(oi));function NMe(t){return EMe.has(t)}var MQ=Ns({name:"zIndex",initialState:MMe,reducers:{registerZIndexPortal:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]?t.zIndexMap[n].consumers+=1:t.zIndexMap[n]={consumers:1,element:void 0,panoramaElement:void 0}},prepare:Fr()},unregisterZIndexPortal:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]&&(t.zIndexMap[n].consumers-=1,t.zIndexMap[n].consumers<=0&&!NMe(n)&&delete t.zIndexMap[n])},prepare:Fr()},registerZIndexPortalElement:{reducer:(t,e)=>{var{zIndex:n,element:r,isPanorama:i}=e.payload;t.zIndexMap[n]?i?t.zIndexMap[n].panoramaElement=r:t.zIndexMap[n].element=r:t.zIndexMap[n]={consumers:0,element:i?void 0:r,panoramaElement:i?r:void 0}},prepare:Fr()},unregisterZIndexPortalElement:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]&&(e.payload.isPanorama?t.zIndexMap[n].panoramaElement=void 0:t.zIndexMap[n].element=void 0)},prepare:Fr()}}}),{registerZIndexPortal:AMe,unregisterZIndexPortal:TMe,registerZIndexPortalElement:CMe,unregisterZIndexPortalElement:kMe}=MQ.actions,jMe=MQ.reducer;function $a(t){var{zIndex:e,children:n}=t,r=p0e(),i=r&&e!==void 0&&e!==0,a=Bi(),o=Mr();w.useLayoutEffect(()=>i?(o(AMe({zIndex:e})),()=>{o(TMe({zIndex:e}))}):ch,[o,e,i]);var l=Vt(c=>bMe(c,e,a));return i?l?Yc.createPortal(n,l):null:n}function d3(){return d3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},d3.apply(null,arguments)}function P$(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 T_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?P$(Object(n),!0).forEach(function(r){PMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):P$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function PMe(t,e,n){return(e=RMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function RMe(t){var e=DMe(t,"string");return typeof e=="symbol"?e:e+""}function DMe(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 OMe(t){var{cursor:e,cursorComp:n,cursorProps:r}=t;return w.isValidElement(e)?w.cloneElement(e,r):w.createElement(n,r)}function LMe(t){var e,{coordinate:n,payload:r,index:i,offset:a,tooltipAxisBandSize:o,layout:l,cursor:c,tooltipEventType:u,chartName:d}=t,f=n,m=r,p=i;if(!c||!f||d!=="ScatterChart"&&u!=="axis")return null;var b,v,x;if(d==="ScatterChart")b=f,v=mye,x=oi.cursorLine;else if(d==="BarChart")b=pye(l,f,a,o),v=vY,x=oi.cursorRectangle;else if(l==="radial"&&nX(f)){var{cx:y,cy:S,radius:M,startAngle:N,endAngle:A}=wY(f);b={cx:y,cy:S,startAngle:N,endAngle:A,innerRadius:M,outerRadius:M},v=MY,x=oi.cursorLine}else b={points:ive(l,f,a)},v=tg,x=oi.cursorLine;var k=typeof c=="object"&&"className"in c?c.className:void 0,C=T_(T_(T_(T_({stroke:"#ccc",pointerEvents:"none"},a),b),$f(c)),{},{payload:m,payloadIndex:p,className:Bn("recharts-tooltip-cursor",k)});return w.createElement($a,{zIndex:(e=t.zIndex)!==null&&e!==void 0?e:x},w.createElement(OMe,{cursor:c,cursorComp:v,cursorProps:C}))}function IMe(t){var e=rMe(),n=rY(),r=dh(),i=vQ();return e==null||n==null||r==null||i==null?null:w.createElement(LMe,d3({},t,{offset:n,layout:r,tooltipAxisBandSize:e,chartName:i}))}var EQ=w.createContext(null),FMe=()=>w.useContext(EQ),MC={exports:{}},R$;function UMe(){return R$||(R$=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,m){if(typeof d!="function")throw new TypeError("The listener must be a function");var p=new i(d,f||c,m),b=n?n+u:u;return c._events[b]?c._events[b].fn?c._events[b]=[c._events[b],p]:c._events[b].push(p):(c._events[b]=p,c._eventsCount++),c}function 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 m=0,p=f.length,b=new Array(p);m<p;m++)b[m]=f[m].fn;return b},l.prototype.listenerCount=function(u){var d=n?n+u:u,f=this._events[d];return f?f.fn?1:f.length:0},l.prototype.emit=function(u,d,f,m,p,b){var v=n?n+u:u;if(!this._events[v])return!1;var x=this._events[v],y=arguments.length,S,M;if(x.fn){switch(x.once&&this.removeListener(u,x.fn,void 0,!0),y){case 1:return x.fn.call(x.context),!0;case 2:return x.fn.call(x.context,d),!0;case 3:return x.fn.call(x.context,d,f),!0;case 4:return x.fn.call(x.context,d,f,m),!0;case 5:return x.fn.call(x.context,d,f,m,p),!0;case 6:return x.fn.call(x.context,d,f,m,p,b),!0}for(M=1,S=new Array(y-1);M<y;M++)S[M-1]=arguments[M];x.fn.apply(x.context,S)}else{var N=x.length,A;for(M=0;M<N;M++)switch(x[M].once&&this.removeListener(u,x[M].fn,void 0,!0),y){case 1:x[M].fn.call(x[M].context);break;case 2:x[M].fn.call(x[M].context,d);break;case 3:x[M].fn.call(x[M].context,d,f);break;case 4:x[M].fn.call(x[M].context,d,f,m);break;default:if(!S)for(A=1,S=new Array(y-1);A<y;A++)S[A-1]=arguments[A];x[M].fn.apply(x[M].context,S)}}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,m){var p=n?n+u:u;if(!this._events[p])return this;if(!d)return o(this,p),this;var b=this._events[p];if(b.fn)b.fn===d&&(!m||b.once)&&(!f||b.context===f)&&o(this,p);else{for(var v=0,x=[],y=b.length;v<y;v++)(b[v].fn!==d||m&&!b[v].once||f&&b[v].context!==f)&&x.push(b[v]);x.length?this._events[p]=x.length===1?x[0]:x: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})(MC)),MC.exports}var zMe=UMe();const BMe=ml(zMe);var H0=new BMe,h3="recharts.syncEvent.tooltip",D$="recharts.syncEvent.brush",QE=(t,e)=>{if(e&&Array.isArray(t)){var n=Number.parseInt(e,10);if(!ul(n))return t[n]}},$Me={chartName:"",tooltipPayloadSearcher:()=>{},eventEmitter:void 0,defaultTooltipEventType:"axis"},NQ=Ns({name:"options",initialState:$Me,reducers:{createEventEmitter:t=>{t.eventEmitter==null&&(t.eventEmitter=Symbol("rechartsEventEmitter"))}}}),HMe=NQ.reducer,{createEventEmitter:VMe}=NQ.actions;function GMe(t){return t.tooltip.syncInteraction}var WMe={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},AQ=Ns({name:"chartData",initialState:WMe,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:O$,setDataStartEndIndexes:qMe,setComputedData:YZe}=AQ.actions,KMe=AQ.reducer,XMe=["x","y"];function L$(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 Qm(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?L$(Object(n),!0).forEach(function(r){YMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):L$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function YMe(t,e,n){return(e=ZMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ZMe(t){var e=QMe(t,"string");return typeof e=="symbol"?e:e+""}function QMe(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 JMe(t,e){if(t==null)return{};var n,r,i=eEe(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 eEe(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 tEe(){var t=Vt(WO),e=Vt(qO),n=Mr(),r=Vt(vZ),i=Vt(Au),a=dh(),o=My(),l=Vt(c=>c.rootProps.className);w.useEffect(()=>{if(t==null)return ch;var c=(u,d,f)=>{if(e!==f&&t===u){if(r==="index"){var m;if(o&&d!==null&&d!==void 0&&(m=d.payload)!==null&&m!==void 0&&m.coordinate&&d.payload.sourceViewBox){var p=d.payload.coordinate,{x:b,y:v}=p,x=JMe(p,XMe),{x:y,y:S,width:M,height:N}=d.payload.sourceViewBox,A=Qm(Qm({},x),{},{x:o.x+(M?(b-y)/M:0)*o.width,y:o.y+(N?(v-S)/N:0)*o.height});n(Qm(Qm({},d),{},{payload:Qm(Qm({},d.payload),{},{coordinate:A})}))}else n(d);return}if(i!=null){var k;if(typeof r=="function"){var C={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},D=r(i,C);k=i[D]}else r==="value"&&(k=i.find(K=>String(K.value)===d.payload.label));var{coordinate:T}=d.payload;if(k==null||d.payload.active===!1||T==null||o==null){n(c3({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}var{x:R,y:U}=T,L=Math.min(R,o.x+o.width),q=Math.min(U,o.y+o.height),j={x:a==="horizontal"?k.coordinate:L,y:a==="horizontal"?q:k.coordinate},W=c3({active:d.payload.active,coordinate:j,dataKey:d.payload.dataKey,index:String(k.index),label:d.payload.label,sourceViewBox:d.payload.sourceViewBox,graphicalItemId:d.payload.graphicalItemId});n(W)}}};return H0.on(h3,c),()=>{H0.off(h3,c)}},[l,n,e,t,r,i,a,o])}function nEe(){var t=Vt(WO),e=Vt(qO),n=Mr();w.useEffect(()=>{if(t==null)return ch;var r=(i,a,o)=>{e!==o&&t===i&&n(qMe(a))};return H0.on(D$,r),()=>{H0.off(D$,r)}},[n,e,t])}function rEe(){var t=Mr();w.useEffect(()=>{t(VMe())},[t]),tEe(),nEe()}function iEe(t,e,n,r,i,a){var o=Vt(p=>dMe(p,t,e)),l=Vt(qO),c=Vt(WO),u=Vt(vZ),d=Vt(GMe),f=d?.active,m=My();w.useEffect(()=>{if(!f&&c!=null&&l!=null){var p=c3({active:a,coordinate:n,dataKey:o,index:i,label:typeof r=="number"?String(r):r,sourceViewBox:m,graphicalItemId:void 0});H0.emit(h3,c,p,l)}},[f,n,o,i,r,l,c,u,a,m])}function I$(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 F$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?I$(Object(n),!0).forEach(function(r){aEe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):I$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function aEe(t,e,n){return(e=sEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function sEe(t){var e=oEe(t,"string");return typeof e=="symbol"?e:e+""}function oEe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function lEe(t){return t.dataKey}function cEe(t,e){return w.isValidElement(t)?w.cloneElement(t,e):typeof t=="function"?w.createElement(t,e):w.createElement(q0e,e)}var U$=[],uEe={allowEscapeViewBox:{x:!1,y:!1},animationDuration:400,animationEasing:"ease",axisId:0,contentStyle:{},cursor:!0,filterNull:!0,includeHidden:!1,isAnimationActive:"auto",itemSorter:"name",itemStyle:{},labelStyle:{},offset:10,reverseDirection:{x:!1,y:!1},separator:" : ",trigger:"hover",useTranslate3d:!1,wrapperStyle:{}};function iw(t){var e,n,r=Kr(t,uEe),{active:i,allowEscapeViewBox:a,animationDuration:o,animationEasing:l,content:c,filterNull:u,isAnimationActive:d,offset:f,payloadUniqBy:m,position:p,reverseDirection:b,useTranslate3d:v,wrapperStyle:x,cursor:y,shared:S,trigger:M,defaultIndex:N,portal:A,axisId:k}=r,C=Mr(),D=typeof N=="number"?String(N):N;w.useEffect(()=>{C(sSe({shared:S,trigger:M,axisId:k,active:i,defaultIndex:D}))},[C,S,M,k,i,D]);var T=My(),R=pY(),U=eSe(S),{activeIndex:L,isActive:q}=(e=Vt(oe=>mMe(oe,U,M,D)))!==null&&e!==void 0?e:{},j=Vt(oe=>fMe(oe,U,M,D)),W=Vt(oe=>SQ(oe,U,M,D)),K=Vt(oe=>hMe(oe,U,M,D)),V=j,J=FMe(),ne=(n=i??q)!==null&&n!==void 0?n:!1,[te,z]=xX([V,ne]),H=U==="axis"?W:void 0;iEe(U,M,K,H,L,ne);var Z=A??J;if(Z==null||T==null||U==null)return null;var ee=V??U$;ne||(ee=U$),u&&ee.length&&(ee=dX(ee.filter(oe=>oe.value!=null&&(oe.hide!==!0||r.includeHidden)),m,lEe));var he=ee.length>0,fe=w.createElement(eye,{allowEscapeViewBox:a,animationDuration:o,animationEasing:l,isAnimationActive:d,active:ne,coordinate:K,hasPayload:he,offset:f,position:p,reverseDirection:b,useTranslate3d:v,viewBox:T,wrapperStyle:x,lastBoundingBox:te,innerRef:z,hasPortalFromProps:!!A},cEe(c,F$(F$({},r),{},{payload:ee,label:H,active:ne,activeIndex:L,coordinate:K,accessibilityLayer:R})));return w.createElement(w.Fragment,null,Yc.createPortal(fe,Z),ne&&w.createElement(IMe,{cursor:y,tooltipEventType:U,coordinate:K,payload:ee,index:L}))}var zy=t=>null;zy.displayName="Cell";function dEe(t,e,n){return(e=hEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function hEe(t){var e=fEe(t,"string");return typeof e=="symbol"?e:e+""}function fEe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}class mEe{constructor(e){dEe(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 z$(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 pEe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?z$(Object(n),!0).forEach(function(r){gEe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):z$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function gEe(t,e,n){return(e=xEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function xEe(t){var e=bEe(t,"string");return typeof e=="symbol"?e:e+""}function bEe(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 yEe={cacheSize:2e3,enableCache:!0},TQ=pEe({},yEe),B$=new mEe(TQ.cacheSize),vEe={position:"absolute",top:"-20000px",left:0,padding:0,margin:0,border:"none",whiteSpace:"pre"},$$="recharts_measurement_span";function _Ee(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 H$=(t,e)=>{try{var n=document.getElementById($$);n||(n=document.createElement("span"),n.setAttribute("id",$$),n.setAttribute("aria-hidden","true"),document.body.appendChild(n)),Object.assign(n.style,vEe,e),n.textContent="".concat(t);var r=n.getBoundingClientRect();return{width:r.width,height:r.height}}catch{return{width:0,height:0}}},n0=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null||Ay.isSsr)return{width:0,height:0};if(!TQ.enableCache)return H$(e,n);var r=_Ee(e,n),i=B$.get(r);if(i)return i;var a=H$(e,n);return B$.set(r,a),a},CQ;function wEe(t,e,n){return(e=SEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function SEe(t){var e=MEe(t,"string");return typeof e=="symbol"?e:e+""}function MEe(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 V$=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,G$=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,EEe=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,NEe=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,AEe={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},TEe=["cm","mm","pt","pc","in","Q","px"];function CEe(t){return TEe.includes(t)}var Wp="NaN";function kEe(t,e){return t*AEe[e]}class xa{static parse(e){var n,[,r,i]=(n=NEe.exec(e))!==null&&n!==void 0?n:[];return r==null?xa.NaN:new xa(parseFloat(r),i??"")}constructor(e,n){this.num=e,this.unit=n,this.num=e,this.unit=n,ul(e)&&(this.unit=""),n!==""&&!EEe.test(n)&&(this.num=NaN,this.unit=""),CEe(n)&&(this.num=kEe(e,n),this.unit="px")}add(e){return this.unit!==e.unit?new xa(NaN,""):new xa(this.num+e.num,this.unit)}subtract(e){return this.unit!==e.unit?new xa(NaN,""):new xa(this.num-e.num,this.unit)}multiply(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new xa(NaN,""):new xa(this.num*e.num,this.unit||e.unit)}divide(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new xa(NaN,""):new xa(this.num/e.num,this.unit||e.unit)}toString(){return"".concat(this.num).concat(this.unit)}isNaN(){return ul(this.num)}}CQ=xa;wEe(xa,"NaN",new CQ(NaN,""));function kQ(t){if(t==null||t.includes(Wp))return Wp;for(var e=t;e.includes("*")||e.includes("/");){var n,[,r,i,a]=(n=V$.exec(e))!==null&&n!==void 0?n:[],o=xa.parse(r??""),l=xa.parse(a??""),c=i==="*"?o.multiply(l):o.divide(l);if(c.isNaN())return Wp;e=e.replace(V$,c.toString())}for(;e.includes("+")||/.-\d+(?:\.\d+)?/.test(e);){var u,[,d,f,m]=(u=G$.exec(e))!==null&&u!==void 0?u:[],p=xa.parse(d??""),b=xa.parse(m??""),v=f==="+"?p.add(b):p.subtract(b);if(v.isNaN())return Wp;e=e.replace(G$,v.toString())}return e}var W$=/\(([^()]*)\)/;function jEe(t){for(var e=t,n;(n=W$.exec(e))!=null;){var[,r]=n;e=e.replace(W$,kQ(r))}return e}function PEe(t){var e=t.replace(/\s+/g,"");return e=jEe(e),e=kQ(e),e}function REe(t){try{return PEe(t)}catch{return Wp}}function EC(t){var e=REe(t.slice(5,-1));return e===Wp?"":e}var DEe=["x","y","lineHeight","capHeight","fill","scaleToFit","textAnchor","verticalAnchor"],OEe=["dx","dy","angle","className","breakAll"];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 q$(t,e){if(t==null)return{};var n,r,i=LEe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function LEe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var jQ=/[ \f\n\r\t\v\u2028\u2029]+/,PQ=t=>{var{children:e,breakAll:n,style:r}=t;try{var i=[];Hr(e)||(n?i=e.toString().split(""):i=e.toString().split(jQ));var a=i.map(l=>({word:l,width:n0(l,r).width})),o=n?0:n0(" ",r).width;return{wordsWithComputedWidth:a,spaceWidth:o}}catch{return null}};function IEe(t){return t==="start"||t==="middle"||t==="end"||t==="inherit"}var RQ=(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},[]),DQ=t=>t.reduce((e,n)=>e.width>n.width?e:n),FEe="…",K$=(t,e,n,r,i,a,o,l)=>{var c=t.slice(0,e),u=PQ({breakAll:n,style:r,children:c+FEe});if(!u)return[!1,[]];var d=RQ(u.wordsWithComputedWidth,a,o,l),f=d.length>i||DQ(d).width>Number(a);return[f,d]},UEe=(t,e,n,r,i)=>{var{maxLines:a,children:o,style:l,breakAll:c}=t,u=zt(a),d=String(o),f=RQ(e,r,n,i);if(!u||i)return f;var m=f.length>a||DQ(f).width>Number(r);if(!m)return f;for(var p=0,b=d.length-1,v=0,x;p<=b&&v<=d.length-1;){var y=Math.floor((p+b)/2),S=y-1,[M,N]=K$(d,S,c,l,a,r,n,i),[A]=K$(d,y,c,l,a,r,n,i);if(!M&&!A&&(p=y+1),M&&A&&(b=y-1),!M&&A){x=N;break}v++}return x||f},X$=t=>{var e=Hr(t)?[]:t.toString().split(jQ);return[{words:e,width:void 0}]},zEe=t=>{var{width:e,scaleToFit:n,children:r,style:i,breakAll:a,maxLines:o}=t;if((e||n)&&!Ay.isSsr){var l,c,u=PQ({breakAll:a,children:r,style:i});if(u){var{wordsWithComputedWidth:d,spaceWidth:f}=u;l=d,c=f}else return X$(r);return UEe({breakAll:a,children:r,maxLines:o,style:i},l,c,e,!!n)}return X$(r)},OQ="#808080",BEe={angle:0,breakAll:!1,capHeight:"0.71em",fill:OQ,lineHeight:"1em",scaleToFit:!1,textAnchor:"start",verticalAnchor:"end",x:0,y:0},JE=w.forwardRef((t,e)=>{var n=Kr(t,BEe),{x:r,y:i,lineHeight:a,capHeight:o,fill:l,scaleToFit:c,textAnchor:u,verticalAnchor:d}=n,f=q$(n,DEe),m=w.useMemo(()=>zEe({breakAll:f.breakAll,children:f.children,maxLines:f.maxLines,scaleToFit:c,style:f.style,width:f.width}),[f.breakAll,f.children,f.maxLines,c,f.style,f.width]),{dx:p,dy:b,angle:v,className:x,breakAll:y}=f,S=q$(f,OEe);if(!Do(r)||!Do(i)||m.length===0)return null;var M=Number(r)+(zt(p)?p:0),N=Number(i)+(zt(b)?b:0);if(!pn(M)||!pn(N))return null;var A;switch(d){case"start":A=EC("calc(".concat(o,")"));break;case"middle":A=EC("calc(".concat((m.length-1)/2," * -").concat(a," + (").concat(o," / 2))"));break;default:A=EC("calc(".concat(m.length-1," * -").concat(a,")"));break}var k=[],C=m[0];if(c&&C!=null){var D=C.width,{width:T}=f;k.push("scale(".concat(zt(T)&&zt(D)?T/D:1,")"))}return v&&k.push("rotate(".concat(v,", ").concat(M,", ").concat(N,")")),k.length&&(S.transform=k.join(" ")),w.createElement("text",f3({},Aa(S),{ref:e,x:M,y:N,className:Bn("recharts-text",x),textAnchor:u,fill:l.includes("url")?OQ:l}),m.map((R,U)=>{var L=R.words.join(y?"":" ");return w.createElement("tspan",{x:M,dy:U===0?A:a,key:"".concat(L,"-").concat(U)},L)}))});JE.displayName="Text";function Y$(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 Al(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Y$(Object(n),!0).forEach(function(r){$Ee(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Y$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function $Ee(t,e,n){return(e=HEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function HEe(t){var e=VEe(t,"string");return typeof e=="symbol"?e:e+""}function VEe(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 GEe=t=>{var{viewBox:e,position:n,offset:r=0,parentViewBox:i}=t,{x:a,y:o,height:l,upperWidth:c,lowerWidth:u}=hO(e),d=a,f=a+(c-u)/2,m=(d+f)/2,p=(c+u)/2,b=d+c/2,v=l>=0?1:-1,x=v*r,y=v>0?"end":"start",S=v>0?"start":"end",M=c>=0?1:-1,N=M*r,A=M>0?"end":"start",k=M>0?"start":"end",C=i;if(n==="top"){var D={x:d+c/2,y:o-x,horizontalAnchor:"middle",verticalAnchor:y};return C&&(D.height=Math.max(o-C.y,0),D.width=c),D}if(n==="bottom"){var T={x:f+u/2,y:o+l+x,horizontalAnchor:"middle",verticalAnchor:S};return C&&(T.height=Math.max(C.y+C.height-(o+l),0),T.width=u),T}if(n==="left"){var R={x:m-N,y:o+l/2,horizontalAnchor:A,verticalAnchor:"middle"};return C&&(R.width=Math.max(R.x-C.x,0),R.height=l),R}if(n==="right"){var U={x:m+p+N,y:o+l/2,horizontalAnchor:k,verticalAnchor:"middle"};return C&&(U.width=Math.max(C.x+C.width-U.x,0),U.height=l),U}var L=C?{width:p,height:l}:{};return n==="insideLeft"?Al({x:m+N,y:o+l/2,horizontalAnchor:k,verticalAnchor:"middle"},L):n==="insideRight"?Al({x:m+p-N,y:o+l/2,horizontalAnchor:A,verticalAnchor:"middle"},L):n==="insideTop"?Al({x:d+c/2,y:o+x,horizontalAnchor:"middle",verticalAnchor:S},L):n==="insideBottom"?Al({x:f+u/2,y:o+l-x,horizontalAnchor:"middle",verticalAnchor:y},L):n==="insideTopLeft"?Al({x:d+N,y:o+x,horizontalAnchor:k,verticalAnchor:S},L):n==="insideTopRight"?Al({x:d+c-N,y:o+x,horizontalAnchor:A,verticalAnchor:S},L):n==="insideBottomLeft"?Al({x:f+N,y:o+l-x,horizontalAnchor:k,verticalAnchor:y},L):n==="insideBottomRight"?Al({x:f+u-N,y:o+l-x,horizontalAnchor:A,verticalAnchor:y},L):n&&typeof n=="object"&&(zt(n.x)||Gf(n.x))&&(zt(n.y)||Gf(n.y))?Al({x:a+Ba(n.x,p),y:o+Ba(n.y,l),horizontalAnchor:"end",verticalAnchor:"end"},L):Al({x:b,y:o+l/2,horizontalAnchor:"middle",verticalAnchor:"middle"},L)},WEe=["labelRef"],qEe=["content"];function Z$(t,e){if(t==null)return{};var n,r,i=KEe(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 KEe(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 Q$(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 Ub(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Q$(Object(n),!0).forEach(function(r){XEe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Q$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function XEe(t,e,n){return(e=YEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function YEe(t){var e=ZEe(t,"string");return typeof e=="symbol"?e:e+""}function ZEe(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 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)}var LQ=w.createContext(null),IQ=t=>{var{x:e,y:n,upperWidth:r,lowerWidth:i,width:a,height:o,children:l}=t,c=w.useMemo(()=>({x:e,y:n,upperWidth:r,lowerWidth:i,width:a,height:o}),[e,n,r,i,a,o]);return w.createElement(LQ.Provider,{value:c},l)},FQ=()=>{var t=w.useContext(LQ),e=My();return t||(e?hO(e):void 0)},QEe=w.createContext(null),JEe=()=>{var t=w.useContext(QEe),e=Vt(EZ);return t||e},eNe=t=>{var{value:e,formatter:n}=t,r=Hr(t.children)?e:t.children;return typeof n=="function"?n(r):r},T4=t=>t!=null&&typeof t=="function",tNe=(t,e)=>{var n=ea(e-t),r=Math.min(Math.abs(e-t),360);return n*r},nNe=(t,e,n,r,i)=>{var{offset:a,className:o}=t,{cx:l,cy:c,innerRadius:u,outerRadius:d,startAngle:f,endAngle:m,clockWise:p}=i,b=(u+d)/2,v=tNe(f,m),x=v>=0?1:-1,y,S;switch(e){case"insideStart":y=f+x*a,S=p;break;case"insideEnd":y=m-x*a,S=!p;break;case"end":y=m+x*a,S=p;break;default:throw new Error("Unsupported position ".concat(e))}S=v<=0?S:!S;var M=Ei(l,c,b,y),N=Ei(l,c,b,y+(S?1:-1)*359),A="M".concat(M.x,",").concat(M.y,`
  44. A`).concat(b,",").concat(b,",0,1,").concat(S?0:1,`,
  45. `).concat(N.x,",").concat(N.y),k=Hr(t.id)?k0("recharts-radial-line-"):t.id;return w.createElement("text",qc({},r,{dominantBaseline:"central",className:Bn("recharts-radial-bar-label",o)}),w.createElement("defs",null,w.createElement("path",{id:k,d:A})),w.createElement("textPath",{xlinkHref:"#".concat(k)},n))},rNe=(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}=Ei(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 m=(a+o)/2,{x:p,y:b}=Ei(r,i,m,u);return{x:p,y:b,textAnchor:"middle",verticalAnchor:"middle"}},aw=t=>t!=null&&"cx"in t&&zt(t.cx),iNe={angle:0,offset:5,zIndex:oi.label,position:"middle",textBreakAll:!1};function aNe(t){if(!aw(t))return t;var{cx:e,cy:n,outerRadius:r}=t,i=r*2;return{x:e-r,y:n-r,width:i,upperWidth:i,lowerWidth:i,height:i}}function gd(t){var e=Kr(t,iNe),{viewBox:n,parentViewBox:r,position:i,value:a,children:o,content:l,className:c="",textBreakAll:u,labelRef:d}=e,f=JEe(),m=FQ(),p=i==="center"?m:f??m,b,v,x;n==null?b=p:aw(n)?b=n:b=hO(n);var y=aNe(b);if(!b||Hr(a)&&Hr(o)&&!w.isValidElement(l)&&typeof l!="function")return null;var S=Ub(Ub({},e),{},{viewBox:b});if(w.isValidElement(l)){var{labelRef:M}=S,N=Z$(S,WEe);return w.cloneElement(l,N)}if(typeof l=="function"){var{content:A}=S,k=Z$(S,qEe);if(v=w.createElement(l,k),w.isValidElement(v))return v}else v=eNe(e);var C=Aa(e);if(aw(b)){if(i==="insideStart"||i==="insideEnd"||i==="end")return nNe(e,i,v,C,b);x=rNe(b,e.offset,e.position)}else{if(!y)return null;var D=GEe({viewBox:y,position:i,offset:e.offset,parentViewBox:aw(r)?void 0:r});x=Ub(Ub({x:D.x,y:D.y,textAnchor:D.horizontalAnchor,verticalAnchor:D.verticalAnchor},D.width!==void 0?{width:D.width}:{}),D.height!==void 0?{height:D.height}:{})}return w.createElement($a,{zIndex:e.zIndex},w.createElement(JE,qc({ref:d,className:Bn("recharts-label",c)},C,x,{textAnchor:IEe(C.textAnchor)?C.textAnchor:x.textAnchor,breakAll:u}),v))}gd.displayName="Label";var sNe=(t,e,n)=>{if(!t)return null;var r={viewBox:e,labelRef:n};return t===!0?w.createElement(gd,qc({key:"label-implicit"},r)):Do(t)?w.createElement(gd,qc({key:"label-implicit",value:t},r)):w.isValidElement(t)?t.type===gd?w.cloneElement(t,Ub({key:"label-implicit"},r)):w.createElement(gd,qc({key:"label-implicit",content:t},r)):T4(t)?w.createElement(gd,qc({key:"label-implicit",content:t},r)):t&&typeof t=="object"?w.createElement(gd,qc({},t,{key:"label-implicit"},r)):null};function UQ(t){var{label:e,labelRef:n}=t,r=FQ();return sNe(e,r,n)||null}var NC={},AC={},J$;function oNe(){return J$||(J$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n[n.length-1]}t.last=e})(AC)),AC}var TC={},eH;function lNe(){return eH||(eH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Array.isArray(n)?n:Array.from(n)}t.toArray=e})(TC)),TC}var tH;function cNe(){return tH||(tH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=oNe(),n=lNe(),r=tO();function i(a){if(r.isArrayLike(a))return e.last(n.toArray(a))}t.last=i})(NC)),NC}var CC,nH;function uNe(){return nH||(nH=1,CC=cNe().last),CC}var dNe=uNe();const hNe=ml(dNe);var fNe=["valueAccessor"],mNe=["dataKey","clockWise","id","textBreakAll","zIndex"];function ES(){return ES=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},ES.apply(null,arguments)}function rH(t,e){if(t==null)return{};var n,r,i=pNe(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 pNe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var gNe=t=>Array.isArray(t.value)?hNe(t.value):t.value,zQ=w.createContext(void 0),C4=zQ.Provider,BQ=w.createContext(void 0),xNe=BQ.Provider;function bNe(){return w.useContext(zQ)}function yNe(){return w.useContext(BQ)}function sw(t){var{valueAccessor:e=gNe}=t,n=rH(t,fNe),{dataKey:r,clockWise:i,id:a,textBreakAll:o,zIndex:l}=n,c=rH(n,mNe),u=bNe(),d=yNe(),f=u||d;return!f||!f.length?null:w.createElement($a,{zIndex:l??oi.label},w.createElement(qr,{className:"recharts-label-list"},f.map((m,p)=>{var b,v=Hr(r)?e(m,p):ir(m.payload,r),x=Hr(a)?{}:{id:"".concat(a,"-").concat(p)};return w.createElement(gd,ES({key:"label-".concat(p)},Aa(m),c,x,{fill:(b=n.fill)!==null&&b!==void 0?b:m.fill,parentViewBox:m.parentViewBox,value:v,textBreakAll:o,viewBox:m.viewBox,index:p,zIndex:0}))})))}sw.displayName="LabelList";function eN(t){var{label:e}=t;return e?e===!0?w.createElement(sw,{key:"labelList-implicit"}):w.isValidElement(e)||T4(e)?w.createElement(sw,{key:"labelList-implicit",content:e}):typeof e=="object"?w.createElement(sw,ES({key:"labelList-implicit"},e,{type:String(e.type)})):null:null}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)}var $Q=t=>{var{cx:e,cy:n,r,className:i}=t,a=Bn("recharts-dot",i);return zt(e)&&zt(n)&&zt(r)?w.createElement("circle",m3({},ts(t),eO(t),{className:a,cx:e,cy:n,r})):null},HQ=t=>t.graphicalItems.polarItems,vNe=tt([Xr,Ry],QO),tN=tt([HQ,ci,vNe],JO),_Ne=tt([tN],e4),nN=tt([_Ne,zE],t4),wNe=tt([nN,ci,tN],r4);tt([nN,ci,tN],(t,e,n)=>n.length>0?t.flatMap(r=>n.flatMap(i=>{var a,o=ir(r,(a=e.dataKey)!==null&&a!==void 0?a:i.dataKey);return{value:o,errorDomain:[]}})).filter(Boolean):e?.dataKey!=null?t.map(r=>({value:ir(r,e.dataKey),errorDomain:[]})):t.map(r=>({value:r,errorDomain:[]})));var iH=()=>{},SNe=tt([nN,ci,tN,XE,Xr],o4),MNe=tt([ci,a4,s4,iH,SNe,iH,Fn,Xr],l4),VQ=tt([ci,Fn,nN,wNe,Py,Xr,MNe],c4),ENe=tt([VQ,rx,mh],h4),NNe=tt([ci,VQ,ENe,Xr],m4);tt([mh,NNe],AZ);var ANe={radiusAxis:{},angleAxis:{}},GQ=Ns({name:"polarAxis",initialState:ANe,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:ZZe,removeRadiusAxis:QZe,addAngleAxis:JZe,removeAngleAxis:eQe}=GQ.actions,TNe=GQ.reducer;function WQ(t){return t&&typeof t=="object"&&"className"in t&&typeof t.className=="string"?t.className:""}function aH(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 sH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?aH(Object(n),!0).forEach(function(r){CNe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):aH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function CNe(t,e,n){return(e=kNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function kNe(t){var e=jNe(t,"string");return typeof e=="symbol"?e:e+""}function jNe(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 PNe=(t,e)=>e,k4=tt([HQ,PNe],(t,e)=>t.filter(n=>n.type==="pie").find(n=>n.id===e)),RNe=[],j4=(t,e,n)=>n?.length===0?RNe:n,qQ=tt([zE,k4,j4],(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=>sH(sH({},e.presentationProps),a.props))),i!=null)return i}}),DNe=tt([qQ,k4,j4],(t,e,n)=>{if(!(t==null||e==null))return t.map((r,i)=>{var a,o=ir(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:uh(o,e.dataKey),color:l,payload:r,type:e.legendType}})}),ONe=tt([qQ,k4,j4,zi],(t,e,n,r)=>{if(!(e==null||t==null))return L2e({offset:r,pieSettings:e,displayedData:t,cells:n})}),kC={exports:{}},fr={};var oH;function LNe(){if(oH)return fr;oH=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"),m=Symbol.for("react.view_transition"),p=Symbol.for("react.client.reference");function b(v){if(typeof v=="object"&&v!==null){var x=v.$$typeof;switch(x){case t:switch(v=v.type,v){case n:case i:case r:case c:case u:case m:return v;default:switch(v=v&&v.$$typeof,v){case o:case l:case f:case d:return v;case a:return v;default:return x}}case e:return x}}}return fr.ContextConsumer=a,fr.ContextProvider=o,fr.Element=t,fr.ForwardRef=l,fr.Fragment=n,fr.Lazy=f,fr.Memo=d,fr.Portal=e,fr.Profiler=i,fr.StrictMode=r,fr.Suspense=c,fr.SuspenseList=u,fr.isContextConsumer=function(v){return b(v)===a},fr.isContextProvider=function(v){return b(v)===o},fr.isElement=function(v){return typeof v=="object"&&v!==null&&v.$$typeof===t},fr.isForwardRef=function(v){return b(v)===l},fr.isFragment=function(v){return b(v)===n},fr.isLazy=function(v){return b(v)===f},fr.isMemo=function(v){return b(v)===d},fr.isPortal=function(v){return b(v)===e},fr.isProfiler=function(v){return b(v)===i},fr.isStrictMode=function(v){return b(v)===r},fr.isSuspense=function(v){return b(v)===c},fr.isSuspenseList=function(v){return b(v)===u},fr.isValidElementType=function(v){return typeof v=="string"||typeof v=="function"||v===n||v===i||v===r||v===c||v===u||typeof v=="object"&&v!==null&&(v.$$typeof===f||v.$$typeof===d||v.$$typeof===o||v.$$typeof===a||v.$$typeof===l||v.$$typeof===p||v.getModuleId!==void 0)},fr.typeOf=b,fr}var lH;function INe(){return lH||(lH=1,kC.exports=LNe()),kC.exports}var FNe=INe(),cH=t=>typeof t=="string"?t:t?t.displayName||t.name||"Component":"",uH=null,jC=null,KQ=t=>{if(t===uH&&Array.isArray(jC))return jC;var e=[];return w.Children.forEach(t,n=>{Hr(n)||(FNe.isFragment(n)?e=e.concat(KQ(n.props.children)):e.push(n))}),jC=e,uH=t,e};function P4(t,e){var n=[],r=[];return Array.isArray(e)?r=e.map(i=>cH(i)):r=[cH(e)],KQ(t).forEach(i=>{var a=Vf(i,"type.displayName")||Vf(i,"type.name");a&&r.indexOf(a)!==-1&&n.push(i)}),n}var R4=t=>t&&typeof t=="object"&&"clipDot"in t?!!t.clipDot:!0,PC={},dH;function UNe(){return dH||(dH=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})(PC)),PC}var RC,hH;function zNe(){return hH||(hH=1,RC=UNe().isPlainObject),RC}var BNe=zNe();const $Ne=ml(BNe);var fH,mH,pH,gH,xH;function bH(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 yH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?bH(Object(n),!0).forEach(function(r){HNe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):bH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function HNe(t,e,n){return(e=VNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function VNe(t){var e=GNe(t,"string");return typeof e=="symbol"?e:e+""}function GNe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function NS(){return NS=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},NS.apply(null,arguments)}function pb(t,e){return e||(e=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}var vH=(t,e,n,r,i)=>{var a=n-r,o;return o=ni(fH||(fH=pb(["M ",",",""])),t,e),o+=ni(mH||(mH=pb(["L ",",",""])),t+n,e),o+=ni(pH||(pH=pb(["L ",",",""])),t+n-a/2,e+i),o+=ni(gH||(gH=pb(["L ",",",""])),t+n-a/2-r,e+i),o+=ni(xH||(xH=pb(["L ",","," Z"])),t,e),o},WNe={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},qNe=t=>{var e=Kr(t,WNe),{x:n,y:r,upperWidth:i,lowerWidth:a,height:o,className:l}=e,{animationEasing:c,animationDuration:u,animationBegin:d,isUpdateAnimationActive:f}=e,m=w.useRef(null),[p,b]=w.useState(-1),v=w.useRef(i),x=w.useRef(a),y=w.useRef(o),S=w.useRef(n),M=w.useRef(r),N=Qg(t,"trapezoid-");if(w.useEffect(()=>{if(m.current&&m.current.getTotalLength)try{var j=m.current.getTotalLength();j&&b(j)}catch{}},[]),n!==+n||r!==+r||i!==+i||a!==+a||o!==+o||i===0&&a===0||o===0)return null;var A=Bn("recharts-trapezoid",l);if(!f)return w.createElement("g",null,w.createElement("path",NS({},Aa(e),{className:A,d:vH(n,r,i,a,o)})));var k=v.current,C=x.current,D=y.current,T=S.current,R=M.current,U="0px ".concat(p===-1?1:p,"px"),L="".concat(p,"px 0px"),q=gY(["strokeDasharray"],u,c);return w.createElement(Zg,{animationId:N,key:N,canBegin:p>0,duration:u,easing:c,isActive:f,begin:d},j=>{var W=nr(k,i,j),K=nr(C,a,j),V=nr(D,o,j),J=nr(T,n,j),ne=nr(R,r,j);m.current&&(v.current=W,x.current=K,y.current=V,S.current=J,M.current=ne);var te=j>0?{transition:q,strokeDasharray:L}:{strokeDasharray:U};return w.createElement("path",NS({},Aa(e),{className:A,d:vH(J,ne,W,K,V),ref:m,style:yH(yH({},te),e.style)}))})},KNe=["option","shapeType","activeClassName"];function XNe(t,e){if(t==null)return{};var n,r,i=YNe(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 YNe(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 _H(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 AS(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?_H(Object(n),!0).forEach(function(r){ZNe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):_H(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function ZNe(t,e,n){return(e=QNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function QNe(t){var e=JNe(t,"string");return typeof e=="symbol"?e:e+""}function JNe(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 e2e(t,e){return AS(AS({},e),t)}function t2e(t,e){return t==="symbols"}function wH(t){var{shapeType:e,elementProps:n}=t;switch(e){case"rectangle":return w.createElement(vY,n);case"trapezoid":return w.createElement(qNe,n);case"sector":return w.createElement(MY,n);case"symbols":if(t2e(e))return w.createElement(JD,n);break;case"curve":return w.createElement(tg,n);default:return null}}function n2e(t){return w.isValidElement(t)?t.props:t}function D4(t){var{option:e,shapeType:n,activeClassName:r="recharts-active-shape"}=t,i=XNe(t,KNe),a;if(w.isValidElement(e))a=w.cloneElement(e,AS(AS({},i),n2e(e)));else if(typeof e=="function")a=e(i,i.index);else if($Ne(e)&&typeof e!="boolean"){var o=e2e(e,i);a=w.createElement(wH,{shapeType:n,elementProps:o})}else{var l=i;a=w.createElement(wH,{shapeType:n,elementProps:l})}return i.isActive?w.createElement(qr,{className:r},a):a}var O4=(t,e,n)=>{var r=Mr();return(i,a)=>o=>{t?.(i,a,o),r(rQ({activeIndex:String(a),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}},L4=t=>{var e=Mr();return(n,r)=>i=>{t?.(n,r,i),e(oSe())}},I4=(t,e,n)=>{var r=Mr();return(i,a)=>o=>{t?.(i,a,o),r(lSe({activeIndex:String(a),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function rN(t){var{tooltipEntrySettings:e}=t,n=Mr(),r=Bi(),i=w.useRef(null);return w.useLayoutEffect(()=>{r||(i.current===null?n(rSe(e)):i.current!==e&&n(iSe({prev:i.current,next:e})),i.current=e)},[e,n,r]),w.useLayoutEffect(()=>()=>{i.current&&(n(aSe(i.current)),i.current=null)},[n]),null}function F4(t){var{legendPayload:e}=t,n=Mr(),r=Bi(),i=w.useRef(null);return w.useLayoutEffect(()=>{r||(i.current===null?n(hY(e)):i.current!==e&&n(fY({prev:i.current,next:e})),i.current=e)},[n,r,e]),w.useLayoutEffect(()=>()=>{i.current&&(n(mY(i.current)),i.current=null)},[n]),null}function r2e(t){var{legendPayload:e}=t,n=Mr(),r=Vt(Fn),i=w.useRef(null);return w.useLayoutEffect(()=>{r!=="centric"&&r!=="radial"||(i.current===null?n(hY(e)):i.current!==e&&n(fY({prev:i.current,next:e})),i.current=e)},[n,r,e]),w.useLayoutEffect(()=>()=>{i.current&&(n(mY(i.current)),i.current=null)},[n]),null}var DC,i2e=()=>{var[t]=w.useState(()=>k0("uid-"));return t},a2e=(DC=eoe.useId)!==null&&DC!==void 0?DC:i2e;function s2e(t,e){var n=a2e();return e||(t?"".concat(t,"-").concat(n):n)}var o2e=w.createContext(void 0),iN=t=>{var{id:e,type:n,children:r}=t,i=s2e("recharts-".concat(n),e);return w.createElement(o2e.Provider,{value:i},r(i))},l2e={cartesianItems:[],polarItems:[]},XQ=Ns({name:"graphicalItems",initialState:l2e,reducers:{addCartesianGraphicalItem:{reducer(t,e){t.cartesianItems.push(e.payload)},prepare:Fr()},replaceCartesianGraphicalItem:{reducer(t,e){var{prev:n,next:r}=e.payload,i=rl(t).cartesianItems.indexOf(n);i>-1&&(t.cartesianItems[i]=r)},prepare:Fr()},removeCartesianGraphicalItem:{reducer(t,e){var n=rl(t).cartesianItems.indexOf(e.payload);n>-1&&t.cartesianItems.splice(n,1)},prepare:Fr()},addPolarGraphicalItem:{reducer(t,e){t.polarItems.push(e.payload)},prepare:Fr()},removePolarGraphicalItem:{reducer(t,e){var n=rl(t).polarItems.indexOf(e.payload);n>-1&&t.polarItems.splice(n,1)},prepare:Fr()}}}),{addCartesianGraphicalItem:c2e,replaceCartesianGraphicalItem:u2e,removeCartesianGraphicalItem:d2e,addPolarGraphicalItem:h2e,removePolarGraphicalItem:f2e}=XQ.actions,m2e=XQ.reducer,p2e=t=>{var e=Mr(),n=w.useRef(null);return w.useLayoutEffect(()=>{n.current===null?e(c2e(t)):n.current!==t&&e(u2e({prev:n.current,next:t})),n.current=t},[e,t]),w.useLayoutEffect(()=>()=>{n.current&&(e(d2e(n.current)),n.current=null)},[e]),null},U4=w.memo(p2e);function g2e(t){var e=Mr();return w.useLayoutEffect(()=>(e(h2e(t)),()=>{e(f2e(t))}),[e,t]),null}var x2e=["key"],b2e=["onMouseEnter","onClick","onMouseLeave"],y2e=["id"],v2e=["id"];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 ri(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){_2e(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 _2e(t,e,n){return(e=w2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function w2e(t){var e=S2e(t,"string");return typeof e=="symbol"?e:e+""}function S2e(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 Qd(){return Qd=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},Qd.apply(null,arguments)}function aN(t,e){if(t==null)return{};var n,r,i=M2e(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 M2e(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 E2e(t){var e=w.useMemo(()=>P4(t.children,zy),[t.children]),n=Vt(r=>DNe(r,t.id,e));return n==null?null:w.createElement(r2e,{legendPayload:n})}var N2e=w.memo(t=>{var{dataKey:e,nameKey:n,sectors:r,stroke:i,strokeWidth:a,fill:o,name:l,hide:c,tooltipType:u,id:d}=t,f={dataDefinedOnItem:r.map(m=>m.tooltipPayload),getPosition:m=>{var p;return(p=r[Number(m)])===null||p===void 0?void 0:p.tooltipPosition},settings:{stroke:i,strokeWidth:a,fill:o,dataKey:e,nameKey:n,name:uh(l,e),hide:c,type:u,color:o,unit:"",graphicalItemId:d}};return w.createElement(rN,{tooltipEntrySettings:f})}),A2e=(t,e)=>t>e?"start":t<e?"end":"middle",T2e=(t,e,n)=>Ba(typeof e=="function"?e(t):e,n,n*.8),C2e=(t,e,n)=>{var{top:r,left:i,width:a,height:o}=e,l=_Y(a,o),c=i+Ba(t.cx,a,a/2),u=r+Ba(t.cy,o,o/2),d=Ba(t.innerRadius,l,0),f=T2e(n,t.outerRadius,l),m=t.maxRadius||Math.sqrt(a*a+o*o)/2;return{cx:c,cy:u,innerRadius:d,outerRadius:f,maxRadius:m}},k2e=(t,e)=>{var n=ea(e-t),r=Math.min(Math.abs(e-t),360);return n*r},j2e=(t,e)=>{if(w.isValidElement(t))return w.cloneElement(t,e);if(typeof t=="function")return t(e);var n=Bn("recharts-pie-label-line",typeof t!="boolean"?t.className:""),{key:r}=e,i=aN(e,x2e);return w.createElement(tg,Qd({},i,{type:"linear",className:n}))},P2e=(t,e,n)=>{if(w.isValidElement(t))return w.cloneElement(t,e);var r=n;if(typeof t=="function"&&(r=t(e),w.isValidElement(r)))return r;var i=Bn("recharts-pie-label-text",WQ(t));return w.createElement(JE,Qd({},e,{alignmentBaseline:"middle",className:i}),r)};function R2e(t){var{sectors:e,props:n,showLabels:r}=t,{label:i,labelLine:a,dataKey:o}=n;if(!r||!i||!e)return null;var l=ts(n),c=$f(i),u=$f(a),d=typeof i=="object"&&"offsetRadius"in i&&typeof i.offsetRadius=="number"&&i.offsetRadius||20,f=e.map((m,p)=>{var b=(m.startAngle+m.endAngle)/2,v=Ei(m.cx,m.cy,m.outerRadius+d,b),x=ri(ri(ri(ri({},l),m),{},{stroke:"none"},c),{},{index:p,textAnchor:A2e(v.x,m.cx)},v),y=ri(ri(ri(ri({},l),m),{},{fill:"none",stroke:m.fill},u),{},{index:p,points:[Ei(m.cx,m.cy,m.outerRadius,b),v],key:"line"});return w.createElement($a,{zIndex:oi.label,key:"label-".concat(m.startAngle,"-").concat(m.endAngle,"-").concat(m.midAngle,"-").concat(p)},w.createElement(qr,null,a&&j2e(a,y),P2e(i,x,ir(m,o))))});return w.createElement(qr,{className:"recharts-pie-labels"},f)}function D2e(t){var{sectors:e,props:n,showLabels:r}=t,{label:i}=n;return typeof i=="object"&&i!=null&&"position"in i?w.createElement(eN,{label:i}):w.createElement(R2e,{sectors:e,props:n,showLabels:r})}function O2e(t){var{sectors:e,activeShape:n,inactiveShape:r,allOtherPieProps:i,shape:a,id:o}=t,l=Vt(Zd),c=Vt(S4),u=Vt(qSe),{onMouseEnter:d,onClick:f,onMouseLeave:m}=i,p=aN(i,b2e),b=O4(d,i.dataKey,o),v=L4(m),x=I4(f,i.dataKey,o);return e==null||e.length===0?null:w.createElement(w.Fragment,null,e.map((y,S)=>{if(y?.startAngle===0&&y?.endAngle===0&&e.length!==1)return null;var M=u==null||u===o,N=String(S)===l&&(c==null||i.dataKey===c)&&M,A=l?r:null,k=n&&N?n:A,C=ri(ri({},y),{},{stroke:y.stroke,tabIndex:-1,[QX]:S,[JX]:o});return w.createElement(qr,Qd({key:"sector-".concat(y?.startAngle,"-").concat(y?.endAngle,"-").concat(y.midAngle,"-").concat(S),tabIndex:-1,className:"recharts-pie-sector"},vy(p,y,S),{onMouseEnter:b(y,S),onMouseLeave:v(y,S),onClick:x(y,S)}),w.createElement(D4,Qd({option:a??k,index:S,shapeType:"sector",isActive:N},C)))}))}function L2e(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,m=Math.abs(n.minAngle),p=k2e(l,c),b=Math.abs(p),v=r.length<=1?0:(e=n.paddingAngle)!==null&&e!==void 0?e:0,x=r.filter(k=>ir(k,u,0)!==0).length,y=(b>=360?x:x-1)*v,S=b-x*m-y,M=r.reduce((k,C)=>{var D=ir(C,u,0);return k+(zt(D)?D:0)},0),N;if(M>0){var A;N=r.map((k,C)=>{var D=ir(k,u,0),T=ir(k,d,C),R=C2e(n,a,k),U=(zt(D)?D:0)/M,L,q=ri(ri({},k),i&&i[C]&&i[C].props);C?L=A.endAngle+ea(p)*v*(D!==0?1:0):L=l;var j=L+ea(p)*((D!==0?m:0)+U*S),W=(L+j)/2,K=(R.innerRadius+R.outerRadius)/2,V=[{name:T,value:D,payload:q,dataKey:u,type:f,graphicalItemId:n.id}],J=Ei(R.cx,R.cy,K,W);return A=ri(ri(ri(ri({},n.presentationProps),{},{percent:U,cornerRadius:typeof o=="string"?parseFloat(o):o,name:T,tooltipPayload:V,midAngle:W,middleRadius:K,tooltipPosition:J},q),R),{},{value:D,dataKey:u,startAngle:L,endAngle:j,payload:q,paddingAngle:ea(p)*v}),A})}return N}function I2e(t){var{showLabels:e,sectors:n,children:r}=t,i=w.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 w.createElement(xNe,{value:e?i:void 0},r)}function F2e(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:m}=e,p=Qg(e,"recharts-pie-"),b=n.current,[v,x]=w.useState(!1),y=w.useCallback(()=>{typeof m=="function"&&m(),x(!1)},[m]),S=w.useCallback(()=>{typeof f=="function"&&f(),x(!0)},[f]);return w.createElement(I2e,{showLabels:!v,sectors:i},w.createElement(Zg,{animationId:p,begin:o,duration:l,isActive:a,easing:c,onAnimationStart:S,onAnimationEnd:y,key:p},M=>{var N,A=[],k=i&&i[0],C=(N=k?.startAngle)!==null&&N!==void 0?N:0;return i?.forEach((D,T)=>{var R=b&&b[T],U=T>0?Vf(D,"paddingAngle",0):0;if(R){var L=nr(R.endAngle-R.startAngle,D.endAngle-D.startAngle,M),q=ri(ri({},D),{},{startAngle:C+U,endAngle:C+L+U});A.push(q),C=q.endAngle}else{var{endAngle:j,startAngle:W}=D,K=nr(0,j-W,M),V=ri(ri({},D),{},{startAngle:C+U,endAngle:C+K+U});A.push(V),C=V.endAngle}}),n.current=A,w.createElement(qr,null,w.createElement(O2e,{sectors:A,activeShape:u,inactiveShape:d,allOtherPieProps:e,shape:e.shape,id:r}))}),w.createElement(D2e,{showLabels:!v,sectors:i,props:e}),e.children)}var U2e={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:oi.area};function z2e(t){var{id:e}=t,n=aN(t,y2e),{hide:r,className:i,rootTabIndex:a}=t,o=w.useMemo(()=>P4(t.children,zy),[t.children]),l=Vt(d=>ONe(d,e,o)),c=w.useRef(null),u=Bn("recharts-pie",i);return r||l==null?(c.current=null,w.createElement(qr,{tabIndex:a,className:u})):w.createElement($a,{zIndex:t.zIndex},w.createElement(N2e,{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,id:e}),w.createElement(qr,{tabIndex:a,className:u},w.createElement(F2e,{props:ri(ri({},n),{},{sectors:l}),previousSectorsRef:c,id:e})))}function YQ(t){var e=Kr(t,U2e),{id:n}=e,r=aN(e,v2e),i=ts(r);return w.createElement(iN,{id:n,type:"pie"},a=>w.createElement(w.Fragment,null,w.createElement(g2e,{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}),w.createElement(E2e,Qd({},r,{id:a})),w.createElement(z2e,Qd({},r,{id:a}))))}YQ.displayName="Pie";var B2e=["points"];function MH(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 OC(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?MH(Object(n),!0).forEach(function(r){$2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):MH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function $2e(t,e,n){return(e=H2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function H2e(t){var e=V2e(t,"string");return typeof e=="symbol"?e:e+""}function V2e(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 TS(){return TS=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},TS.apply(null,arguments)}function G2e(t,e){if(t==null)return{};var n,r,i=W2e(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 W2e(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 q2e(t){var{option:e,dotProps:n,className:r}=t;if(w.isValidElement(e))return w.cloneElement(e,n);if(typeof e=="function")return e(n);var i=Bn(r,typeof e!="boolean"?e.className:""),a=n??{},{points:o}=a,l=G2e(a,B2e);return w.createElement($Q,TS({},l,{className:i}))}function K2e(t,e){return t==null?!1:e?!0:t.length===1}function ZQ(t){var{points:e,dot:n,className:r,dotClassName:i,dataKey:a,baseProps:o,needClip:l,clipPathId:c,zIndex:u=oi.scatter}=t;if(!K2e(e,n))return null;var d=R4(n),f=gpe(n),m=e.map((b,v)=>{var x,y,S=OC(OC(OC({r:3},o),f),{},{index:v,cx:(x=b.x)!==null&&x!==void 0?x:void 0,cy:(y=b.y)!==null&&y!==void 0?y:void 0,dataKey:a,value:b.value,payload:b.payload,points:e});return w.createElement(q2e,{key:"dot-".concat(v),option:n,dotProps:S,className:i})}),p={};return l&&c!=null&&(p.clipPath="url(#clipPath-".concat(d?"":"dots-").concat(c,")")),w.createElement($a,{zIndex:u},w.createElement(qr,TS({className:r},p),m))}function EH(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 NH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?EH(Object(n),!0).forEach(function(r){X2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):EH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function X2e(t,e,n){return(e=Y2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Y2e(t){var e=Z2e(t,"string");return typeof e=="symbol"?e:e+""}function Z2e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var QQ=0,Q2e={xAxis:{},yAxis:{},zAxis:{}},JQ=Ns({name:"cartesianAxis",initialState:Q2e,reducers:{addXAxis:{reducer(t,e){t.xAxis[e.payload.id]=e.payload},prepare:Fr()},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:Fr()},removeXAxis:{reducer(t,e){delete t.xAxis[e.payload.id]},prepare:Fr()},addYAxis:{reducer(t,e){t.yAxis[e.payload.id]=e.payload},prepare:Fr()},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:Fr()},removeYAxis:{reducer(t,e){delete t.yAxis[e.payload.id]},prepare:Fr()},addZAxis:{reducer(t,e){t.zAxis[e.payload.id]=e.payload},prepare:Fr()},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:Fr()},removeZAxis:{reducer(t,e){delete t.zAxis[e.payload.id]},prepare:Fr()},updateYAxisWidth(t,e){var{id:n,width:r}=e.payload,i=t.yAxis[n];if(i){var a,o=i.widthHistory||[];if(o.length===3&&o[0]===o[2]&&r===o[1]&&r!==i.width&&Math.abs(r-((a=o[0])!==null&&a!==void 0?a:0))<=1)return;var l=[...o,r].slice(-3);t.yAxis[n]=NH(NH({},i),{},{width:r,widthHistory:l})}}}}),{addXAxis:J2e,replaceXAxis:eAe,removeXAxis:tAe,addYAxis:nAe,replaceYAxis:rAe,removeYAxis:iAe,addZAxis:tQe,replaceZAxis:nQe,removeZAxis:rQe,updateYAxisWidth:aAe}=JQ.actions,sAe=JQ.reducer,oAe=tt([zi],t=>({top:t.top,bottom:t.bottom,left:t.left,right:t.right})),lAe=tt([oAe,Su,Mu],(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)}}),sN=()=>Vt(lAe),cAe=()=>Vt(QSe);function AH(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 LC(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?AH(Object(n),!0).forEach(function(r){uAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):AH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function uAe(t,e,n){return(e=dAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function dAe(t){var e=hAe(t,"string");return typeof e=="symbol"?e:e+""}function hAe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var fAe=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=LC(LC(LC({},l),$f(i)),eO(i)),u;return w.isValidElement(i)?u=w.cloneElement(i,c):typeof i=="function"?u=i(c):u=w.createElement($Q,c),w.createElement(qr,{className:"recharts-active-dot",clipPath:o},u)};function p3(t){var{points:e,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:o=oi.activeDot}=t,l=Vt(Zd),c=cAe();if(e==null||c==null)return null;var u=e.find(d=>c.includes(d.payload));return Hr(u)?null:w.createElement($a,{zIndex:o},w.createElement(fAe,{point:u,childIndex:Number(l),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var TH=(t,e,n)=>{var r=n??t;if(!Hr(r))return Ba(r,e,0)},mAe=(t,e,n)=>{var r={},i=t.filter(GE),a=t.filter(u=>u.stackId==null),o=i.reduce((u,d)=>{var f=u[d.stackId];return f==null&&(f=[]),f.push(d),u[d.stackId]=f,u},r),l=Object.entries(o).map(u=>{var d,[f,m]=u,p=m.map(v=>v.dataKey),b=TH(e,n,(d=m[0])===null||d===void 0?void 0:d.barSize);return{stackId:f,dataKeys:p,barSize:b}}),c=a.map(u=>{var d=[u.dataKey].filter(m=>m!=null),f=TH(e,n,u.barSize);return{stackId:void 0,dataKeys:d,barSize:f}});return[...l,...c]};function CH(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 C_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?CH(Object(n),!0).forEach(function(r){pAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):CH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function pAe(t,e,n){return(e=gAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function gAe(t){var e=xAe(t,"string");return typeof e=="symbol"?e:e+""}function xAe(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 bAe(t,e,n,r,i){var a,o=r.length;if(!(o<1)){var l=Ba(t,n,0,!0),c,u=[];if(pn((a=r[0])===null||a===void 0?void 0:a.barSize)){var d=!1,f=n/o,m=r.reduce((S,M)=>S+(M.barSize||0),0);m+=(o-1)*l,m>=n&&(m-=(o-1)*l,l=0),m>=n&&f>0&&(d=!0,f*=.9,m=o*f);var p=(n-m)/2>>0,b={offset:p-l,size:0};c=r.reduce((S,M)=>{var N,A={stackId:M.stackId,dataKeys:M.dataKeys,position:{offset:b.offset+b.size+l,size:d?f:(N=M.barSize)!==null&&N!==void 0?N:0}},k=[...S,A];return b=A.position,k},u)}else{var v=Ba(e,n,0,!0);n-2*v-(o-1)*l<=0&&(l=0);var x=(n-2*v-(o-1)*l)/o;x>1&&(x>>=0);var y=pn(i)?Math.min(x,i):x;c=r.reduce((S,M,N)=>[...S,{stackId:M.stackId,dataKeys:M.dataKeys,position:{offset:v+(x+l)*N+(x-y)/2,size:y}}],u)}return c}}var yAe=(t,e,n,r,i,a,o)=>{var l=Hr(o)?e:o,c=bAe(n,r,i!==a?i:a,t,l);return i!==a&&c!=null&&(c=c.map(u=>C_(C_({},u),{},{position:C_(C_({},u.position),{},{offset:u.position.offset-i/2})}))),c},vAe=(t,e)=>{var n=VE(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)}}}},_Ae=(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}};function wAe(t,e){return t&&typeof t=="object"&&"zIndex"in t&&typeof t.zIndex=="number"&&pn(t.zIndex)?t.zIndex:e}var eJ=t=>{var{chartData:e}=t,n=Mr(),r=Bi();return w.useEffect(()=>r?()=>{}:(n(O$(e)),()=>{n(O$(void 0))}),[e,n,r]),null},kH={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},tJ=Ns({name:"brush",initialState:kH,reducers:{setBrushSettings(t,e){return e.payload==null?kH:e.payload}}}),{setBrushSettings:iQe}=tJ.actions,SAe=tJ.reducer,MAe=(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)}},EAe=t=>{var{x1:e,y1:n,x2:r,y2:i}=t;return MAe({x:e,y:n},{x:r,y:i})};function NAe(t){return(t%180+180)%180}var AAe=function(e){var{width:n,height:r}=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,a=NAe(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)},TAe={dots:[],areas:[],lines:[]},nJ=Ns({name:"referenceElements",initialState:TAe,reducers:{addDot:(t,e)=>{t.dots.push(e.payload)},removeDot:(t,e)=>{var n=rl(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=rl(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=rl(t).lines.findIndex(r=>r===e.payload);n!==-1&&t.lines.splice(n,1)}}}),{addDot:aQe,removeDot:sQe,addArea:oQe,removeArea:lQe,addLine:CAe,removeLine:kAe}=nJ.actions,jAe=nJ.reducer,rJ=w.createContext(void 0),PAe=t=>{var{children:e}=t,[n]=w.useState("".concat(k0("recharts"),"-clip")),r=sN();if(r==null)return null;var{x:i,y:a,width:o,height:l}=r;return w.createElement(rJ.Provider,{value:n},w.createElement("defs",null,w.createElement("clipPath",{id:n},w.createElement("rect",{x:i,y:a,height:l,width:o}))),e)},RAe=()=>w.useContext(rJ);class DAe{constructor(e){var{x:n,y:r}=e;this.xAxisScale=n,this.yAxisScale=r}map(e,n){var r,i,{position:a}=n;return{x:(r=this.xAxisScale.map(e.x,{position:a}))!==null&&r!==void 0?r:0,y:(i=this.yAxisScale.map(e.y,{position:a}))!==null&&i!==void 0?i:0}}mapWithFallback(e,n){var r,i,{position:a,fallback:o}=n,l,c;return o==="rangeMin"?l=this.yAxisScale.rangeMin():o==="rangeMax"?l=this.yAxisScale.rangeMax():l=0,o==="rangeMin"?c=this.xAxisScale.rangeMin():o==="rangeMax"?c=this.xAxisScale.rangeMax():c=0,{x:(r=this.xAxisScale.map(e.x,{position:a}))!==null&&r!==void 0?r:c,y:(i=this.yAxisScale.map(e.y,{position:a}))!==null&&i!==void 0?i:l}}isInRange(e){var{x:n,y:r}=e,i=n==null||this.xAxisScale.isInRange(n),a=r==null||this.yAxisScale.isInRange(r);return i&&a}}function jH(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 PH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?jH(Object(n),!0).forEach(function(r){OAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):jH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function OAe(t,e,n){return(e=LAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function LAe(t){var e=IAe(t,"string");return typeof e=="symbol"?e:e+""}function IAe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function CS(){return CS=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},CS.apply(null,arguments)}var FAe=(t,e)=>{var n;if(w.isValidElement(t))n=w.cloneElement(t,e);else if(typeof t=="function")n=t(e);else{if(!pn(e.x1)||!pn(e.y1)||!pn(e.x2)||!pn(e.y2))return null;n=w.createElement("line",CS({},e,{className:"recharts-reference-line-line"}))}return n},UAe=(t,e,n,r,i,a)=>{var{x:o,width:l}=a,c=i.map(t,{position:n});if(!pn(c)||e==="discard"&&!i.isInRange(c))return null;var u=[{x:o+l,y:c},{x:o,y:c}];return r==="left"?u.reverse():u},zAe=(t,e,n,r,i,a)=>{var{y:o,height:l}=a,c=i.map(t,{position:n});if(!pn(c)||e==="discard"&&!i.isInRange(c))return null;var u=[{x:c,y:o+l},{x:c,y:o}];return r==="top"?u.reverse():u},BAe=(t,e,n,r)=>{var i=[r.mapWithFallback(t[0],{position:n,fallback:"rangeMin"}),r.mapWithFallback(t[1],{position:n,fallback:"rangeMax"})];return e==="discard"&&i.some(a=>!r.isInRange(a))?null:i},$Ae=(t,e,n,r,i,a,o)=>{var{x:l,y:c,segment:u,ifOverflow:d}=o,f=Do(l),m=Do(c);return m?UAe(c,d,r,a,e,n):f?zAe(l,d,r,i,t,n):u!=null&&u.length===2?BAe(u,d,r,new DAe({x:t,y:e})):null};function HAe(t){var e=Mr();return w.useEffect(()=>(e(CAe(t)),()=>{e(kAe(t))})),null}function VAe(t){var{xAxisId:e,yAxisId:n,shape:r,className:i,ifOverflow:a}=t,o=Bi(),l=RAe(),c=Vt(C=>cc(C,e)),u=Vt(C=>uc(C,n)),d=Vt(C=>Eg(C,"xAxis",e,o)),f=Vt(C=>Eg(C,"yAxis",n,o)),m=My();if(!l||!m||c==null||u==null||d==null||f==null)return null;var p=$Ae(d,f,m,t.position,c.orientation,u.orientation,t);if(!p)return null;var b=p[0],v=p[1];if(b==null||v==null)return null;var{x,y}=b,{x:S,y:M}=v,N=a==="hidden"?"url(#".concat(l,")"):void 0,A=PH(PH({clipPath:N},Aa(t)),{},{x1:x,y1:y,x2:S,y2:M}),k=EAe({x1:x,y1:y,x2:S,y2:M});return w.createElement($a,{zIndex:t.zIndex},w.createElement(qr,{className:Bn("recharts-reference-line",i)},FAe(r,A),w.createElement(IQ,CS({},k,{lowerWidth:k.width,upperWidth:k.width}),w.createElement(UQ,{label:t.label}),t.children)))}var GAe={ifOverflow:"discard",xAxisId:0,yAxisId:0,fill:"none",label:!1,stroke:"#ccc",fillOpacity:1,strokeWidth:1,position:"middle",zIndex:oi.line};function zb(t){var e=Kr(t,GAe);return w.createElement(w.Fragment,null,w.createElement(HAe,{yAxisId:e.yAxisId,xAxisId:e.xAxisId,ifOverflow:e.ifOverflow,x:e.x,y:e.y,segment:e.segment}),w.createElement(VAe,e))}zb.displayName="ReferenceLine";function iJ(t,e){if(e<1)return[];if(e===1)return t;for(var n=[],r=0;r<t.length;r+=e){var i=t[r];i!==void 0&&n.push(i)}return n}function WAe(t,e,n){var r={width:t.width+e.width,height:t.height+e.height};return AAe(r,n)}function qAe(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 V0(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 KAe(t,e){return iJ(t,e+1)}function XAe(t,e,n,r,i){for(var a=(r||[]).slice(),{start:o,end:l}=e,c=0,u=1,d=o,f=function(){var b=r?.[c];if(b===void 0)return{v:iJ(r,u)};var v=c,x,y=()=>(x===void 0&&(x=n(b,v)),x),S=b.coordinate,M=c===0||V0(t,S,y,d,l);M||(c=0,d=o,u+=1),M&&(d=S+t*(y()/2+i),c+=u)},m;u<=a.length;)if(m=f(),m)return m.v;return[]}function YAe(t,e,n,r,i){var a=(r||[]).slice(),o=a.length;if(o===0)return[];for(var{start:l,end:c}=e,u=1;u<=o;u++){for(var d=(o-1)%u,f=l,m=!0,p=function(){var N=r[v];if(N==null)return 0;var A=v,k,C=()=>(k===void 0&&(k=n(N,A)),k),D=N.coordinate,T=v===d||V0(t,D,C,f,c);if(!T)return m=!1,1;T&&(f=D+t*(C()/2+i))},b,v=d;v<o&&(b=p(),!(b!==0&&b===1));v+=u);if(m){for(var x=[],y=d;y<o;y+=u){var S=r[y];S!=null&&x.push(S)}return x}}return[]}function RH(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?RH(Object(n),!0).forEach(function(r){ZAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):RH(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 eTe(t,e,n,r,i){for(var a=(r||[]).slice(),o=a.length,{start:l}=e,{end:c}=e,u=function(m){var p=a[m];if(p==null)return 1;var b=p,v,x=()=>(v===void 0&&(v=n(p,m)),v);if(m===o-1){var y=t*(b.coordinate+t*x()/2-c);a[m]=b=Oa(Oa({},b),{},{tickCoord:y>0?b.coordinate-y*t:b.coordinate})}else a[m]=b=Oa(Oa({},b),{},{tickCoord:b.coordinate});if(b.tickCoord!=null){var S=V0(t,b.tickCoord,x,l,c);S&&(c=b.tickCoord-t*(x()/2+i),a[m]=Oa(Oa({},b),{},{isShow:!0}))}},d=o-1;d>=0;d--)u(d);return a}function tTe(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];if(d!=null){var f=n(d,l-1),m=t*(d.coordinate+t*f/2-u);if(o[l-1]=d=Oa(Oa({},d),{},{tickCoord:m>0?d.coordinate-m*t:d.coordinate}),d.tickCoord!=null){var p=V0(t,d.tickCoord,()=>f,c,u);p&&(u=d.tickCoord-t*(f/2+i),o[l-1]=Oa(Oa({},d),{},{isShow:!0}))}}}for(var b=a?l-1:l,v=function(S){var M=o[S];if(M==null)return 1;var N=M,A,k=()=>(A===void 0&&(A=n(M,S)),A);if(S===0){var C=t*(N.coordinate-t*k()/2-c);o[S]=N=Oa(Oa({},N),{},{tickCoord:C<0?N.coordinate-C*t:N.coordinate})}else o[S]=N=Oa(Oa({},N),{},{tickCoord:N.coordinate});if(N.tickCoord!=null){var D=V0(t,N.tickCoord,k,c,u);D&&(c=N.tickCoord+t*(k()/2+i),o[S]=Oa(Oa({},N),{},{isShow:!0}))}},x=0;x<b;x++)v(x);return o}function z4(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(zt(c)||Ay.isSsr){var m;return(m=KAe(i,zt(c)?c:0))!==null&&m!==void 0?m:[]}var p=[],b=l==="top"||l==="bottom"?"width":"height",v=d&&b==="width"?n0(d,{fontSize:e,letterSpacing:n}):{width:0,height:0},x=(A,k)=>{var C=typeof u=="function"?u(A.value,k):A.value;return b==="width"?WAe(n0(C,{fontSize:e,letterSpacing:n}),v,f):n0(C,{fontSize:e,letterSpacing:n})[b]},y=i[0],S=i[1],M=i.length>=2&&y!=null&&S!=null?ea(S.coordinate-y.coordinate):1,N=qAe(a,M,b);return c==="equidistantPreserveStart"?XAe(M,N,x,i,o):c==="equidistantPreserveEnd"?YAe(M,N,x,i,o):(c==="preserveStart"||c==="preserveStartEnd"?p=tTe(M,N,x,i,o,c==="preserveStartEnd"):p=eTe(M,N,x,i,o),p.filter(A=>A.isShow))}var nTe=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},rTe=["axisLine","width","height","className","hide","ticks","axisType"];function iTe(t,e){if(t==null)return{};var n,r,i=aTe(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 aTe(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 Yf(){return Yf=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},Yf.apply(null,arguments)}function DH(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 ti(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?DH(Object(n),!0).forEach(function(r){sTe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):DH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function sTe(t,e,n){return(e=oTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function oTe(t){var e=lTe(t,"string");return typeof e=="symbol"?e:e+""}function lTe(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 iu={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:oi.axis};function cTe(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=ti(ti(ti({},c),ts(l)),{},{fill:"none"});if(a==="top"||a==="bottom"){var d=+(a==="top"&&!o||a==="bottom"&&o);u=ti(ti({},u),{},{x1:e,y1:n+d*i,x2:e+r,y2:n+d*i})}else{var f=+(a==="left"&&!o||a==="right"&&o);u=ti(ti({},u),{},{x1:e+f*r,y1:n,x2:e+f*r,y2:n+i})}return w.createElement("line",Yf({},u,{className:Bn("recharts-cartesian-axis-line",Vf(l,"className"))}))}function uTe(t,e,n,r,i,a,o,l,c){var u,d,f,m,p,b,v=l?-1:1,x=t.tickSize||o,y=zt(t.tickCoord)?t.tickCoord:t.coordinate;switch(a){case"top":u=d=t.coordinate,m=n+ +!l*i,f=m-v*x,b=f-v*c,p=y;break;case"left":f=m=t.coordinate,d=e+ +!l*r,u=d-v*x,p=u-v*c,b=y;break;case"right":f=m=t.coordinate,d=e+ +l*r,u=d+v*x,p=u+v*c,b=y;break;default:u=d=t.coordinate,m=n+ +l*i,f=m+v*x,b=f+v*c,p=y;break}return{line:{x1:u,y1:f,x2:d,y2:m},tick:{x:p,y:b}}}function dTe(t,e){switch(t){case"left":return e?"start":"end";case"right":return e?"end":"start";default:return"middle"}}function hTe(t,e){switch(t){case"left":case"right":return"middle";case"top":return e?"start":"end";default:return e?"end":"start"}}function fTe(t){var{option:e,tickProps:n,value:r}=t,i,a=Bn(n.className,"recharts-cartesian-axis-tick-value");if(w.isValidElement(e))i=w.cloneElement(e,ti(ti({},n),{},{className:a}));else if(typeof e=="function")i=e(ti(ti({},n),{},{className:a}));else{var o="recharts-cartesian-axis-tick-value";typeof e!="boolean"&&(o=Bn(o,WQ(e))),i=w.createElement(JE,Yf({},n,{className:o}),r)}return i}var mTe=w.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:m,y:p,width:b,height:v,tickSize:x,tickMargin:y,fontSize:S,letterSpacing:M,getTicksConfig:N,events:A,axisType:k}=t,C=z4(ti(ti({},N),{},{ticks:n}),S,M),D=dTe(d,f),T=hTe(d,f),R=ts(N),U=$f(r),L={};typeof i=="object"&&(L=i);var q=ti(ti({},R),{},{fill:"none"},L),j=C.map(V=>ti({entry:V},uTe(V,m,p,b,v,d,x,f,y))),W=j.map(V=>{var{entry:J,line:ne}=V;return w.createElement(qr,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(J.value,"-").concat(J.coordinate,"-").concat(J.tickCoord)},i&&w.createElement("line",Yf({},q,ne,{className:Bn("recharts-cartesian-axis-tick-line",Vf(i,"className"))})))}),K=j.map((V,J)=>{var ne,te,{entry:z,tick:H}=V,Z=ti(ti(ti(ti({verticalAnchor:T},R),{},{textAnchor:D,stroke:"none",fill:a},H),{},{index:J,payload:z,visibleTicksCount:C.length,tickFormatter:o,padding:c},u),{},{angle:(ne=(te=u?.angle)!==null&&te!==void 0?te:R.angle)!==null&&ne!==void 0?ne:0}),ee=ti(ti({},Z),U);return w.createElement(qr,Yf({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(z.value,"-").concat(z.coordinate,"-").concat(z.tickCoord)},vy(A,z,J)),r&&w.createElement(fTe,{option:r,tickProps:ee,value:"".concat(typeof o=="function"?o(z.value,J):z.value).concat(l||"")}))});return w.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(k,"-ticks")},K.length>0&&w.createElement($a,{zIndex:oi.label},w.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(k,"-tick-labels"),ref:e},K)),W.length>0&&w.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(k,"-tick-lines")},W))}),pTe=w.forwardRef((t,e)=>{var{axisLine:n,width:r,height:i,className:a,hide:o,ticks:l,axisType:c}=t,u=iTe(t,rTe),[d,f]=w.useState(""),[m,p]=w.useState(""),b=w.useRef(null);w.useImperativeHandle(e,()=>({getCalculatedWidth:()=>{var x;return nTe({ticks:b.current,label:(x=t.labelRef)===null||x===void 0?void 0:x.current,labelGapWithTick:5,tickSize:t.tickSize,tickMargin:t.tickMargin})}}));var v=w.useCallback(x=>{if(x){var y=x.getElementsByClassName("recharts-cartesian-axis-tick-value");b.current=y;var S=y[0];if(S){var M=window.getComputedStyle(S),N=M.fontSize,A=M.letterSpacing;(N!==d||A!==m)&&(f(N),p(A))}}},[d,m]);return o||r!=null&&r<=0||i!=null&&i<=0?null:w.createElement($a,{zIndex:t.zIndex},w.createElement(qr,{className:Bn("recharts-cartesian-axis",a)},w.createElement(cTe,{x:t.x,y:t.y,width:r,height:i,orientation:t.orientation,mirror:t.mirror,axisLine:n,otherSvgProps:ts(t)}),w.createElement(mTe,{ref:v,axisType:c,events:u,fontSize:d,getTicksConfig:t,height:t.height,letterSpacing:m,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}),w.createElement(IQ,{x:t.x,y:t.y,width:t.width,height:t.height,lowerWidth:t.width,upperWidth:t.width},w.createElement(UQ,{label:t.label,labelRef:t.labelRef}),t.children)))}),B4=w.forwardRef((t,e)=>{var n=Kr(t,iu);return w.createElement(pTe,Yf({},n,{ref:e}))});B4.displayName="CartesianAxis";var gTe=["x1","y1","x2","y2","key"],xTe=["offset"],bTe=["xAxisId","yAxisId"],yTe=["xAxisId","yAxisId"];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 Fa(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){vTe(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 vTe(t,e,n){return(e=_Te(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function _Te(t){var e=wTe(t,"string");return typeof e=="symbol"?e:e+""}function wTe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function ff(){return ff=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},ff.apply(null,arguments)}function kS(t,e){if(t==null)return{};var n,r,i=STe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function STe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var MTe=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 w.createElement("rect",{x:r,y:i,ry:l,width:a,height:o,stroke:"none",fill:e,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function aJ(t){var{option:e,lineItemProps:n}=t,r;if(w.isValidElement(e))r=w.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=kS(n,gTe),f=(i=ts(d))!==null&&i!==void 0?i:{},{offset:m}=f,p=kS(f,xTe);r=w.createElement("line",ff({},p,{x1:a,y1:o,x2:l,y2:c,fill:"none",key:u}))}return r}function ETe(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=kS(t,bTe),c=i.map((u,d)=>{var f=Fa(Fa({},l),{},{x1:e,y1:u,x2:e+n,y2:u,key:"line-".concat(d),index:d});return w.createElement(aJ,{key:"line-".concat(d),option:r,lineItemProps:f})});return w.createElement("g",{className:"recharts-cartesian-grid-horizontal"},c)}function NTe(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=kS(t,yTe),c=i.map((u,d)=>{var f=Fa(Fa({},l),{},{x1:u,y1:e,x2:u,y2:e+n,key:"line-".concat(d),index:d});return w.createElement(aJ,{option:r,lineItemProps:f,key:"line-".concat(d)})});return w.createElement("g",{className:"recharts-cartesian-grid-vertical"},c)}function ATe(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,m)=>f-m);i!==u[0]&&u.unshift(0);var d=u.map((f,m)=>{var p=u[m+1],b=p==null,v=b?i+o-f:p-f;if(v<=0)return null;var x=m%e.length;return w.createElement("rect",{key:"react-".concat(m),y:f,x:r,height:v,width:a,stroke:"none",fill:e[x],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return w.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},d)}function TTe(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,m)=>f-m);i!==u[0]&&u.unshift(0);var d=u.map((f,m)=>{var p=u[m+1],b=p==null,v=b?i+o-f:p-f;if(v<=0)return null;var x=m%n.length;return w.createElement("rect",{key:"react-".concat(m),x:f,y:a,width:v,height:l,stroke:"none",fill:n[x],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return w.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},d)}var CTe=(t,e)=>{var{xAxis:n,width:r,height:i,offset:a}=t;return KX(z4(Fa(Fa(Fa({},iu),n),{},{ticks:XX(n),viewBox:{x:0,y:0,width:r,height:i}})),a.left,a.left+a.width,e)},kTe=(t,e)=>{var{yAxis:n,width:r,height:i,offset:a}=t;return KX(z4(Fa(Fa(Fa({},iu),n),{},{ticks:XX(n),viewBox:{x:0,y:0,width:r,height:i}})),a.top,a.top+a.height,e)},jTe={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:oi.grid};function jS(t){var e=fO(),n=mO(),r=rY(),i=Fa(Fa({},Kr(t,jTe)),{},{x:zt(t.x)?t.x:r.left,y:zt(t.y)?t.y:r.top,width:zt(t.width)?t.width:r.width,height:zt(t.height)?t.height:r.height}),{xAxisId:a,yAxisId:o,x:l,y:c,width:u,height:d,syncWithTicks:f,horizontalValues:m,verticalValues:p}=i,b=Bi(),v=Vt(T=>S$(T,"xAxis",a,b)),x=Vt(T=>S$(T,"yAxis",o,b));if(!Jl(u)||!Jl(d)||!zt(l)||!zt(c))return null;var y=i.verticalCoordinatesGenerator||CTe,S=i.horizontalCoordinatesGenerator||kTe,{horizontalPoints:M,verticalPoints:N}=i;if((!M||!M.length)&&typeof S=="function"){var A=m&&m.length,k=S({yAxis:x?Fa(Fa({},x),{},{ticks:A?m:x.ticks}):void 0,width:e??u,height:n??d,offset:r},A?!0:f);eS(Array.isArray(k),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof k,"]")),Array.isArray(k)&&(M=k)}if((!N||!N.length)&&typeof y=="function"){var C=p&&p.length,D=y({xAxis:v?Fa(Fa({},v),{},{ticks:C?p:v.ticks}):void 0,width:e??u,height:n??d,offset:r},C?!0:f);eS(Array.isArray(D),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof D,"]")),Array.isArray(D)&&(N=D)}return w.createElement($a,{zIndex:i.zIndex},w.createElement("g",{className:"recharts-cartesian-grid"},w.createElement(MTe,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),w.createElement(ATe,ff({},i,{horizontalPoints:M})),w.createElement(TTe,ff({},i,{verticalPoints:N})),w.createElement(ETe,ff({},i,{offset:r,horizontalPoints:M,xAxis:v,yAxis:x})),w.createElement(NTe,ff({},i,{offset:r,verticalPoints:N,xAxis:v,yAxis:x}))))}jS.displayName="CartesianGrid";var PTe={},sJ=Ns({name:"errorBars",initialState:PTe,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:cQe,replaceErrorBar:uQe,removeErrorBar:dQe}=sJ.actions,RTe=sJ.reducer,DTe=["children"];function OTe(t,e){if(t==null)return{};var n,r,i=LTe(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 LTe(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 ITe={data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0},FTe=w.createContext(ITe);function oJ(t){var{children:e}=t,n=OTe(t,DTe);return w.createElement(FTe.Provider,{value:n},e)}function oN(t,e){var n,r,i=Vt(u=>cc(u,t)),a=Vt(u=>uc(u,e)),o=(n=i?.allowDataOverflow)!==null&&n!==void 0?n:Xi.allowDataOverflow,l=(r=a?.allowDataOverflow)!==null&&r!==void 0?r:Yi.allowDataOverflow,c=o||l;return{needClip:c,needClipX:o,needClipY:l}}function $4(t){var{xAxisId:e,yAxisId:n,clipPathId:r}=t,i=sN(),{needClipX:a,needClipY:o,needClip:l}=oN(e,n);if(!l||!i)return null;var{x:c,y:u,width:d,height:f}=i;return w.createElement("clipPath",{id:"clipPath-".concat(r)},w.createElement("rect",{x:a?c:c-d/2,y:o?u:u-f/2,width:a?d:d*2,height:o?f:f*2}))}var lJ=(t,e,n,r)=>nc(t,"xAxis",e,r),cJ=(t,e,n,r)=>tc(t,"xAxis",e,r),uJ=(t,e,n,r)=>nc(t,"yAxis",n,r),dJ=(t,e,n,r)=>tc(t,"yAxis",n,r),UTe=tt([Fn,lJ,uJ,cJ,dJ],(t,e,n,r,i)=>xl(t,"xAxis")?Yd(e,r,!1):Yd(n,i,!1)),zTe=(t,e,n,r,i)=>i;function BTe(t){return t.type==="line"}var $Te=tt([Dy,zTe],(t,e)=>t.filter(BTe).find(n=>n.id===e)),HTe=tt([Fn,lJ,uJ,cJ,dJ,$Te,UTe,$O],(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:m}=a,p;if(m!=null&&m.length>0?p=m:p=c?.slice(u,d+1),p!=null)return CCe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:f,bandSize:o,displayedData:p})}});function hJ(t){var e=$f(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 IC={exports:{}},FC={};var LH;function VTe(){if(LH)return FC;LH=1;var t=Vg();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 FC.useSyncExternalStoreWithSelector=function(c,u,d,f,m){var p=i(null);if(p.current===null){var b={hasValue:!1,value:null};p.current=b}else b=p.current;p=o(function(){function x(A){if(!y){if(y=!0,S=A,A=f(A),m!==void 0&&b.hasValue){var k=b.value;if(m(k,A))return M=k}return M=A}if(k=M,n(S,A))return k;var C=f(A);return m!==void 0&&m(k,C)?(S=A,k):(S=A,M=C)}var y=!1,S,M,N=d===void 0?null:d;return[function(){return x(u())},N===null?void 0:function(){return x(N())}]},[u,d,f,m]);var v=r(c,p[0],p[1]);return a(function(){b.hasValue=!0,b.value=v},[v]),l(v),v},FC}var IH;function GTe(){return IH||(IH=1,IC.exports=VTe()),IC.exports}GTe();function WTe(t){t()}function qTe(){let t=null,e=null;return{clear(){t=null,e=null},notify(){WTe(()=>{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 FH={notify(){},get:()=>[]};function KTe(t,e){let n,r=FH,i=0,a=!1;function o(v){d();const x=r.subscribe(v);let y=!1;return()=>{y||(y=!0,x(),f())}}function l(){r.notify()}function c(){b.onStateChange&&b.onStateChange()}function u(){return a}function d(){i++,n||(n=t.subscribe(c),r=qTe())}function f(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=FH)}function m(){a||(a=!0,d())}function p(){a&&(a=!1,f())}const b={addNestedSub:o,notifyNestedSubs:l,handleChangeWrapper:c,isSubscribed:u,trySubscribe:m,tryUnsubscribe:p,getListeners:()=>r};return b}var XTe=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",YTe=XTe(),ZTe=()=>typeof navigator<"u"&&navigator.product==="ReactNative",QTe=ZTe(),JTe=()=>YTe||QTe?w.useLayoutEffect:w.useEffect,eCe=JTe();function UH(t,e){return t===e?t!==0||e!==0||1/t===1/e:t!==t&&e!==e}function tCe(t,e){if(UH(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])||!UH(t[n[i]],e[n[i]]))return!1;return!0}var nCe=Symbol.for("react-redux-context"),rCe=typeof globalThis<"u"?globalThis:{};function iCe(){if(!w.createContext)return{};const t=rCe[nCe]??=new Map;let e=t.get(w.createContext);return e||(e=w.createContext(null),t.set(w.createContext,e)),e}var aCe=iCe();function sCe(t){const{children:e,context:n,serverState:r,store:i}=t,a=w.useMemo(()=>{const c=KTe(i);return{store:i,subscription:c,getServerState:r?()=>r:void 0}},[i,r]),o=w.useMemo(()=>i.getState(),[i]);eCe(()=>{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||aCe;return w.createElement(l.Provider,{value:a},e)}var oCe=sCe,lCe=new Set(["axisLine","tickLine","activeBar","activeDot","activeLabel","activeShape","allowEscapeViewBox","background","cursor","dot","label","line","margin","padding","position","shape","style","tick","wrapperStyle","radius"]);function cCe(t,e){return t==null&&e==null?!0:typeof t=="number"&&typeof e=="number"?t===e||t!==t&&e!==e:t===e}function By(t,e){var n=new Set([...Object.keys(t),...Object.keys(e)]);for(var r of n)if(lCe.has(r)){if(t[r]==null&&e[r]==null)continue;if(!tCe(t[r],e[r]))return!1}else if(!cCe(t[r],e[r]))return!1;return!0}var uCe=["id"],dCe=["type","layout","connectNulls","needClip","shape"],hCe=["activeDot","animateNewValues","animationBegin","animationDuration","animationEasing","connectNulls","dot","hide","isAnimationActive","label","legendType","xAxisId","yAxisId","id"];function G0(){return G0=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},G0.apply(null,arguments)}function zH(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 Ol(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?zH(Object(n),!0).forEach(function(r){fCe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):zH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function fCe(t,e,n){return(e=mCe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function mCe(t){var e=pCe(t,"string");return typeof e=="symbol"?e:e+""}function pCe(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 H4(t,e){if(t==null)return{};var n,r,i=gCe(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 gCe(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 xCe=t=>{var{dataKey:e,name:n,stroke:r,legendType:i,hide:a}=t;return[{inactive:a,dataKey:e,type:i,color:r,value:uh(n,e),payload:t}]},bCe=w.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:l,unit:c,tooltipType:u,id:d}=t,f={dataDefinedOnItem:n,getPosition:ch,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:e,nameKey:void 0,name:uh(o,e),hide:l,type:u,color:r,unit:c,graphicalItemId:d}};return w.createElement(rN,{tooltipEntrySettings:f})}),fJ=(t,e)=>"".concat(e,"px ").concat(t-e,"px");function yCe(t,e){for(var n=t.length%2!==0?[...t,0]:t,r=[],i=0;i<e;++i)r=[...r,...n];return r}var vCe=(t,e,n)=>{var r=n.reduce((p,b)=>p+b);if(!r)return fJ(e,t);for(var i=Math.floor(t/r),a=t%r,o=e-t,l=[],c=0,u=0;c<n.length;u+=(d=n[c])!==null&&d!==void 0?d:0,++c){var d,f=n[c];if(f!=null&&u+f>a){l=[...n.slice(0,c),a-u];break}}var m=l.length%2===0?[0,o]:[o];return[...yCe(n,i),...l,...m].map(p=>"".concat(p,"px")).join(", ")};function _Ce(t){var{clipPathId:e,points:n,props:r}=t,{dot:i,dataKey:a,needClip:o}=r,{id:l}=r,c=H4(r,uCe),u=ts(c);return w.createElement(ZQ,{points:n,dot:i,className:"recharts-line-dots",dotClassName:"recharts-line-dot",dataKey:a,baseProps:u,needClip:o,clipPathId:e})}function wCe(t){var{showLabels:e,children:n,points:r}=t,i=w.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 Ol(Ol({},c),{},{value:a.value,payload:a.payload,viewBox:c,parentViewBox:void 0,fill:void 0})}),[r]);return w.createElement(C4,{value:e?i:void 0},n)}function BH(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=H4(a,dCe),m=Ol(Ol({},Aa(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 w.createElement(w.Fragment,null,r?.length>1&&w.createElement(D4,G0({shapeType:"curve",option:d},m,{pathRef:n})),w.createElement(_Ce,{points:r,clipPathId:e,props:a}))}function SCe(t){try{return t&&t.getTotalLength&&t.getTotalLength()||0}catch{return 0}}function MCe(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:m,width:p,height:b,onAnimationEnd:v,onAnimationStart:x}=n,y=i.current,S=Qg(o,"recharts-line-"),M=w.useRef(S),[N,A]=w.useState(!1),k=!N,C=w.useCallback(()=>{typeof v=="function"&&v(),A(!1)},[v]),D=w.useCallback(()=>{typeof x=="function"&&x(),A(!0)},[x]),T=SCe(r.current),R=w.useRef(0);M.current!==S&&(R.current=a.current,M.current=S);var U=R.current;return w.createElement(wCe,{points:o,showLabels:k},n.children,w.createElement(Zg,{animationId:S,begin:u,duration:d,isActive:c,easing:f,onAnimationEnd:C,onAnimationStart:D,key:S},L=>{var q=nr(U,T+U,L),j=Math.min(q,T),W;if(c)if(l){var K="".concat(l).split(/[,\s]+/gim).map(ne=>parseFloat(ne));W=vCe(j,T,K)}else W=fJ(T,j);else W=l==null?void 0:String(l);if(L>0&&T>0&&(i.current=o,a.current=Math.max(a.current,j)),y){var V=y.length/o.length,J=L===1?o:o.map((ne,te)=>{var z=Math.floor(te*V);if(y[z]){var H=y[z];return Ol(Ol({},ne),{},{x:nr(H.x,ne.x,L),y:nr(H.y,ne.y,L)})}return m?Ol(Ol({},ne),{},{x:nr(p*2,ne.x,L),y:nr(b/2,ne.y,L)}):Ol(Ol({},ne),{},{x:ne.x,y:ne.y})});return i.current=J,w.createElement(BH,{props:n,points:J,clipPathId:e,pathRef:r,strokeDasharray:W})}return w.createElement(BH,{props:n,points:o,clipPathId:e,pathRef:r,strokeDasharray:W})}),w.createElement(eN,{label:n.label}))}function ECe(t){var{clipPathId:e,props:n}=t,r=w.useRef(null),i=w.useRef(0),a=w.useRef(null);return w.createElement(MCe,{props:n,clipPathId:e,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:a})}var NCe=(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:ir(t.payload,e)}};class ACe extends w.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:m,zIndex:p}=this.props;if(e)return null;var b=Bn("recharts-line",i),v=f,{r:x,strokeWidth:y}=hJ(n),S=R4(n),M=x*2+y,N=m?"url(#clipPath-".concat(S?"":"dots-").concat(v,")"):void 0;return w.createElement($a,{zIndex:p},w.createElement(qr,{className:b},m&&w.createElement("defs",null,w.createElement($4,{clipPathId:v,xAxisId:a,yAxisId:o}),!S&&w.createElement("clipPath",{id:"clipPath-dots-".concat(v)},w.createElement("rect",{x:c-M/2,y:l-M/2,width:u+M,height:d+M}))),w.createElement(oJ,{xAxisId:a,yAxisId:o,data:r,dataPointFormatter:NCe,errorBarOffset:0},w.createElement(ECe,{props:this.props,clipPathId:v}))),w.createElement(p3,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:N}))}}var mJ={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:oi.line,type:"linear"};function TCe(t){var e=Kr(t,mJ),{activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,connectNulls:l,dot:c,hide:u,isAnimationActive:d,label:f,legendType:m,xAxisId:p,yAxisId:b,id:v}=e,x=H4(e,hCe),{needClip:y}=oN(p,b),S=sN(),M=dh(),N=Bi(),A=Vt(R=>HTe(R,p,b,N,v));if(M!=="horizontal"&&M!=="vertical"||A==null||S==null)return null;var{height:k,width:C,x:D,y:T}=S;return w.createElement(ACe,G0({},x,{id:v,connectNulls:l,dot:c,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,isAnimationActive:d,hide:u,label:f,legendType:m,xAxisId:p,yAxisId:b,points:A,layout:M,height:k,width:C,left:D,top:T,needClip:y}))}function CCe(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=ir(u,o);if(e==="horizontal"){var m=Jw({axis:n,ticks:i,bandSize:l,entry:u,index:d}),p=Hr(f)?null:r.scale.map(f);return{x:m,y:p??null,value:f,payload:u}}var b=Hr(f)?null:n.scale.map(f),v=Jw({axis:r,ticks:a,bandSize:l,entry:u,index:d});return b==null||v==null?null:{x:b,y:v,value:f,payload:u}}).filter(Boolean)}function kCe(t){var e=Kr(t,mJ),n=Bi();return w.createElement(iN,{id:e.id,type:"line"},r=>w.createElement(w.Fragment,null,w.createElement(F4,{legendPayload:xCe(e)}),w.createElement(bCe,{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,id:r}),w.createElement(U4,{type:"line",id:r,data:e.data,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,hide:e.hide,isPanorama:n}),w.createElement(TCe,G0({},e,{id:r}))))}var pJ=w.memo(kCe,By);pJ.displayName="Line";function dc(t,e){var n,r;return(n=(r=t.graphicalItems.cartesianItems.find(i=>i.id===e))===null||r===void 0?void 0:r.xAxisId)!==null&&n!==void 0?n:QQ}function hc(t,e){var n,r;return(n=(r=t.graphicalItems.cartesianItems.find(i=>i.id===e))===null||r===void 0?void 0:r.yAxisId)!==null&&n!==void 0?n:QQ}var gJ=(t,e,n)=>nc(t,"xAxis",dc(t,e),n),xJ=(t,e,n)=>tc(t,"xAxis",dc(t,e),n),bJ=(t,e,n)=>nc(t,"yAxis",hc(t,e),n),yJ=(t,e,n)=>tc(t,"yAxis",hc(t,e),n),jCe=tt([Fn,gJ,bJ,xJ,yJ],(t,e,n,r,i)=>xl(t,"xAxis")?Yd(e,r,!1):Yd(n,i,!1)),PCe=(t,e)=>e,vJ=tt([Dy,PCe],(t,e)=>t.filter(n=>n.type==="area").find(n=>n.id===e)),_J=t=>{var e=Fn(t),n=xl(e,"xAxis");return n?"yAxis":"xAxis"},RCe=(t,e)=>{var n=_J(t);return n==="yAxis"?hc(t,e):dc(t,e)},DCe=(t,e,n)=>wS(t,_J(t),RCe(t,e),n),OCe=tt([vJ,DCe],(t,e)=>{var n;if(!(t==null||e==null)){var{stackId:r}=t,i=VE(t);if(!(r==null||i==null)){var a=(n=e[r])===null||n===void 0?void 0:n.stackedData,o=a?.find(l=>l.key===i);if(o!=null)return o.map(l=>[l[0],l[1]])}}}),LCe=tt([Fn,gJ,bJ,xJ,yJ,OCe,aZ,jCe,vJ,q1e],(t,e,n,r,i,a,o,l,c,u)=>{var{chartData:d,dataStartIndex:f,dataEndIndex:m}=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,b;if(p&&p.length>0?b=p:b=d?.slice(f,m+1),b!=null)return tke({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:f,areaSettings:c,stackedData:a,displayedData:b,chartBaseValue:u,bandSize:l})}}),ICe=["id"],FCe=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function Ef(){return Ef=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},Ef.apply(null,arguments)}function wJ(t,e){if(t==null)return{};var n,r,i=UCe(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 UCe(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 $H(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 qp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?$H(Object(n),!0).forEach(function(r){zCe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):$H(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function zCe(t,e,n){return(e=BCe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function BCe(t){var e=$Ce(t,"string");return typeof e=="symbol"?e:e+""}function $Ce(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 PS(t,e){return t&&t!=="none"?t:e}var HCe=t=>{var{dataKey:e,name:n,stroke:r,fill:i,legendType:a,hide:o}=t;return[{inactive:o,dataKey:e,type:a,color:PS(r,i),value:uh(n,e),payload:t}]},VCe=w.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:l,unit:c,tooltipType:u,id:d}=t,f={dataDefinedOnItem:n,getPosition:ch,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:e,nameKey:void 0,name:uh(o,e),hide:l,type:u,color:PS(r,a),unit:c,graphicalItemId:d}};return w.createElement(rN,{tooltipEntrySettings:f})});function GCe(t){var{clipPathId:e,points:n,props:r}=t,{needClip:i,dot:a,dataKey:o}=r,l=ts(r);return w.createElement(ZQ,{points:n,dot:a,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:o,baseProps:l,needClip:i,clipPathId:e})}function WCe(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 qp(qp({},c),{},{value:a.value,payload:a.payload,parentViewBox:void 0,viewBox:c,fill:void 0})});return w.createElement(C4,{value:e?i:void 0},n)}function HH(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,m=wJ(a,ICe),p=ts(m),b=Aa(m);return w.createElement(w.Fragment,null,e?.length>1&&w.createElement(qr,{clipPath:r?"url(#clipPath-".concat(i,")"):void 0},w.createElement(tg,Ef({},b,{id:f,points:e,connectNulls:u,type:l,baseLine:n,layout:o,stroke:"none",className:"recharts-area-area"})),c!=="none"&&w.createElement(tg,Ef({},p,{className:"recharts-area-curve",layout:o,type:l,connectNulls:u,fill:"none",points:e})),c!=="none"&&d&&w.createElement(tg,Ef({},p,{className:"recharts-area-curve",layout:o,type:l,connectNulls:u,fill:"none",points:n}))),w.createElement(GCe,{points:e,props:m,clipPathId:i}))}function qCe(t){var e,n,{alpha:r,baseLine:i,points:a,strokeWidth:o}=t,l=(e=a[0])===null||e===void 0?void 0:e.y,c=(n=a[a.length-1])===null||n===void 0?void 0:n.y;if(!pn(l)||!pn(c))return null;var u=r*Math.abs(l-c),d=Math.max(...a.map(f=>f.x||0));return zt(i)?d=Math.max(i,d):i&&Array.isArray(i)&&i.length&&(d=Math.max(...i.map(f=>f.x||0),d)),zt(d)?w.createElement("rect",{x:0,y:l<c?l:l-u,width:d+(o?parseInt("".concat(o),10):1),height:Math.floor(u)}):null}function KCe(t){var e,n,{alpha:r,baseLine:i,points:a,strokeWidth:o}=t,l=(e=a[0])===null||e===void 0?void 0:e.x,c=(n=a[a.length-1])===null||n===void 0?void 0:n.x;if(!pn(l)||!pn(c))return null;var u=r*Math.abs(l-c),d=Math.max(...a.map(f=>f.y||0));return zt(i)?d=Math.max(i,d):i&&Array.isArray(i)&&i.length&&(d=Math.max(...i.map(f=>f.y||0),d)),zt(d)?w.createElement("rect",{x:l<c?l:l-u,y:0,width:u,height:Math.floor(d+(o?parseInt("".concat(o),10):1))}):null}function XCe(t){var{alpha:e,layout:n,points:r,baseLine:i,strokeWidth:a}=t;return n==="vertical"?w.createElement(qCe,{alpha:e,points:r,baseLine:i,strokeWidth:a}):w.createElement(KCe,{alpha:e,points:r,baseLine:i,strokeWidth:a})}function YCe(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:m,onAnimationEnd:p}=r,b=w.useMemo(()=>({points:o,baseLine:l}),[o,l]),v=Qg(b,"recharts-area-"),x=pO(),[y,S]=w.useState(!1),M=!y,N=w.useCallback(()=>{typeof p=="function"&&p(),S(!1)},[p]),A=w.useCallback(()=>{typeof m=="function"&&m(),S(!0)},[m]);if(x==null)return null;var k=i.current,C=a.current;return w.createElement(WCe,{showLabels:M,points:o},r.children,w.createElement(Zg,{animationId:v,begin:u,duration:d,isActive:c,easing:f,onAnimationEnd:N,onAnimationStart:A,key:v},D=>{if(k){var T=k.length/o.length,R=D===1?o:o.map((L,q)=>{var j=Math.floor(q*T);if(k[j]){var W=k[j];return qp(qp({},L),{},{x:nr(W.x,L.x,D),y:nr(W.y,L.y,D)})}return L}),U;return zt(l)?U=nr(C,l,D):Hr(l)||ul(l)?U=nr(C,0,D):U=l.map((L,q)=>{var j=Math.floor(q*T);if(Array.isArray(C)&&C[j]){var W=C[j];return qp(qp({},L),{},{x:nr(W.x,L.x,D),y:nr(W.y,L.y,D)})}return L}),D>0&&(i.current=R,a.current=U),w.createElement(HH,{points:R,baseLine:U,needClip:e,clipPathId:n,props:r})}return D>0&&(i.current=o,a.current=l),w.createElement(qr,null,c&&w.createElement("defs",null,w.createElement("clipPath",{id:"animationClipPath-".concat(n)},w.createElement(XCe,{alpha:D,points:o,baseLine:l,layout:x,strokeWidth:r.strokeWidth}))),w.createElement(qr,{clipPath:"url(#animationClipPath-".concat(n,")")},w.createElement(HH,{points:o,baseLine:l,needClip:e,clipPathId:n,props:r})))}),w.createElement(eN,{label:r.label}))}function ZCe(t){var{needClip:e,clipPathId:n,props:r}=t,i=w.useRef(null),a=w.useRef();return w.createElement(YCe,{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}class QCe extends w.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:m,baseLine:p,zIndex:b}=this.props;if(e)return null;var v=Bn("recharts-area",i),x=m,{r:y,strokeWidth:S}=hJ(n),M=R4(n),N=y*2+S,A=l?"url(#clipPath-".concat(M?"":"dots-").concat(x,")"):void 0;return w.createElement($a,{zIndex:b},w.createElement(qr,{className:v},l&&w.createElement("defs",null,w.createElement($4,{clipPathId:x,xAxisId:c,yAxisId:u}),!M&&w.createElement("clipPath",{id:"clipPath-dots-".concat(x)},w.createElement("rect",{x:o-N/2,y:a-N/2,width:d+N,height:f+N}))),w.createElement(ZCe,{needClip:l,clipPathId:x,props:this.props})),w.createElement(p3,{points:r,mainColor:PS(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:A}),this.props.isRange&&Array.isArray(p)&&w.createElement(p3,{points:p,mainColor:PS(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:A}))}}var SJ={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:oi.area};function JCe(t){var e,n=Kr(t,SJ),{activeDot:r,animationBegin:i,animationDuration:a,animationEasing:o,connectNulls:l,dot:c,fill:u,fillOpacity:d,hide:f,isAnimationActive:m,legendType:p,stroke:b,xAxisId:v,yAxisId:x}=n,y=wJ(n,FCe),S=dh(),M=vQ(),{needClip:N}=oN(v,x),A=Bi(),{points:k,isRange:C,baseLine:D}=(e=Vt(j=>LCe(j,t.id,A)))!==null&&e!==void 0?e:{},T=sN();if(S!=="horizontal"&&S!=="vertical"||T==null||M!=="AreaChart"&&M!=="ComposedChart")return null;var{height:R,width:U,x:L,y:q}=T;return!k||!k.length?null:w.createElement(QCe,Ef({},y,{activeDot:r,animationBegin:i,animationDuration:a,animationEasing:o,baseLine:D,connectNulls:l,dot:c,fill:u,fillOpacity:d,height:R,hide:f,layout:S,isAnimationActive:m==="auto"?!Ay.isSsr:m,isRange:C,legendType:p,needClip:N,points:k,stroke:b,width:U,left:L,top:q,xAxisId:v,yAxisId:x}))}var eke=(t,e,n,r,i)=>{var a=n??e;if(zt(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 tke(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:m,bandSize:p}=t,b=i&&i.length,v=eke(a,o,n,l,c),x=a==="horizontal",y=!1,S=u.map((N,A)=>{var k,C,D,T;if(b)T=i[d+A];else{var R=ir(N,r);Array.isArray(R)?(T=R,y=!0):T=[v,R]}var U=(k=(C=T)===null||C===void 0?void 0:C[1])!==null&&k!==void 0?k:null,L=U==null||b&&!e&&ir(N,r)==null;if(x){var q;return{x:Jw({axis:l,ticks:f,bandSize:p,entry:N,index:A}),y:L?null:(q=c.scale.map(U))!==null&&q!==void 0?q:null,value:T,payload:N}}return{x:L?null:(D=l.scale.map(U))!==null&&D!==void 0?D:null,y:Jw({axis:c,ticks:m,bandSize:p,entry:N,index:A}),value:T,payload:N}}),M;return b||y?M=S.map(N=>{var A,k=Array.isArray(N.value)?N.value[0]:null;if(x){var C;return{x:N.x,y:k!=null&&N.y!=null&&(C=c.scale.map(k))!==null&&C!==void 0?C:null,payload:N.payload}}return{x:k!=null&&(A=l.scale.map(k))!==null&&A!==void 0?A:null,y:N.y,payload:N.payload}}):M=x?c.scale.map(v):l.scale.map(v),{points:S,baseLine:M??0,isRange:y}}function nke(t){var e=Kr(t,SJ),n=Bi();return w.createElement(iN,{id:e.id,type:"area"},r=>w.createElement(w.Fragment,null,w.createElement(F4,{legendPayload:HCe(e)}),w.createElement(VCe,{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,id:r}),w.createElement(U4,{type:"area",id:r,data:e.data,dataKey:e.dataKey,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,stackId:YX(e.stackId),hide:e.hide,barSize:void 0,baseValue:e.baseValue,isPanorama:n,connectNulls:e.connectNulls}),w.createElement(JCe,Ef({},e,{id:r}))))}var MJ=w.memo(nke,By);MJ.displayName="Area";var rke="Invariant failed";function ike(t,e){throw new Error(rke)}function g3(){return g3=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},g3.apply(null,arguments)}function RS(t){return w.createElement(D4,g3({shapeType:"rectangle",activeClassName:"recharts-active-bar"},t))}var ake=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(r,i)=>{if(zt(e))return e;var a=zt(r)||Hr(r);return a?e(r,i):(a||ike(),n)}},ske=(t,e,n)=>n,oke=(t,e)=>e,$y=tt([Dy,oke],(t,e)=>t.filter(n=>n.type==="bar").find(n=>n.id===e)),lke=tt([$y],t=>t?.maxBarSize),cke=(t,e,n,r)=>r,uke=tt([Fn,Dy,dc,hc,ske],(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")),dke=(t,e,n)=>{var r=Fn(t),i=dc(t,e),a=hc(t,e);if(!(i==null||a==null))return r==="horizontal"?wS(t,"yAxis",a,n):wS(t,"xAxis",i,n)},hke=(t,e)=>{var n=Fn(t),r=dc(t,e),i=hc(t,e);if(!(r==null||i==null))return n==="horizontal"?w$(t,"xAxis",r):w$(t,"yAxis",i)},fke=tt([uke,W1e,hke],mAe),mke=(t,e,n)=>{var r,i,a=$y(t,e);if(a==null)return 0;var o=dc(t,e),l=hc(t,e);if(o==null||l==null)return 0;var c=Fn(t),u=xZ(t),{maxBarSize:d}=a,f=Hr(d)?u:d,m,p;return c==="horizontal"?(m=nc(t,"xAxis",o,n),p=tc(t,"xAxis",o,n)):(m=nc(t,"yAxis",l,n),p=tc(t,"yAxis",l,n)),(r=(i=Yd(m,p,!0))!==null&&i!==void 0?i:f)!==null&&r!==void 0?r:0},EJ=(t,e,n)=>{var r=Fn(t),i=dc(t,e),a=hc(t,e);if(!(i==null||a==null)){var o,l;return r==="horizontal"?(o=nc(t,"xAxis",i,n),l=tc(t,"xAxis",i,n)):(o=nc(t,"yAxis",a,n),l=tc(t,"yAxis",a,n)),Yd(o,l)}},pke=tt([fke,xZ,G1e,bZ,mke,EJ,lke],yAe),gke=(t,e,n)=>{var r=dc(t,e);if(r!=null)return nc(t,"xAxis",r,n)},xke=(t,e,n)=>{var r=hc(t,e);if(r!=null)return nc(t,"yAxis",r,n)},bke=(t,e,n)=>{var r=dc(t,e);if(r!=null)return tc(t,"xAxis",r,n)},yke=(t,e,n)=>{var r=hc(t,e);if(r!=null)return tc(t,"yAxis",r,n)},vke=tt([pke,$y],_Ae),_ke=tt([dke,$y],vAe),wke=tt([zi,uO,gke,xke,bke,yke,vke,Fn,aZ,EJ,_ke,$y,cke],(t,e,n,r,i,a,o,l,c,u,d,f,m)=>{var{chartData:p,dataStartIndex:b,dataEndIndex:v}=c;if(!(f==null||o==null||e==null||l!=="horizontal"&&l!=="vertical"||n==null||r==null||i==null||a==null||u==null)){var{data:x}=f,y;if(x!=null&&x.length>0?y=x:y=p?.slice(b,v+1),y!=null)return Yke({layout:l,barSettings:f,pos:o,parentViewBox:e,bandSize:u,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,stackedData:d,displayedData:y,offset:t,cells:m,dataStartIndex:b})}}),Ske=["index"];function x3(){return x3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},x3.apply(null,arguments)}function Mke(t,e){if(t==null)return{};var n,r,i=Eke(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 Eke(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 NJ=w.createContext(void 0),Nke=t=>{var e=w.useContext(NJ);if(e!=null)return e.stackId;if(t!=null)return YX(t)},Ake=(t,e)=>"recharts-bar-stack-clip-path-".concat(t,"-").concat(e),Tke=t=>{var e=w.useContext(NJ);if(e!=null){var{stackId:n}=e;return"url(#".concat(Ake(n,t),")")}},AJ=t=>{var{index:e}=t,n=Mke(t,Ske),r=Tke(e);return w.createElement(qr,x3({className:"recharts-bar-stack-layer",clipPath:r},n))},Cke=["onMouseEnter","onMouseLeave","onClick"],kke=["value","background","tooltipPosition"],jke=["id"],Pke=["onMouseEnter","onClick","onMouseLeave"];function bu(){return bu=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},bu.apply(null,arguments)}function VH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Xa(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?VH(Object(n),!0).forEach(function(r){Rke(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):VH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Rke(t,e,n){return(e=Dke(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Dke(t){var e=Oke(t,"string");return typeof e=="symbol"?e:e+""}function Oke(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 DS(t,e){if(t==null)return{};var n,r,i=Lke(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 Lke(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 Ike=t=>{var{dataKey:e,name:n,fill:r,legendType:i,hide:a}=t;return[{inactive:a,dataKey:e,type:i,color:r,value:uh(n,e),payload:t}]},Fke=w.memo(t=>{var{dataKey:e,stroke:n,strokeWidth:r,fill:i,name:a,hide:o,unit:l,tooltipType:c,id:u}=t,d={dataDefinedOnItem:void 0,getPosition:ch,settings:{stroke:n,strokeWidth:r,fill:i,dataKey:e,nameKey:void 0,name:uh(a,e),hide:o,type:c,color:i,unit:l,graphicalItemId:u}};return w.createElement(rN,{tooltipEntrySettings:d})});function Uke(t){var e=Vt(Zd),{data:n,dataKey:r,background:i,allOtherBarProps:a}=t,{onMouseEnter:o,onMouseLeave:l,onClick:c}=a,u=DS(a,Cke),d=O4(o,r,a.id),f=L4(l),m=I4(c,r,a.id);if(!i||n==null)return null;var p=$f(i);return w.createElement($a,{zIndex:wAe(i,oi.barBackground)},n.map((b,v)=>{var{value:x,background:y,tooltipPosition:S}=b,M=DS(b,kke);if(!y)return null;var N=d(b,v),A=f(b,v),k=m(b,v),C=Xa(Xa(Xa(Xa(Xa({option:i,isActive:String(v)===e},M),{},{fill:"#eee"},y),p),vy(u,b,v)),{},{onMouseEnter:N,onMouseLeave:A,onClick:k,dataKey:r,index:v,className:"recharts-bar-background-rectangle"});return w.createElement(RS,bu({key:"background-bar-".concat(v)},C))}))}function zke(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 Xa(Xa({},o),{},{value:a.value,payload:a.payload,parentViewBox:a.parentViewBox,viewBox:o,fill:a.fill})});return w.createElement(C4,{value:e?i:void 0},n)}function Bke(t){var{shape:e,activeBar:n,baseProps:r,entry:i,index:a,dataKey:o}=t,l=Vt(Zd),c=Vt(S4),u=n&&String(a)===l&&(c==null||o===c),d=u?n:e;return u?w.createElement($a,{zIndex:oi.activeBar},w.createElement(AJ,{index:a},w.createElement(RS,bu({},r,{name:String(r.name)},i,{isActive:u,option:d,index:a,dataKey:o})))):w.createElement(RS,bu({},r,{name:String(r.name)},i,{isActive:u,option:d,index:a,dataKey:o}))}function $ke(t){var{shape:e,baseProps:n,entry:r,index:i,dataKey:a}=t;return w.createElement(RS,bu({},n,{name:String(n.name)},r,{isActive:!1,option:e,index:i,dataKey:a}))}function Hke(t){var e,{data:n,props:r}=t,i=(e=ts(r))!==null&&e!==void 0?e:{},{id:a}=i,o=DS(i,jke),{shape:l,dataKey:c,activeBar:u}=r,{onMouseEnter:d,onClick:f,onMouseLeave:m}=r,p=DS(r,Pke),b=O4(d,c,a),v=L4(m),x=I4(f,c,a);return n?w.createElement(w.Fragment,null,n.map((y,S)=>w.createElement(AJ,bu({index:S,key:"rectangle-".concat(y?.x,"-").concat(y?.y,"-").concat(y?.value,"-").concat(S),className:"recharts-bar-rectangle"},vy(p,y,S),{onMouseEnter:b(y,S),onMouseLeave:v(y,S),onClick:x(y,S)}),u?w.createElement(Bke,{shape:l,activeBar:u,baseProps:o,entry:y,index:S,dataKey:c}):w.createElement($ke,{shape:l,baseProps:o,entry:y,index:S,dataKey:c})))):null}function Vke(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,m=Qg(e,"recharts-bar-"),[p,b]=w.useState(!1),v=!p,x=w.useCallback(()=>{typeof u=="function"&&u(),b(!1)},[u]),y=w.useCallback(()=>{typeof d=="function"&&d(),b(!0)},[d]);return w.createElement(zke,{showLabels:v,rects:r},w.createElement(Zg,{animationId:m,begin:o,duration:l,isActive:a,easing:c,onAnimationEnd:x,onAnimationStart:y,key:m},S=>{var M=S===1?r:r?.map((N,A)=>{var k=f&&f[A];if(k)return Xa(Xa({},N),{},{x:nr(k.x,N.x,S),y:nr(k.y,N.y,S),width:nr(k.width,N.width,S),height:nr(k.height,N.height,S)});if(i==="horizontal"){var C=nr(0,N.height,S),D=nr(N.stackedBarStart,N.y,S);return Xa(Xa({},N),{},{y:D,height:C})}var T=nr(0,N.width,S),R=nr(N.stackedBarStart,N.x,S);return Xa(Xa({},N),{},{width:T,x:R})});return S>0&&(n.current=M??null),M==null?null:w.createElement(qr,null,w.createElement(Hke,{props:e,data:M}))}),w.createElement(eN,{label:e.label}),e.children)}function Gke(t){var e=w.useRef(null);return w.createElement(Vke,{previousRectanglesRef:e,props:t})}var TJ=0,Wke=(t,e)=>{var n=Array.isArray(t.value)?t.value[1]:t.value;return{x:t.x,y:t.y,value:n,errorVal:ir(t,e)}};class qke extends w.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=Bn("recharts-bar",i),f=u;return w.createElement(qr,{className:d,id:u},l&&w.createElement("defs",null,w.createElement($4,{clipPathId:f,xAxisId:a,yAxisId:o})),w.createElement(qr,{className:"recharts-bar-rectangles",clipPath:l?"url(#clipPath-".concat(f,")"):void 0},w.createElement(Uke,{data:n,dataKey:r,background:c,allOtherBarProps:this.props}),w.createElement(Gke,this.props)))}}var Kke={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:TJ,xAxisId:0,yAxisId:0,zIndex:oi.bar};function Xke(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}=oN(e,n),m=dh(),p=Bi(),b=P4(t.children,zy),v=Vt(S=>wke(S,t.id,p,b));if(m!=="vertical"&&m!=="horizontal")return null;var x,y=v?.[0];return y==null||y.height==null||y.width==null?x=0:x=m==="vertical"?y.height/2:y.width/2,w.createElement(oJ,{xAxisId:e,yAxisId:n,data:v,dataPointFormatter:Wke,errorBarOffset:x},w.createElement(qke,bu({},t,{layout:m,needClip:f,data:v,xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:o,animationBegin:l,animationDuration:c,animationEasing:u,isAnimationActive:d})))}function Yke(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:m,cells:p,parentViewBox:b,dataStartIndex:v}=t,x=e==="horizontal"?l:o,y=d?x.scale.domain():null,S=Rbe({numericAxis:x}),M=x.scale.map(S);return f.map((N,A)=>{var k,C,D,T,R,U;if(d){var L=d[A+v];if(L==null)return null;k=Tbe(L,y)}else k=ir(N,n),Array.isArray(k)||(k=[S,k]);var q=ake(r,TJ)(k[1],A);if(e==="horizontal"){var j,W=l.scale.map(k[0]),K=l.scale.map(k[1]);if(W==null||K==null)return null;C=_8({axis:o,ticks:c,bandSize:a,offset:i.offset,entry:N,index:A}),D=(j=K??W)!==null&&j!==void 0?j:void 0,T=i.size;var V=W-K;if(R=ul(V)?0:V,U={x:C,y:m.top,width:T,height:m.height},Math.abs(q)>0&&Math.abs(R)<Math.abs(q)){var J=ea(R||q)*(Math.abs(q)-Math.abs(R));D-=J,R+=J}}else{var ne=o.scale.map(k[0]),te=o.scale.map(k[1]);if(ne==null||te==null)return null;if(C=ne,D=_8({axis:l,ticks:u,bandSize:a,offset:i.offset,entry:N,index:A}),T=te-ne,R=i.size,U={x:m.left,y:D,width:m.width,height:R},Math.abs(q)>0&&Math.abs(T)<Math.abs(q)){var z=ea(T||q)*(Math.abs(q)-Math.abs(T));T+=z}}if(C==null||D==null||T==null||R==null)return null;var H=Xa(Xa({},N),{},{stackedBarStart:M,x:C,y:D,width:T,height:R,value:d?k:k[1],payload:N,background:U,tooltipPosition:{x:C+T/2,y:D+R/2},parentViewBox:b},p&&p[A]&&p[A].props);return H}).filter(Boolean)}function Zke(t){var e=Kr(t,Kke),n=Nke(e.stackId),r=Bi();return w.createElement(iN,{id:e.id,type:"bar"},i=>w.createElement(w.Fragment,null,w.createElement(F4,{legendPayload:Ike(e)}),w.createElement(Fke,{dataKey:e.dataKey,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType,id:i}),w.createElement(U4,{type:"bar",id:i,data:void 0,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,stackId:n,hide:e.hide,barSize:e.barSize,minPointSize:e.minPointSize,maxBarSize:e.maxBarSize,isPanorama:r}),w.createElement($a,{zIndex:e.zIndex},w.createElement(Xke,bu({},e,{id:i})))))}var CJ=w.memo(Zke,By);CJ.displayName="Bar";var Qke=["domain","range"],Jke=["domain","range"];function GH(t,e){if(t==null)return{};var n,r,i=eje(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 eje(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 WH(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 kJ(t,e){if(t===e)return!0;var{domain:n,range:r}=t,i=GH(t,Qke),{domain:a,range:o}=e,l=GH(e,Jke);return!WH(n,a)||!WH(r,o)?!1:By(i,l)}var tje=["type"],nje=["dangerouslySetInnerHTML","ticks","scale"],rje=["id","scale"];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 qH(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 KH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?qH(Object(n),!0).forEach(function(r){ije(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):qH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function ije(t,e,n){return(e=aje(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function aje(t){var e=sje(t,"string");return typeof e=="symbol"?e:e+""}function sje(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 y3(t,e){if(t==null)return{};var n,r,i=oje(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 oje(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 lje(t){var e=Mr(),n=w.useRef(null),r=pO(),{type:i}=t,a=y3(t,tje),o=$E(r,"xAxis",i),l=w.useMemo(()=>{if(o!=null)return KH(KH({},a),{},{type:o})},[a,o]);return w.useLayoutEffect(()=>{l!=null&&(n.current===null?e(J2e(l)):n.current!==l&&e(eAe({prev:n.current,next:l})),n.current=l)},[l,e]),w.useLayoutEffect(()=>()=>{n.current&&(e(tAe(n.current)),n.current=null)},[e]),null}var cje=t=>{var{xAxisId:e,className:n}=t,r=Vt(uO),i=Bi(),a="xAxis",o=Vt(y=>ZZ(y,a,e,i)),l=Vt(y=>qZ(y,e)),c=Vt(y=>qwe(y,e)),u=Vt(y=>TZ(y,e));if(l==null||c==null||u==null)return null;var{dangerouslySetInnerHTML:d,ticks:f,scale:m}=t,p=y3(t,nje),{id:b,scale:v}=u,x=y3(u,rje);return w.createElement(B4,b3({},p,x,{x:c.x,y:c.y,width:l.width,height:l.height,className:Bn("recharts-".concat(a," ").concat(a),n),viewBox:r,ticks:o,axisType:a}))},uje={allowDataOverflow:Xi.allowDataOverflow,allowDecimals:Xi.allowDecimals,allowDuplicatedCategory:Xi.allowDuplicatedCategory,angle:Xi.angle,axisLine:iu.axisLine,height:Xi.height,hide:!1,includeHidden:Xi.includeHidden,interval:Xi.interval,label:!1,minTickGap:Xi.minTickGap,mirror:Xi.mirror,orientation:Xi.orientation,padding:Xi.padding,reversed:Xi.reversed,scale:Xi.scale,tick:Xi.tick,tickCount:Xi.tickCount,tickLine:iu.tickLine,tickSize:iu.tickSize,type:Xi.type,xAxisId:0},dje=t=>{var e=Kr(t,uje);return w.createElement(w.Fragment,null,w.createElement(lje,{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}),w.createElement(cje,e))},OS=w.memo(dje,kJ);OS.displayName="XAxis";var hje=["type"],fje=["dangerouslySetInnerHTML","ticks","scale"],mje=["id","scale"];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 XH(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 YH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?XH(Object(n),!0).forEach(function(r){pje(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):XH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function pje(t,e,n){return(e=gje(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function gje(t){var e=xje(t,"string");return typeof e=="symbol"?e:e+""}function xje(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 _3(t,e){if(t==null)return{};var n,r,i=bje(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 bje(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 yje(t){var e=Mr(),n=w.useRef(null),r=pO(),{type:i}=t,a=_3(t,hje),o=$E(r,"yAxis",i),l=w.useMemo(()=>{if(o!=null)return YH(YH({},a),{},{type:o})},[o,a]);return w.useLayoutEffect(()=>{l!=null&&(n.current===null?e(nAe(l)):n.current!==l&&e(rAe({prev:n.current,next:l})),n.current=l)},[l,e]),w.useLayoutEffect(()=>()=>{n.current&&(e(iAe(n.current)),n.current=null)},[e]),null}function vje(t){var{yAxisId:e,className:n,width:r,label:i}=t,a=w.useRef(null),o=w.useRef(null),l=Vt(uO),c=Bi(),u=Mr(),d="yAxis",f=Vt(k=>KZ(k,e)),m=Vt(k=>Xwe(k,e)),p=Vt(k=>ZZ(k,d,e,c)),b=Vt(k=>CZ(k,e));if(w.useLayoutEffect(()=>{if(!(r!=="auto"||!f||T4(i)||w.isValidElement(i)||b==null)){var k=a.current;if(k){var C=k.getCalculatedWidth();Math.round(f.width)!==Math.round(C)&&u(aAe({id:e,width:C}))}}},[p,f,u,i,e,r,b]),f==null||m==null||b==null)return null;var{dangerouslySetInnerHTML:v,ticks:x,scale:y}=t,S=_3(t,fje),{id:M,scale:N}=b,A=_3(b,mje);return w.createElement(B4,v3({},S,A,{ref:a,labelRef:o,x:m.x,y:m.y,tickTextProps:r==="auto"?{width:void 0}:{width:r},width:f.width,height:f.height,className:Bn("recharts-".concat(d," ").concat(d),n),viewBox:l,ticks:p,axisType:d}))}var _je={allowDataOverflow:Yi.allowDataOverflow,allowDecimals:Yi.allowDecimals,allowDuplicatedCategory:Yi.allowDuplicatedCategory,angle:Yi.angle,axisLine:iu.axisLine,hide:!1,includeHidden:Yi.includeHidden,interval:Yi.interval,label:!1,minTickGap:Yi.minTickGap,mirror:Yi.mirror,orientation:Yi.orientation,padding:Yi.padding,reversed:Yi.reversed,scale:Yi.scale,tick:Yi.tick,tickCount:Yi.tickCount,tickLine:iu.tickLine,tickSize:iu.tickSize,type:Yi.type,width:Yi.width,yAxisId:0},wje=t=>{var e=Kr(t,_je);return w.createElement(w.Fragment,null,w.createElement(yje,{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}),w.createElement(vje,e))},LS=w.memo(wje,kJ);LS.displayName="YAxis";var Sje=(t,e)=>e,V4=tt([Sje,Fn,EZ,oa,mQ,Au,uMe,zi],xMe),G4=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)}},jJ=Oo("mouseClick"),PJ=wy();PJ.startListening({actionCreator:jJ,effect:(t,e)=>{var n=t.payload,r=V4(e.getState(),G4(n));r?.activeIndex!=null&&e.dispatch(cSe({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var w3=Oo("mouseMove"),RJ=wy(),k_=null;RJ.startListening({actionCreator:w3,effect:(t,e)=>{var n=t.payload;k_!==null&&cancelAnimationFrame(k_);var r=G4(n);k_=requestAnimationFrame(()=>{var i=e.getState(),a=x4(i,i.tooltip.settings.shared);if(a==="axis"){var o=V4(i,r);o?.activeIndex!=null?e.dispatch(aQ({activeIndex:o.activeIndex,activeDataKey:void 0,activeCoordinate:o.activeCoordinate})):e.dispatch(iQ())}k_=null})}});function Mje(t,e){return e instanceof HTMLElement?"HTMLElement <".concat(e.tagName,' class="').concat(e.className,'">'):e===window?"global.window":t==="children"&&typeof e=="object"&&e!==null?"<<CHILDREN>>":e}var ZH={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},DJ=Ns({name:"rootProps",initialState:ZH,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:ZH.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}}}),Eje=DJ.reducer,{updateOptions:Nje}=DJ.actions,Aje=null,Tje={updatePolarOptions:(t,e)=>e.payload},OJ=Ns({name:"polarOptions",initialState:Aje,reducers:Tje}),{updatePolarOptions:Cje}=OJ.actions,kje=OJ.reducer,LJ=Oo("keyDown"),IJ=Oo("focus"),W4=wy();W4.startListening({actionCreator:LJ,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=b4(i,ox(n),Ly(n),Fy(n)),l=o==null?-1:Number(o);if(!(!Number.isFinite(l)||l<0)){var c=Au(n);if(a==="Enter"){var u=MS(n,"axis","hover",String(i.index));e.dispatch(u3({active:!i.active,activeIndex:i.index,activeCoordinate:u}));return}var d=Jwe(n),f=d==="left-to-right"?1:-1,m=a==="ArrowRight"?1:-1,p=l+m*f;if(!(c==null||p>=c.length||p<0)){var b=MS(n,"axis","hover",String(p));e.dispatch(u3({active:!0,activeIndex:p.toString(),activeCoordinate:b}))}}}}}});W4.startListening({actionCreator:IJ,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=MS(n,"axis","hover",String(a));e.dispatch(u3({active:!0,activeIndex:a,activeCoordinate:o}))}}}});var go=Oo("externalEvent"),FJ=wy(),UC=new Map;FJ.startListening({actionCreator:go,effect:(t,e)=>{var{handler:n,reactEvent:r}=t.payload;if(n!=null){r.persist();var i=r.type,a=UC.get(i);a!==void 0&&cancelAnimationFrame(a);var o=requestAnimationFrame(()=>{try{var l=e.getState(),c={activeCoordinate:XSe(l),activeDataKey:S4(l),activeIndex:Zd(l),activeLabel:xQ(l),activeTooltipIndex:Zd(l),isTooltipActive:YSe(l)};n(c,r)}finally{UC.delete(i)}});UC.set(i,o)}}});var jje=tt([ax],t=>t.tooltipItemPayloads),Pje=tt([jje,(t,e)=>e,(t,e,n)=>n],(t,e,n)=>{if(e!=null){var r=t.find(a=>a.settings.graphicalItemId===n);if(r!=null){var{getPosition:i}=r;if(i!=null)return i(e)}}}),UJ=Oo("touchMove"),zJ=wy();zJ.startListening({actionCreator:UJ,effect:(t,e)=>{var n=t.payload;if(!(n.touches==null||n.touches.length===0)){var r=e.getState(),i=x4(r,r.tooltip.settings.shared);if(i==="axis"){var a=n.touches[0];if(a==null)return;var o=V4(r,G4({clientX:a.clientX,clientY:a.clientY,currentTarget:n.currentTarget}));o?.activeIndex!=null&&e.dispatch(aQ({activeIndex:o.activeIndex,activeDataKey:void 0,activeCoordinate:o.activeCoordinate}))}else if(i==="item"){var l,c=n.touches[0];if(document.elementFromPoint==null||c==null)return;var u=document.elementFromPoint(c.clientX,c.clientY);if(!u||!u.getAttribute)return;var d=u.getAttribute(QX),f=(l=u.getAttribute(JX))!==null&&l!==void 0?l:void 0,m=sx(r).find(v=>v.id===f);if(d==null||m==null||f==null)return;var{dataKey:p}=m,b=Pje(r,d,f);e.dispatch(rQ({activeDataKey:p,activeIndex:d,activeCoordinate:b,activeGraphicalItemId:f}))}}}});var Rje=yX({brush:SAe,cartesianAxis:sAe,chartData:KMe,errorBars:RTe,graphicalItems:m2e,layout:Sbe,legend:C0e,options:HMe,polarAxis:TNe,polarOptions:kje,referenceElements:jAe,rootProps:Eje,tooltip:uSe,zIndex:jMe}),Dje=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"Chart";return Kxe({reducer:Rje,preloadedState:e,middleware:r=>{var i;return r({serializableCheck:!1,immutableCheck:!["commonjs","es6","production"].includes((i="es6")!==null&&i!==void 0?i:"")}).concat([PJ.middleware,RJ.middleware,W4.middleware,FJ.middleware,zJ.middleware])},enhancers:r=>{var i=r;return typeof r=="function"&&(i=r()),i.concat(DX({type:"raf"}))},devTools:{serialize:{replacer:Mje},name:"recharts-".concat(n)}})};function BJ(t){var{preloadedState:e,children:n,reduxStoreName:r}=t,i=Bi(),a=w.useRef(null);if(i)return n;a.current==null&&(a.current=Dje(e,r));var o=rO;return w.createElement(oCe,{context:o,store:a.current},n)}function Oje(t){var{layout:e,margin:n}=t,r=Mr(),i=Bi();return w.useEffect(()=>{i||(r(vbe(e)),r(ybe(n)))},[r,i,e,n]),null}var $J=w.memo(Oje,By);function HJ(t){var e=Mr();return w.useEffect(()=>{e(Nje(t))},[e,t]),null}function QH(t){var{zIndex:e,isPanorama:n}=t,r=w.useRef(null),i=Mr();return w.useLayoutEffect(()=>(r.current&&i(CMe({zIndex:e,element:r.current,isPanorama:n})),()=>{i(kMe({zIndex:e,isPanorama:n}))}),[i,e,n]),w.createElement("g",{tabIndex:-1,ref:r})}function JH(t){var{children:e,isPanorama:n}=t,r=Vt(yMe);if(!r||r.length===0)return e;var i=r.filter(o=>o<0),a=r.filter(o=>o>0);return w.createElement(w.Fragment,null,i.map(o=>w.createElement(QH,{key:o,zIndex:o,isPanorama:n})),e,a.map(o=>w.createElement(QH,{key:o,zIndex:o,isPanorama:n})))}var Lje=["children"];function Ije(t,e){if(t==null)return{};var n,r,i=Fje(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 Fje(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 IS(){return IS=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},IS.apply(null,arguments)}var Uje={width:"100%",height:"100%",display:"block"},zje=w.forwardRef((t,e)=>{var n=fO(),r=mO(),i=pY();if(!Jl(n)||!Jl(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),w.createElement(WD,IS({},o,{title:l,desc:c,role:d,tabIndex:u,width:n,height:r,style:Uje,ref:e}),a)}),Bje=t=>{var{children:e}=t,n=Vt(kE);if(!n)return null;var{width:r,height:i,y:a,x:o}=n;return w.createElement(WD,{width:r,height:i,x:o,y:a},e)},eV=w.forwardRef((t,e)=>{var{children:n}=t,r=Ije(t,Lje),i=Bi();return i?w.createElement(Bje,null,w.createElement(JH,{isPanorama:!0},n)):w.createElement(zje,IS({ref:e},r),w.createElement(JH,{isPanorama:!1},n))});function $je(){var t=Mr(),[e,n]=w.useState(null),r=Vt(Ube);return w.useEffect(()=>{if(e!=null){var i=e.getBoundingClientRect(),a=i.width/e.offsetWidth;pn(a)&&a!==r&&t(wbe(a))}},[e,t,r]),n}function tV(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 Hje(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?tV(Object(n),!0).forEach(function(r){Vje(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):tV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Vje(t,e,n){return(e=Gje(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Gje(t){var e=Wje(t,"string");return typeof e=="symbol"?e:e+""}function Wje(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 zd(){return zd=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},zd.apply(null,arguments)}var qje=()=>(rEe(),null);function FS(t){if(typeof t=="number")return t;if(typeof t=="string"){var e=parseFloat(t);if(!Number.isNaN(e))return e}return 0}var Kje=w.forwardRef((t,e)=>{var n,r,i=w.useRef(null),[a,o]=w.useState({containerWidth:FS((n=t.style)===null||n===void 0?void 0:n.width),containerHeight:FS((r=t.style)===null||r===void 0?void 0:r.height)}),l=w.useCallback((u,d)=>{o(f=>{var m=Math.round(u),p=Math.round(d);return f.containerWidth===m&&f.containerHeight===p?f:{containerWidth:m,containerHeight:p}})},[]),c=w.useCallback(u=>{if(typeof e=="function"&&e(u),u!=null&&typeof ResizeObserver<"u"){var{width:d,height:f}=u.getBoundingClientRect();l(d,f);var m=b=>{var v=b[0];if(v!=null){var{width:x,height:y}=v.contentRect;l(x,y)}},p=new ResizeObserver(m);p.observe(u),i.current=p}},[e,l]);return w.useEffect(()=>()=>{var u=i.current;u?.disconnect()},[l]),w.createElement(w.Fragment,null,w.createElement(Ey,{width:a.containerWidth,height:a.containerHeight}),w.createElement("div",zd({ref:c},t)))}),Xje=w.forwardRef((t,e)=>{var{width:n,height:r}=t,[i,a]=w.useState({containerWidth:FS(n),containerHeight:FS(r)}),o=w.useCallback((c,u)=>{a(d=>{var f=Math.round(c),m=Math.round(u);return d.containerWidth===f&&d.containerHeight===m?d:{containerWidth:f,containerHeight:m}})},[]),l=w.useCallback(c=>{if(typeof e=="function"&&e(c),c!=null){var{width:u,height:d}=c.getBoundingClientRect();o(u,d)}},[e,o]);return w.createElement(w.Fragment,null,w.createElement(Ey,{width:i.containerWidth,height:i.containerHeight}),w.createElement("div",zd({ref:l},t)))}),Yje=w.forwardRef((t,e)=>{var{width:n,height:r}=t;return w.createElement(w.Fragment,null,w.createElement(Ey,{width:n,height:r}),w.createElement("div",zd({ref:e},t)))}),Zje=w.forwardRef((t,e)=>{var{width:n,height:r}=t;return typeof n=="string"||typeof r=="string"?w.createElement(Xje,zd({},t,{ref:e})):typeof n=="number"&&typeof r=="number"?w.createElement(Yje,zd({},t,{width:n,height:r,ref:e})):w.createElement(w.Fragment,null,w.createElement(Ey,{width:n,height:r}),w.createElement("div",zd({ref:e},t)))});function Qje(t){return t?Kje:Zje}var Jje=w.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:m,onTouchEnd:p,onTouchMove:b,onTouchStart:v,style:x,width:y,responsive:S,dispatchTouchEvents:M=!0}=t,N=w.useRef(null),A=Mr(),[k,C]=w.useState(null),[D,T]=w.useState(null),R=$je(),U=dO(),L=U?.width>0?U.width:y,q=U?.height>0?U.height:i,j=w.useCallback(ge=>{R(ge),typeof e=="function"&&e(ge),C(ge),T(ge),ge!=null&&(N.current=ge)},[R,e,C,T]),W=w.useCallback(ge=>{A(jJ(ge)),A(go({handler:a,reactEvent:ge}))},[A,a]),K=w.useCallback(ge=>{A(w3(ge)),A(go({handler:u,reactEvent:ge}))},[A,u]),V=w.useCallback(ge=>{A(iQ()),A(go({handler:d,reactEvent:ge}))},[A,d]),J=w.useCallback(ge=>{A(w3(ge)),A(go({handler:f,reactEvent:ge}))},[A,f]),ne=w.useCallback(()=>{A(IJ())},[A]),te=w.useCallback(ge=>{A(LJ(ge.key))},[A]),z=w.useCallback(ge=>{A(go({handler:o,reactEvent:ge}))},[A,o]),H=w.useCallback(ge=>{A(go({handler:l,reactEvent:ge}))},[A,l]),Z=w.useCallback(ge=>{A(go({handler:c,reactEvent:ge}))},[A,c]),ee=w.useCallback(ge=>{A(go({handler:m,reactEvent:ge}))},[A,m]),he=w.useCallback(ge=>{A(go({handler:v,reactEvent:ge}))},[A,v]),fe=w.useCallback(ge=>{M&&A(UJ(ge)),A(go({handler:b,reactEvent:ge}))},[A,M,b]),oe=w.useCallback(ge=>{A(go({handler:p,reactEvent:ge}))},[A,p]),Ne=Qje(S);return w.createElement(EQ.Provider,{value:k},w.createElement(OK.Provider,{value:D},w.createElement(Ne,{width:L??x?.width,height:q??x?.height,className:Bn("recharts-wrapper",r),style:Hje({position:"relative",cursor:"default",width:L,height:q},x),onClick:W,onContextMenu:z,onDoubleClick:H,onFocus:ne,onKeyDown:te,onMouseDown:Z,onMouseEnter:K,onMouseLeave:V,onMouseMove:J,onMouseUp:ee,onTouchEnd:oe,onTouchMove:fe,onTouchStart:he,ref:j},w.createElement(qje,null),n)))}),ePe=["width","height","responsive","children","className","style","compact","title","desc"];function tPe(t,e){if(t==null)return{};var n,r,i=nPe(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 nPe(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 VJ=w.forwardRef((t,e)=>{var{width:n,height:r,responsive:i,children:a,className:o,style:l,compact:c,title:u,desc:d}=t,f=tPe(t,ePe),m=ts(f);return c?w.createElement(w.Fragment,null,w.createElement(Ey,{width:n,height:r}),w.createElement(eV,{otherAttributes:m,title:u,desc:d},a)):w.createElement(Jje,{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},w.createElement(eV,{otherAttributes:m,title:u,desc:d,ref:e},w.createElement(PAe,null,a)))});function S3(){return S3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},S3.apply(null,arguments)}var rPe={top:5,right:5,bottom:5,left:5},iPe={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:rPe,responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},q4=w.forwardRef(function(e,n){var r,i=Kr(e.categoricalChartProps,iPe),{chartName:a,defaultTooltipEventType:o,validateTooltipEventTypes:l,tooltipPayloadSearcher:c,categoricalChartProps:u}=e,d={chartName:a,defaultTooltipEventType:o,validateTooltipEventTypes:l,tooltipPayloadSearcher:c,eventEmitter:void 0};return w.createElement(BJ,{preloadedState:{options:d},reduxStoreName:(r=u.id)!==null&&r!==void 0?r:a},w.createElement(eJ,{chartData:u.data}),w.createElement($J,{layout:i.layout,margin:i.margin}),w.createElement(HJ,{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}),w.createElement(VJ,S3({},i,{ref:n})))}),aPe=["axis"],sPe=w.forwardRef((t,e)=>w.createElement(q4,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:aPe,tooltipPayloadSearcher:QE,categoricalChartProps:t,ref:e})),oPe=["axis","item"],lPe=w.forwardRef((t,e)=>w.createElement(q4,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:oPe,tooltipPayloadSearcher:QE,categoricalChartProps:t,ref:e}));function cPe(t){var e=Mr();return w.useEffect(()=>{e(Cje(t))},[e,t]),null}var uPe=["layout"];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 dPe(t,e){if(t==null)return{};var n,r,i=hPe(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 hPe(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 fPe={top:5,right:5,bottom:5,left:5},GJ={accessibilityLayer:!0,stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:fPe,reverseStackOrder:!1,syncMethod:"index",layout:"radial",responsive:!1,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"},mPe=w.forwardRef(function(e,n){var r,i=Kr(e.categoricalChartProps,GJ),{layout:a}=i,o=dPe(i,uPe),{chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d}=e,f={chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d,eventEmitter:void 0};return w.createElement(BJ,{preloadedState:{options:f},reduxStoreName:(r=i.id)!==null&&r!==void 0?r:l},w.createElement(eJ,{chartData:i.data}),w.createElement($J,{layout:a,margin:i.margin}),w.createElement(HJ,{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}),w.createElement(cPe,{cx:i.cx,cy:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius}),w.createElement(VJ,M3({},o,{ref:n})))});function nV(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 rV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?nV(Object(n),!0).forEach(function(r){pPe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):nV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function pPe(t,e,n){return(e=gPe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function gPe(t){var e=xPe(t,"string");return typeof e=="symbol"?e:e+""}function xPe(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 bPe=["item"],yPe=rV(rV({},GJ),{},{layout:"centric",startAngle:0,endAngle:360}),vPe=w.forwardRef((t,e)=>{var n=Kr(t,yPe);return w.createElement(mPe,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:bPe,tooltipPayloadSearcher:QE,categoricalChartProps:n,ref:e})}),_Pe=["axis"],wPe=w.forwardRef((t,e)=>w.createElement(q4,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:_Pe,tooltipPayloadSearcher:QE,categoricalChartProps:t,ref:e}));const iV=[{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 SPe({isOpen:t,onClose:e,printerId:n,printerName:r,amsId:i,amsLabel:a,initialMode:o="humidity",thresholds:l}){const{t:c}=Gg(),{mode:u}=oh(),[d,f]=w.useState("24h"),[m,p]=w.useState(o),b=u==="dark",{data:v}=ft({queryKey:["settings"],queryFn:me.getSettings}),x=v?.time_format||"system";w.useEffect(()=>{if(!t)return;const ee=he=>{he.key==="Escape"&&e()};return window.addEventListener("keydown",ee),()=>window.removeEventListener("keydown",ee)},[t,e]);const y=iV.find(ee=>ee.value===d)?.hours||24,{data:S,isLoading:M,error:N}=ft({queryKey:["ams-history",n,i,y],queryFn:()=>me.getAMSHistory(n,i,y),enabled:t,refetchInterval:6e4});if(!t)return null;const A=S?.data.map(ee=>{const he=Si(ee.recorded_at)||new Date,fe={hour:"2-digit",minute:"2-digit",...y>24?{day:"numeric",month:"short"}:{}};return{time:he.getTime(),humidity:ee.humidity,temperature:ee.temperature,timeLabel:he.toLocaleTimeString([],t0(fe,x))}})||[],k=l?.humidityGood||40,C=l?.humidityFair||60,D=l?.tempGood||30,T=l?.tempFair||35,R=A[A.length-1],U=R?.humidity,L=R?.temperature,q=ee=>{const he=ee.filter(Re=>Re!=null);if(he.length<4)return"stable";const fe=he.slice(0,Math.floor(he.length/4)),oe=he.slice(-Math.floor(he.length/4)),Ne=fe.reduce((Re,de)=>Re+de,0)/fe.length,Se=oe.reduce((Re,de)=>Re+de,0)/oe.length-Ne;return Math.abs(Se)<2?"stable":Se>0?"up":"down"},j=q(A.map(ee=>ee.humidity)),W=q(A.map(ee=>ee.temperature)),K=({trend:ee})=>ee==="up"?s.jsx(MK,{className:"w-4 h-4 text-red-400"}):ee==="down"?s.jsx(SK,{className:"w-4 h-4 text-green-400"}):s.jsx(bP,{className:"w-4 h-4 text-gray-400 dark:text-bambu-gray"}),V=ee=>ee==null?"#9ca3af":ee<=k?"#22a352":ee<=C?"#d4a017":"#c62828",J=ee=>ee==null?"#9ca3af":ee<=D?"#22a352":ee<=T?"#d4a017":"#c62828",ne=b?"#2d2d2d":"#ffffff",te=b?"#1d1d1d":"#f3f4f6",z=b?"#3d3d3d":"#e5e7eb",H=b?"#ffffff":"#111827",Z=b?"#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:ne},onClick:ee=>ee.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b",style:{borderColor:z},children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold",style:{color:H},children:[a," ",c("common.history","History")]}),s.jsx("p",{className:"text-sm",style:{color:Z},children:r})]}),s.jsx("button",{onClick:e,className:"p-2 rounded-lg transition-colors",style:{color:Z},children:s.jsx(Gt,{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:te},children:[s.jsxs("button",{onClick:()=>p("humidity"),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${m==="humidity"?"bg-blue-600 text-white":""}`,style:m!=="humidity"?{color:Z}:void 0,children:[s.jsx(ID,{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 ${m==="temperature"?"bg-orange-600 text-white":""}`,style:m!=="temperature"?{color:Z}:void 0,children:[s.jsx(hE,{className:"w-4 h-4"}),c("common.temperature","Temperature")]})]}),s.jsx("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor:te},children:iV.map(ee=>s.jsx("button",{onClick:()=>f(ee.value),className:`px-3 py-1 text-sm rounded-md transition-colors ${d===ee.value?"bg-bambu-green text-white":""}`,style:d!==ee.value?{color:Z}:void 0,children:ee.label},ee.value))})]}),s.jsx("div",{className:"grid grid-cols-4 gap-4",children:m==="humidity"?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:te},children:[s.jsx("p",{className:"text-xs",style:{color:Z},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(K,{trend:j})]})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:te},children:[s.jsx("p",{className:"text-xs",style:{color:Z},children:c("common.average","Average")}),s.jsx("p",{className:"text-2xl font-bold",style:{color:H},children:S?.avg_humidity!=null?`${S.avg_humidity}%`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:te},children:[s.jsx("p",{className:"text-xs",style:{color:Z},children:c("common.min","Min")}),s.jsx("p",{className:"text-2xl font-bold text-green-500",children:S?.min_humidity!=null?`${S.min_humidity}%`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:te},children:[s.jsx("p",{className:"text-xs",style:{color:Z},children:c("common.max","Max")}),s.jsx("p",{className:"text-2xl font-bold text-red-500",children:S?.max_humidity!=null?`${S.max_humidity}%`:"—"})]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:te},children:[s.jsx("p",{className:"text-xs",style:{color:Z},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:J(L)},children:L!=null?`${L}°C`:"—"}),s.jsx(K,{trend:W})]})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:te},children:[s.jsx("p",{className:"text-xs",style:{color:Z},children:c("common.average","Average")}),s.jsx("p",{className:"text-2xl font-bold",style:{color:H},children:S?.avg_temperature!=null?`${S.avg_temperature}°C`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:te},children:[s.jsx("p",{className:"text-xs",style:{color:Z},children:c("common.min","Min")}),s.jsx("p",{className:"text-2xl font-bold text-blue-500",children:S?.min_temperature!=null?`${S.min_temperature}°C`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:te},children:[s.jsx("p",{className:"text-xs",style:{color:Z},children:c("common.max","Max")}),s.jsx("p",{className:"text-2xl font-bold text-red-500",children:S?.max_temperature!=null?`${S.max_temperature}°C`:"—"})]})]})}),s.jsx("div",{className:"rounded-lg p-4",style:{backgroundColor:te},children:M?s.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:Z},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:Z},children:c("common.noData","No data available for this time range")}):s.jsx(nw,{width:"100%",height:300,children:s.jsxs(sPe,{data:A,children:[s.jsx(jS,{strokeDasharray:"3 3",stroke:b?"#3d3d3d":"#e5e7eb"}),s.jsx(OS,{dataKey:"time",type:"number",domain:["dataMin","dataMax"],tickFormatter:ee=>{const he=new Date(ee);return y>24?he.toLocaleDateString([],{day:"numeric",month:"short"}):he.toLocaleTimeString([],t0({hour:"2-digit",minute:"2-digit"},x))},stroke:b?"#9ca3af":"#6b7280",tick:{fontSize:12}}),s.jsx(LS,{stroke:b?"#9ca3af":"#6b7280",tick:{fontSize:12},domain:m==="humidity"?[0,100]:["auto","auto"],tickFormatter:ee=>m==="humidity"?`${ee}%`:`${ee}°C`}),s.jsx(iw,{contentStyle:{backgroundColor:b?"#2d2d2d":"#ffffff",border:`1px solid ${b?"#3d3d3d":"#e5e7eb"}`,borderRadius:"8px",color:b?"#fff":"#000"},labelFormatter:ee=>new Date(ee).toLocaleString(void 0,t0({year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"},x)),formatter:ee=>[m==="humidity"?`${ee??0}%`:`${ee??0}°C`,m==="humidity"?"Humidity":"Temperature"]}),s.jsx(bO,{}),m==="humidity"?s.jsxs(s.Fragment,{children:[s.jsx(zb,{y:k,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),s.jsx(zb,{y:C,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}):s.jsxs(s.Fragment,{children:[s.jsx(zb,{y:D,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),s.jsx(zb,{y:T,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}),s.jsx(pJ,{type:"monotone",dataKey:m,name:m==="humidity"?"Humidity":"Temperature",stroke:m==="humidity"?"#3b82f6":"#f97316",strokeWidth:2,dot:!1,activeDot:{r:4}})]})})}),s.jsx("div",{className:"text-xs text-center",style:{color:Z},children:c("amsHistory.recordingInfo","Data is recorded every 5 minutes while the printer is connected")})]})]})})}function zC({data:t,children:e,disabled:n,className:r="",spoolman:i,configureSlot:a}){const[o,l]=w.useState(!1),[c,u]=w.useState("top"),[d,f]=w.useState(!1),m=w.useRef(null),p=w.useRef(null),b=w.useRef(null),v=()=>{const k=t.trayUuid;k&&(navigator.clipboard&&window.isSecureContext?navigator.clipboard.writeText(k).then(()=>{f(!0),setTimeout(()=>f(!1),2e3)}).catch(()=>{x(k)}):x(k))},x=k=>{const C=document.createElement("textarea");C.value=k,C.style.position="fixed",C.style.opacity="0",document.body.appendChild(C),C.select();try{document.execCommand("copy"),f(!0),setTimeout(()=>f(!1),2e3)}catch{console.error("Failed to copy to clipboard")}document.body.removeChild(C)};w.useEffect(()=>{if(o&&m.current&&p.current){const k=m.current.getBoundingClientRect(),C=p.current.offsetHeight,D=k.top,T=window.innerHeight-k.bottom;D<C+12&&T>D?u("bottom"):u("top")}},[o]);const y=()=>{n||(b.current&&clearTimeout(b.current),b.current=setTimeout(()=>l(!0),80))},S=()=>{b.current&&clearTimeout(b.current),b.current=setTimeout(()=>l(!1),100)};w.useEffect(()=>()=>{b.current&&clearTimeout(b.current)},[]);const M=k=>k<=15?"#ef4444":k<=30?"#f97316":k<=50?"#eab308":"#22c55e",N=k=>{if(!k)return!1;const C=k.replace("#",""),D=parseInt(C.slice(0,2),16),T=parseInt(C.slice(2,4),16),R=parseInt(C.slice(4,6),16);return(.299*D+.587*T+.114*R)/255>.6},A=t.colorHex?`#${t.colorHex.replace("#","")}`:null;return s.jsxs("div",{ref:m,className:`relative ${r}`,onMouseEnter:y,onMouseLeave:S,children:[e,o&&s.jsxs("div",{ref:p,className:`
  46. absolute left-1/2 -translate-x-1/2 z-50
  47. ${c==="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:A||"#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. ${N(A)?"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(ID,{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:M(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:k=>{k.stopPropagation(),v()},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),"..."]}),d?s.jsx(Es,{className:"w-3 h-3 text-bambu-green"}):s.jsx(il,{className:"w-3 h-3"})]})]}),i.onLinkSpool&&s.jsxs("button",{onClick:k=>{k.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(Gl,{className:"w-3.5 h-3.5"}),"Link to Spoolman"]})]}),a?.enabled&&s.jsx("div",{className:`${i?.enabled&&t.trayUuid?"":"pt-2 mt-2 border-t border-bambu-dark-tertiary"}`,children:s.jsxs("button",{onClick:k=>{k.stopPropagation(),a.onConfigure?.()},className:"w-full flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs font-medium rounded transition-colors bg-bambu-blue/20 hover:bg-bambu-blue/30 text-bambu-blue",title:"Configure slot with filament profile and K value",children:[s.jsx(Kd,{className:"w-3.5 h-3.5"}),"Configure"]})})]})]}),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. ${c==="top"?"top-full border-t-[6px] border-t-bambu-dark-tertiary":"bottom-full border-b-[6px] border-b-bambu-dark-tertiary"}
  65. `})]})]})}function aV({children:t,className:e="",configureSlot:n}){const[r,i]=w.useState(!1),a=w.useRef(null),o=()=>{a.current&&clearTimeout(a.current),a.current=setTimeout(()=>i(!0),80)},l=()=>{a.current&&clearTimeout(a.current),a.current=setTimeout(()=>i(!1),100)};return w.useEffect(()=>()=>{a.current&&clearTimeout(a.current)},[]),s.jsxs("div",{className:`relative ${e}`,onMouseEnter:o,onMouseLeave:l,children:[t,r&&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.jsxs("div",{className:`
  69. bg-bambu-dark-secondary border border-bambu-dark-tertiary
  70. rounded-md shadow-lg overflow-hidden
  71. `,children:[s.jsx("div",{className:"px-3 py-1.5 text-xs text-bambu-gray whitespace-nowrap",children:"Empty slot"}),n?.enabled&&s.jsx("div",{className:"px-2 pb-2",children:s.jsxs("button",{onClick:c=>{c.stopPropagation(),n.onConfigure?.()},className:"w-full flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs font-medium rounded transition-colors bg-bambu-blue/20 hover:bg-bambu-blue/30 text-bambu-blue",title:"Configure slot with filament profile and K value",children:[s.jsx(Kd,{className:"w-3.5 h-3.5"}),"Configure"]})})]}),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 MPe({isOpen:t,onClose:e,trayUuid:n,trayInfo:r}){const i=ln(),[a,o]=w.useState(null),{data:l,isLoading:c}=ft({queryKey:["unlinked-spools"],queryFn:me.getUnlinkedSpools,enabled:t}),u=pt({mutationFn:f=>me.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(Gl,{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(Gt,{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(mt,{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(Es,{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(Me,{variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(Me,{onClick:d,disabled:!a||u.isPending,children:u.isPending?s.jsxs(s.Fragment,{children:[s.jsx(mt,{className:"w-4 h-4 animate-spin"}),"Linking..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Gl,{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 EPe(t,e){if(t===255)return"External";let n,r=!1;t>=128&&t<=135?(n=t-128,r=!0):t>=0&&t<=3?(n=t,r=e===1):n=0,n=Math.max(0,Math.min(n,7));const i=String.fromCharCode(65+n);return r?`HT-${i}`:`AMS-${i}`}function sV(t){const e=t.includes("_")?t.split("_")[0]:t;return e.startsWith("GFS")?"GF"+e.slice(3):(e.startsWith("PFUS")||e.startsWith("PFSP"),e)}const NPe=["PLA","PETG","ABS","ASA","TPU","PC","PA","NYLON","PVA","HIPS","PP","PET"];function oV(t){const e=t.replace(/@.+$/,"").trim(),n=e.toUpperCase();for(const i of NPe){const a=new RegExp(`\\b${i}\\b`,"i");if(a.test(n)){const o=e.split(a),l=o[0]?.trim()||"",c=o[1]?.trim()||"";return{material:i,brand:l,variant:c}}}const r=e.split(/\s+/);return r.length>=2?{material:r[1],brand:r[0],variant:r.slice(2).join(" ")}:{material:e,brand:"",variant:""}}function BC(t){return!t.startsWith("GF")&&!t.startsWith("P1")}const APe={white:"FFFFFF",black:"000000",red:"FF0000",green:"00FF00",blue:"0000FF",yellow:"FFFF00",cyan:"00FFFF",magenta:"FF00FF",orange:"FFA500",purple:"800080",pink:"FFC0CB",brown:"8B4513",gray:"808080",grey:"808080","jade white":"FFFEF2",ivory:"FFFFF0",beige:"F5F5DC",cream:"FFFDD0",silver:"C0C0C0",gold:"FFD700",bronze:"CD7F32",copper:"B87333",navy:"000080",teal:"008080",olive:"808000",maroon:"800000",coral:"FF7F50",salmon:"FA8072",lime:"32CD32",mint:"98FF98","forest green":"228B22","sky blue":"87CEEB","royal blue":"4169E1",turquoise:"40E0D0",lavender:"E6E6FA",violet:"EE82EE",plum:"DDA0DD",tan:"D2B48C",chocolate:"D2691E",charcoal:"36454F",slate:"708090",transparent:"000000",natural:"F5F5DC",wood:"DEB887"},TPe=[{name:"White",hex:"FFFFFF"},{name:"Black",hex:"000000"},{name:"Red",hex:"FF0000"},{name:"Blue",hex:"0000FF"},{name:"Green",hex:"00AA00"},{name:"Yellow",hex:"FFFF00"},{name:"Orange",hex:"FFA500"},{name:"Gray",hex:"808080"}],CPe=[{name:"Cyan",hex:"00FFFF"},{name:"Magenta",hex:"FF00FF"},{name:"Purple",hex:"800080"},{name:"Pink",hex:"FFC0CB"},{name:"Brown",hex:"8B4513"},{name:"Beige",hex:"F5F5DC"},{name:"Navy",hex:"000080"},{name:"Teal",hex:"008080"},{name:"Lime",hex:"32CD32"},{name:"Gold",hex:"FFD700"},{name:"Silver",hex:"C0C0C0"},{name:"Maroon",hex:"800000"},{name:"Olive",hex:"808000"},{name:"Coral",hex:"FF7F50"},{name:"Salmon",hex:"FA8072"},{name:"Turquoise",hex:"40E0D0"},{name:"Violet",hex:"EE82EE"},{name:"Indigo",hex:"4B0082"},{name:"Chocolate",hex:"D2691E"},{name:"Tan",hex:"D2B48C"},{name:"Slate",hex:"708090"},{name:"Charcoal",hex:"36454F"},{name:"Ivory",hex:"FFFFF0"},{name:"Cream",hex:"FFFDD0"}];function kPe(t){const e=t.toLowerCase().trim();return APe[e]||null}function jPe({isOpen:t,onClose:e,printerId:n,slotInfo:r,nozzleDiameter:i="0.4",onSuccess:a}){const[o,l]=w.useState(""),[c,u]=w.useState(null),[d,f]=w.useState(""),[m,p]=w.useState(""),[b,v]=w.useState(""),[x,y]=w.useState(!1),[S,M]=w.useState(!1),{data:N,isLoading:A}=ft({queryKey:["cloudSettings"],queryFn:()=>me.getCloudSettings(),enabled:t}),{data:k,isLoading:C}=ft({queryKey:["kprofiles",n,i],queryFn:()=>me.getKProfiles(n,i),enabled:t&&!!n}),D=pt({mutationFn:async()=>{if(!o)throw new Error("No filament preset selected");const J=N?.filament.find(ge=>ge.setting_id===o);if(!J)throw new Error("Selected preset not found");const ne=oV(J.name),te=c?.slot_id??-1,z=d||r.trayColor?.slice(0,6)||"FFFFFF",H=J.name.replace(/@.+$/,"").trim();let Z=sV(o);if(!o.startsWith("GFS"))try{const ge=await me.getCloudSettingDetail(o);ge.filament_id?Z=ge.filament_id:ge.base_id&&(Z=sV(ge.base_id),console.log(`Derived tray_info_idx from base_id: ${ge.base_id} -> ${Z}`))}catch(ge){console.warn("Failed to fetch preset detail for filament_id:",ge)}let ee=190,he=230;const fe=ne.material.toUpperCase();fe.includes("PLA")?(ee=190,he=230):fe.includes("PETG")?(ee=220,he=260):fe.includes("ABS")||fe.includes("ASA")?(ee=240,he=280):fe.includes("TPU")?(ee=200,he=240):fe.includes("PC")?(ee=260,he=300):(fe.includes("PA")||fe.includes("NYLON"))&&(ee=250,he=290);const oe=c?.k_value?parseFloat(c.k_value):0,Ne=await me.configureAmsSlot(n,r.amsId,r.trayId,{tray_info_idx:Z,tray_type:ne.material||"PLA",tray_sub_brands:H,tray_color:z+"FF",nozzle_temp_min:ee,nozzle_temp_max:he,cali_idx:te,nozzle_diameter:i,setting_id:o,kprofile_filament_id:c?.filament_id,kprofile_setting_id:c?.setting_id||void 0,k_value:oe});try{await me.saveSlotPreset(n,r.amsId,r.trayId,o,H)}catch(ge){console.warn("Failed to save slot preset mapping:",ge)}return Ne},onSuccess:()=>{y(!0),a?.(),setTimeout(()=>{y(!1),e()},1500)}}),T=pt({mutationFn:async()=>me.resetAmsSlot(n,r.amsId,r.trayId),onSuccess:()=>{y(!0),a?.(),setTimeout(()=>{y(!1),e()},1500)}}),R=w.useMemo(()=>{if(!N?.filament)return[];const J=b.toLowerCase();return N.filament.filter(ne=>J?ne.name.toLowerCase().includes(J):!0).sort((ne,te)=>{const z=BC(ne.setting_id),H=BC(te.setting_id);return z&&!H?-1:!z&&H?1:ne.name.localeCompare(te.name)})},[N?.filament,b]),U=w.useMemo(()=>{if(!o||!N?.filament)return null;const J=N.filament.find(z=>z.setting_id===o);if(!J)return null;let ne=J.name.replace(/@.+$/,"").trim();ne.startsWith("# ")&&(ne=ne.slice(2).trim());const te=oV(ne);return{fullName:ne,material:te.material,brand:te.brand}},[o,N?.filament]),L=U?.fullName||"",q=w.useMemo(()=>{if(!k?.profiles||!U)return[];const{fullName:J,material:ne,brand:te}=U,z=J.toUpperCase(),H=ne.toUpperCase(),Z=te.toUpperCase();if(!H||H.length<2)return[];const ee=k.profiles.filter(fe=>{const oe=fe.name.toUpperCase();if(Z)return!(!oe.includes(Z)||!oe.includes(H));if(oe.includes(z)||oe.includes(H))return!0;const ge={NYLON:["PA","PA-CF","PA6"],PA:["NYLON"]}[H]||[];for(const Se of ge)if(oe.includes(Se))return!0;return!1}),he=new Map;for(const fe of ee){const oe=`${fe.name}|${fe.k_value}`,Ne=he.get(oe);Ne?fe.extruder_id===1&&Ne.extruder_id===0&&he.set(oe,fe):he.set(oe,fe)}return Array.from(he.values())},[k?.profiles,U]);w.useEffect(()=>{if(t&&N?.filament){if(r.trayInfoIdx){const J=N.filament.find(ne=>ne.setting_id===r.trayInfoIdx);J&&l(J.setting_id)}}else t||(l(""),u(null),f(""),p(""),v(""),y(!1))},[t,N?.filament,r.trayInfoIdx]),w.useEffect(()=>{q.length>0?u(q[0]):u(null)},[o,q]);const j=w.useCallback(J=>{J.key==="Escape"&&e()},[e]);if(w.useEffect(()=>{if(t)return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[t,j]),!t)return null;const W=A||C,K=o&&!D.isPending,V=d||r.trayColor?.slice(0,6)||"FFFFFF";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-lg 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(Kd,{className:"w-5 h-5 text-bambu-blue"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Configure AMS Slot"})]}),s.jsx("button",{onClick:e,className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:s.jsx(Gt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-4 space-y-4 max-h-[60vh] overflow-y-auto",children:[x&&s.jsx("div",{className:"absolute inset-0 bg-bambu-dark-secondary/95 z-10 flex items-center justify-center rounded-xl",children:s.jsxs("div",{className:"text-center space-y-3",children:[s.jsx(JM,{className:"w-16 h-16 text-bambu-green mx-auto"}),s.jsx("p",{className:"text-lg font-semibold text-white",children:"Slot Configured!"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Settings sent to printer"})]})}),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:"Configuring slot:"}),s.jsxs("div",{className:"flex items-center gap-2",children:[r.trayColor&&s.jsx("span",{className:"w-4 h-4 rounded-full border border-white/20",style:{backgroundColor:`#${r.trayColor.slice(0,6)}`}}),s.jsxs("span",{className:"text-white font-medium",children:[EPe(r.amsId,r.trayCount)," Slot ",r.trayId+1]}),r.traySubBrands&&s.jsxs("span",{className:"text-bambu-gray",children:["(",r.traySubBrands,")"]})]})]}),W?s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(mt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-2",children:["Filament Profile ",s.jsx("span",{className:"text-red-400",children:"*"})]}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:"text",placeholder:"Search presets...",value:b,onChange:J=>v(J.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder:text-bambu-gray focus:border-bambu-green focus:outline-none mb-2"}),s.jsx("div",{className:"max-h-48 overflow-y-auto space-y-1",children:R.length===0?s.jsx("p",{className:"text-center py-4 text-bambu-gray",children:N?.filament?.length===0?"No cloud presets. Login to Bambu Cloud to sync.":"No matching presets found."}):R.map(J=>s.jsx("button",{onClick:()=>l(J.setting_id),className:`w-full p-2 rounded-lg border text-left transition-colors ${o===J.setting_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 justify-between",children:[s.jsx("span",{className:"text-white text-sm truncate",children:J.name}),BC(J.setting_id)&&s.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-bambu-blue/20 text-bambu-blue",children:"Custom"})]})},J.setting_id))})]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-2",children:["K Profile (Pressure Advance)",L&&s.jsxs("span",{className:"ml-2 text-xs text-bambu-blue",children:["Filtering for: ",L]})]}),q.length>0?s.jsxs("div",{className:"relative",children:[s.jsxs("select",{value:c?.name||"",onChange:J=>{const ne=q.find(te=>te.name===J.target.value);u(ne||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 appearance-none pr-10",children:[s.jsx("option",{value:"",children:"No K profile (use default 0.020)"}),q.map(J=>s.jsxs("option",{value:J.name,children:[J.name," (K=",J.k_value,")"]},`${J.name}-${J.extruder_id}`))]}),s.jsx(Oi,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}):o?s.jsx("p",{className:"text-sm text-bambu-gray italic py-2",children:"No matching K profiles found. Default K=0.020 will be used."}):s.jsx("span",{className:"inline-block text-xs px-2 py-1 rounded bg-amber-500/20 text-amber-400 border border-amber-500/30",children:"Select a filament profile first"}),c&&s.jsxs("p",{className:"text-xs text-bambu-green mt-1",children:["K=",c.k_value," from printer calibration"]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Custom Color (optional)"}),s.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-2",children:[TPe.map(J=>s.jsx("button",{onClick:()=>{f(J.hex),p(J.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${d===J.hex?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:`#${J.hex}`},title:J.name},J.hex)),s.jsx("button",{onClick:()=>M(!S),className:"w-7 h-7 rounded-md border-2 border-white/20 hover:border-white/40 flex items-center justify-center text-white/60 hover:text-white/80 transition-all text-xs",title:S?"Show less colors":"Show more colors",children:S?"−":"+"})]}),S&&s.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:CPe.map(J=>s.jsx("button",{onClick:()=>{f(J.hex),p(J.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${d===J.hex?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:`#${J.hex}`},title:J.name},J.hex))}),s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsx("div",{className:"w-10 h-10 rounded-lg border-2 border-white/20 flex-shrink-0",style:{backgroundColor:`#${V}`}}),s.jsx("input",{type:"text",placeholder:"Color name or hex (e.g., brown, FF8800)",value:m,onChange:J=>{const ne=J.target.value;p(ne);const te=kPe(ne);if(te)f(te);else{const z=ne.replace(/[^0-9A-Fa-f]/g,"").toUpperCase();z.length===6?f(z):z.length===3&&f(z.split("").map(H=>H+H).join(""))}},className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder:text-bambu-gray focus:border-bambu-green focus:outline-none text-sm"}),d&&s.jsx("button",{onClick:()=>{f(""),p("")},className:"px-2 py-1 text-xs text-bambu-gray hover:text-white bg-bambu-dark-tertiary rounded",title:"Clear custom color",children:"Clear"})]}),d&&s.jsxs("p",{className:"text-xs text-bambu-gray mt-1.5",children:["Hex: #",d]})]})]})]}),s.jsxs("div",{className:"flex justify-between p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(Me,{variant:"secondary",onClick:()=>T.mutate(),disabled:T.isPending||D.isPending,className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:T.isPending?s.jsxs(s.Fragment,{children:[s.jsx(mt,{className:"w-4 h-4 animate-spin"}),"Resetting..."]}):s.jsxs(s.Fragment,{children:[s.jsx(lm,{className:"w-4 h-4"}),"Reset Slot"]})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Me,{variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(Me,{onClick:()=>D.mutate(),disabled:!K,children:D.isPending?s.jsxs(s.Fragment,{children:[s.jsx(mt,{className:"w-4 h-4 animate-spin"}),"Configuring..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Kd,{className:"w-4 h-4"}),"Configure Slot"]})})]})]}),(D.isError||T.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:D.error?.message||T.error?.message})]})]})}function PPe({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 lV=({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"})]}),cV={"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"},RPe={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 $C(t){if(!t)return null;if(cV[t])return cV[t];const e=t.split("-");if(e.length<2)return null;const n=e[1];return RPe[n]||null}function HC(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,m=r/255;i===d?l=((f-m)/u+(f<m?6:0))/6:i===f?l=((m-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<45&&o<.45||l>=45&&l<70&&o<.4?"Brown":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 VC(t){return(t??.02).toFixed(3)}function uV({side:t}){const{mode:e}=oh(),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 dV({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 DPe({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 OPe({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 LPe({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 IPe({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 FPe({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 GC({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 hV({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=dV:a<=l?d=DPe:d=OPe,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 fV({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=LPe):t<=o?(l="#d4a017",c="Fair",u=IPe):(l="#c62828",c="Bad",u=FPe),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 Qu(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 mV(t){return t>50?"#00ae42":t>=15?"#f59e0b":"#ef4444"}function UPe(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function zPe(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 BPe(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 $Pe(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 WC(t){return t?!!(t.tray_info_idx&&t.tray_info_idx.startsWith("GF")||t.tray_uuid&&t.tray_uuid!=="00000000000000000000000000000000"||t.tag_uid&&t.tag_uid!=="0000000000000000"):!1}function HPe({url:t,printName:e}){const[n,r]=w.useState(!1),[i,a]=w.useState(!1),[o,l]=w.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(Bs,{className:"w-8 h-8 text-bambu-gray"})]}):s.jsx(Bs,{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 VPe({printers:t}){const e=ln(),n=w.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]=w.useState(0);return w.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 pV(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 gV({printer:t,hideIfDisconnected:e,maintenanceInfo:n,viewMode:r="expanded",cardSize:i=2,amsThresholds:a,spoolmanEnabled:o=!1,hasUnlinkedSpools:l=!1,timeFormat:c="system",cameraViewMode:u="window",onOpenEmbeddedCamera:d}){const f=ln(),m=pl(),{showToast:p}=Yn(),[b,v]=w.useState(!1),[x,y]=w.useState(!1),[S,M]=w.useState(!0),[N,A]=w.useState(!1),[k,C]=w.useState(!1),[D,T]=w.useState(!1),[R,U]=w.useState(!1),[L,q]=w.useState(!1),[j,W]=w.useState(!1),[K,V]=w.useState(!1),[J,ne]=w.useState(!1),[te,z]=w.useState(!1),[H,Z]=w.useState(!1),[ee,he]=w.useState(null),[fe,oe]=w.useState(null),[Ne,ge]=w.useState(null),[Se,Re]=w.useState(!1),[de,Qe]=w.useState(null),[G,ie]=w.useState(!1),[X,$]=w.useState(!1),[I,ce]=w.useState(null),[Ee,Ie]=w.useState(!1),{data:le}=ft({queryKey:["printerStatus",t.id],queryFn:()=>me.getPrinterStatus(t.id),refetchInterval:3e4}),{data:B}=ft({queryKey:["firmwareUpdate",t.id],queryFn:()=>Q1.checkPrinterUpdate(t.id),staleTime:300*1e3,refetchInterval:300*1e3}),O=w.useMemo(()=>{const Oe=new Set;if(le?.ams)for(const gt of le.ams)for(const Rt of gt.tray||[])Rt.tray_info_idx&&Oe.add(Rt.tray_info_idx);return le?.vt_tray?.tray_info_idx&&Oe.add(le.vt_tray.tray_info_idx),Array.from(Oe)},[le?.ams,le?.vt_tray]),{data:Y}=ft({queryKey:["filamentInfo",O],queryFn:()=>me.getFilamentInfo(O),enabled:O.length>0,staleTime:300*1e3}),{data:pe}=ft({queryKey:["slotPresets",t.id],queryFn:()=>me.getSlotPresets(t.id),staleTime:120*1e3}),[we,ae]=w.useState(null);w.useEffect(()=>{le?.wifi_signal!=null&&ae(le.wifi_signal)},[le?.wifi_signal]);const ke=le?.wifi_signal??we,De=w.useRef(void 0);w.useEffect(()=>{le?.connected!==void 0&&(De.current=le.connected)},[le?.connected]);const Ke=le?.connected??De.current,et=w.useRef({});w.useEffect(()=>{le?.ams_extruder_map&&Object.keys(le.ams_extruder_map).length>0&&(et.current=le.ams_extruder_map)},[le?.ams_extruder_map]);const Ye=le?.ams_extruder_map&&Object.keys(le.ams_extruder_map).length>0?le.ams_extruder_map:et.current,se=w.useRef([]);w.useEffect(()=>{le?.ams&&le.ams.length>0&&(se.current=le.ams)},[le?.ams]);const ye=le?.ams&&le.ams.length>0?le.ams:se.current,Ce=w.useRef(255),Ue=le?.tray_now;Ue!==void 0&&Ue!==255&&(Ce.current=Ue);const dt=Ue===void 0||Ue===255?Ce.current:Ue,{data:re}=ft({queryKey:["smartPlugByPrinter",t.id],queryFn:()=>me.getSmartPlugByPrinter(t.id)}),{data:Fe}=ft({queryKey:["smartPlugStatus",re?.id],queryFn:()=>re?me.getSmartPlugStatus(re.id):null,enabled:!!re,refetchInterval:1e4}),{data:ve}=ft({queryKey:["queue",t.id,"pending"],queryFn:()=>me.getQueue(t.id,"pending")}),$e=ve?.length||0,{data:Le}=ft({queryKey:["archives",t.id,"last"],queryFn:()=>me.getArchives(t.id,1,0),enabled:le?.connected&&le?.state!=="RUNNING"}),Ae=Le?.[0],Ge=e&&Ke===!1,it=pt({mutationFn:Oe=>me.deletePrinter(t.id,Oe.deleteArchives),onSuccess:()=>{f.invalidateQueries({queryKey:["printers"]}),f.invalidateQueries({queryKey:["archives"]}),f.invalidateQueries({queryKey:["maintenanceOverview"]})}}),Ot=pt({mutationFn:()=>me.connectPrinter(t.id),onSuccess:()=>{f.invalidateQueries({queryKey:["printerStatus",t.id]})}}),kt=pt({mutationFn:Oe=>re?me.controlSmartPlug(re.id,Oe):Promise.reject("No plug"),onSuccess:()=>{f.invalidateQueries({queryKey:["smartPlugStatus",re?.id]})}}),on=pt({mutationFn:Oe=>re?me.updateSmartPlug(re.id,{auto_off:Oe}):Promise.reject("No plug"),onSuccess:()=>{f.invalidateQueries({queryKey:["smartPlugByPrinter",t.id]}),f.invalidateQueries({queryKey:["smart-plugs"]})}}),Ut=pt({mutationFn:()=>me.stopPrint(t.id),onSuccess:()=>{p("Print stopped"),f.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:Oe=>p(Oe.message||"Failed to stop print","error")}),yn=pt({mutationFn:()=>me.pausePrint(t.id),onSuccess:()=>{p("Print paused"),f.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:Oe=>p(Oe.message||"Failed to pause print","error")}),xt=pt({mutationFn:()=>me.resumePrint(t.id),onSuccess:()=>{p("Print resumed"),f.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:Oe=>p(Oe.message||"Failed to resume print","error")}),Yt=pt({mutationFn:Oe=>me.setChamberLight(t.id,Oe),onMutate:async Oe=>{await f.cancelQueries({queryKey:["printerStatus",t.id]});const gt=f.getQueryData(["printerStatus",t.id]);return f.setQueryData(["printerStatus",t.id],Rt=>({...Rt,chamber_light:Oe})),{previousStatus:gt}},onSuccess:(Oe,gt)=>{p(`Chamber light ${gt?"on":"off"}`)},onError:(Oe,gt,Rt)=>{Rt?.previousStatus&&f.setQueryData(["printerStatus",t.id],Rt.previousStatus),p(Oe.message||"Failed to control chamber light","error")}}),sn=pt({mutationFn:Oe=>me.updatePrinter(t.id,{plate_detection_enabled:Oe}),onSuccess:()=>{f.invalidateQueries({queryKey:["printers"]}),p(sn.variables?"Plate check enabled":"Plate check disabled")},onError:Oe=>p(Oe.message||"Failed to update setting","error")}),Tt=(le?.state==="RUNNING"||le?.state==="PAUSE"||le?.state==="PAUSED")&&(le?.printable_objects_count??0)>=2,{data:Cn,refetch:Cr}=ft({queryKey:["printableObjects",t.id],queryFn:()=>me.getPrintableObjects(t.id),enabled:H||Tt,refetchInterval:H?5e3:Tt?3e4:!1}),er=pt({mutationFn:Oe=>me.skipObjects(t.id,Oe),onSuccess:Oe=>{p(Oe.message||"Objects skipped"),Cr()},onError:Oe=>p(Oe.message||"Failed to skip objects","error")}),[Un,yr]=w.useState(null),Ci=w.useRef(!1),gi=w.useRef(null),_e=w.useRef(!1),Je=pt({mutationFn:({amsId:Oe,slotId:gt})=>me.refreshAmsSlot(t.id,Oe,gt),onMutate:({amsId:Oe,slotId:gt})=>{gi.current&&clearTimeout(gi.current),Ci.current=!1,_e.current=!1,yr({amsId:Oe,slotId:gt}),setTimeout(()=>{_e.current=!0},2e3),gi.current=setTimeout(()=>{yr(null)},3e4)},onSuccess:Oe=>{p(Oe.message||"RFID re-read initiated")},onError:Oe=>{p(Oe.message||"Failed to re-read RFID","error"),gi.current&&clearTimeout(gi.current),yr(null)}}),[Ze,lt]=w.useState(null),[st,Pt]=w.useState(null),Bt=async()=>{try{const Oe=await me.getPlateReferences(t.id);lt(Oe)}catch{}},Ht=()=>{sn.mutate(!t.plate_detection_enabled)},Jt=async()=>{ie(!0),Qe(null);try{const Oe=await me.checkPlateEmpty(t.id,{includeDebugImage:!0});Qe(Oe),Bt()}catch(Oe){p(Oe instanceof Error?Oe.message:"Failed to check plate","error")}finally{ie(!1)}},ue=async Oe=>{$(!0);try{const gt=await me.calibratePlateDetection(t.id,{label:Oe});if(gt.success){p(gt.message||"Calibration saved!","success"),Bt();const Rt=await me.checkPlateEmpty(t.id,{includeDebugImage:!0});Qe(Rt)}else p(gt.message||"Calibration failed","error")}catch(gt){p(gt instanceof Error?gt.message:"Calibration failed","error")}finally{$(!1)}},je=async(Oe,gt)=>{try{await me.updatePlateReferenceLabel(t.id,Oe,gt),Pt(null),Bt()}catch(Rt){p(Rt instanceof Error?Rt.message:"Failed to update label","error")}},Ve=async Oe=>{try{await me.deletePlateReference(t.id,Oe),p("Reference deleted","success"),Bt();const gt=await me.checkPlateEmpty(t.id,{includeDebugImage:!0});Qe(gt)}catch(gt){p(gt instanceof Error?gt.message:"Failed to delete reference","error")}},We=async()=>{if(I){Ie(!0);try{await me.updatePrinter(t.id,{plate_detection_roi:I}),p("Detection area saved","success"),ce(null);const Oe=await me.checkPlateEmpty(t.id,{includeDebugImage:!0});Qe(Oe)}catch(Oe){p(Oe instanceof Error?Oe.message:"Failed to save detection area","error")}finally{Ie(!1)}}};w.useEffect(()=>{const Oe=gt=>{gt.key==="Escape"&&de&&Qe(null)};return window.addEventListener("keydown",Oe),()=>window.removeEventListener("keydown",Oe)},[de]);const He=w.useRef(null);w.useEffect(()=>{if(!Un)return;const Oe=le?.ams_status_main??0;return Oe!==0&&(Ci.current=!0,He.current&&(clearTimeout(He.current),He.current=null)),Ci.current&&Oe===0&&(_e.current?(gi.current&&clearTimeout(gi.current),yr(null)):He.current||(He.current=setTimeout(()=>{gi.current&&clearTimeout(gi.current),yr(null)},2e3))),()=>{He.current&&clearTimeout(He.current)}},[le?.ams_status_main,Un]);const[wt,Dt]=w.useState(null);if(Ge)return null;const Et=()=>{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"}},St=()=>{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"}},Mt=()=>{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(Nt,{className:"relative",children:[s.jsxs(Ct,{className:i>=3?"p-5":"",children:[s.jsxs("div",{className:Mt(),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:BPe(t.model),alt:t.model||"Printer",className:`object-contain rounded-lg bg-bambu-dark flex-shrink-0 ${Et()}`}),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 ${St()}`,children:t.name}),r==="compact"&&s.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${le?.connected?"bg-status-ok":"bg-status-error"}`,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(Jn,{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(Me,{variant:"ghost",size:"sm",onClick:()=>v(!b),children:s.jsx(Ld,{className:"w-4 h-4"})}),b&&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:()=>{A(!0),v(!1)},children:[s.jsx(Na,{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:()=>{Ot.mutate(),v(!1)},children:[s.jsx(Ar,{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),v(!1)},children:[s.jsx(wK,{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),v(!1)},children:[s.jsx(hn,{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-status-ok/20 text-status-ok":"bg-status-error/20 text-status-error"}`,children:[le?.connected?s.jsx(Xg,{className:"w-3 h-3"}):s.jsx(BD,{className:"w-3 h-3"}),le?.connected?"Connected":"Offline"]}),le?.connected&&ke!=null&&s.jsxs("span",{className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs ${ke>=-50||ke>=-60?"bg-status-ok/20 text-status-ok":ke>=-70?"bg-status-warning/20 text-status-warning":ke>=-80?"bg-orange-500/20 text-orange-600":"bg-status-error/20 text-status-error"}`,title:`WiFi: ${ke} dBm - ${$Pe(ke).label}`,children:[s.jsx($fe,{className:"w-3 h-3"}),ke,"dBm"]}),le?.connected&&(()=>{const Oe=le.hms_errors?lpe(le.hms_errors):[];return s.jsxs("button",{onClick:()=>W(!0),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${Oe.length>0?Oe.some(gt=>gt.severity<=2)?"bg-status-error/20 text-status-error":"bg-status-warning/20 text-status-warning":"bg-status-ok/20 text-status-ok"}`,title:"Click to view HMS errors",children:[s.jsx(Tn,{className:"w-3 h-3"}),Oe.length>0?Oe.length:"OK"]})})(),n&&s.jsxs("button",{onClick:()=>m("/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-status-error/20 text-status-error":n.warning_count>0?"bg-status-warning/20 text-status-warning":"bg-status-ok/20 text-status-ok"}`,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(Xd,{className:"w-3 h-3"}),n.due_count>0||n.warning_count>0?n.due_count+n.warning_count:"OK"]}),$e>0&&s.jsxs("button",{onClick:()=>m("/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:`${$e} print${$e>1?"s":""} in queue`,children:[s.jsx(sl,{className:"w-3 h-3"}),$e]}),B?.update_available&&s.jsxs("button",{onClick:()=>Re(!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: ${B.current_version} → ${B.latest_version}`,children:[s.jsx($r,{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(Nt,{className:"w-full max-w-md mx-4",children:s.jsxs(Ct,{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(Tn,{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:S,onChange:Oe=>M(Oe.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:S?"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(Me,{variant:"secondary",onClick:()=>{y(!1),M(!0)},children:"Cancel"}),s.jsx(Me,{variant:"danger",onClick:()=>{it.mutate({deleteArchives:S}),y(!1),M(!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:pV(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:()=>Z(!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(lV,{className:"w-4 h-4"}),Cn&&Cn.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:Cn.skipped_count})]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx(HPe,{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(Jn,{className:"w-3 h-3"}),UPe(le.remaining_time*60)]}),s.jsxs("span",{className:"text-bambu-green font-medium",title:"Estimated completion time",children:["ETA ",zPe(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(sl,{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:pV(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:"—"})]}),Ae?s.jsxs("p",{className:"text-xs text-bambu-gray mt-2 truncate",title:Ae.print_name||Ae.filename,children:["Last: ",Ae.print_name||Ae.filename,Ae.completed_at&&s.jsxs("span",{className:"ml-1 text-bambu-gray/60",children:["• ",xg(Ae.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(hpe,{printerId:t.id})]}),le.temperatures&&r==="expanded"&&(()=>{const Oe=le.temperatures.nozzle_heating||le.temperatures.nozzle_2_heating||!1,gt=le.temperatures.bed_heating||!1,Rt=le.temperatures.chamber_heating||!1,ct=t.nozzle_count===2||le.temperatures.nozzle_2!==void 0,Zt=le.active_extruder===1?"L":"R";return s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg flex-1",children:[s.jsx(GC,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-orange-400",isHeating:Oe}),le.temperatures.nozzle_2!==void 0?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-[9px] text-bambu-gray",children:"L / R"}),s.jsxs("p",{className:"text-[11px] 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-[9px] text-bambu-gray",children:"Nozzle"}),s.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(le.temperatures.nozzle||0),"°C"]})]})]}),s.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg flex-1",children:[s.jsx(GC,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-blue-400",isHeating:gt}),s.jsx("p",{className:"text-[9px] text-bambu-gray",children:"Bed"}),s.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(le.temperatures.bed||0),"°C"]})]}),le.temperatures.chamber!==void 0&&s.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg flex-1",children:[s.jsx(GC,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-green-400",isHeating:Rt}),s.jsx("p",{className:"text-[9px] text-bambu-gray",children:"Chamber"}),s.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(le.temperatures.chamber||0),"°C"]})]}),ct&&s.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg",title:`Active: ${Zt==="L"?"Left":"Right"} nozzle`,children:[s.jsx("p",{className:`text-[11px] font-bold ${Zt==="L"?"text-amber-400":"text-gray-500"}`,children:"L"}),s.jsx("p",{className:"text-[9px] text-bambu-gray",children:"Nozzle"}),s.jsx("p",{className:`text-[11px] font-bold ${Zt==="R"?"text-amber-400":"text-gray-500"}`,children:"R"})]})]})})(),r==="expanded"&&(()=>{const Oe=le.state==="RUNNING",gt=le.state==="PAUSED"||le.state==="PAUSE",Rt=Oe||gt,ct=Ut.isPending||yn.isPending||xt.isPending,Zt=le.cooling_fan_speed,Kt=le.big_fan1_speed,be=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 ${Zt&&Zt>0?"bg-cyan-500/10":"bg-bambu-dark"}`,title:"Part Cooling Fan",children:[s.jsx(dK,{className:`w-3.5 h-3.5 ${Zt&&Zt>0?"text-cyan-400":"text-bambu-gray/50"}`}),s.jsxs("span",{className:`text-[10px] ${Zt&&Zt>0?"text-cyan-400":"text-bambu-gray/50"}`,children:[Zt??0,"%"]})]}),s.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${Kt&&Kt>0?"bg-blue-500/10":"bg-bambu-dark"}`,title:"Auxiliary Fan",children:[s.jsx(EK,{className:`w-3.5 h-3.5 ${Kt&&Kt>0?"text-blue-400":"text-bambu-gray/50"}`}),s.jsxs("span",{className:`text-[10px] ${Kt&&Kt>0?"text-blue-400":"text-bambu-gray/50"}`,children:[Kt??0,"%"]})]}),s.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${be&&be>0?"bg-green-500/10":"bg-bambu-dark"}`,title:"Chamber Fan",children:[s.jsx(Mue,{className:`w-3.5 h-3.5 ${be&&be>0?"text-green-400":"text-bambu-gray/50"}`}),s.jsxs("span",{className:`text-[10px] ${be&&be>0?"text-green-400":"text-bambu-gray/50"}`,children:[be??0,"%"]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{onClick:()=>V(!0),disabled:!Rt||ct,className:`
  77. flex items-center justify-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium
  78. transition-colors
  79. ${Rt?"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(cl,{className:"w-3 h-3"}),"Stop"]}),s.jsxs("button",{onClick:()=>gt?z(!0):ne(!0),disabled:!Rt||ct,className:`
  81. flex items-center justify-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium
  82. transition-colors
  83. ${Rt?gt?"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:gt?"Resume print":"Pause print",children:[gt?s.jsx(ol,{className:"w-3 h-3"}):s.jsx(UD,{className:"w-3 h-3"}),gt?"Resume":"Pause"]})]})]})]})})(),ye&&ye.length>0&&r==="expanded"&&(()=>{const Oe=ye.filter(ct=>ct.tray.length>1),gt=ye.filter(ct=>ct.tray.length===1),Rt=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:[Oe.length>0&&s.jsx("div",{className:"grid grid-cols-2 gap-3",children:Oe.map(ct=>{const Zt=Ye[String(ct.id)],Kt=ct.id>=128?ct.id-128:ct.id,be=Zt!==void 0?Zt:Kt,ut=be===1,It=be===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:Qu(ct.id,ct.tray.length)}),Rt&&(ut||It)&&s.jsx(uV,{side:ut?"L":"R"})]}),(ct.humidity!=null||ct.temp!=null)&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[ct.humidity!=null&&s.jsx(hV,{humidity:ct.humidity,goodThreshold:a?.humidityGood,fairThreshold:a?.humidityFair,onClick:()=>he({amsId:ct.id,amsLabel:Qu(ct.id,ct.tray.length),mode:"humidity"}),compact:!0}),ct.temp!=null&&s.jsx(fV,{temp:ct.temp,goodThreshold:a?.tempGood,fairThreshold:a?.tempFair,onClick:()=>he({amsId:ct.id,amsLabel:Qu(ct.id,ct.tray.length),mode:"temperature"}),compact:!0})]})]}),s.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:[0,1,2,3].map(yt=>{const Xt=ct.tray[yt]||ct.tray.find(jr=>jr.id===yt),tr=Xt?.tray_type&&Xt.remain>=0,cn=!Xt?.tray_type,ki=ct.id*4+yt,$n=dt===ki,ui=Xt?.tray_info_idx?Y?.[Xt.tray_info_idx]:null,vr=pe?.[ki],Zn=Xt?.tray_type?{vendor:WC(Xt)?"Bambu Lab":"Generic",profile:ui?.name||vr?.preset_name||Xt.tray_sub_brands||Xt.tray_type,colorName:$C(Xt.tray_id_name)||HC(Xt.tray_color),colorHex:Xt.tray_color||null,kFactor:VC(Xt.k),fillLevel:tr?Xt.remain:null,trayUuid:Xt.tray_uuid||null}:null,kr=Un?.amsId===ct.id&&Un?.slotId===yt,to=s.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${cn?"opacity-50":""} ${$n?"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:Xt?.tray_color?`#${Xt.tray_color}`:Xt?.tray_type?"#333":"transparent",borderColor:cn?"#666":"rgba(255,255,255,0.1)",borderStyle:cn?"dashed":"solid"}}),s.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:Xt?.tray_type||"—"}),s.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:tr&&Xt?s.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${Xt.remain}%`,backgroundColor:mV(Xt.remain)}}):Xt?.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:[kr&&s.jsx("div",{className:"absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20",children:s.jsx(Ar,{className:"w-4 h-4 text-bambu-green animate-spin"})}),le?.state!=="RUNNING"&&s.jsx("button",{onClick:jr=>{jr.stopPropagation(),Dt(wt?.amsId===ct.id&&wt?.slotId===yt?null:{amsId:ct.id,slotId:yt})},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(Ld,{className:"w-2.5 h-2.5 text-bambu-gray"})}),le?.state!=="RUNNING"&&wt?.amsId===ct.id&&wt?.slotId===yt&&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:jr=>{jr.stopPropagation(),Je.mutate({amsId:ct.id,slotId:yt}),Dt(null)},disabled:kr,children:[s.jsx(Ar,{className:`w-3 h-3 ${kr?"animate-spin":""}`}),"Re-read RFID"]})}),Zn?s.jsx(zC,{data:Zn,spoolman:{enabled:o,hasUnlinkedSpools:l,onLinkSpool:o&&Zn.trayUuid?jr=>{oe({trayUuid:jr,trayInfo:{type:Zn.profile,color:Zn.colorHex||"",location:`${Qu(ct.id,ct.tray.length)} Slot ${yt+1}`}})}:void 0},configureSlot:{enabled:!0,onConfigure:()=>ge({amsId:ct.id,trayId:yt,trayCount:ct.tray.length,trayType:Xt?.tray_type||void 0,trayColor:Xt?.tray_color||void 0,traySubBrands:Xt?.tray_sub_brands||void 0,trayInfoIdx:Xt?.tray_info_idx||void 0})},children:to}):s.jsx(aV,{configureSlot:{enabled:!0,onConfigure:()=>ge({amsId:ct.id,trayId:yt,trayCount:ct.tray.length})},children:to})]},yt)})})]},ct.id)})}),(gt.length>0||le.vt_tray&&le.vt_tray.tray_type)&&s.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[gt.map(ct=>{const Zt=Ye[String(ct.id)],Kt=ct.id>=128?ct.id-128:ct.id,be=Zt!==void 0?Zt:Kt,ut=be===1,It=be===0,yt=ct.tray[0],Xt=yt?.tray_type&&yt.remain>=0,tr=!yt?.tray_type,cn=ct.id*4+(yt?.id??0),ki=dt===cn,$n=yt?.tray_info_idx?Y?.[yt.tray_info_idx]:null,ui=pe?.[cn],vr=yt?.tray_type?{vendor:WC(yt)?"Bambu Lab":"Generic",profile:$n?.name||ui?.preset_name||yt.tray_sub_brands||yt.tray_type,colorName:$C(yt.tray_id_name)||HC(yt.tray_color),colorHex:yt.tray_color||null,kFactor:VC(yt.k),fillLevel:Xt?yt.remain:null,trayUuid:yt.tray_uuid||null}:null,Zn=yt?.id??0,kr=Un?.amsId===ct.id&&Un?.slotId===Zn,to=s.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${tr?"opacity-50":""} ${ki?"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:yt?.tray_color?`#${yt.tray_color}`:yt?.tray_type?"#333":"transparent",borderColor:tr?"#666":"rgba(255,255,255,0.1)",borderStyle:tr?"dashed":"solid"}}),s.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:yt?.tray_type||"—"}),s.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:Xt?s.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${yt.remain}%`,backgroundColor:mV(yt.remain)}}):yt?.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:Qu(ct.id,ct.tray.length)}),Rt&&(ut||It)&&s.jsx(uV,{side:ut?"L":"R"})]}),s.jsxs("div",{className:"flex gap-1.5",children:[s.jsxs("div",{className:"relative group flex-1",children:[kr&&s.jsx("div",{className:"absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20",children:s.jsx(Ar,{className:"w-4 h-4 text-bambu-green animate-spin"})}),le?.state!=="RUNNING"&&s.jsx("button",{onClick:jr=>{jr.stopPropagation(),Dt(wt?.amsId===ct.id&&wt?.slotId===Zn?null:{amsId:ct.id,slotId:Zn})},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(Ld,{className:"w-2.5 h-2.5 text-bambu-gray"})}),le?.state!=="RUNNING"&&wt?.amsId===ct.id&&wt?.slotId===Zn&&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:jr=>{jr.stopPropagation(),Je.mutate({amsId:ct.id,slotId:Zn}),Dt(null)},disabled:kr,children:[s.jsx(Ar,{className:`w-3 h-3 ${kr?"animate-spin":""}`}),"Re-read RFID"]})}),vr?s.jsx(zC,{data:vr,spoolman:{enabled:o,hasUnlinkedSpools:l,onLinkSpool:o&&vr.trayUuid?jr=>{oe({trayUuid:jr,trayInfo:{type:vr.profile,color:vr.colorHex||"",location:Qu(ct.id,ct.tray.length)}})}:void 0},configureSlot:{enabled:!0,onConfigure:()=>ge({amsId:ct.id,trayId:Zn,trayCount:ct.tray.length,trayType:yt?.tray_type||void 0,trayColor:yt?.tray_color||void 0,traySubBrands:yt?.tray_sub_brands||void 0,trayInfoIdx:yt?.tray_info_idx||void 0})},children:to}):s.jsx(aV,{configureSlot:{enabled:!0,onConfigure:()=>ge({amsId:ct.id,trayId:Zn,trayCount:ct.tray.length})},children:to})]}),(ct.humidity!=null||ct.temp!=null)&&s.jsxs("div",{className:"flex flex-col justify-center gap-1 shrink-0",children:[ct.temp!=null&&s.jsx(fV,{temp:ct.temp,goodThreshold:a?.tempGood,fairThreshold:a?.tempFair,onClick:()=>he({amsId:ct.id,amsLabel:Qu(ct.id,ct.tray.length),mode:"temperature"}),compact:!0}),ct.humidity!=null&&s.jsx(hV,{humidity:ct.humidity,goodThreshold:a?.humidityGood,fairThreshold:a?.humidityFair,onClick:()=>he({amsId:ct.id,amsLabel:Qu(ct.id,ct.tray.length),mode:"humidity"}),compact:!0})]})]})]},ct.id)}),le.vt_tray&&le.vt_tray.tray_type&&(()=>{const ct=le.vt_tray,Zt=dt===254,Kt=ct.tray_info_idx?Y?.[ct.tray_info_idx]:null,be=pe?.[1020],ut={vendor:WC(ct)?"Bambu Lab":"Generic",profile:Kt?.name||be?.preset_name||ct.tray_sub_brands||ct.tray_type||"Unknown",colorName:$C(ct.tray_id_name)||HC(ct.tray_color),colorHex:ct.tray_color||null,kFactor:VC(ct.k),fillLevel:null,trayUuid:ct.tray_uuid||null},It=s.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center cursor-default ${Zt?"ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark":""}`,children:[s.jsx("div",{className:"w-3.5 h-3.5 rounded-full mx-auto mb-0.5 border-2",style:{backgroundColor:ct.tray_color?`#${ct.tray_color}`:"#333",borderColor:Zt?"var(--accent)":"rgba(255,255,255,0.1)"}}),s.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:ct.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(zC,{data:ut,spoolman:{enabled:o,hasUnlinkedSpools:l,onLinkSpool:o&&ut.trayUuid?yt=>{oe({trayUuid:yt,trayInfo:{type:ut.profile,color:ut.colorHex||"",location:"External Spool"}})}:void 0},configureSlot:{enabled:!0,onConfigure:()=>ge({amsId:255,trayId:0,trayCount:1,trayType:ct.tray_type||void 0,trayColor:ct.tray_color||void 0,traySubBrands:ct.tray_sub_brands||void 0,trayInfoIdx:ct.tray_info_idx||void 0})},children:It})]})})()]})]})]})})()]}),re&&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(Bf,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"text-sm text-white truncate",children:re.name}),Fe&&s.jsxs("span",{className:`text-xs px-1.5 py-0.5 rounded flex-shrink-0 ${Fe.state==="ON"?"bg-bambu-green/20 text-bambu-green":Fe.state==="OFF"?"bg-red-500/20 text-red-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:[Fe.state||"?",Fe.state==="ON"&&Fe.energy?.power!=null&&s.jsxs("span",{className:"text-yellow-400 ml-1.5",children:["· ",Fe.energy.power,"W"]})]})]}),s.jsx("div",{className:"flex-1"}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsxs("button",{onClick:()=>U(!0),disabled:kt.isPending||Fe?.state==="ON",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${Fe?.state==="ON"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[s.jsx(wu,{className:"w-3 h-3"}),"On"]}),s.jsxs("button",{onClick:()=>q(!0),disabled:kt.isPending||Fe?.state==="OFF",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${Fe?.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(uE,{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 ${re.auto_off_executed?"text-bambu-green":"text-bambu-gray"}`,children:re.auto_off_executed?"Auto-off done":"Auto-off"}),s.jsx("button",{onClick:()=>on.mutate(!re.auto_off),disabled:on.isPending||re.auto_off_executed,title:re.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 ${re.auto_off_executed?"bg-bambu-green/50 cursor-not-allowed":re.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 ${re.auto_off||re.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(Me,{variant:"secondary",size:"sm",onClick:()=>Yt.mutate(!le?.chamber_light),disabled:!le?.connected||Yt.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(PPe,{on:le?.chamber_light??!1,className:"w-4 h-4"})}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>{if(u==="embedded"&&d)d(t.id,t.name);else{const Oe=localStorage.getItem("cameraWindowState"),gt=Oe?JSON.parse(Oe):{width:640,height:400},Rt=[`width=${gt.width}`,`height=${gt.height}`,gt.left!==void 0?`left=${gt.left}`:"",gt.top!==void 0?`top=${gt.top}`:"","menubar=no,toolbar=no,location=no,status=no,noopener"].filter(Boolean).join(",");window.open(`/camera/${t.id}`,`camera-${t.id}`,Rt)}},disabled:!le?.connected,title:u==="embedded"?"Open camera overlay":"Open camera in new window",children:s.jsx($D,{className:"w-4 h-4"})}),s.jsxs("div",{className:`inline-flex rounded-md ${t.plate_detection_enabled?"ring-1 ring-green-500":""}`,children:[s.jsx(Me,{variant:"secondary",size:"sm",onClick:Ht,disabled:!le?.connected||sn.isPending,title:t.plate_detection_enabled?"Plate check enabled - Click to disable":"Plate check disabled - Click to enable",className:`!rounded-r-none !border-r-0 ${t.plate_detection_enabled?"!border-green-500 !text-green-400 hover:!bg-green-500/20":""}`,children:sn.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(Dw,{className:"w-4 h-4"})}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:Jt,disabled:!le?.connected||G,title:"Manage plate detection calibration",className:`!rounded-l-none !px-1.5 ${t.plate_detection_enabled?"!border-green-500 !text-green-400 hover:!bg-green-500/20":""}`,children:G?s.jsx(mt,{className:"w-3 h-3 animate-spin"}):s.jsx(Oi,{className:"w-3 h-3"})})]}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>C(!0),title:"Browse printer files",children:[s.jsx(aE,{className:"w-4 h-4"}),"Files"]})]})]})]}),k&&s.jsx(epe,{printerId:t.id,printerName:t.name,onClose:()=>C(!1)}),D&&s.jsx(spe,{printerId:t.id,printerName:t.name,onClose:()=>T(!1)}),de&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>Qe(null),children:s.jsxs("div",{className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl max-w-lg w-full",onClick:Oe=>Oe.stopPropagation(),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:[de.needs_calibration?s.jsx(Dw,{className:"w-5 h-5 text-blue-500"}):de.is_empty?s.jsx(Hn,{className:"w-5 h-5 text-green-500"}):s.jsx(za,{className:"w-5 h-5 text-yellow-500"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Build Plate Check"}),de.reference_count!==void 0&&de.max_references&&s.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark-tertiary px-2 py-1 rounded",children:[de.reference_count,"/",de.max_references," refs"]})]}),s.jsx("button",{onClick:()=>Qe(null),className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:s.jsx(Gt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[de.light_warning&&s.jsxs("div",{className:"p-3 rounded-lg bg-yellow-500/20 border border-yellow-500/50",children:[s.jsxs("p",{className:"font-medium text-yellow-400 flex items-center gap-2",children:[s.jsx(Tn,{className:"w-4 h-4"}),"Chamber light is OFF"]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"For reliable detection, please turn ON the chamber light before checking or calibrating."})]}),de.needs_calibration?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"p-3 rounded-lg bg-blue-500/20 border border-blue-500/50",children:[s.jsx("p",{className:"font-medium text-blue-400",children:"Calibration Required"}),s.jsxs("p",{className:"text-sm text-bambu-gray mt-1",children:["Please ensure the build plate is ",s.jsx("strong",{children:"completely empty"})," and chamber light is ",s.jsx("strong",{children:"ON"}),", then click Calibrate."]})]}),s.jsxs("div",{className:"text-sm text-bambu-gray space-y-2",children:[s.jsx("p",{children:"Calibration captures a reference image of the empty plate. Future checks will compare against this reference to detect objects."}),s.jsxs("p",{children:[s.jsx("strong",{children:"Tip:"})," You can store up to 5 calibrations for different plates. The system automatically uses the best match when checking."]})]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:`p-3 rounded-lg ${de.is_empty?"bg-green-500/20 border border-green-500/50":"bg-yellow-500/20 border border-yellow-500/50"}`,children:[s.jsx("p",{className:`font-medium ${de.is_empty?"text-green-400":"text-yellow-400"}`,children:de.is_empty?"Plate appears empty":"Objects detected on plate"}),s.jsxs("p",{className:"text-sm text-bambu-gray mt-1",children:["Confidence: ",Math.round(de.confidence*100),"% | Difference: ",de.difference_percent.toFixed(1),"%"]})]}),de.debug_image_url&&s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:"Analysis preview:"}),s.jsx("img",{src:de.debug_image_url,alt:"Plate detection analysis",className:"w-full rounded-lg border border-bambu-dark-tertiary"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:"Green box = detection area, Red overlay = differences from calibration"})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:de.message})]}),Ze&&Ze.references.length>0&&s.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[s.jsxs("p",{className:"text-sm font-medium text-white mb-2",children:["Saved References (",Ze.references.length,"/",Ze.max_references,")"]}),s.jsx("div",{className:"grid grid-cols-5 gap-2",children:Ze.references.map(Oe=>s.jsxs("div",{className:"relative group",children:[s.jsx("img",{src:me.getPlateReferenceThumbnailUrl(t.id,Oe.index),alt:Oe.label||`Reference ${Oe.index+1}`,className:"w-full aspect-video object-cover rounded border border-bambu-dark-tertiary"}),s.jsx("button",{onClick:()=>Ve(Oe.index),className:"absolute top-1 right-1 p-0.5 bg-red-500/80 rounded opacity-0 group-hover:opacity-100 transition-opacity",title:"Delete reference",children:s.jsx(Gt,{className:"w-3 h-3 text-white"})}),st?.index===Oe.index?s.jsx("input",{type:"text",value:st.label,onChange:gt=>Pt({...st,label:gt.target.value}),onBlur:()=>je(Oe.index,st.label),onKeyDown:gt=>{gt.key==="Enter"&&je(Oe.index,st.label),gt.key==="Escape"&&Pt(null)},className:"w-full mt-1 px-1 py-0.5 text-xs bg-bambu-dark-tertiary border border-bambu-green rounded text-white",autoFocus:!0,placeholder:"Label..."}):s.jsx("p",{className:"text-xs text-bambu-gray mt-1 truncate cursor-pointer hover:text-white",onClick:()=>Pt({index:Oe.index,label:Oe.label}),title:Oe.label?`${Oe.label} - Click to edit`:"Click to add label",children:Oe.label||s.jsx("span",{className:"italic opacity-50",children:"No label"})}),s.jsx("p",{className:"text-[10px] text-bambu-gray/60",children:Oe.timestamp?new Date(Oe.timestamp).toLocaleDateString():""})]},Oe.index))})]}),!de.needs_calibration&&s.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Detection Area (ROI)"}),I?s.jsxs("div",{className:"flex gap-1",children:[s.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>ce(null),disabled:Ee,children:"Cancel"}),s.jsx(Me,{size:"sm",onClick:We,disabled:Ee,children:Ee?s.jsx(mt,{className:"w-3 h-3 animate-spin"}):"Save"})]}):s.jsxs(Me,{variant:"ghost",size:"sm",onClick:()=>ce(de.roi||{x:.15,y:.35,w:.7,h:.55}),children:[s.jsx(Na,{className:"w-3 h-3 mr-1"}),"Edit"]})]}),I?s.jsxs("div",{className:"space-y-3 bg-bambu-dark-tertiary/50 p-3 rounded-lg",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-bambu-gray",children:"X Start"}),s.jsx("input",{type:"range",min:"0",max:"0.9",step:"0.01",value:I.x,onChange:Oe=>ce({...I,x:parseFloat(Oe.target.value)}),className:"w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500"}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:[Math.round(I.x*100),"%"]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-bambu-gray",children:"Y Start"}),s.jsx("input",{type:"range",min:"0",max:"0.9",step:"0.01",value:I.y,onChange:Oe=>ce({...I,y:parseFloat(Oe.target.value)}),className:"w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500"}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:[Math.round(I.y*100),"%"]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-bambu-gray",children:"Width"}),s.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.01",value:I.w,onChange:Oe=>ce({...I,w:parseFloat(Oe.target.value)}),className:"w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500"}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:[Math.round(I.w*100),"%"]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-bambu-gray",children:"Height"}),s.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.01",value:I.h,onChange:Oe=>ce({...I,h:parseFloat(Oe.target.value)}),className:"w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500"}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:[Math.round(I.h*100),"%"]})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Adjust the detection area to focus on the build plate. The green box in the preview shows the current area."})]}):s.jsxs("p",{className:"text-xs text-bambu-gray",children:["Current: X=",Math.round((de.roi?.x||.15)*100),"%, Y=",Math.round((de.roi?.y||.35)*100),"%, W=",Math.round((de.roi?.w||.7)*100),"%, H=",Math.round((de.roi?.h||.55)*100),"%"]})]})]}),s.jsx("div",{className:"flex justify-end gap-2 p-4 border-t border-bambu-dark-tertiary",children:de.needs_calibration?s.jsxs(s.Fragment,{children:[s.jsx(Me,{variant:"ghost",onClick:()=>Qe(null),children:"Cancel"}),s.jsx(Me,{onClick:()=>ue(),disabled:X,children:X?s.jsxs(s.Fragment,{children:[s.jsx(mt,{className:"w-4 h-4 mr-2 animate-spin"}),"Calibrating..."]}):"Calibrate Empty Plate"})]}):s.jsxs(s.Fragment,{children:[s.jsx(Me,{variant:"ghost",onClick:()=>ue(),disabled:X,children:X?"Adding...":`Add Reference (${Ze?.references.length||0}/${Ze?.max_references||5})`}),s.jsx(Me,{onClick:()=>Qe(null),children:"Close"})]})})]})}),R&&re&&s.jsx(zn,{title:"Power On Printer",message:`Are you sure you want to turn ON the power for "${t.name}"?`,confirmText:"Power On",variant:"default",onConfirm:()=>{kt.mutate("on"),U(!1)},onCancel:()=>U(!1)}),L&&re&&s.jsx(zn,{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:()=>{kt.mutate("off"),q(!1)},onCancel:()=>q(!1)}),K&&s.jsx(zn,{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:()=>{Ut.mutate(),V(!1)},onCancel:()=>V(!1)}),J&&s.jsx(zn,{title:"Pause Print",message:`Are you sure you want to pause the current print on "${t.name}"?`,confirmText:"Pause Print",variant:"default",onConfirm:()=>{yn.mutate(),ne(!1)},onCancel:()=>ne(!1)}),te&&s.jsx(zn,{title:"Resume Print",message:`Are you sure you want to resume the print on "${t.name}"?`,confirmText:"Resume Print",variant:"default",onConfirm:()=>{xt.mutate(),z(!1)},onCancel:()=>z(!1)}),H&&s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:()=>Z(!1),onKeyDown:Oe=>Oe.key==="Escape"&&Z(!1),tabIndex:-1,ref:Oe=>Oe?.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] max-h-[85vh] flex flex-col overflow-hidden",onClick:Oe=>Oe.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(lV,{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:()=>Z(!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(Gt,{className:"w-4 h-4"})})]}),Cn?Cn.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 overflow-hidden",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(sfe,{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:[Cn.skipped_count,"/",Cn.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 flex-1 overflow-hidden",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 overflow-y-auto",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(Bs,{className:"w-8 h-8 text-gray-300 dark:text-bambu-gray/30"})}),Cn.objects.length>0&&s.jsx("div",{className:"absolute inset-0 pointer-events-none",children:Cn.objects.map((Oe,gt)=>{let Rt,ct;if(Oe.x!=null&&Oe.y!=null&&Cn.bbox_all){const[Zt,Kt,be,ut]=Cn.bbox_all,It=be-Zt,yt=ut-Kt,Xt=8,tr=100-Xt*2;Rt=Xt+(Oe.x-Zt)/It*tr,ct=Xt+(ut-Oe.y)/yt*tr,Rt=Math.max(5,Math.min(95,Rt)),ct=Math.max(5,Math.min(95,ct))}else if(Oe.x!=null&&Oe.y!=null)Rt=Oe.x/256*100,ct=100-Oe.y/256*100,Rt=Math.max(5,Math.min(95,Rt)),ct=Math.max(5,Math.min(95,ct));else{const Zt=Math.ceil(Math.sqrt(Cn.objects.length)),Kt=Math.floor(gt/Zt),be=gt%Zt,ut=Math.ceil(Cn.objects.length/Zt);Rt=15+be*(70/Zt)+35/Zt,ct=15+Kt*(70/ut)+35/ut}return s.jsx("div",{className:`absolute flex items-center justify-center w-6 h-6 rounded-full text-[10px] font-bold shadow-lg ${Oe.skipped?"bg-red-500 text-white line-through":"bg-bambu-green text-black"}`,style:{left:`${Rt}%`,top:`${ct}%`,transform:"translate(-50%, -50%)"},title:Oe.name,children:Oe.id},Oe.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:[Cn.objects.filter(Oe=>!Oe.skipped).length," active"]})]})}),s.jsx("div",{className:"flex-1 min-w-0 overflow-y-auto",children:Cn.objects.map(Oe=>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. ${Oe.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. ${Oe.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 ${Oe.skipped?"text-red-500 dark:text-red-400":"text-green-600 dark:text-bambu-green"}`,children:Oe.id}),s.jsx("span",{className:`text-[8px] uppercase tracking-wider ${Oe.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 ${Oe.skipped?"text-red-500 dark:text-red-400 line-through":"text-gray-900 dark:text-white"}`,children:Oe.name}),Oe.skipped&&s.jsx("span",{className:"text-[10px] text-red-400/60",children:"Will be skipped"})]}),Oe.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:()=>er.mutate([Oe.id]),disabled:er.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"})]},Oe.id))})]})]}):s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(mt,{className:"w-5 h-5 animate-spin text-bambu-gray"})})]})]}),j&&s.jsx(upe,{printerName:t.name,errors:le?.hms_errors||[],onClose:()=>W(!1)}),ee&&s.jsx(SPe,{isOpen:!!ee,onClose:()=>he(null),printerId:t.id,printerName:t.name,amsId:ee.amsId,amsLabel:ee.amsLabel,initialMode:ee.mode,thresholds:a}),fe&&s.jsx(MPe,{isOpen:!!fe,onClose:()=>oe(null),trayUuid:fe.trayUuid,trayInfo:fe.trayInfo}),Ne&&s.jsx(jPe,{isOpen:!!Ne,onClose:()=>ge(null),printerId:t.id,slotInfo:Ne,onSuccess:()=>{f.invalidateQueries({queryKey:["slotPresets",t.id]}),f.invalidateQueries({queryKey:["printerStatus",t.id]})}}),N&&s.jsx(qPe,{printer:t,onClose:()=>A(!1)}),Se&&B&&s.jsx(WPe,{printer:t,firmwareInfo:B,onClose:()=>Re(!1)}),wt&&s.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>Dt(null)})]})}function GPe({onClose:t,onAdd:e,existingSerials:n}){const[r,i]=w.useState({name:"",serial_number:"",ip_address:"",access_code:"",model:"",auto_archive:!0}),[a,o]=w.useState(!1),[l,c]=w.useState([]),[u,d]=w.useState(""),[f,m]=w.useState(!1),[p,b]=w.useState(!1),[v,x]=w.useState("192.168.1.0/24"),[y,S]=w.useState({scanned:0,total:0});w.useEffect(()=>{Ml.getInfo().then(C=>{b(C.is_docker)}).catch(()=>{})},[]);const M=l.filter(C=>!n.includes(C.serial)),N=async()=>{d(""),c([]),o(!0),m(!1),S({scanned:0,total:0});try{if(p){await Ml.startSubnetScan(v);const C=setInterval(async()=>{try{const D=await Ml.getScanStatus();S({scanned:D.scanned,total:D.total});const T=await Ml.getDiscoveredPrinters();c(T),D.running||(clearInterval(C),o(!1),m(!0))}catch(D){console.error("Failed to get scan status:",D)}},500)}else{await Ml.startDiscovery(10);const C=setInterval(async()=>{try{const D=await Ml.getDiscoveredPrinters();c(D)}catch(D){console.error("Failed to get discovered printers:",D)}},1e3);setTimeout(async()=>{clearInterval(C);try{await Ml.stopDiscovery()}catch{}o(!1),m(!0);try{const D=await Ml.getDiscoveredPrinters();c(D)}catch(D){console.error("Failed to get final discovered printers:",D)}},1e4)}}catch(C){console.error("Failed to start discovery:",C),d(C instanceof Error?C.message:"Failed to start discovery"),o(!1),m(!0)}},A=C=>C?{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"}[C]||C:"",k=C=>{const D=C.serial.startsWith("unknown-")?"":C.serial;i({...r,name:C.name||"",serial_number:D,ip_address:C.ip_address,model:A(C.model)}),c([])};return w.useEffect(()=>()=>{Ml.stopDiscovery().catch(()=>{}),Ml.stopSubnetScan().catch(()=>{})},[]),w.useEffect(()=>{const C=D=>{D.key==="Escape"&&t()};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[t]),s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:t,children:s.jsx(Nt,{className:"w-full max-w-md",onClick:C=>C.stopPropagation(),children:s.jsxs(Ct,{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:v,onChange:C=>x(C.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(Me,{type:"button",variant:"secondary",onClick:N,disabled:a,className:"w-full",children:a?s.jsxs(s.Fragment,{children:[s.jsx(mt,{className:"w-4 h-4 animate-spin"}),p&&y.total>0?`Scanning... ${y.scanned}/${y.total}`:"Scanning..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Sa,{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}),M.length>0&&s.jsx("div",{className:"mt-3 space-y-2 max-h-40 overflow-y-auto",children:M.map(C=>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:()=>k(C),children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"font-medium text-white text-sm truncate",children:C.name||C.serial}),s.jsxs("p",{className:"text-xs text-bambu-gray truncate",children:[A(C.model)||"Unknown"," • ",C.ip_address,C.serial.startsWith("unknown-")&&s.jsx("span",{className:"text-yellow-500",children:" • Serial required"})]})]}),s.jsx(Oi,{className:"w-4 h-4 text-bambu-gray -rotate-90 flex-shrink-0 ml-2"})]},C.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&&M.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:C=>{C.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:C=>i({...r,name:C.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:C=>i({...r,ip_address:C.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:C=>i({...r,serial_number:C.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:C=>i({...r,access_code:C.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:C=>i({...r,model:C.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:C=>i({...r,auto_archive:C.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(Me,{type:"button",variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),s.jsx(Me,{type:"submit",className:"flex-1",children:"Add Printer"})]})]})]})})})}function WPe({printer:t,firmwareInfo:e,onClose:n}){const r=ln(),{showToast:i}=Yn(),[a,o]=w.useState(null),[l,c]=w.useState(!1),[u,d]=w.useState(null),{data:f,isLoading:m}=ft({queryKey:["firmwarePrepare",t.id],queryFn:()=>Q1.prepareUpload(t.id),staleTime:3e4}),p=pt({mutationFn:()=>Q1.startUpload(t.id),onSuccess:()=>{c(!0);const v=setInterval(async()=>{try{const x=await Q1.getUploadStatus(t.id);o(x),(x.status==="complete"||x.status==="error")&&(clearInterval(v),d(null),c(!1),x.status==="complete"&&(i("Firmware uploaded! Trigger update from printer screen.","success"),r.invalidateQueries({queryKey:["firmwareUpdate",t.id]})))}catch{}},2e3);d(v)},onError:v=>{i(`Failed to start upload: ${v.message}`,"error"),c(!1)}});w.useEffect(()=>()=>{u&&clearInterval(u)},[u]);const b=()=>{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(Nt,{className:"w-full max-w-md mx-4",children:s.jsxs(Ct,{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($r,{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})]})]}),m?s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-sm mb-4",children:[s.jsx(mt,{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(Bs,{className:"w-4 h-4"}),"SD card ready. Click below to upload firmware."]}):s.jsx("div",{className:"space-y-1",children:f.errors.map((v,x)=>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"}),v]},x))})}):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-status-error":a.status==="complete"?"bg-status-ok":"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(Me,{variant:"secondary",onClick:n,children:a?.status==="complete"?"Done":"Cancel"}),f?.can_proceed&&!l&&a?.status!=="complete"&&s.jsx(Me,{onClick:b,disabled:p.isPending,children:p.isPending?s.jsxs(s.Fragment,{children:[s.jsx(mt,{className:"w-4 h-4 animate-spin mr-2"}),"Starting..."]}):s.jsxs(s.Fragment,{children:[s.jsx($r,{className:"w-4 h-4 mr-2"}),"Upload Firmware"]})})]})]})})})}function qPe({printer:t,onClose:e}){const n=ln(),[r,i]=w.useState({name:t.name,ip_address:t.ip_address,access_code:"",model:t.model||"",location:t.location||"",auto_archive:t.auto_archive}),a=pt({mutationFn:l=>me.updatePrinter(t.id,l),onSuccess:()=>{n.invalidateQueries({queryKey:["printers"]}),n.invalidateQueries({queryKey:["printerStatus",t.id]}),e()}});w.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(Nt,{className:"w-full max-w-md",onClick:l=>l.stopPropagation(),children:s.jsxs(Ct,{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(Me,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsx(Me,{type:"submit",className:"flex-1",disabled:a.isPending,children:a.isPending?"Saving...":"Save Changes"})]})]})]})})})}function KPe(t){const{data:e}=ft({queryKey:["printerStatus",t],queryFn:()=>me.getPrinterStatus(t),refetchInterval:3e4});return!e?.connected}function XPe({printer:t,plug:e,onPowerOn:n,isPowering:r}){const i=KPe(t.id),{data:a}=ft({queryKey:["smartPlugStatus",e.id],queryFn:()=>me.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(wu,{className:"w-3 h-3"}),r?"...":"On"]})]}):null}function YPe(){const[t,e]=w.useState(!1),[n,r]=w.useState(()=>localStorage.getItem("hideDisconnectedPrinters")==="true"),[i,a]=w.useState(!1),[o,l]=w.useState(null),[c,u]=w.useState(()=>localStorage.getItem("printerSortBy")||"name"),[d,f]=w.useState(()=>localStorage.getItem("printerSortAsc")!=="false"),[m,p]=w.useState(()=>{const H=localStorage.getItem("printerCardSize");return H?parseInt(H,10):2}),b=m===1?"compact":"expanded",v=ln(),[x,y]=w.useState(()=>{const H=localStorage.getItem("openEmbeddedCameras");if(H)try{const Z=JSON.parse(H);return new Map(Z.map(ee=>[ee.id,ee]))}catch{return new Map}return new Map});w.useEffect(()=>{const H=Array.from(x.values());H.length>0?localStorage.setItem("openEmbeddedCameras",JSON.stringify(H)):localStorage.removeItem("openEmbeddedCameras")},[x]);const{data:S,isLoading:M}=ft({queryKey:["printers"],queryFn:me.getPrinters}),{data:N}=ft({queryKey:["settings"],queryFn:me.getSettings});w.useEffect(()=>{N?.camera_view_mode==="window"&&x.size>0&&y(new Map)},[N?.camera_view_mode,x.size]);const{data:A}=ft({queryKey:["smart-plugs"],queryFn:me.getSmartPlugs}),{data:k}=ft({queryKey:["maintenanceOverview"],queryFn:me.getMaintenanceOverview,staleTime:60*1e3}),{data:C}=ft({queryKey:["spoolman-status"],queryFn:me.getSpoolmanStatus,staleTime:60*1e3}),D=C?.enabled&&C?.connected,{data:T}=ft({queryKey:["unlinked-spools"],queryFn:me.getUnlinkedSpools,enabled:!!D,staleTime:30*1e3}),R=T&&T.length>0,U=k?.reduce((H,Z)=>(H[Z.printer_id]={due_count:Z.due_count,warning_count:Z.warning_count,total_print_hours:Z.total_print_hours},H),{})||{},L=A?.reduce((H,Z)=>(Z.printer_id&&(H[Z.printer_id]=Z),H),{})||{},q=pt({mutationFn:me.createPrinter,onSuccess:()=>{v.invalidateQueries({queryKey:["printers"]}),v.invalidateQueries({queryKey:["maintenanceOverview"]}),e(!1)}}),j=pt({mutationFn:H=>me.controlSmartPlug(H,"on"),onSuccess:()=>{v.invalidateQueries({queryKey:["smart-plugs"]}),l(null)},onError:()=>{l(null)}}),W=()=>{const H=!n;r(H),localStorage.setItem("hideDisconnectedPrinters",String(H))},K=H=>{u(H),localStorage.setItem("printerSortBy",H)},V=()=>{const H=!d;f(H),localStorage.setItem("printerSortAsc",String(H))},J=()=>{switch(m){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"}},ne=["S","M","L","XL"],te=w.useMemo(()=>{if(!S)return[];const H=[...S];switch(c){case"name":H.sort((Z,ee)=>Z.name.localeCompare(ee.name));break;case"model":H.sort((Z,ee)=>(Z.model||"").localeCompare(ee.model||""));break;case"location":H.sort((Z,ee)=>{const he=Z.location||"",fe=ee.location||"";return!he&&fe?1:he&&!fe?-1:he.localeCompare(fe)||Z.name.localeCompare(ee.name)});break;case"status":H.sort((Z,ee)=>{const he=v.getQueryData(["printerStatus",Z.id]),fe=v.getQueryData(["printerStatus",ee.id]),oe=Ne=>Ne?.connected?Ne.state==="RUNNING"?0:1:2;return oe(he)-oe(fe)});break}return d||H.reverse(),H},[S,c,d,v]),z=w.useMemo(()=>{if(c!=="location")return null;const H={};return te.forEach(Z=>{const ee=Z.location||"Ungrouped";H[ee]||(H[ee]=[]),H[ee].push(Z)}),H},[c,te]);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(VPe,{printers:S})]}),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:H=>K(H.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:V,className:"p-1.5 rounded-lg hover:bg-bambu-dark-tertiary transition-colors",title:d?"Sort descending":"Sort ascending",children:d?s.jsx(hg,{className:"w-4 h-4 text-bambu-gray"}):s.jsx(A0,{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:ne.map((H,Z)=>{const ee=Z+1,he=m===ee;return s.jsx("button",{onClick:()=>{p(ee),localStorage.setItem("printerCardSize",String(ee))},className:`px-2 py-1.5 text-xs font-medium transition-colors ${Z===0?"rounded-l-lg":""} ${Z===ne.length-1?"rounded-r-lg":""} ${he?"bg-bambu-green text-white":"text-bambu-gray hover:bg-bambu-dark-tertiary hover:text-white"}`,title:`${H==="S"?"Small":H==="M"?"Medium":H==="L"?"Large":"Extra large"} cards`,children:H},H)})}),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:W,className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Hide offline"]}),n&&Object.keys(L).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(wu,{className:"w-4 h-4"}),"Power On",s.jsx(Oi,{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"}),S?.filter(H=>L[H.id]).map(H=>s.jsx(XPe,{printer:H,plug:L[H.id],onPowerOn:Z=>{l(Z),j.mutate(Z)},isPowering:o===L[H.id]?.id},H.id)),S?.filter(H=>L[H.id]).length===0&&s.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No printers with smart plugs"})]})]})]}),s.jsxs(Me,{onClick:()=>e(!0),children:[s.jsx(rr,{className:"w-4 h-4"}),"Add Printer"]})]})]}),M?s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading printers..."}):S?.length===0?s.jsx(Nt,{children:s.jsxs(Ct,{className:"text-center py-12",children:[s.jsx("p",{className:"text-bambu-gray mb-4",children:"No printers configured yet"}),s.jsxs(Me,{onClick:()=>e(!0),children:[s.jsx(rr,{className:"w-4 h-4"}),"Add Your First Printer"]})]})}):z?s.jsx("div",{className:"space-y-6",children:Object.entries(z).map(([H,Z])=>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"}),H,s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",Z.length,")"]})]}),s.jsx("div",{className:`grid gap-4 ${m>=3?"gap-6":""} ${J()}`,children:Z.map(ee=>s.jsx(gV,{printer:ee,hideIfDisconnected:n,maintenanceInfo:U[ee.id],viewMode:b,cardSize:m,amsThresholds:N?{humidityGood:Number(N.ams_humidity_good)||40,humidityFair:Number(N.ams_humidity_fair)||60,tempGood:Number(N.ams_temp_good)||28,tempFair:Number(N.ams_temp_fair)||35}:void 0,spoolmanEnabled:D,hasUnlinkedSpools:R,timeFormat:N?.time_format||"system",cameraViewMode:N?.camera_view_mode||"window",onOpenEmbeddedCamera:(he,fe)=>y(oe=>new Map(oe).set(he,{id:he,name:fe}))},ee.id))})]},H))}):s.jsx("div",{className:`grid gap-4 ${m>=3?"gap-6":""} ${J()}`,children:te.map(H=>s.jsx(gV,{printer:H,hideIfDisconnected:n,maintenanceInfo:U[H.id],viewMode:b,cardSize:m,spoolmanEnabled:D,hasUnlinkedSpools:R,amsThresholds:N?{humidityGood:Number(N.ams_humidity_good)||40,humidityFair:Number(N.ams_humidity_fair)||60,tempGood:Number(N.ams_temp_good)||28,tempFair:Number(N.ams_temp_fair)||35}:void 0,timeFormat:N?.time_format||"system",cameraViewMode:N?.camera_view_mode||"window",onOpenEmbeddedCamera:(Z,ee)=>y(he=>new Map(he).set(Z,{id:Z,name:ee}))},H.id))}),t&&s.jsx(GPe,{onClose:()=>e(!1),onAdd:H=>q.mutate(H),existingSerials:S?.map(H=>H.serial_number)||[]}),Array.from(x.values()).map((H,Z)=>s.jsx(ape,{printerId:H.id,printerName:H.name,viewerIndex:Z,onClose:()=>y(ee=>{const he=new Map(ee);return he.delete(H.id),he})},H.id))]})}function ZPe(){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 QPe(){return ZPe()==="windows"?"bambustudio://":"bambustudioopen://"}function Kc(t){const e=QPe();window.location.href=`${e}${encodeURIComponent(t)}`}const K4="182",rg={ROTATE:0,DOLLY:1,PAN:2},Kp={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},JPe=0,xV=1,e3e=2,ow=1,t3e=2,Bb=3,Jd=0,_s=1,Il=2,au=0,ig=1,bV=2,yV=3,vV=4,n3e=5,Jh=100,r3e=101,i3e=102,a3e=103,s3e=104,o3e=200,l3e=201,c3e=202,u3e=203,E3=204,N3=205,d3e=206,h3e=207,f3e=208,m3e=209,p3e=210,g3e=211,x3e=212,b3e=213,y3e=214,A3=0,T3=1,C3=2,Ng=3,k3=4,j3=5,P3=6,R3=7,X4=0,v3e=1,_3e=2,ql=0,WJ=1,qJ=2,KJ=3,XJ=4,YJ=5,ZJ=6,QJ=7,JJ=300,Zf=301,Ag=302,D3=303,O3=304,lN=306,L3=1e3,Jc=1001,I3=1002,Ma=1003,w3e=1004,j_=1005,Ua=1006,qC=1007,mf=1008,Hs=1009,eee=1010,tee=1011,W0=1012,Y4=1013,rc=1014,$l=1015,yu=1016,Z4=1017,Q4=1018,q0=1020,nee=35902,ree=35899,iee=1021,aee=1022,el=1023,vu=1026,pf=1027,see=1028,J4=1029,Tg=1030,eL=1031,tL=1033,lw=33776,cw=33777,uw=33778,dw=33779,F3=35840,U3=35841,z3=35842,B3=35843,$3=36196,H3=37492,V3=37496,G3=37488,W3=37489,q3=37490,K3=37491,X3=37808,Y3=37809,Z3=37810,Q3=37811,J3=37812,eR=37813,tR=37814,nR=37815,rR=37816,iR=37817,aR=37818,sR=37819,oR=37820,lR=37821,cR=36492,uR=36494,dR=36495,hR=36283,fR=36284,mR=36285,pR=36286,S3e=3200,oee=0,M3e=1,Md="",vo="srgb",Cg="srgb-linear",US="linear",lr="srgb",Jm=7680,_V=519,E3e=512,N3e=513,A3e=514,nL=515,T3e=516,C3e=517,rL=518,k3e=519,wV=35044,SV="300 es",Hl=2e3,zS=2001;function lee(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function BS(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function j3e(){const t=BS("canvas");return t.style.display="block",t}const MV={};function EV(...t){const e="THREE."+t.shift();console.log(e,...t)}function un(...t){const e="THREE."+t.shift();console.warn(e,...t)}function Kn(...t){const e="THREE."+t.shift();console.error(e,...t)}function K0(...t){const e=t.join(" ");e in MV||(MV[e]=!0,un(...t))}function P3e(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 dm=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 ka=["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"],hw=Math.PI/180,gR=180/Math.PI;function Hy(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(ka[t&255]+ka[t>>8&255]+ka[t>>16&255]+ka[t>>24&255]+"-"+ka[e&255]+ka[e>>8&255]+"-"+ka[e>>16&15|64]+ka[e>>24&255]+"-"+ka[n&63|128]+ka[n>>8&255]+"-"+ka[n>>16&255]+ka[n>>24&255]+ka[r&255]+ka[r>>8&255]+ka[r>>16&255]+ka[r>>24&255]).toLowerCase()}function Pn(t,e,n){return Math.max(e,Math.min(n,t))}function R3e(t,e){return(t%e+e)%e}function KC(t,e,n){return(1-n)*t+n*e}function gb(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 fs(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 D3e={DEG2RAD:hw};let Mn=class cee{constructor(e=0,n=0){cee.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=Pn(this.x,e.x,n.x),this.y=Pn(this.y,e.y,n.y),this}clampScalar(e,n){return this.x=Pn(this.x,e,n),this.y=Pn(this.y,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Pn(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(Pn(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}},Qf=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],m=a[o+0],p=a[o+1],b=a[o+2],v=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]=m,e[n+1]=p,e[n+2]=b,e[n+3]=v;return}if(f!==v||c!==m||u!==p||d!==b){let x=c*m+u*p+d*b+f*v;x<0&&(m=-m,p=-p,b=-b,v=-v,x=-x);let y=1-l;if(x<.9995){const S=Math.acos(x),M=Math.sin(S);y=Math.sin(y*S)/M,l=Math.sin(l*S)/M,c=c*y+m*l,u=u*y+p*l,d=d*y+b*l,f=f*y+v*l}else{c=c*y+m*l,u=u*y+p*l,d=d*y+b*l,f=f*y+v*l;const S=1/Math.sqrt(c*c+u*u+d*d+f*f);c*=S,u*=S,d*=S,f*=S}}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],m=a[o+1],p=a[o+2],b=a[o+3];return e[n]=l*b+d*f+c*p-u*m,e[n+1]=c*b+d*m+u*f-l*p,e[n+2]=u*b+d*p+l*m-c*f,e[n+3]=d*b-l*f-c*m-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),m=c(r/2),p=c(i/2),b=c(a/2);switch(o){case"XYZ":this._x=m*d*f+u*p*b,this._y=u*p*f-m*d*b,this._z=u*d*b+m*p*f,this._w=u*d*f-m*p*b;break;case"YXZ":this._x=m*d*f+u*p*b,this._y=u*p*f-m*d*b,this._z=u*d*b-m*p*f,this._w=u*d*f+m*p*b;break;case"ZXY":this._x=m*d*f-u*p*b,this._y=u*p*f+m*d*b,this._z=u*d*b+m*p*f,this._w=u*d*f-m*p*b;break;case"ZYX":this._x=m*d*f-u*p*b,this._y=u*p*f+m*d*b,this._z=u*d*b-m*p*f,this._w=u*d*f+m*p*b;break;case"YZX":this._x=m*d*f+u*p*b,this._y=u*p*f+m*d*b,this._z=u*d*b-m*p*f,this._w=u*d*f-m*p*b;break;case"XZY":this._x=m*d*f-u*p*b,this._y=u*p*f-m*d*b,this._z=u*d*b+m*p*f,this._w=u*d*f+m*p*b;break;default:un("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],m=r+l+f;if(m>0){const p=.5/Math.sqrt(m+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(Pn(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}},nt=class uee{constructor(e=0,n=0,r=0){uee.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(NV.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(NV.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=Pn(this.x,e.x,n.x),this.y=Pn(this.y,e.y,n.y),this.z=Pn(this.z,e.z,n.z),this}clampScalar(e,n){return this.x=Pn(this.x,e,n),this.y=Pn(this.y,e,n),this.z=Pn(this.z,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Pn(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 XC.copy(this).projectOnVector(e),this.sub(XC)}reflect(e){return this.sub(XC.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(Pn(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 XC=new nt,NV=new Qf;let Nn=class dee{constructor(e,n,r,i,a,o,l,c,u){dee.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],m=r[2],p=r[5],b=r[8],v=i[0],x=i[3],y=i[6],S=i[1],M=i[4],N=i[7],A=i[2],k=i[5],C=i[8];return a[0]=o*v+l*S+c*A,a[3]=o*x+l*M+c*k,a[6]=o*y+l*N+c*C,a[1]=u*v+d*S+f*A,a[4]=u*x+d*M+f*k,a[7]=u*y+d*N+f*C,a[2]=m*v+p*S+b*A,a[5]=m*x+p*M+b*k,a[8]=m*y+p*N+b*C,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,m=l*c-d*a,p=u*a-o*c,b=n*f+r*m+i*p;if(b===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/b;return e[0]=f*v,e[1]=(i*u-d*r)*v,e[2]=(l*r-i*o)*v,e[3]=m*v,e[4]=(d*n-i*c)*v,e[5]=(i*a-l*n)*v,e[6]=p*v,e[7]=(r*c-u*n)*v,e[8]=(o*n-r*a)*v,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,i,a,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(YC.makeScale(e,n)),this}rotate(e){return this.premultiply(YC.makeRotation(-e)),this}translate(e,n){return this.premultiply(YC.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 YC=new Nn,AV=new Nn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),TV=new Nn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function O3e(){const t={enabled:!0,workingColorSpace:Cg,spaces:{},convert:function(i,a,o){return this.enabled===!1||a===o||!a||!o||(this.spaces[a].transfer===lr&&(i.r=su(i.r),i.g=su(i.g),i.b=su(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===lr&&(i.r=ag(i.r),i.g=ag(i.g),i.b=ag(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===Md?US: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 K0("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(i,a)},toWorkingColorSpace:function(i,a){return K0("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({[Cg]:{primaries:e,whitePoint:r,transfer:US,toXYZ:AV,fromXYZ:TV,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:vo},outputColorSpaceConfig:{drawingBufferColorSpace:vo}},[vo]:{primaries:e,whitePoint:r,transfer:lr,toXYZ:AV,fromXYZ:TV,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:vo}}}),t}const Vn=O3e();function su(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function ag(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let ep,L3e=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{ep===void 0&&(ep=BS("canvas")),ep.width=e.width,ep.height=e.height;const i=ep.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),r=ep}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=BS("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]=su(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(su(n[r]/255)*255):n[r]=su(n[r]);return{data:n,width:e.width,height:e.height}}else return un("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},I3e=0,iL=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:I3e++}),this.uuid=Hy(),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):typeof VideoFrame<"u"&&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(ZC(i[o].image)):a.push(ZC(i[o]))}else a=ZC(i);r.url=a}return n||(e.images[this.uuid]=r),r}};function ZC(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?L3e.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(un("Texture: Unable to serialize Texture."),{})}let F3e=0;const QC=new nt;let bl=class fw extends dm{constructor(e=fw.DEFAULT_IMAGE,n=fw.DEFAULT_MAPPING,r=Jc,i=Jc,a=Ua,o=mf,l=el,c=Hs,u=fw.DEFAULT_ANISOTROPY,d=Md){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:F3e++}),this.uuid=Hy(),this.name="",this.source=new iL(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 Mn(0,0),this.repeat=new Mn(1,1),this.center=new Mn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Nn,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(QC).x}get height(){return this.source.getSize(QC).y}get depth(){return this.source.getSize(QC).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){un(`Texture.setValues(): parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){un(`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!==JJ)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case L3:e.x=e.x-Math.floor(e.x);break;case Jc:e.x=e.x<0?0:1;break;case I3: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 L3:e.y=e.y-Math.floor(e.y);break;case Jc:e.y=e.y<0?0:1;break;case I3: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++}};bl.DEFAULT_IMAGE=null;bl.DEFAULT_MAPPING=JJ;bl.DEFAULT_ANISOTROPY=1;let Mi=class hee{constructor(e=0,n=0,r=0,i=1){hee.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],m=c[1],p=c[5],b=c[9],v=c[2],x=c[6],y=c[10];if(Math.abs(d-m)<.01&&Math.abs(f-v)<.01&&Math.abs(b-x)<.01){if(Math.abs(d+m)<.1&&Math.abs(f+v)<.1&&Math.abs(b+x)<.1&&Math.abs(u+p+y-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const M=(u+1)/2,N=(p+1)/2,A=(y+1)/2,k=(d+m)/4,C=(f+v)/4,D=(b+x)/4;return M>N&&M>A?M<.01?(r=0,i=.707106781,a=.707106781):(r=Math.sqrt(M),i=k/r,a=C/r):N>A?N<.01?(r=.707106781,i=0,a=.707106781):(i=Math.sqrt(N),r=k/i,a=D/i):A<.01?(r=.707106781,i=.707106781,a=0):(a=Math.sqrt(A),r=C/a,i=D/a),this.set(r,i,a,n),this}let S=Math.sqrt((x-b)*(x-b)+(f-v)*(f-v)+(m-d)*(m-d));return Math.abs(S)<.001&&(S=1),this.x=(x-b)/S,this.y=(f-v)/S,this.z=(m-d)/S,this.w=Math.acos((u+p+y-1)/2),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this.w=n[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,n){return this.x=Pn(this.x,e.x,n.x),this.y=Pn(this.y,e.y,n.y),this.z=Pn(this.z,e.z,n.z),this.w=Pn(this.w,e.w,n.w),this}clampScalar(e,n){return this.x=Pn(this.x,e,n),this.y=Pn(this.y,e,n),this.z=Pn(this.z,e,n),this.w=Pn(this.w,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Pn(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}},U3e=class extends dm{constructor(e=1,n=1,r={}){super(),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Ua,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 Mi(0,0,e,n),this.scissorTest=!1,this.viewport=new Mi(0,0,e,n);const i={width:e,height:n,depth:r.depth},a=new bl(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:Ua,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 iL(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"})}},Kl=class extends U3e{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}},fee=class extends bl{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=Ma,this.minFilter=Ma,this.wrapR=Jc,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},z3e=class extends bl{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=Ma,this.minFilter=Ma,this.wrapR=Jc,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Jf=class{constructor(e=new nt(1/0,1/0,1/0),n=new nt(-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($o.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint($o.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=$o.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,$o):$o.fromBufferAttribute(a,o),$o.applyMatrix4(e.matrixWorld),this.expandByPoint($o);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),P_.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),P_.copy(r.boundingBox)),P_.applyMatrix4(e.matrixWorld),this.union(P_)}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,$o),$o.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(xb),R_.subVectors(this.max,xb),tp.subVectors(e.a,xb),np.subVectors(e.b,xb),rp.subVectors(e.c,xb),Ju.subVectors(np,tp),ed.subVectors(rp,np),Lh.subVectors(tp,rp);let n=[0,-Ju.z,Ju.y,0,-ed.z,ed.y,0,-Lh.z,Lh.y,Ju.z,0,-Ju.x,ed.z,0,-ed.x,Lh.z,0,-Lh.x,-Ju.y,Ju.x,0,-ed.y,ed.x,0,-Lh.y,Lh.x,0];return!JC(n,tp,np,rp,R_)||(n=[1,0,0,0,1,0,0,0,1],!JC(n,tp,np,rp,R_))?!1:(D_.crossVectors(Ju,ed),n=[D_.x,D_.y,D_.z],JC(n,tp,np,rp,R_))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,$o).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize($o).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:(kc[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),kc[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),kc[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),kc[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),kc[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),kc[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),kc[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),kc[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(kc),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 kc=[new nt,new nt,new nt,new nt,new nt,new nt,new nt,new nt],$o=new nt,P_=new Jf,tp=new nt,np=new nt,rp=new nt,Ju=new nt,ed=new nt,Lh=new nt,xb=new nt,R_=new nt,D_=new nt,Ih=new nt;function JC(t,e,n,r,i){for(let a=0,o=t.length-3;a<=o;a+=3){Ih.fromArray(t,a);const l=i.x*Math.abs(Ih.x)+i.y*Math.abs(Ih.y)+i.z*Math.abs(Ih.z),c=e.dot(Ih),u=n.dot(Ih),d=r.dot(Ih);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>l)return!1}return!0}const B3e=new Jf,bb=new nt,ek=new nt;let cN=class{constructor(e=new nt,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):B3e.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;bb.subVectors(e,this.center);const n=bb.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(bb,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):(ek.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(bb.copy(e.center).add(ek)),this.expandByPoint(bb.copy(e.center).sub(ek))),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 jc=new nt,tk=new nt,O_=new nt,td=new nt,nk=new nt,L_=new nt,rk=new nt;let aL=class{constructor(e=new nt,n=new nt(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,jc)),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=jc.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(jc.copy(this.origin).addScaledVector(this.direction,n),jc.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){tk.copy(e).add(n).multiplyScalar(.5),O_.copy(n).sub(e).normalize(),td.copy(this.origin).sub(tk);const a=e.distanceTo(n)*.5,o=-this.direction.dot(O_),l=td.dot(this.direction),c=-td.dot(O_),u=td.lengthSq(),d=Math.abs(1-o*o);let f,m,p,b;if(d>0)if(f=o*c-l,m=o*l-c,b=a*d,f>=0)if(m>=-b)if(m<=b){const v=1/d;f*=v,m*=v,p=f*(f+o*m+2*l)+m*(o*f+m+2*c)+u}else m=a,f=Math.max(0,-(o*m+l)),p=-f*f+m*(m+2*c)+u;else m=-a,f=Math.max(0,-(o*m+l)),p=-f*f+m*(m+2*c)+u;else m<=-b?(f=Math.max(0,-(-o*a+l)),m=f>0?-a:Math.min(Math.max(-a,-c),a),p=-f*f+m*(m+2*c)+u):m<=b?(f=0,m=Math.min(Math.max(-a,-c),a),p=m*(m+2*c)+u):(f=Math.max(0,-(o*a+l)),m=f>0?a:Math.min(Math.max(-a,-c),a),p=-f*f+m*(m+2*c)+u);else m=o>0?-a:a,f=Math.max(0,-(o*m+l)),p=-f*f+m*(m+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(tk).addScaledVector(O_,m),p}intersectSphere(e,n){jc.subVectors(e.center,this.origin);const r=jc.dot(this.direction),i=jc.dot(jc)-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,m=this.origin;return u>=0?(r=(e.min.x-m.x)*u,i=(e.max.x-m.x)*u):(r=(e.max.x-m.x)*u,i=(e.min.x-m.x)*u),d>=0?(a=(e.min.y-m.y)*d,o=(e.max.y-m.y)*d):(a=(e.max.y-m.y)*d,o=(e.min.y-m.y)*d),r>o||a>i||((a>r||isNaN(r))&&(r=a),(o<i||isNaN(i))&&(i=o),f>=0?(l=(e.min.z-m.z)*f,c=(e.max.z-m.z)*f):(l=(e.max.z-m.z)*f,c=(e.min.z-m.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,jc)!==null}intersectTriangle(e,n,r,i,a){nk.subVectors(n,e),L_.subVectors(r,e),rk.crossVectors(nk,L_);let o=this.direction.dot(rk),l;if(o>0){if(i)return null;l=1}else if(o<0)l=-1,o=-o;else return null;td.subVectors(this.origin,e);const c=l*this.direction.dot(L_.crossVectors(td,L_));if(c<0)return null;const u=l*this.direction.dot(nk.cross(td));if(u<0||c+u>o)return null;const d=-l*td.dot(rk);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)}},mi=class xR{constructor(e,n,r,i,a,o,l,c,u,d,f,m,p,b,v,x){xR.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,m,p,b,v,x)}set(e,n,r,i,a,o,l,c,u,d,f,m,p,b,v,x){const y=this.elements;return y[0]=e,y[4]=n,y[8]=r,y[12]=i,y[1]=a,y[5]=o,y[9]=l,y[13]=c,y[2]=u,y[6]=d,y[10]=f,y[14]=m,y[3]=p,y[7]=b,y[11]=v,y[15]=x,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new xR().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 this.determinant()===0?(e.set(1,0,0),n.set(0,1,0),r.set(0,0,1),this):(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){if(e.determinant()===0)return this.identity();const n=this.elements,r=e.elements,i=1/ip.setFromMatrixColumn(e,0).length(),a=1/ip.setFromMatrixColumn(e,1).length(),o=1/ip.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 m=o*d,p=o*f,b=l*d,v=l*f;n[0]=c*d,n[4]=-c*f,n[8]=u,n[1]=p+b*u,n[5]=m-v*u,n[9]=-l*c,n[2]=v-m*u,n[6]=b+p*u,n[10]=o*c}else if(e.order==="YXZ"){const m=c*d,p=c*f,b=u*d,v=u*f;n[0]=m+v*l,n[4]=b*l-p,n[8]=o*u,n[1]=o*f,n[5]=o*d,n[9]=-l,n[2]=p*l-b,n[6]=v+m*l,n[10]=o*c}else if(e.order==="ZXY"){const m=c*d,p=c*f,b=u*d,v=u*f;n[0]=m-v*l,n[4]=-o*f,n[8]=b+p*l,n[1]=p+b*l,n[5]=o*d,n[9]=v-m*l,n[2]=-o*u,n[6]=l,n[10]=o*c}else if(e.order==="ZYX"){const m=o*d,p=o*f,b=l*d,v=l*f;n[0]=c*d,n[4]=b*u-p,n[8]=m*u+v,n[1]=c*f,n[5]=v*u+m,n[9]=p*u-b,n[2]=-u,n[6]=l*c,n[10]=o*c}else if(e.order==="YZX"){const m=o*c,p=o*u,b=l*c,v=l*u;n[0]=c*d,n[4]=v-m*f,n[8]=b*f+p,n[1]=f,n[5]=o*d,n[9]=-l*d,n[2]=-u*d,n[6]=p*f+b,n[10]=m-v*f}else if(e.order==="XZY"){const m=o*c,p=o*u,b=l*c,v=l*u;n[0]=c*d,n[4]=-f,n[8]=u*d,n[1]=m*f+v,n[5]=o*d,n[9]=p*f-b,n[2]=b*f-p,n[6]=l*d,n[10]=v*f+m}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($3e,e,H3e)}lookAt(e,n,r){const i=this.elements;return Ls.subVectors(e,n),Ls.lengthSq()===0&&(Ls.z=1),Ls.normalize(),nd.crossVectors(r,Ls),nd.lengthSq()===0&&(Math.abs(r.z)===1?Ls.x+=1e-4:Ls.z+=1e-4,Ls.normalize(),nd.crossVectors(r,Ls)),nd.normalize(),I_.crossVectors(Ls,nd),i[0]=nd.x,i[4]=I_.x,i[8]=Ls.x,i[1]=nd.y,i[5]=I_.y,i[9]=Ls.y,i[2]=nd.z,i[6]=I_.z,i[10]=Ls.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],m=r[9],p=r[13],b=r[2],v=r[6],x=r[10],y=r[14],S=r[3],M=r[7],N=r[11],A=r[15],k=i[0],C=i[4],D=i[8],T=i[12],R=i[1],U=i[5],L=i[9],q=i[13],j=i[2],W=i[6],K=i[10],V=i[14],J=i[3],ne=i[7],te=i[11],z=i[15];return a[0]=o*k+l*R+c*j+u*J,a[4]=o*C+l*U+c*W+u*ne,a[8]=o*D+l*L+c*K+u*te,a[12]=o*T+l*q+c*V+u*z,a[1]=d*k+f*R+m*j+p*J,a[5]=d*C+f*U+m*W+p*ne,a[9]=d*D+f*L+m*K+p*te,a[13]=d*T+f*q+m*V+p*z,a[2]=b*k+v*R+x*j+y*J,a[6]=b*C+v*U+x*W+y*ne,a[10]=b*D+v*L+x*K+y*te,a[14]=b*T+v*q+x*V+y*z,a[3]=S*k+M*R+N*j+A*J,a[7]=S*C+M*U+N*W+A*ne,a[11]=S*D+M*L+N*K+A*te,a[15]=S*T+M*q+N*V+A*z,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[4],i=e[8],a=e[12],o=e[1],l=e[5],c=e[9],u=e[13],d=e[2],f=e[6],m=e[10],p=e[14],b=e[3],v=e[7],x=e[11],y=e[15],S=c*p-u*m,M=l*p-u*f,N=l*m-c*f,A=o*p-u*d,k=o*m-c*d,C=o*f-l*d;return n*(v*S-x*M+y*N)-r*(b*S-x*A+y*k)+i*(b*M-v*A+y*C)-a*(b*N-v*k+x*C)}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],m=e[10],p=e[11],b=e[12],v=e[13],x=e[14],y=e[15],S=f*x*u-v*m*u+v*c*p-l*x*p-f*c*y+l*m*y,M=b*m*u-d*x*u-b*c*p+o*x*p+d*c*y-o*m*y,N=d*v*u-b*f*u+b*l*p-o*v*p-d*l*y+o*f*y,A=b*f*c-d*v*c-b*l*m+o*v*m+d*l*x-o*f*x,k=n*S+r*M+i*N+a*A;if(k===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const C=1/k;return e[0]=S*C,e[1]=(v*m*a-f*x*a-v*i*p+r*x*p+f*i*y-r*m*y)*C,e[2]=(l*x*a-v*c*a+v*i*u-r*x*u-l*i*y+r*c*y)*C,e[3]=(f*c*a-l*m*a-f*i*u+r*m*u+l*i*p-r*c*p)*C,e[4]=M*C,e[5]=(d*x*a-b*m*a+b*i*p-n*x*p-d*i*y+n*m*y)*C,e[6]=(b*c*a-o*x*a-b*i*u+n*x*u+o*i*y-n*c*y)*C,e[7]=(o*m*a-d*c*a+d*i*u-n*m*u-o*i*p+n*c*p)*C,e[8]=N*C,e[9]=(b*f*a-d*v*a-b*r*p+n*v*p+d*r*y-n*f*y)*C,e[10]=(o*v*a-b*l*a+b*r*u-n*v*u-o*r*y+n*l*y)*C,e[11]=(d*l*a-o*f*a-d*r*u+n*f*u+o*r*p-n*l*p)*C,e[12]=A*C,e[13]=(d*v*i-b*f*i+b*r*m-n*v*m-d*r*x+n*f*x)*C,e[14]=(b*l*i-o*v*i-b*r*c+n*v*c+o*r*x-n*l*x)*C,e[15]=(o*f*i-d*l*i+d*r*c-n*f*c-o*r*m+n*l*m)*C,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,m=a*u,p=a*d,b=a*f,v=o*d,x=o*f,y=l*f,S=c*u,M=c*d,N=c*f,A=r.x,k=r.y,C=r.z;return i[0]=(1-(v+y))*A,i[1]=(p+N)*A,i[2]=(b-M)*A,i[3]=0,i[4]=(p-N)*k,i[5]=(1-(m+y))*k,i[6]=(x+S)*k,i[7]=0,i[8]=(b+M)*C,i[9]=(x-S)*C,i[10]=(1-(m+v))*C,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;if(e.x=i[12],e.y=i[13],e.z=i[14],this.determinant()===0)return r.set(1,1,1),n.identity(),this;let a=ip.set(i[0],i[1],i[2]).length();const o=ip.set(i[4],i[5],i[6]).length(),l=ip.set(i[8],i[9],i[10]).length();this.determinant()<0&&(a=-a),Ho.copy(this);const u=1/a,d=1/o,f=1/l;return Ho.elements[0]*=u,Ho.elements[1]*=u,Ho.elements[2]*=u,Ho.elements[4]*=d,Ho.elements[5]*=d,Ho.elements[6]*=d,Ho.elements[8]*=f,Ho.elements[9]*=f,Ho.elements[10]*=f,n.setFromRotationMatrix(Ho),r.x=a,r.y=o,r.z=l,this}makePerspective(e,n,r,i,a,o,l=Hl,c=!1){const u=this.elements,d=2*a/(n-e),f=2*a/(r-i),m=(n+e)/(n-e),p=(r+i)/(r-i);let b,v;if(c)b=a/(o-a),v=o*a/(o-a);else if(l===Hl)b=-(o+a)/(o-a),v=-2*o*a/(o-a);else if(l===zS)b=-o/(o-a),v=-o*a/(o-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+l);return u[0]=d,u[4]=0,u[8]=m,u[12]=0,u[1]=0,u[5]=f,u[9]=p,u[13]=0,u[2]=0,u[6]=0,u[10]=b,u[14]=v,u[3]=0,u[7]=0,u[11]=-1,u[15]=0,this}makeOrthographic(e,n,r,i,a,o,l=Hl,c=!1){const u=this.elements,d=2/(n-e),f=2/(r-i),m=-(n+e)/(n-e),p=-(r+i)/(r-i);let b,v;if(c)b=1/(o-a),v=o/(o-a);else if(l===Hl)b=-2/(o-a),v=-(o+a)/(o-a);else if(l===zS)b=-1/(o-a),v=-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]=m,u[1]=0,u[5]=f,u[9]=0,u[13]=p,u[2]=0,u[6]=0,u[10]=b,u[14]=v,u[3]=0,u[7]=0,u[11]=0,u[15]=1,this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<16;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<16;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e[n+9]=r[9],e[n+10]=r[10],e[n+11]=r[11],e[n+12]=r[12],e[n+13]=r[13],e[n+14]=r[14],e[n+15]=r[15],e}};const ip=new nt,Ho=new mi,$3e=new nt(0,0,0),H3e=new nt(1,1,1),nd=new nt,I_=new nt,Ls=new nt,CV=new mi,kV=new Qf;let eh=class mee{constructor(e=0,n=0,r=0,i=mee.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],m=i[6],p=i[10];switch(n){case"XYZ":this._y=Math.asin(Pn(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,p),this._z=Math.atan2(-o,a)):(this._x=Math.atan2(m,u),this._z=0);break;case"YXZ":this._x=Math.asin(-Pn(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(Pn(m,-1,1)),Math.abs(m)<.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(-Pn(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(m,p),this._z=Math.atan2(c,a)):(this._x=0,this._z=Math.atan2(-o,u));break;case"YZX":this._z=Math.asin(Pn(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(-Pn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(m,u),this._y=Math.atan2(l,a)):(this._x=Math.atan2(-d,p),this._y=0);break;default:un("Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return CV.makeRotationFromQuaternion(e),this.setFromRotationMatrix(CV,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return kV.setFromEuler(this),this.setFromQuaternion(kV,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}};eh.DEFAULT_ORDER="XYZ";let pee=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}},V3e=0;const jV=new nt,ap=new Qf,Pc=new mi,F_=new nt,yb=new nt,G3e=new nt,W3e=new Qf,PV=new nt(1,0,0),RV=new nt(0,1,0),DV=new nt(0,0,1),OV={type:"added"},q3e={type:"removed"},sp={type:"childadded",child:null},ik={type:"childremoved",child:null};let Js=class mw extends dm{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:V3e++}),this.uuid=Hy(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=mw.DEFAULT_UP.clone();const e=new nt,n=new eh,r=new Qf,i=new nt(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 mi},normalMatrix:{value:new Nn}}),this.matrix=new mi,this.matrixWorld=new mi,this.matrixAutoUpdate=mw.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=mw.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new pee,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 ap.setFromAxisAngle(e,n),this.quaternion.multiply(ap),this}rotateOnWorldAxis(e,n){return ap.setFromAxisAngle(e,n),this.quaternion.premultiply(ap),this}rotateX(e){return this.rotateOnAxis(PV,e)}rotateY(e){return this.rotateOnAxis(RV,e)}rotateZ(e){return this.rotateOnAxis(DV,e)}translateOnAxis(e,n){return jV.copy(e).applyQuaternion(this.quaternion),this.position.add(jV.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(PV,e)}translateY(e){return this.translateOnAxis(RV,e)}translateZ(e){return this.translateOnAxis(DV,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Pc.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?F_.copy(e):F_.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),yb.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Pc.lookAt(yb,F_,this.up):Pc.lookAt(F_,yb,this.up),this.quaternion.setFromRotationMatrix(Pc),i&&(Pc.extractRotation(i.matrixWorld),ap.setFromRotationMatrix(Pc),this.quaternion.premultiply(ap.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(Kn("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(OV),sp.child=e,this.dispatchEvent(sp),sp.child=null):Kn("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(q3e),ik.child=e,this.dispatchEvent(ik),ik.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),Pc.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Pc.multiply(e.parent.matrixWorld)),e.applyMatrix4(Pc),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(OV),sp.child=e,this.dispatchEvent(sp),sp.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(yb,e,G3e),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(yb,W3e,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),m=o(e.skeletons),p=o(e.animations),b=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),m.length>0&&(r.skeletons=m),p.length>0&&(r.animations=p),b.length>0&&(r.nodes=b)}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}};Js.DEFAULT_UP=new nt(0,1,0);Js.DEFAULT_MATRIX_AUTO_UPDATE=!0;Js.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Vo=new nt,Rc=new nt,ak=new nt,Dc=new nt,op=new nt,lp=new nt,LV=new nt,sk=new nt,ok=new nt,lk=new nt,ck=new Mi,uk=new Mi,dk=new Mi;let vb=class zp{constructor(e=new nt,n=new nt,r=new nt){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),Vo.subVectors(e,n),i.cross(Vo);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){Vo.subVectors(i,n),Rc.subVectors(r,n),ak.subVectors(e,n);const o=Vo.dot(Vo),l=Vo.dot(Rc),c=Vo.dot(ak),u=Rc.dot(Rc),d=Rc.dot(ak),f=o*u-l*l;if(f===0)return a.set(0,0,0),null;const m=1/f,p=(u*c-l*d)*m,b=(o*d-l*c)*m;return a.set(1-p-b,b,p)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,Dc)===null?!1:Dc.x>=0&&Dc.y>=0&&Dc.x+Dc.y<=1}static getInterpolation(e,n,r,i,a,o,l,c){return this.getBarycoord(e,n,r,i,Dc)===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,Dc.x),c.addScaledVector(o,Dc.y),c.addScaledVector(l,Dc.z),c)}static getInterpolatedAttribute(e,n,r,i,a,o){return ck.setScalar(0),uk.setScalar(0),dk.setScalar(0),ck.fromBufferAttribute(e,n),uk.fromBufferAttribute(e,r),dk.fromBufferAttribute(e,i),o.setScalar(0),o.addScaledVector(ck,a.x),o.addScaledVector(uk,a.y),o.addScaledVector(dk,a.z),o}static isFrontFacing(e,n,r,i){return Vo.subVectors(r,n),Rc.subVectors(e,n),Vo.cross(Rc).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 Vo.subVectors(this.c,this.b),Rc.subVectors(this.a,this.b),Vo.cross(Rc).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return zp.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return zp.getBarycoord(e,this.a,this.b,this.c,n)}getInterpolation(e,n,r,i,a){return zp.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}containsPoint(e){return zp.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return zp.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;op.subVectors(i,r),lp.subVectors(a,r),sk.subVectors(e,r);const c=op.dot(sk),u=lp.dot(sk);if(c<=0&&u<=0)return n.copy(r);ok.subVectors(e,i);const d=op.dot(ok),f=lp.dot(ok);if(d>=0&&f<=d)return n.copy(i);const m=c*f-d*u;if(m<=0&&c>=0&&d<=0)return o=c/(c-d),n.copy(r).addScaledVector(op,o);lk.subVectors(e,a);const p=op.dot(lk),b=lp.dot(lk);if(b>=0&&p<=b)return n.copy(a);const v=p*u-c*b;if(v<=0&&u>=0&&b<=0)return l=u/(u-b),n.copy(r).addScaledVector(lp,l);const x=d*b-p*f;if(x<=0&&f-d>=0&&p-b>=0)return LV.subVectors(a,i),l=(f-d)/(f-d+(p-b)),n.copy(i).addScaledVector(LV,l);const y=1/(x+v+m);return o=v*y,l=m*y,n.copy(r).addScaledVector(op,o).addScaledVector(lp,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};const gee={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},rd={h:0,s:0,l:0},U_={h:0,s:0,l:0};function hk(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 Rn=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=vo){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Vn.colorSpaceToWorking(this,n),this}setRGB(e,n,r,i=Vn.workingColorSpace){return this.r=e,this.g=n,this.b=r,Vn.colorSpaceToWorking(this,i),this}setHSL(e,n,r,i=Vn.workingColorSpace){if(e=R3e(e,1),n=Pn(n,0,1),r=Pn(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=hk(o,a,e+1/3),this.g=hk(o,a,e),this.b=hk(o,a,e-1/3)}return Vn.colorSpaceToWorking(this,i),this}setStyle(e,n=vo){function r(a){a!==void 0&&parseFloat(a)<1&&un("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:un("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);un("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=vo){const r=gee[e.toLowerCase()];return r!==void 0?this.setHex(r,n):un("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=su(e.r),this.g=su(e.g),this.b=su(e.b),this}copyLinearToSRGB(e){return this.r=ag(e.r),this.g=ag(e.g),this.b=ag(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=vo){return Vn.workingToColorSpace(ja.copy(this),e),Math.round(Pn(ja.r*255,0,255))*65536+Math.round(Pn(ja.g*255,0,255))*256+Math.round(Pn(ja.b*255,0,255))}getHexString(e=vo){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=Vn.workingColorSpace){Vn.workingToColorSpace(ja.copy(this),n);const r=ja.r,i=ja.g,a=ja.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=Vn.workingColorSpace){return Vn.workingToColorSpace(ja.copy(this),n),e.r=ja.r,e.g=ja.g,e.b=ja.b,e}getStyle(e=vo){Vn.workingToColorSpace(ja.copy(this),e);const n=ja.r,r=ja.g,i=ja.b;return e!==vo?`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(rd),this.setHSL(rd.h+e,rd.s+n,rd.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(rd),e.getHSL(U_);const r=KC(rd.h,U_.h,n),i=KC(rd.s,U_.s,n),a=KC(rd.l,U_.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 ja=new Rn;Rn.NAMES=gee;let K3e=0,lx=class extends dm{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:K3e++}),this.uuid=Hy(),this.name="",this.type="Material",this.blending=ig,this.side=Jd,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=E3,this.blendDst=N3,this.blendEquation=Jh,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Rn(0,0,0),this.blendAlpha=0,this.depthFunc=Ng,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=_V,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Jm,this.stencilZFail=Jm,this.stencilZPass=Jm,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){un(`Material: parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){un(`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!==ig&&(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!==E3&&(r.blendSrc=this.blendSrc),this.blendDst!==N3&&(r.blendDst=this.blendDst),this.blendEquation!==Jh&&(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!==Ng&&(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!==_V&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Jm&&(r.stencilFail=this.stencilFail),this.stencilZFail!==Jm&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==Jm&&(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.allowOverride===!1&&(r.allowOverride=!1),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.allowOverride=e.allowOverride,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++}},sL=class extends lx{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Rn(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 eh,this.combine=X4,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 _i=new nt,z_=new Mn;let X3e=0,Co=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:X3e++}),this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=r,this.usage=wV,this.updateRanges=[],this.gpuType=$l,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++)z_.fromBufferAttribute(this,n),z_.applyMatrix3(e),this.setXY(n,z_.x,z_.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)_i.fromBufferAttribute(this,n),_i.applyMatrix3(e),this.setXYZ(n,_i.x,_i.y,_i.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)_i.fromBufferAttribute(this,n),_i.applyMatrix4(e),this.setXYZ(n,_i.x,_i.y,_i.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)_i.fromBufferAttribute(this,n),_i.applyNormalMatrix(e),this.setXYZ(n,_i.x,_i.y,_i.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)_i.fromBufferAttribute(this,n),_i.transformDirection(e),this.setXYZ(n,_i.x,_i.y,_i.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=gb(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=fs(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=gb(n,this.array)),n}setX(e,n){return this.normalized&&(n=fs(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=gb(n,this.array)),n}setY(e,n){return this.normalized&&(n=fs(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=gb(n,this.array)),n}setZ(e,n){return this.normalized&&(n=fs(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=gb(n,this.array)),n}setW(e,n){return this.normalized&&(n=fs(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=fs(n,this.array),r=fs(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=fs(n,this.array),r=fs(r,this.array),i=fs(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=fs(n,this.array),r=fs(r,this.array),i=fs(i,this.array),a=fs(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!==wV&&(e.usage=this.usage),e}},xee=class extends Co{constructor(e,n,r){super(new Uint16Array(e),n,r)}},bee=class extends Co{constructor(e,n,r){super(new Uint32Array(e),n,r)}},Ks=class extends Co{constructor(e,n,r){super(new Float32Array(e),n,r)}},Y3e=0;const fo=new mi,fk=new Js,cp=new nt,Is=new Jf,_b=new Jf,Wi=new nt;let yl=class yee extends dm{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Y3e++}),this.uuid=Hy(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,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(lee(e)?bee:xee)(e,1):this.index=e,this}setIndirect(e,n=0){return this.indirect=e,this.indirectOffset=n,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 Nn().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 fo.makeRotationFromQuaternion(e),this.applyMatrix4(fo),this}rotateX(e){return fo.makeRotationX(e),this.applyMatrix4(fo),this}rotateY(e){return fo.makeRotationY(e),this.applyMatrix4(fo),this}rotateZ(e){return fo.makeRotationZ(e),this.applyMatrix4(fo),this}translate(e,n,r){return fo.makeTranslation(e,n,r),this.applyMatrix4(fo),this}scale(e,n,r){return fo.makeScale(e,n,r),this.applyMatrix4(fo),this}lookAt(e){return fk.lookAt(e),fk.updateMatrix(),this.applyMatrix4(fk.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(cp).negate(),this.translate(cp.x,cp.y,cp.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 Ks(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&&un("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 Jf);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Kn("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new nt(-1/0,-1/0,-1/0),new nt(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];Is.setFromBufferAttribute(a),this.morphTargetsRelative?(Wi.addVectors(this.boundingBox.min,Is.min),this.boundingBox.expandByPoint(Wi),Wi.addVectors(this.boundingBox.max,Is.max),this.boundingBox.expandByPoint(Wi)):(this.boundingBox.expandByPoint(Is.min),this.boundingBox.expandByPoint(Is.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Kn('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 cN);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Kn("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new nt,1/0);return}if(e){const r=this.boundingSphere.center;if(Is.setFromBufferAttribute(e),n)for(let a=0,o=n.length;a<o;a++){const l=n[a];_b.setFromBufferAttribute(l),this.morphTargetsRelative?(Wi.addVectors(Is.min,_b.min),Is.expandByPoint(Wi),Wi.addVectors(Is.max,_b.max),Is.expandByPoint(Wi)):(Is.expandByPoint(_b.min),Is.expandByPoint(_b.max))}Is.getCenter(r);let i=0;for(let a=0,o=e.count;a<o;a++)Wi.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(Wi));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++)Wi.fromBufferAttribute(l,u),c&&(cp.fromBufferAttribute(e,u),Wi.add(cp)),i=Math.max(i,r.distanceToSquared(Wi))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&Kn('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){Kn("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 Co(new Float32Array(4*r.count),4));const o=this.getAttribute("tangent"),l=[],c=[];for(let D=0;D<r.count;D++)l[D]=new nt,c[D]=new nt;const u=new nt,d=new nt,f=new nt,m=new Mn,p=new Mn,b=new Mn,v=new nt,x=new nt;function y(D,T,R){u.fromBufferAttribute(r,D),d.fromBufferAttribute(r,T),f.fromBufferAttribute(r,R),m.fromBufferAttribute(a,D),p.fromBufferAttribute(a,T),b.fromBufferAttribute(a,R),d.sub(u),f.sub(u),p.sub(m),b.sub(m);const U=1/(p.x*b.y-b.x*p.y);isFinite(U)&&(v.copy(d).multiplyScalar(b.y).addScaledVector(f,-p.y).multiplyScalar(U),x.copy(f).multiplyScalar(p.x).addScaledVector(d,-b.x).multiplyScalar(U),l[D].add(v),l[T].add(v),l[R].add(v),c[D].add(x),c[T].add(x),c[R].add(x))}let S=this.groups;S.length===0&&(S=[{start:0,count:e.count}]);for(let D=0,T=S.length;D<T;++D){const R=S[D],U=R.start,L=R.count;for(let q=U,j=U+L;q<j;q+=3)y(e.getX(q+0),e.getX(q+1),e.getX(q+2))}const M=new nt,N=new nt,A=new nt,k=new nt;function C(D){A.fromBufferAttribute(i,D),k.copy(A);const T=l[D];M.copy(T),M.sub(A.multiplyScalar(A.dot(T))).normalize(),N.crossVectors(k,T);const U=N.dot(c[D])<0?-1:1;o.setXYZW(D,M.x,M.y,M.z,U)}for(let D=0,T=S.length;D<T;++D){const R=S[D],U=R.start,L=R.count;for(let q=U,j=U+L;q<j;q+=3)C(e.getX(q+0)),C(e.getX(q+1)),C(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 Co(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let m=0,p=r.count;m<p;m++)r.setXYZ(m,0,0,0);const i=new nt,a=new nt,o=new nt,l=new nt,c=new nt,u=new nt,d=new nt,f=new nt;if(e)for(let m=0,p=e.count;m<p;m+=3){const b=e.getX(m+0),v=e.getX(m+1),x=e.getX(m+2);i.fromBufferAttribute(n,b),a.fromBufferAttribute(n,v),o.fromBufferAttribute(n,x),d.subVectors(o,a),f.subVectors(i,a),d.cross(f),l.fromBufferAttribute(r,b),c.fromBufferAttribute(r,v),u.fromBufferAttribute(r,x),l.add(d),c.add(d),u.add(d),r.setXYZ(b,l.x,l.y,l.z),r.setXYZ(v,c.x,c.y,c.z),r.setXYZ(x,u.x,u.y,u.z)}else for(let m=0,p=n.count;m<p;m+=3)i.fromBufferAttribute(n,m+0),a.fromBufferAttribute(n,m+1),o.fromBufferAttribute(n,m+2),d.subVectors(o,a),f.subVectors(i,a),d.cross(f),r.setXYZ(m+0,d.x,d.y,d.z),r.setXYZ(m+1,d.x,d.y,d.z),r.setXYZ(m+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++)Wi.fromBufferAttribute(e,n),Wi.normalize(),e.setXYZ(n,Wi.x,Wi.y,Wi.z)}toNonIndexed(){function e(l,c){const u=l.array,d=l.itemSize,f=l.normalized,m=new u.constructor(c.length*d);let p=0,b=0;for(let v=0,x=c.length;v<x;v++){l.isInterleavedBufferAttribute?p=c[v]*l.data.stride+l.offset:p=c[v]*d;for(let y=0;y<d;y++)m[b++]=u[p++]}return new Co(m,d,f)}if(this.index===null)return un("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new yee,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 m=u[d],p=e(m,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,m=u.length;f<m;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 m=0,p=f.length;m<p;m++)d.push(f[m].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 IV=new mi,Fh=new aL,B_=new cN,FV=new nt,$_=new nt,H_=new nt,V_=new nt,mk=new nt,G_=new nt,UV=new nt,W_=new nt;let hl=class extends Js{constructor(e=new yl,n=new sL){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){G_.set(0,0,0);for(let c=0,u=a.length;c<u;c++){const d=l[c],f=a[c];d!==0&&(mk.fromBufferAttribute(f,e),o?G_.addScaledVector(mk,d):G_.addScaledVector(mk.sub(n),d))}n.add(G_)}return n}raycast(e,n){const r=this.geometry,i=this.material,a=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),B_.copy(r.boundingSphere),B_.applyMatrix4(a),Fh.copy(e.ray).recast(e.near),!(B_.containsPoint(Fh.origin)===!1&&(Fh.intersectSphere(B_,FV)===null||Fh.origin.distanceToSquared(FV)>(e.far-e.near)**2))&&(IV.copy(a).invert(),Fh.copy(e.ray).applyMatrix4(IV),!(r.boundingBox!==null&&Fh.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,Fh)))}_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,m=a.groups,p=a.drawRange;if(l!==null)if(Array.isArray(o))for(let b=0,v=m.length;b<v;b++){const x=m[b],y=o[x.materialIndex],S=Math.max(x.start,p.start),M=Math.min(l.count,Math.min(x.start+x.count,p.start+p.count));for(let N=S,A=M;N<A;N+=3){const k=l.getX(N),C=l.getX(N+1),D=l.getX(N+2);i=q_(this,y,e,r,u,d,f,k,C,D),i&&(i.faceIndex=Math.floor(N/3),i.face.materialIndex=x.materialIndex,n.push(i))}}else{const b=Math.max(0,p.start),v=Math.min(l.count,p.start+p.count);for(let x=b,y=v;x<y;x+=3){const S=l.getX(x),M=l.getX(x+1),N=l.getX(x+2);i=q_(this,o,e,r,u,d,f,S,M,N),i&&(i.faceIndex=Math.floor(x/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(o))for(let b=0,v=m.length;b<v;b++){const x=m[b],y=o[x.materialIndex],S=Math.max(x.start,p.start),M=Math.min(c.count,Math.min(x.start+x.count,p.start+p.count));for(let N=S,A=M;N<A;N+=3){const k=N,C=N+1,D=N+2;i=q_(this,y,e,r,u,d,f,k,C,D),i&&(i.faceIndex=Math.floor(N/3),i.face.materialIndex=x.materialIndex,n.push(i))}}else{const b=Math.max(0,p.start),v=Math.min(c.count,p.start+p.count);for(let x=b,y=v;x<y;x+=3){const S=x,M=x+1,N=x+2;i=q_(this,o,e,r,u,d,f,S,M,N),i&&(i.faceIndex=Math.floor(x/3),n.push(i))}}}};function Z3e(t,e,n,r,i,a,o,l){let c;if(e.side===_s?c=r.intersectTriangle(o,a,i,!0,l):c=r.intersectTriangle(i,a,o,e.side===Jd,l),c===null)return null;W_.copy(l),W_.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(W_);return u<n.near||u>n.far?null:{distance:u,point:W_.clone(),object:t}}function q_(t,e,n,r,i,a,o,l,c,u){t.getVertexPosition(l,$_),t.getVertexPosition(c,H_),t.getVertexPosition(u,V_);const d=Z3e(t,e,n,r,$_,H_,V_,UV);if(d){const f=new nt;vb.getBarycoord(UV,$_,H_,V_,f),i&&(d.uv=vb.getInterpolatedAttribute(i,l,c,u,f,new Mn)),a&&(d.uv1=vb.getInterpolatedAttribute(a,l,c,u,f,new Mn)),o&&(d.normal=vb.getInterpolatedAttribute(o,l,c,u,f,new nt),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const m={a:l,b:c,c:u,normal:new nt,materialIndex:0};vb.getNormal($_,H_,V_,m.normal),d.face=m,d.barycoord=f}return d}let oL=class vee extends yl{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 m=0,p=0;b("z","y","x",-1,-1,r,n,e,o,a,0),b("z","y","x",1,-1,r,n,-e,o,a,1),b("x","z","y",1,1,e,r,n,i,o,2),b("x","z","y",1,-1,e,r,-n,i,o,3),b("x","y","z",1,-1,e,n,r,i,a,4),b("x","y","z",-1,-1,e,n,-r,i,a,5),this.setIndex(c),this.setAttribute("position",new Ks(u,3)),this.setAttribute("normal",new Ks(d,3)),this.setAttribute("uv",new Ks(f,2));function b(v,x,y,S,M,N,A,k,C,D,T){const R=N/C,U=A/D,L=N/2,q=A/2,j=k/2,W=C+1,K=D+1;let V=0,J=0;const ne=new nt;for(let te=0;te<K;te++){const z=te*U-q;for(let H=0;H<W;H++){const Z=H*R-L;ne[v]=Z*S,ne[x]=z*M,ne[y]=j,u.push(ne.x,ne.y,ne.z),ne[v]=0,ne[x]=0,ne[y]=k>0?1:-1,d.push(ne.x,ne.y,ne.z),f.push(H/C),f.push(1-te/D),V+=1}}for(let te=0;te<D;te++)for(let z=0;z<C;z++){const H=m+z+W*te,Z=m+z+W*(te+1),ee=m+(z+1)+W*(te+1),he=m+(z+1)+W*te;c.push(H,Z,he),c.push(Z,ee,he),J+=6}l.addGroup(p,J,T),p+=J,m+=V}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new vee(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function kg(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?(un("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 qa(t){const e={};for(let n=0;n<t.length;n++){const r=kg(t[n]);for(const i in r)e[i]=r[i]}return e}function Q3e(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function _ee(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Vn.workingColorSpace}const J3e={clone:kg,merge:qa};var eRe=`void main() {
  91. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  92. }`,tRe=`void main() {
  93. gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
  94. }`;let ic=class extends lx{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=eRe,this.fragmentShader=tRe,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=kg(e.uniforms),this.uniformsGroups=Q3e(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.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,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}},wee=class extends Js{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new mi,this.projectionMatrix=new mi,this.projectionMatrixInverse=new mi,this.coordinateSystem=Hl,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 id=new nt,zV=new Mn,BV=new Mn;let So=class extends wee{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=gR*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(hw*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return gR*2*Math.atan(Math.tan(hw*.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){id.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(id.x,id.y).multiplyScalar(-e/id.z),id.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),r.set(id.x,id.y).multiplyScalar(-e/id.z)}getViewSize(e,n){return this.getViewBounds(e,zV,BV),n.subVectors(BV,zV)}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(hw*.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 up=-90,dp=1;let nRe=class extends Js{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new So(up,dp,e,n);i.layers=this.layers,this.add(i);const a=new So(up,dp,e,n);a.layers=this.layers,this.add(a);const o=new So(up,dp,e,n);o.layers=this.layers,this.add(o);const l=new So(up,dp,e,n);l.layers=this.layers,this.add(l);const c=new So(up,dp,e,n);c.layers=this.layers,this.add(c);const u=new So(up,dp,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===Hl)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===zS)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(),m=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),b=e.xr.enabled;e.xr.enabled=!1;const v=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(n,a),e.setRenderTarget(r,1,i),e.render(n,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=v,e.setRenderTarget(r,5,i),e.render(n,d),e.setRenderTarget(f,m,p),e.xr.enabled=b,r.texture.needsPMREMUpdate=!0}},See=class extends bl{constructor(e=[],n=Zf,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}},Mee=class extends Kl{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 See(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 oL(5,5,5),a=new ic({name:"CubemapFromEquirect",uniforms:kg(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:_s,blending:au});a.uniforms.tEquirect.value=n;const o=new hl(i,a),l=n.minFilter;return n.minFilter===mf&&(n.minFilter=Ua),new nRe(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)}},$b=class extends Js{constructor(){super(),this.isGroup=!0,this.type="Group"}};const rRe={type:"move"};let pk=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new $b,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 $b,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new nt,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new nt),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new $b,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new nt,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new nt),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 v of e.hand.values()){const x=n.getJointPose(v,r),y=this._getHandJoint(u,v);x!==null&&(y.matrix.fromArray(x.transform.matrix),y.matrix.decompose(y.position,y.rotation,y.scale),y.matrixWorldNeedsUpdate=!0,y.jointRadius=x.radius),y.visible=x!==null}const d=u.joints["index-finger-tip"],f=u.joints["thumb-tip"],m=d.position.distanceTo(f.position),p=.02,b=.005;u.inputState.pinching&&m>p+b?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&m<=p-b&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(a=n.getPose(e.gripSpace,r),a!==null&&(c.matrix.fromArray(a.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,a.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(a.linearVelocity)):c.hasLinearVelocity=!1,a.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(a.angularVelocity)):c.hasAngularVelocity=!1));l!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&a!==null&&(i=a),i!==null&&(l.matrix.fromArray(i.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,i.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(i.linearVelocity)):l.hasLinearVelocity=!1,i.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(i.angularVelocity)):l.hasAngularVelocity=!1,this.dispatchEvent(rRe)))}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 $b;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}},iRe=class extends Js{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 eh,this.environmentIntensity=1,this.environmentRotation=new eh,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}},aRe=class extends bl{constructor(e=null,n=1,r=1,i,a,o,l,c,u=Ma,d=Ma,f,m){super(null,o,l,c,u,d,i,a,f,m),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};const gk=new nt,sRe=new nt,oRe=new Nn;let xd=class{constructor(e=new nt(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=gk.subVectors(r,n).cross(sRe.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(gk),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||oRe.getNormalMatrix(e),i=this.coplanarPoint(gk).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 Uh=new cN,lRe=new Mn(.5,.5),K_=new nt;let lL=class{constructor(e=new xd,n=new xd,r=new xd,i=new xd,a=new xd,o=new xd){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=Hl,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],m=a[6],p=a[7],b=a[8],v=a[9],x=a[10],y=a[11],S=a[12],M=a[13],N=a[14],A=a[15];if(i[0].setComponents(u-o,p-d,y-b,A-S).normalize(),i[1].setComponents(u+o,p+d,y+b,A+S).normalize(),i[2].setComponents(u+l,p+f,y+v,A+M).normalize(),i[3].setComponents(u-l,p-f,y-v,A-M).normalize(),r)i[4].setComponents(c,m,x,N).normalize(),i[5].setComponents(u-c,p-m,y-x,A-N).normalize();else if(i[4].setComponents(u-c,p-m,y-x,A-N).normalize(),n===Hl)i[5].setComponents(u+c,p+m,y+x,A+N).normalize();else if(n===zS)i[5].setComponents(c,m,x,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(),Uh.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Uh.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Uh)}intersectsSprite(e){Uh.center.set(0,0,0);const n=lRe.distanceTo(e.center);return Uh.radius=.7071067811865476+n,Uh.applyMatrix4(e.matrixWorld),this.intersectsSphere(Uh)}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(K_.x=i.normal.x>0?e.max.x:e.min.x,K_.y=i.normal.y>0?e.max.y:e.min.y,K_.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(K_)<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)}},Eee=class extends lx{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Rn(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 $S=new nt,HS=new nt,$V=new mi,wb=new aL,X_=new cN,xk=new nt,HV=new nt;let cRe=class extends Js{constructor(e=new yl,n=new Eee){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++)$S.fromBufferAttribute(n,i-1),HS.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=$S.distanceTo(HS);e.setAttribute("lineDistance",new Ks(r,1))}else un("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(),X_.copy(r.boundingSphere),X_.applyMatrix4(i),X_.radius+=a,e.ray.intersectsSphere(X_)===!1)return;$V.copy(i).invert(),wb.copy(e.ray).applyMatrix4($V);const l=a/((this.scale.x+this.scale.y+this.scale.z)/3),c=l*l,u=this.isLineSegments?2:1,d=r.index,m=r.attributes.position;if(d!==null){const p=Math.max(0,o.start),b=Math.min(d.count,o.start+o.count);for(let v=p,x=b-1;v<x;v+=u){const y=d.getX(v),S=d.getX(v+1),M=Y_(this,e,wb,c,y,S,v);M&&n.push(M)}if(this.isLineLoop){const v=d.getX(b-1),x=d.getX(p),y=Y_(this,e,wb,c,v,x,b-1);y&&n.push(y)}}else{const p=Math.max(0,o.start),b=Math.min(m.count,o.start+o.count);for(let v=p,x=b-1;v<x;v+=u){const y=Y_(this,e,wb,c,v,v+1,v);y&&n.push(y)}if(this.isLineLoop){const v=Y_(this,e,wb,c,b-1,p,b-1);v&&n.push(v)}}}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,o=i.length;a<o;a++){const l=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=a}}}}};function Y_(t,e,n,r,i,a,o){const l=t.geometry.attributes.position;if($S.fromBufferAttribute(l,i),HS.fromBufferAttribute(l,a),n.distanceSqToSegment($S,HS,xk,HV)>r)return;xk.applyMatrix4(t.matrixWorld);const u=e.ray.origin.distanceTo(xk);if(!(u<e.near||u>e.far))return{distance:u,point:HV.clone().applyMatrix4(t.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:t}}const VV=new nt,GV=new nt;let uRe=class extends cRe{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)VV.fromBufferAttribute(n,i),GV.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+VV.distanceTo(GV);e.setAttribute("lineDistance",new Ks(r,1))}else un("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},X0=class extends bl{constructor(e,n,r=rc,i,a,o,l=Ma,c=Ma,u,d=vu,f=1){if(d!==vu&&d!==pf)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const m={width:e,height:n,depth:f};super(m,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 iL(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 dRe extends X0{constructor(e,n=rc,r=Zf,i,a,o=Ma,l=Ma,c,u=vu){const d={width:e,height:e,depth:1},f=[d,d,d,d,d,d];super(e,e,n,r,i,a,o,l,c,u),this.image=f,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class Nee extends bl{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}let cL=class Aee extends yl{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,m=n/c,p=[],b=[],v=[],x=[];for(let y=0;y<d;y++){const S=y*m-o;for(let M=0;M<u;M++){const N=M*f-a;b.push(N,-S,0),v.push(0,0,1),x.push(M/l),x.push(1-y/c)}}for(let y=0;y<c;y++)for(let S=0;S<l;S++){const M=S+u*y,N=S+u*(y+1),A=S+1+u*(y+1),k=S+1+u*y;p.push(M,N,k),p.push(N,A,k)}this.setIndex(p),this.setAttribute("position",new Ks(b,3)),this.setAttribute("normal",new Ks(v,3)),this.setAttribute("uv",new Ks(x,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Aee(e.width,e.height,e.widthSegments,e.heightSegments)}};class hRe extends ic{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class fRe extends lx{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Rn(16777215),this.specular=new Rn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Rn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=oee,this.normalScale=new Mn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new eh,this.combine=X4,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 mRe=class extends lx{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=S3e,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}},pRe=class extends lx{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}},Tee=class extends Js{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new Rn(e),this.intensity=n}dispose(){this.dispatchEvent({type:"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,n}};const bk=new mi,WV=new nt,qV=new nt;let gRe=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Mn(512,512),this.mapType=Hs,this.map=null,this.mapPass=null,this.matrix=new mi,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new lL,this._frameExtents=new Mn(1,1),this._viewportCount=1,this._viewports=[new Mi(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;WV.setFromMatrixPosition(e.matrixWorld),n.position.copy(WV),qV.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(qV),n.updateMatrixWorld(),bk.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(bk,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(bk)}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}},uL=class extends wee{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 xRe extends gRe{constructor(){super(new uL(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class KV extends Tee{constructor(e,n){super(e,n),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Js.DEFAULT_UP),this.updateMatrix(),this.target=new Js,this.shadow=new xRe}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){const n=super.toJSON(e);return n.object.shadow=this.shadow.toJSON(),n.object.target=this.target.uuid,n}}let bRe=class extends Tee{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}},yRe=class extends So{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},XV=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=Pn(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(Pn(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};class vRe extends uRe{constructor(e=10,n=10,r=4473924,i=8947848){r=new Rn(r),i=new Rn(i);const a=n/2,o=e/n,l=e/2,c=[],u=[];for(let m=0,p=0,b=-l;m<=n;m++,b+=o){c.push(-l,0,b,l,0,b),c.push(b,0,-l,b,0,l);const v=m===a?r:i;v.toArray(u,p),p+=3,v.toArray(u,p),p+=3,v.toArray(u,p),p+=3,v.toArray(u,p),p+=3}const d=new yl;d.setAttribute("position",new Ks(c,3)),d.setAttribute("color",new Ks(u,3));const f=new Eee({vertexColors:!0,toneMapped:!1});super(d,f),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class _Re extends dm{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){un("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function YV(t,e,n,r){const i=wRe(r);switch(n){case iee:return t*e;case see:return t*e/i.components*i.byteLength;case J4:return t*e/i.components*i.byteLength;case Tg:return t*e*2/i.components*i.byteLength;case eL:return t*e*2/i.components*i.byteLength;case aee:return t*e*3/i.components*i.byteLength;case el:return t*e*4/i.components*i.byteLength;case tL:return t*e*4/i.components*i.byteLength;case lw:case cw:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case uw:case dw:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case U3:case B3:return Math.max(t,16)*Math.max(e,8)/4;case F3:case z3:return Math.max(t,8)*Math.max(e,8)/2;case $3:case H3:case G3:case W3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case V3:case q3:case K3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case X3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case Y3:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case Z3:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case Q3:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case J3:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case eR:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case tR:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case nR:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case rR:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case iR:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case aR:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case sR:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case oR:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case lR:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case cR:case uR:case dR:return Math.ceil(t/4)*Math.ceil(e/4)*16;case hR:case fR:return Math.ceil(t/4)*Math.ceil(e/4)*8;case mR:case pR:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}function wRe(t){switch(t){case Hs:case eee:return{byteLength:1,components:1};case W0:case tee:case yu:return{byteLength:2,components:1};case Z4:case Q4:return{byteLength:2,components:4};case rc:case Y4:case $l:return{byteLength:4,components:1};case nee:case ree:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:K4}}));typeof window<"u"&&(window.__THREE__?un("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=K4);function Cee(){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 SRe(t){const e=new WeakMap;function n(l,c){const u=l.array,d=l.usage,f=u.byteLength,m=t.createBuffer();t.bindBuffer(c,m),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:m,type:p,bytesPerElement:u.BYTES_PER_ELEMENT,version:l.version,size:f}}function r(l,c,u){const d=c.array,f=c.updateRanges;if(t.bindBuffer(u,l),f.length===0)t.bufferSubData(u,0,d);else{f.sort((p,b)=>p.start-b.start);let m=0;for(let p=1;p<f.length;p++){const b=f[m],v=f[p];v.start<=b.start+b.count+1?b.count=Math.max(b.count,v.start+v.count-b.start):(++m,f[m]=v)}f.length=m+1;for(let p=0,b=f.length;p<b;p++){const v=f[p];t.bufferSubData(u,v.start*d.BYTES_PER_ELEMENT,d,v.start,v.count)}c.clearUpdateRanges()}c.onUploadCallback()}function i(l){return l.isInterleavedBufferAttribute&&(l=l.data),e.get(l)}function a(l){l.isInterleavedBufferAttribute&&(l=l.data);const c=e.get(l);c&&(t.deleteBuffer(c.buffer),e.delete(l))}function 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 MRe=`#ifdef USE_ALPHAHASH
  114. if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
  115. #endif`,ERe=`#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`,NRe=`#ifdef USE_ALPHAMAP
  151. diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
  152. #endif`,ARe=`#ifdef USE_ALPHAMAP
  153. uniform sampler2D alphaMap;
  154. #endif`,TRe=`#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`,CRe=`#ifdef USE_ALPHATEST
  162. uniform float alphaTest;
  163. #endif`,kRe=`#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`,jRe=`#ifdef USE_AOMAP
  177. uniform sampler2D aoMap;
  178. uniform float aoMapIntensity;
  179. #endif`,PRe=`#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`,RRe=`#ifdef USE_BATCHING
  214. mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
  215. #endif`,DRe=`vec3 transformed = vec3( position );
  216. #ifdef USE_ALPHAHASH
  217. vPosition = vec3( position );
  218. #endif`,ORe=`vec3 objectNormal = vec3( normal );
  219. #ifdef USE_TANGENT
  220. vec3 objectTangent = vec3( tangent.xyz );
  221. #endif`,LRe=`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`,IRe=`#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`,FRe=`#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`,URe=`#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`,zRe=`#if NUM_CLIPPING_PLANES > 0
  366. varying vec3 vClipPosition;
  367. uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
  368. #endif`,BRe=`#if NUM_CLIPPING_PLANES > 0
  369. varying vec3 vClipPosition;
  370. #endif`,$Re=`#if NUM_CLIPPING_PLANES > 0
  371. vClipPosition = - mvPosition.xyz;
  372. #endif`,HRe=`#if defined( USE_COLOR_ALPHA )
  373. diffuseColor *= vColor;
  374. #elif defined( USE_COLOR )
  375. diffuseColor.rgb *= vColor;
  376. #endif`,VRe=`#if defined( USE_COLOR_ALPHA )
  377. varying vec4 vColor;
  378. #elif defined( USE_COLOR )
  379. varying vec3 vColor;
  380. #endif`,GRe=`#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`,WRe=`#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`,qRe=`#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`,KRe=`#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`,XRe=`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`,YRe=`#ifdef USE_DISPLACEMENTMAP
  588. uniform sampler2D displacementMap;
  589. uniform float displacementScale;
  590. uniform float displacementBias;
  591. #endif`,ZRe=`#ifdef USE_DISPLACEMENTMAP
  592. transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
  593. #endif`,QRe=`#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`,JRe=`#ifdef USE_EMISSIVEMAP
  600. uniform sampler2D emissiveMap;
  601. #endif`,eDe="gl_FragColor = linearToOutputTexel( gl_FragColor );",tDe=`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. }`,nDe=`#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`,rDe=`#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`,iDe=`#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`,aDe=`#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`,sDe=`#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`,oDe=`#ifdef USE_FOG
  686. vFogDepth = - mvPosition.z;
  687. #endif`,lDe=`#ifdef USE_FOG
  688. varying float vFogDepth;
  689. #endif`,cDe=`#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`,uDe=`#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`,dDe=`#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. }`,hDe=`#ifdef USE_LIGHTMAP
  718. uniform sampler2D lightMap;
  719. uniform float lightMapIntensity;
  720. #endif`,fDe=`LambertMaterial material;
  721. material.diffuseColor = diffuseColor.rgb;
  722. material.specularStrength = specularStrength;`,mDe=`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`,pDe=`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`,gDe=`#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`,xDe=`ToonMaterial material;
  886. material.diffuseColor = diffuseColor.rgb;`,bDe=`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`,yDe=`BlinnPhongMaterial material;
  899. material.diffuseColor = diffuseColor.rgb;
  900. material.specularColor = specular;
  901. material.specularShininess = shininess;
  902. material.specularStrength = specularStrength;`,vDe=`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`,_De=`PhysicalMaterial material;
  920. material.diffuseColor = diffuseColor.rgb;
  921. material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );
  922. material.metalness = metalnessFactor;
  923. vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
  924. float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
  925. material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
  926. material.roughness = min( material.roughness, 1.0 );
  927. #ifdef IOR
  928. material.ior = ior;
  929. #ifdef USE_SPECULAR
  930. float specularIntensityFactor = specularIntensity;
  931. vec3 specularColorFactor = specularColor;
  932. #ifdef USE_SPECULAR_COLORMAP
  933. specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
  934. #endif
  935. #ifdef USE_SPECULAR_INTENSITYMAP
  936. specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
  937. #endif
  938. material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
  939. #else
  940. float specularIntensityFactor = 1.0;
  941. vec3 specularColorFactor = vec3( 1.0 );
  942. material.specularF90 = 1.0;
  943. #endif
  944. material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor;
  945. material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );
  946. #else
  947. material.specularColor = vec3( 0.04 );
  948. material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );
  949. material.specularF90 = 1.0;
  950. #endif
  951. #ifdef USE_CLEARCOAT
  952. material.clearcoat = clearcoat;
  953. material.clearcoatRoughness = clearcoatRoughness;
  954. material.clearcoatF0 = vec3( 0.04 );
  955. material.clearcoatF90 = 1.0;
  956. #ifdef USE_CLEARCOATMAP
  957. material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
  958. #endif
  959. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  960. material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
  961. #endif
  962. material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
  963. material.clearcoatRoughness += geometryRoughness;
  964. material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
  965. #endif
  966. #ifdef USE_DISPERSION
  967. material.dispersion = dispersion;
  968. #endif
  969. #ifdef USE_IRIDESCENCE
  970. material.iridescence = iridescence;
  971. material.iridescenceIOR = iridescenceIOR;
  972. #ifdef USE_IRIDESCENCEMAP
  973. material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
  974. #endif
  975. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  976. material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
  977. #else
  978. material.iridescenceThickness = iridescenceThicknessMaximum;
  979. #endif
  980. #endif
  981. #ifdef USE_SHEEN
  982. material.sheenColor = sheenColor;
  983. #ifdef USE_SHEEN_COLORMAP
  984. material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
  985. #endif
  986. material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 );
  987. #ifdef USE_SHEEN_ROUGHNESSMAP
  988. material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
  989. #endif
  990. #endif
  991. #ifdef USE_ANISOTROPY
  992. #ifdef USE_ANISOTROPYMAP
  993. mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
  994. vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
  995. vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
  996. #else
  997. vec2 anisotropyV = anisotropyVector;
  998. #endif
  999. material.anisotropy = length( anisotropyV );
  1000. if( material.anisotropy == 0.0 ) {
  1001. anisotropyV = vec2( 1.0, 0.0 );
  1002. } else {
  1003. anisotropyV /= material.anisotropy;
  1004. material.anisotropy = saturate( material.anisotropy );
  1005. }
  1006. material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
  1007. material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
  1008. material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
  1009. #endif`,wDe=`uniform sampler2D dfgLUT;
  1010. struct PhysicalMaterial {
  1011. vec3 diffuseColor;
  1012. vec3 diffuseContribution;
  1013. vec3 specularColor;
  1014. vec3 specularColorBlended;
  1015. float roughness;
  1016. float metalness;
  1017. float specularF90;
  1018. float dispersion;
  1019. #ifdef USE_CLEARCOAT
  1020. float clearcoat;
  1021. float clearcoatRoughness;
  1022. vec3 clearcoatF0;
  1023. float clearcoatF90;
  1024. #endif
  1025. #ifdef USE_IRIDESCENCE
  1026. float iridescence;
  1027. float iridescenceIOR;
  1028. float iridescenceThickness;
  1029. vec3 iridescenceFresnel;
  1030. vec3 iridescenceF0;
  1031. vec3 iridescenceFresnelDielectric;
  1032. vec3 iridescenceFresnelMetallic;
  1033. #endif
  1034. #ifdef USE_SHEEN
  1035. vec3 sheenColor;
  1036. float sheenRoughness;
  1037. #endif
  1038. #ifdef IOR
  1039. float ior;
  1040. #endif
  1041. #ifdef USE_TRANSMISSION
  1042. float transmission;
  1043. float transmissionAlpha;
  1044. float thickness;
  1045. float attenuationDistance;
  1046. vec3 attenuationColor;
  1047. #endif
  1048. #ifdef USE_ANISOTROPY
  1049. float anisotropy;
  1050. float alphaT;
  1051. vec3 anisotropyT;
  1052. vec3 anisotropyB;
  1053. #endif
  1054. };
  1055. vec3 clearcoatSpecularDirect = vec3( 0.0 );
  1056. vec3 clearcoatSpecularIndirect = vec3( 0.0 );
  1057. vec3 sheenSpecularDirect = vec3( 0.0 );
  1058. vec3 sheenSpecularIndirect = vec3(0.0 );
  1059. vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
  1060. float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
  1061. float x2 = x * x;
  1062. float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
  1063. return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
  1064. }
  1065. float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
  1066. float a2 = pow2( alpha );
  1067. float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
  1068. float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
  1069. return 0.5 / max( gv + gl, EPSILON );
  1070. }
  1071. float D_GGX( const in float alpha, const in float dotNH ) {
  1072. float a2 = pow2( alpha );
  1073. float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
  1074. return RECIPROCAL_PI * a2 / pow2( denom );
  1075. }
  1076. #ifdef USE_ANISOTROPY
  1077. 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 ) {
  1078. float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
  1079. float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
  1080. float v = 0.5 / ( gv + gl );
  1081. return v;
  1082. }
  1083. float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
  1084. float a2 = alphaT * alphaB;
  1085. highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
  1086. highp float v2 = dot( v, v );
  1087. float w2 = a2 / v2;
  1088. return RECIPROCAL_PI * a2 * pow2 ( w2 );
  1089. }
  1090. #endif
  1091. #ifdef USE_CLEARCOAT
  1092. vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
  1093. vec3 f0 = material.clearcoatF0;
  1094. float f90 = material.clearcoatF90;
  1095. float roughness = material.clearcoatRoughness;
  1096. float alpha = pow2( roughness );
  1097. vec3 halfDir = normalize( lightDir + viewDir );
  1098. float dotNL = saturate( dot( normal, lightDir ) );
  1099. float dotNV = saturate( dot( normal, viewDir ) );
  1100. float dotNH = saturate( dot( normal, halfDir ) );
  1101. float dotVH = saturate( dot( viewDir, halfDir ) );
  1102. vec3 F = F_Schlick( f0, f90, dotVH );
  1103. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  1104. float D = D_GGX( alpha, dotNH );
  1105. return F * ( V * D );
  1106. }
  1107. #endif
  1108. vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
  1109. vec3 f0 = material.specularColorBlended;
  1110. float f90 = material.specularF90;
  1111. float roughness = material.roughness;
  1112. float alpha = pow2( roughness );
  1113. vec3 halfDir = normalize( lightDir + viewDir );
  1114. float dotNL = saturate( dot( normal, lightDir ) );
  1115. float dotNV = saturate( dot( normal, viewDir ) );
  1116. float dotNH = saturate( dot( normal, halfDir ) );
  1117. float dotVH = saturate( dot( viewDir, halfDir ) );
  1118. vec3 F = F_Schlick( f0, f90, dotVH );
  1119. #ifdef USE_IRIDESCENCE
  1120. F = mix( F, material.iridescenceFresnel, material.iridescence );
  1121. #endif
  1122. #ifdef USE_ANISOTROPY
  1123. float dotTL = dot( material.anisotropyT, lightDir );
  1124. float dotTV = dot( material.anisotropyT, viewDir );
  1125. float dotTH = dot( material.anisotropyT, halfDir );
  1126. float dotBL = dot( material.anisotropyB, lightDir );
  1127. float dotBV = dot( material.anisotropyB, viewDir );
  1128. float dotBH = dot( material.anisotropyB, halfDir );
  1129. float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
  1130. float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
  1131. #else
  1132. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  1133. float D = D_GGX( alpha, dotNH );
  1134. #endif
  1135. return F * ( V * D );
  1136. }
  1137. vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
  1138. const float LUT_SIZE = 64.0;
  1139. const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
  1140. const float LUT_BIAS = 0.5 / LUT_SIZE;
  1141. float dotNV = saturate( dot( N, V ) );
  1142. vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
  1143. uv = uv * LUT_SCALE + LUT_BIAS;
  1144. return uv;
  1145. }
  1146. float LTC_ClippedSphereFormFactor( const in vec3 f ) {
  1147. float l = length( f );
  1148. return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
  1149. }
  1150. vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
  1151. float x = dot( v1, v2 );
  1152. float y = abs( x );
  1153. float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
  1154. float b = 3.4175940 + ( 4.1616724 + y ) * y;
  1155. float v = a / b;
  1156. float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
  1157. return cross( v1, v2 ) * theta_sintheta;
  1158. }
  1159. vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
  1160. vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
  1161. vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
  1162. vec3 lightNormal = cross( v1, v2 );
  1163. if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
  1164. vec3 T1, T2;
  1165. T1 = normalize( V - N * dot( V, N ) );
  1166. T2 = - cross( N, T1 );
  1167. mat3 mat = mInv * transpose( mat3( T1, T2, N ) );
  1168. vec3 coords[ 4 ];
  1169. coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
  1170. coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
  1171. coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
  1172. coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
  1173. coords[ 0 ] = normalize( coords[ 0 ] );
  1174. coords[ 1 ] = normalize( coords[ 1 ] );
  1175. coords[ 2 ] = normalize( coords[ 2 ] );
  1176. coords[ 3 ] = normalize( coords[ 3 ] );
  1177. vec3 vectorFormFactor = vec3( 0.0 );
  1178. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
  1179. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
  1180. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
  1181. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
  1182. float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
  1183. return vec3( result );
  1184. }
  1185. #if defined( USE_SHEEN )
  1186. float D_Charlie( float roughness, float dotNH ) {
  1187. float alpha = pow2( roughness );
  1188. float invAlpha = 1.0 / alpha;
  1189. float cos2h = dotNH * dotNH;
  1190. float sin2h = max( 1.0 - cos2h, 0.0078125 );
  1191. return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
  1192. }
  1193. float V_Neubelt( float dotNV, float dotNL ) {
  1194. return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
  1195. }
  1196. vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
  1197. vec3 halfDir = normalize( lightDir + viewDir );
  1198. float dotNL = saturate( dot( normal, lightDir ) );
  1199. float dotNV = saturate( dot( normal, viewDir ) );
  1200. float dotNH = saturate( dot( normal, halfDir ) );
  1201. float D = D_Charlie( sheenRoughness, dotNH );
  1202. float V = V_Neubelt( dotNV, dotNL );
  1203. return sheenColor * ( D * V );
  1204. }
  1205. #endif
  1206. float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  1207. float dotNV = saturate( dot( normal, viewDir ) );
  1208. float r2 = roughness * roughness;
  1209. float rInv = 1.0 / ( roughness + 0.1 );
  1210. float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv;
  1211. float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv;
  1212. float DG = exp( a * dotNV + b );
  1213. return saturate( DG );
  1214. }
  1215. vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
  1216. float dotNV = saturate( dot( normal, viewDir ) );
  1217. vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;
  1218. return specularColor * fab.x + specularF90 * fab.y;
  1219. }
  1220. #ifdef USE_IRIDESCENCE
  1221. 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 ) {
  1222. #else
  1223. 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 ) {
  1224. #endif
  1225. float dotNV = saturate( dot( normal, viewDir ) );
  1226. vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;
  1227. #ifdef USE_IRIDESCENCE
  1228. vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
  1229. #else
  1230. vec3 Fr = specularColor;
  1231. #endif
  1232. vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
  1233. float Ess = fab.x + fab.y;
  1234. float Ems = 1.0 - Ess;
  1235. vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
  1236. singleScatter += FssEss;
  1237. multiScatter += Fms * Ems;
  1238. }
  1239. vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
  1240. vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );
  1241. float dotNL = saturate( dot( normal, lightDir ) );
  1242. float dotNV = saturate( dot( normal, viewDir ) );
  1243. vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg;
  1244. vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg;
  1245. vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y;
  1246. vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y;
  1247. float Ess_V = dfgV.x + dfgV.y;
  1248. float Ess_L = dfgL.x + dfgL.y;
  1249. float Ems_V = 1.0 - Ess_V;
  1250. float Ems_L = 1.0 - Ess_L;
  1251. vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619;
  1252. vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON );
  1253. float compensationFactor = Ems_V * Ems_L;
  1254. vec3 multiScatter = Fms * compensationFactor;
  1255. return singleScatter + multiScatter;
  1256. }
  1257. #if NUM_RECT_AREA_LIGHTS > 0
  1258. 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 ) {
  1259. vec3 normal = geometryNormal;
  1260. vec3 viewDir = geometryViewDir;
  1261. vec3 position = geometryPosition;
  1262. vec3 lightPos = rectAreaLight.position;
  1263. vec3 halfWidth = rectAreaLight.halfWidth;
  1264. vec3 halfHeight = rectAreaLight.halfHeight;
  1265. vec3 lightColor = rectAreaLight.color;
  1266. float roughness = material.roughness;
  1267. vec3 rectCoords[ 4 ];
  1268. rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
  1269. rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
  1270. rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
  1271. vec2 uv = LTC_Uv( normal, viewDir, roughness );
  1272. vec4 t1 = texture2D( ltc_1, uv );
  1273. vec4 t2 = texture2D( ltc_2, uv );
  1274. mat3 mInv = mat3(
  1275. vec3( t1.x, 0, t1.y ),
  1276. vec3( 0, 1, 0 ),
  1277. vec3( t1.z, 0, t1.w )
  1278. );
  1279. vec3 fresnel = ( material.specularColorBlended * t2.x + ( vec3( 1.0 ) - material.specularColorBlended ) * t2.y );
  1280. reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
  1281. reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
  1282. }
  1283. #endif
  1284. 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 ) {
  1285. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  1286. vec3 irradiance = dotNL * directLight.color;
  1287. #ifdef USE_CLEARCOAT
  1288. float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
  1289. vec3 ccIrradiance = dotNLcc * directLight.color;
  1290. clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
  1291. #endif
  1292. #ifdef USE_SHEEN
  1293. sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
  1294. float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
  1295. float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness );
  1296. float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL );
  1297. irradiance *= sheenEnergyComp;
  1298. #endif
  1299. reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );
  1300. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution );
  1301. }
  1302. 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 ) {
  1303. vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution );
  1304. #ifdef USE_SHEEN
  1305. float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
  1306. float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;
  1307. diffuse *= sheenEnergyComp;
  1308. #endif
  1309. reflectedLight.indirectDiffuse += diffuse;
  1310. }
  1311. 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) {
  1312. #ifdef USE_CLEARCOAT
  1313. clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
  1314. #endif
  1315. #ifdef USE_SHEEN
  1316. sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI;
  1317. #endif
  1318. vec3 singleScatteringDielectric = vec3( 0.0 );
  1319. vec3 multiScatteringDielectric = vec3( 0.0 );
  1320. vec3 singleScatteringMetallic = vec3( 0.0 );
  1321. vec3 multiScatteringMetallic = vec3( 0.0 );
  1322. #ifdef USE_IRIDESCENCE
  1323. computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric );
  1324. computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic );
  1325. #else
  1326. computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric );
  1327. computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic );
  1328. #endif
  1329. vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );
  1330. vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );
  1331. vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric;
  1332. vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric );
  1333. vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
  1334. vec3 indirectSpecular = radiance * singleScattering;
  1335. indirectSpecular += multiScattering * cosineWeightedIrradiance;
  1336. vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance;
  1337. #ifdef USE_SHEEN
  1338. float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
  1339. float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;
  1340. indirectSpecular *= sheenEnergyComp;
  1341. indirectDiffuse *= sheenEnergyComp;
  1342. #endif
  1343. reflectedLight.indirectSpecular += indirectSpecular;
  1344. reflectedLight.indirectDiffuse += indirectDiffuse;
  1345. }
  1346. #define RE_Direct RE_Direct_Physical
  1347. #define RE_Direct_RectArea RE_Direct_RectArea_Physical
  1348. #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
  1349. #define RE_IndirectSpecular RE_IndirectSpecular_Physical
  1350. float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
  1351. return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
  1352. }`,SDe=`
  1353. vec3 geometryPosition = - vViewPosition;
  1354. vec3 geometryNormal = normal;
  1355. vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
  1356. vec3 geometryClearcoatNormal = vec3( 0.0 );
  1357. #ifdef USE_CLEARCOAT
  1358. geometryClearcoatNormal = clearcoatNormal;
  1359. #endif
  1360. #ifdef USE_IRIDESCENCE
  1361. float dotNVi = saturate( dot( normal, geometryViewDir ) );
  1362. if ( material.iridescenceThickness == 0.0 ) {
  1363. material.iridescence = 0.0;
  1364. } else {
  1365. material.iridescence = saturate( material.iridescence );
  1366. }
  1367. if ( material.iridescence > 0.0 ) {
  1368. material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
  1369. material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );
  1370. material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness );
  1371. material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
  1372. }
  1373. #endif
  1374. IncidentLight directLight;
  1375. #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
  1376. PointLight pointLight;
  1377. #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
  1378. PointLightShadow pointLightShadow;
  1379. #endif
  1380. #pragma unroll_loop_start
  1381. for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
  1382. pointLight = pointLights[ i ];
  1383. getPointLightInfo( pointLight, geometryPosition, directLight );
  1384. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )
  1385. pointLightShadow = pointLightShadows[ i ];
  1386. directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
  1387. #endif
  1388. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1389. }
  1390. #pragma unroll_loop_end
  1391. #endif
  1392. #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
  1393. SpotLight spotLight;
  1394. vec4 spotColor;
  1395. vec3 spotLightCoord;
  1396. bool inSpotLightMap;
  1397. #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
  1398. SpotLightShadow spotLightShadow;
  1399. #endif
  1400. #pragma unroll_loop_start
  1401. for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
  1402. spotLight = spotLights[ i ];
  1403. getSpotLightInfo( spotLight, geometryPosition, directLight );
  1404. #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  1405. #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
  1406. #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1407. #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
  1408. #else
  1409. #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  1410. #endif
  1411. #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
  1412. spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
  1413. inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
  1414. spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
  1415. directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
  1416. #endif
  1417. #undef SPOT_LIGHT_MAP_INDEX
  1418. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1419. spotLightShadow = spotLightShadows[ i ];
  1420. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  1421. #endif
  1422. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1423. }
  1424. #pragma unroll_loop_end
  1425. #endif
  1426. #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
  1427. DirectionalLight directionalLight;
  1428. #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
  1429. DirectionalLightShadow directionalLightShadow;
  1430. #endif
  1431. #pragma unroll_loop_start
  1432. for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
  1433. directionalLight = directionalLights[ i ];
  1434. getDirectionalLightInfo( directionalLight, directLight );
  1435. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
  1436. directionalLightShadow = directionalLightShadows[ i ];
  1437. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  1438. #endif
  1439. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1440. }
  1441. #pragma unroll_loop_end
  1442. #endif
  1443. #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
  1444. RectAreaLight rectAreaLight;
  1445. #pragma unroll_loop_start
  1446. for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
  1447. rectAreaLight = rectAreaLights[ i ];
  1448. RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1449. }
  1450. #pragma unroll_loop_end
  1451. #endif
  1452. #if defined( RE_IndirectDiffuse )
  1453. vec3 iblIrradiance = vec3( 0.0 );
  1454. vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
  1455. #if defined( USE_LIGHT_PROBES )
  1456. irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
  1457. #endif
  1458. #if ( NUM_HEMI_LIGHTS > 0 )
  1459. #pragma unroll_loop_start
  1460. for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
  1461. irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
  1462. }
  1463. #pragma unroll_loop_end
  1464. #endif
  1465. #endif
  1466. #if defined( RE_IndirectSpecular )
  1467. vec3 radiance = vec3( 0.0 );
  1468. vec3 clearcoatRadiance = vec3( 0.0 );
  1469. #endif`,MDe=`#if defined( RE_IndirectDiffuse )
  1470. #ifdef USE_LIGHTMAP
  1471. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  1472. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  1473. irradiance += lightMapIrradiance;
  1474. #endif
  1475. #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
  1476. iblIrradiance += getIBLIrradiance( geometryNormal );
  1477. #endif
  1478. #endif
  1479. #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
  1480. #ifdef USE_ANISOTROPY
  1481. radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
  1482. #else
  1483. radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
  1484. #endif
  1485. #ifdef USE_CLEARCOAT
  1486. clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
  1487. #endif
  1488. #endif`,EDe=`#if defined( RE_IndirectDiffuse )
  1489. RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1490. #endif
  1491. #if defined( RE_IndirectSpecular )
  1492. RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1493. #endif`,NDe=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
  1494. gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
  1495. #endif`,ADe=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
  1496. uniform float logDepthBufFC;
  1497. varying float vFragDepth;
  1498. varying float vIsPerspective;
  1499. #endif`,TDe=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
  1500. varying float vFragDepth;
  1501. varying float vIsPerspective;
  1502. #endif`,CDe=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
  1503. vFragDepth = 1.0 + gl_Position.w;
  1504. vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
  1505. #endif`,kDe=`#ifdef USE_MAP
  1506. vec4 sampledDiffuseColor = texture2D( map, vMapUv );
  1507. #ifdef DECODE_VIDEO_TEXTURE
  1508. sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
  1509. #endif
  1510. diffuseColor *= sampledDiffuseColor;
  1511. #endif`,jDe=`#ifdef USE_MAP
  1512. uniform sampler2D map;
  1513. #endif`,PDe=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  1514. #if defined( USE_POINTS_UV )
  1515. vec2 uv = vUv;
  1516. #else
  1517. vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
  1518. #endif
  1519. #endif
  1520. #ifdef USE_MAP
  1521. diffuseColor *= texture2D( map, uv );
  1522. #endif
  1523. #ifdef USE_ALPHAMAP
  1524. diffuseColor.a *= texture2D( alphaMap, uv ).g;
  1525. #endif`,RDe=`#if defined( USE_POINTS_UV )
  1526. varying vec2 vUv;
  1527. #else
  1528. #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  1529. uniform mat3 uvTransform;
  1530. #endif
  1531. #endif
  1532. #ifdef USE_MAP
  1533. uniform sampler2D map;
  1534. #endif
  1535. #ifdef USE_ALPHAMAP
  1536. uniform sampler2D alphaMap;
  1537. #endif`,DDe=`float metalnessFactor = metalness;
  1538. #ifdef USE_METALNESSMAP
  1539. vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
  1540. metalnessFactor *= texelMetalness.b;
  1541. #endif`,ODe=`#ifdef USE_METALNESSMAP
  1542. uniform sampler2D metalnessMap;
  1543. #endif`,LDe=`#ifdef USE_INSTANCING_MORPH
  1544. float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  1545. float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
  1546. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1547. morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
  1548. }
  1549. #endif`,IDe=`#if defined( USE_MORPHCOLORS )
  1550. vColor *= morphTargetBaseInfluence;
  1551. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1552. #if defined( USE_COLOR_ALPHA )
  1553. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
  1554. #elif defined( USE_COLOR )
  1555. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
  1556. #endif
  1557. }
  1558. #endif`,FDe=`#ifdef USE_MORPHNORMALS
  1559. objectNormal *= morphTargetBaseInfluence;
  1560. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1561. if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
  1562. }
  1563. #endif`,UDe=`#ifdef USE_MORPHTARGETS
  1564. #ifndef USE_INSTANCING_MORPH
  1565. uniform float morphTargetBaseInfluence;
  1566. uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  1567. #endif
  1568. uniform sampler2DArray morphTargetsTexture;
  1569. uniform ivec2 morphTargetsTextureSize;
  1570. vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
  1571. int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
  1572. int y = texelIndex / morphTargetsTextureSize.x;
  1573. int x = texelIndex - y * morphTargetsTextureSize.x;
  1574. ivec3 morphUV = ivec3( x, y, morphTargetIndex );
  1575. return texelFetch( morphTargetsTexture, morphUV, 0 );
  1576. }
  1577. #endif`,zDe=`#ifdef USE_MORPHTARGETS
  1578. transformed *= morphTargetBaseInfluence;
  1579. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1580. if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
  1581. }
  1582. #endif`,BDe=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
  1583. #ifdef FLAT_SHADED
  1584. vec3 fdx = dFdx( vViewPosition );
  1585. vec3 fdy = dFdy( vViewPosition );
  1586. vec3 normal = normalize( cross( fdx, fdy ) );
  1587. #else
  1588. vec3 normal = normalize( vNormal );
  1589. #ifdef DOUBLE_SIDED
  1590. normal *= faceDirection;
  1591. #endif
  1592. #endif
  1593. #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
  1594. #ifdef USE_TANGENT
  1595. mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  1596. #else
  1597. mat3 tbn = getTangentFrame( - vViewPosition, normal,
  1598. #if defined( USE_NORMALMAP )
  1599. vNormalMapUv
  1600. #elif defined( USE_CLEARCOAT_NORMALMAP )
  1601. vClearcoatNormalMapUv
  1602. #else
  1603. vUv
  1604. #endif
  1605. );
  1606. #endif
  1607. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  1608. tbn[0] *= faceDirection;
  1609. tbn[1] *= faceDirection;
  1610. #endif
  1611. #endif
  1612. #ifdef USE_CLEARCOAT_NORMALMAP
  1613. #ifdef USE_TANGENT
  1614. mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  1615. #else
  1616. mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
  1617. #endif
  1618. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  1619. tbn2[0] *= faceDirection;
  1620. tbn2[1] *= faceDirection;
  1621. #endif
  1622. #endif
  1623. vec3 nonPerturbedNormal = normal;`,$De=`#ifdef USE_NORMALMAP_OBJECTSPACE
  1624. normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  1625. #ifdef FLIP_SIDED
  1626. normal = - normal;
  1627. #endif
  1628. #ifdef DOUBLE_SIDED
  1629. normal = normal * faceDirection;
  1630. #endif
  1631. normal = normalize( normalMatrix * normal );
  1632. #elif defined( USE_NORMALMAP_TANGENTSPACE )
  1633. vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  1634. mapN.xy *= normalScale;
  1635. normal = normalize( tbn * mapN );
  1636. #elif defined( USE_BUMPMAP )
  1637. normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
  1638. #endif`,HDe=`#ifndef FLAT_SHADED
  1639. varying vec3 vNormal;
  1640. #ifdef USE_TANGENT
  1641. varying vec3 vTangent;
  1642. varying vec3 vBitangent;
  1643. #endif
  1644. #endif`,VDe=`#ifndef FLAT_SHADED
  1645. varying vec3 vNormal;
  1646. #ifdef USE_TANGENT
  1647. varying vec3 vTangent;
  1648. varying vec3 vBitangent;
  1649. #endif
  1650. #endif`,GDe=`#ifndef FLAT_SHADED
  1651. vNormal = normalize( transformedNormal );
  1652. #ifdef USE_TANGENT
  1653. vTangent = normalize( transformedTangent );
  1654. vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
  1655. #endif
  1656. #endif`,WDe=`#ifdef USE_NORMALMAP
  1657. uniform sampler2D normalMap;
  1658. uniform vec2 normalScale;
  1659. #endif
  1660. #ifdef USE_NORMALMAP_OBJECTSPACE
  1661. uniform mat3 normalMatrix;
  1662. #endif
  1663. #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
  1664. mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
  1665. vec3 q0 = dFdx( eye_pos.xyz );
  1666. vec3 q1 = dFdy( eye_pos.xyz );
  1667. vec2 st0 = dFdx( uv.st );
  1668. vec2 st1 = dFdy( uv.st );
  1669. vec3 N = surf_norm;
  1670. vec3 q1perp = cross( q1, N );
  1671. vec3 q0perp = cross( N, q0 );
  1672. vec3 T = q1perp * st0.x + q0perp * st1.x;
  1673. vec3 B = q1perp * st0.y + q0perp * st1.y;
  1674. float det = max( dot( T, T ), dot( B, B ) );
  1675. float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
  1676. return mat3( T * scale, B * scale, N );
  1677. }
  1678. #endif`,qDe=`#ifdef USE_CLEARCOAT
  1679. vec3 clearcoatNormal = nonPerturbedNormal;
  1680. #endif`,KDe=`#ifdef USE_CLEARCOAT_NORMALMAP
  1681. vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
  1682. clearcoatMapN.xy *= clearcoatNormalScale;
  1683. clearcoatNormal = normalize( tbn2 * clearcoatMapN );
  1684. #endif`,XDe=`#ifdef USE_CLEARCOATMAP
  1685. uniform sampler2D clearcoatMap;
  1686. #endif
  1687. #ifdef USE_CLEARCOAT_NORMALMAP
  1688. uniform sampler2D clearcoatNormalMap;
  1689. uniform vec2 clearcoatNormalScale;
  1690. #endif
  1691. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  1692. uniform sampler2D clearcoatRoughnessMap;
  1693. #endif`,YDe=`#ifdef USE_IRIDESCENCEMAP
  1694. uniform sampler2D iridescenceMap;
  1695. #endif
  1696. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  1697. uniform sampler2D iridescenceThicknessMap;
  1698. #endif`,ZDe=`#ifdef OPAQUE
  1699. diffuseColor.a = 1.0;
  1700. #endif
  1701. #ifdef USE_TRANSMISSION
  1702. diffuseColor.a *= material.transmissionAlpha;
  1703. #endif
  1704. gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,QDe=`vec3 packNormalToRGB( const in vec3 normal ) {
  1705. return normalize( normal ) * 0.5 + 0.5;
  1706. }
  1707. vec3 unpackRGBToNormal( const in vec3 rgb ) {
  1708. return 2.0 * rgb.xyz - 1.0;
  1709. }
  1710. const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
  1711. const float Inv255 = 1. / 255.;
  1712. const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
  1713. const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
  1714. const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
  1715. const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
  1716. vec4 packDepthToRGBA( const in float v ) {
  1717. if( v <= 0.0 )
  1718. return vec4( 0., 0., 0., 0. );
  1719. if( v >= 1.0 )
  1720. return vec4( 1., 1., 1., 1. );
  1721. float vuf;
  1722. float af = modf( v * PackFactors.a, vuf );
  1723. float bf = modf( vuf * ShiftRight8, vuf );
  1724. float gf = modf( vuf * ShiftRight8, vuf );
  1725. return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
  1726. }
  1727. vec3 packDepthToRGB( const in float v ) {
  1728. if( v <= 0.0 )
  1729. return vec3( 0., 0., 0. );
  1730. if( v >= 1.0 )
  1731. return vec3( 1., 1., 1. );
  1732. float vuf;
  1733. float bf = modf( v * PackFactors.b, vuf );
  1734. float gf = modf( vuf * ShiftRight8, vuf );
  1735. return vec3( vuf * Inv255, gf * PackUpscale, bf );
  1736. }
  1737. vec2 packDepthToRG( const in float v ) {
  1738. if( v <= 0.0 )
  1739. return vec2( 0., 0. );
  1740. if( v >= 1.0 )
  1741. return vec2( 1., 1. );
  1742. float vuf;
  1743. float gf = modf( v * 256., vuf );
  1744. return vec2( vuf * Inv255, gf );
  1745. }
  1746. float unpackRGBAToDepth( const in vec4 v ) {
  1747. return dot( v, UnpackFactors4 );
  1748. }
  1749. float unpackRGBToDepth( const in vec3 v ) {
  1750. return dot( v, UnpackFactors3 );
  1751. }
  1752. float unpackRGToDepth( const in vec2 v ) {
  1753. return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
  1754. }
  1755. vec4 pack2HalfToRGBA( const in vec2 v ) {
  1756. vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
  1757. return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
  1758. }
  1759. vec2 unpackRGBATo2Half( const in vec4 v ) {
  1760. return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
  1761. }
  1762. float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
  1763. return ( viewZ + near ) / ( near - far );
  1764. }
  1765. float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
  1766. return depth * ( near - far ) - near;
  1767. }
  1768. float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
  1769. return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
  1770. }
  1771. float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
  1772. return ( near * far ) / ( ( far - near ) * depth - far );
  1773. }`,JDe=`#ifdef PREMULTIPLIED_ALPHA
  1774. gl_FragColor.rgb *= gl_FragColor.a;
  1775. #endif`,eOe=`vec4 mvPosition = vec4( transformed, 1.0 );
  1776. #ifdef USE_BATCHING
  1777. mvPosition = batchingMatrix * mvPosition;
  1778. #endif
  1779. #ifdef USE_INSTANCING
  1780. mvPosition = instanceMatrix * mvPosition;
  1781. #endif
  1782. mvPosition = modelViewMatrix * mvPosition;
  1783. gl_Position = projectionMatrix * mvPosition;`,tOe=`#ifdef DITHERING
  1784. gl_FragColor.rgb = dithering( gl_FragColor.rgb );
  1785. #endif`,nOe=`#ifdef DITHERING
  1786. vec3 dithering( vec3 color ) {
  1787. float grid_position = rand( gl_FragCoord.xy );
  1788. vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
  1789. dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
  1790. return color + dither_shift_RGB;
  1791. }
  1792. #endif`,rOe=`float roughnessFactor = roughness;
  1793. #ifdef USE_ROUGHNESSMAP
  1794. vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
  1795. roughnessFactor *= texelRoughness.g;
  1796. #endif`,iOe=`#ifdef USE_ROUGHNESSMAP
  1797. uniform sampler2D roughnessMap;
  1798. #endif`,aOe=`#if NUM_SPOT_LIGHT_COORDS > 0
  1799. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  1800. #endif
  1801. #if NUM_SPOT_LIGHT_MAPS > 0
  1802. uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
  1803. #endif
  1804. #ifdef USE_SHADOWMAP
  1805. #if NUM_DIR_LIGHT_SHADOWS > 0
  1806. #if defined( SHADOWMAP_TYPE_PCF )
  1807. uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
  1808. #else
  1809. uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
  1810. #endif
  1811. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  1812. struct DirectionalLightShadow {
  1813. float shadowIntensity;
  1814. float shadowBias;
  1815. float shadowNormalBias;
  1816. float shadowRadius;
  1817. vec2 shadowMapSize;
  1818. };
  1819. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  1820. #endif
  1821. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1822. #if defined( SHADOWMAP_TYPE_PCF )
  1823. uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
  1824. #else
  1825. uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
  1826. #endif
  1827. struct SpotLightShadow {
  1828. float shadowIntensity;
  1829. float shadowBias;
  1830. float shadowNormalBias;
  1831. float shadowRadius;
  1832. vec2 shadowMapSize;
  1833. };
  1834. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  1835. #endif
  1836. #if NUM_POINT_LIGHT_SHADOWS > 0
  1837. #if defined( SHADOWMAP_TYPE_PCF )
  1838. uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
  1839. #elif defined( SHADOWMAP_TYPE_BASIC )
  1840. uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
  1841. #endif
  1842. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  1843. struct PointLightShadow {
  1844. float shadowIntensity;
  1845. float shadowBias;
  1846. float shadowNormalBias;
  1847. float shadowRadius;
  1848. vec2 shadowMapSize;
  1849. float shadowCameraNear;
  1850. float shadowCameraFar;
  1851. };
  1852. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  1853. #endif
  1854. #if defined( SHADOWMAP_TYPE_PCF )
  1855. float interleavedGradientNoise( vec2 position ) {
  1856. return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) );
  1857. }
  1858. vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) {
  1859. const float goldenAngle = 2.399963229728653;
  1860. float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) );
  1861. float theta = float( sampleIndex ) * goldenAngle + phi;
  1862. return vec2( cos( theta ), sin( theta ) ) * r;
  1863. }
  1864. #endif
  1865. #if defined( SHADOWMAP_TYPE_PCF )
  1866. float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
  1867. float shadow = 1.0;
  1868. shadowCoord.xyz /= shadowCoord.w;
  1869. shadowCoord.z += shadowBias;
  1870. bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
  1871. bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
  1872. if ( frustumTest ) {
  1873. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  1874. float radius = shadowRadius * texelSize.x;
  1875. float phi = interleavedGradientNoise( gl_FragCoord.xy ) * 6.28318530718;
  1876. shadow = (
  1877. texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) +
  1878. texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) +
  1879. texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) +
  1880. texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) +
  1881. texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) )
  1882. ) * 0.2;
  1883. }
  1884. return mix( 1.0, shadow, shadowIntensity );
  1885. }
  1886. #elif defined( SHADOWMAP_TYPE_VSM )
  1887. float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
  1888. float shadow = 1.0;
  1889. shadowCoord.xyz /= shadowCoord.w;
  1890. shadowCoord.z += shadowBias;
  1891. bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
  1892. bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
  1893. if ( frustumTest ) {
  1894. vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg;
  1895. float mean = distribution.x;
  1896. float variance = distribution.y * distribution.y;
  1897. #ifdef USE_REVERSED_DEPTH_BUFFER
  1898. float hard_shadow = step( mean, shadowCoord.z );
  1899. #else
  1900. float hard_shadow = step( shadowCoord.z, mean );
  1901. #endif
  1902. if ( hard_shadow == 1.0 ) {
  1903. shadow = 1.0;
  1904. } else {
  1905. variance = max( variance, 0.0000001 );
  1906. float d = shadowCoord.z - mean;
  1907. float p_max = variance / ( variance + d * d );
  1908. p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 );
  1909. shadow = max( hard_shadow, p_max );
  1910. }
  1911. }
  1912. return mix( 1.0, shadow, shadowIntensity );
  1913. }
  1914. #else
  1915. float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
  1916. float shadow = 1.0;
  1917. shadowCoord.xyz /= shadowCoord.w;
  1918. shadowCoord.z += shadowBias;
  1919. bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
  1920. bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
  1921. if ( frustumTest ) {
  1922. float depth = texture2D( shadowMap, shadowCoord.xy ).r;
  1923. #ifdef USE_REVERSED_DEPTH_BUFFER
  1924. shadow = step( depth, shadowCoord.z );
  1925. #else
  1926. shadow = step( shadowCoord.z, depth );
  1927. #endif
  1928. }
  1929. return mix( 1.0, shadow, shadowIntensity );
  1930. }
  1931. #endif
  1932. #if NUM_POINT_LIGHT_SHADOWS > 0
  1933. #if defined( SHADOWMAP_TYPE_PCF )
  1934. float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
  1935. float shadow = 1.0;
  1936. vec3 lightToPosition = shadowCoord.xyz;
  1937. vec3 bd3D = normalize( lightToPosition );
  1938. vec3 absVec = abs( lightToPosition );
  1939. float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );
  1940. if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {
  1941. float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );
  1942. dp += shadowBias;
  1943. float texelSize = shadowRadius / shadowMapSize.x;
  1944. vec3 absDir = abs( bd3D );
  1945. vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 );
  1946. tangent = normalize( cross( bd3D, tangent ) );
  1947. vec3 bitangent = cross( bd3D, tangent );
  1948. float phi = interleavedGradientNoise( gl_FragCoord.xy ) * 6.28318530718;
  1949. shadow = (
  1950. texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 0, 5, phi ).x + bitangent * vogelDiskSample( 0, 5, phi ).y ) * texelSize, dp ) ) +
  1951. texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 1, 5, phi ).x + bitangent * vogelDiskSample( 1, 5, phi ).y ) * texelSize, dp ) ) +
  1952. texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 2, 5, phi ).x + bitangent * vogelDiskSample( 2, 5, phi ).y ) * texelSize, dp ) ) +
  1953. texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 3, 5, phi ).x + bitangent * vogelDiskSample( 3, 5, phi ).y ) * texelSize, dp ) ) +
  1954. texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 4, 5, phi ).x + bitangent * vogelDiskSample( 4, 5, phi ).y ) * texelSize, dp ) )
  1955. ) * 0.2;
  1956. }
  1957. return mix( 1.0, shadow, shadowIntensity );
  1958. }
  1959. #elif defined( SHADOWMAP_TYPE_BASIC )
  1960. float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
  1961. float shadow = 1.0;
  1962. vec3 lightToPosition = shadowCoord.xyz;
  1963. vec3 bd3D = normalize( lightToPosition );
  1964. vec3 absVec = abs( lightToPosition );
  1965. float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );
  1966. if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {
  1967. float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );
  1968. dp += shadowBias;
  1969. float depth = textureCube( shadowMap, bd3D ).r;
  1970. #ifdef USE_REVERSED_DEPTH_BUFFER
  1971. shadow = step( depth, dp );
  1972. #else
  1973. shadow = step( dp, depth );
  1974. #endif
  1975. }
  1976. return mix( 1.0, shadow, shadowIntensity );
  1977. }
  1978. #endif
  1979. #endif
  1980. #endif`,sOe=`#if NUM_SPOT_LIGHT_COORDS > 0
  1981. uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
  1982. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  1983. #endif
  1984. #ifdef USE_SHADOWMAP
  1985. #if NUM_DIR_LIGHT_SHADOWS > 0
  1986. uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
  1987. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  1988. struct DirectionalLightShadow {
  1989. float shadowIntensity;
  1990. float shadowBias;
  1991. float shadowNormalBias;
  1992. float shadowRadius;
  1993. vec2 shadowMapSize;
  1994. };
  1995. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  1996. #endif
  1997. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1998. struct SpotLightShadow {
  1999. float shadowIntensity;
  2000. float shadowBias;
  2001. float shadowNormalBias;
  2002. float shadowRadius;
  2003. vec2 shadowMapSize;
  2004. };
  2005. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  2006. #endif
  2007. #if NUM_POINT_LIGHT_SHADOWS > 0
  2008. uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
  2009. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  2010. struct PointLightShadow {
  2011. float shadowIntensity;
  2012. float shadowBias;
  2013. float shadowNormalBias;
  2014. float shadowRadius;
  2015. vec2 shadowMapSize;
  2016. float shadowCameraNear;
  2017. float shadowCameraFar;
  2018. };
  2019. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  2020. #endif
  2021. #endif`,oOe=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
  2022. vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  2023. vec4 shadowWorldPosition;
  2024. #endif
  2025. #if defined( USE_SHADOWMAP )
  2026. #if NUM_DIR_LIGHT_SHADOWS > 0
  2027. #pragma unroll_loop_start
  2028. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  2029. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
  2030. vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
  2031. }
  2032. #pragma unroll_loop_end
  2033. #endif
  2034. #if NUM_POINT_LIGHT_SHADOWS > 0
  2035. #pragma unroll_loop_start
  2036. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  2037. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
  2038. vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
  2039. }
  2040. #pragma unroll_loop_end
  2041. #endif
  2042. #endif
  2043. #if NUM_SPOT_LIGHT_COORDS > 0
  2044. #pragma unroll_loop_start
  2045. for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
  2046. shadowWorldPosition = worldPosition;
  2047. #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  2048. shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
  2049. #endif
  2050. vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
  2051. }
  2052. #pragma unroll_loop_end
  2053. #endif`,lOe=`float getShadowMask() {
  2054. float shadow = 1.0;
  2055. #ifdef USE_SHADOWMAP
  2056. #if NUM_DIR_LIGHT_SHADOWS > 0
  2057. DirectionalLightShadow directionalLight;
  2058. #pragma unroll_loop_start
  2059. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  2060. directionalLight = directionalLightShadows[ i ];
  2061. shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  2062. }
  2063. #pragma unroll_loop_end
  2064. #endif
  2065. #if NUM_SPOT_LIGHT_SHADOWS > 0
  2066. SpotLightShadow spotLight;
  2067. #pragma unroll_loop_start
  2068. for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
  2069. spotLight = spotLightShadows[ i ];
  2070. shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  2071. }
  2072. #pragma unroll_loop_end
  2073. #endif
  2074. #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )
  2075. PointLightShadow pointLight;
  2076. #pragma unroll_loop_start
  2077. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  2078. pointLight = pointLightShadows[ i ];
  2079. shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
  2080. }
  2081. #pragma unroll_loop_end
  2082. #endif
  2083. #endif
  2084. return shadow;
  2085. }`,cOe=`#ifdef USE_SKINNING
  2086. mat4 boneMatX = getBoneMatrix( skinIndex.x );
  2087. mat4 boneMatY = getBoneMatrix( skinIndex.y );
  2088. mat4 boneMatZ = getBoneMatrix( skinIndex.z );
  2089. mat4 boneMatW = getBoneMatrix( skinIndex.w );
  2090. #endif`,uOe=`#ifdef USE_SKINNING
  2091. uniform mat4 bindMatrix;
  2092. uniform mat4 bindMatrixInverse;
  2093. uniform highp sampler2D boneTexture;
  2094. mat4 getBoneMatrix( const in float i ) {
  2095. int size = textureSize( boneTexture, 0 ).x;
  2096. int j = int( i ) * 4;
  2097. int x = j % size;
  2098. int y = j / size;
  2099. vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
  2100. vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
  2101. vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
  2102. vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
  2103. return mat4( v1, v2, v3, v4 );
  2104. }
  2105. #endif`,dOe=`#ifdef USE_SKINNING
  2106. vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
  2107. vec4 skinned = vec4( 0.0 );
  2108. skinned += boneMatX * skinVertex * skinWeight.x;
  2109. skinned += boneMatY * skinVertex * skinWeight.y;
  2110. skinned += boneMatZ * skinVertex * skinWeight.z;
  2111. skinned += boneMatW * skinVertex * skinWeight.w;
  2112. transformed = ( bindMatrixInverse * skinned ).xyz;
  2113. #endif`,hOe=`#ifdef USE_SKINNING
  2114. mat4 skinMatrix = mat4( 0.0 );
  2115. skinMatrix += skinWeight.x * boneMatX;
  2116. skinMatrix += skinWeight.y * boneMatY;
  2117. skinMatrix += skinWeight.z * boneMatZ;
  2118. skinMatrix += skinWeight.w * boneMatW;
  2119. skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
  2120. objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
  2121. #ifdef USE_TANGENT
  2122. objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
  2123. #endif
  2124. #endif`,fOe=`float specularStrength;
  2125. #ifdef USE_SPECULARMAP
  2126. vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
  2127. specularStrength = texelSpecular.r;
  2128. #else
  2129. specularStrength = 1.0;
  2130. #endif`,mOe=`#ifdef USE_SPECULARMAP
  2131. uniform sampler2D specularMap;
  2132. #endif`,pOe=`#if defined( TONE_MAPPING )
  2133. gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
  2134. #endif`,gOe=`#ifndef saturate
  2135. #define saturate( a ) clamp( a, 0.0, 1.0 )
  2136. #endif
  2137. uniform float toneMappingExposure;
  2138. vec3 LinearToneMapping( vec3 color ) {
  2139. return saturate( toneMappingExposure * color );
  2140. }
  2141. vec3 ReinhardToneMapping( vec3 color ) {
  2142. color *= toneMappingExposure;
  2143. return saturate( color / ( vec3( 1.0 ) + color ) );
  2144. }
  2145. vec3 CineonToneMapping( vec3 color ) {
  2146. color *= toneMappingExposure;
  2147. color = max( vec3( 0.0 ), color - 0.004 );
  2148. return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
  2149. }
  2150. vec3 RRTAndODTFit( vec3 v ) {
  2151. vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
  2152. vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
  2153. return a / b;
  2154. }
  2155. vec3 ACESFilmicToneMapping( vec3 color ) {
  2156. const mat3 ACESInputMat = mat3(
  2157. vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
  2158. vec3( 0.04823, 0.01566, 0.83777 )
  2159. );
  2160. const mat3 ACESOutputMat = mat3(
  2161. vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
  2162. vec3( -0.07367, -0.00605, 1.07602 )
  2163. );
  2164. color *= toneMappingExposure / 0.6;
  2165. color = ACESInputMat * color;
  2166. color = RRTAndODTFit( color );
  2167. color = ACESOutputMat * color;
  2168. return saturate( color );
  2169. }
  2170. const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
  2171. vec3( 1.6605, - 0.1246, - 0.0182 ),
  2172. vec3( - 0.5876, 1.1329, - 0.1006 ),
  2173. vec3( - 0.0728, - 0.0083, 1.1187 )
  2174. );
  2175. const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
  2176. vec3( 0.6274, 0.0691, 0.0164 ),
  2177. vec3( 0.3293, 0.9195, 0.0880 ),
  2178. vec3( 0.0433, 0.0113, 0.8956 )
  2179. );
  2180. vec3 agxDefaultContrastApprox( vec3 x ) {
  2181. vec3 x2 = x * x;
  2182. vec3 x4 = x2 * x2;
  2183. return + 15.5 * x4 * x2
  2184. - 40.14 * x4 * x
  2185. + 31.96 * x4
  2186. - 6.868 * x2 * x
  2187. + 0.4298 * x2
  2188. + 0.1191 * x
  2189. - 0.00232;
  2190. }
  2191. vec3 AgXToneMapping( vec3 color ) {
  2192. const mat3 AgXInsetMatrix = mat3(
  2193. vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
  2194. vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
  2195. vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
  2196. );
  2197. const mat3 AgXOutsetMatrix = mat3(
  2198. vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
  2199. vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
  2200. vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
  2201. );
  2202. const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
  2203. color *= toneMappingExposure;
  2204. color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
  2205. color = AgXInsetMatrix * color;
  2206. color = max( color, 1e-10 ); color = log2( color );
  2207. color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
  2208. color = clamp( color, 0.0, 1.0 );
  2209. color = agxDefaultContrastApprox( color );
  2210. color = AgXOutsetMatrix * color;
  2211. color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
  2212. color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
  2213. color = clamp( color, 0.0, 1.0 );
  2214. return color;
  2215. }
  2216. vec3 NeutralToneMapping( vec3 color ) {
  2217. const float StartCompression = 0.8 - 0.04;
  2218. const float Desaturation = 0.15;
  2219. color *= toneMappingExposure;
  2220. float x = min( color.r, min( color.g, color.b ) );
  2221. float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
  2222. color -= offset;
  2223. float peak = max( color.r, max( color.g, color.b ) );
  2224. if ( peak < StartCompression ) return color;
  2225. float d = 1. - StartCompression;
  2226. float newPeak = 1. - d * d / ( peak + d - StartCompression );
  2227. color *= newPeak / peak;
  2228. float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
  2229. return mix( color, vec3( newPeak ), g );
  2230. }
  2231. vec3 CustomToneMapping( vec3 color ) { return color; }`,xOe=`#ifdef USE_TRANSMISSION
  2232. material.transmission = transmission;
  2233. material.transmissionAlpha = 1.0;
  2234. material.thickness = thickness;
  2235. material.attenuationDistance = attenuationDistance;
  2236. material.attenuationColor = attenuationColor;
  2237. #ifdef USE_TRANSMISSIONMAP
  2238. material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
  2239. #endif
  2240. #ifdef USE_THICKNESSMAP
  2241. material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
  2242. #endif
  2243. vec3 pos = vWorldPosition;
  2244. vec3 v = normalize( cameraPosition - pos );
  2245. vec3 n = inverseTransformDirection( normal, viewMatrix );
  2246. vec4 transmitted = getIBLVolumeRefraction(
  2247. n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90,
  2248. pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
  2249. material.attenuationColor, material.attenuationDistance );
  2250. material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
  2251. totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
  2252. #endif`,bOe=`#ifdef USE_TRANSMISSION
  2253. uniform float transmission;
  2254. uniform float thickness;
  2255. uniform float attenuationDistance;
  2256. uniform vec3 attenuationColor;
  2257. #ifdef USE_TRANSMISSIONMAP
  2258. uniform sampler2D transmissionMap;
  2259. #endif
  2260. #ifdef USE_THICKNESSMAP
  2261. uniform sampler2D thicknessMap;
  2262. #endif
  2263. uniform vec2 transmissionSamplerSize;
  2264. uniform sampler2D transmissionSamplerMap;
  2265. uniform mat4 modelMatrix;
  2266. uniform mat4 projectionMatrix;
  2267. varying vec3 vWorldPosition;
  2268. float w0( float a ) {
  2269. return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
  2270. }
  2271. float w1( float a ) {
  2272. return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
  2273. }
  2274. float w2( float a ){
  2275. return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
  2276. }
  2277. float w3( float a ) {
  2278. return ( 1.0 / 6.0 ) * ( a * a * a );
  2279. }
  2280. float g0( float a ) {
  2281. return w0( a ) + w1( a );
  2282. }
  2283. float g1( float a ) {
  2284. return w2( a ) + w3( a );
  2285. }
  2286. float h0( float a ) {
  2287. return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
  2288. }
  2289. float h1( float a ) {
  2290. return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
  2291. }
  2292. vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
  2293. uv = uv * texelSize.zw + 0.5;
  2294. vec2 iuv = floor( uv );
  2295. vec2 fuv = fract( uv );
  2296. float g0x = g0( fuv.x );
  2297. float g1x = g1( fuv.x );
  2298. float h0x = h0( fuv.x );
  2299. float h1x = h1( fuv.x );
  2300. float h0y = h0( fuv.y );
  2301. float h1y = h1( fuv.y );
  2302. vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  2303. vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  2304. vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  2305. vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  2306. return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
  2307. g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
  2308. }
  2309. vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
  2310. vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
  2311. vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
  2312. vec2 fLodSizeInv = 1.0 / fLodSize;
  2313. vec2 cLodSizeInv = 1.0 / cLodSize;
  2314. vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
  2315. vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
  2316. return mix( fSample, cSample, fract( lod ) );
  2317. }
  2318. vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
  2319. vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
  2320. vec3 modelScale;
  2321. modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
  2322. modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
  2323. modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
  2324. return normalize( refractionVector ) * thickness * modelScale;
  2325. }
  2326. float applyIorToRoughness( const in float roughness, const in float ior ) {
  2327. return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
  2328. }
  2329. vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
  2330. float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
  2331. return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
  2332. }
  2333. vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
  2334. if ( isinf( attenuationDistance ) ) {
  2335. return vec3( 1.0 );
  2336. } else {
  2337. vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
  2338. vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
  2339. }
  2340. }
  2341. vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
  2342. const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
  2343. const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
  2344. const in vec3 attenuationColor, const in float attenuationDistance ) {
  2345. vec4 transmittedLight;
  2346. vec3 transmittance;
  2347. #ifdef USE_DISPERSION
  2348. float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
  2349. vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
  2350. for ( int i = 0; i < 3; i ++ ) {
  2351. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
  2352. vec3 refractedRayExit = position + transmissionRay;
  2353. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  2354. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  2355. refractionCoords += 1.0;
  2356. refractionCoords /= 2.0;
  2357. vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
  2358. transmittedLight[ i ] = transmissionSample[ i ];
  2359. transmittedLight.a += transmissionSample.a;
  2360. transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
  2361. }
  2362. transmittedLight.a /= 3.0;
  2363. #else
  2364. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
  2365. vec3 refractedRayExit = position + transmissionRay;
  2366. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  2367. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  2368. refractionCoords += 1.0;
  2369. refractionCoords /= 2.0;
  2370. transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
  2371. transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
  2372. #endif
  2373. vec3 attenuatedColor = transmittance * transmittedLight.rgb;
  2374. vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
  2375. float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
  2376. return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
  2377. }
  2378. #endif`,yOe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2379. varying vec2 vUv;
  2380. #endif
  2381. #ifdef USE_MAP
  2382. varying vec2 vMapUv;
  2383. #endif
  2384. #ifdef USE_ALPHAMAP
  2385. varying vec2 vAlphaMapUv;
  2386. #endif
  2387. #ifdef USE_LIGHTMAP
  2388. varying vec2 vLightMapUv;
  2389. #endif
  2390. #ifdef USE_AOMAP
  2391. varying vec2 vAoMapUv;
  2392. #endif
  2393. #ifdef USE_BUMPMAP
  2394. varying vec2 vBumpMapUv;
  2395. #endif
  2396. #ifdef USE_NORMALMAP
  2397. varying vec2 vNormalMapUv;
  2398. #endif
  2399. #ifdef USE_EMISSIVEMAP
  2400. varying vec2 vEmissiveMapUv;
  2401. #endif
  2402. #ifdef USE_METALNESSMAP
  2403. varying vec2 vMetalnessMapUv;
  2404. #endif
  2405. #ifdef USE_ROUGHNESSMAP
  2406. varying vec2 vRoughnessMapUv;
  2407. #endif
  2408. #ifdef USE_ANISOTROPYMAP
  2409. varying vec2 vAnisotropyMapUv;
  2410. #endif
  2411. #ifdef USE_CLEARCOATMAP
  2412. varying vec2 vClearcoatMapUv;
  2413. #endif
  2414. #ifdef USE_CLEARCOAT_NORMALMAP
  2415. varying vec2 vClearcoatNormalMapUv;
  2416. #endif
  2417. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2418. varying vec2 vClearcoatRoughnessMapUv;
  2419. #endif
  2420. #ifdef USE_IRIDESCENCEMAP
  2421. varying vec2 vIridescenceMapUv;
  2422. #endif
  2423. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2424. varying vec2 vIridescenceThicknessMapUv;
  2425. #endif
  2426. #ifdef USE_SHEEN_COLORMAP
  2427. varying vec2 vSheenColorMapUv;
  2428. #endif
  2429. #ifdef USE_SHEEN_ROUGHNESSMAP
  2430. varying vec2 vSheenRoughnessMapUv;
  2431. #endif
  2432. #ifdef USE_SPECULARMAP
  2433. varying vec2 vSpecularMapUv;
  2434. #endif
  2435. #ifdef USE_SPECULAR_COLORMAP
  2436. varying vec2 vSpecularColorMapUv;
  2437. #endif
  2438. #ifdef USE_SPECULAR_INTENSITYMAP
  2439. varying vec2 vSpecularIntensityMapUv;
  2440. #endif
  2441. #ifdef USE_TRANSMISSIONMAP
  2442. uniform mat3 transmissionMapTransform;
  2443. varying vec2 vTransmissionMapUv;
  2444. #endif
  2445. #ifdef USE_THICKNESSMAP
  2446. uniform mat3 thicknessMapTransform;
  2447. varying vec2 vThicknessMapUv;
  2448. #endif`,vOe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2449. varying vec2 vUv;
  2450. #endif
  2451. #ifdef USE_MAP
  2452. uniform mat3 mapTransform;
  2453. varying vec2 vMapUv;
  2454. #endif
  2455. #ifdef USE_ALPHAMAP
  2456. uniform mat3 alphaMapTransform;
  2457. varying vec2 vAlphaMapUv;
  2458. #endif
  2459. #ifdef USE_LIGHTMAP
  2460. uniform mat3 lightMapTransform;
  2461. varying vec2 vLightMapUv;
  2462. #endif
  2463. #ifdef USE_AOMAP
  2464. uniform mat3 aoMapTransform;
  2465. varying vec2 vAoMapUv;
  2466. #endif
  2467. #ifdef USE_BUMPMAP
  2468. uniform mat3 bumpMapTransform;
  2469. varying vec2 vBumpMapUv;
  2470. #endif
  2471. #ifdef USE_NORMALMAP
  2472. uniform mat3 normalMapTransform;
  2473. varying vec2 vNormalMapUv;
  2474. #endif
  2475. #ifdef USE_DISPLACEMENTMAP
  2476. uniform mat3 displacementMapTransform;
  2477. varying vec2 vDisplacementMapUv;
  2478. #endif
  2479. #ifdef USE_EMISSIVEMAP
  2480. uniform mat3 emissiveMapTransform;
  2481. varying vec2 vEmissiveMapUv;
  2482. #endif
  2483. #ifdef USE_METALNESSMAP
  2484. uniform mat3 metalnessMapTransform;
  2485. varying vec2 vMetalnessMapUv;
  2486. #endif
  2487. #ifdef USE_ROUGHNESSMAP
  2488. uniform mat3 roughnessMapTransform;
  2489. varying vec2 vRoughnessMapUv;
  2490. #endif
  2491. #ifdef USE_ANISOTROPYMAP
  2492. uniform mat3 anisotropyMapTransform;
  2493. varying vec2 vAnisotropyMapUv;
  2494. #endif
  2495. #ifdef USE_CLEARCOATMAP
  2496. uniform mat3 clearcoatMapTransform;
  2497. varying vec2 vClearcoatMapUv;
  2498. #endif
  2499. #ifdef USE_CLEARCOAT_NORMALMAP
  2500. uniform mat3 clearcoatNormalMapTransform;
  2501. varying vec2 vClearcoatNormalMapUv;
  2502. #endif
  2503. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2504. uniform mat3 clearcoatRoughnessMapTransform;
  2505. varying vec2 vClearcoatRoughnessMapUv;
  2506. #endif
  2507. #ifdef USE_SHEEN_COLORMAP
  2508. uniform mat3 sheenColorMapTransform;
  2509. varying vec2 vSheenColorMapUv;
  2510. #endif
  2511. #ifdef USE_SHEEN_ROUGHNESSMAP
  2512. uniform mat3 sheenRoughnessMapTransform;
  2513. varying vec2 vSheenRoughnessMapUv;
  2514. #endif
  2515. #ifdef USE_IRIDESCENCEMAP
  2516. uniform mat3 iridescenceMapTransform;
  2517. varying vec2 vIridescenceMapUv;
  2518. #endif
  2519. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2520. uniform mat3 iridescenceThicknessMapTransform;
  2521. varying vec2 vIridescenceThicknessMapUv;
  2522. #endif
  2523. #ifdef USE_SPECULARMAP
  2524. uniform mat3 specularMapTransform;
  2525. varying vec2 vSpecularMapUv;
  2526. #endif
  2527. #ifdef USE_SPECULAR_COLORMAP
  2528. uniform mat3 specularColorMapTransform;
  2529. varying vec2 vSpecularColorMapUv;
  2530. #endif
  2531. #ifdef USE_SPECULAR_INTENSITYMAP
  2532. uniform mat3 specularIntensityMapTransform;
  2533. varying vec2 vSpecularIntensityMapUv;
  2534. #endif
  2535. #ifdef USE_TRANSMISSIONMAP
  2536. uniform mat3 transmissionMapTransform;
  2537. varying vec2 vTransmissionMapUv;
  2538. #endif
  2539. #ifdef USE_THICKNESSMAP
  2540. uniform mat3 thicknessMapTransform;
  2541. varying vec2 vThicknessMapUv;
  2542. #endif`,_Oe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2543. vUv = vec3( uv, 1 ).xy;
  2544. #endif
  2545. #ifdef USE_MAP
  2546. vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
  2547. #endif
  2548. #ifdef USE_ALPHAMAP
  2549. vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
  2550. #endif
  2551. #ifdef USE_LIGHTMAP
  2552. vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
  2553. #endif
  2554. #ifdef USE_AOMAP
  2555. vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
  2556. #endif
  2557. #ifdef USE_BUMPMAP
  2558. vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
  2559. #endif
  2560. #ifdef USE_NORMALMAP
  2561. vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
  2562. #endif
  2563. #ifdef USE_DISPLACEMENTMAP
  2564. vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
  2565. #endif
  2566. #ifdef USE_EMISSIVEMAP
  2567. vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
  2568. #endif
  2569. #ifdef USE_METALNESSMAP
  2570. vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
  2571. #endif
  2572. #ifdef USE_ROUGHNESSMAP
  2573. vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
  2574. #endif
  2575. #ifdef USE_ANISOTROPYMAP
  2576. vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
  2577. #endif
  2578. #ifdef USE_CLEARCOATMAP
  2579. vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
  2580. #endif
  2581. #ifdef USE_CLEARCOAT_NORMALMAP
  2582. vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
  2583. #endif
  2584. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2585. vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
  2586. #endif
  2587. #ifdef USE_IRIDESCENCEMAP
  2588. vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
  2589. #endif
  2590. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2591. vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
  2592. #endif
  2593. #ifdef USE_SHEEN_COLORMAP
  2594. vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
  2595. #endif
  2596. #ifdef USE_SHEEN_ROUGHNESSMAP
  2597. vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
  2598. #endif
  2599. #ifdef USE_SPECULARMAP
  2600. vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
  2601. #endif
  2602. #ifdef USE_SPECULAR_COLORMAP
  2603. vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
  2604. #endif
  2605. #ifdef USE_SPECULAR_INTENSITYMAP
  2606. vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
  2607. #endif
  2608. #ifdef USE_TRANSMISSIONMAP
  2609. vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
  2610. #endif
  2611. #ifdef USE_THICKNESSMAP
  2612. vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
  2613. #endif`,wOe=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
  2614. vec4 worldPosition = vec4( transformed, 1.0 );
  2615. #ifdef USE_BATCHING
  2616. worldPosition = batchingMatrix * worldPosition;
  2617. #endif
  2618. #ifdef USE_INSTANCING
  2619. worldPosition = instanceMatrix * worldPosition;
  2620. #endif
  2621. worldPosition = modelMatrix * worldPosition;
  2622. #endif`;const SOe=`varying vec2 vUv;
  2623. uniform mat3 uvTransform;
  2624. void main() {
  2625. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  2626. gl_Position = vec4( position.xy, 1.0, 1.0 );
  2627. }`,MOe=`uniform sampler2D t2D;
  2628. uniform float backgroundIntensity;
  2629. varying vec2 vUv;
  2630. void main() {
  2631. vec4 texColor = texture2D( t2D, vUv );
  2632. #ifdef DECODE_VIDEO_TEXTURE
  2633. 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 );
  2634. #endif
  2635. texColor.rgb *= backgroundIntensity;
  2636. gl_FragColor = texColor;
  2637. #include <tonemapping_fragment>
  2638. #include <colorspace_fragment>
  2639. }`,EOe=`varying vec3 vWorldDirection;
  2640. #include <common>
  2641. void main() {
  2642. vWorldDirection = transformDirection( position, modelMatrix );
  2643. #include <begin_vertex>
  2644. #include <project_vertex>
  2645. gl_Position.z = gl_Position.w;
  2646. }`,NOe=`#ifdef ENVMAP_TYPE_CUBE
  2647. uniform samplerCube envMap;
  2648. #elif defined( ENVMAP_TYPE_CUBE_UV )
  2649. uniform sampler2D envMap;
  2650. #endif
  2651. uniform float flipEnvMap;
  2652. uniform float backgroundBlurriness;
  2653. uniform float backgroundIntensity;
  2654. uniform mat3 backgroundRotation;
  2655. varying vec3 vWorldDirection;
  2656. #include <cube_uv_reflection_fragment>
  2657. void main() {
  2658. #ifdef ENVMAP_TYPE_CUBE
  2659. vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
  2660. #elif defined( ENVMAP_TYPE_CUBE_UV )
  2661. vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
  2662. #else
  2663. vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  2664. #endif
  2665. texColor.rgb *= backgroundIntensity;
  2666. gl_FragColor = texColor;
  2667. #include <tonemapping_fragment>
  2668. #include <colorspace_fragment>
  2669. }`,AOe=`varying vec3 vWorldDirection;
  2670. #include <common>
  2671. void main() {
  2672. vWorldDirection = transformDirection( position, modelMatrix );
  2673. #include <begin_vertex>
  2674. #include <project_vertex>
  2675. gl_Position.z = gl_Position.w;
  2676. }`,TOe=`uniform samplerCube tCube;
  2677. uniform float tFlip;
  2678. uniform float opacity;
  2679. varying vec3 vWorldDirection;
  2680. void main() {
  2681. vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
  2682. gl_FragColor = texColor;
  2683. gl_FragColor.a *= opacity;
  2684. #include <tonemapping_fragment>
  2685. #include <colorspace_fragment>
  2686. }`,COe=`#include <common>
  2687. #include <batching_pars_vertex>
  2688. #include <uv_pars_vertex>
  2689. #include <displacementmap_pars_vertex>
  2690. #include <morphtarget_pars_vertex>
  2691. #include <skinning_pars_vertex>
  2692. #include <logdepthbuf_pars_vertex>
  2693. #include <clipping_planes_pars_vertex>
  2694. varying vec2 vHighPrecisionZW;
  2695. void main() {
  2696. #include <uv_vertex>
  2697. #include <batching_vertex>
  2698. #include <skinbase_vertex>
  2699. #include <morphinstance_vertex>
  2700. #ifdef USE_DISPLACEMENTMAP
  2701. #include <beginnormal_vertex>
  2702. #include <morphnormal_vertex>
  2703. #include <skinnormal_vertex>
  2704. #endif
  2705. #include <begin_vertex>
  2706. #include <morphtarget_vertex>
  2707. #include <skinning_vertex>
  2708. #include <displacementmap_vertex>
  2709. #include <project_vertex>
  2710. #include <logdepthbuf_vertex>
  2711. #include <clipping_planes_vertex>
  2712. vHighPrecisionZW = gl_Position.zw;
  2713. }`,kOe=`#if DEPTH_PACKING == 3200
  2714. uniform float opacity;
  2715. #endif
  2716. #include <common>
  2717. #include <packing>
  2718. #include <uv_pars_fragment>
  2719. #include <map_pars_fragment>
  2720. #include <alphamap_pars_fragment>
  2721. #include <alphatest_pars_fragment>
  2722. #include <alphahash_pars_fragment>
  2723. #include <logdepthbuf_pars_fragment>
  2724. #include <clipping_planes_pars_fragment>
  2725. varying vec2 vHighPrecisionZW;
  2726. void main() {
  2727. vec4 diffuseColor = vec4( 1.0 );
  2728. #include <clipping_planes_fragment>
  2729. #if DEPTH_PACKING == 3200
  2730. diffuseColor.a = opacity;
  2731. #endif
  2732. #include <map_fragment>
  2733. #include <alphamap_fragment>
  2734. #include <alphatest_fragment>
  2735. #include <alphahash_fragment>
  2736. #include <logdepthbuf_fragment>
  2737. #ifdef USE_REVERSED_DEPTH_BUFFER
  2738. float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
  2739. #else
  2740. float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
  2741. #endif
  2742. #if DEPTH_PACKING == 3200
  2743. gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
  2744. #elif DEPTH_PACKING == 3201
  2745. gl_FragColor = packDepthToRGBA( fragCoordZ );
  2746. #elif DEPTH_PACKING == 3202
  2747. gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
  2748. #elif DEPTH_PACKING == 3203
  2749. gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
  2750. #endif
  2751. }`,jOe=`#define DISTANCE
  2752. varying vec3 vWorldPosition;
  2753. #include <common>
  2754. #include <batching_pars_vertex>
  2755. #include <uv_pars_vertex>
  2756. #include <displacementmap_pars_vertex>
  2757. #include <morphtarget_pars_vertex>
  2758. #include <skinning_pars_vertex>
  2759. #include <clipping_planes_pars_vertex>
  2760. void main() {
  2761. #include <uv_vertex>
  2762. #include <batching_vertex>
  2763. #include <skinbase_vertex>
  2764. #include <morphinstance_vertex>
  2765. #ifdef USE_DISPLACEMENTMAP
  2766. #include <beginnormal_vertex>
  2767. #include <morphnormal_vertex>
  2768. #include <skinnormal_vertex>
  2769. #endif
  2770. #include <begin_vertex>
  2771. #include <morphtarget_vertex>
  2772. #include <skinning_vertex>
  2773. #include <displacementmap_vertex>
  2774. #include <project_vertex>
  2775. #include <worldpos_vertex>
  2776. #include <clipping_planes_vertex>
  2777. vWorldPosition = worldPosition.xyz;
  2778. }`,POe=`#define DISTANCE
  2779. uniform vec3 referencePosition;
  2780. uniform float nearDistance;
  2781. uniform float farDistance;
  2782. varying vec3 vWorldPosition;
  2783. #include <common>
  2784. #include <uv_pars_fragment>
  2785. #include <map_pars_fragment>
  2786. #include <alphamap_pars_fragment>
  2787. #include <alphatest_pars_fragment>
  2788. #include <alphahash_pars_fragment>
  2789. #include <clipping_planes_pars_fragment>
  2790. void main () {
  2791. vec4 diffuseColor = vec4( 1.0 );
  2792. #include <clipping_planes_fragment>
  2793. #include <map_fragment>
  2794. #include <alphamap_fragment>
  2795. #include <alphatest_fragment>
  2796. #include <alphahash_fragment>
  2797. float dist = length( vWorldPosition - referencePosition );
  2798. dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
  2799. dist = saturate( dist );
  2800. gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );
  2801. }`,ROe=`varying vec3 vWorldDirection;
  2802. #include <common>
  2803. void main() {
  2804. vWorldDirection = transformDirection( position, modelMatrix );
  2805. #include <begin_vertex>
  2806. #include <project_vertex>
  2807. }`,DOe=`uniform sampler2D tEquirect;
  2808. varying vec3 vWorldDirection;
  2809. #include <common>
  2810. void main() {
  2811. vec3 direction = normalize( vWorldDirection );
  2812. vec2 sampleUV = equirectUv( direction );
  2813. gl_FragColor = texture2D( tEquirect, sampleUV );
  2814. #include <tonemapping_fragment>
  2815. #include <colorspace_fragment>
  2816. }`,OOe=`uniform float scale;
  2817. attribute float lineDistance;
  2818. varying float vLineDistance;
  2819. #include <common>
  2820. #include <uv_pars_vertex>
  2821. #include <color_pars_vertex>
  2822. #include <fog_pars_vertex>
  2823. #include <morphtarget_pars_vertex>
  2824. #include <logdepthbuf_pars_vertex>
  2825. #include <clipping_planes_pars_vertex>
  2826. void main() {
  2827. vLineDistance = scale * lineDistance;
  2828. #include <uv_vertex>
  2829. #include <color_vertex>
  2830. #include <morphinstance_vertex>
  2831. #include <morphcolor_vertex>
  2832. #include <begin_vertex>
  2833. #include <morphtarget_vertex>
  2834. #include <project_vertex>
  2835. #include <logdepthbuf_vertex>
  2836. #include <clipping_planes_vertex>
  2837. #include <fog_vertex>
  2838. }`,LOe=`uniform vec3 diffuse;
  2839. uniform float opacity;
  2840. uniform float dashSize;
  2841. uniform float totalSize;
  2842. varying float vLineDistance;
  2843. #include <common>
  2844. #include <color_pars_fragment>
  2845. #include <uv_pars_fragment>
  2846. #include <map_pars_fragment>
  2847. #include <fog_pars_fragment>
  2848. #include <logdepthbuf_pars_fragment>
  2849. #include <clipping_planes_pars_fragment>
  2850. void main() {
  2851. vec4 diffuseColor = vec4( diffuse, opacity );
  2852. #include <clipping_planes_fragment>
  2853. if ( mod( vLineDistance, totalSize ) > dashSize ) {
  2854. discard;
  2855. }
  2856. vec3 outgoingLight = vec3( 0.0 );
  2857. #include <logdepthbuf_fragment>
  2858. #include <map_fragment>
  2859. #include <color_fragment>
  2860. outgoingLight = diffuseColor.rgb;
  2861. #include <opaque_fragment>
  2862. #include <tonemapping_fragment>
  2863. #include <colorspace_fragment>
  2864. #include <fog_fragment>
  2865. #include <premultiplied_alpha_fragment>
  2866. }`,IOe=`#include <common>
  2867. #include <batching_pars_vertex>
  2868. #include <uv_pars_vertex>
  2869. #include <envmap_pars_vertex>
  2870. #include <color_pars_vertex>
  2871. #include <fog_pars_vertex>
  2872. #include <morphtarget_pars_vertex>
  2873. #include <skinning_pars_vertex>
  2874. #include <logdepthbuf_pars_vertex>
  2875. #include <clipping_planes_pars_vertex>
  2876. void main() {
  2877. #include <uv_vertex>
  2878. #include <color_vertex>
  2879. #include <morphinstance_vertex>
  2880. #include <morphcolor_vertex>
  2881. #include <batching_vertex>
  2882. #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
  2883. #include <beginnormal_vertex>
  2884. #include <morphnormal_vertex>
  2885. #include <skinbase_vertex>
  2886. #include <skinnormal_vertex>
  2887. #include <defaultnormal_vertex>
  2888. #endif
  2889. #include <begin_vertex>
  2890. #include <morphtarget_vertex>
  2891. #include <skinning_vertex>
  2892. #include <project_vertex>
  2893. #include <logdepthbuf_vertex>
  2894. #include <clipping_planes_vertex>
  2895. #include <worldpos_vertex>
  2896. #include <envmap_vertex>
  2897. #include <fog_vertex>
  2898. }`,FOe=`uniform vec3 diffuse;
  2899. uniform float opacity;
  2900. #ifndef FLAT_SHADED
  2901. varying vec3 vNormal;
  2902. #endif
  2903. #include <common>
  2904. #include <dithering_pars_fragment>
  2905. #include <color_pars_fragment>
  2906. #include <uv_pars_fragment>
  2907. #include <map_pars_fragment>
  2908. #include <alphamap_pars_fragment>
  2909. #include <alphatest_pars_fragment>
  2910. #include <alphahash_pars_fragment>
  2911. #include <aomap_pars_fragment>
  2912. #include <lightmap_pars_fragment>
  2913. #include <envmap_common_pars_fragment>
  2914. #include <envmap_pars_fragment>
  2915. #include <fog_pars_fragment>
  2916. #include <specularmap_pars_fragment>
  2917. #include <logdepthbuf_pars_fragment>
  2918. #include <clipping_planes_pars_fragment>
  2919. void main() {
  2920. vec4 diffuseColor = vec4( diffuse, opacity );
  2921. #include <clipping_planes_fragment>
  2922. #include <logdepthbuf_fragment>
  2923. #include <map_fragment>
  2924. #include <color_fragment>
  2925. #include <alphamap_fragment>
  2926. #include <alphatest_fragment>
  2927. #include <alphahash_fragment>
  2928. #include <specularmap_fragment>
  2929. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2930. #ifdef USE_LIGHTMAP
  2931. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  2932. reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
  2933. #else
  2934. reflectedLight.indirectDiffuse += vec3( 1.0 );
  2935. #endif
  2936. #include <aomap_fragment>
  2937. reflectedLight.indirectDiffuse *= diffuseColor.rgb;
  2938. vec3 outgoingLight = reflectedLight.indirectDiffuse;
  2939. #include <envmap_fragment>
  2940. #include <opaque_fragment>
  2941. #include <tonemapping_fragment>
  2942. #include <colorspace_fragment>
  2943. #include <fog_fragment>
  2944. #include <premultiplied_alpha_fragment>
  2945. #include <dithering_fragment>
  2946. }`,UOe=`#define LAMBERT
  2947. varying vec3 vViewPosition;
  2948. #include <common>
  2949. #include <batching_pars_vertex>
  2950. #include <uv_pars_vertex>
  2951. #include <displacementmap_pars_vertex>
  2952. #include <envmap_pars_vertex>
  2953. #include <color_pars_vertex>
  2954. #include <fog_pars_vertex>
  2955. #include <normal_pars_vertex>
  2956. #include <morphtarget_pars_vertex>
  2957. #include <skinning_pars_vertex>
  2958. #include <shadowmap_pars_vertex>
  2959. #include <logdepthbuf_pars_vertex>
  2960. #include <clipping_planes_pars_vertex>
  2961. void main() {
  2962. #include <uv_vertex>
  2963. #include <color_vertex>
  2964. #include <morphinstance_vertex>
  2965. #include <morphcolor_vertex>
  2966. #include <batching_vertex>
  2967. #include <beginnormal_vertex>
  2968. #include <morphnormal_vertex>
  2969. #include <skinbase_vertex>
  2970. #include <skinnormal_vertex>
  2971. #include <defaultnormal_vertex>
  2972. #include <normal_vertex>
  2973. #include <begin_vertex>
  2974. #include <morphtarget_vertex>
  2975. #include <skinning_vertex>
  2976. #include <displacementmap_vertex>
  2977. #include <project_vertex>
  2978. #include <logdepthbuf_vertex>
  2979. #include <clipping_planes_vertex>
  2980. vViewPosition = - mvPosition.xyz;
  2981. #include <worldpos_vertex>
  2982. #include <envmap_vertex>
  2983. #include <shadowmap_vertex>
  2984. #include <fog_vertex>
  2985. }`,zOe=`#define LAMBERT
  2986. uniform vec3 diffuse;
  2987. uniform vec3 emissive;
  2988. uniform float opacity;
  2989. #include <common>
  2990. #include <dithering_pars_fragment>
  2991. #include <color_pars_fragment>
  2992. #include <uv_pars_fragment>
  2993. #include <map_pars_fragment>
  2994. #include <alphamap_pars_fragment>
  2995. #include <alphatest_pars_fragment>
  2996. #include <alphahash_pars_fragment>
  2997. #include <aomap_pars_fragment>
  2998. #include <lightmap_pars_fragment>
  2999. #include <emissivemap_pars_fragment>
  3000. #include <envmap_common_pars_fragment>
  3001. #include <envmap_pars_fragment>
  3002. #include <fog_pars_fragment>
  3003. #include <bsdfs>
  3004. #include <lights_pars_begin>
  3005. #include <normal_pars_fragment>
  3006. #include <lights_lambert_pars_fragment>
  3007. #include <shadowmap_pars_fragment>
  3008. #include <bumpmap_pars_fragment>
  3009. #include <normalmap_pars_fragment>
  3010. #include <specularmap_pars_fragment>
  3011. #include <logdepthbuf_pars_fragment>
  3012. #include <clipping_planes_pars_fragment>
  3013. void main() {
  3014. vec4 diffuseColor = vec4( diffuse, opacity );
  3015. #include <clipping_planes_fragment>
  3016. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3017. vec3 totalEmissiveRadiance = emissive;
  3018. #include <logdepthbuf_fragment>
  3019. #include <map_fragment>
  3020. #include <color_fragment>
  3021. #include <alphamap_fragment>
  3022. #include <alphatest_fragment>
  3023. #include <alphahash_fragment>
  3024. #include <specularmap_fragment>
  3025. #include <normal_fragment_begin>
  3026. #include <normal_fragment_maps>
  3027. #include <emissivemap_fragment>
  3028. #include <lights_lambert_fragment>
  3029. #include <lights_fragment_begin>
  3030. #include <lights_fragment_maps>
  3031. #include <lights_fragment_end>
  3032. #include <aomap_fragment>
  3033. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  3034. #include <envmap_fragment>
  3035. #include <opaque_fragment>
  3036. #include <tonemapping_fragment>
  3037. #include <colorspace_fragment>
  3038. #include <fog_fragment>
  3039. #include <premultiplied_alpha_fragment>
  3040. #include <dithering_fragment>
  3041. }`,BOe=`#define MATCAP
  3042. varying vec3 vViewPosition;
  3043. #include <common>
  3044. #include <batching_pars_vertex>
  3045. #include <uv_pars_vertex>
  3046. #include <color_pars_vertex>
  3047. #include <displacementmap_pars_vertex>
  3048. #include <fog_pars_vertex>
  3049. #include <normal_pars_vertex>
  3050. #include <morphtarget_pars_vertex>
  3051. #include <skinning_pars_vertex>
  3052. #include <logdepthbuf_pars_vertex>
  3053. #include <clipping_planes_pars_vertex>
  3054. void main() {
  3055. #include <uv_vertex>
  3056. #include <color_vertex>
  3057. #include <morphinstance_vertex>
  3058. #include <morphcolor_vertex>
  3059. #include <batching_vertex>
  3060. #include <beginnormal_vertex>
  3061. #include <morphnormal_vertex>
  3062. #include <skinbase_vertex>
  3063. #include <skinnormal_vertex>
  3064. #include <defaultnormal_vertex>
  3065. #include <normal_vertex>
  3066. #include <begin_vertex>
  3067. #include <morphtarget_vertex>
  3068. #include <skinning_vertex>
  3069. #include <displacementmap_vertex>
  3070. #include <project_vertex>
  3071. #include <logdepthbuf_vertex>
  3072. #include <clipping_planes_vertex>
  3073. #include <fog_vertex>
  3074. vViewPosition = - mvPosition.xyz;
  3075. }`,$Oe=`#define MATCAP
  3076. uniform vec3 diffuse;
  3077. uniform float opacity;
  3078. uniform sampler2D matcap;
  3079. varying vec3 vViewPosition;
  3080. #include <common>
  3081. #include <dithering_pars_fragment>
  3082. #include <color_pars_fragment>
  3083. #include <uv_pars_fragment>
  3084. #include <map_pars_fragment>
  3085. #include <alphamap_pars_fragment>
  3086. #include <alphatest_pars_fragment>
  3087. #include <alphahash_pars_fragment>
  3088. #include <fog_pars_fragment>
  3089. #include <normal_pars_fragment>
  3090. #include <bumpmap_pars_fragment>
  3091. #include <normalmap_pars_fragment>
  3092. #include <logdepthbuf_pars_fragment>
  3093. #include <clipping_planes_pars_fragment>
  3094. void main() {
  3095. vec4 diffuseColor = vec4( diffuse, opacity );
  3096. #include <clipping_planes_fragment>
  3097. #include <logdepthbuf_fragment>
  3098. #include <map_fragment>
  3099. #include <color_fragment>
  3100. #include <alphamap_fragment>
  3101. #include <alphatest_fragment>
  3102. #include <alphahash_fragment>
  3103. #include <normal_fragment_begin>
  3104. #include <normal_fragment_maps>
  3105. vec3 viewDir = normalize( vViewPosition );
  3106. vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
  3107. vec3 y = cross( viewDir, x );
  3108. vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
  3109. #ifdef USE_MATCAP
  3110. vec4 matcapColor = texture2D( matcap, uv );
  3111. #else
  3112. vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
  3113. #endif
  3114. vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
  3115. #include <opaque_fragment>
  3116. #include <tonemapping_fragment>
  3117. #include <colorspace_fragment>
  3118. #include <fog_fragment>
  3119. #include <premultiplied_alpha_fragment>
  3120. #include <dithering_fragment>
  3121. }`,HOe=`#define NORMAL
  3122. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3123. varying vec3 vViewPosition;
  3124. #endif
  3125. #include <common>
  3126. #include <batching_pars_vertex>
  3127. #include <uv_pars_vertex>
  3128. #include <displacementmap_pars_vertex>
  3129. #include <normal_pars_vertex>
  3130. #include <morphtarget_pars_vertex>
  3131. #include <skinning_pars_vertex>
  3132. #include <logdepthbuf_pars_vertex>
  3133. #include <clipping_planes_pars_vertex>
  3134. void main() {
  3135. #include <uv_vertex>
  3136. #include <batching_vertex>
  3137. #include <beginnormal_vertex>
  3138. #include <morphinstance_vertex>
  3139. #include <morphnormal_vertex>
  3140. #include <skinbase_vertex>
  3141. #include <skinnormal_vertex>
  3142. #include <defaultnormal_vertex>
  3143. #include <normal_vertex>
  3144. #include <begin_vertex>
  3145. #include <morphtarget_vertex>
  3146. #include <skinning_vertex>
  3147. #include <displacementmap_vertex>
  3148. #include <project_vertex>
  3149. #include <logdepthbuf_vertex>
  3150. #include <clipping_planes_vertex>
  3151. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3152. vViewPosition = - mvPosition.xyz;
  3153. #endif
  3154. }`,VOe=`#define NORMAL
  3155. uniform float opacity;
  3156. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3157. varying vec3 vViewPosition;
  3158. #endif
  3159. #include <uv_pars_fragment>
  3160. #include <normal_pars_fragment>
  3161. #include <bumpmap_pars_fragment>
  3162. #include <normalmap_pars_fragment>
  3163. #include <logdepthbuf_pars_fragment>
  3164. #include <clipping_planes_pars_fragment>
  3165. void main() {
  3166. vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
  3167. #include <clipping_planes_fragment>
  3168. #include <logdepthbuf_fragment>
  3169. #include <normal_fragment_begin>
  3170. #include <normal_fragment_maps>
  3171. gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a );
  3172. #ifdef OPAQUE
  3173. gl_FragColor.a = 1.0;
  3174. #endif
  3175. }`,GOe=`#define PHONG
  3176. varying vec3 vViewPosition;
  3177. #include <common>
  3178. #include <batching_pars_vertex>
  3179. #include <uv_pars_vertex>
  3180. #include <displacementmap_pars_vertex>
  3181. #include <envmap_pars_vertex>
  3182. #include <color_pars_vertex>
  3183. #include <fog_pars_vertex>
  3184. #include <normal_pars_vertex>
  3185. #include <morphtarget_pars_vertex>
  3186. #include <skinning_pars_vertex>
  3187. #include <shadowmap_pars_vertex>
  3188. #include <logdepthbuf_pars_vertex>
  3189. #include <clipping_planes_pars_vertex>
  3190. void main() {
  3191. #include <uv_vertex>
  3192. #include <color_vertex>
  3193. #include <morphcolor_vertex>
  3194. #include <batching_vertex>
  3195. #include <beginnormal_vertex>
  3196. #include <morphinstance_vertex>
  3197. #include <morphnormal_vertex>
  3198. #include <skinbase_vertex>
  3199. #include <skinnormal_vertex>
  3200. #include <defaultnormal_vertex>
  3201. #include <normal_vertex>
  3202. #include <begin_vertex>
  3203. #include <morphtarget_vertex>
  3204. #include <skinning_vertex>
  3205. #include <displacementmap_vertex>
  3206. #include <project_vertex>
  3207. #include <logdepthbuf_vertex>
  3208. #include <clipping_planes_vertex>
  3209. vViewPosition = - mvPosition.xyz;
  3210. #include <worldpos_vertex>
  3211. #include <envmap_vertex>
  3212. #include <shadowmap_vertex>
  3213. #include <fog_vertex>
  3214. }`,WOe=`#define PHONG
  3215. uniform vec3 diffuse;
  3216. uniform vec3 emissive;
  3217. uniform vec3 specular;
  3218. uniform float shininess;
  3219. uniform float opacity;
  3220. #include <common>
  3221. #include <dithering_pars_fragment>
  3222. #include <color_pars_fragment>
  3223. #include <uv_pars_fragment>
  3224. #include <map_pars_fragment>
  3225. #include <alphamap_pars_fragment>
  3226. #include <alphatest_pars_fragment>
  3227. #include <alphahash_pars_fragment>
  3228. #include <aomap_pars_fragment>
  3229. #include <lightmap_pars_fragment>
  3230. #include <emissivemap_pars_fragment>
  3231. #include <envmap_common_pars_fragment>
  3232. #include <envmap_pars_fragment>
  3233. #include <fog_pars_fragment>
  3234. #include <bsdfs>
  3235. #include <lights_pars_begin>
  3236. #include <normal_pars_fragment>
  3237. #include <lights_phong_pars_fragment>
  3238. #include <shadowmap_pars_fragment>
  3239. #include <bumpmap_pars_fragment>
  3240. #include <normalmap_pars_fragment>
  3241. #include <specularmap_pars_fragment>
  3242. #include <logdepthbuf_pars_fragment>
  3243. #include <clipping_planes_pars_fragment>
  3244. void main() {
  3245. vec4 diffuseColor = vec4( diffuse, opacity );
  3246. #include <clipping_planes_fragment>
  3247. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3248. vec3 totalEmissiveRadiance = emissive;
  3249. #include <logdepthbuf_fragment>
  3250. #include <map_fragment>
  3251. #include <color_fragment>
  3252. #include <alphamap_fragment>
  3253. #include <alphatest_fragment>
  3254. #include <alphahash_fragment>
  3255. #include <specularmap_fragment>
  3256. #include <normal_fragment_begin>
  3257. #include <normal_fragment_maps>
  3258. #include <emissivemap_fragment>
  3259. #include <lights_phong_fragment>
  3260. #include <lights_fragment_begin>
  3261. #include <lights_fragment_maps>
  3262. #include <lights_fragment_end>
  3263. #include <aomap_fragment>
  3264. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
  3265. #include <envmap_fragment>
  3266. #include <opaque_fragment>
  3267. #include <tonemapping_fragment>
  3268. #include <colorspace_fragment>
  3269. #include <fog_fragment>
  3270. #include <premultiplied_alpha_fragment>
  3271. #include <dithering_fragment>
  3272. }`,qOe=`#define STANDARD
  3273. varying vec3 vViewPosition;
  3274. #ifdef USE_TRANSMISSION
  3275. varying vec3 vWorldPosition;
  3276. #endif
  3277. #include <common>
  3278. #include <batching_pars_vertex>
  3279. #include <uv_pars_vertex>
  3280. #include <displacementmap_pars_vertex>
  3281. #include <color_pars_vertex>
  3282. #include <fog_pars_vertex>
  3283. #include <normal_pars_vertex>
  3284. #include <morphtarget_pars_vertex>
  3285. #include <skinning_pars_vertex>
  3286. #include <shadowmap_pars_vertex>
  3287. #include <logdepthbuf_pars_vertex>
  3288. #include <clipping_planes_pars_vertex>
  3289. void main() {
  3290. #include <uv_vertex>
  3291. #include <color_vertex>
  3292. #include <morphinstance_vertex>
  3293. #include <morphcolor_vertex>
  3294. #include <batching_vertex>
  3295. #include <beginnormal_vertex>
  3296. #include <morphnormal_vertex>
  3297. #include <skinbase_vertex>
  3298. #include <skinnormal_vertex>
  3299. #include <defaultnormal_vertex>
  3300. #include <normal_vertex>
  3301. #include <begin_vertex>
  3302. #include <morphtarget_vertex>
  3303. #include <skinning_vertex>
  3304. #include <displacementmap_vertex>
  3305. #include <project_vertex>
  3306. #include <logdepthbuf_vertex>
  3307. #include <clipping_planes_vertex>
  3308. vViewPosition = - mvPosition.xyz;
  3309. #include <worldpos_vertex>
  3310. #include <shadowmap_vertex>
  3311. #include <fog_vertex>
  3312. #ifdef USE_TRANSMISSION
  3313. vWorldPosition = worldPosition.xyz;
  3314. #endif
  3315. }`,KOe=`#define STANDARD
  3316. #ifdef PHYSICAL
  3317. #define IOR
  3318. #define USE_SPECULAR
  3319. #endif
  3320. uniform vec3 diffuse;
  3321. uniform vec3 emissive;
  3322. uniform float roughness;
  3323. uniform float metalness;
  3324. uniform float opacity;
  3325. #ifdef IOR
  3326. uniform float ior;
  3327. #endif
  3328. #ifdef USE_SPECULAR
  3329. uniform float specularIntensity;
  3330. uniform vec3 specularColor;
  3331. #ifdef USE_SPECULAR_COLORMAP
  3332. uniform sampler2D specularColorMap;
  3333. #endif
  3334. #ifdef USE_SPECULAR_INTENSITYMAP
  3335. uniform sampler2D specularIntensityMap;
  3336. #endif
  3337. #endif
  3338. #ifdef USE_CLEARCOAT
  3339. uniform float clearcoat;
  3340. uniform float clearcoatRoughness;
  3341. #endif
  3342. #ifdef USE_DISPERSION
  3343. uniform float dispersion;
  3344. #endif
  3345. #ifdef USE_IRIDESCENCE
  3346. uniform float iridescence;
  3347. uniform float iridescenceIOR;
  3348. uniform float iridescenceThicknessMinimum;
  3349. uniform float iridescenceThicknessMaximum;
  3350. #endif
  3351. #ifdef USE_SHEEN
  3352. uniform vec3 sheenColor;
  3353. uniform float sheenRoughness;
  3354. #ifdef USE_SHEEN_COLORMAP
  3355. uniform sampler2D sheenColorMap;
  3356. #endif
  3357. #ifdef USE_SHEEN_ROUGHNESSMAP
  3358. uniform sampler2D sheenRoughnessMap;
  3359. #endif
  3360. #endif
  3361. #ifdef USE_ANISOTROPY
  3362. uniform vec2 anisotropyVector;
  3363. #ifdef USE_ANISOTROPYMAP
  3364. uniform sampler2D anisotropyMap;
  3365. #endif
  3366. #endif
  3367. varying vec3 vViewPosition;
  3368. #include <common>
  3369. #include <dithering_pars_fragment>
  3370. #include <color_pars_fragment>
  3371. #include <uv_pars_fragment>
  3372. #include <map_pars_fragment>
  3373. #include <alphamap_pars_fragment>
  3374. #include <alphatest_pars_fragment>
  3375. #include <alphahash_pars_fragment>
  3376. #include <aomap_pars_fragment>
  3377. #include <lightmap_pars_fragment>
  3378. #include <emissivemap_pars_fragment>
  3379. #include <iridescence_fragment>
  3380. #include <cube_uv_reflection_fragment>
  3381. #include <envmap_common_pars_fragment>
  3382. #include <envmap_physical_pars_fragment>
  3383. #include <fog_pars_fragment>
  3384. #include <lights_pars_begin>
  3385. #include <normal_pars_fragment>
  3386. #include <lights_physical_pars_fragment>
  3387. #include <transmission_pars_fragment>
  3388. #include <shadowmap_pars_fragment>
  3389. #include <bumpmap_pars_fragment>
  3390. #include <normalmap_pars_fragment>
  3391. #include <clearcoat_pars_fragment>
  3392. #include <iridescence_pars_fragment>
  3393. #include <roughnessmap_pars_fragment>
  3394. #include <metalnessmap_pars_fragment>
  3395. #include <logdepthbuf_pars_fragment>
  3396. #include <clipping_planes_pars_fragment>
  3397. void main() {
  3398. vec4 diffuseColor = vec4( diffuse, opacity );
  3399. #include <clipping_planes_fragment>
  3400. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3401. vec3 totalEmissiveRadiance = emissive;
  3402. #include <logdepthbuf_fragment>
  3403. #include <map_fragment>
  3404. #include <color_fragment>
  3405. #include <alphamap_fragment>
  3406. #include <alphatest_fragment>
  3407. #include <alphahash_fragment>
  3408. #include <roughnessmap_fragment>
  3409. #include <metalnessmap_fragment>
  3410. #include <normal_fragment_begin>
  3411. #include <normal_fragment_maps>
  3412. #include <clearcoat_normal_fragment_begin>
  3413. #include <clearcoat_normal_fragment_maps>
  3414. #include <emissivemap_fragment>
  3415. #include <lights_physical_fragment>
  3416. #include <lights_fragment_begin>
  3417. #include <lights_fragment_maps>
  3418. #include <lights_fragment_end>
  3419. #include <aomap_fragment>
  3420. vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
  3421. vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
  3422. #include <transmission_fragment>
  3423. vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
  3424. #ifdef USE_SHEEN
  3425. outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect;
  3426. #endif
  3427. #ifdef USE_CLEARCOAT
  3428. float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
  3429. vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
  3430. outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
  3431. #endif
  3432. #include <opaque_fragment>
  3433. #include <tonemapping_fragment>
  3434. #include <colorspace_fragment>
  3435. #include <fog_fragment>
  3436. #include <premultiplied_alpha_fragment>
  3437. #include <dithering_fragment>
  3438. }`,XOe=`#define TOON
  3439. varying vec3 vViewPosition;
  3440. #include <common>
  3441. #include <batching_pars_vertex>
  3442. #include <uv_pars_vertex>
  3443. #include <displacementmap_pars_vertex>
  3444. #include <color_pars_vertex>
  3445. #include <fog_pars_vertex>
  3446. #include <normal_pars_vertex>
  3447. #include <morphtarget_pars_vertex>
  3448. #include <skinning_pars_vertex>
  3449. #include <shadowmap_pars_vertex>
  3450. #include <logdepthbuf_pars_vertex>
  3451. #include <clipping_planes_pars_vertex>
  3452. void main() {
  3453. #include <uv_vertex>
  3454. #include <color_vertex>
  3455. #include <morphinstance_vertex>
  3456. #include <morphcolor_vertex>
  3457. #include <batching_vertex>
  3458. #include <beginnormal_vertex>
  3459. #include <morphnormal_vertex>
  3460. #include <skinbase_vertex>
  3461. #include <skinnormal_vertex>
  3462. #include <defaultnormal_vertex>
  3463. #include <normal_vertex>
  3464. #include <begin_vertex>
  3465. #include <morphtarget_vertex>
  3466. #include <skinning_vertex>
  3467. #include <displacementmap_vertex>
  3468. #include <project_vertex>
  3469. #include <logdepthbuf_vertex>
  3470. #include <clipping_planes_vertex>
  3471. vViewPosition = - mvPosition.xyz;
  3472. #include <worldpos_vertex>
  3473. #include <shadowmap_vertex>
  3474. #include <fog_vertex>
  3475. }`,YOe=`#define TOON
  3476. uniform vec3 diffuse;
  3477. uniform vec3 emissive;
  3478. uniform float opacity;
  3479. #include <common>
  3480. #include <dithering_pars_fragment>
  3481. #include <color_pars_fragment>
  3482. #include <uv_pars_fragment>
  3483. #include <map_pars_fragment>
  3484. #include <alphamap_pars_fragment>
  3485. #include <alphatest_pars_fragment>
  3486. #include <alphahash_pars_fragment>
  3487. #include <aomap_pars_fragment>
  3488. #include <lightmap_pars_fragment>
  3489. #include <emissivemap_pars_fragment>
  3490. #include <gradientmap_pars_fragment>
  3491. #include <fog_pars_fragment>
  3492. #include <bsdfs>
  3493. #include <lights_pars_begin>
  3494. #include <normal_pars_fragment>
  3495. #include <lights_toon_pars_fragment>
  3496. #include <shadowmap_pars_fragment>
  3497. #include <bumpmap_pars_fragment>
  3498. #include <normalmap_pars_fragment>
  3499. #include <logdepthbuf_pars_fragment>
  3500. #include <clipping_planes_pars_fragment>
  3501. void main() {
  3502. vec4 diffuseColor = vec4( diffuse, opacity );
  3503. #include <clipping_planes_fragment>
  3504. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3505. vec3 totalEmissiveRadiance = emissive;
  3506. #include <logdepthbuf_fragment>
  3507. #include <map_fragment>
  3508. #include <color_fragment>
  3509. #include <alphamap_fragment>
  3510. #include <alphatest_fragment>
  3511. #include <alphahash_fragment>
  3512. #include <normal_fragment_begin>
  3513. #include <normal_fragment_maps>
  3514. #include <emissivemap_fragment>
  3515. #include <lights_toon_fragment>
  3516. #include <lights_fragment_begin>
  3517. #include <lights_fragment_maps>
  3518. #include <lights_fragment_end>
  3519. #include <aomap_fragment>
  3520. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  3521. #include <opaque_fragment>
  3522. #include <tonemapping_fragment>
  3523. #include <colorspace_fragment>
  3524. #include <fog_fragment>
  3525. #include <premultiplied_alpha_fragment>
  3526. #include <dithering_fragment>
  3527. }`,ZOe=`uniform float size;
  3528. uniform float scale;
  3529. #include <common>
  3530. #include <color_pars_vertex>
  3531. #include <fog_pars_vertex>
  3532. #include <morphtarget_pars_vertex>
  3533. #include <logdepthbuf_pars_vertex>
  3534. #include <clipping_planes_pars_vertex>
  3535. #ifdef USE_POINTS_UV
  3536. varying vec2 vUv;
  3537. uniform mat3 uvTransform;
  3538. #endif
  3539. void main() {
  3540. #ifdef USE_POINTS_UV
  3541. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  3542. #endif
  3543. #include <color_vertex>
  3544. #include <morphinstance_vertex>
  3545. #include <morphcolor_vertex>
  3546. #include <begin_vertex>
  3547. #include <morphtarget_vertex>
  3548. #include <project_vertex>
  3549. gl_PointSize = size;
  3550. #ifdef USE_SIZEATTENUATION
  3551. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  3552. if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
  3553. #endif
  3554. #include <logdepthbuf_vertex>
  3555. #include <clipping_planes_vertex>
  3556. #include <worldpos_vertex>
  3557. #include <fog_vertex>
  3558. }`,QOe=`uniform vec3 diffuse;
  3559. uniform float opacity;
  3560. #include <common>
  3561. #include <color_pars_fragment>
  3562. #include <map_particle_pars_fragment>
  3563. #include <alphatest_pars_fragment>
  3564. #include <alphahash_pars_fragment>
  3565. #include <fog_pars_fragment>
  3566. #include <logdepthbuf_pars_fragment>
  3567. #include <clipping_planes_pars_fragment>
  3568. void main() {
  3569. vec4 diffuseColor = vec4( diffuse, opacity );
  3570. #include <clipping_planes_fragment>
  3571. vec3 outgoingLight = vec3( 0.0 );
  3572. #include <logdepthbuf_fragment>
  3573. #include <map_particle_fragment>
  3574. #include <color_fragment>
  3575. #include <alphatest_fragment>
  3576. #include <alphahash_fragment>
  3577. outgoingLight = diffuseColor.rgb;
  3578. #include <opaque_fragment>
  3579. #include <tonemapping_fragment>
  3580. #include <colorspace_fragment>
  3581. #include <fog_fragment>
  3582. #include <premultiplied_alpha_fragment>
  3583. }`,JOe=`#include <common>
  3584. #include <batching_pars_vertex>
  3585. #include <fog_pars_vertex>
  3586. #include <morphtarget_pars_vertex>
  3587. #include <skinning_pars_vertex>
  3588. #include <logdepthbuf_pars_vertex>
  3589. #include <shadowmap_pars_vertex>
  3590. void main() {
  3591. #include <batching_vertex>
  3592. #include <beginnormal_vertex>
  3593. #include <morphinstance_vertex>
  3594. #include <morphnormal_vertex>
  3595. #include <skinbase_vertex>
  3596. #include <skinnormal_vertex>
  3597. #include <defaultnormal_vertex>
  3598. #include <begin_vertex>
  3599. #include <morphtarget_vertex>
  3600. #include <skinning_vertex>
  3601. #include <project_vertex>
  3602. #include <logdepthbuf_vertex>
  3603. #include <worldpos_vertex>
  3604. #include <shadowmap_vertex>
  3605. #include <fog_vertex>
  3606. }`,e4e=`uniform vec3 color;
  3607. uniform float opacity;
  3608. #include <common>
  3609. #include <fog_pars_fragment>
  3610. #include <bsdfs>
  3611. #include <lights_pars_begin>
  3612. #include <logdepthbuf_pars_fragment>
  3613. #include <shadowmap_pars_fragment>
  3614. #include <shadowmask_pars_fragment>
  3615. void main() {
  3616. #include <logdepthbuf_fragment>
  3617. gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
  3618. #include <tonemapping_fragment>
  3619. #include <colorspace_fragment>
  3620. #include <fog_fragment>
  3621. }`,t4e=`uniform float rotation;
  3622. uniform vec2 center;
  3623. #include <common>
  3624. #include <uv_pars_vertex>
  3625. #include <fog_pars_vertex>
  3626. #include <logdepthbuf_pars_vertex>
  3627. #include <clipping_planes_pars_vertex>
  3628. void main() {
  3629. #include <uv_vertex>
  3630. vec4 mvPosition = modelViewMatrix[ 3 ];
  3631. vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
  3632. #ifndef USE_SIZEATTENUATION
  3633. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  3634. if ( isPerspective ) scale *= - mvPosition.z;
  3635. #endif
  3636. vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
  3637. vec2 rotatedPosition;
  3638. rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
  3639. rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
  3640. mvPosition.xy += rotatedPosition;
  3641. gl_Position = projectionMatrix * mvPosition;
  3642. #include <logdepthbuf_vertex>
  3643. #include <clipping_planes_vertex>
  3644. #include <fog_vertex>
  3645. }`,n4e=`uniform vec3 diffuse;
  3646. uniform float opacity;
  3647. #include <common>
  3648. #include <uv_pars_fragment>
  3649. #include <map_pars_fragment>
  3650. #include <alphamap_pars_fragment>
  3651. #include <alphatest_pars_fragment>
  3652. #include <alphahash_pars_fragment>
  3653. #include <fog_pars_fragment>
  3654. #include <logdepthbuf_pars_fragment>
  3655. #include <clipping_planes_pars_fragment>
  3656. void main() {
  3657. vec4 diffuseColor = vec4( diffuse, opacity );
  3658. #include <clipping_planes_fragment>
  3659. vec3 outgoingLight = vec3( 0.0 );
  3660. #include <logdepthbuf_fragment>
  3661. #include <map_fragment>
  3662. #include <alphamap_fragment>
  3663. #include <alphatest_fragment>
  3664. #include <alphahash_fragment>
  3665. outgoingLight = diffuseColor.rgb;
  3666. #include <opaque_fragment>
  3667. #include <tonemapping_fragment>
  3668. #include <colorspace_fragment>
  3669. #include <fog_fragment>
  3670. }`,wn={alphahash_fragment:MRe,alphahash_pars_fragment:ERe,alphamap_fragment:NRe,alphamap_pars_fragment:ARe,alphatest_fragment:TRe,alphatest_pars_fragment:CRe,aomap_fragment:kRe,aomap_pars_fragment:jRe,batching_pars_vertex:PRe,batching_vertex:RRe,begin_vertex:DRe,beginnormal_vertex:ORe,bsdfs:LRe,iridescence_fragment:IRe,bumpmap_pars_fragment:FRe,clipping_planes_fragment:URe,clipping_planes_pars_fragment:zRe,clipping_planes_pars_vertex:BRe,clipping_planes_vertex:$Re,color_fragment:HRe,color_pars_fragment:VRe,color_pars_vertex:GRe,color_vertex:WRe,common:qRe,cube_uv_reflection_fragment:KRe,defaultnormal_vertex:XRe,displacementmap_pars_vertex:YRe,displacementmap_vertex:ZRe,emissivemap_fragment:QRe,emissivemap_pars_fragment:JRe,colorspace_fragment:eDe,colorspace_pars_fragment:tDe,envmap_fragment:nDe,envmap_common_pars_fragment:rDe,envmap_pars_fragment:iDe,envmap_pars_vertex:aDe,envmap_physical_pars_fragment:gDe,envmap_vertex:sDe,fog_vertex:oDe,fog_pars_vertex:lDe,fog_fragment:cDe,fog_pars_fragment:uDe,gradientmap_pars_fragment:dDe,lightmap_pars_fragment:hDe,lights_lambert_fragment:fDe,lights_lambert_pars_fragment:mDe,lights_pars_begin:pDe,lights_toon_fragment:xDe,lights_toon_pars_fragment:bDe,lights_phong_fragment:yDe,lights_phong_pars_fragment:vDe,lights_physical_fragment:_De,lights_physical_pars_fragment:wDe,lights_fragment_begin:SDe,lights_fragment_maps:MDe,lights_fragment_end:EDe,logdepthbuf_fragment:NDe,logdepthbuf_pars_fragment:ADe,logdepthbuf_pars_vertex:TDe,logdepthbuf_vertex:CDe,map_fragment:kDe,map_pars_fragment:jDe,map_particle_fragment:PDe,map_particle_pars_fragment:RDe,metalnessmap_fragment:DDe,metalnessmap_pars_fragment:ODe,morphinstance_vertex:LDe,morphcolor_vertex:IDe,morphnormal_vertex:FDe,morphtarget_pars_vertex:UDe,morphtarget_vertex:zDe,normal_fragment_begin:BDe,normal_fragment_maps:$De,normal_pars_fragment:HDe,normal_pars_vertex:VDe,normal_vertex:GDe,normalmap_pars_fragment:WDe,clearcoat_normal_fragment_begin:qDe,clearcoat_normal_fragment_maps:KDe,clearcoat_pars_fragment:XDe,iridescence_pars_fragment:YDe,opaque_fragment:ZDe,packing:QDe,premultiplied_alpha_fragment:JDe,project_vertex:eOe,dithering_fragment:tOe,dithering_pars_fragment:nOe,roughnessmap_fragment:rOe,roughnessmap_pars_fragment:iOe,shadowmap_pars_fragment:aOe,shadowmap_pars_vertex:sOe,shadowmap_vertex:oOe,shadowmask_pars_fragment:lOe,skinbase_vertex:cOe,skinning_pars_vertex:uOe,skinning_vertex:dOe,skinnormal_vertex:hOe,specularmap_fragment:fOe,specularmap_pars_fragment:mOe,tonemapping_fragment:pOe,tonemapping_pars_fragment:gOe,transmission_fragment:xOe,transmission_pars_fragment:bOe,uv_pars_fragment:yOe,uv_pars_vertex:vOe,uv_vertex:_Oe,worldpos_vertex:wOe,background_vert:SOe,background_frag:MOe,backgroundCube_vert:EOe,backgroundCube_frag:NOe,cube_vert:AOe,cube_frag:TOe,depth_vert:COe,depth_frag:kOe,distance_vert:jOe,distance_frag:POe,equirect_vert:ROe,equirect_frag:DOe,linedashed_vert:OOe,linedashed_frag:LOe,meshbasic_vert:IOe,meshbasic_frag:FOe,meshlambert_vert:UOe,meshlambert_frag:zOe,meshmatcap_vert:BOe,meshmatcap_frag:$Oe,meshnormal_vert:HOe,meshnormal_frag:VOe,meshphong_vert:GOe,meshphong_frag:WOe,meshphysical_vert:qOe,meshphysical_frag:KOe,meshtoon_vert:XOe,meshtoon_frag:YOe,points_vert:ZOe,points_frag:QOe,shadow_vert:JOe,shadow_frag:e4e,sprite_vert:t4e,sprite_frag:n4e},Ft={common:{diffuse:{value:new Rn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Nn},alphaMap:{value:null},alphaMapTransform:{value:new Nn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Nn}},envmap:{envMap:{value:null},envMapRotation:{value:new Nn},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 Nn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Nn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Nn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Nn},normalScale:{value:new Mn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Nn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Nn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Nn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Nn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Rn(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 Rn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Nn},alphaTest:{value:0},uvTransform:{value:new Nn}},sprite:{diffuse:{value:new Rn(16777215)},opacity:{value:1},center:{value:new Mn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Nn},alphaMap:{value:null},alphaMapTransform:{value:new Nn},alphaTest:{value:0}}},Ll={basic:{uniforms:qa([Ft.common,Ft.specularmap,Ft.envmap,Ft.aomap,Ft.lightmap,Ft.fog]),vertexShader:wn.meshbasic_vert,fragmentShader:wn.meshbasic_frag},lambert:{uniforms:qa([Ft.common,Ft.specularmap,Ft.envmap,Ft.aomap,Ft.lightmap,Ft.emissivemap,Ft.bumpmap,Ft.normalmap,Ft.displacementmap,Ft.fog,Ft.lights,{emissive:{value:new Rn(0)}}]),vertexShader:wn.meshlambert_vert,fragmentShader:wn.meshlambert_frag},phong:{uniforms:qa([Ft.common,Ft.specularmap,Ft.envmap,Ft.aomap,Ft.lightmap,Ft.emissivemap,Ft.bumpmap,Ft.normalmap,Ft.displacementmap,Ft.fog,Ft.lights,{emissive:{value:new Rn(0)},specular:{value:new Rn(1118481)},shininess:{value:30}}]),vertexShader:wn.meshphong_vert,fragmentShader:wn.meshphong_frag},standard:{uniforms:qa([Ft.common,Ft.envmap,Ft.aomap,Ft.lightmap,Ft.emissivemap,Ft.bumpmap,Ft.normalmap,Ft.displacementmap,Ft.roughnessmap,Ft.metalnessmap,Ft.fog,Ft.lights,{emissive:{value:new Rn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:wn.meshphysical_vert,fragmentShader:wn.meshphysical_frag},toon:{uniforms:qa([Ft.common,Ft.aomap,Ft.lightmap,Ft.emissivemap,Ft.bumpmap,Ft.normalmap,Ft.displacementmap,Ft.gradientmap,Ft.fog,Ft.lights,{emissive:{value:new Rn(0)}}]),vertexShader:wn.meshtoon_vert,fragmentShader:wn.meshtoon_frag},matcap:{uniforms:qa([Ft.common,Ft.bumpmap,Ft.normalmap,Ft.displacementmap,Ft.fog,{matcap:{value:null}}]),vertexShader:wn.meshmatcap_vert,fragmentShader:wn.meshmatcap_frag},points:{uniforms:qa([Ft.points,Ft.fog]),vertexShader:wn.points_vert,fragmentShader:wn.points_frag},dashed:{uniforms:qa([Ft.common,Ft.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:wn.linedashed_vert,fragmentShader:wn.linedashed_frag},depth:{uniforms:qa([Ft.common,Ft.displacementmap]),vertexShader:wn.depth_vert,fragmentShader:wn.depth_frag},normal:{uniforms:qa([Ft.common,Ft.bumpmap,Ft.normalmap,Ft.displacementmap,{opacity:{value:1}}]),vertexShader:wn.meshnormal_vert,fragmentShader:wn.meshnormal_frag},sprite:{uniforms:qa([Ft.sprite,Ft.fog]),vertexShader:wn.sprite_vert,fragmentShader:wn.sprite_frag},background:{uniforms:{uvTransform:{value:new Nn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:wn.background_vert,fragmentShader:wn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Nn}},vertexShader:wn.backgroundCube_vert,fragmentShader:wn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:wn.cube_vert,fragmentShader:wn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:wn.equirect_vert,fragmentShader:wn.equirect_frag},distance:{uniforms:qa([Ft.common,Ft.displacementmap,{referencePosition:{value:new nt},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:wn.distance_vert,fragmentShader:wn.distance_frag},shadow:{uniforms:qa([Ft.lights,Ft.fog,{color:{value:new Rn(0)},opacity:{value:1}}]),vertexShader:wn.shadow_vert,fragmentShader:wn.shadow_frag}};Ll.physical={uniforms:qa([Ll.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Nn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Nn},clearcoatNormalScale:{value:new Mn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Nn},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Nn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Nn},sheen:{value:0},sheenColor:{value:new Rn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Nn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Nn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Nn},transmissionSamplerSize:{value:new Mn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Nn},attenuationDistance:{value:0},attenuationColor:{value:new Rn(0)},specularColor:{value:new Rn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Nn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Nn},anisotropyVector:{value:new Mn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Nn}}]),vertexShader:wn.meshphysical_vert,fragmentShader:wn.meshphysical_frag};const Z_={r:0,b:0,g:0},zh=new eh,r4e=new mi;function i4e(t,e,n,r,i,a,o){const l=new Rn(0);let c=a===!0?0:1,u,d,f=null,m=0,p=null;function b(M){let N=M.isScene===!0?M.background:null;return N&&N.isTexture&&(N=(M.backgroundBlurriness>0?n:e).get(N)),N}function v(M){let N=!1;const A=b(M);A===null?y(l,c):A&&A.isColor&&(y(A,1),N=!0);const k=t.xr.getEnvironmentBlendMode();k==="additive"?r.buffers.color.setClear(0,0,0,1,o):k==="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 x(M,N){const A=b(N);A&&(A.isCubeTexture||A.mapping===lN)?(d===void 0&&(d=new hl(new oL(1,1,1),new ic({name:"BackgroundCubeMaterial",uniforms:kg(Ll.backgroundCube.uniforms),vertexShader:Ll.backgroundCube.vertexShader,fragmentShader:Ll.backgroundCube.fragmentShader,side:_s,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(k,C,D){this.matrixWorld.copyPosition(D.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),zh.copy(N.backgroundRotation),zh.x*=-1,zh.y*=-1,zh.z*=-1,A.isCubeTexture&&A.isRenderTargetTexture===!1&&(zh.y*=-1,zh.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(r4e.makeRotationFromEuler(zh)),d.material.toneMapped=Vn.getTransfer(A.colorSpace)!==lr,(f!==A||m!==A.version||p!==t.toneMapping)&&(d.material.needsUpdate=!0,f=A,m=A.version,p=t.toneMapping),d.layers.enableAll(),M.unshift(d,d.geometry,d.material,0,0,null)):A&&A.isTexture&&(u===void 0&&(u=new hl(new cL(2,2),new ic({name:"BackgroundMaterial",uniforms:kg(Ll.background.uniforms),vertexShader:Ll.background.vertexShader,fragmentShader:Ll.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=Vn.getTransfer(A.colorSpace)!==lr,A.matrixAutoUpdate===!0&&A.updateMatrix(),u.material.uniforms.uvTransform.value.copy(A.matrix),(f!==A||m!==A.version||p!==t.toneMapping)&&(u.material.needsUpdate=!0,f=A,m=A.version,p=t.toneMapping),u.layers.enableAll(),M.unshift(u,u.geometry,u.material,0,0,null))}function y(M,N){M.getRGB(Z_,_ee(t)),r.buffers.color.setClear(Z_.r,Z_.g,Z_.b,N,o)}function S(){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(M,N=1){l.set(M),c=N,y(l,c)},getClearAlpha:function(){return c},setClearAlpha:function(M){c=M,y(l,c)},render:v,addToRenderList:x,dispose:S}}function a4e(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),r={},i=m(null);let a=i,o=!1;function l(R,U,L,q,j){let W=!1;const K=f(q,L,U);a!==K&&(a=K,u(a.object)),W=p(R,q,L,j),W&&b(R,q,L,j),j!==null&&e.update(j,t.ELEMENT_ARRAY_BUFFER),(W||o)&&(o=!1,N(R,U,L,q),j!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(j).buffer))}function c(){return t.createVertexArray()}function u(R){return t.bindVertexArray(R)}function d(R){return t.deleteVertexArray(R)}function f(R,U,L){const q=L.wireframe===!0;let j=r[R.id];j===void 0&&(j={},r[R.id]=j);let W=j[U.id];W===void 0&&(W={},j[U.id]=W);let K=W[q];return K===void 0&&(K=m(c()),W[q]=K),K}function m(R){const U=[],L=[],q=[];for(let j=0;j<n;j++)U[j]=0,L[j]=0,q[j]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:U,enabledAttributes:L,attributeDivisors:q,object:R,attributes:{},index:null}}function p(R,U,L,q){const j=a.attributes,W=U.attributes;let K=0;const V=L.getAttributes();for(const J in V)if(V[J].location>=0){const te=j[J];let z=W[J];if(z===void 0&&(J==="instanceMatrix"&&R.instanceMatrix&&(z=R.instanceMatrix),J==="instanceColor"&&R.instanceColor&&(z=R.instanceColor)),te===void 0||te.attribute!==z||z&&te.data!==z.data)return!0;K++}return a.attributesNum!==K||a.index!==q}function b(R,U,L,q){const j={},W=U.attributes;let K=0;const V=L.getAttributes();for(const J in V)if(V[J].location>=0){let te=W[J];te===void 0&&(J==="instanceMatrix"&&R.instanceMatrix&&(te=R.instanceMatrix),J==="instanceColor"&&R.instanceColor&&(te=R.instanceColor));const z={};z.attribute=te,te&&te.data&&(z.data=te.data),j[J]=z,K++}a.attributes=j,a.attributesNum=K,a.index=q}function v(){const R=a.newAttributes;for(let U=0,L=R.length;U<L;U++)R[U]=0}function x(R){y(R,0)}function y(R,U){const L=a.newAttributes,q=a.enabledAttributes,j=a.attributeDivisors;L[R]=1,q[R]===0&&(t.enableVertexAttribArray(R),q[R]=1),j[R]!==U&&(t.vertexAttribDivisor(R,U),j[R]=U)}function S(){const R=a.newAttributes,U=a.enabledAttributes;for(let L=0,q=U.length;L<q;L++)U[L]!==R[L]&&(t.disableVertexAttribArray(L),U[L]=0)}function M(R,U,L,q,j,W,K){K===!0?t.vertexAttribIPointer(R,U,L,j,W):t.vertexAttribPointer(R,U,L,q,j,W)}function N(R,U,L,q){v();const j=q.attributes,W=L.getAttributes(),K=U.defaultAttributeValues;for(const V in W){const J=W[V];if(J.location>=0){let ne=j[V];if(ne===void 0&&(V==="instanceMatrix"&&R.instanceMatrix&&(ne=R.instanceMatrix),V==="instanceColor"&&R.instanceColor&&(ne=R.instanceColor)),ne!==void 0){const te=ne.normalized,z=ne.itemSize,H=e.get(ne);if(H===void 0)continue;const Z=H.buffer,ee=H.type,he=H.bytesPerElement,fe=ee===t.INT||ee===t.UNSIGNED_INT||ne.gpuType===Y4;if(ne.isInterleavedBufferAttribute){const oe=ne.data,Ne=oe.stride,ge=ne.offset;if(oe.isInstancedInterleavedBuffer){for(let Se=0;Se<J.locationSize;Se++)y(J.location+Se,oe.meshPerAttribute);R.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=oe.meshPerAttribute*oe.count)}else for(let Se=0;Se<J.locationSize;Se++)x(J.location+Se);t.bindBuffer(t.ARRAY_BUFFER,Z);for(let Se=0;Se<J.locationSize;Se++)M(J.location+Se,z/J.locationSize,ee,te,Ne*he,(ge+z/J.locationSize*Se)*he,fe)}else{if(ne.isInstancedBufferAttribute){for(let oe=0;oe<J.locationSize;oe++)y(J.location+oe,ne.meshPerAttribute);R.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=ne.meshPerAttribute*ne.count)}else for(let oe=0;oe<J.locationSize;oe++)x(J.location+oe);t.bindBuffer(t.ARRAY_BUFFER,Z);for(let oe=0;oe<J.locationSize;oe++)M(J.location+oe,z/J.locationSize,ee,te,z*he,z/J.locationSize*oe*he,fe)}}else if(K!==void 0){const te=K[V];if(te!==void 0)switch(te.length){case 2:t.vertexAttrib2fv(J.location,te);break;case 3:t.vertexAttrib3fv(J.location,te);break;case 4:t.vertexAttrib4fv(J.location,te);break;default:t.vertexAttrib1fv(J.location,te)}}}}S()}function A(){D();for(const R in r){const U=r[R];for(const L in U){const q=U[L];for(const j in q)d(q[j].object),delete q[j];delete U[L]}delete r[R]}}function k(R){if(r[R.id]===void 0)return;const U=r[R.id];for(const L in U){const q=U[L];for(const j in q)d(q[j].object),delete q[j];delete U[L]}delete r[R.id]}function C(R){for(const U in r){const L=r[U];if(L[R.id]===void 0)continue;const q=L[R.id];for(const j in q)d(q[j].object),delete q[j];delete L[R.id]}}function D(){T(),o=!0,a!==i&&(a=i,u(a.object))}function T(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:l,reset:D,resetDefaultState:T,dispose:A,releaseStatesOfGeometry:k,releaseStatesOfProgram:C,initAttributes:v,enableAttribute:x,disableUnusedAttributes:S}}function s4e(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 b=0;b<f;b++)p+=d[b];n.update(p,r,1)}function c(u,d,f,m){if(f===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let b=0;b<u.length;b++)o(u[b],d[b],m[b]);else{p.multiDrawArraysInstancedWEBGL(r,u,0,d,0,m,0,f);let b=0;for(let v=0;v<f;v++)b+=d[v]*m[v];n.update(b,r,1)}}this.setMode=i,this.render=a,this.renderInstances=o,this.renderMultiDraw=l,this.renderMultiDrawInstances=c}function o4e(t,e,n,r){let i;function a(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const C=e.get("EXT_texture_filter_anisotropic");i=t.getParameter(C.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function o(C){return!(C!==el&&r.convert(C)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT))}function l(C){const D=C===yu&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(C!==Hs&&r.convert(C)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&C!==$l&&!D)}function c(C){if(C==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";C="mediump"}return C==="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&&(un("WebGLRenderer:",u,"not supported, using",d,"instead."),u=d);const f=n.logarithmicDepthBuffer===!0,m=n.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),p=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),b=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=t.getParameter(t.MAX_TEXTURE_SIZE),x=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),y=t.getParameter(t.MAX_VERTEX_ATTRIBS),S=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),M=t.getParameter(t.MAX_VARYING_VECTORS),N=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),A=t.getParameter(t.MAX_SAMPLES),k=t.getParameter(t.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:a,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:l,precision:u,logarithmicDepthBuffer:f,reversedDepthBuffer:m,maxTextures:p,maxVertexTextures:b,maxTextureSize:v,maxCubemapSize:x,maxAttributes:y,maxVertexUniforms:S,maxVaryings:M,maxFragmentUniforms:N,maxSamples:A,samples:k}}function l4e(t){const e=this;let n=null,r=0,i=!1,a=!1;const o=new xd,l=new Nn,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,m){const p=f.length!==0||m||r!==0||i;return i=m,r=f.length,p},this.beginShadows=function(){a=!0,d(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(f,m){n=d(f,m,0)},this.setState=function(f,m,p){const b=f.clippingPlanes,v=f.clipIntersection,x=f.clipShadows,y=t.get(f);if(!i||b===null||b.length===0||a&&!x)a?d(null):u();else{const S=a?0:r,M=S*4;let N=y.clippingState||null;c.value=N,N=d(b,m,M,p);for(let A=0;A!==M;++A)N[A]=n[A];y.clippingState=N,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=S}};function u(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function d(f,m,p,b){const v=f!==null?f.length:0;let x=null;if(v!==0){if(x=c.value,b!==!0||x===null){const y=p+v*4,S=m.matrixWorldInverse;l.getNormalMatrix(S),(x===null||x.length<y)&&(x=new Float32Array(y));for(let M=0,N=p;M!==v;++M,N+=4)o.copy(f[M]).applyMatrix4(S,l),o.normal.toArray(x,N),x[N+3]=o.constant}c.value=x,c.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,x}}function c4e(t){let e=new WeakMap;function n(o,l){return l===D3?o.mapping=Zf:l===O3&&(o.mapping=Ag),o}function r(o){if(o&&o.isTexture){const l=o.mapping;if(l===D3||l===O3)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 Mee(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 Cd=4,ZV=[.125,.215,.35,.446,.526,.582],ef=20,u4e=256,Sb=new uL,QV=new Rn;let yk=null,vk=0,_k=0,wk=!1;const d4e=new nt;let JV=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=d4e}=a;yk=this._renderer.getRenderTarget(),vk=this._renderer.getActiveCubeFace(),_k=this._renderer.getActiveMipmapLevel(),wk=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=nG(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=tG(),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(yk,vk,_k),this._renderer.xr.enabled=wk,e.scissorTest=!1,hp(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===Zf||e.mapping===Ag?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),yk=this._renderer.getRenderTarget(),vk=this._renderer.getActiveCubeFace(),_k=this._renderer.getActiveMipmapLevel(),wk=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:Ua,minFilter:Ua,generateMipmaps:!1,type:yu,format:el,colorSpace:Cg,depthBuffer:!1},i=eG(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=eG(e,n,r);const{_lodMax:a}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=h4e(a)),this._blurMaterial=m4e(a,e,n),this._ggxMaterial=f4e(a,e,n)}return i}_compileMaterial(e){const n=new hl(new yl,e);this._renderer.compile(n,Sb)}_sceneToCubeUV(e,n,r,i,a){const c=new So(90,1,n,r),u=[1,-1,1,1,1,1],d=[1,1,1,-1,-1,-1],f=this._renderer,m=f.autoClear,p=f.toneMapping;f.getClearColor(QV),f.toneMapping=ql,f.autoClear=!1,f.state.buffers.depth.getReversed()&&(f.setRenderTarget(i),f.clearDepth(),f.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new hl(new oL,new sL({name:"PMREM.Background",side:_s,depthWrite:!1,depthTest:!1})));const v=this._backgroundBox,x=v.material;let y=!1;const S=e.background;S?S.isColor&&(x.color.copy(S),e.background=null,y=!0):(x.color.copy(QV),y=!0);for(let M=0;M<6;M++){const N=M%3;N===0?(c.up.set(0,u[M],0),c.position.set(a.x,a.y,a.z),c.lookAt(a.x+d[M],a.y,a.z)):N===1?(c.up.set(0,0,u[M]),c.position.set(a.x,a.y,a.z),c.lookAt(a.x,a.y+d[M],a.z)):(c.up.set(0,u[M],0),c.position.set(a.x,a.y,a.z),c.lookAt(a.x,a.y,a.z+d[M]));const A=this._cubeSize;hp(i,N*A,M>2?A:0,A,A),f.setRenderTarget(i),y&&f.render(v,c),f.render(e,c)}f.toneMapping=p,f.autoClear=m,e.background=S}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===Zf||e.mapping===Ag;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=nG()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=tG());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;hp(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(o,Sb)}_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),m=0+u*1.25,p=f*m,{_lodMax:b}=this,v=this._sizeLods[r],x=3*v*(r>b-Cd?r-b+Cd:0),y=4*(this._cubeSize-v);c.envMap.value=e.texture,c.roughness.value=p,c.mipInt.value=b-n,hp(a,x,y,3*v,2*v),i.setRenderTarget(a),i.render(l,Sb),c.envMap.value=a.texture,c.roughness.value=0,c.mipInt.value=b-r,hp(e,x,y,3*v,2*v),i.setRenderTarget(e),i.render(l,Sb)}_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"&&Kn("blur direction must be either latitudinal or longitudinal!");const d=3,f=this._lodMeshes[i];f.material=u;const m=u.uniforms,p=this._sizeLods[r]-1,b=isFinite(a)?Math.PI/(2*p):2*Math.PI/(2*ef-1),v=a/b,x=isFinite(a)?1+Math.floor(d*v):ef;x>ef&&un(`sigmaRadians, ${a}, is too large and will clip, as it requested ${x} samples when the maximum is set to ${ef}`);const y=[];let S=0;for(let C=0;C<ef;++C){const D=C/v,T=Math.exp(-D*D/2);y.push(T),C===0?S+=T:C<x&&(S+=2*T)}for(let C=0;C<y.length;C++)y[C]=y[C]/S;m.envMap.value=e.texture,m.samples.value=x,m.weights.value=y,m.latitudinal.value=o==="latitudinal",l&&(m.poleAxis.value=l);const{_lodMax:M}=this;m.dTheta.value=b,m.mipInt.value=M-r;const N=this._sizeLods[i],A=3*N*(i>M-Cd?i-M+Cd:0),k=4*(this._cubeSize-N);hp(n,A,k,3*N,2*N),c.setRenderTarget(n),c.render(f,Sb)}};function h4e(t){const e=[],n=[],r=[];let i=t;const a=t-Cd+1+ZV.length;for(let o=0;o<a;o++){const l=Math.pow(2,i);e.push(l);let c=1/l;o>t-Cd?c=ZV[o-t+Cd-1]:o===0&&(c=0),n.push(c);const u=1/(l-2),d=-u,f=1+u,m=[d,d,f,d,f,f,d,d,f,f,d,f],p=6,b=6,v=3,x=2,y=1,S=new Float32Array(v*b*p),M=new Float32Array(x*b*p),N=new Float32Array(y*b*p);for(let k=0;k<p;k++){const C=k%3*2/3-1,D=k>2?0:-1,T=[C,D,0,C+2/3,D,0,C+2/3,D+1,0,C,D,0,C+2/3,D+1,0,C,D+1,0];S.set(T,v*b*k),M.set(m,x*b*k);const R=[k,k,k,k,k,k];N.set(R,y*b*k)}const A=new yl;A.setAttribute("position",new Co(S,v)),A.setAttribute("uv",new Co(M,x)),A.setAttribute("faceIndex",new Co(N,y)),r.push(new hl(A,null)),i>Cd&&i--}return{lodMeshes:r,sizeLods:e,sigmas:n}}function eG(t,e,n){const r=new Kl(t,e,n);return r.texture.mapping=lN,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function hp(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function f4e(t,e,n){return new ic({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:u4e,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:uN(),fragmentShader:`
  3671. precision highp float;
  3672. precision highp int;
  3673. varying vec3 vOutputDirection;
  3674. uniform sampler2D envMap;
  3675. uniform float roughness;
  3676. uniform float mipInt;
  3677. #define ENVMAP_TYPE_CUBE_UV
  3678. #include <cube_uv_reflection_fragment>
  3679. #define PI 3.14159265359
  3680. // Van der Corput radical inverse
  3681. float radicalInverse_VdC(uint bits) {
  3682. bits = (bits << 16u) | (bits >> 16u);
  3683. bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
  3684. bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
  3685. bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
  3686. bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
  3687. return float(bits) * 2.3283064365386963e-10; // / 0x100000000
  3688. }
  3689. // Hammersley sequence
  3690. vec2 hammersley(uint i, uint N) {
  3691. return vec2(float(i) / float(N), radicalInverse_VdC(i));
  3692. }
  3693. // GGX VNDF importance sampling (Eric Heitz 2018)
  3694. // "Sampling the GGX Distribution of Visible Normals"
  3695. // https://jcgt.org/published/0007/04/01/
  3696. vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
  3697. float alpha = roughness * roughness;
  3698. // Section 3.2: Transform view direction to hemisphere configuration
  3699. vec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z));
  3700. // Section 4.1: Orthonormal basis
  3701. float lensq = Vh.x * Vh.x + Vh.y * Vh.y;
  3702. vec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0);
  3703. vec3 T2 = cross(Vh, T1);
  3704. // Section 4.2: Parameterization of projected area
  3705. float r = sqrt(Xi.x);
  3706. float phi = 2.0 * PI * Xi.y;
  3707. float t1 = r * cos(phi);
  3708. float t2 = r * sin(phi);
  3709. float s = 0.5 * (1.0 + Vh.z);
  3710. t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
  3711. // Section 4.3: Reprojection onto hemisphere
  3712. vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh;
  3713. // Section 3.4: Transform back to ellipsoid configuration
  3714. return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
  3715. }
  3716. void main() {
  3717. vec3 N = normalize(vOutputDirection);
  3718. vec3 V = N; // Assume view direction equals normal for pre-filtering
  3719. vec3 prefilteredColor = vec3(0.0);
  3720. float totalWeight = 0.0;
  3721. // For very low roughness, just sample the environment directly
  3722. if (roughness < 0.001) {
  3723. gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
  3724. return;
  3725. }
  3726. // Tangent space basis for VNDF sampling
  3727. vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
  3728. vec3 tangent = normalize(cross(up, N));
  3729. vec3 bitangent = cross(N, tangent);
  3730. for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
  3731. vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
  3732. // For PMREM, V = N, so in tangent space V is always (0, 0, 1)
  3733. vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
  3734. // Transform H back to world space
  3735. vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
  3736. vec3 L = normalize(2.0 * dot(V, H) * H - V);
  3737. float NdotL = max(dot(N, L), 0.0);
  3738. if(NdotL > 0.0) {
  3739. // Sample environment at fixed mip level
  3740. // VNDF importance sampling handles the distribution filtering
  3741. vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
  3742. // Weight by NdotL for the split-sum approximation
  3743. // VNDF PDF naturally accounts for the visible microfacet distribution
  3744. prefilteredColor += sampleColor * NdotL;
  3745. totalWeight += NdotL;
  3746. }
  3747. }
  3748. if (totalWeight > 0.0) {
  3749. prefilteredColor = prefilteredColor / totalWeight;
  3750. }
  3751. gl_FragColor = vec4(prefilteredColor, 1.0);
  3752. }
  3753. `,blending:au,depthTest:!1,depthWrite:!1})}function m4e(t,e,n){const r=new Float32Array(ef),i=new nt(0,1,0);return new ic({name:"SphericalGaussianBlur",defines:{n:ef,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:uN(),fragmentShader:`
  3754. precision mediump float;
  3755. precision mediump int;
  3756. varying vec3 vOutputDirection;
  3757. uniform sampler2D envMap;
  3758. uniform int samples;
  3759. uniform float weights[ n ];
  3760. uniform bool latitudinal;
  3761. uniform float dTheta;
  3762. uniform float mipInt;
  3763. uniform vec3 poleAxis;
  3764. #define ENVMAP_TYPE_CUBE_UV
  3765. #include <cube_uv_reflection_fragment>
  3766. vec3 getSample( float theta, vec3 axis ) {
  3767. float cosTheta = cos( theta );
  3768. // Rodrigues' axis-angle rotation
  3769. vec3 sampleDirection = vOutputDirection * cosTheta
  3770. + cross( axis, vOutputDirection ) * sin( theta )
  3771. + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
  3772. return bilinearCubeUV( envMap, sampleDirection, mipInt );
  3773. }
  3774. void main() {
  3775. vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
  3776. if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
  3777. axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
  3778. }
  3779. axis = normalize( axis );
  3780. gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  3781. gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
  3782. for ( int i = 1; i < n; i++ ) {
  3783. if ( i >= samples ) {
  3784. break;
  3785. }
  3786. float theta = dTheta * float( i );
  3787. gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
  3788. gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
  3789. }
  3790. }
  3791. `,blending:au,depthTest:!1,depthWrite:!1})}function tG(){return new ic({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:uN(),fragmentShader:`
  3792. precision mediump float;
  3793. precision mediump int;
  3794. varying vec3 vOutputDirection;
  3795. uniform sampler2D envMap;
  3796. #include <common>
  3797. void main() {
  3798. vec3 outputDirection = normalize( vOutputDirection );
  3799. vec2 uv = equirectUv( outputDirection );
  3800. gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
  3801. }
  3802. `,blending:au,depthTest:!1,depthWrite:!1})}function nG(){return new ic({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:uN(),fragmentShader:`
  3803. precision mediump float;
  3804. precision mediump int;
  3805. uniform float flipEnvMap;
  3806. varying vec3 vOutputDirection;
  3807. uniform samplerCube envMap;
  3808. void main() {
  3809. gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
  3810. }
  3811. `,blending:au,depthTest:!1,depthWrite:!1})}function uN(){return`
  3812. precision mediump float;
  3813. precision mediump int;
  3814. attribute float faceIndex;
  3815. varying vec3 vOutputDirection;
  3816. // RH coordinate system; PMREM face-indexing convention
  3817. vec3 getDirection( vec2 uv, float face ) {
  3818. uv = 2.0 * uv - 1.0;
  3819. vec3 direction = vec3( uv, 1.0 );
  3820. if ( face == 0.0 ) {
  3821. direction = direction.zyx; // ( 1, v, u ) pos x
  3822. } else if ( face == 1.0 ) {
  3823. direction = direction.xzy;
  3824. direction.xz *= -1.0; // ( -u, 1, -v ) pos y
  3825. } else if ( face == 2.0 ) {
  3826. direction.x *= -1.0; // ( -u, v, 1 ) pos z
  3827. } else if ( face == 3.0 ) {
  3828. direction = direction.zyx;
  3829. direction.xz *= -1.0; // ( -1, v, -u ) neg x
  3830. } else if ( face == 4.0 ) {
  3831. direction = direction.xzy;
  3832. direction.xy *= -1.0; // ( -u, -1, v ) neg y
  3833. } else if ( face == 5.0 ) {
  3834. direction.z *= -1.0; // ( u, v, -1 ) neg z
  3835. }
  3836. return direction;
  3837. }
  3838. void main() {
  3839. vOutputDirection = getDirection( uv, faceIndex );
  3840. gl_Position = vec4( position, 1.0 );
  3841. }
  3842. `}function p4e(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,u=c===D3||c===O3,d=c===Zf||c===Ag;if(u||d){let f=e.get(l);const m=f!==void 0?f.texture.pmremVersion:0;if(l.isRenderTargetTexture&&l.pmremVersion!==m)return n===null&&(n=new JV(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 JV(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 g4e(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&&K0("WebGLRenderer: "+r+" extension not supported."),i}}}function x4e(t,e,n,r){const i={},a=new WeakMap;function o(f){const m=f.target;m.index!==null&&e.remove(m.index);for(const b in m.attributes)e.remove(m.attributes[b]);m.removeEventListener("dispose",o),delete i[m.id];const p=a.get(m);p&&(e.remove(p),a.delete(m)),r.releaseStatesOfGeometry(m),m.isInstancedBufferGeometry===!0&&delete m._maxInstanceCount,n.memory.geometries--}function l(f,m){return i[m.id]===!0||(m.addEventListener("dispose",o),i[m.id]=!0,n.memory.geometries++),m}function c(f){const m=f.attributes;for(const p in m)e.update(m[p],t.ARRAY_BUFFER)}function u(f){const m=[],p=f.index,b=f.attributes.position;let v=0;if(p!==null){const S=p.array;v=p.version;for(let M=0,N=S.length;M<N;M+=3){const A=S[M+0],k=S[M+1],C=S[M+2];m.push(A,k,k,C,C,A)}}else if(b!==void 0){const S=b.array;v=b.version;for(let M=0,N=S.length/3-1;M<N;M+=3){const A=M+0,k=M+1,C=M+2;m.push(A,k,k,C,C,A)}}else return;const x=new(lee(m)?bee:xee)(m,1);x.version=v;const y=a.get(f);y&&e.remove(y),a.set(f,x)}function d(f){const m=a.get(f);if(m){const p=f.index;p!==null&&m.version<p.version&&u(f)}else u(f);return a.get(f)}return{get:l,update:c,getWireframeAttribute:d}}function b4e(t,e,n){let r;function i(m){r=m}let a,o;function l(m){a=m.type,o=m.bytesPerElement}function c(m,p){t.drawElements(r,p,a,m*o),n.update(p,r,1)}function u(m,p,b){b!==0&&(t.drawElementsInstanced(r,p,a,m*o,b),n.update(p,r,b))}function d(m,p,b){if(b===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(r,p,0,a,m,0,b);let x=0;for(let y=0;y<b;y++)x+=p[y];n.update(x,r,1)}function f(m,p,b,v){if(b===0)return;const x=e.get("WEBGL_multi_draw");if(x===null)for(let y=0;y<m.length;y++)u(m[y]/o,p[y],v[y]);else{x.multiDrawElementsInstancedWEBGL(r,p,0,a,m,0,v,0,b);let y=0;for(let S=0;S<b;S++)y+=p[S]*v[S];n.update(y,r,1)}}this.setMode=i,this.setIndex=l,this.render=c,this.renderInstances=u,this.renderMultiDraw=d,this.renderMultiDrawInstances=f}function y4e(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:Kn("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 v4e(t,e,n){const r=new WeakMap,i=new Mi;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 m=r.get(l);if(m===void 0||m.count!==f){let R=function(){D.dispose(),r.delete(l),l.removeEventListener("dispose",R)};var p=R;m!==void 0&&m.texture.dispose();const b=l.morphAttributes.position!==void 0,v=l.morphAttributes.normal!==void 0,x=l.morphAttributes.color!==void 0,y=l.morphAttributes.position||[],S=l.morphAttributes.normal||[],M=l.morphAttributes.color||[];let N=0;b===!0&&(N=1),v===!0&&(N=2),x===!0&&(N=3);let A=l.attributes.position.count*N,k=1;A>e.maxTextureSize&&(k=Math.ceil(A/e.maxTextureSize),A=e.maxTextureSize);const C=new Float32Array(A*k*4*f),D=new fee(C,A,k,f);D.type=$l,D.needsUpdate=!0;const T=N*4;for(let U=0;U<f;U++){const L=y[U],q=S[U],j=M[U],W=A*k*4*U;for(let K=0;K<L.count;K++){const V=K*T;b===!0&&(i.fromBufferAttribute(L,K),C[W+V+0]=i.x,C[W+V+1]=i.y,C[W+V+2]=i.z,C[W+V+3]=0),v===!0&&(i.fromBufferAttribute(q,K),C[W+V+4]=i.x,C[W+V+5]=i.y,C[W+V+6]=i.z,C[W+V+7]=0),x===!0&&(i.fromBufferAttribute(j,K),C[W+V+8]=i.x,C[W+V+9]=i.y,C[W+V+10]=i.z,C[W+V+11]=j.itemSize===4?i.w:1)}}m={count:f,texture:D,size:new Mn(A,k)},r.set(l,m),l.addEventListener("dispose",R)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(t,"morphTexture",o.morphTexture,n);else{let b=0;for(let x=0;x<u.length;x++)b+=u[x];const v=l.morphTargetsRelative?1:1-b;c.getUniforms().setValue(t,"morphTargetBaseInfluence",v),c.getUniforms().setValue(t,"morphTargetInfluences",u)}c.getUniforms().setValue(t,"morphTargetsTexture",m.texture,n),c.getUniforms().setValue(t,"morphTargetsTextureSize",m.size)}return{update:a}}function _4e(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 m=c.skeleton;i.get(m)!==u&&(m.update(),i.set(m,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 w4e={[WJ]:"LINEAR_TONE_MAPPING",[qJ]:"REINHARD_TONE_MAPPING",[KJ]:"CINEON_TONE_MAPPING",[XJ]:"ACES_FILMIC_TONE_MAPPING",[ZJ]:"AGX_TONE_MAPPING",[QJ]:"NEUTRAL_TONE_MAPPING",[YJ]:"CUSTOM_TONE_MAPPING"};function S4e(t,e,n,r,i){const a=new Kl(e,n,{type:t,depthBuffer:r,stencilBuffer:i}),o=new Kl(e,n,{type:yu,depthBuffer:!1,stencilBuffer:!1}),l=new yl;l.setAttribute("position",new Ks([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new Ks([0,2,0,0,2,0],2));const c=new hRe({uniforms:{tDiffuse:{value:null}},vertexShader:`
  3843. precision highp float;
  3844. uniform mat4 modelViewMatrix;
  3845. uniform mat4 projectionMatrix;
  3846. attribute vec3 position;
  3847. attribute vec2 uv;
  3848. varying vec2 vUv;
  3849. void main() {
  3850. vUv = uv;
  3851. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  3852. }`,fragmentShader:`
  3853. precision highp float;
  3854. uniform sampler2D tDiffuse;
  3855. varying vec2 vUv;
  3856. #include <tonemapping_pars_fragment>
  3857. #include <colorspace_pars_fragment>
  3858. void main() {
  3859. gl_FragColor = texture2D( tDiffuse, vUv );
  3860. #ifdef LINEAR_TONE_MAPPING
  3861. gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );
  3862. #elif defined( REINHARD_TONE_MAPPING )
  3863. gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );
  3864. #elif defined( CINEON_TONE_MAPPING )
  3865. gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );
  3866. #elif defined( ACES_FILMIC_TONE_MAPPING )
  3867. gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );
  3868. #elif defined( AGX_TONE_MAPPING )
  3869. gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );
  3870. #elif defined( NEUTRAL_TONE_MAPPING )
  3871. gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );
  3872. #elif defined( CUSTOM_TONE_MAPPING )
  3873. gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );
  3874. #endif
  3875. #ifdef SRGB_TRANSFER
  3876. gl_FragColor = sRGBTransferOETF( gl_FragColor );
  3877. #endif
  3878. }`,depthTest:!1,depthWrite:!1}),u=new hl(l,c),d=new uL(-1,1,1,-1,0,1);let f=null,m=null,p=!1,b,v=null,x=[],y=!1;this.setSize=function(S,M){a.setSize(S,M),o.setSize(S,M);for(let N=0;N<x.length;N++){const A=x[N];A.setSize&&A.setSize(S,M)}},this.setEffects=function(S){x=S,y=x.length>0&&x[0].isRenderPass===!0;const M=a.width,N=a.height;for(let A=0;A<x.length;A++){const k=x[A];k.setSize&&k.setSize(M,N)}},this.begin=function(S,M){if(p||S.toneMapping===ql&&x.length===0)return!1;if(v=M,M!==null){const N=M.width,A=M.height;(a.width!==N||a.height!==A)&&this.setSize(N,A)}return y===!1&&S.setRenderTarget(a),b=S.toneMapping,S.toneMapping=ql,!0},this.hasRenderPass=function(){return y},this.end=function(S,M){S.toneMapping=b,p=!0;let N=a,A=o;for(let k=0;k<x.length;k++){const C=x[k];if(C.enabled!==!1&&(C.render(S,A,N,M),C.needsSwap!==!1)){const D=N;N=A,A=D}}if(f!==S.outputColorSpace||m!==S.toneMapping){f=S.outputColorSpace,m=S.toneMapping,c.defines={},Vn.getTransfer(f)===lr&&(c.defines.SRGB_TRANSFER="");const k=w4e[m];k&&(c.defines[k]=""),c.needsUpdate=!0}c.uniforms.tDiffuse.value=N.texture,S.setRenderTarget(v),S.render(u,d),v=null,p=!1},this.isCompositing=function(){return p},this.dispose=function(){a.dispose(),o.dispose(),l.dispose(),c.dispose()}}const kee=new bl,bR=new X0(1,1),jee=new fee,Pee=new z3e,Ree=new See,rG=[],iG=[],aG=new Float32Array(16),sG=new Float32Array(9),oG=new Float32Array(4);function cx(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let a=rG[i];if(a===void 0&&(a=new Float32Array(i),rG[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 Li(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 Ii(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function dN(t,e){let n=iG[e];n===void 0&&(n=new Int32Array(e),iG[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function M4e(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function E4e(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(Li(n,e))return;t.uniform2fv(this.addr,e),Ii(n,e)}}function N4e(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(Li(n,e))return;t.uniform3fv(this.addr,e),Ii(n,e)}}function A4e(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(Li(n,e))return;t.uniform4fv(this.addr,e),Ii(n,e)}}function T4e(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Li(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),Ii(n,e)}else{if(Li(n,r))return;oG.set(r),t.uniformMatrix2fv(this.addr,!1,oG),Ii(n,r)}}function C4e(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Li(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),Ii(n,e)}else{if(Li(n,r))return;sG.set(r),t.uniformMatrix3fv(this.addr,!1,sG),Ii(n,r)}}function k4e(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Li(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),Ii(n,e)}else{if(Li(n,r))return;aG.set(r),t.uniformMatrix4fv(this.addr,!1,aG),Ii(n,r)}}function j4e(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function P4e(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(Li(n,e))return;t.uniform2iv(this.addr,e),Ii(n,e)}}function R4e(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(Li(n,e))return;t.uniform3iv(this.addr,e),Ii(n,e)}}function D4e(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(Li(n,e))return;t.uniform4iv(this.addr,e),Ii(n,e)}}function O4e(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function L4e(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(Li(n,e))return;t.uniform2uiv(this.addr,e),Ii(n,e)}}function I4e(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(Li(n,e))return;t.uniform3uiv(this.addr,e),Ii(n,e)}}function F4e(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(Li(n,e))return;t.uniform4uiv(this.addr,e),Ii(n,e)}}function U4e(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?(bR.compareFunction=n.isReversedDepthBuffer()?rL:nL,a=bR):a=kee,n.setTexture2D(e||a,i)}function z4e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||Pee,i)}function B4e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||Ree,i)}function $4e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||jee,i)}function H4e(t){switch(t){case 5126:return M4e;case 35664:return E4e;case 35665:return N4e;case 35666:return A4e;case 35674:return T4e;case 35675:return C4e;case 35676:return k4e;case 5124:case 35670:return j4e;case 35667:case 35671:return P4e;case 35668:case 35672:return R4e;case 35669:case 35673:return D4e;case 5125:return O4e;case 36294:return L4e;case 36295:return I4e;case 36296:return F4e;case 35678:case 36198:case 36298:case 36306:case 35682:return U4e;case 35679:case 36299:case 36307:return z4e;case 35680:case 36300:case 36308:case 36293:return B4e;case 36289:case 36303:case 36311:case 36292:return $4e}}function V4e(t,e){t.uniform1fv(this.addr,e)}function G4e(t,e){const n=cx(e,this.size,2);t.uniform2fv(this.addr,n)}function W4e(t,e){const n=cx(e,this.size,3);t.uniform3fv(this.addr,n)}function q4e(t,e){const n=cx(e,this.size,4);t.uniform4fv(this.addr,n)}function K4e(t,e){const n=cx(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function X4e(t,e){const n=cx(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function Y4e(t,e){const n=cx(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function Z4e(t,e){t.uniform1iv(this.addr,e)}function Q4e(t,e){t.uniform2iv(this.addr,e)}function J4e(t,e){t.uniform3iv(this.addr,e)}function eLe(t,e){t.uniform4iv(this.addr,e)}function tLe(t,e){t.uniform1uiv(this.addr,e)}function nLe(t,e){t.uniform2uiv(this.addr,e)}function rLe(t,e){t.uniform3uiv(this.addr,e)}function iLe(t,e){t.uniform4uiv(this.addr,e)}function aLe(t,e,n){const r=this.cache,i=e.length,a=dN(n,i);Li(r,a)||(t.uniform1iv(this.addr,a),Ii(r,a));let o;this.type===t.SAMPLER_2D_SHADOW?o=bR:o=kee;for(let l=0;l!==i;++l)n.setTexture2D(e[l]||o,a[l])}function sLe(t,e,n){const r=this.cache,i=e.length,a=dN(n,i);Li(r,a)||(t.uniform1iv(this.addr,a),Ii(r,a));for(let o=0;o!==i;++o)n.setTexture3D(e[o]||Pee,a[o])}function oLe(t,e,n){const r=this.cache,i=e.length,a=dN(n,i);Li(r,a)||(t.uniform1iv(this.addr,a),Ii(r,a));for(let o=0;o!==i;++o)n.setTextureCube(e[o]||Ree,a[o])}function lLe(t,e,n){const r=this.cache,i=e.length,a=dN(n,i);Li(r,a)||(t.uniform1iv(this.addr,a),Ii(r,a));for(let o=0;o!==i;++o)n.setTexture2DArray(e[o]||jee,a[o])}function cLe(t){switch(t){case 5126:return V4e;case 35664:return G4e;case 35665:return W4e;case 35666:return q4e;case 35674:return K4e;case 35675:return X4e;case 35676:return Y4e;case 5124:case 35670:return Z4e;case 35667:case 35671:return Q4e;case 35668:case 35672:return J4e;case 35669:case 35673:return eLe;case 5125:return tLe;case 36294:return nLe;case 36295:return rLe;case 36296:return iLe;case 35678:case 36198:case 36298:case 36306:case 35682:return aLe;case 35679:case 36299:case 36307:return sLe;case 35680:case 36300:case 36308:case 36293:return oLe;case 36289:case 36303:case 36311:case 36292:return lLe}}let uLe=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=H4e(n.type)}},dLe=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=cLe(n.type)}},hLe=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 Sk=/(\w+)(\])?(\[|\.)?/g;function lG(t,e){t.seq.push(e),t.map[e.id]=e}function fLe(t,e,n){const r=t.name,i=r.length;for(Sk.lastIndex=0;;){const a=Sk.exec(r),o=Sk.lastIndex;let l=a[1];const c=a[2]==="]",u=a[3];if(c&&(l=l|0),u===void 0||u==="["&&o+2===i){lG(n,u===void 0?new uLe(l,t,e):new dLe(l,t,e));break}else{let f=n.map[l];f===void 0&&(f=new hLe(l),lG(n,f)),n=f}}}let pw=class{constructor(e,n){this.seq=[],this.map={};const r=e.getProgramParameter(n,e.ACTIVE_UNIFORMS);for(let o=0;o<r;++o){const l=e.getActiveUniform(n,o),c=e.getUniformLocation(n,l.name);fLe(l,c,this)}const i=[],a=[];for(const o of this.seq)o.type===e.SAMPLER_2D_SHADOW||o.type===e.SAMPLER_CUBE_SHADOW||o.type===e.SAMPLER_2D_ARRAY_SHADOW?i.push(o):a.push(o);i.length>0&&(this.seq=i.concat(a))}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 cG(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const mLe=37297;let pLe=0;function gLe(t,e){const n=t.split(`
  3879. `),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(`
  3880. `)}const uG=new Nn;function xLe(t){Vn._getMatrix(uG,Vn.workingColorSpace,t);const e=`mat3( ${uG.elements.map(n=>n.toFixed(4))} )`;switch(Vn.getTransfer(t)){case US:return[e,"LinearTransferOETF"];case lr:return[e,"sRGBTransferOETF"];default:return un("WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}function dG(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()+`
  3881. `+a+`
  3882. `+gLe(t.getShaderSource(e),l)}else return a}function bLe(t,e){const n=xLe(e);return[`vec4 ${t}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
  3883. `)}const yLe={[WJ]:"Linear",[qJ]:"Reinhard",[KJ]:"Cineon",[XJ]:"ACESFilmic",[ZJ]:"AgX",[QJ]:"Neutral",[YJ]:"Custom"};function vLe(t,e){const n=yLe[e];return n===void 0?(un("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+t+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const Q_=new nt;function _Le(){Vn.getLuminanceCoefficients(Q_);const t=Q_.x.toFixed(4),e=Q_.y.toFixed(4),n=Q_.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${t}, ${e}, ${n} );`," return dot( weights, rgb );","}"].join(`
  3884. `)}function wLe(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Hb).join(`
  3885. `)}function SLe(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
  3886. `)}function MLe(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 Hb(t){return t!==""}function hG(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 fG(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const ELe=/^[ \t]*#include +<([\w\d./]+)>/gm;function yR(t){return t.replace(ELe,ALe)}const NLe=new Map;function ALe(t,e){let n=wn[e];if(n===void 0){const r=NLe.get(e);if(r!==void 0)n=wn[r],un('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return yR(n)}const TLe=/#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 mG(t){return t.replace(TLe,CLe)}function CLe(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 pG(t){let e=`precision ${t.precision} float;
  3887. precision ${t.precision} int;
  3888. precision ${t.precision} sampler2D;
  3889. precision ${t.precision} samplerCube;
  3890. precision ${t.precision} sampler3D;
  3891. precision ${t.precision} sampler2DArray;
  3892. precision ${t.precision} sampler2DShadow;
  3893. precision ${t.precision} samplerCubeShadow;
  3894. precision ${t.precision} sampler2DArrayShadow;
  3895. precision ${t.precision} isampler2D;
  3896. precision ${t.precision} isampler3D;
  3897. precision ${t.precision} isamplerCube;
  3898. precision ${t.precision} isampler2DArray;
  3899. precision ${t.precision} usampler2D;
  3900. precision ${t.precision} usampler3D;
  3901. precision ${t.precision} usamplerCube;
  3902. precision ${t.precision} usampler2DArray;
  3903. `;return t.precision==="highp"?e+=`
  3904. #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
  3905. #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
  3906. #define LOW_PRECISION`),e}const kLe={[ow]:"SHADOWMAP_TYPE_PCF",[Bb]:"SHADOWMAP_TYPE_VSM"};function jLe(t){return kLe[t.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}const PLe={[Zf]:"ENVMAP_TYPE_CUBE",[Ag]:"ENVMAP_TYPE_CUBE",[lN]:"ENVMAP_TYPE_CUBE_UV"};function RLe(t){return t.envMap===!1?"ENVMAP_TYPE_CUBE":PLe[t.envMapMode]||"ENVMAP_TYPE_CUBE"}const DLe={[Ag]:"ENVMAP_MODE_REFRACTION"};function OLe(t){return t.envMap===!1?"ENVMAP_MODE_REFLECTION":DLe[t.envMapMode]||"ENVMAP_MODE_REFLECTION"}const LLe={[X4]:"ENVMAP_BLENDING_MULTIPLY",[v3e]:"ENVMAP_BLENDING_MIX",[_3e]:"ENVMAP_BLENDING_ADD"};function ILe(t){return t.envMap===!1?"ENVMAP_BLENDING_NONE":LLe[t.combine]||"ENVMAP_BLENDING_NONE"}function FLe(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 ULe(t,e,n,r){const i=t.getContext(),a=n.defines;let o=n.vertexShader,l=n.fragmentShader;const c=jLe(n),u=RLe(n),d=OLe(n),f=ILe(n),m=FLe(n),p=wLe(n),b=SLe(a),v=i.createProgram();let x,y,S=n.glslVersion?"#version "+n.glslVersion+`
  3907. `:"";n.isRawShaderMaterial?(x=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(Hb).join(`
  3908. `),x.length>0&&(x+=`
  3909. `),y=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(Hb).join(`
  3910. `),y.length>0&&(y+=`
  3911. `)):(x=[pG(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
  3912. `].filter(Hb).join(`
  3913. `),y=[pG(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",n.envMap?"#define "+f:"",m?"#define CUBEUV_TEXEL_WIDTH "+m.texelWidth:"",m?"#define CUBEUV_TEXEL_HEIGHT "+m.texelHeight:"",m?"#define CUBEUV_MAX_MIP "+m.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!==ql?"#define TONE_MAPPING":"",n.toneMapping!==ql?wn.tonemapping_pars_fragment:"",n.toneMapping!==ql?vLe("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",wn.colorspace_pars_fragment,bLe("linearToOutputTexel",n.outputColorSpace),_Le(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
  3914. `].filter(Hb).join(`
  3915. `)),o=yR(o),o=hG(o,n),o=fG(o,n),l=yR(l),l=hG(l,n),l=fG(l,n),o=mG(o),l=mG(l),n.isRawShaderMaterial!==!0&&(S=`#version 300 es
  3916. `,x=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(`
  3917. `)+`
  3918. `+x,y=["#define varying in",n.glslVersion===SV?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===SV?"":"#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(`
  3919. `)+`
  3920. `+y);const M=S+x+o,N=S+y+l,A=cG(i,i.VERTEX_SHADER,M),k=cG(i,i.FRAGMENT_SHADER,N);i.attachShader(v,A),i.attachShader(v,k),n.index0AttributeName!==void 0?i.bindAttribLocation(v,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(v,0,"position"),i.linkProgram(v);function C(U){if(t.debug.checkShaderErrors){const L=i.getProgramInfoLog(v)||"",q=i.getShaderInfoLog(A)||"",j=i.getShaderInfoLog(k)||"",W=L.trim(),K=q.trim(),V=j.trim();let J=!0,ne=!0;if(i.getProgramParameter(v,i.LINK_STATUS)===!1)if(J=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,v,A,k);else{const te=dG(i,A,"vertex"),z=dG(i,k,"fragment");Kn("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(v,i.VALIDATE_STATUS)+`
  3921. Material Name: `+U.name+`
  3922. Material Type: `+U.type+`
  3923. Program Info Log: `+W+`
  3924. `+te+`
  3925. `+z)}else W!==""?un("WebGLProgram: Program Info Log:",W):(K===""||V==="")&&(ne=!1);ne&&(U.diagnostics={runnable:J,programLog:W,vertexShader:{log:K,prefix:x},fragmentShader:{log:V,prefix:y}})}i.deleteShader(A),i.deleteShader(k),D=new pw(i,v),T=MLe(i,v)}let D;this.getUniforms=function(){return D===void 0&&C(this),D};let T;this.getAttributes=function(){return T===void 0&&C(this),T};let R=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return R===!1&&(R=i.getProgramParameter(v,mLe)),R},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(v),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=pLe++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=A,this.fragmentShader=k,this}let zLe=0,BLe=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 $Le(e),n.set(e,r)),r}},$Le=class{constructor(e){this.id=zLe++,this.code=e,this.usedTimes=0}};function HLe(t,e,n,r,i,a,o){const l=new pee,c=new BLe,u=new Set,d=[],f=new Map,m=i.logarithmicDepthBuffer;let p=i.precision;const b={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function v(T){return u.add(T),T===0?"uv":`uv${T}`}function x(T,R,U,L,q){const j=L.fog,W=q.geometry,K=T.isMeshStandardMaterial?L.environment:null,V=(T.isMeshStandardMaterial?n:e).get(T.envMap||K),J=V&&V.mapping===lN?V.image.height:null,ne=b[T.type];T.precision!==null&&(p=i.getMaxPrecision(T.precision),p!==T.precision&&un("WebGLProgram.getParameters:",T.precision,"not supported, using",p,"instead."));const te=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,z=te!==void 0?te.length:0;let H=0;W.morphAttributes.position!==void 0&&(H=1),W.morphAttributes.normal!==void 0&&(H=2),W.morphAttributes.color!==void 0&&(H=3);let Z,ee,he,fe;if(ne){const kt=Ll[ne];Z=kt.vertexShader,ee=kt.fragmentShader}else Z=T.vertexShader,ee=T.fragmentShader,c.update(T),he=c.getVertexShaderID(T),fe=c.getFragmentShaderID(T);const oe=t.getRenderTarget(),Ne=t.state.buffers.depth.getReversed(),ge=q.isInstancedMesh===!0,Se=q.isBatchedMesh===!0,Re=!!T.map,de=!!T.matcap,Qe=!!V,G=!!T.aoMap,ie=!!T.lightMap,X=!!T.bumpMap,$=!!T.normalMap,I=!!T.displacementMap,ce=!!T.emissiveMap,Ee=!!T.metalnessMap,Ie=!!T.roughnessMap,le=T.anisotropy>0,B=T.clearcoat>0,O=T.dispersion>0,Y=T.iridescence>0,pe=T.sheen>0,we=T.transmission>0,ae=le&&!!T.anisotropyMap,ke=B&&!!T.clearcoatMap,De=B&&!!T.clearcoatNormalMap,Ke=B&&!!T.clearcoatRoughnessMap,et=Y&&!!T.iridescenceMap,Ye=Y&&!!T.iridescenceThicknessMap,se=pe&&!!T.sheenColorMap,ye=pe&&!!T.sheenRoughnessMap,Ce=!!T.specularMap,Ue=!!T.specularColorMap,dt=!!T.specularIntensityMap,re=we&&!!T.transmissionMap,Fe=we&&!!T.thicknessMap,ve=!!T.gradientMap,$e=!!T.alphaMap,Le=T.alphaTest>0,Ae=!!T.alphaHash,Ge=!!T.extensions;let it=ql;T.toneMapped&&(oe===null||oe.isXRRenderTarget===!0)&&(it=t.toneMapping);const Ot={shaderID:ne,shaderType:T.type,shaderName:T.name,vertexShader:Z,fragmentShader:ee,defines:T.defines,customVertexShaderID:he,customFragmentShaderID:fe,isRawShaderMaterial:T.isRawShaderMaterial===!0,glslVersion:T.glslVersion,precision:p,batching:Se,batchingColor:Se&&q._colorsTexture!==null,instancing:ge,instancingColor:ge&&q.instanceColor!==null,instancingMorph:ge&&q.morphTexture!==null,outputColorSpace:oe===null?t.outputColorSpace:oe.isXRRenderTarget===!0?oe.texture.colorSpace:Cg,alphaToCoverage:!!T.alphaToCoverage,map:Re,matcap:de,envMap:Qe,envMapMode:Qe&&V.mapping,envMapCubeUVHeight:J,aoMap:G,lightMap:ie,bumpMap:X,normalMap:$,displacementMap:I,emissiveMap:ce,normalMapObjectSpace:$&&T.normalMapType===M3e,normalMapTangentSpace:$&&T.normalMapType===oee,metalnessMap:Ee,roughnessMap:Ie,anisotropy:le,anisotropyMap:ae,clearcoat:B,clearcoatMap:ke,clearcoatNormalMap:De,clearcoatRoughnessMap:Ke,dispersion:O,iridescence:Y,iridescenceMap:et,iridescenceThicknessMap:Ye,sheen:pe,sheenColorMap:se,sheenRoughnessMap:ye,specularMap:Ce,specularColorMap:Ue,specularIntensityMap:dt,transmission:we,transmissionMap:re,thicknessMap:Fe,gradientMap:ve,opaque:T.transparent===!1&&T.blending===ig&&T.alphaToCoverage===!1,alphaMap:$e,alphaTest:Le,alphaHash:Ae,combine:T.combine,mapUv:Re&&v(T.map.channel),aoMapUv:G&&v(T.aoMap.channel),lightMapUv:ie&&v(T.lightMap.channel),bumpMapUv:X&&v(T.bumpMap.channel),normalMapUv:$&&v(T.normalMap.channel),displacementMapUv:I&&v(T.displacementMap.channel),emissiveMapUv:ce&&v(T.emissiveMap.channel),metalnessMapUv:Ee&&v(T.metalnessMap.channel),roughnessMapUv:Ie&&v(T.roughnessMap.channel),anisotropyMapUv:ae&&v(T.anisotropyMap.channel),clearcoatMapUv:ke&&v(T.clearcoatMap.channel),clearcoatNormalMapUv:De&&v(T.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ke&&v(T.clearcoatRoughnessMap.channel),iridescenceMapUv:et&&v(T.iridescenceMap.channel),iridescenceThicknessMapUv:Ye&&v(T.iridescenceThicknessMap.channel),sheenColorMapUv:se&&v(T.sheenColorMap.channel),sheenRoughnessMapUv:ye&&v(T.sheenRoughnessMap.channel),specularMapUv:Ce&&v(T.specularMap.channel),specularColorMapUv:Ue&&v(T.specularColorMap.channel),specularIntensityMapUv:dt&&v(T.specularIntensityMap.channel),transmissionMapUv:re&&v(T.transmissionMap.channel),thicknessMapUv:Fe&&v(T.thicknessMap.channel),alphaMapUv:$e&&v(T.alphaMap.channel),vertexTangents:!!W.attributes.tangent&&($||le),vertexColors:T.vertexColors,vertexAlphas:T.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,pointsUvs:q.isPoints===!0&&!!W.attributes.uv&&(Re||$e),fog:!!j,useFog:T.fog===!0,fogExp2:!!j&&j.isFogExp2,flatShading:T.flatShading===!0&&T.wireframe===!1,sizeAttenuation:T.sizeAttenuation===!0,logarithmicDepthBuffer:m,reversedDepthBuffer:Ne,skinning:q.isSkinnedMesh===!0,morphTargets:W.morphAttributes.position!==void 0,morphNormals:W.morphAttributes.normal!==void 0,morphColors:W.morphAttributes.color!==void 0,morphTargetsCount:z,morphTextureStride:H,numDirLights:R.directional.length,numPointLights:R.point.length,numSpotLights:R.spot.length,numSpotLightMaps:R.spotLightMap.length,numRectAreaLights:R.rectArea.length,numHemiLights:R.hemi.length,numDirLightShadows:R.directionalShadowMap.length,numPointLightShadows:R.pointShadowMap.length,numSpotLightShadows:R.spotShadowMap.length,numSpotLightShadowsWithMaps:R.numSpotLightShadowsWithMaps,numLightProbes:R.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:T.dithering,shadowMapEnabled:t.shadowMap.enabled&&U.length>0,shadowMapType:t.shadowMap.type,toneMapping:it,decodeVideoTexture:Re&&T.map.isVideoTexture===!0&&Vn.getTransfer(T.map.colorSpace)===lr,decodeVideoTextureEmissive:ce&&T.emissiveMap.isVideoTexture===!0&&Vn.getTransfer(T.emissiveMap.colorSpace)===lr,premultipliedAlpha:T.premultipliedAlpha,doubleSided:T.side===Il,flipSided:T.side===_s,useDepthPacking:T.depthPacking>=0,depthPacking:T.depthPacking||0,index0AttributeName:T.index0AttributeName,extensionClipCullDistance:Ge&&T.extensions.clipCullDistance===!0&&r.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Ge&&T.extensions.multiDraw===!0||Se)&&r.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:T.customProgramCacheKey()};return Ot.vertexUv1s=u.has(1),Ot.vertexUv2s=u.has(2),Ot.vertexUv3s=u.has(3),u.clear(),Ot}function y(T){const R=[];if(T.shaderID?R.push(T.shaderID):(R.push(T.customVertexShaderID),R.push(T.customFragmentShaderID)),T.defines!==void 0)for(const U in T.defines)R.push(U),R.push(T.defines[U]);return T.isRawShaderMaterial===!1&&(S(R,T),M(R,T),R.push(t.outputColorSpace)),R.push(T.customProgramCacheKey),R.join()}function S(T,R){T.push(R.precision),T.push(R.outputColorSpace),T.push(R.envMapMode),T.push(R.envMapCubeUVHeight),T.push(R.mapUv),T.push(R.alphaMapUv),T.push(R.lightMapUv),T.push(R.aoMapUv),T.push(R.bumpMapUv),T.push(R.normalMapUv),T.push(R.displacementMapUv),T.push(R.emissiveMapUv),T.push(R.metalnessMapUv),T.push(R.roughnessMapUv),T.push(R.anisotropyMapUv),T.push(R.clearcoatMapUv),T.push(R.clearcoatNormalMapUv),T.push(R.clearcoatRoughnessMapUv),T.push(R.iridescenceMapUv),T.push(R.iridescenceThicknessMapUv),T.push(R.sheenColorMapUv),T.push(R.sheenRoughnessMapUv),T.push(R.specularMapUv),T.push(R.specularColorMapUv),T.push(R.specularIntensityMapUv),T.push(R.transmissionMapUv),T.push(R.thicknessMapUv),T.push(R.combine),T.push(R.fogExp2),T.push(R.sizeAttenuation),T.push(R.morphTargetsCount),T.push(R.morphAttributeCount),T.push(R.numDirLights),T.push(R.numPointLights),T.push(R.numSpotLights),T.push(R.numSpotLightMaps),T.push(R.numHemiLights),T.push(R.numRectAreaLights),T.push(R.numDirLightShadows),T.push(R.numPointLightShadows),T.push(R.numSpotLightShadows),T.push(R.numSpotLightShadowsWithMaps),T.push(R.numLightProbes),T.push(R.shadowMapType),T.push(R.toneMapping),T.push(R.numClippingPlanes),T.push(R.numClipIntersection),T.push(R.depthPacking)}function M(T,R){l.disableAll(),R.instancing&&l.enable(0),R.instancingColor&&l.enable(1),R.instancingMorph&&l.enable(2),R.matcap&&l.enable(3),R.envMap&&l.enable(4),R.normalMapObjectSpace&&l.enable(5),R.normalMapTangentSpace&&l.enable(6),R.clearcoat&&l.enable(7),R.iridescence&&l.enable(8),R.alphaTest&&l.enable(9),R.vertexColors&&l.enable(10),R.vertexAlphas&&l.enable(11),R.vertexUv1s&&l.enable(12),R.vertexUv2s&&l.enable(13),R.vertexUv3s&&l.enable(14),R.vertexTangents&&l.enable(15),R.anisotropy&&l.enable(16),R.alphaHash&&l.enable(17),R.batching&&l.enable(18),R.dispersion&&l.enable(19),R.batchingColor&&l.enable(20),R.gradientMap&&l.enable(21),T.push(l.mask),l.disableAll(),R.fog&&l.enable(0),R.useFog&&l.enable(1),R.flatShading&&l.enable(2),R.logarithmicDepthBuffer&&l.enable(3),R.reversedDepthBuffer&&l.enable(4),R.skinning&&l.enable(5),R.morphTargets&&l.enable(6),R.morphNormals&&l.enable(7),R.morphColors&&l.enable(8),R.premultipliedAlpha&&l.enable(9),R.shadowMapEnabled&&l.enable(10),R.doubleSided&&l.enable(11),R.flipSided&&l.enable(12),R.useDepthPacking&&l.enable(13),R.dithering&&l.enable(14),R.transmission&&l.enable(15),R.sheen&&l.enable(16),R.opaque&&l.enable(17),R.pointsUvs&&l.enable(18),R.decodeVideoTexture&&l.enable(19),R.decodeVideoTextureEmissive&&l.enable(20),R.alphaToCoverage&&l.enable(21),T.push(l.mask)}function N(T){const R=b[T.type];let U;if(R){const L=Ll[R];U=J3e.clone(L.uniforms)}else U=T.uniforms;return U}function A(T,R){let U=f.get(R);return U!==void 0?++U.usedTimes:(U=new ULe(t,R,T,a),d.push(U),f.set(R,U)),U}function k(T){if(--T.usedTimes===0){const R=d.indexOf(T);d[R]=d[d.length-1],d.pop(),f.delete(T.cacheKey),T.destroy()}}function C(T){c.remove(T)}function D(){c.dispose()}return{getParameters:x,getProgramCacheKey:y,getUniforms:N,acquireProgram:A,releaseProgram:k,releaseShaderCache:C,programs:d,dispose:D}}function VLe(){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 GLe(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 gG(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 xG(){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,m,p,b,v,x){let y=t[e];return y===void 0?(y={id:f.id,object:f,geometry:m,material:p,groupOrder:b,renderOrder:f.renderOrder,z:v,group:x},t[e]=y):(y.id=f.id,y.object=f,y.geometry=m,y.material=p,y.groupOrder=b,y.renderOrder=f.renderOrder,y.z=v,y.group=x),e++,y}function l(f,m,p,b,v,x){const y=o(f,m,p,b,v,x);p.transmission>0?r.push(y):p.transparent===!0?i.push(y):n.push(y)}function c(f,m,p,b,v,x){const y=o(f,m,p,b,v,x);p.transmission>0?r.unshift(y):p.transparent===!0?i.unshift(y):n.unshift(y)}function u(f,m){n.length>1&&n.sort(f||GLe),r.length>1&&r.sort(m||gG),i.length>1&&i.sort(m||gG)}function d(){for(let f=e,m=t.length;f<m;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 WLe(){let t=new WeakMap;function e(r,i){const a=t.get(r);let o;return a===void 0?(o=new xG,t.set(r,[o])):i>=a.length?(o=new xG,a.push(o)):o=a[i],o}function n(){t=new WeakMap}return{get:e,dispose:n}}function qLe(){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 nt,color:new Rn};break;case"SpotLight":n={position:new nt,direction:new nt,color:new Rn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new nt,color:new Rn,distance:0,decay:0};break;case"HemisphereLight":n={direction:new nt,skyColor:new Rn,groundColor:new Rn};break;case"RectAreaLight":n={color:new Rn,position:new nt,halfWidth:new nt,halfHeight:new nt};break}return t[e.id]=n,n}}}function KLe(){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 Mn};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Mn};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Mn,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let XLe=0;function YLe(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function ZLe(t){const e=new qLe,n=KLe(),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 nt);const i=new nt,a=new mi,o=new mi;function l(u){let d=0,f=0,m=0;for(let T=0;T<9;T++)r.probe[T].set(0,0,0);let p=0,b=0,v=0,x=0,y=0,S=0,M=0,N=0,A=0,k=0,C=0;u.sort(YLe);for(let T=0,R=u.length;T<R;T++){const U=u[T],L=U.color,q=U.intensity,j=U.distance;let W=null;if(U.shadow&&U.shadow.map&&(U.shadow.map.texture.format===Tg?W=U.shadow.map.texture:W=U.shadow.map.depthTexture||U.shadow.map.texture),U.isAmbientLight)d+=L.r*q,f+=L.g*q,m+=L.b*q;else if(U.isLightProbe){for(let K=0;K<9;K++)r.probe[K].addScaledVector(U.sh.coefficients[K],q);C++}else if(U.isDirectionalLight){const K=e.get(U);if(K.color.copy(U.color).multiplyScalar(U.intensity),U.castShadow){const V=U.shadow,J=n.get(U);J.shadowIntensity=V.intensity,J.shadowBias=V.bias,J.shadowNormalBias=V.normalBias,J.shadowRadius=V.radius,J.shadowMapSize=V.mapSize,r.directionalShadow[p]=J,r.directionalShadowMap[p]=W,r.directionalShadowMatrix[p]=U.shadow.matrix,S++}r.directional[p]=K,p++}else if(U.isSpotLight){const K=e.get(U);K.position.setFromMatrixPosition(U.matrixWorld),K.color.copy(L).multiplyScalar(q),K.distance=j,K.coneCos=Math.cos(U.angle),K.penumbraCos=Math.cos(U.angle*(1-U.penumbra)),K.decay=U.decay,r.spot[v]=K;const V=U.shadow;if(U.map&&(r.spotLightMap[A]=U.map,A++,V.updateMatrices(U),U.castShadow&&k++),r.spotLightMatrix[v]=V.matrix,U.castShadow){const J=n.get(U);J.shadowIntensity=V.intensity,J.shadowBias=V.bias,J.shadowNormalBias=V.normalBias,J.shadowRadius=V.radius,J.shadowMapSize=V.mapSize,r.spotShadow[v]=J,r.spotShadowMap[v]=W,N++}v++}else if(U.isRectAreaLight){const K=e.get(U);K.color.copy(L).multiplyScalar(q),K.halfWidth.set(U.width*.5,0,0),K.halfHeight.set(0,U.height*.5,0),r.rectArea[x]=K,x++}else if(U.isPointLight){const K=e.get(U);if(K.color.copy(U.color).multiplyScalar(U.intensity),K.distance=U.distance,K.decay=U.decay,U.castShadow){const V=U.shadow,J=n.get(U);J.shadowIntensity=V.intensity,J.shadowBias=V.bias,J.shadowNormalBias=V.normalBias,J.shadowRadius=V.radius,J.shadowMapSize=V.mapSize,J.shadowCameraNear=V.camera.near,J.shadowCameraFar=V.camera.far,r.pointShadow[b]=J,r.pointShadowMap[b]=W,r.pointShadowMatrix[b]=U.shadow.matrix,M++}r.point[b]=K,b++}else if(U.isHemisphereLight){const K=e.get(U);K.skyColor.copy(U.color).multiplyScalar(q),K.groundColor.copy(U.groundColor).multiplyScalar(q),r.hemi[y]=K,y++}}x>0&&(t.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=Ft.LTC_FLOAT_1,r.rectAreaLTC2=Ft.LTC_FLOAT_2):(r.rectAreaLTC1=Ft.LTC_HALF_1,r.rectAreaLTC2=Ft.LTC_HALF_2)),r.ambient[0]=d,r.ambient[1]=f,r.ambient[2]=m;const D=r.hash;(D.directionalLength!==p||D.pointLength!==b||D.spotLength!==v||D.rectAreaLength!==x||D.hemiLength!==y||D.numDirectionalShadows!==S||D.numPointShadows!==M||D.numSpotShadows!==N||D.numSpotMaps!==A||D.numLightProbes!==C)&&(r.directional.length=p,r.spot.length=v,r.rectArea.length=x,r.point.length=b,r.hemi.length=y,r.directionalShadow.length=S,r.directionalShadowMap.length=S,r.pointShadow.length=M,r.pointShadowMap.length=M,r.spotShadow.length=N,r.spotShadowMap.length=N,r.directionalShadowMatrix.length=S,r.pointShadowMatrix.length=M,r.spotLightMatrix.length=N+A-k,r.spotLightMap.length=A,r.numSpotLightShadowsWithMaps=k,r.numLightProbes=C,D.directionalLength=p,D.pointLength=b,D.spotLength=v,D.rectAreaLength=x,D.hemiLength=y,D.numDirectionalShadows=S,D.numPointShadows=M,D.numSpotShadows=N,D.numSpotMaps=A,D.numLightProbes=C,r.version=XLe++)}function c(u,d){let f=0,m=0,p=0,b=0,v=0;const x=d.matrixWorldInverse;for(let y=0,S=u.length;y<S;y++){const M=u[y];if(M.isDirectionalLight){const N=r.directional[f];N.direction.setFromMatrixPosition(M.matrixWorld),i.setFromMatrixPosition(M.target.matrixWorld),N.direction.sub(i),N.direction.transformDirection(x),f++}else if(M.isSpotLight){const N=r.spot[p];N.position.setFromMatrixPosition(M.matrixWorld),N.position.applyMatrix4(x),N.direction.setFromMatrixPosition(M.matrixWorld),i.setFromMatrixPosition(M.target.matrixWorld),N.direction.sub(i),N.direction.transformDirection(x),p++}else if(M.isRectAreaLight){const N=r.rectArea[b];N.position.setFromMatrixPosition(M.matrixWorld),N.position.applyMatrix4(x),o.identity(),a.copy(M.matrixWorld),a.premultiply(x),o.extractRotation(a),N.halfWidth.set(M.width*.5,0,0),N.halfHeight.set(0,M.height*.5,0),N.halfWidth.applyMatrix4(o),N.halfHeight.applyMatrix4(o),b++}else if(M.isPointLight){const N=r.point[m];N.position.setFromMatrixPosition(M.matrixWorld),N.position.applyMatrix4(x),m++}else if(M.isHemisphereLight){const N=r.hemi[v];N.direction.setFromMatrixPosition(M.matrixWorld),N.direction.transformDirection(x),v++}}}return{setup:l,setupView:c,state:r}}function bG(t){const e=new ZLe(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 QLe(t){let e=new WeakMap;function n(i,a=0){const o=e.get(i);let l;return o===void 0?(l=new bG(t),e.set(i,[l])):a>=o.length?(l=new bG(t),o.push(l)):l=o[a],l}function r(){e=new WeakMap}return{get:n,dispose:r}}const JLe=`void main() {
  3926. gl_Position = vec4( position, 1.0 );
  3927. }`,eIe=`uniform sampler2D shadow_pass;
  3928. uniform vec2 resolution;
  3929. uniform float radius;
  3930. void main() {
  3931. const float samples = float( VSM_SAMPLES );
  3932. float mean = 0.0;
  3933. float squared_mean = 0.0;
  3934. float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
  3935. float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
  3936. for ( float i = 0.0; i < samples; i ++ ) {
  3937. float uvOffset = uvStart + i * uvStride;
  3938. #ifdef HORIZONTAL_PASS
  3939. vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg;
  3940. mean += distribution.x;
  3941. squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
  3942. #else
  3943. float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r;
  3944. mean += depth;
  3945. squared_mean += depth * depth;
  3946. #endif
  3947. }
  3948. mean = mean / samples;
  3949. squared_mean = squared_mean / samples;
  3950. float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
  3951. gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
  3952. }`,tIe=[new nt(1,0,0),new nt(-1,0,0),new nt(0,1,0),new nt(0,-1,0),new nt(0,0,1),new nt(0,0,-1)],nIe=[new nt(0,-1,0),new nt(0,-1,0),new nt(0,0,1),new nt(0,0,-1),new nt(0,-1,0),new nt(0,-1,0)],yG=new mi,Mb=new nt,Mk=new nt;function rIe(t,e,n){let r=new lL;const i=new Mn,a=new Mn,o=new Mi,l=new mRe,c=new pRe,u={},d=n.maxTextureSize,f={[Jd]:_s,[_s]:Jd,[Il]:Il},m=new ic({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Mn},radius:{value:4}},vertexShader:JLe,fragmentShader:eIe}),p=m.clone();p.defines.HORIZONTAL_PASS=1;const b=new yl;b.setAttribute("position",new Co(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new hl(b,m),x=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=ow;let y=this.type;this.render=function(k,C,D){if(x.enabled===!1||x.autoUpdate===!1&&x.needsUpdate===!1||k.length===0)return;k.type===t3e&&(un("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),k.type=ow);const T=t.getRenderTarget(),R=t.getActiveCubeFace(),U=t.getActiveMipmapLevel(),L=t.state;L.setBlending(au),L.buffers.depth.getReversed()===!0?L.buffers.color.setClear(0,0,0,0):L.buffers.color.setClear(1,1,1,1),L.buffers.depth.setTest(!0),L.setScissorTest(!1);const q=y!==this.type;q&&C.traverse(function(j){j.material&&(Array.isArray(j.material)?j.material.forEach(W=>W.needsUpdate=!0):j.material.needsUpdate=!0)});for(let j=0,W=k.length;j<W;j++){const K=k[j],V=K.shadow;if(V===void 0){un("WebGLShadowMap:",K,"has no shadow.");continue}if(V.autoUpdate===!1&&V.needsUpdate===!1)continue;i.copy(V.mapSize);const J=V.getFrameExtents();if(i.multiply(J),a.copy(V.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(a.x=Math.floor(d/J.x),i.x=a.x*J.x,V.mapSize.x=a.x),i.y>d&&(a.y=Math.floor(d/J.y),i.y=a.y*J.y,V.mapSize.y=a.y)),V.map===null||q===!0){if(V.map!==null&&(V.map.depthTexture!==null&&(V.map.depthTexture.dispose(),V.map.depthTexture=null),V.map.dispose()),this.type===Bb){if(K.isPointLight){un("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}V.map=new Kl(i.x,i.y,{format:Tg,type:yu,minFilter:Ua,magFilter:Ua,generateMipmaps:!1}),V.map.texture.name=K.name+".shadowMap",V.map.depthTexture=new X0(i.x,i.y,$l),V.map.depthTexture.name=K.name+".shadowMapDepth",V.map.depthTexture.format=vu,V.map.depthTexture.compareFunction=null,V.map.depthTexture.minFilter=Ma,V.map.depthTexture.magFilter=Ma}else{K.isPointLight?(V.map=new Mee(i.x),V.map.depthTexture=new dRe(i.x,rc)):(V.map=new Kl(i.x,i.y),V.map.depthTexture=new X0(i.x,i.y,rc)),V.map.depthTexture.name=K.name+".shadowMap",V.map.depthTexture.format=vu;const te=t.state.buffers.depth.getReversed();this.type===ow?(V.map.depthTexture.compareFunction=te?rL:nL,V.map.depthTexture.minFilter=Ua,V.map.depthTexture.magFilter=Ua):(V.map.depthTexture.compareFunction=null,V.map.depthTexture.minFilter=Ma,V.map.depthTexture.magFilter=Ma)}V.camera.updateProjectionMatrix()}const ne=V.map.isWebGLCubeRenderTarget?6:1;for(let te=0;te<ne;te++){if(V.map.isWebGLCubeRenderTarget)t.setRenderTarget(V.map,te),t.clear();else{te===0&&(t.setRenderTarget(V.map),t.clear());const z=V.getViewport(te);o.set(a.x*z.x,a.y*z.y,a.x*z.z,a.y*z.w),L.viewport(o)}if(K.isPointLight){const z=V.camera,H=V.matrix,Z=K.distance||z.far;Z!==z.far&&(z.far=Z,z.updateProjectionMatrix()),Mb.setFromMatrixPosition(K.matrixWorld),z.position.copy(Mb),Mk.copy(z.position),Mk.add(tIe[te]),z.up.copy(nIe[te]),z.lookAt(Mk),z.updateMatrixWorld(),H.makeTranslation(-Mb.x,-Mb.y,-Mb.z),yG.multiplyMatrices(z.projectionMatrix,z.matrixWorldInverse),V._frustum.setFromProjectionMatrix(yG,z.coordinateSystem,z.reversedDepth)}else V.updateMatrices(K);r=V.getFrustum(),N(C,D,V.camera,K,this.type)}V.isPointLightShadow!==!0&&this.type===Bb&&S(V,D),V.needsUpdate=!1}y=this.type,x.needsUpdate=!1,t.setRenderTarget(T,R,U)};function S(k,C){const D=e.update(v);m.defines.VSM_SAMPLES!==k.blurSamples&&(m.defines.VSM_SAMPLES=k.blurSamples,p.defines.VSM_SAMPLES=k.blurSamples,m.needsUpdate=!0,p.needsUpdate=!0),k.mapPass===null&&(k.mapPass=new Kl(i.x,i.y,{format:Tg,type:yu})),m.uniforms.shadow_pass.value=k.map.depthTexture,m.uniforms.resolution.value=k.mapSize,m.uniforms.radius.value=k.radius,t.setRenderTarget(k.mapPass),t.clear(),t.renderBufferDirect(C,null,D,m,v,null),p.uniforms.shadow_pass.value=k.mapPass.texture,p.uniforms.resolution.value=k.mapSize,p.uniforms.radius.value=k.radius,t.setRenderTarget(k.map),t.clear(),t.renderBufferDirect(C,null,D,p,v,null)}function M(k,C,D,T){let R=null;const U=D.isPointLight===!0?k.customDistanceMaterial:k.customDepthMaterial;if(U!==void 0)R=U;else if(R=D.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||C.alphaToCoverage===!0){const L=R.uuid,q=C.uuid;let j=u[L];j===void 0&&(j={},u[L]=j);let W=j[q];W===void 0&&(W=R.clone(),j[q]=W,C.addEventListener("dispose",A)),R=W}if(R.visible=C.visible,R.wireframe=C.wireframe,T===Bb?R.side=C.shadowSide!==null?C.shadowSide:C.side:R.side=C.shadowSide!==null?C.shadowSide:f[C.side],R.alphaMap=C.alphaMap,R.alphaTest=C.alphaToCoverage===!0?.5:C.alphaTest,R.map=C.map,R.clipShadows=C.clipShadows,R.clippingPlanes=C.clippingPlanes,R.clipIntersection=C.clipIntersection,R.displacementMap=C.displacementMap,R.displacementScale=C.displacementScale,R.displacementBias=C.displacementBias,R.wireframeLinewidth=C.wireframeLinewidth,R.linewidth=C.linewidth,D.isPointLight===!0&&R.isMeshDistanceMaterial===!0){const L=t.properties.get(R);L.light=D}return R}function N(k,C,D,T,R){if(k.visible===!1)return;if(k.layers.test(C.layers)&&(k.isMesh||k.isLine||k.isPoints)&&(k.castShadow||k.receiveShadow&&R===Bb)&&(!k.frustumCulled||r.intersectsObject(k))){k.modelViewMatrix.multiplyMatrices(D.matrixWorldInverse,k.matrixWorld);const q=e.update(k),j=k.material;if(Array.isArray(j)){const W=q.groups;for(let K=0,V=W.length;K<V;K++){const J=W[K],ne=j[J.materialIndex];if(ne&&ne.visible){const te=M(k,ne,T,R);k.onBeforeShadow(t,k,C,D,q,te,J),t.renderBufferDirect(D,null,q,te,k,J),k.onAfterShadow(t,k,C,D,q,te,J)}}}else if(j.visible){const W=M(k,j,T,R);k.onBeforeShadow(t,k,C,D,q,W,null),t.renderBufferDirect(D,null,q,W,k,null),k.onAfterShadow(t,k,C,D,q,W,null)}}const L=k.children;for(let q=0,j=L.length;q<j;q++)N(L[q],C,D,T,R)}function A(k){k.target.removeEventListener("dispose",A);for(const D in u){const T=u[D],R=k.target.uuid;R in T&&(T[R].dispose(),delete T[R])}}}const iIe={[A3]:T3,[C3]:P3,[k3]:R3,[Ng]:j3,[T3]:A3,[P3]:C3,[R3]:k3,[j3]:Ng};function aIe(t,e){function n(){let re=!1;const Fe=new Mi;let ve=null;const $e=new Mi(0,0,0,0);return{setMask:function(Le){ve!==Le&&!re&&(t.colorMask(Le,Le,Le,Le),ve=Le)},setLocked:function(Le){re=Le},setClear:function(Le,Ae,Ge,it,Ot){Ot===!0&&(Le*=it,Ae*=it,Ge*=it),Fe.set(Le,Ae,Ge,it),$e.equals(Fe)===!1&&(t.clearColor(Le,Ae,Ge,it),$e.copy(Fe))},reset:function(){re=!1,ve=null,$e.set(-1,0,0,0)}}}function r(){let re=!1,Fe=!1,ve=null,$e=null,Le=null;return{setReversed:function(Ae){if(Fe!==Ae){const Ge=e.get("EXT_clip_control");Ae?Ge.clipControlEXT(Ge.LOWER_LEFT_EXT,Ge.ZERO_TO_ONE_EXT):Ge.clipControlEXT(Ge.LOWER_LEFT_EXT,Ge.NEGATIVE_ONE_TO_ONE_EXT),Fe=Ae;const it=Le;Le=null,this.setClear(it)}},getReversed:function(){return Fe},setTest:function(Ae){Ae?oe(t.DEPTH_TEST):Ne(t.DEPTH_TEST)},setMask:function(Ae){ve!==Ae&&!re&&(t.depthMask(Ae),ve=Ae)},setFunc:function(Ae){if(Fe&&(Ae=iIe[Ae]),$e!==Ae){switch(Ae){case A3:t.depthFunc(t.NEVER);break;case T3:t.depthFunc(t.ALWAYS);break;case C3:t.depthFunc(t.LESS);break;case Ng:t.depthFunc(t.LEQUAL);break;case k3:t.depthFunc(t.EQUAL);break;case j3:t.depthFunc(t.GEQUAL);break;case P3:t.depthFunc(t.GREATER);break;case R3:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}$e=Ae}},setLocked:function(Ae){re=Ae},setClear:function(Ae){Le!==Ae&&(Fe&&(Ae=1-Ae),t.clearDepth(Ae),Le=Ae)},reset:function(){re=!1,ve=null,$e=null,Le=null,Fe=!1}}}function i(){let re=!1,Fe=null,ve=null,$e=null,Le=null,Ae=null,Ge=null,it=null,Ot=null;return{setTest:function(kt){re||(kt?oe(t.STENCIL_TEST):Ne(t.STENCIL_TEST))},setMask:function(kt){Fe!==kt&&!re&&(t.stencilMask(kt),Fe=kt)},setFunc:function(kt,on,Ut){(ve!==kt||$e!==on||Le!==Ut)&&(t.stencilFunc(kt,on,Ut),ve=kt,$e=on,Le=Ut)},setOp:function(kt,on,Ut){(Ae!==kt||Ge!==on||it!==Ut)&&(t.stencilOp(kt,on,Ut),Ae=kt,Ge=on,it=Ut)},setLocked:function(kt){re=kt},setClear:function(kt){Ot!==kt&&(t.clearStencil(kt),Ot=kt)},reset:function(){re=!1,Fe=null,ve=null,$e=null,Le=null,Ae=null,Ge=null,it=null,Ot=null}}}const a=new n,o=new r,l=new i,c=new WeakMap,u=new WeakMap;let d={},f={},m=new WeakMap,p=[],b=null,v=!1,x=null,y=null,S=null,M=null,N=null,A=null,k=null,C=new Rn(0,0,0),D=0,T=!1,R=null,U=null,L=null,q=null,j=null;const W=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let K=!1,V=0;const J=t.getParameter(t.VERSION);J.indexOf("WebGL")!==-1?(V=parseFloat(/^WebGL (\d)/.exec(J)[1]),K=V>=1):J.indexOf("OpenGL ES")!==-1&&(V=parseFloat(/^OpenGL ES (\d)/.exec(J)[1]),K=V>=2);let ne=null,te={};const z=t.getParameter(t.SCISSOR_BOX),H=t.getParameter(t.VIEWPORT),Z=new Mi().fromArray(z),ee=new Mi().fromArray(H);function he(re,Fe,ve,$e){const Le=new Uint8Array(4),Ae=t.createTexture();t.bindTexture(re,Ae),t.texParameteri(re,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(re,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let Ge=0;Ge<ve;Ge++)re===t.TEXTURE_3D||re===t.TEXTURE_2D_ARRAY?t.texImage3D(Fe,0,t.RGBA,1,1,$e,0,t.RGBA,t.UNSIGNED_BYTE,Le):t.texImage2D(Fe+Ge,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Le);return Ae}const fe={};fe[t.TEXTURE_2D]=he(t.TEXTURE_2D,t.TEXTURE_2D,1),fe[t.TEXTURE_CUBE_MAP]=he(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),fe[t.TEXTURE_2D_ARRAY]=he(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),fe[t.TEXTURE_3D]=he(t.TEXTURE_3D,t.TEXTURE_3D,1,1),a.setClear(0,0,0,1),o.setClear(1),l.setClear(0),oe(t.DEPTH_TEST),o.setFunc(Ng),X(!1),$(xV),oe(t.CULL_FACE),G(au);function oe(re){d[re]!==!0&&(t.enable(re),d[re]=!0)}function Ne(re){d[re]!==!1&&(t.disable(re),d[re]=!1)}function ge(re,Fe){return f[re]!==Fe?(t.bindFramebuffer(re,Fe),f[re]=Fe,re===t.DRAW_FRAMEBUFFER&&(f[t.FRAMEBUFFER]=Fe),re===t.FRAMEBUFFER&&(f[t.DRAW_FRAMEBUFFER]=Fe),!0):!1}function Se(re,Fe){let ve=p,$e=!1;if(re){ve=m.get(Fe),ve===void 0&&(ve=[],m.set(Fe,ve));const Le=re.textures;if(ve.length!==Le.length||ve[0]!==t.COLOR_ATTACHMENT0){for(let Ae=0,Ge=Le.length;Ae<Ge;Ae++)ve[Ae]=t.COLOR_ATTACHMENT0+Ae;ve.length=Le.length,$e=!0}}else ve[0]!==t.BACK&&(ve[0]=t.BACK,$e=!0);$e&&t.drawBuffers(ve)}function Re(re){return b!==re?(t.useProgram(re),b=re,!0):!1}const de={[Jh]:t.FUNC_ADD,[r3e]:t.FUNC_SUBTRACT,[i3e]:t.FUNC_REVERSE_SUBTRACT};de[a3e]=t.MIN,de[s3e]=t.MAX;const Qe={[o3e]:t.ZERO,[l3e]:t.ONE,[c3e]:t.SRC_COLOR,[E3]:t.SRC_ALPHA,[p3e]:t.SRC_ALPHA_SATURATE,[f3e]:t.DST_COLOR,[d3e]:t.DST_ALPHA,[u3e]:t.ONE_MINUS_SRC_COLOR,[N3]:t.ONE_MINUS_SRC_ALPHA,[m3e]:t.ONE_MINUS_DST_COLOR,[h3e]:t.ONE_MINUS_DST_ALPHA,[g3e]:t.CONSTANT_COLOR,[x3e]:t.ONE_MINUS_CONSTANT_COLOR,[b3e]:t.CONSTANT_ALPHA,[y3e]:t.ONE_MINUS_CONSTANT_ALPHA};function G(re,Fe,ve,$e,Le,Ae,Ge,it,Ot,kt){if(re===au){v===!0&&(Ne(t.BLEND),v=!1);return}if(v===!1&&(oe(t.BLEND),v=!0),re!==n3e){if(re!==x||kt!==T){if((y!==Jh||N!==Jh)&&(t.blendEquation(t.FUNC_ADD),y=Jh,N=Jh),kt)switch(re){case ig:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case bV:t.blendFunc(t.ONE,t.ONE);break;case yV:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case vV:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:Kn("WebGLState: Invalid blending: ",re);break}else switch(re){case ig:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case bV:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case yV:Kn("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case vV:Kn("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Kn("WebGLState: Invalid blending: ",re);break}S=null,M=null,A=null,k=null,C.set(0,0,0),D=0,x=re,T=kt}return}Le=Le||Fe,Ae=Ae||ve,Ge=Ge||$e,(Fe!==y||Le!==N)&&(t.blendEquationSeparate(de[Fe],de[Le]),y=Fe,N=Le),(ve!==S||$e!==M||Ae!==A||Ge!==k)&&(t.blendFuncSeparate(Qe[ve],Qe[$e],Qe[Ae],Qe[Ge]),S=ve,M=$e,A=Ae,k=Ge),(it.equals(C)===!1||Ot!==D)&&(t.blendColor(it.r,it.g,it.b,Ot),C.copy(it),D=Ot),x=re,T=!1}function ie(re,Fe){re.side===Il?Ne(t.CULL_FACE):oe(t.CULL_FACE);let ve=re.side===_s;Fe&&(ve=!ve),X(ve),re.blending===ig&&re.transparent===!1?G(au):G(re.blending,re.blendEquation,re.blendSrc,re.blendDst,re.blendEquationAlpha,re.blendSrcAlpha,re.blendDstAlpha,re.blendColor,re.blendAlpha,re.premultipliedAlpha),o.setFunc(re.depthFunc),o.setTest(re.depthTest),o.setMask(re.depthWrite),a.setMask(re.colorWrite);const $e=re.stencilWrite;l.setTest($e),$e&&(l.setMask(re.stencilWriteMask),l.setFunc(re.stencilFunc,re.stencilRef,re.stencilFuncMask),l.setOp(re.stencilFail,re.stencilZFail,re.stencilZPass)),ce(re.polygonOffset,re.polygonOffsetFactor,re.polygonOffsetUnits),re.alphaToCoverage===!0?oe(t.SAMPLE_ALPHA_TO_COVERAGE):Ne(t.SAMPLE_ALPHA_TO_COVERAGE)}function X(re){R!==re&&(re?t.frontFace(t.CW):t.frontFace(t.CCW),R=re)}function $(re){re!==JPe?(oe(t.CULL_FACE),re!==U&&(re===xV?t.cullFace(t.BACK):re===e3e?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):Ne(t.CULL_FACE),U=re}function I(re){re!==L&&(K&&t.lineWidth(re),L=re)}function ce(re,Fe,ve){re?(oe(t.POLYGON_OFFSET_FILL),(q!==Fe||j!==ve)&&(t.polygonOffset(Fe,ve),q=Fe,j=ve)):Ne(t.POLYGON_OFFSET_FILL)}function Ee(re){re?oe(t.SCISSOR_TEST):Ne(t.SCISSOR_TEST)}function Ie(re){re===void 0&&(re=t.TEXTURE0+W-1),ne!==re&&(t.activeTexture(re),ne=re)}function le(re,Fe,ve){ve===void 0&&(ne===null?ve=t.TEXTURE0+W-1:ve=ne);let $e=te[ve];$e===void 0&&($e={type:void 0,texture:void 0},te[ve]=$e),($e.type!==re||$e.texture!==Fe)&&(ne!==ve&&(t.activeTexture(ve),ne=ve),t.bindTexture(re,Fe||fe[re]),$e.type=re,$e.texture=Fe)}function B(){const re=te[ne];re!==void 0&&re.type!==void 0&&(t.bindTexture(re.type,null),re.type=void 0,re.texture=void 0)}function O(){try{t.compressedTexImage2D(...arguments)}catch(re){Kn("WebGLState:",re)}}function Y(){try{t.compressedTexImage3D(...arguments)}catch(re){Kn("WebGLState:",re)}}function pe(){try{t.texSubImage2D(...arguments)}catch(re){Kn("WebGLState:",re)}}function we(){try{t.texSubImage3D(...arguments)}catch(re){Kn("WebGLState:",re)}}function ae(){try{t.compressedTexSubImage2D(...arguments)}catch(re){Kn("WebGLState:",re)}}function ke(){try{t.compressedTexSubImage3D(...arguments)}catch(re){Kn("WebGLState:",re)}}function De(){try{t.texStorage2D(...arguments)}catch(re){Kn("WebGLState:",re)}}function Ke(){try{t.texStorage3D(...arguments)}catch(re){Kn("WebGLState:",re)}}function et(){try{t.texImage2D(...arguments)}catch(re){Kn("WebGLState:",re)}}function Ye(){try{t.texImage3D(...arguments)}catch(re){Kn("WebGLState:",re)}}function se(re){Z.equals(re)===!1&&(t.scissor(re.x,re.y,re.z,re.w),Z.copy(re))}function ye(re){ee.equals(re)===!1&&(t.viewport(re.x,re.y,re.z,re.w),ee.copy(re))}function Ce(re,Fe){let ve=u.get(Fe);ve===void 0&&(ve=new WeakMap,u.set(Fe,ve));let $e=ve.get(re);$e===void 0&&($e=t.getUniformBlockIndex(Fe,re.name),ve.set(re,$e))}function Ue(re,Fe){const $e=u.get(Fe).get(re);c.get(Fe)!==$e&&(t.uniformBlockBinding(Fe,$e,re.__bindingPointIndex),c.set(Fe,$e))}function dt(){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={},ne=null,te={},f={},m=new WeakMap,p=[],b=null,v=!1,x=null,y=null,S=null,M=null,N=null,A=null,k=null,C=new Rn(0,0,0),D=0,T=!1,R=null,U=null,L=null,q=null,j=null,Z.set(0,0,t.canvas.width,t.canvas.height),ee.set(0,0,t.canvas.width,t.canvas.height),a.reset(),o.reset(),l.reset()}return{buffers:{color:a,depth:o,stencil:l},enable:oe,disable:Ne,bindFramebuffer:ge,drawBuffers:Se,useProgram:Re,setBlending:G,setMaterial:ie,setFlipSided:X,setCullFace:$,setLineWidth:I,setPolygonOffset:ce,setScissorTest:Ee,activeTexture:Ie,bindTexture:le,unbindTexture:B,compressedTexImage2D:O,compressedTexImage3D:Y,texImage2D:et,texImage3D:Ye,updateUBOMapping:Ce,uniformBlockBinding:Ue,texStorage2D:De,texStorage3D:Ke,texSubImage2D:pe,texSubImage3D:we,compressedTexSubImage2D:ae,compressedTexSubImage3D:ke,scissor:se,viewport:ye,reset:dt}}function sIe(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 Mn,d=new WeakMap;let f;const m=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function b(B,O){return p?new OffscreenCanvas(B,O):BS("canvas")}function v(B,O,Y){let pe=1;const we=le(B);if((we.width>Y||we.height>Y)&&(pe=Y/Math.max(we.width,we.height)),pe<1)if(typeof HTMLImageElement<"u"&&B instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&B instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&B instanceof ImageBitmap||typeof VideoFrame<"u"&&B instanceof VideoFrame){const ae=Math.floor(pe*we.width),ke=Math.floor(pe*we.height);f===void 0&&(f=b(ae,ke));const De=O?b(ae,ke):f;return De.width=ae,De.height=ke,De.getContext("2d").drawImage(B,0,0,ae,ke),un("WebGLRenderer: Texture has been resized from ("+we.width+"x"+we.height+") to ("+ae+"x"+ke+")."),De}else return"data"in B&&un("WebGLRenderer: Image in DataTexture is too big ("+we.width+"x"+we.height+")."),B;return B}function x(B){return B.generateMipmaps}function y(B){t.generateMipmap(B)}function S(B){return B.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:B.isWebGL3DRenderTarget?t.TEXTURE_3D:B.isWebGLArrayRenderTarget||B.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function M(B,O,Y,pe,we=!1){if(B!==null){if(t[B]!==void 0)return t[B];un("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+B+"'")}let ae=O;if(O===t.RED&&(Y===t.FLOAT&&(ae=t.R32F),Y===t.HALF_FLOAT&&(ae=t.R16F),Y===t.UNSIGNED_BYTE&&(ae=t.R8)),O===t.RED_INTEGER&&(Y===t.UNSIGNED_BYTE&&(ae=t.R8UI),Y===t.UNSIGNED_SHORT&&(ae=t.R16UI),Y===t.UNSIGNED_INT&&(ae=t.R32UI),Y===t.BYTE&&(ae=t.R8I),Y===t.SHORT&&(ae=t.R16I),Y===t.INT&&(ae=t.R32I)),O===t.RG&&(Y===t.FLOAT&&(ae=t.RG32F),Y===t.HALF_FLOAT&&(ae=t.RG16F),Y===t.UNSIGNED_BYTE&&(ae=t.RG8)),O===t.RG_INTEGER&&(Y===t.UNSIGNED_BYTE&&(ae=t.RG8UI),Y===t.UNSIGNED_SHORT&&(ae=t.RG16UI),Y===t.UNSIGNED_INT&&(ae=t.RG32UI),Y===t.BYTE&&(ae=t.RG8I),Y===t.SHORT&&(ae=t.RG16I),Y===t.INT&&(ae=t.RG32I)),O===t.RGB_INTEGER&&(Y===t.UNSIGNED_BYTE&&(ae=t.RGB8UI),Y===t.UNSIGNED_SHORT&&(ae=t.RGB16UI),Y===t.UNSIGNED_INT&&(ae=t.RGB32UI),Y===t.BYTE&&(ae=t.RGB8I),Y===t.SHORT&&(ae=t.RGB16I),Y===t.INT&&(ae=t.RGB32I)),O===t.RGBA_INTEGER&&(Y===t.UNSIGNED_BYTE&&(ae=t.RGBA8UI),Y===t.UNSIGNED_SHORT&&(ae=t.RGBA16UI),Y===t.UNSIGNED_INT&&(ae=t.RGBA32UI),Y===t.BYTE&&(ae=t.RGBA8I),Y===t.SHORT&&(ae=t.RGBA16I),Y===t.INT&&(ae=t.RGBA32I)),O===t.RGB&&(Y===t.UNSIGNED_INT_5_9_9_9_REV&&(ae=t.RGB9_E5),Y===t.UNSIGNED_INT_10F_11F_11F_REV&&(ae=t.R11F_G11F_B10F)),O===t.RGBA){const ke=we?US:Vn.getTransfer(pe);Y===t.FLOAT&&(ae=t.RGBA32F),Y===t.HALF_FLOAT&&(ae=t.RGBA16F),Y===t.UNSIGNED_BYTE&&(ae=ke===lr?t.SRGB8_ALPHA8:t.RGBA8),Y===t.UNSIGNED_SHORT_4_4_4_4&&(ae=t.RGBA4),Y===t.UNSIGNED_SHORT_5_5_5_1&&(ae=t.RGB5_A1)}return(ae===t.R16F||ae===t.R32F||ae===t.RG16F||ae===t.RG32F||ae===t.RGBA16F||ae===t.RGBA32F)&&e.get("EXT_color_buffer_float"),ae}function N(B,O){let Y;return B?O===null||O===rc||O===q0?Y=t.DEPTH24_STENCIL8:O===$l?Y=t.DEPTH32F_STENCIL8:O===W0&&(Y=t.DEPTH24_STENCIL8,un("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):O===null||O===rc||O===q0?Y=t.DEPTH_COMPONENT24:O===$l?Y=t.DEPTH_COMPONENT32F:O===W0&&(Y=t.DEPTH_COMPONENT16),Y}function A(B,O){return x(B)===!0||B.isFramebufferTexture&&B.minFilter!==Ma&&B.minFilter!==Ua?Math.log2(Math.max(O.width,O.height))+1:B.mipmaps!==void 0&&B.mipmaps.length>0?B.mipmaps.length:B.isCompressedTexture&&Array.isArray(B.image)?O.mipmaps.length:1}function k(B){const O=B.target;O.removeEventListener("dispose",k),D(O),O.isVideoTexture&&d.delete(O)}function C(B){const O=B.target;O.removeEventListener("dispose",C),R(O)}function D(B){const O=r.get(B);if(O.__webglInit===void 0)return;const Y=B.source,pe=m.get(Y);if(pe){const we=pe[O.__cacheKey];we.usedTimes--,we.usedTimes===0&&T(B),Object.keys(pe).length===0&&m.delete(Y)}r.remove(B)}function T(B){const O=r.get(B);t.deleteTexture(O.__webglTexture);const Y=B.source,pe=m.get(Y);delete pe[O.__cacheKey],o.memory.textures--}function R(B){const O=r.get(B);if(B.depthTexture&&(B.depthTexture.dispose(),r.remove(B.depthTexture)),B.isWebGLCubeRenderTarget)for(let pe=0;pe<6;pe++){if(Array.isArray(O.__webglFramebuffer[pe]))for(let we=0;we<O.__webglFramebuffer[pe].length;we++)t.deleteFramebuffer(O.__webglFramebuffer[pe][we]);else t.deleteFramebuffer(O.__webglFramebuffer[pe]);O.__webglDepthbuffer&&t.deleteRenderbuffer(O.__webglDepthbuffer[pe])}else{if(Array.isArray(O.__webglFramebuffer))for(let pe=0;pe<O.__webglFramebuffer.length;pe++)t.deleteFramebuffer(O.__webglFramebuffer[pe]);else t.deleteFramebuffer(O.__webglFramebuffer);if(O.__webglDepthbuffer&&t.deleteRenderbuffer(O.__webglDepthbuffer),O.__webglMultisampledFramebuffer&&t.deleteFramebuffer(O.__webglMultisampledFramebuffer),O.__webglColorRenderbuffer)for(let pe=0;pe<O.__webglColorRenderbuffer.length;pe++)O.__webglColorRenderbuffer[pe]&&t.deleteRenderbuffer(O.__webglColorRenderbuffer[pe]);O.__webglDepthRenderbuffer&&t.deleteRenderbuffer(O.__webglDepthRenderbuffer)}const Y=B.textures;for(let pe=0,we=Y.length;pe<we;pe++){const ae=r.get(Y[pe]);ae.__webglTexture&&(t.deleteTexture(ae.__webglTexture),o.memory.textures--),r.remove(Y[pe])}r.remove(B)}let U=0;function L(){U=0}function q(){const B=U;return B>=i.maxTextures&&un("WebGLTextures: Trying to use "+B+" texture units while this GPU supports only "+i.maxTextures),U+=1,B}function j(B){const O=[];return O.push(B.wrapS),O.push(B.wrapT),O.push(B.wrapR||0),O.push(B.magFilter),O.push(B.minFilter),O.push(B.anisotropy),O.push(B.internalFormat),O.push(B.format),O.push(B.type),O.push(B.generateMipmaps),O.push(B.premultiplyAlpha),O.push(B.flipY),O.push(B.unpackAlignment),O.push(B.colorSpace),O.join()}function W(B,O){const Y=r.get(B);if(B.isVideoTexture&&Ee(B),B.isRenderTargetTexture===!1&&B.isExternalTexture!==!0&&B.version>0&&Y.__version!==B.version){const pe=B.image;if(pe===null)un("WebGLRenderer: Texture marked for update but no image data found.");else if(pe.complete===!1)un("WebGLRenderer: Texture marked for update but image is incomplete");else{fe(Y,B,O);return}}else B.isExternalTexture&&(Y.__webglTexture=B.sourceTexture?B.sourceTexture:null);n.bindTexture(t.TEXTURE_2D,Y.__webglTexture,t.TEXTURE0+O)}function K(B,O){const Y=r.get(B);if(B.isRenderTargetTexture===!1&&B.version>0&&Y.__version!==B.version){fe(Y,B,O);return}else B.isExternalTexture&&(Y.__webglTexture=B.sourceTexture?B.sourceTexture:null);n.bindTexture(t.TEXTURE_2D_ARRAY,Y.__webglTexture,t.TEXTURE0+O)}function V(B,O){const Y=r.get(B);if(B.isRenderTargetTexture===!1&&B.version>0&&Y.__version!==B.version){fe(Y,B,O);return}n.bindTexture(t.TEXTURE_3D,Y.__webglTexture,t.TEXTURE0+O)}function J(B,O){const Y=r.get(B);if(B.isCubeDepthTexture!==!0&&B.version>0&&Y.__version!==B.version){oe(Y,B,O);return}n.bindTexture(t.TEXTURE_CUBE_MAP,Y.__webglTexture,t.TEXTURE0+O)}const ne={[L3]:t.REPEAT,[Jc]:t.CLAMP_TO_EDGE,[I3]:t.MIRRORED_REPEAT},te={[Ma]:t.NEAREST,[w3e]:t.NEAREST_MIPMAP_NEAREST,[j_]:t.NEAREST_MIPMAP_LINEAR,[Ua]:t.LINEAR,[qC]:t.LINEAR_MIPMAP_NEAREST,[mf]:t.LINEAR_MIPMAP_LINEAR},z={[E3e]:t.NEVER,[k3e]:t.ALWAYS,[N3e]:t.LESS,[nL]:t.LEQUAL,[A3e]:t.EQUAL,[rL]:t.GEQUAL,[T3e]:t.GREATER,[C3e]:t.NOTEQUAL};function H(B,O){if(O.type===$l&&e.has("OES_texture_float_linear")===!1&&(O.magFilter===Ua||O.magFilter===qC||O.magFilter===j_||O.magFilter===mf||O.minFilter===Ua||O.minFilter===qC||O.minFilter===j_||O.minFilter===mf)&&un("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri(B,t.TEXTURE_WRAP_S,ne[O.wrapS]),t.texParameteri(B,t.TEXTURE_WRAP_T,ne[O.wrapT]),(B===t.TEXTURE_3D||B===t.TEXTURE_2D_ARRAY)&&t.texParameteri(B,t.TEXTURE_WRAP_R,ne[O.wrapR]),t.texParameteri(B,t.TEXTURE_MAG_FILTER,te[O.magFilter]),t.texParameteri(B,t.TEXTURE_MIN_FILTER,te[O.minFilter]),O.compareFunction&&(t.texParameteri(B,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(B,t.TEXTURE_COMPARE_FUNC,z[O.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(O.magFilter===Ma||O.minFilter!==j_&&O.minFilter!==mf||O.type===$l&&e.has("OES_texture_float_linear")===!1)return;if(O.anisotropy>1||r.get(O).__currentAnisotropy){const Y=e.get("EXT_texture_filter_anisotropic");t.texParameterf(B,Y.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(O.anisotropy,i.getMaxAnisotropy())),r.get(O).__currentAnisotropy=O.anisotropy}}}function Z(B,O){let Y=!1;B.__webglInit===void 0&&(B.__webglInit=!0,O.addEventListener("dispose",k));const pe=O.source;let we=m.get(pe);we===void 0&&(we={},m.set(pe,we));const ae=j(O);if(ae!==B.__cacheKey){we[ae]===void 0&&(we[ae]={texture:t.createTexture(),usedTimes:0},o.memory.textures++,Y=!0),we[ae].usedTimes++;const ke=we[B.__cacheKey];ke!==void 0&&(we[B.__cacheKey].usedTimes--,ke.usedTimes===0&&T(O)),B.__cacheKey=ae,B.__webglTexture=we[ae].texture}return Y}function ee(B,O,Y){return Math.floor(Math.floor(B/Y)/O)}function he(B,O,Y,pe){const ae=B.updateRanges;if(ae.length===0)n.texSubImage2D(t.TEXTURE_2D,0,0,0,O.width,O.height,Y,pe,O.data);else{ae.sort((Ye,se)=>Ye.start-se.start);let ke=0;for(let Ye=1;Ye<ae.length;Ye++){const se=ae[ke],ye=ae[Ye],Ce=se.start+se.count,Ue=ee(ye.start,O.width,4),dt=ee(se.start,O.width,4);ye.start<=Ce+1&&Ue===dt&&ee(ye.start+ye.count-1,O.width,4)===Ue?se.count=Math.max(se.count,ye.start+ye.count-se.start):(++ke,ae[ke]=ye)}ae.length=ke+1;const De=t.getParameter(t.UNPACK_ROW_LENGTH),Ke=t.getParameter(t.UNPACK_SKIP_PIXELS),et=t.getParameter(t.UNPACK_SKIP_ROWS);t.pixelStorei(t.UNPACK_ROW_LENGTH,O.width);for(let Ye=0,se=ae.length;Ye<se;Ye++){const ye=ae[Ye],Ce=Math.floor(ye.start/4),Ue=Math.ceil(ye.count/4),dt=Ce%O.width,re=Math.floor(Ce/O.width),Fe=Ue,ve=1;t.pixelStorei(t.UNPACK_SKIP_PIXELS,dt),t.pixelStorei(t.UNPACK_SKIP_ROWS,re),n.texSubImage2D(t.TEXTURE_2D,0,dt,re,Fe,ve,Y,pe,O.data)}B.clearUpdateRanges(),t.pixelStorei(t.UNPACK_ROW_LENGTH,De),t.pixelStorei(t.UNPACK_SKIP_PIXELS,Ke),t.pixelStorei(t.UNPACK_SKIP_ROWS,et)}}function fe(B,O,Y){let pe=t.TEXTURE_2D;(O.isDataArrayTexture||O.isCompressedArrayTexture)&&(pe=t.TEXTURE_2D_ARRAY),O.isData3DTexture&&(pe=t.TEXTURE_3D);const we=Z(B,O),ae=O.source;n.bindTexture(pe,B.__webglTexture,t.TEXTURE0+Y);const ke=r.get(ae);if(ae.version!==ke.__version||we===!0){n.activeTexture(t.TEXTURE0+Y);const De=Vn.getPrimaries(Vn.workingColorSpace),Ke=O.colorSpace===Md?null:Vn.getPrimaries(O.colorSpace),et=O.colorSpace===Md||De===Ke?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,O.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,O.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,O.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,et);let Ye=v(O.image,!1,i.maxTextureSize);Ye=Ie(O,Ye);const se=a.convert(O.format,O.colorSpace),ye=a.convert(O.type);let Ce=M(O.internalFormat,se,ye,O.colorSpace,O.isVideoTexture);H(pe,O);let Ue;const dt=O.mipmaps,re=O.isVideoTexture!==!0,Fe=ke.__version===void 0||we===!0,ve=ae.dataReady,$e=A(O,Ye);if(O.isDepthTexture)Ce=N(O.format===pf,O.type),Fe&&(re?n.texStorage2D(t.TEXTURE_2D,1,Ce,Ye.width,Ye.height):n.texImage2D(t.TEXTURE_2D,0,Ce,Ye.width,Ye.height,0,se,ye,null));else if(O.isDataTexture)if(dt.length>0){re&&Fe&&n.texStorage2D(t.TEXTURE_2D,$e,Ce,dt[0].width,dt[0].height);for(let Le=0,Ae=dt.length;Le<Ae;Le++)Ue=dt[Le],re?ve&&n.texSubImage2D(t.TEXTURE_2D,Le,0,0,Ue.width,Ue.height,se,ye,Ue.data):n.texImage2D(t.TEXTURE_2D,Le,Ce,Ue.width,Ue.height,0,se,ye,Ue.data);O.generateMipmaps=!1}else re?(Fe&&n.texStorage2D(t.TEXTURE_2D,$e,Ce,Ye.width,Ye.height),ve&&he(O,Ye,se,ye)):n.texImage2D(t.TEXTURE_2D,0,Ce,Ye.width,Ye.height,0,se,ye,Ye.data);else if(O.isCompressedTexture)if(O.isCompressedArrayTexture){re&&Fe&&n.texStorage3D(t.TEXTURE_2D_ARRAY,$e,Ce,dt[0].width,dt[0].height,Ye.depth);for(let Le=0,Ae=dt.length;Le<Ae;Le++)if(Ue=dt[Le],O.format!==el)if(se!==null)if(re){if(ve)if(O.layerUpdates.size>0){const Ge=YV(Ue.width,Ue.height,O.format,O.type);for(const it of O.layerUpdates){const Ot=Ue.data.subarray(it*Ge/Ue.data.BYTES_PER_ELEMENT,(it+1)*Ge/Ue.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Le,0,0,it,Ue.width,Ue.height,1,se,Ot)}O.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Le,0,0,0,Ue.width,Ue.height,Ye.depth,se,Ue.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,Le,Ce,Ue.width,Ue.height,Ye.depth,0,Ue.data,0,0);else un("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else re?ve&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,Le,0,0,0,Ue.width,Ue.height,Ye.depth,se,ye,Ue.data):n.texImage3D(t.TEXTURE_2D_ARRAY,Le,Ce,Ue.width,Ue.height,Ye.depth,0,se,ye,Ue.data)}else{re&&Fe&&n.texStorage2D(t.TEXTURE_2D,$e,Ce,dt[0].width,dt[0].height);for(let Le=0,Ae=dt.length;Le<Ae;Le++)Ue=dt[Le],O.format!==el?se!==null?re?ve&&n.compressedTexSubImage2D(t.TEXTURE_2D,Le,0,0,Ue.width,Ue.height,se,Ue.data):n.compressedTexImage2D(t.TEXTURE_2D,Le,Ce,Ue.width,Ue.height,0,Ue.data):un("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):re?ve&&n.texSubImage2D(t.TEXTURE_2D,Le,0,0,Ue.width,Ue.height,se,ye,Ue.data):n.texImage2D(t.TEXTURE_2D,Le,Ce,Ue.width,Ue.height,0,se,ye,Ue.data)}else if(O.isDataArrayTexture)if(re){if(Fe&&n.texStorage3D(t.TEXTURE_2D_ARRAY,$e,Ce,Ye.width,Ye.height,Ye.depth),ve)if(O.layerUpdates.size>0){const Le=YV(Ye.width,Ye.height,O.format,O.type);for(const Ae of O.layerUpdates){const Ge=Ye.data.subarray(Ae*Le/Ye.data.BYTES_PER_ELEMENT,(Ae+1)*Le/Ye.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,Ae,Ye.width,Ye.height,1,se,ye,Ge)}O.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,Ye.width,Ye.height,Ye.depth,se,ye,Ye.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,Ce,Ye.width,Ye.height,Ye.depth,0,se,ye,Ye.data);else if(O.isData3DTexture)re?(Fe&&n.texStorage3D(t.TEXTURE_3D,$e,Ce,Ye.width,Ye.height,Ye.depth),ve&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,Ye.width,Ye.height,Ye.depth,se,ye,Ye.data)):n.texImage3D(t.TEXTURE_3D,0,Ce,Ye.width,Ye.height,Ye.depth,0,se,ye,Ye.data);else if(O.isFramebufferTexture){if(Fe)if(re)n.texStorage2D(t.TEXTURE_2D,$e,Ce,Ye.width,Ye.height);else{let Le=Ye.width,Ae=Ye.height;for(let Ge=0;Ge<$e;Ge++)n.texImage2D(t.TEXTURE_2D,Ge,Ce,Le,Ae,0,se,ye,null),Le>>=1,Ae>>=1}}else if(dt.length>0){if(re&&Fe){const Le=le(dt[0]);n.texStorage2D(t.TEXTURE_2D,$e,Ce,Le.width,Le.height)}for(let Le=0,Ae=dt.length;Le<Ae;Le++)Ue=dt[Le],re?ve&&n.texSubImage2D(t.TEXTURE_2D,Le,0,0,se,ye,Ue):n.texImage2D(t.TEXTURE_2D,Le,Ce,se,ye,Ue);O.generateMipmaps=!1}else if(re){if(Fe){const Le=le(Ye);n.texStorage2D(t.TEXTURE_2D,$e,Ce,Le.width,Le.height)}ve&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,se,ye,Ye)}else n.texImage2D(t.TEXTURE_2D,0,Ce,se,ye,Ye);x(O)&&y(pe),ke.__version=ae.version,O.onUpdate&&O.onUpdate(O)}B.__version=O.version}function oe(B,O,Y){if(O.image.length!==6)return;const pe=Z(B,O),we=O.source;n.bindTexture(t.TEXTURE_CUBE_MAP,B.__webglTexture,t.TEXTURE0+Y);const ae=r.get(we);if(we.version!==ae.__version||pe===!0){n.activeTexture(t.TEXTURE0+Y);const ke=Vn.getPrimaries(Vn.workingColorSpace),De=O.colorSpace===Md?null:Vn.getPrimaries(O.colorSpace),Ke=O.colorSpace===Md||ke===De?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,O.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,O.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,O.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ke);const et=O.isCompressedTexture||O.image[0].isCompressedTexture,Ye=O.image[0]&&O.image[0].isDataTexture,se=[];for(let Ae=0;Ae<6;Ae++)!et&&!Ye?se[Ae]=v(O.image[Ae],!0,i.maxCubemapSize):se[Ae]=Ye?O.image[Ae].image:O.image[Ae],se[Ae]=Ie(O,se[Ae]);const ye=se[0],Ce=a.convert(O.format,O.colorSpace),Ue=a.convert(O.type),dt=M(O.internalFormat,Ce,Ue,O.colorSpace),re=O.isVideoTexture!==!0,Fe=ae.__version===void 0||pe===!0,ve=we.dataReady;let $e=A(O,ye);H(t.TEXTURE_CUBE_MAP,O);let Le;if(et){re&&Fe&&n.texStorage2D(t.TEXTURE_CUBE_MAP,$e,dt,ye.width,ye.height);for(let Ae=0;Ae<6;Ae++){Le=se[Ae].mipmaps;for(let Ge=0;Ge<Le.length;Ge++){const it=Le[Ge];O.format!==el?Ce!==null?re?ve&&n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Ge,0,0,it.width,it.height,Ce,it.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Ge,dt,it.width,it.height,0,it.data):un("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):re?ve&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Ge,0,0,it.width,it.height,Ce,Ue,it.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Ge,dt,it.width,it.height,0,Ce,Ue,it.data)}}}else{if(Le=O.mipmaps,re&&Fe){Le.length>0&&$e++;const Ae=le(se[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,$e,dt,Ae.width,Ae.height)}for(let Ae=0;Ae<6;Ae++)if(Ye){re?ve&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,0,0,0,se[Ae].width,se[Ae].height,Ce,Ue,se[Ae].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,0,dt,se[Ae].width,se[Ae].height,0,Ce,Ue,se[Ae].data);for(let Ge=0;Ge<Le.length;Ge++){const Ot=Le[Ge].image[Ae].image;re?ve&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Ge+1,0,0,Ot.width,Ot.height,Ce,Ue,Ot.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Ge+1,dt,Ot.width,Ot.height,0,Ce,Ue,Ot.data)}}else{re?ve&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,0,0,0,Ce,Ue,se[Ae]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,0,dt,Ce,Ue,se[Ae]);for(let Ge=0;Ge<Le.length;Ge++){const it=Le[Ge];re?ve&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Ge+1,0,0,Ce,Ue,it.image[Ae]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Ge+1,dt,Ce,Ue,it.image[Ae])}}}x(O)&&y(t.TEXTURE_CUBE_MAP),ae.__version=we.version,O.onUpdate&&O.onUpdate(O)}B.__version=O.version}function Ne(B,O,Y,pe,we,ae){const ke=a.convert(Y.format,Y.colorSpace),De=a.convert(Y.type),Ke=M(Y.internalFormat,ke,De,Y.colorSpace),et=r.get(O),Ye=r.get(Y);if(Ye.__renderTarget=O,!et.__hasExternalTextures){const se=Math.max(1,O.width>>ae),ye=Math.max(1,O.height>>ae);we===t.TEXTURE_3D||we===t.TEXTURE_2D_ARRAY?n.texImage3D(we,ae,Ke,se,ye,O.depth,0,ke,De,null):n.texImage2D(we,ae,Ke,se,ye,0,ke,De,null)}n.bindFramebuffer(t.FRAMEBUFFER,B),ce(O)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,pe,we,Ye.__webglTexture,0,I(O)):(we===t.TEXTURE_2D||we>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&we<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,pe,we,Ye.__webglTexture,ae),n.bindFramebuffer(t.FRAMEBUFFER,null)}function ge(B,O,Y){if(t.bindRenderbuffer(t.RENDERBUFFER,B),O.depthBuffer){const pe=O.depthTexture,we=pe&&pe.isDepthTexture?pe.type:null,ae=N(O.stencilBuffer,we),ke=O.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;ce(O)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,I(O),ae,O.width,O.height):Y?t.renderbufferStorageMultisample(t.RENDERBUFFER,I(O),ae,O.width,O.height):t.renderbufferStorage(t.RENDERBUFFER,ae,O.width,O.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,ke,t.RENDERBUFFER,B)}else{const pe=O.textures;for(let we=0;we<pe.length;we++){const ae=pe[we],ke=a.convert(ae.format,ae.colorSpace),De=a.convert(ae.type),Ke=M(ae.internalFormat,ke,De,ae.colorSpace);ce(O)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,I(O),Ke,O.width,O.height):Y?t.renderbufferStorageMultisample(t.RENDERBUFFER,I(O),Ke,O.width,O.height):t.renderbufferStorage(t.RENDERBUFFER,Ke,O.width,O.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function Se(B,O,Y){const pe=O.isWebGLCubeRenderTarget===!0;if(n.bindFramebuffer(t.FRAMEBUFFER,B),!(O.depthTexture&&O.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const we=r.get(O.depthTexture);if(we.__renderTarget=O,(!we.__webglTexture||O.depthTexture.image.width!==O.width||O.depthTexture.image.height!==O.height)&&(O.depthTexture.image.width=O.width,O.depthTexture.image.height=O.height,O.depthTexture.needsUpdate=!0),pe){if(we.__webglInit===void 0&&(we.__webglInit=!0,O.depthTexture.addEventListener("dispose",k)),we.__webglTexture===void 0){we.__webglTexture=t.createTexture(),n.bindTexture(t.TEXTURE_CUBE_MAP,we.__webglTexture),H(t.TEXTURE_CUBE_MAP,O.depthTexture);const et=a.convert(O.depthTexture.format),Ye=a.convert(O.depthTexture.type);let se;O.depthTexture.format===vu?se=t.DEPTH_COMPONENT24:O.depthTexture.format===pf&&(se=t.DEPTH24_STENCIL8);for(let ye=0;ye<6;ye++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,0,se,O.width,O.height,0,et,Ye,null)}}else W(O.depthTexture,0);const ae=we.__webglTexture,ke=I(O),De=pe?t.TEXTURE_CUBE_MAP_POSITIVE_X+Y:t.TEXTURE_2D,Ke=O.depthTexture.format===pf?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(O.depthTexture.format===vu)ce(O)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,Ke,De,ae,0,ke):t.framebufferTexture2D(t.FRAMEBUFFER,Ke,De,ae,0);else if(O.depthTexture.format===pf)ce(O)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,Ke,De,ae,0,ke):t.framebufferTexture2D(t.FRAMEBUFFER,Ke,De,ae,0);else throw new Error("Unknown depthTexture format")}function Re(B){const O=r.get(B),Y=B.isWebGLCubeRenderTarget===!0;if(O.__boundDepthTexture!==B.depthTexture){const pe=B.depthTexture;if(O.__depthDisposeCallback&&O.__depthDisposeCallback(),pe){const we=()=>{delete O.__boundDepthTexture,delete O.__depthDisposeCallback,pe.removeEventListener("dispose",we)};pe.addEventListener("dispose",we),O.__depthDisposeCallback=we}O.__boundDepthTexture=pe}if(B.depthTexture&&!O.__autoAllocateDepthBuffer)if(Y)for(let pe=0;pe<6;pe++)Se(O.__webglFramebuffer[pe],B,pe);else{const pe=B.texture.mipmaps;pe&&pe.length>0?Se(O.__webglFramebuffer[0],B,0):Se(O.__webglFramebuffer,B,0)}else if(Y){O.__webglDepthbuffer=[];for(let pe=0;pe<6;pe++)if(n.bindFramebuffer(t.FRAMEBUFFER,O.__webglFramebuffer[pe]),O.__webglDepthbuffer[pe]===void 0)O.__webglDepthbuffer[pe]=t.createRenderbuffer(),ge(O.__webglDepthbuffer[pe],B,!1);else{const we=B.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ae=O.__webglDepthbuffer[pe];t.bindRenderbuffer(t.RENDERBUFFER,ae),t.framebufferRenderbuffer(t.FRAMEBUFFER,we,t.RENDERBUFFER,ae)}}else{const pe=B.texture.mipmaps;if(pe&&pe.length>0?n.bindFramebuffer(t.FRAMEBUFFER,O.__webglFramebuffer[0]):n.bindFramebuffer(t.FRAMEBUFFER,O.__webglFramebuffer),O.__webglDepthbuffer===void 0)O.__webglDepthbuffer=t.createRenderbuffer(),ge(O.__webglDepthbuffer,B,!1);else{const we=B.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ae=O.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,ae),t.framebufferRenderbuffer(t.FRAMEBUFFER,we,t.RENDERBUFFER,ae)}}n.bindFramebuffer(t.FRAMEBUFFER,null)}function de(B,O,Y){const pe=r.get(B);O!==void 0&&Ne(pe.__webglFramebuffer,B,B.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),Y!==void 0&&Re(B)}function Qe(B){const O=B.texture,Y=r.get(B),pe=r.get(O);B.addEventListener("dispose",C);const we=B.textures,ae=B.isWebGLCubeRenderTarget===!0,ke=we.length>1;if(ke||(pe.__webglTexture===void 0&&(pe.__webglTexture=t.createTexture()),pe.__version=O.version,o.memory.textures++),ae){Y.__webglFramebuffer=[];for(let De=0;De<6;De++)if(O.mipmaps&&O.mipmaps.length>0){Y.__webglFramebuffer[De]=[];for(let Ke=0;Ke<O.mipmaps.length;Ke++)Y.__webglFramebuffer[De][Ke]=t.createFramebuffer()}else Y.__webglFramebuffer[De]=t.createFramebuffer()}else{if(O.mipmaps&&O.mipmaps.length>0){Y.__webglFramebuffer=[];for(let De=0;De<O.mipmaps.length;De++)Y.__webglFramebuffer[De]=t.createFramebuffer()}else Y.__webglFramebuffer=t.createFramebuffer();if(ke)for(let De=0,Ke=we.length;De<Ke;De++){const et=r.get(we[De]);et.__webglTexture===void 0&&(et.__webglTexture=t.createTexture(),o.memory.textures++)}if(B.samples>0&&ce(B)===!1){Y.__webglMultisampledFramebuffer=t.createFramebuffer(),Y.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,Y.__webglMultisampledFramebuffer);for(let De=0;De<we.length;De++){const Ke=we[De];Y.__webglColorRenderbuffer[De]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,Y.__webglColorRenderbuffer[De]);const et=a.convert(Ke.format,Ke.colorSpace),Ye=a.convert(Ke.type),se=M(Ke.internalFormat,et,Ye,Ke.colorSpace,B.isXRRenderTarget===!0),ye=I(B);t.renderbufferStorageMultisample(t.RENDERBUFFER,ye,se,B.width,B.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+De,t.RENDERBUFFER,Y.__webglColorRenderbuffer[De])}t.bindRenderbuffer(t.RENDERBUFFER,null),B.depthBuffer&&(Y.__webglDepthRenderbuffer=t.createRenderbuffer(),ge(Y.__webglDepthRenderbuffer,B,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(ae){n.bindTexture(t.TEXTURE_CUBE_MAP,pe.__webglTexture),H(t.TEXTURE_CUBE_MAP,O);for(let De=0;De<6;De++)if(O.mipmaps&&O.mipmaps.length>0)for(let Ke=0;Ke<O.mipmaps.length;Ke++)Ne(Y.__webglFramebuffer[De][Ke],B,O,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+De,Ke);else Ne(Y.__webglFramebuffer[De],B,O,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+De,0);x(O)&&y(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(ke){for(let De=0,Ke=we.length;De<Ke;De++){const et=we[De],Ye=r.get(et);let se=t.TEXTURE_2D;(B.isWebGL3DRenderTarget||B.isWebGLArrayRenderTarget)&&(se=B.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(se,Ye.__webglTexture),H(se,et),Ne(Y.__webglFramebuffer,B,et,t.COLOR_ATTACHMENT0+De,se,0),x(et)&&y(se)}n.unbindTexture()}else{let De=t.TEXTURE_2D;if((B.isWebGL3DRenderTarget||B.isWebGLArrayRenderTarget)&&(De=B.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(De,pe.__webglTexture),H(De,O),O.mipmaps&&O.mipmaps.length>0)for(let Ke=0;Ke<O.mipmaps.length;Ke++)Ne(Y.__webglFramebuffer[Ke],B,O,t.COLOR_ATTACHMENT0,De,Ke);else Ne(Y.__webglFramebuffer,B,O,t.COLOR_ATTACHMENT0,De,0);x(O)&&y(De),n.unbindTexture()}B.depthBuffer&&Re(B)}function G(B){const O=B.textures;for(let Y=0,pe=O.length;Y<pe;Y++){const we=O[Y];if(x(we)){const ae=S(B),ke=r.get(we).__webglTexture;n.bindTexture(ae,ke),y(ae),n.unbindTexture()}}}const ie=[],X=[];function $(B){if(B.samples>0){if(ce(B)===!1){const O=B.textures,Y=B.width,pe=B.height;let we=t.COLOR_BUFFER_BIT;const ae=B.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ke=r.get(B),De=O.length>1;if(De)for(let et=0;et<O.length;et++)n.bindFramebuffer(t.FRAMEBUFFER,ke.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+et,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,ke.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+et,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,ke.__webglMultisampledFramebuffer);const Ke=B.texture.mipmaps;Ke&&Ke.length>0?n.bindFramebuffer(t.DRAW_FRAMEBUFFER,ke.__webglFramebuffer[0]):n.bindFramebuffer(t.DRAW_FRAMEBUFFER,ke.__webglFramebuffer);for(let et=0;et<O.length;et++){if(B.resolveDepthBuffer&&(B.depthBuffer&&(we|=t.DEPTH_BUFFER_BIT),B.stencilBuffer&&B.resolveStencilBuffer&&(we|=t.STENCIL_BUFFER_BIT)),De){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,ke.__webglColorRenderbuffer[et]);const Ye=r.get(O[et]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,Ye,0)}t.blitFramebuffer(0,0,Y,pe,0,0,Y,pe,we,t.NEAREST),c===!0&&(ie.length=0,X.length=0,ie.push(t.COLOR_ATTACHMENT0+et),B.depthBuffer&&B.resolveDepthBuffer===!1&&(ie.push(ae),X.push(ae),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,X)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,ie))}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),De)for(let et=0;et<O.length;et++){n.bindFramebuffer(t.FRAMEBUFFER,ke.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+et,t.RENDERBUFFER,ke.__webglColorRenderbuffer[et]);const Ye=r.get(O[et]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,ke.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+et,t.TEXTURE_2D,Ye,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,ke.__webglMultisampledFramebuffer)}else if(B.depthBuffer&&B.resolveDepthBuffer===!1&&c){const O=B.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[O])}}}function I(B){return Math.min(i.maxSamples,B.samples)}function ce(B){const O=r.get(B);return B.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&O.__useRenderToTexture!==!1}function Ee(B){const O=o.render.frame;d.get(B)!==O&&(d.set(B,O),B.update())}function Ie(B,O){const Y=B.colorSpace,pe=B.format,we=B.type;return B.isCompressedTexture===!0||B.isVideoTexture===!0||Y!==Cg&&Y!==Md&&(Vn.getTransfer(Y)===lr?(pe!==el||we!==Hs)&&un("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Kn("WebGLTextures: Unsupported texture color space:",Y)),O}function le(B){return typeof HTMLImageElement<"u"&&B instanceof HTMLImageElement?(u.width=B.naturalWidth||B.width,u.height=B.naturalHeight||B.height):typeof VideoFrame<"u"&&B instanceof VideoFrame?(u.width=B.displayWidth,u.height=B.displayHeight):(u.width=B.width,u.height=B.height),u}this.allocateTextureUnit=q,this.resetTextureUnits=L,this.setTexture2D=W,this.setTexture2DArray=K,this.setTexture3D=V,this.setTextureCube=J,this.rebindTextures=de,this.setupRenderTarget=Qe,this.updateRenderTargetMipmap=G,this.updateMultisampleRenderTarget=$,this.setupDepthRenderbuffer=Re,this.setupFrameBufferTexture=Ne,this.useMultisampledRTT=ce,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function oIe(t,e){function n(r,i=Md){let a;const o=Vn.getTransfer(i);if(r===Hs)return t.UNSIGNED_BYTE;if(r===Z4)return t.UNSIGNED_SHORT_4_4_4_4;if(r===Q4)return t.UNSIGNED_SHORT_5_5_5_1;if(r===nee)return t.UNSIGNED_INT_5_9_9_9_REV;if(r===ree)return t.UNSIGNED_INT_10F_11F_11F_REV;if(r===eee)return t.BYTE;if(r===tee)return t.SHORT;if(r===W0)return t.UNSIGNED_SHORT;if(r===Y4)return t.INT;if(r===rc)return t.UNSIGNED_INT;if(r===$l)return t.FLOAT;if(r===yu)return t.HALF_FLOAT;if(r===iee)return t.ALPHA;if(r===aee)return t.RGB;if(r===el)return t.RGBA;if(r===vu)return t.DEPTH_COMPONENT;if(r===pf)return t.DEPTH_STENCIL;if(r===see)return t.RED;if(r===J4)return t.RED_INTEGER;if(r===Tg)return t.RG;if(r===eL)return t.RG_INTEGER;if(r===tL)return t.RGBA_INTEGER;if(r===lw||r===cw||r===uw||r===dw)if(o===lr)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(r===lw)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===cw)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===uw)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===dw)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(r===lw)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===cw)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===uw)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===dw)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===F3||r===U3||r===z3||r===B3)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(r===F3)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===U3)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===z3)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===B3)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===$3||r===H3||r===V3||r===G3||r===W3||r===q3||r===K3)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(r===$3||r===H3)return o===lr?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(r===V3)return o===lr?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC;if(r===G3)return a.COMPRESSED_R11_EAC;if(r===W3)return a.COMPRESSED_SIGNED_R11_EAC;if(r===q3)return a.COMPRESSED_RG11_EAC;if(r===K3)return a.COMPRESSED_SIGNED_RG11_EAC}else return null;if(r===X3||r===Y3||r===Z3||r===Q3||r===J3||r===eR||r===tR||r===nR||r===rR||r===iR||r===aR||r===sR||r===oR||r===lR)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(r===X3)return o===lr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===Y3)return o===lr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===Z3)return o===lr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===Q3)return o===lr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===J3)return o===lr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===eR)return o===lr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===tR)return o===lr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===nR)return o===lr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===rR)return o===lr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===iR)return o===lr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===aR)return o===lr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===sR)return o===lr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===oR)return o===lr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===lR)return o===lr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===cR||r===uR||r===dR)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(r===cR)return o===lr?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===uR)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===dR)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===hR||r===fR||r===mR||r===pR)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(r===hR)return a.COMPRESSED_RED_RGTC1_EXT;if(r===fR)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===mR)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===pR)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===q0?t.UNSIGNED_INT_24_8:t[r]!==void 0?t[r]:null}return{convert:n}}const lIe=`
  3953. void main() {
  3954. gl_Position = vec4( position, 1.0 );
  3955. }`,cIe=`
  3956. uniform sampler2DArray depthColor;
  3957. uniform float depthWidth;
  3958. uniform float depthHeight;
  3959. void main() {
  3960. vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
  3961. if ( coord.x >= 1.0 ) {
  3962. gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
  3963. } else {
  3964. gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
  3965. }
  3966. }`;class uIe{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,n){if(this.texture===null){const r=new Nee(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 ic({vertexShader:lIe,fragmentShader:cIe,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new hl(new cL(20,20),r)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}let dIe=class extends dm{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,m=null,p=null,b=null;const v=typeof XRWebGLBinding<"u",x=new uIe,y={},S=n.getContextAttributes();let M=null,N=null;const A=[],k=[],C=new Mn;let D=null;const T=new So;T.viewport=new Mi;const R=new So;R.viewport=new Mi;const U=[T,R],L=new yRe;let q=null,j=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(fe){let oe=A[fe];return oe===void 0&&(oe=new pk,A[fe]=oe),oe.getTargetRaySpace()},this.getControllerGrip=function(fe){let oe=A[fe];return oe===void 0&&(oe=new pk,A[fe]=oe),oe.getGripSpace()},this.getHand=function(fe){let oe=A[fe];return oe===void 0&&(oe=new pk,A[fe]=oe),oe.getHandSpace()};function W(fe){const oe=k.indexOf(fe.inputSource);if(oe===-1)return;const Ne=A[oe];Ne!==void 0&&(Ne.update(fe.inputSource,fe.frame,u||o),Ne.dispatchEvent({type:fe.type,data:fe.inputSource}))}function K(){i.removeEventListener("select",W),i.removeEventListener("selectstart",W),i.removeEventListener("selectend",W),i.removeEventListener("squeeze",W),i.removeEventListener("squeezestart",W),i.removeEventListener("squeezeend",W),i.removeEventListener("end",K),i.removeEventListener("inputsourceschange",V);for(let fe=0;fe<A.length;fe++){const oe=k[fe];oe!==null&&(k[fe]=null,A[fe].disconnect(oe))}q=null,j=null,x.reset();for(const fe in y)delete y[fe];e.setRenderTarget(M),p=null,m=null,f=null,i=null,N=null,he.stop(),r.isPresenting=!1,e.setPixelRatio(D),e.setSize(C.width,C.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(fe){a=fe,r.isPresenting===!0&&un("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(fe){l=fe,r.isPresenting===!0&&un("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(fe){u=fe},this.getBaseLayer=function(){return m!==null?m:p},this.getBinding=function(){return f===null&&v&&(f=new XRWebGLBinding(i,n)),f},this.getFrame=function(){return b},this.getSession=function(){return i},this.setSession=async function(fe){if(i=fe,i!==null){if(M=e.getRenderTarget(),i.addEventListener("select",W),i.addEventListener("selectstart",W),i.addEventListener("selectend",W),i.addEventListener("squeeze",W),i.addEventListener("squeezestart",W),i.addEventListener("squeezeend",W),i.addEventListener("end",K),i.addEventListener("inputsourceschange",V),S.xrCompatible!==!0&&await n.makeXRCompatible(),D=e.getPixelRatio(),e.getSize(C),v&&"createProjectionLayer"in XRWebGLBinding.prototype){let Ne=null,ge=null,Se=null;S.depth&&(Se=S.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,Ne=S.stencil?pf:vu,ge=S.stencil?q0:rc);const Re={colorFormat:n.RGBA8,depthFormat:Se,scaleFactor:a};f=this.getBinding(),m=f.createProjectionLayer(Re),i.updateRenderState({layers:[m]}),e.setPixelRatio(1),e.setSize(m.textureWidth,m.textureHeight,!1),N=new Kl(m.textureWidth,m.textureHeight,{format:el,type:Hs,depthTexture:new X0(m.textureWidth,m.textureHeight,ge,void 0,void 0,void 0,void 0,void 0,void 0,Ne),stencilBuffer:S.stencil,colorSpace:e.outputColorSpace,samples:S.antialias?4:0,resolveDepthBuffer:m.ignoreDepthValues===!1,resolveStencilBuffer:m.ignoreDepthValues===!1})}else{const Ne={antialias:S.antialias,alpha:!0,depth:S.depth,stencil:S.stencil,framebufferScaleFactor:a};p=new XRWebGLLayer(i,n,Ne),i.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),N=new Kl(p.framebufferWidth,p.framebufferHeight,{format:el,type:Hs,colorSpace:e.outputColorSpace,stencilBuffer:S.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}N.isXRRenderTarget=!0,this.setFoveation(c),u=null,o=await i.requestReferenceSpace(l),he.setContext(i),he.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return x.getDepthTexture()};function V(fe){for(let oe=0;oe<fe.removed.length;oe++){const Ne=fe.removed[oe],ge=k.indexOf(Ne);ge>=0&&(k[ge]=null,A[ge].disconnect(Ne))}for(let oe=0;oe<fe.added.length;oe++){const Ne=fe.added[oe];let ge=k.indexOf(Ne);if(ge===-1){for(let Re=0;Re<A.length;Re++)if(Re>=k.length){k.push(Ne),ge=Re;break}else if(k[Re]===null){k[Re]=Ne,ge=Re;break}if(ge===-1)break}const Se=A[ge];Se&&Se.connect(Ne)}}const J=new nt,ne=new nt;function te(fe,oe,Ne){J.setFromMatrixPosition(oe.matrixWorld),ne.setFromMatrixPosition(Ne.matrixWorld);const ge=J.distanceTo(ne),Se=oe.projectionMatrix.elements,Re=Ne.projectionMatrix.elements,de=Se[14]/(Se[10]-1),Qe=Se[14]/(Se[10]+1),G=(Se[9]+1)/Se[5],ie=(Se[9]-1)/Se[5],X=(Se[8]-1)/Se[0],$=(Re[8]+1)/Re[0],I=de*X,ce=de*$,Ee=ge/(-X+$),Ie=Ee*-X;if(oe.matrixWorld.decompose(fe.position,fe.quaternion,fe.scale),fe.translateX(Ie),fe.translateZ(Ee),fe.matrixWorld.compose(fe.position,fe.quaternion,fe.scale),fe.matrixWorldInverse.copy(fe.matrixWorld).invert(),Se[10]===-1)fe.projectionMatrix.copy(oe.projectionMatrix),fe.projectionMatrixInverse.copy(oe.projectionMatrixInverse);else{const le=de+Ee,B=Qe+Ee,O=I-Ie,Y=ce+(ge-Ie),pe=G*Qe/B*le,we=ie*Qe/B*le;fe.projectionMatrix.makePerspective(O,Y,pe,we,le,B),fe.projectionMatrixInverse.copy(fe.projectionMatrix).invert()}}function z(fe,oe){oe===null?fe.matrixWorld.copy(fe.matrix):fe.matrixWorld.multiplyMatrices(oe.matrixWorld,fe.matrix),fe.matrixWorldInverse.copy(fe.matrixWorld).invert()}this.updateCamera=function(fe){if(i===null)return;let oe=fe.near,Ne=fe.far;x.texture!==null&&(x.depthNear>0&&(oe=x.depthNear),x.depthFar>0&&(Ne=x.depthFar)),L.near=R.near=T.near=oe,L.far=R.far=T.far=Ne,(q!==L.near||j!==L.far)&&(i.updateRenderState({depthNear:L.near,depthFar:L.far}),q=L.near,j=L.far),L.layers.mask=fe.layers.mask|6,T.layers.mask=L.layers.mask&3,R.layers.mask=L.layers.mask&5;const ge=fe.parent,Se=L.cameras;z(L,ge);for(let Re=0;Re<Se.length;Re++)z(Se[Re],ge);Se.length===2?te(L,T,R):L.projectionMatrix.copy(T.projectionMatrix),H(fe,L,ge)};function H(fe,oe,Ne){Ne===null?fe.matrix.copy(oe.matrixWorld):(fe.matrix.copy(Ne.matrixWorld),fe.matrix.invert(),fe.matrix.multiply(oe.matrixWorld)),fe.matrix.decompose(fe.position,fe.quaternion,fe.scale),fe.updateMatrixWorld(!0),fe.projectionMatrix.copy(oe.projectionMatrix),fe.projectionMatrixInverse.copy(oe.projectionMatrixInverse),fe.isPerspectiveCamera&&(fe.fov=gR*2*Math.atan(1/fe.projectionMatrix.elements[5]),fe.zoom=1)}this.getCamera=function(){return L},this.getFoveation=function(){if(!(m===null&&p===null))return c},this.setFoveation=function(fe){c=fe,m!==null&&(m.fixedFoveation=fe),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=fe)},this.hasDepthSensing=function(){return x.texture!==null},this.getDepthSensingMesh=function(){return x.getMesh(L)},this.getCameraTexture=function(fe){return y[fe]};let Z=null;function ee(fe,oe){if(d=oe.getViewerPose(u||o),b=oe,d!==null){const Ne=d.views;p!==null&&(e.setRenderTargetFramebuffer(N,p.framebuffer),e.setRenderTarget(N));let ge=!1;Ne.length!==L.cameras.length&&(L.cameras.length=0,ge=!0);for(let Qe=0;Qe<Ne.length;Qe++){const G=Ne[Qe];let ie=null;if(p!==null)ie=p.getViewport(G);else{const $=f.getViewSubImage(m,G);ie=$.viewport,Qe===0&&(e.setRenderTargetTextures(N,$.colorTexture,$.depthStencilTexture),e.setRenderTarget(N))}let X=U[Qe];X===void 0&&(X=new So,X.layers.enable(Qe),X.viewport=new Mi,U[Qe]=X),X.matrix.fromArray(G.transform.matrix),X.matrix.decompose(X.position,X.quaternion,X.scale),X.projectionMatrix.fromArray(G.projectionMatrix),X.projectionMatrixInverse.copy(X.projectionMatrix).invert(),X.viewport.set(ie.x,ie.y,ie.width,ie.height),Qe===0&&(L.matrix.copy(X.matrix),L.matrix.decompose(L.position,L.quaternion,L.scale)),ge===!0&&L.cameras.push(X)}const Se=i.enabledFeatures;if(Se&&Se.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&v){f=r.getBinding();const Qe=f.getDepthInformation(Ne[0]);Qe&&Qe.isValid&&Qe.texture&&x.init(Qe,i.renderState)}if(Se&&Se.includes("camera-access")&&v){e.state.unbindTexture(),f=r.getBinding();for(let Qe=0;Qe<Ne.length;Qe++){const G=Ne[Qe].camera;if(G){let ie=y[G];ie||(ie=new Nee,y[G]=ie);const X=f.getCameraImage(G);ie.sourceTexture=X}}}}for(let Ne=0;Ne<A.length;Ne++){const ge=k[Ne],Se=A[Ne];ge!==null&&Se!==void 0&&Se.update(ge,oe,u||o)}Z&&Z(fe,oe),oe.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:oe}),b=null}const he=new Cee;he.setAnimationLoop(ee),this.setAnimationLoop=function(fe){Z=fe},this.dispose=function(){}}};const Bh=new eh,hIe=new mi;function fIe(t,e){function n(x,y){x.matrixAutoUpdate===!0&&x.updateMatrix(),y.value.copy(x.matrix)}function r(x,y){y.color.getRGB(x.fogColor.value,_ee(t)),y.isFog?(x.fogNear.value=y.near,x.fogFar.value=y.far):y.isFogExp2&&(x.fogDensity.value=y.density)}function i(x,y,S,M,N){y.isMeshBasicMaterial||y.isMeshLambertMaterial?a(x,y):y.isMeshToonMaterial?(a(x,y),f(x,y)):y.isMeshPhongMaterial?(a(x,y),d(x,y)):y.isMeshStandardMaterial?(a(x,y),m(x,y),y.isMeshPhysicalMaterial&&p(x,y,N)):y.isMeshMatcapMaterial?(a(x,y),b(x,y)):y.isMeshDepthMaterial?a(x,y):y.isMeshDistanceMaterial?(a(x,y),v(x,y)):y.isMeshNormalMaterial?a(x,y):y.isLineBasicMaterial?(o(x,y),y.isLineDashedMaterial&&l(x,y)):y.isPointsMaterial?c(x,y,S,M):y.isSpriteMaterial?u(x,y):y.isShadowMaterial?(x.color.value.copy(y.color),x.opacity.value=y.opacity):y.isShaderMaterial&&(y.uniformsNeedUpdate=!1)}function a(x,y){x.opacity.value=y.opacity,y.color&&x.diffuse.value.copy(y.color),y.emissive&&x.emissive.value.copy(y.emissive).multiplyScalar(y.emissiveIntensity),y.map&&(x.map.value=y.map,n(y.map,x.mapTransform)),y.alphaMap&&(x.alphaMap.value=y.alphaMap,n(y.alphaMap,x.alphaMapTransform)),y.bumpMap&&(x.bumpMap.value=y.bumpMap,n(y.bumpMap,x.bumpMapTransform),x.bumpScale.value=y.bumpScale,y.side===_s&&(x.bumpScale.value*=-1)),y.normalMap&&(x.normalMap.value=y.normalMap,n(y.normalMap,x.normalMapTransform),x.normalScale.value.copy(y.normalScale),y.side===_s&&x.normalScale.value.negate()),y.displacementMap&&(x.displacementMap.value=y.displacementMap,n(y.displacementMap,x.displacementMapTransform),x.displacementScale.value=y.displacementScale,x.displacementBias.value=y.displacementBias),y.emissiveMap&&(x.emissiveMap.value=y.emissiveMap,n(y.emissiveMap,x.emissiveMapTransform)),y.specularMap&&(x.specularMap.value=y.specularMap,n(y.specularMap,x.specularMapTransform)),y.alphaTest>0&&(x.alphaTest.value=y.alphaTest);const S=e.get(y),M=S.envMap,N=S.envMapRotation;M&&(x.envMap.value=M,Bh.copy(N),Bh.x*=-1,Bh.y*=-1,Bh.z*=-1,M.isCubeTexture&&M.isRenderTargetTexture===!1&&(Bh.y*=-1,Bh.z*=-1),x.envMapRotation.value.setFromMatrix4(hIe.makeRotationFromEuler(Bh)),x.flipEnvMap.value=M.isCubeTexture&&M.isRenderTargetTexture===!1?-1:1,x.reflectivity.value=y.reflectivity,x.ior.value=y.ior,x.refractionRatio.value=y.refractionRatio),y.lightMap&&(x.lightMap.value=y.lightMap,x.lightMapIntensity.value=y.lightMapIntensity,n(y.lightMap,x.lightMapTransform)),y.aoMap&&(x.aoMap.value=y.aoMap,x.aoMapIntensity.value=y.aoMapIntensity,n(y.aoMap,x.aoMapTransform))}function o(x,y){x.diffuse.value.copy(y.color),x.opacity.value=y.opacity,y.map&&(x.map.value=y.map,n(y.map,x.mapTransform))}function l(x,y){x.dashSize.value=y.dashSize,x.totalSize.value=y.dashSize+y.gapSize,x.scale.value=y.scale}function c(x,y,S,M){x.diffuse.value.copy(y.color),x.opacity.value=y.opacity,x.size.value=y.size*S,x.scale.value=M*.5,y.map&&(x.map.value=y.map,n(y.map,x.uvTransform)),y.alphaMap&&(x.alphaMap.value=y.alphaMap,n(y.alphaMap,x.alphaMapTransform)),y.alphaTest>0&&(x.alphaTest.value=y.alphaTest)}function u(x,y){x.diffuse.value.copy(y.color),x.opacity.value=y.opacity,x.rotation.value=y.rotation,y.map&&(x.map.value=y.map,n(y.map,x.mapTransform)),y.alphaMap&&(x.alphaMap.value=y.alphaMap,n(y.alphaMap,x.alphaMapTransform)),y.alphaTest>0&&(x.alphaTest.value=y.alphaTest)}function d(x,y){x.specular.value.copy(y.specular),x.shininess.value=Math.max(y.shininess,1e-4)}function f(x,y){y.gradientMap&&(x.gradientMap.value=y.gradientMap)}function m(x,y){x.metalness.value=y.metalness,y.metalnessMap&&(x.metalnessMap.value=y.metalnessMap,n(y.metalnessMap,x.metalnessMapTransform)),x.roughness.value=y.roughness,y.roughnessMap&&(x.roughnessMap.value=y.roughnessMap,n(y.roughnessMap,x.roughnessMapTransform)),y.envMap&&(x.envMapIntensity.value=y.envMapIntensity)}function p(x,y,S){x.ior.value=y.ior,y.sheen>0&&(x.sheenColor.value.copy(y.sheenColor).multiplyScalar(y.sheen),x.sheenRoughness.value=y.sheenRoughness,y.sheenColorMap&&(x.sheenColorMap.value=y.sheenColorMap,n(y.sheenColorMap,x.sheenColorMapTransform)),y.sheenRoughnessMap&&(x.sheenRoughnessMap.value=y.sheenRoughnessMap,n(y.sheenRoughnessMap,x.sheenRoughnessMapTransform))),y.clearcoat>0&&(x.clearcoat.value=y.clearcoat,x.clearcoatRoughness.value=y.clearcoatRoughness,y.clearcoatMap&&(x.clearcoatMap.value=y.clearcoatMap,n(y.clearcoatMap,x.clearcoatMapTransform)),y.clearcoatRoughnessMap&&(x.clearcoatRoughnessMap.value=y.clearcoatRoughnessMap,n(y.clearcoatRoughnessMap,x.clearcoatRoughnessMapTransform)),y.clearcoatNormalMap&&(x.clearcoatNormalMap.value=y.clearcoatNormalMap,n(y.clearcoatNormalMap,x.clearcoatNormalMapTransform),x.clearcoatNormalScale.value.copy(y.clearcoatNormalScale),y.side===_s&&x.clearcoatNormalScale.value.negate())),y.dispersion>0&&(x.dispersion.value=y.dispersion),y.iridescence>0&&(x.iridescence.value=y.iridescence,x.iridescenceIOR.value=y.iridescenceIOR,x.iridescenceThicknessMinimum.value=y.iridescenceThicknessRange[0],x.iridescenceThicknessMaximum.value=y.iridescenceThicknessRange[1],y.iridescenceMap&&(x.iridescenceMap.value=y.iridescenceMap,n(y.iridescenceMap,x.iridescenceMapTransform)),y.iridescenceThicknessMap&&(x.iridescenceThicknessMap.value=y.iridescenceThicknessMap,n(y.iridescenceThicknessMap,x.iridescenceThicknessMapTransform))),y.transmission>0&&(x.transmission.value=y.transmission,x.transmissionSamplerMap.value=S.texture,x.transmissionSamplerSize.value.set(S.width,S.height),y.transmissionMap&&(x.transmissionMap.value=y.transmissionMap,n(y.transmissionMap,x.transmissionMapTransform)),x.thickness.value=y.thickness,y.thicknessMap&&(x.thicknessMap.value=y.thicknessMap,n(y.thicknessMap,x.thicknessMapTransform)),x.attenuationDistance.value=y.attenuationDistance,x.attenuationColor.value.copy(y.attenuationColor)),y.anisotropy>0&&(x.anisotropyVector.value.set(y.anisotropy*Math.cos(y.anisotropyRotation),y.anisotropy*Math.sin(y.anisotropyRotation)),y.anisotropyMap&&(x.anisotropyMap.value=y.anisotropyMap,n(y.anisotropyMap,x.anisotropyMapTransform))),x.specularIntensity.value=y.specularIntensity,x.specularColor.value.copy(y.specularColor),y.specularColorMap&&(x.specularColorMap.value=y.specularColorMap,n(y.specularColorMap,x.specularColorMapTransform)),y.specularIntensityMap&&(x.specularIntensityMap.value=y.specularIntensityMap,n(y.specularIntensityMap,x.specularIntensityMapTransform))}function b(x,y){y.matcap&&(x.matcap.value=y.matcap)}function v(x,y){const S=e.get(y).light;x.referencePosition.value.setFromMatrixPosition(S.matrixWorld),x.nearDistance.value=S.shadow.camera.near,x.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function mIe(t,e,n,r){let i={},a={},o=[];const l=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function c(S,M){const N=M.program;r.uniformBlockBinding(S,N)}function u(S,M){let N=i[S.id];N===void 0&&(b(S),N=d(S),i[S.id]=N,S.addEventListener("dispose",x));const A=M.program;r.updateUBOMapping(S,A);const k=e.render.frame;a[S.id]!==k&&(m(S),a[S.id]=k)}function d(S){const M=f();S.__bindingPointIndex=M;const N=t.createBuffer(),A=S.__size,k=S.usage;return t.bindBuffer(t.UNIFORM_BUFFER,N),t.bufferData(t.UNIFORM_BUFFER,A,k),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,M,N),N}function f(){for(let S=0;S<l;S++)if(o.indexOf(S)===-1)return o.push(S),S;return Kn("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function m(S){const M=i[S.id],N=S.uniforms,A=S.__cache;t.bindBuffer(t.UNIFORM_BUFFER,M);for(let k=0,C=N.length;k<C;k++){const D=Array.isArray(N[k])?N[k]:[N[k]];for(let T=0,R=D.length;T<R;T++){const U=D[T];if(p(U,k,T,A)===!0){const L=U.__offset,q=Array.isArray(U.value)?U.value:[U.value];let j=0;for(let W=0;W<q.length;W++){const K=q[W],V=v(K);typeof K=="number"||typeof K=="boolean"?(U.__data[0]=K,t.bufferSubData(t.UNIFORM_BUFFER,L+j,U.__data)):K.isMatrix3?(U.__data[0]=K.elements[0],U.__data[1]=K.elements[1],U.__data[2]=K.elements[2],U.__data[3]=0,U.__data[4]=K.elements[3],U.__data[5]=K.elements[4],U.__data[6]=K.elements[5],U.__data[7]=0,U.__data[8]=K.elements[6],U.__data[9]=K.elements[7],U.__data[10]=K.elements[8],U.__data[11]=0):(K.toArray(U.__data,j),j+=V.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,L,U.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function p(S,M,N,A){const k=S.value,C=M+"_"+N;if(A[C]===void 0)return typeof k=="number"||typeof k=="boolean"?A[C]=k:A[C]=k.clone(),!0;{const D=A[C];if(typeof k=="number"||typeof k=="boolean"){if(D!==k)return A[C]=k,!0}else if(D.equals(k)===!1)return D.copy(k),!0}return!1}function b(S){const M=S.uniforms;let N=0;const A=16;for(let C=0,D=M.length;C<D;C++){const T=Array.isArray(M[C])?M[C]:[M[C]];for(let R=0,U=T.length;R<U;R++){const L=T[R],q=Array.isArray(L.value)?L.value:[L.value];for(let j=0,W=q.length;j<W;j++){const K=q[j],V=v(K),J=N%A,ne=J%V.boundary,te=J+ne;N+=ne,te!==0&&A-te<V.storage&&(N+=A-te),L.__data=new Float32Array(V.storage/Float32Array.BYTES_PER_ELEMENT),L.__offset=N,N+=V.storage}}}const k=N%A;return k>0&&(N+=A-k),S.__size=N,S.__cache={},this}function v(S){const M={boundary:0,storage:0};return typeof S=="number"||typeof S=="boolean"?(M.boundary=4,M.storage=4):S.isVector2?(M.boundary=8,M.storage=8):S.isVector3||S.isColor?(M.boundary=16,M.storage=12):S.isVector4?(M.boundary=16,M.storage=16):S.isMatrix3?(M.boundary=48,M.storage=48):S.isMatrix4?(M.boundary=64,M.storage=64):S.isTexture?un("WebGLRenderer: Texture samplers can not be part of an uniforms group."):un("WebGLRenderer: Unsupported uniform value type.",S),M}function x(S){const M=S.target;M.removeEventListener("dispose",x);const N=o.indexOf(M.__bindingPointIndex);o.splice(N,1),t.deleteBuffer(i[M.id]),delete i[M.id],delete a[M.id]}function y(){for(const S in i)t.deleteBuffer(i[S]);o=[],i={},a={}}return{bind:c,update:u,dispose:y}}const pIe=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let Tl=null;function gIe(){return Tl===null&&(Tl=new aRe(pIe,16,16,Tg,yu),Tl.name="DFG_LUT",Tl.minFilter=Ua,Tl.magFilter=Ua,Tl.wrapS=Jc,Tl.wrapT=Jc,Tl.generateMipmaps=!1,Tl.needsUpdate=!0),Tl}let xIe=class{constructor(e={}){const{canvas:n=j3e(),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:m=!1,outputBufferType:p=Hs}=e;this.isWebGLRenderer=!0;let b;if(r!==null){if(typeof WebGLRenderingContext<"u"&&r instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");b=r.getContextAttributes().alpha}else b=o;const v=p,x=new Set([tL,eL,J4]),y=new Set([Hs,rc,W0,q0,Z4,Q4]),S=new Uint32Array(4),M=new Int32Array(4);let N=null,A=null;const k=[],C=[];let D=null;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=ql,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const T=this;let R=!1;this._outputColorSpace=vo;let U=0,L=0,q=null,j=-1,W=null;const K=new Mi,V=new Mi;let J=null;const ne=new Rn(0);let te=0,z=n.width,H=n.height,Z=1,ee=null,he=null;const fe=new Mi(0,0,z,H),oe=new Mi(0,0,z,H);let Ne=!1;const ge=new lL;let Se=!1,Re=!1;const de=new mi,Qe=new nt,G=new Mi,ie={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let X=!1;function $(){return q===null?Z:1}let I=r;function ce(ue,je){return n.getContext(ue,je)}try{const ue={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${K4}`),n.addEventListener("webglcontextlost",it,!1),n.addEventListener("webglcontextrestored",Ot,!1),n.addEventListener("webglcontextcreationerror",kt,!1),I===null){const je="webgl2";if(I=ce(je,ue),I===null)throw ce(je)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(ue){throw Kn("WebGLRenderer: "+ue.message),ue}let Ee,Ie,le,B,O,Y,pe,we,ae,ke,De,Ke,et,Ye,se,ye,Ce,Ue,dt,re,Fe,ve,$e,Le;function Ae(){Ee=new g4e(I),Ee.init(),ve=new oIe(I,Ee),Ie=new o4e(I,Ee,e,ve),le=new aIe(I,Ee),Ie.reversedDepthBuffer&&m&&le.buffers.depth.setReversed(!0),B=new y4e(I),O=new VLe,Y=new sIe(I,Ee,le,O,Ie,ve,B),pe=new c4e(T),we=new p4e(T),ae=new SRe(I),$e=new a4e(I,ae),ke=new x4e(I,ae,B,$e),De=new _4e(I,ke,ae,B),dt=new v4e(I,Ie,Y),ye=new l4e(O),Ke=new HLe(T,pe,we,Ee,Ie,$e,ye),et=new fIe(T,O),Ye=new WLe,se=new QLe(Ee),Ue=new i4e(T,pe,we,le,De,b,c),Ce=new rIe(T,De,Ie),Le=new mIe(I,B,Ie,le),re=new s4e(I,Ee,B),Fe=new b4e(I,Ee,B),B.programs=Ke.programs,T.capabilities=Ie,T.extensions=Ee,T.properties=O,T.renderLists=Ye,T.shadowMap=Ce,T.state=le,T.info=B}Ae(),v!==Hs&&(D=new S4e(v,n.width,n.height,i,a));const Ge=new dIe(T,I);this.xr=Ge,this.getContext=function(){return I},this.getContextAttributes=function(){return I.getContextAttributes()},this.forceContextLoss=function(){const ue=Ee.get("WEBGL_lose_context");ue&&ue.loseContext()},this.forceContextRestore=function(){const ue=Ee.get("WEBGL_lose_context");ue&&ue.restoreContext()},this.getPixelRatio=function(){return Z},this.setPixelRatio=function(ue){ue!==void 0&&(Z=ue,this.setSize(z,H,!1))},this.getSize=function(ue){return ue.set(z,H)},this.setSize=function(ue,je,Ve=!0){if(Ge.isPresenting){un("WebGLRenderer: Can't change size while VR device is presenting.");return}z=ue,H=je,n.width=Math.floor(ue*Z),n.height=Math.floor(je*Z),Ve===!0&&(n.style.width=ue+"px",n.style.height=je+"px"),D!==null&&D.setSize(n.width,n.height),this.setViewport(0,0,ue,je)},this.getDrawingBufferSize=function(ue){return ue.set(z*Z,H*Z).floor()},this.setDrawingBufferSize=function(ue,je,Ve){z=ue,H=je,Z=Ve,n.width=Math.floor(ue*Ve),n.height=Math.floor(je*Ve),this.setViewport(0,0,ue,je)},this.setEffects=function(ue){if(v===Hs){console.error("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(ue){for(let je=0;je<ue.length;je++)if(ue[je].isOutputPass===!0){console.warn("THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}D.setEffects(ue||[])},this.getCurrentViewport=function(ue){return ue.copy(K)},this.getViewport=function(ue){return ue.copy(fe)},this.setViewport=function(ue,je,Ve,We){ue.isVector4?fe.set(ue.x,ue.y,ue.z,ue.w):fe.set(ue,je,Ve,We),le.viewport(K.copy(fe).multiplyScalar(Z).round())},this.getScissor=function(ue){return ue.copy(oe)},this.setScissor=function(ue,je,Ve,We){ue.isVector4?oe.set(ue.x,ue.y,ue.z,ue.w):oe.set(ue,je,Ve,We),le.scissor(V.copy(oe).multiplyScalar(Z).round())},this.getScissorTest=function(){return Ne},this.setScissorTest=function(ue){le.setScissorTest(Ne=ue)},this.setOpaqueSort=function(ue){ee=ue},this.setTransparentSort=function(ue){he=ue},this.getClearColor=function(ue){return ue.copy(Ue.getClearColor())},this.setClearColor=function(){Ue.setClearColor(...arguments)},this.getClearAlpha=function(){return Ue.getClearAlpha()},this.setClearAlpha=function(){Ue.setClearAlpha(...arguments)},this.clear=function(ue=!0,je=!0,Ve=!0){let We=0;if(ue){let He=!1;if(q!==null){const wt=q.texture.format;He=x.has(wt)}if(He){const wt=q.texture.type,Dt=y.has(wt),Et=Ue.getClearColor(),St=Ue.getClearAlpha(),Mt=Et.r,Oe=Et.g,gt=Et.b;Dt?(S[0]=Mt,S[1]=Oe,S[2]=gt,S[3]=St,I.clearBufferuiv(I.COLOR,0,S)):(M[0]=Mt,M[1]=Oe,M[2]=gt,M[3]=St,I.clearBufferiv(I.COLOR,0,M))}else We|=I.COLOR_BUFFER_BIT}je&&(We|=I.DEPTH_BUFFER_BIT),Ve&&(We|=I.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),I.clear(We)},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",it,!1),n.removeEventListener("webglcontextrestored",Ot,!1),n.removeEventListener("webglcontextcreationerror",kt,!1),Ue.dispose(),Ye.dispose(),se.dispose(),O.dispose(),pe.dispose(),we.dispose(),De.dispose(),$e.dispose(),Le.dispose(),Ke.dispose(),Ge.dispose(),Ge.removeEventListener("sessionstart",Tt),Ge.removeEventListener("sessionend",Cn),Cr.stop()};function it(ue){ue.preventDefault(),EV("WebGLRenderer: Context Lost."),R=!0}function Ot(){EV("WebGLRenderer: Context Restored."),R=!1;const ue=B.autoReset,je=Ce.enabled,Ve=Ce.autoUpdate,We=Ce.needsUpdate,He=Ce.type;Ae(),B.autoReset=ue,Ce.enabled=je,Ce.autoUpdate=Ve,Ce.needsUpdate=We,Ce.type=He}function kt(ue){Kn("WebGLRenderer: A WebGL context could not be created. Reason: ",ue.statusMessage)}function on(ue){const je=ue.target;je.removeEventListener("dispose",on),Ut(je)}function Ut(ue){yn(ue),O.remove(ue)}function yn(ue){const je=O.get(ue).programs;je!==void 0&&(je.forEach(function(Ve){Ke.releaseProgram(Ve)}),ue.isShaderMaterial&&Ke.releaseShaderCache(ue))}this.renderBufferDirect=function(ue,je,Ve,We,He,wt){je===null&&(je=ie);const Dt=He.isMesh&&He.matrixWorld.determinant()<0,Et=lt(ue,je,Ve,We,He);le.setMaterial(We,Dt);let St=Ve.index,Mt=1;if(We.wireframe===!0){if(St=ke.getWireframeAttribute(Ve),St===void 0)return;Mt=2}const Oe=Ve.drawRange,gt=Ve.attributes.position;let Rt=Oe.start*Mt,ct=(Oe.start+Oe.count)*Mt;wt!==null&&(Rt=Math.max(Rt,wt.start*Mt),ct=Math.min(ct,(wt.start+wt.count)*Mt)),St!==null?(Rt=Math.max(Rt,0),ct=Math.min(ct,St.count)):gt!=null&&(Rt=Math.max(Rt,0),ct=Math.min(ct,gt.count));const Zt=ct-Rt;if(Zt<0||Zt===1/0)return;$e.setup(He,We,Et,Ve,St);let Kt,be=re;if(St!==null&&(Kt=ae.get(St),be=Fe,be.setIndex(Kt)),He.isMesh)We.wireframe===!0?(le.setLineWidth(We.wireframeLinewidth*$()),be.setMode(I.LINES)):be.setMode(I.TRIANGLES);else if(He.isLine){let ut=We.linewidth;ut===void 0&&(ut=1),le.setLineWidth(ut*$()),He.isLineSegments?be.setMode(I.LINES):He.isLineLoop?be.setMode(I.LINE_LOOP):be.setMode(I.LINE_STRIP)}else He.isPoints?be.setMode(I.POINTS):He.isSprite&&be.setMode(I.TRIANGLES);if(He.isBatchedMesh)if(He._multiDrawInstances!==null)K0("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),be.renderMultiDrawInstances(He._multiDrawStarts,He._multiDrawCounts,He._multiDrawCount,He._multiDrawInstances);else if(Ee.get("WEBGL_multi_draw"))be.renderMultiDraw(He._multiDrawStarts,He._multiDrawCounts,He._multiDrawCount);else{const ut=He._multiDrawStarts,It=He._multiDrawCounts,yt=He._multiDrawCount,Xt=St?ae.get(St).bytesPerElement:1,tr=O.get(We).currentProgram.getUniforms();for(let cn=0;cn<yt;cn++)tr.setValue(I,"_gl_DrawID",cn),be.render(ut[cn]/Xt,It[cn])}else if(He.isInstancedMesh)be.renderInstances(Rt,Zt,He.count);else if(Ve.isInstancedBufferGeometry){const ut=Ve._maxInstanceCount!==void 0?Ve._maxInstanceCount:1/0,It=Math.min(Ve.instanceCount,ut);be.renderInstances(Rt,Zt,It)}else be.render(Rt,Zt)};function xt(ue,je,Ve){ue.transparent===!0&&ue.side===Il&&ue.forceSinglePass===!1?(ue.side=_s,ue.needsUpdate=!0,_e(ue,je,Ve),ue.side=Jd,ue.needsUpdate=!0,_e(ue,je,Ve),ue.side=Il):_e(ue,je,Ve)}this.compile=function(ue,je,Ve=null){Ve===null&&(Ve=ue),A=se.get(Ve),A.init(je),C.push(A),Ve.traverseVisible(function(He){He.isLight&&He.layers.test(je.layers)&&(A.pushLight(He),He.castShadow&&A.pushShadow(He))}),ue!==Ve&&ue.traverseVisible(function(He){He.isLight&&He.layers.test(je.layers)&&(A.pushLight(He),He.castShadow&&A.pushShadow(He))}),A.setupLights();const We=new Set;return ue.traverse(function(He){if(!(He.isMesh||He.isPoints||He.isLine||He.isSprite))return;const wt=He.material;if(wt)if(Array.isArray(wt))for(let Dt=0;Dt<wt.length;Dt++){const Et=wt[Dt];xt(Et,Ve,He),We.add(Et)}else xt(wt,Ve,He),We.add(wt)}),A=C.pop(),We},this.compileAsync=function(ue,je,Ve=null){const We=this.compile(ue,je,Ve);return new Promise(He=>{function wt(){if(We.forEach(function(Dt){O.get(Dt).currentProgram.isReady()&&We.delete(Dt)}),We.size===0){He(ue);return}setTimeout(wt,10)}Ee.get("KHR_parallel_shader_compile")!==null?wt():setTimeout(wt,10)})};let Yt=null;function sn(ue){Yt&&Yt(ue)}function Tt(){Cr.stop()}function Cn(){Cr.start()}const Cr=new Cee;Cr.setAnimationLoop(sn),typeof self<"u"&&Cr.setContext(self),this.setAnimationLoop=function(ue){Yt=ue,Ge.setAnimationLoop(ue),ue===null?Cr.stop():Cr.start()},Ge.addEventListener("sessionstart",Tt),Ge.addEventListener("sessionend",Cn),this.render=function(ue,je){if(je!==void 0&&je.isCamera!==!0){Kn("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(R===!0)return;const Ve=Ge.enabled===!0&&Ge.isPresenting===!0,We=D!==null&&(q===null||Ve)&&D.begin(T,q);if(ue.matrixWorldAutoUpdate===!0&&ue.updateMatrixWorld(),je.parent===null&&je.matrixWorldAutoUpdate===!0&&je.updateMatrixWorld(),Ge.enabled===!0&&Ge.isPresenting===!0&&(D===null||D.isCompositing()===!1)&&(Ge.cameraAutoUpdate===!0&&Ge.updateCamera(je),je=Ge.getCamera()),ue.isScene===!0&&ue.onBeforeRender(T,ue,je,q),A=se.get(ue,C.length),A.init(je),C.push(A),de.multiplyMatrices(je.projectionMatrix,je.matrixWorldInverse),ge.setFromProjectionMatrix(de,Hl,je.reversedDepth),Re=this.localClippingEnabled,Se=ye.init(this.clippingPlanes,Re),N=Ye.get(ue,k.length),N.init(),k.push(N),Ge.enabled===!0&&Ge.isPresenting===!0){const Dt=T.xr.getDepthSensingMesh();Dt!==null&&er(Dt,je,-1/0,T.sortObjects)}er(ue,je,0,T.sortObjects),N.finish(),T.sortObjects===!0&&N.sort(ee,he),X=Ge.enabled===!1||Ge.isPresenting===!1||Ge.hasDepthSensing()===!1,X&&Ue.addToRenderList(N,ue),this.info.render.frame++,Se===!0&&ye.beginShadows();const He=A.state.shadowsArray;if(Ce.render(He,ue,je),Se===!0&&ye.endShadows(),this.info.autoReset===!0&&this.info.reset(),(We&&D.hasRenderPass())===!1){const Dt=N.opaque,Et=N.transmissive;if(A.setupLights(),je.isArrayCamera){const St=je.cameras;if(Et.length>0)for(let Mt=0,Oe=St.length;Mt<Oe;Mt++){const gt=St[Mt];yr(Dt,Et,ue,gt)}X&&Ue.render(ue);for(let Mt=0,Oe=St.length;Mt<Oe;Mt++){const gt=St[Mt];Un(N,ue,gt,gt.viewport)}}else Et.length>0&&yr(Dt,Et,ue,je),X&&Ue.render(ue),Un(N,ue,je)}q!==null&&L===0&&(Y.updateMultisampleRenderTarget(q),Y.updateRenderTargetMipmap(q)),We&&D.end(T),ue.isScene===!0&&ue.onAfterRender(T,ue,je),$e.resetDefaultState(),j=-1,W=null,C.pop(),C.length>0?(A=C[C.length-1],Se===!0&&ye.setGlobalState(T.clippingPlanes,A.state.camera)):A=null,k.pop(),k.length>0?N=k[k.length-1]:N=null};function er(ue,je,Ve,We){if(ue.visible===!1)return;if(ue.layers.test(je.layers)){if(ue.isGroup)Ve=ue.renderOrder;else if(ue.isLOD)ue.autoUpdate===!0&&ue.update(je);else if(ue.isLight)A.pushLight(ue),ue.castShadow&&A.pushShadow(ue);else if(ue.isSprite){if(!ue.frustumCulled||ge.intersectsSprite(ue)){We&&G.setFromMatrixPosition(ue.matrixWorld).applyMatrix4(de);const Dt=De.update(ue),Et=ue.material;Et.visible&&N.push(ue,Dt,Et,Ve,G.z,null)}}else if((ue.isMesh||ue.isLine||ue.isPoints)&&(!ue.frustumCulled||ge.intersectsObject(ue))){const Dt=De.update(ue),Et=ue.material;if(We&&(ue.boundingSphere!==void 0?(ue.boundingSphere===null&&ue.computeBoundingSphere(),G.copy(ue.boundingSphere.center)):(Dt.boundingSphere===null&&Dt.computeBoundingSphere(),G.copy(Dt.boundingSphere.center)),G.applyMatrix4(ue.matrixWorld).applyMatrix4(de)),Array.isArray(Et)){const St=Dt.groups;for(let Mt=0,Oe=St.length;Mt<Oe;Mt++){const gt=St[Mt],Rt=Et[gt.materialIndex];Rt&&Rt.visible&&N.push(ue,Dt,Rt,Ve,G.z,gt)}}else Et.visible&&N.push(ue,Dt,Et,Ve,G.z,null)}}const wt=ue.children;for(let Dt=0,Et=wt.length;Dt<Et;Dt++)er(wt[Dt],je,Ve,We)}function Un(ue,je,Ve,We){const{opaque:He,transmissive:wt,transparent:Dt}=ue;A.setupLightsView(Ve),Se===!0&&ye.setGlobalState(T.clippingPlanes,Ve),We&&le.viewport(K.copy(We)),He.length>0&&Ci(He,je,Ve),wt.length>0&&Ci(wt,je,Ve),Dt.length>0&&Ci(Dt,je,Ve),le.buffers.depth.setTest(!0),le.buffers.depth.setMask(!0),le.buffers.color.setMask(!0),le.setPolygonOffset(!1)}function yr(ue,je,Ve,We){if((Ve.isScene===!0?Ve.overrideMaterial:null)!==null)return;if(A.state.transmissionRenderTarget[We.id]===void 0){const Rt=Ee.has("EXT_color_buffer_half_float")||Ee.has("EXT_color_buffer_float");A.state.transmissionRenderTarget[We.id]=new Kl(1,1,{generateMipmaps:!0,type:Rt?yu:Hs,minFilter:mf,samples:Ie.samples,stencilBuffer:a,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Vn.workingColorSpace})}const wt=A.state.transmissionRenderTarget[We.id],Dt=We.viewport||K;wt.setSize(Dt.z*T.transmissionResolutionScale,Dt.w*T.transmissionResolutionScale);const Et=T.getRenderTarget(),St=T.getActiveCubeFace(),Mt=T.getActiveMipmapLevel();T.setRenderTarget(wt),T.getClearColor(ne),te=T.getClearAlpha(),te<1&&T.setClearColor(16777215,.5),T.clear(),X&&Ue.render(Ve);const Oe=T.toneMapping;T.toneMapping=ql;const gt=We.viewport;if(We.viewport!==void 0&&(We.viewport=void 0),A.setupLightsView(We),Se===!0&&ye.setGlobalState(T.clippingPlanes,We),Ci(ue,Ve,We),Y.updateMultisampleRenderTarget(wt),Y.updateRenderTargetMipmap(wt),Ee.has("WEBGL_multisampled_render_to_texture")===!1){let Rt=!1;for(let ct=0,Zt=je.length;ct<Zt;ct++){const Kt=je[ct],{object:be,geometry:ut,material:It,group:yt}=Kt;if(It.side===Il&&be.layers.test(We.layers)){const Xt=It.side;It.side=_s,It.needsUpdate=!0,gi(be,Ve,We,ut,It,yt),It.side=Xt,It.needsUpdate=!0,Rt=!0}}Rt===!0&&(Y.updateMultisampleRenderTarget(wt),Y.updateRenderTargetMipmap(wt))}T.setRenderTarget(Et,St,Mt),T.setClearColor(ne,te),gt!==void 0&&(We.viewport=gt),T.toneMapping=Oe}function Ci(ue,je,Ve){const We=je.isScene===!0?je.overrideMaterial:null;for(let He=0,wt=ue.length;He<wt;He++){const Dt=ue[He],{object:Et,geometry:St,group:Mt}=Dt;let Oe=Dt.material;Oe.allowOverride===!0&&We!==null&&(Oe=We),Et.layers.test(Ve.layers)&&gi(Et,je,Ve,St,Oe,Mt)}}function gi(ue,je,Ve,We,He,wt){ue.onBeforeRender(T,je,Ve,We,He,wt),ue.modelViewMatrix.multiplyMatrices(Ve.matrixWorldInverse,ue.matrixWorld),ue.normalMatrix.getNormalMatrix(ue.modelViewMatrix),He.onBeforeRender(T,je,Ve,We,ue,wt),He.transparent===!0&&He.side===Il&&He.forceSinglePass===!1?(He.side=_s,He.needsUpdate=!0,T.renderBufferDirect(Ve,je,We,He,ue,wt),He.side=Jd,He.needsUpdate=!0,T.renderBufferDirect(Ve,je,We,He,ue,wt),He.side=Il):T.renderBufferDirect(Ve,je,We,He,ue,wt),ue.onAfterRender(T,je,Ve,We,He,wt)}function _e(ue,je,Ve){je.isScene!==!0&&(je=ie);const We=O.get(ue),He=A.state.lights,wt=A.state.shadowsArray,Dt=He.state.version,Et=Ke.getParameters(ue,He.state,wt,je,Ve),St=Ke.getProgramCacheKey(Et);let Mt=We.programs;We.environment=ue.isMeshStandardMaterial?je.environment:null,We.fog=je.fog,We.envMap=(ue.isMeshStandardMaterial?we:pe).get(ue.envMap||We.environment),We.envMapRotation=We.environment!==null&&ue.envMap===null?je.environmentRotation:ue.envMapRotation,Mt===void 0&&(ue.addEventListener("dispose",on),Mt=new Map,We.programs=Mt);let Oe=Mt.get(St);if(Oe!==void 0){if(We.currentProgram===Oe&&We.lightsStateVersion===Dt)return Ze(ue,Et),Oe}else Et.uniforms=Ke.getUniforms(ue),ue.onBeforeCompile(Et,T),Oe=Ke.acquireProgram(Et,St),Mt.set(St,Oe),We.uniforms=Et.uniforms;const gt=We.uniforms;return(!ue.isShaderMaterial&&!ue.isRawShaderMaterial||ue.clipping===!0)&&(gt.clippingPlanes=ye.uniform),Ze(ue,Et),We.needsLights=Pt(ue),We.lightsStateVersion=Dt,We.needsLights&&(gt.ambientLightColor.value=He.state.ambient,gt.lightProbe.value=He.state.probe,gt.directionalLights.value=He.state.directional,gt.directionalLightShadows.value=He.state.directionalShadow,gt.spotLights.value=He.state.spot,gt.spotLightShadows.value=He.state.spotShadow,gt.rectAreaLights.value=He.state.rectArea,gt.ltc_1.value=He.state.rectAreaLTC1,gt.ltc_2.value=He.state.rectAreaLTC2,gt.pointLights.value=He.state.point,gt.pointLightShadows.value=He.state.pointShadow,gt.hemisphereLights.value=He.state.hemi,gt.directionalShadowMap.value=He.state.directionalShadowMap,gt.directionalShadowMatrix.value=He.state.directionalShadowMatrix,gt.spotShadowMap.value=He.state.spotShadowMap,gt.spotLightMatrix.value=He.state.spotLightMatrix,gt.spotLightMap.value=He.state.spotLightMap,gt.pointShadowMap.value=He.state.pointShadowMap,gt.pointShadowMatrix.value=He.state.pointShadowMatrix),We.currentProgram=Oe,We.uniformsList=null,Oe}function Je(ue){if(ue.uniformsList===null){const je=ue.currentProgram.getUniforms();ue.uniformsList=pw.seqWithValue(je.seq,ue.uniforms)}return ue.uniformsList}function Ze(ue,je){const Ve=O.get(ue);Ve.outputColorSpace=je.outputColorSpace,Ve.batching=je.batching,Ve.batchingColor=je.batchingColor,Ve.instancing=je.instancing,Ve.instancingColor=je.instancingColor,Ve.instancingMorph=je.instancingMorph,Ve.skinning=je.skinning,Ve.morphTargets=je.morphTargets,Ve.morphNormals=je.morphNormals,Ve.morphColors=je.morphColors,Ve.morphTargetsCount=je.morphTargetsCount,Ve.numClippingPlanes=je.numClippingPlanes,Ve.numIntersection=je.numClipIntersection,Ve.vertexAlphas=je.vertexAlphas,Ve.vertexTangents=je.vertexTangents,Ve.toneMapping=je.toneMapping}function lt(ue,je,Ve,We,He){je.isScene!==!0&&(je=ie),Y.resetTextureUnits();const wt=je.fog,Dt=We.isMeshStandardMaterial?je.environment:null,Et=q===null?T.outputColorSpace:q.isXRRenderTarget===!0?q.texture.colorSpace:Cg,St=(We.isMeshStandardMaterial?we:pe).get(We.envMap||Dt),Mt=We.vertexColors===!0&&!!Ve.attributes.color&&Ve.attributes.color.itemSize===4,Oe=!!Ve.attributes.tangent&&(!!We.normalMap||We.anisotropy>0),gt=!!Ve.morphAttributes.position,Rt=!!Ve.morphAttributes.normal,ct=!!Ve.morphAttributes.color;let Zt=ql;We.toneMapped&&(q===null||q.isXRRenderTarget===!0)&&(Zt=T.toneMapping);const Kt=Ve.morphAttributes.position||Ve.morphAttributes.normal||Ve.morphAttributes.color,be=Kt!==void 0?Kt.length:0,ut=O.get(We),It=A.state.lights;if(Se===!0&&(Re===!0||ue!==W)){const Zn=ue===W&&We.id===j;ye.setState(We,ue,Zn)}let yt=!1;We.version===ut.__version?(ut.needsLights&&ut.lightsStateVersion!==It.state.version||ut.outputColorSpace!==Et||He.isBatchedMesh&&ut.batching===!1||!He.isBatchedMesh&&ut.batching===!0||He.isBatchedMesh&&ut.batchingColor===!0&&He.colorTexture===null||He.isBatchedMesh&&ut.batchingColor===!1&&He.colorTexture!==null||He.isInstancedMesh&&ut.instancing===!1||!He.isInstancedMesh&&ut.instancing===!0||He.isSkinnedMesh&&ut.skinning===!1||!He.isSkinnedMesh&&ut.skinning===!0||He.isInstancedMesh&&ut.instancingColor===!0&&He.instanceColor===null||He.isInstancedMesh&&ut.instancingColor===!1&&He.instanceColor!==null||He.isInstancedMesh&&ut.instancingMorph===!0&&He.morphTexture===null||He.isInstancedMesh&&ut.instancingMorph===!1&&He.morphTexture!==null||ut.envMap!==St||We.fog===!0&&ut.fog!==wt||ut.numClippingPlanes!==void 0&&(ut.numClippingPlanes!==ye.numPlanes||ut.numIntersection!==ye.numIntersection)||ut.vertexAlphas!==Mt||ut.vertexTangents!==Oe||ut.morphTargets!==gt||ut.morphNormals!==Rt||ut.morphColors!==ct||ut.toneMapping!==Zt||ut.morphTargetsCount!==be)&&(yt=!0):(yt=!0,ut.__version=We.version);let Xt=ut.currentProgram;yt===!0&&(Xt=_e(We,je,He));let tr=!1,cn=!1,ki=!1;const $n=Xt.getUniforms(),ui=ut.uniforms;if(le.useProgram(Xt.program)&&(tr=!0,cn=!0,ki=!0),We.id!==j&&(j=We.id,cn=!0),tr||W!==ue){le.buffers.depth.getReversed()&&ue.reversedDepth!==!0&&(ue._reversedDepth=!0,ue.updateProjectionMatrix()),$n.setValue(I,"projectionMatrix",ue.projectionMatrix),$n.setValue(I,"viewMatrix",ue.matrixWorldInverse);const kr=$n.map.cameraPosition;kr!==void 0&&kr.setValue(I,Qe.setFromMatrixPosition(ue.matrixWorld)),Ie.logarithmicDepthBuffer&&$n.setValue(I,"logDepthBufFC",2/(Math.log(ue.far+1)/Math.LN2)),(We.isMeshPhongMaterial||We.isMeshToonMaterial||We.isMeshLambertMaterial||We.isMeshBasicMaterial||We.isMeshStandardMaterial||We.isShaderMaterial)&&$n.setValue(I,"isOrthographic",ue.isOrthographicCamera===!0),W!==ue&&(W=ue,cn=!0,ki=!0)}if(ut.needsLights&&(It.state.directionalShadowMap.length>0&&$n.setValue(I,"directionalShadowMap",It.state.directionalShadowMap,Y),It.state.spotShadowMap.length>0&&$n.setValue(I,"spotShadowMap",It.state.spotShadowMap,Y),It.state.pointShadowMap.length>0&&$n.setValue(I,"pointShadowMap",It.state.pointShadowMap,Y)),He.isSkinnedMesh){$n.setOptional(I,He,"bindMatrix"),$n.setOptional(I,He,"bindMatrixInverse");const Zn=He.skeleton;Zn&&(Zn.boneTexture===null&&Zn.computeBoneTexture(),$n.setValue(I,"boneTexture",Zn.boneTexture,Y))}He.isBatchedMesh&&($n.setOptional(I,He,"batchingTexture"),$n.setValue(I,"batchingTexture",He._matricesTexture,Y),$n.setOptional(I,He,"batchingIdTexture"),$n.setValue(I,"batchingIdTexture",He._indirectTexture,Y),$n.setOptional(I,He,"batchingColorTexture"),He._colorsTexture!==null&&$n.setValue(I,"batchingColorTexture",He._colorsTexture,Y));const vr=Ve.morphAttributes;if((vr.position!==void 0||vr.normal!==void 0||vr.color!==void 0)&&dt.update(He,Ve,Xt),(cn||ut.receiveShadow!==He.receiveShadow)&&(ut.receiveShadow=He.receiveShadow,$n.setValue(I,"receiveShadow",He.receiveShadow)),We.isMeshGouraudMaterial&&We.envMap!==null&&(ui.envMap.value=St,ui.flipEnvMap.value=St.isCubeTexture&&St.isRenderTargetTexture===!1?-1:1),We.isMeshStandardMaterial&&We.envMap===null&&je.environment!==null&&(ui.envMapIntensity.value=je.environmentIntensity),ui.dfgLUT!==void 0&&(ui.dfgLUT.value=gIe()),cn&&($n.setValue(I,"toneMappingExposure",T.toneMappingExposure),ut.needsLights&&st(ui,ki),wt&&We.fog===!0&&et.refreshFogUniforms(ui,wt),et.refreshMaterialUniforms(ui,We,Z,H,A.state.transmissionRenderTarget[ue.id]),pw.upload(I,Je(ut),ui,Y)),We.isShaderMaterial&&We.uniformsNeedUpdate===!0&&(pw.upload(I,Je(ut),ui,Y),We.uniformsNeedUpdate=!1),We.isSpriteMaterial&&$n.setValue(I,"center",He.center),$n.setValue(I,"modelViewMatrix",He.modelViewMatrix),$n.setValue(I,"normalMatrix",He.normalMatrix),$n.setValue(I,"modelMatrix",He.matrixWorld),We.isShaderMaterial||We.isRawShaderMaterial){const Zn=We.uniformsGroups;for(let kr=0,to=Zn.length;kr<to;kr++){const jr=Zn[kr];Le.update(jr,Xt),Le.bind(jr,Xt)}}return Xt}function st(ue,je){ue.ambientLightColor.needsUpdate=je,ue.lightProbe.needsUpdate=je,ue.directionalLights.needsUpdate=je,ue.directionalLightShadows.needsUpdate=je,ue.pointLights.needsUpdate=je,ue.pointLightShadows.needsUpdate=je,ue.spotLights.needsUpdate=je,ue.spotLightShadows.needsUpdate=je,ue.rectAreaLights.needsUpdate=je,ue.hemisphereLights.needsUpdate=je}function Pt(ue){return ue.isMeshLambertMaterial||ue.isMeshToonMaterial||ue.isMeshPhongMaterial||ue.isMeshStandardMaterial||ue.isShadowMaterial||ue.isShaderMaterial&&ue.lights===!0}this.getActiveCubeFace=function(){return U},this.getActiveMipmapLevel=function(){return L},this.getRenderTarget=function(){return q},this.setRenderTargetTextures=function(ue,je,Ve){const We=O.get(ue);We.__autoAllocateDepthBuffer=ue.resolveDepthBuffer===!1,We.__autoAllocateDepthBuffer===!1&&(We.__useRenderToTexture=!1),O.get(ue.texture).__webglTexture=je,O.get(ue.depthTexture).__webglTexture=We.__autoAllocateDepthBuffer?void 0:Ve,We.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(ue,je){const Ve=O.get(ue);Ve.__webglFramebuffer=je,Ve.__useDefaultFramebuffer=je===void 0};const Bt=I.createFramebuffer();this.setRenderTarget=function(ue,je=0,Ve=0){q=ue,U=je,L=Ve;let We=null,He=!1,wt=!1;if(ue){const Et=O.get(ue);if(Et.__useDefaultFramebuffer!==void 0){le.bindFramebuffer(I.FRAMEBUFFER,Et.__webglFramebuffer),K.copy(ue.viewport),V.copy(ue.scissor),J=ue.scissorTest,le.viewport(K),le.scissor(V),le.setScissorTest(J),j=-1;return}else if(Et.__webglFramebuffer===void 0)Y.setupRenderTarget(ue);else if(Et.__hasExternalTextures)Y.rebindTextures(ue,O.get(ue.texture).__webglTexture,O.get(ue.depthTexture).__webglTexture);else if(ue.depthBuffer){const Oe=ue.depthTexture;if(Et.__boundDepthTexture!==Oe){if(Oe!==null&&O.has(Oe)&&(ue.width!==Oe.image.width||ue.height!==Oe.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");Y.setupDepthRenderbuffer(ue)}}const St=ue.texture;(St.isData3DTexture||St.isDataArrayTexture||St.isCompressedArrayTexture)&&(wt=!0);const Mt=O.get(ue).__webglFramebuffer;ue.isWebGLCubeRenderTarget?(Array.isArray(Mt[je])?We=Mt[je][Ve]:We=Mt[je],He=!0):ue.samples>0&&Y.useMultisampledRTT(ue)===!1?We=O.get(ue).__webglMultisampledFramebuffer:Array.isArray(Mt)?We=Mt[Ve]:We=Mt,K.copy(ue.viewport),V.copy(ue.scissor),J=ue.scissorTest}else K.copy(fe).multiplyScalar(Z).floor(),V.copy(oe).multiplyScalar(Z).floor(),J=Ne;if(Ve!==0&&(We=Bt),le.bindFramebuffer(I.FRAMEBUFFER,We)&&le.drawBuffers(ue,We),le.viewport(K),le.scissor(V),le.setScissorTest(J),He){const Et=O.get(ue.texture);I.framebufferTexture2D(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_CUBE_MAP_POSITIVE_X+je,Et.__webglTexture,Ve)}else if(wt){const Et=je;for(let St=0;St<ue.textures.length;St++){const Mt=O.get(ue.textures[St]);I.framebufferTextureLayer(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0+St,Mt.__webglTexture,Ve,Et)}}else if(ue!==null&&Ve!==0){const Et=O.get(ue.texture);I.framebufferTexture2D(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,Et.__webglTexture,Ve)}j=-1},this.readRenderTargetPixels=function(ue,je,Ve,We,He,wt,Dt,Et=0){if(!(ue&&ue.isWebGLRenderTarget)){Kn("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let St=O.get(ue).__webglFramebuffer;if(ue.isWebGLCubeRenderTarget&&Dt!==void 0&&(St=St[Dt]),St){le.bindFramebuffer(I.FRAMEBUFFER,St);try{const Mt=ue.textures[Et],Oe=Mt.format,gt=Mt.type;if(!Ie.textureFormatReadable(Oe)){Kn("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Ie.textureTypeReadable(gt)){Kn("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}je>=0&&je<=ue.width-We&&Ve>=0&&Ve<=ue.height-He&&(ue.textures.length>1&&I.readBuffer(I.COLOR_ATTACHMENT0+Et),I.readPixels(je,Ve,We,He,ve.convert(Oe),ve.convert(gt),wt))}finally{const Mt=q!==null?O.get(q).__webglFramebuffer:null;le.bindFramebuffer(I.FRAMEBUFFER,Mt)}}},this.readRenderTargetPixelsAsync=async function(ue,je,Ve,We,He,wt,Dt,Et=0){if(!(ue&&ue.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let St=O.get(ue).__webglFramebuffer;if(ue.isWebGLCubeRenderTarget&&Dt!==void 0&&(St=St[Dt]),St)if(je>=0&&je<=ue.width-We&&Ve>=0&&Ve<=ue.height-He){le.bindFramebuffer(I.FRAMEBUFFER,St);const Mt=ue.textures[Et],Oe=Mt.format,gt=Mt.type;if(!Ie.textureFormatReadable(Oe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Ie.textureTypeReadable(gt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Rt=I.createBuffer();I.bindBuffer(I.PIXEL_PACK_BUFFER,Rt),I.bufferData(I.PIXEL_PACK_BUFFER,wt.byteLength,I.STREAM_READ),ue.textures.length>1&&I.readBuffer(I.COLOR_ATTACHMENT0+Et),I.readPixels(je,Ve,We,He,ve.convert(Oe),ve.convert(gt),0);const ct=q!==null?O.get(q).__webglFramebuffer:null;le.bindFramebuffer(I.FRAMEBUFFER,ct);const Zt=I.fenceSync(I.SYNC_GPU_COMMANDS_COMPLETE,0);return I.flush(),await P3e(I,Zt,4),I.bindBuffer(I.PIXEL_PACK_BUFFER,Rt),I.getBufferSubData(I.PIXEL_PACK_BUFFER,0,wt),I.deleteBuffer(Rt),I.deleteSync(Zt),wt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(ue,je=null,Ve=0){const We=Math.pow(2,-Ve),He=Math.floor(ue.image.width*We),wt=Math.floor(ue.image.height*We),Dt=je!==null?je.x:0,Et=je!==null?je.y:0;Y.setTexture2D(ue,0),I.copyTexSubImage2D(I.TEXTURE_2D,Ve,0,0,Dt,Et,He,wt),le.unbindTexture()};const Ht=I.createFramebuffer(),Jt=I.createFramebuffer();this.copyTextureToTexture=function(ue,je,Ve=null,We=null,He=0,wt=null){wt===null&&(He!==0?(K0("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),wt=He,He=0):wt=0);let Dt,Et,St,Mt,Oe,gt,Rt,ct,Zt;const Kt=ue.isCompressedTexture?ue.mipmaps[wt]:ue.image;if(Ve!==null)Dt=Ve.max.x-Ve.min.x,Et=Ve.max.y-Ve.min.y,St=Ve.isBox3?Ve.max.z-Ve.min.z:1,Mt=Ve.min.x,Oe=Ve.min.y,gt=Ve.isBox3?Ve.min.z:0;else{const vr=Math.pow(2,-He);Dt=Math.floor(Kt.width*vr),Et=Math.floor(Kt.height*vr),ue.isDataArrayTexture?St=Kt.depth:ue.isData3DTexture?St=Math.floor(Kt.depth*vr):St=1,Mt=0,Oe=0,gt=0}We!==null?(Rt=We.x,ct=We.y,Zt=We.z):(Rt=0,ct=0,Zt=0);const be=ve.convert(je.format),ut=ve.convert(je.type);let It;je.isData3DTexture?(Y.setTexture3D(je,0),It=I.TEXTURE_3D):je.isDataArrayTexture||je.isCompressedArrayTexture?(Y.setTexture2DArray(je,0),It=I.TEXTURE_2D_ARRAY):(Y.setTexture2D(je,0),It=I.TEXTURE_2D),I.pixelStorei(I.UNPACK_FLIP_Y_WEBGL,je.flipY),I.pixelStorei(I.UNPACK_PREMULTIPLY_ALPHA_WEBGL,je.premultiplyAlpha),I.pixelStorei(I.UNPACK_ALIGNMENT,je.unpackAlignment);const yt=I.getParameter(I.UNPACK_ROW_LENGTH),Xt=I.getParameter(I.UNPACK_IMAGE_HEIGHT),tr=I.getParameter(I.UNPACK_SKIP_PIXELS),cn=I.getParameter(I.UNPACK_SKIP_ROWS),ki=I.getParameter(I.UNPACK_SKIP_IMAGES);I.pixelStorei(I.UNPACK_ROW_LENGTH,Kt.width),I.pixelStorei(I.UNPACK_IMAGE_HEIGHT,Kt.height),I.pixelStorei(I.UNPACK_SKIP_PIXELS,Mt),I.pixelStorei(I.UNPACK_SKIP_ROWS,Oe),I.pixelStorei(I.UNPACK_SKIP_IMAGES,gt);const $n=ue.isDataArrayTexture||ue.isData3DTexture,ui=je.isDataArrayTexture||je.isData3DTexture;if(ue.isDepthTexture){const vr=O.get(ue),Zn=O.get(je),kr=O.get(vr.__renderTarget),to=O.get(Zn.__renderTarget);le.bindFramebuffer(I.READ_FRAMEBUFFER,kr.__webglFramebuffer),le.bindFramebuffer(I.DRAW_FRAMEBUFFER,to.__webglFramebuffer);for(let jr=0;jr<St;jr++)$n&&(I.framebufferTextureLayer(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,O.get(ue).__webglTexture,He,gt+jr),I.framebufferTextureLayer(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,O.get(je).__webglTexture,wt,Zt+jr)),I.blitFramebuffer(Mt,Oe,Dt,Et,Rt,ct,Dt,Et,I.DEPTH_BUFFER_BIT,I.NEAREST);le.bindFramebuffer(I.READ_FRAMEBUFFER,null),le.bindFramebuffer(I.DRAW_FRAMEBUFFER,null)}else if(He!==0||ue.isRenderTargetTexture||O.has(ue)){const vr=O.get(ue),Zn=O.get(je);le.bindFramebuffer(I.READ_FRAMEBUFFER,Ht),le.bindFramebuffer(I.DRAW_FRAMEBUFFER,Jt);for(let kr=0;kr<St;kr++)$n?I.framebufferTextureLayer(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,vr.__webglTexture,He,gt+kr):I.framebufferTexture2D(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,vr.__webglTexture,He),ui?I.framebufferTextureLayer(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,Zn.__webglTexture,wt,Zt+kr):I.framebufferTexture2D(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,Zn.__webglTexture,wt),He!==0?I.blitFramebuffer(Mt,Oe,Dt,Et,Rt,ct,Dt,Et,I.COLOR_BUFFER_BIT,I.NEAREST):ui?I.copyTexSubImage3D(It,wt,Rt,ct,Zt+kr,Mt,Oe,Dt,Et):I.copyTexSubImage2D(It,wt,Rt,ct,Mt,Oe,Dt,Et);le.bindFramebuffer(I.READ_FRAMEBUFFER,null),le.bindFramebuffer(I.DRAW_FRAMEBUFFER,null)}else ui?ue.isDataTexture||ue.isData3DTexture?I.texSubImage3D(It,wt,Rt,ct,Zt,Dt,Et,St,be,ut,Kt.data):je.isCompressedArrayTexture?I.compressedTexSubImage3D(It,wt,Rt,ct,Zt,Dt,Et,St,be,Kt.data):I.texSubImage3D(It,wt,Rt,ct,Zt,Dt,Et,St,be,ut,Kt):ue.isDataTexture?I.texSubImage2D(I.TEXTURE_2D,wt,Rt,ct,Dt,Et,be,ut,Kt.data):ue.isCompressedTexture?I.compressedTexSubImage2D(I.TEXTURE_2D,wt,Rt,ct,Kt.width,Kt.height,be,Kt.data):I.texSubImage2D(I.TEXTURE_2D,wt,Rt,ct,Dt,Et,be,ut,Kt);I.pixelStorei(I.UNPACK_ROW_LENGTH,yt),I.pixelStorei(I.UNPACK_IMAGE_HEIGHT,Xt),I.pixelStorei(I.UNPACK_SKIP_PIXELS,tr),I.pixelStorei(I.UNPACK_SKIP_ROWS,cn),I.pixelStorei(I.UNPACK_SKIP_IMAGES,ki),wt===0&&je.generateMipmaps&&I.generateMipmap(It),le.unbindTexture()},this.initRenderTarget=function(ue){O.get(ue).__webglFramebuffer===void 0&&Y.setupRenderTarget(ue)},this.initTexture=function(ue){ue.isCubeTexture?Y.setTextureCube(ue,0):ue.isData3DTexture?Y.setTexture3D(ue,0):ue.isDataArrayTexture||ue.isCompressedArrayTexture?Y.setTexture2DArray(ue,0):Y.setTexture2D(ue,0),le.unbindTexture()},this.resetState=function(){U=0,L=0,q=null,le.reset(),$e.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Hl}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=Vn._getDrawingBufferColorSpace(e),n.unpackColorSpace=Vn._getUnpackColorSpace()}};const vG={type:"change"},dL={type:"start"},Dee={type:"end"},J_=new aL,_G=new xd,bIe=Math.cos(70*D3e.DEG2RAD),Pi=new nt,ms=2*Math.PI,gr={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Ek=1e-6;class yIe extends _Re{constructor(e,n=null){super(e,n),this.state=gr.NONE,this.target=new nt,this.cursor=new nt,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:rg.ROTATE,MIDDLE:rg.DOLLY,RIGHT:rg.PAN},this.touches={ONE:Kp.ROTATE,TWO:Kp.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new nt,this._lastQuaternion=new Qf,this._lastTargetPosition=new nt,this._quat=new Qf().setFromUnitVectors(e.up,new nt(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new XV,this._sphericalDelta=new XV,this._scale=1,this._panOffset=new nt,this._rotateStart=new Mn,this._rotateEnd=new Mn,this._rotateDelta=new Mn,this._panStart=new Mn,this._panEnd=new Mn,this._panDelta=new Mn,this._dollyStart=new Mn,this._dollyEnd=new Mn,this._dollyDelta=new Mn,this._dollyDirection=new nt,this._mouse=new Mn,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=_Ie.bind(this),this._onPointerDown=vIe.bind(this),this._onPointerUp=wIe.bind(this),this._onContextMenu=CIe.bind(this),this._onMouseWheel=EIe.bind(this),this._onKeyDown=NIe.bind(this),this._onTouchStart=AIe.bind(this),this._onTouchMove=TIe.bind(this),this._onMouseDown=SIe.bind(this),this._onMouseMove=MIe.bind(this),this._interceptControlDown=kIe.bind(this),this._interceptControlUp=jIe.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.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.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(vG),this.update(),this.state=gr.NONE}update(e=null){const n=this.object.position;Pi.copy(n).sub(this.target),Pi.applyQuaternion(this._quat),this._spherical.setFromVector3(Pi),this.autoRotate&&this.state===gr.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+=ms:r>Math.PI&&(r-=ms),i<-Math.PI?i+=ms:i>Math.PI&&(i-=ms),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(Pi.setFromSpherical(this._spherical),Pi.applyQuaternion(this._quatInverse),n.copy(this.target).add(Pi),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=Pi.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 nt(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 nt(this._mouse.x,this._mouse.y,0);u.unproject(this.object),this.object.position.sub(u).add(l),this.object.updateMatrixWorld(),o=Pi.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):(J_.origin.copy(this.object.position),J_.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(J_.direction))<bIe?this.object.lookAt(this.target):(_G.setFromNormalAndCoplanarPoint(this.object.up,this.target),J_.intersectPlane(_G,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)>Ek||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Ek||this._lastTargetPosition.distanceToSquared(this.target)>Ek?(this.dispatchEvent(vG),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?ms/60*this.autoRotateSpeed*e:ms/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){Pi.setFromMatrixColumn(n,0),Pi.multiplyScalar(-e),this._panOffset.add(Pi)}_panUp(e,n){this.screenSpacePanning===!0?Pi.setFromMatrixColumn(n,1):(Pi.setFromMatrixColumn(n,0),Pi.crossVectors(this.object.up,Pi)),Pi.multiplyScalar(e),this._panOffset.add(Pi)}_pan(e,n){const r=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;Pi.copy(i).sub(this.target);let a=Pi.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(ms*this._rotateDelta.x/n.clientHeight),this._rotateUp(ms*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(ms*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(-ms*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(ms*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(-ms*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(ms*this._rotateDelta.x/n.clientHeight),this._rotateUp(ms*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 Mn,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 vIe(t){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(t.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(t)&&(this._addPointer(t),t.pointerType==="touch"?this._onTouchStart(t):this._onMouseDown(t)))}function _Ie(t){this.enabled!==!1&&(t.pointerType==="touch"?this._onTouchMove(t):this._onMouseMove(t))}function wIe(t){switch(this._removePointer(t),this._pointers.length){case 0:this.domElement.releasePointerCapture(t.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(Dee),this.state=gr.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 SIe(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 rg.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(t),this.state=gr.DOLLY;break;case rg.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=gr.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=gr.ROTATE}break;case rg.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=gr.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=gr.PAN}break;default:this.state=gr.NONE}this.state!==gr.NONE&&this.dispatchEvent(dL)}function MIe(t){switch(this.state){case gr.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(t);break;case gr.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(t);break;case gr.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(t);break}}function EIe(t){this.enabled===!1||this.enableZoom===!1||this.state!==gr.NONE||(t.preventDefault(),this.dispatchEvent(dL),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(Dee))}function NIe(t){this.enabled!==!1&&this._handleKeyDown(t)}function AIe(t){switch(this._trackPointer(t),this._pointers.length){case 1:switch(this.touches.ONE){case Kp.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(t),this.state=gr.TOUCH_ROTATE;break;case Kp.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(t),this.state=gr.TOUCH_PAN;break;default:this.state=gr.NONE}break;case 2:switch(this.touches.TWO){case Kp.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(t),this.state=gr.TOUCH_DOLLY_PAN;break;case Kp.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(t),this.state=gr.TOUCH_DOLLY_ROTATE;break;default:this.state=gr.NONE}break;default:this.state=gr.NONE}this.state!==gr.NONE&&this.dispatchEvent(dL)}function TIe(t){switch(this._trackPointer(t),this.state){case gr.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(t),this.update();break;case gr.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(t),this.update();break;case gr.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(t),this.update();break;case gr.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(t),this.update();break;default:this.state=gr.NONE}}function CIe(t){this.enabled!==!1&&t.preventDefault()}function kIe(t){t.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function jIe(t){t.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function PIe(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 yl;let u=0;for(let d=0;d<t.length;++d){const f=t[d];let m=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]),m++}if(m!==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 m=0;m<t.length;++m){const p=t[m].index;for(let b=0;b<p.count;++b)f.push(p.getX(b)+d);d+=t[m].attributes.position.count}c.setIndex(f)}for(const d in a){const f=wG(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 m=0;m<f;++m){const p=[];for(let v=0;v<o[d].length;++v)p.push(o[d][v][m]);const b=wG(p);if(!b)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" morphAttribute."),null;c.morphAttributes[d].push(b)}}return c}function wG(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 Co(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 m=0,p=d.count;m<p;m++)for(let b=0;b<n;b++){const v=d.getComponent(m,b);l.setComponent(m+f,b,v)}}else o.set(d.array,c);c+=d.count*n}return i!==void 0&&(l.gpuType=i),l}function e1(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 Nk={exports:{}};var SG;function RIe(){return SG||(SG=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 e1=="function"&&e1;if(!d&&f)return f(u,!0);if(l)return l(u,!0);var m=new Error("Cannot find module '"+u+"'");throw m.code="MODULE_NOT_FOUND",m}var p=i[u]={exports:{}};r[u][0].call(p.exports,function(b){var v=r[u][1][b];return o(v||b)},p,p.exports,n,r,i,a)}return i[u].exports}for(var l=typeof e1=="function"&&e1,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,m,p,b,v,x=[],y=0,S=c.length,M=S,N=a.getTypeOf(c)!=="string";y<c.length;)M=S-y,f=N?(u=c[y++],d=y<S?c[y++]:0,y<S?c[y++]:0):(u=c.charCodeAt(y++),d=y<S?c.charCodeAt(y++):0,y<S?c.charCodeAt(y++):0),m=u>>2,p=(3&u)<<4|d>>4,b=1<M?(15&d)<<2|f>>6:64,v=2<M?63&f:64,x.push(l.charAt(m)+l.charAt(p)+l.charAt(b)+l.charAt(v));return x.join("")},i.decode=function(c){var u,d,f,m,p,b,v=0,x=0,y="data:";if(c.substr(0,y.length)===y)throw new Error("Invalid base64 input, it looks like a data url.");var S,M=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===l.charAt(64)&&M--,c.charAt(c.length-2)===l.charAt(64)&&M--,M%1!=0)throw new Error("Invalid base64 input, bad content length.");for(S=o.uint8array?new Uint8Array(0|M):new Array(0|M);v<c.length;)u=l.indexOf(c.charAt(v++))<<2|(m=l.indexOf(c.charAt(v++)))>>4,d=(15&m)<<4|(p=l.indexOf(c.charAt(v++)))>>2,f=(3&p)<<6|(b=l.indexOf(c.charAt(v++))),S[x++]=u,p!==64&&(S[x++]=d),b!==64&&(S[x++]=f);return S}},{"./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,m,p,b){this.compressedSize=d,this.uncompressedSize=f,this.crc32=m,this.compression=p,this.compressedContent=b}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,m){return d.pipe(new l).pipe(new c("uncompressedSize")).pipe(f.compressWorker(m)).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,m){var p=o,b=m+f;u^=-1;for(var v=m;v<b;v++)u=u>>>8^p[255&(u^d[v])];return-1^u})(0|c,l,l.length,0):(function(u,d,f,m){var p=o,b=m+f;u^=-1;for(var v=m;v<b;v++)u=u>>>8^p[255&(u^d.charCodeAt(v))];return-1^u})(0|c,l,l.length,0):0}},{"./utils":32}],5:[function(n,r,i){i.base64=!1,i.binary=!1,i.dir=!1,i.createFolders=!0,i.date=null,i.compression=null,i.compressionOptions=null,i.comment=null,i.unixPermissions=null,i.dosPermissions=null},{}],6:[function(n,r,i){var a=null;a=typeof Promise<"u"?Promise:n("lie"),r.exports={Promise:a}},{lie:37}],7:[function(n,r,i){var a=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",o=n("pako"),l=n("./utils"),c=n("./stream/GenericWorker"),u=a?"uint8array":"array";function d(f,m){c.call(this,"FlateWorker/"+f),this._pako=null,this._pakoAction=f,this._pakoOptions=m,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(m){f.push({data:m,meta:f.meta})}},i.compressWorker=function(f){return new d("Deflate",f)},i.uncompressWorker=function(){return new d("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,r,i){function a(p,b){var v,x="";for(v=0;v<b;v++)x+=String.fromCharCode(255&p),p>>>=8;return x}function o(p,b,v,x,y,S){var M,N,A=p.file,k=p.compression,C=S!==u.utf8encode,D=l.transformTo("string",S(A.name)),T=l.transformTo("string",u.utf8encode(A.name)),R=A.comment,U=l.transformTo("string",S(R)),L=l.transformTo("string",u.utf8encode(R)),q=T.length!==A.name.length,j=L.length!==R.length,W="",K="",V="",J=A.dir,ne=A.date,te={crc32:0,compressedSize:0,uncompressedSize:0};b&&!v||(te.crc32=p.crc32,te.compressedSize=p.compressedSize,te.uncompressedSize=p.uncompressedSize);var z=0;b&&(z|=8),C||!q&&!j||(z|=2048);var H=0,Z=0;J&&(H|=16),y==="UNIX"?(Z=798,H|=(function(he,fe){var oe=he;return he||(oe=fe?16893:33204),(65535&oe)<<16})(A.unixPermissions,J)):(Z=20,H|=(function(he){return 63&(he||0)})(A.dosPermissions)),M=ne.getUTCHours(),M<<=6,M|=ne.getUTCMinutes(),M<<=5,M|=ne.getUTCSeconds()/2,N=ne.getUTCFullYear()-1980,N<<=4,N|=ne.getUTCMonth()+1,N<<=5,N|=ne.getUTCDate(),q&&(K=a(1,1)+a(d(D),4)+T,W+="up"+a(K.length,2)+K),j&&(V=a(1,1)+a(d(U),4)+L,W+="uc"+a(V.length,2)+V);var ee="";return ee+=`
  3967. \0`,ee+=a(z,2),ee+=k.magic,ee+=a(M,2),ee+=a(N,2),ee+=a(te.crc32,4),ee+=a(te.compressedSize,4),ee+=a(te.uncompressedSize,4),ee+=a(D.length,2),ee+=a(W.length,2),{fileRecord:f.LOCAL_FILE_HEADER+ee+D+W,dirRecord:f.CENTRAL_FILE_HEADER+a(Z,2)+ee+a(U.length,2)+"\0\0\0\0"+a(H,4)+a(x,4)+D+W+U}}var l=n("../utils"),c=n("../stream/GenericWorker"),u=n("../utf8"),d=n("../crc32"),f=n("../signature");function m(p,b,v,x){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=b,this.zipPlatform=v,this.encodeFileName=x,this.streamFiles=p,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}l.inherits(m,c),m.prototype.push=function(p){var b=p.meta.percent||0,v=this.entriesCount,x=this._sources.length;this.accumulate?this.contentBuffer.push(p):(this.bytesWritten+=p.data.length,c.prototype.push.call(this,{data:p.data,meta:{currentFile:this.currentFile,percent:v?(b+100*(v-x-1))/v:100}}))},m.prototype.openedSource=function(p){this.currentSourceOffset=this.bytesWritten,this.currentFile=p.file.name;var b=this.streamFiles&&!p.file.dir;if(b){var v=o(p,b,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:v.fileRecord,meta:{percent:0}})}else this.accumulate=!0},m.prototype.closedSource=function(p){this.accumulate=!1;var b=this.streamFiles&&!p.file.dir,v=o(p,b,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(v.dirRecord),b)this.push({data:(function(x){return f.DATA_DESCRIPTOR+a(x.crc32,4)+a(x.compressedSize,4)+a(x.uncompressedSize,4)})(p),meta:{percent:100}});else for(this.push({data:v.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},m.prototype.flush=function(){for(var p=this.bytesWritten,b=0;b<this.dirRecords.length;b++)this.push({data:this.dirRecords[b],meta:{percent:100}});var v=this.bytesWritten-p,x=(function(y,S,M,N,A){var k=l.transformTo("string",A(N));return f.CENTRAL_DIRECTORY_END+"\0\0\0\0"+a(y,2)+a(y,2)+a(S,4)+a(M,4)+a(k.length,2)+k})(this.dirRecords.length,v,p,this.zipComment,this.encodeFileName);this.push({data:x,meta:{percent:100}})},m.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},m.prototype.registerPrevious=function(p){this._sources.push(p);var b=this;return p.on("data",function(v){b.processChunk(v)}),p.on("end",function(){b.closedSource(b.previous.streamInfo),b._sources.length?b.prepareNextSource():b.end()}),p.on("error",function(v){b.error(v)}),this},m.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))},m.prototype.error=function(p){var b=this._sources;if(!c.prototype.error.call(this,p))return!1;for(var v=0;v<b.length;v++)try{b[v].error(p)}catch{}return!0},m.prototype.lock=function(){c.prototype.lock.call(this);for(var p=this._sources,b=0;b<p.length;b++)p[b].lock()},r.exports=m},{"../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(m,p){f++;var b=(function(S,M){var N=S||M,A=a[N];if(!A)throw new Error(N+" is not a valid compression method !");return A})(p.options.compression,c.compression),v=p.options.compressionOptions||c.compressionOptions||{},x=p.dir,y=p.date;p._compressWorker(b,v).withStreamInfo("file",{name:m,dir:x,date:y,comment:p.comment||"",unixPermissions:p.unixPermissions,dosPermissions:p.dosPermissions}).pipe(d)}),d.entriesCount=f}catch(m){d.error(m)}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(m){return new o.Promise(function(p,b){var v=m.decompressed.getContentWorker().pipe(new u);v.on("error",function(x){b(x)}).on("end",function(){v.streamInfo.crc32!==m.decompressed.crc32?b(new Error("Corrupted zip : CRC32 mismatch")):p()}).resume()})}r.exports=function(m,p){var b=this;return p=a.extend(p||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:l.utf8decode}),d.isNode&&d.isStream(m)?o.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):a.prepareContent("the loaded zip file",m,!0,p.optimizedBinaryString,p.base64).then(function(v){var x=new c(p);return x.load(v),x}).then(function(v){var x=[o.Promise.resolve(v)],y=v.files;if(p.checkCRC32)for(var S=0;S<y.length;S++)x.push(f(y[S]));return o.Promise.all(x)}).then(function(v){for(var x=v.shift(),y=x.files,S=0;S<y.length;S++){var M=y[S],N=M.fileNameStr,A=a.resolve(M.fileNameStr);b.file(A,M.decompressed,{binary:!0,optimizedBinaryString:!0,date:M.date,dir:M.dir,comment:M.fileCommentStr.length?M.fileCommentStr:null,unixPermissions:M.unixPermissions,dosPermissions:M.dosPermissions,createFolders:p.createFolders}),M.dir||(b.file(A).unsafeOriginalName=N)}return x.zipComment.length&&(b.comment=x.zipComment),b})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(n,r,i){var a=n("../utils"),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,m){d.push(f)||d._helper.pause(),u&&u(m)}).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,k,C){var D,T=l.getTypeOf(k),R=l.extend(C||{},d);R.date=R.date||new Date,R.compression!==null&&(R.compression=R.compression.toUpperCase()),typeof R.unixPermissions=="string"&&(R.unixPermissions=parseInt(R.unixPermissions,8)),R.unixPermissions&&16384&R.unixPermissions&&(R.dir=!0),R.dosPermissions&&16&R.dosPermissions&&(R.dir=!0),R.dir&&(A=y(A)),R.createFolders&&(D=x(A))&&S.call(this,D,!0);var U=T==="string"&&R.binary===!1&&R.base64===!1;C&&C.binary!==void 0||(R.binary=!U),(k instanceof f&&k.uncompressedSize===0||R.dir||!k||k.length===0)&&(R.base64=!1,R.binary=!0,k="",R.compression="STORE",T="string");var L=null;L=k instanceof f||k instanceof c?k:b.isNode&&b.isStream(k)?new v(A,k):l.prepareContent(A,k,R.binary,R.optimizedBinaryString,R.base64);var q=new m(A,L,R);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"),m=n("./zipObject"),p=n("./generate"),b=n("./nodejsUtils"),v=n("./nodejs/NodejsStreamInputAdapter"),x=function(A){A.slice(-1)==="/"&&(A=A.substring(0,A.length-1));var k=A.lastIndexOf("/");return 0<k?A.substring(0,k):""},y=function(A){return A.slice(-1)!=="/"&&(A+="/"),A},S=function(A,k){return k=k!==void 0?k:d.createFolders,A=y(A),this.files[A]||a.call(this,A,null,{dir:!0,createFolders:k}),this.files[A]};function M(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 k,C,D;for(k in this.files)D=this.files[k],(C=k.slice(this.root.length,k.length))&&k.slice(0,this.root.length)===this.root&&A(C,D)},filter:function(A){var k=[];return this.forEach(function(C,D){A(C,D)&&k.push(D)}),k},file:function(A,k,C){if(arguments.length!==1)return A=this.root+A,a.call(this,A,k,C),this;if(M(A)){var D=A;return this.filter(function(R,U){return!U.dir&&D.test(R)})}var T=this.files[this.root+A];return T&&!T.dir?T:null},folder:function(A){if(!A)return this;if(M(A))return this.filter(function(T,R){return R.dir&&A.test(T)});var k=this.root+A,C=S.call(this,k),D=this.clone();return D.root=C.name,D},remove:function(A){A=this.root+A;var k=this.files[A];if(k||(A.slice(-1)!=="/"&&(A+="/"),k=this.files[A]),k&&!k.dir)delete this.files[A];else for(var C=this.filter(function(T,R){return R.name.slice(0,A.length)===A}),D=0;D<C.length;D++)delete this.files[C[D].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 k,C={};try{if((C=l.extend(A||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:o.utf8encode})).type=C.type.toLowerCase(),C.compression=C.compression.toUpperCase(),C.type==="binarystring"&&(C.type="string"),!C.type)throw new Error("No output type specified.");l.checkSupport(C.type),C.platform!=="darwin"&&C.platform!=="freebsd"&&C.platform!=="linux"&&C.platform!=="sunos"||(C.platform="UNIX"),C.platform==="win32"&&(C.platform="DOS");var D=C.comment||this.comment||"";k=p.generateWorker(this,C,D)}catch(T){(k=new c("error")).error(T)}return new u(k,C.type||"string",C.mimeType)},generateAsync:function(A,k){return this.generateInternalStream(A).accumulate(k)},generateNodeStream:function(A,k){return(A=A||{}).type||(A.type="nodebuffer"),this.generateInternalStream(A).toNodejsStream(k)}};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),m=this.length-4;0<=m;--m)if(this.data[m]===c&&this.data[m+1]===u&&this.data[m+2]===d&&this.data[m+3]===f)return m-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),m=this.readData(4);return c===m[0]&&u===m[1]&&d===m[2]&&f===m[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 m=a.getTypeOf(f);return a.checkSupport(m),m!=="string"||o.uint8array?m==="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 m(b,v){return new d.Promise(function(x,y){var S=[],M=b._internalType,N=b._outputType,A=b._mimeType;b.on("data",function(k,C){S.push(k),v&&v(C)}).on("error",function(k){S=[],y(k)}).on("end",function(){try{var k=(function(C,D,T){switch(C){case"blob":return a.newBlob(a.transformTo("arraybuffer",D),T);case"base64":return c.encode(D);default:return a.transformTo(C,D)}})(N,(function(C,D){var T,R=0,U=null,L=0;for(T=0;T<D.length;T++)L+=D[T].length;switch(C){case"string":return D.join("");case"array":return Array.prototype.concat.apply([],D);case"uint8array":for(U=new Uint8Array(L),T=0;T<D.length;T++)U.set(D[T],R),R+=D[T].length;return U;case"nodebuffer":return Buffer.concat(D);default:throw new Error("concat : unsupported type '"+C+"'")}})(M,S),A);x(k)}catch(C){y(C)}S=[]}).resume()})}function p(b,v,x){var y=v;switch(v){case"blob":case"arraybuffer":y="uint8array";break;case"base64":y="string"}try{this._internalType=y,this._outputType=v,this._mimeType=x,a.checkSupport(y),this._worker=b.pipe(new o(y)),b.lock()}catch(S){this._worker=new l("error"),this._worker.error(S)}}p.prototype={accumulate:function(b){return m(this,b)},on:function(b,v){var x=this;return b==="data"?this._worker.on(b,function(y){v.call(x,y.data,y.meta)}):this._worker.on(b,function(){a.delay(v,arguments,x)}),this},resume:function(){return a.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(b){if(a.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new f(this,{objectMode:this._outputType!=="nodebuffer"},b)}},r.exports=p},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(n,r,i){if(i.base64=!0,i.array=!0,i.string=!0,i.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",i.nodebuffer=typeof Buffer<"u",i.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")i.blob=!1;else{var a=new ArrayBuffer(0);try{i.blob=new Blob([a],{type:"application/zip"}).size===0}catch{try{var 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 m(){c.call(this,"utf-8 encode")}i.utf8encode=function(p){return o.nodebuffer?l.newBufferFrom(p,"utf-8"):(function(b){var v,x,y,S,M,N=b.length,A=0;for(S=0;S<N;S++)(64512&(x=b.charCodeAt(S)))==55296&&S+1<N&&(64512&(y=b.charCodeAt(S+1)))==56320&&(x=65536+(x-55296<<10)+(y-56320),S++),A+=x<128?1:x<2048?2:x<65536?3:4;for(v=o.uint8array?new Uint8Array(A):new Array(A),S=M=0;M<A;S++)(64512&(x=b.charCodeAt(S)))==55296&&S+1<N&&(64512&(y=b.charCodeAt(S+1)))==56320&&(x=65536+(x-55296<<10)+(y-56320),S++),x<128?v[M++]=x:(x<2048?v[M++]=192|x>>>6:(x<65536?v[M++]=224|x>>>12:(v[M++]=240|x>>>18,v[M++]=128|x>>>12&63),v[M++]=128|x>>>6&63),v[M++]=128|63&x);return v})(p)},i.utf8decode=function(p){return o.nodebuffer?a.transformTo("nodebuffer",p).toString("utf-8"):(function(b){var v,x,y,S,M=b.length,N=new Array(2*M);for(v=x=0;v<M;)if((y=b[v++])<128)N[x++]=y;else if(4<(S=u[y]))N[x++]=65533,v+=S-1;else{for(y&=S===2?31:S===3?15:7;1<S&&v<M;)y=y<<6|63&b[v++],S--;1<S?N[x++]=65533:y<65536?N[x++]=y:(y-=65536,N[x++]=55296|y>>10&1023,N[x++]=56320|1023&y)}return N.length!==x&&(N.subarray?N=N.subarray(0,x):N.length=x),a.applyFromCharCode(N)})(p=a.transformTo(o.uint8array?"uint8array":"array",p))},a.inherits(f,c),f.prototype.processChunk=function(p){var b=a.transformTo(o.uint8array?"uint8array":"array",p.data);if(this.leftOver&&this.leftOver.length){if(o.uint8array){var v=b;(b=new Uint8Array(v.length+this.leftOver.length)).set(this.leftOver,0),b.set(v,this.leftOver.length)}else b=this.leftOver.concat(b);this.leftOver=null}var x=(function(S,M){var N;for((M=M||S.length)>S.length&&(M=S.length),N=M-1;0<=N&&(192&S[N])==128;)N--;return N<0||N===0?M:N+u[S[N]]>M?N:M})(b),y=b;x!==b.length&&(o.uint8array?(y=b.subarray(0,x),this.leftOver=b.subarray(x,b.length)):(y=b.slice(0,x),this.leftOver=b.slice(x,b.length))),this.push({data:i.utf8decode(y),meta:p.meta})},f.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=f,a.inherits(m,c),m.prototype.processChunk=function(p){this.push({data:i.utf8encode(p.data),meta:p.meta})},i.Utf8EncodeWorker=m},{"./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(v){return v}function d(v,x){for(var y=0;y<v.length;++y)x[y]=255&v.charCodeAt(y);return x}n("setimmediate"),i.newBlob=function(v,x){i.checkSupport("blob");try{return new Blob([v],{type:x})}catch{try{var y=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return y.append(v),y.getBlob(x)}catch{throw new Error("Bug : can't construct the Blob.")}}};var f={stringifyByChunk:function(v,x,y){var S=[],M=0,N=v.length;if(N<=y)return String.fromCharCode.apply(null,v);for(;M<N;)x==="array"||x==="nodebuffer"?S.push(String.fromCharCode.apply(null,v.slice(M,Math.min(M+y,N)))):S.push(String.fromCharCode.apply(null,v.subarray(M,Math.min(M+y,N)))),M+=y;return S.join("")},stringifyByChar:function(v){for(var x="",y=0;y<v.length;y++)x+=String.fromCharCode(v[y]);return x},applyCanBeUsed:{uint8array:(function(){try{return a.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return a.nodebuffer&&String.fromCharCode.apply(null,l.allocBuffer(1)).length===1}catch{return!1}})()}};function m(v){var x=65536,y=i.getTypeOf(v),S=!0;if(y==="uint8array"?S=f.applyCanBeUsed.uint8array:y==="nodebuffer"&&(S=f.applyCanBeUsed.nodebuffer),S)for(;1<x;)try{return f.stringifyByChunk(v,y,x)}catch{x=Math.floor(x/2)}return f.stringifyByChar(v)}function p(v,x){for(var y=0;y<v.length;y++)x[y]=v[y];return x}i.applyFromCharCode=m;var b={};b.string={string:u,array:function(v){return d(v,new Array(v.length))},arraybuffer:function(v){return b.string.uint8array(v).buffer},uint8array:function(v){return d(v,new Uint8Array(v.length))},nodebuffer:function(v){return d(v,l.allocBuffer(v.length))}},b.array={string:m,array:u,arraybuffer:function(v){return new Uint8Array(v).buffer},uint8array:function(v){return new Uint8Array(v)},nodebuffer:function(v){return l.newBufferFrom(v)}},b.arraybuffer={string:function(v){return m(new Uint8Array(v))},array:function(v){return p(new Uint8Array(v),new Array(v.byteLength))},arraybuffer:u,uint8array:function(v){return new Uint8Array(v)},nodebuffer:function(v){return l.newBufferFrom(new Uint8Array(v))}},b.uint8array={string:m,array:function(v){return p(v,new Array(v.length))},arraybuffer:function(v){return v.buffer},uint8array:u,nodebuffer:function(v){return l.newBufferFrom(v)}},b.nodebuffer={string:m,array:function(v){return p(v,new Array(v.length))},arraybuffer:function(v){return b.nodebuffer.uint8array(v).buffer},uint8array:function(v){return p(v,new Uint8Array(v.length))},nodebuffer:u},i.transformTo=function(v,x){if(x=x||"",!v)return x;i.checkSupport(v);var y=i.getTypeOf(x);return b[y][v](x)},i.resolve=function(v){for(var x=v.split("/"),y=[],S=0;S<x.length;S++){var M=x[S];M==="."||M===""&&S!==0&&S!==x.length-1||(M===".."?y.pop():y.push(M))}return y.join("/")},i.getTypeOf=function(v){return typeof v=="string"?"string":Object.prototype.toString.call(v)==="[object Array]"?"array":a.nodebuffer&&l.isBuffer(v)?"nodebuffer":a.uint8array&&v instanceof Uint8Array?"uint8array":a.arraybuffer&&v instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(v){if(!a[v.toLowerCase()])throw new Error(v+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(v){var x,y,S="";for(y=0;y<(v||"").length;y++)S+="\\x"+((x=v.charCodeAt(y))<16?"0":"")+x.toString(16).toUpperCase();return S},i.delay=function(v,x,y){setImmediate(function(){v.apply(y||null,x||[])})},i.inherits=function(v,x){function y(){}y.prototype=x.prototype,v.prototype=new y},i.extend=function(){var v,x,y={};for(v=0;v<arguments.length;v++)for(x in arguments[v])Object.prototype.hasOwnProperty.call(arguments[v],x)&&y[x]===void 0&&(y[x]=arguments[v][x]);return y},i.prepareContent=function(v,x,y,S,M){return c.Promise.resolve(x).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,k){var C=new FileReader;C.onload=function(D){A(D.target.result)},C.onerror=function(D){k(D.target.error)},C.readAsArrayBuffer(N)}):N}).then(function(N){var A=i.getTypeOf(N);return A?(A==="arraybuffer"?N=i.transformTo("uint8array",N):A==="string"&&(M?N=o.decode(N):y&&S!==!0&&(N=(function(k){return d(k,a.uint8array?new Uint8Array(k.length):new Array(k.length))})(N))),N):c.Promise.reject(new Error("Can't read the data of '"+v+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(n,r,i){var a=n("./reader/readerFor"),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 m=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+o.pretty(m)+", expected "+o.pretty(f)+")")}},isSignature:function(f,m){var p=this.reader.index;this.reader.setIndex(f);var b=this.reader.readString(4)===m;return this.reader.setIndex(p),b},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var f=this.reader.readData(this.zipCommentLength),m=u.uint8array?"uint8array":"array",p=o.transformTo(m,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,m,p,b=this.zip64EndOfCentralSize-44;0<b;)f=this.reader.readInt(2),m=this.reader.readInt(4),p=this.reader.readData(m),this.zip64ExtensibleData[f]={id:f,length:m,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,m;for(f=0;f<this.files.length;f++)m=this.files[f],this.reader.setIndex(m.localHeaderOffset),this.checkSignature(l.LOCAL_FILE_HEADER),m.readLocalPart(this.reader),m.handleUTF8(),m.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 m=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 b=m-p;if(0<b)this.isSignature(m,l.CENTRAL_FILE_HEADER)||(this.reader.zero=b);else if(b<0)throw new Error("Corrupted zip: missing "+Math.abs(b)+" bytes.")},prepareReader:function(f){this.reader=a(f)},load:function(f){this.prepareReader(f),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},r.exports=d},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(n,r,i){var a=n("./reader/readerFor"),o=n("./utils"),l=n("./compressedObject"),c=n("./crc32"),u=n("./utf8"),d=n("./compressions"),f=n("./support");function m(p,b){this.options=p,this.loadOptions=b}m.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(p){var b,v;if(p.skip(22),this.fileNameLength=p.readInt(2),v=p.readInt(2),this.fileName=p.readData(this.fileNameLength),p.skip(v),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((b=(function(x){for(var y in d)if(Object.prototype.hasOwnProperty.call(d,y)&&d[y].magic===x)return d[y];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+o.pretty(this.compressionMethod)+" unknown (inner file : "+o.transformTo("string",this.fileName)+")");this.decompressed=new l(this.compressedSize,this.uncompressedSize,this.crc32,b,p.readData(this.compressedSize))},readCentralPart:function(p){this.versionMadeBy=p.readInt(2),p.skip(2),this.bitFlag=p.readInt(2),this.compressionMethod=p.readString(2),this.date=p.readDate(),this.crc32=p.readInt(4),this.compressedSize=p.readInt(4),this.uncompressedSize=p.readInt(4);var b=p.readInt(2);if(this.extraFieldsLength=p.readInt(2),this.fileCommentLength=p.readInt(2),this.diskNumberStart=p.readInt(2),this.internalFileAttributes=p.readInt(2),this.externalFileAttributes=p.readInt(4),this.localHeaderOffset=p.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");p.skip(b),this.readExtraFields(p),this.parseZIP64ExtraField(p),this.fileComment=p.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var p=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),p==0&&(this.dosPermissions=63&this.externalFileAttributes),p==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var p=a(this.extraFields[1].value);this.uncompressedSize===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 b,v,x,y=p.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});p.index+4<y;)b=p.readInt(2),v=p.readInt(2),x=p.readData(v),this.extraFields[b]={id:b,length:v,value:x};p.setIndex(y)},handleUTF8:function(){var p=f.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=u.utf8decode(this.fileName),this.fileCommentStr=u.utf8decode(this.fileComment);else{var b=this.findExtraFieldUnicodePath();if(b!==null)this.fileNameStr=b;else{var v=o.transformTo(p,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(v)}var x=this.findExtraFieldUnicodeComment();if(x!==null)this.fileCommentStr=x;else{var y=o.transformTo(p,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(y)}}},findExtraFieldUnicodePath:function(){var p=this.extraFields[28789];if(p){var b=a(p.value);return b.readInt(1)!==1||c(this.fileName)!==b.readInt(4)?null:u.utf8decode(b.readData(p.length-5))}return null},findExtraFieldUnicodeComment:function(){var p=this.extraFields[25461];if(p){var b=a(p.value);return b.readInt(1)!==1||c(this.fileComment)!==b.readInt(4)?null:u.utf8decode(b.readData(p.length-5))}return null}},r.exports=m},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(n,r,i){function a(b,v,x){this.name=b,this.dir=x.dir,this.date=x.date,this.comment=x.comment,this.unixPermissions=x.unixPermissions,this.dosPermissions=x.dosPermissions,this._data=v,this._dataBinary=x.binary,this.options={compression:x.compression,compressionOptions:x.compressionOptions}}var o=n("./stream/StreamHelper"),l=n("./stream/DataWorker"),c=n("./utf8"),u=n("./compressedObject"),d=n("./stream/GenericWorker");a.prototype={internalStream:function(b){var v=null,x="string";try{if(!b)throw new Error("No output type specified.");var y=(x=b.toLowerCase())==="string"||x==="text";x!=="binarystring"&&x!=="text"||(x="string"),v=this._decompressWorker();var S=!this._dataBinary;S&&!y&&(v=v.pipe(new c.Utf8EncodeWorker)),!S&&y&&(v=v.pipe(new c.Utf8DecodeWorker))}catch(M){(v=new d("error")).error(M)}return new o(v,x,"")},async:function(b,v){return this.internalStream(b).accumulate(v)},nodeStream:function(b,v){return this.internalStream(b||"nodebuffer").toNodejsStream(v)},_compressWorker:function(b,v){if(this._data instanceof u&&this._data.compression.magic===b.magic)return this._data.getCompressedWorker();var x=this._decompressWorker();return this._dataBinary||(x=x.pipe(new c.Utf8EncodeWorker)),u.createWorkerFrom(x,b,v)},_decompressWorker:function(){return this._data instanceof u?this._data.getContentWorker():this._data instanceof d?this._data:new l(this._data)}};for(var f=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],m=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]]=m;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(b),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 v=a.document.createElement("script");v.onreadystatechange=function(){b(),v.onreadystatechange=null,v.parentNode.removeChild(v),v=null},a.document.documentElement.appendChild(v)}:function(){setTimeout(b,0)};else{var m=new a.MessageChannel;m.port1.onmessage=b,o=function(){m.port2.postMessage(0)}}var p=[];function b(){var v,x;l=!0;for(var y=p.length;y;){for(x=p,p=[],v=-1;++v<y;)x[v]();y=p.length}l=!1}r.exports=function(v){p.push(v)!==1||l||o()}}).call(this,typeof c_<"u"?c_: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(y){if(typeof y!="function")throw new TypeError("resolver must be a function");this.state=d,this.queue=[],this.outcome=void 0,y!==o&&v(this,y)}function m(y,S,M){this.promise=y,typeof S=="function"&&(this.onFulfilled=S,this.callFulfilled=this.otherCallFulfilled),typeof M=="function"&&(this.onRejected=M,this.callRejected=this.otherCallRejected)}function p(y,S,M){a(function(){var N;try{N=S(M)}catch(A){return l.reject(y,A)}N===y?l.reject(y,new TypeError("Cannot resolve promise with itself")):l.resolve(y,N)})}function b(y){var S=y&&y.then;if(y&&(typeof y=="object"||typeof y=="function")&&typeof S=="function")return function(){S.apply(y,arguments)}}function v(y,S){var M=!1;function N(C){M||(M=!0,l.reject(y,C))}function A(C){M||(M=!0,l.resolve(y,C))}var k=x(function(){S(A,N)});k.status==="error"&&N(k.value)}function x(y,S){var M={};try{M.value=y(S),M.status="success"}catch(N){M.status="error",M.value=N}return M}(r.exports=f).prototype.finally=function(y){if(typeof y!="function")return this;var S=this.constructor;return this.then(function(M){return S.resolve(y()).then(function(){return M})},function(M){return S.resolve(y()).then(function(){throw M})})},f.prototype.catch=function(y){return this.then(null,y)},f.prototype.then=function(y,S){if(typeof y!="function"&&this.state===u||typeof S!="function"&&this.state===c)return this;var M=new this.constructor(o);return this.state!==d?p(M,this.state===u?y:S,this.outcome):this.queue.push(new m(M,y,S)),M},m.prototype.callFulfilled=function(y){l.resolve(this.promise,y)},m.prototype.otherCallFulfilled=function(y){p(this.promise,this.onFulfilled,y)},m.prototype.callRejected=function(y){l.reject(this.promise,y)},m.prototype.otherCallRejected=function(y){p(this.promise,this.onRejected,y)},l.resolve=function(y,S){var M=x(b,S);if(M.status==="error")return l.reject(y,M.value);var N=M.value;if(N)v(y,N);else{y.state=u,y.outcome=S;for(var A=-1,k=y.queue.length;++A<k;)y.queue[A].callFulfilled(S)}return y},l.reject=function(y,S){y.state=c,y.outcome=S;for(var M=-1,N=y.queue.length;++M<N;)y.queue[M].callRejected(S);return y},f.resolve=function(y){return y instanceof this?y:l.resolve(new this(o),y)},f.reject=function(y){var S=new this(o);return l.reject(S,y)},f.all=function(y){var S=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var M=y.length,N=!1;if(!M)return this.resolve([]);for(var A=new Array(M),k=0,C=-1,D=new this(o);++C<M;)T(y[C],C);return D;function T(R,U){S.resolve(R).then(function(L){A[U]=L,++k!==M||N||(N=!0,l.resolve(D,A))},function(L){N||(N=!0,l.reject(D,L))})}},f.race=function(y){var S=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var M=y.length,N=!1;if(!M)return this.resolve([]);for(var A=-1,k=new this(o);++A<M;)C=y[A],S.resolve(C).then(function(D){N||(N=!0,l.resolve(k,D))},function(D){N||(N=!0,l.reject(k,D))});var C;return k}},{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,m=-1,p=0,b=8;function v(y){if(!(this instanceof v))return new v(y);this.options=o.assign({level:m,method:b,chunkSize:16384,windowBits:15,memLevel:8,strategy:p,to:""},y||{});var S=this.options;S.raw&&0<S.windowBits?S.windowBits=-S.windowBits:S.gzip&&0<S.windowBits&&S.windowBits<16&&(S.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var M=a.deflateInit2(this.strm,S.level,S.method,S.windowBits,S.memLevel,S.strategy);if(M!==f)throw new Error(c[M]);if(S.header&&a.deflateSetHeader(this.strm,S.header),S.dictionary){var N;if(N=typeof S.dictionary=="string"?l.string2buf(S.dictionary):d.call(S.dictionary)==="[object ArrayBuffer]"?new Uint8Array(S.dictionary):S.dictionary,(M=a.deflateSetDictionary(this.strm,N))!==f)throw new Error(c[M]);this._dict_set=!0}}function x(y,S){var M=new v(S);if(M.push(y,!0),M.err)throw M.msg||c[M.err];return M.result}v.prototype.push=function(y,S){var M,N,A=this.strm,k=this.options.chunkSize;if(this.ended)return!1;N=S===~~S?S:S===!0?4:0,typeof y=="string"?A.input=l.string2buf(y):d.call(y)==="[object ArrayBuffer]"?A.input=new Uint8Array(y):A.input=y,A.next_in=0,A.avail_in=A.input.length;do{if(A.avail_out===0&&(A.output=new o.Buf8(k),A.next_out=0,A.avail_out=k),(M=a.deflate(A,N))!==1&&M!==f)return this.onEnd(M),!(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)&&M!==1);return N===4?(M=a.deflateEnd(this.strm),this.onEnd(M),this.ended=!0,M===f):N!==2||(this.onEnd(f),!(A.avail_out=0))},v.prototype.onData=function(y){this.chunks.push(y)},v.prototype.onEnd=function(y){y===f&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=y,this.msg=this.strm.msg},i.Deflate=v,i.deflate=x,i.deflateRaw=function(y,S){return(S=S||{}).raw=!0,x(y,S)},i.gzip=function(y,S){return(S=S||{}).gzip=!0,x(y,S)}},{"./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"),m=Object.prototype.toString;function p(v){if(!(this instanceof p))return new p(v);this.options=o.assign({chunkSize:16384,windowBits:0,to:""},v||{});var x=this.options;x.raw&&0<=x.windowBits&&x.windowBits<16&&(x.windowBits=-x.windowBits,x.windowBits===0&&(x.windowBits=-15)),!(0<=x.windowBits&&x.windowBits<16)||v&&v.windowBits||(x.windowBits+=32),15<x.windowBits&&x.windowBits<48&&(15&x.windowBits)==0&&(x.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new d,this.strm.avail_out=0;var y=a.inflateInit2(this.strm,x.windowBits);if(y!==c.Z_OK)throw new Error(u[y]);this.header=new f,a.inflateGetHeader(this.strm,this.header)}function b(v,x){var y=new p(x);if(y.push(v,!0),y.err)throw y.msg||u[y.err];return y.result}p.prototype.push=function(v,x){var y,S,M,N,A,k,C=this.strm,D=this.options.chunkSize,T=this.options.dictionary,R=!1;if(this.ended)return!1;S=x===~~x?x:x===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof v=="string"?C.input=l.binstring2buf(v):m.call(v)==="[object ArrayBuffer]"?C.input=new Uint8Array(v):C.input=v,C.next_in=0,C.avail_in=C.input.length;do{if(C.avail_out===0&&(C.output=new o.Buf8(D),C.next_out=0,C.avail_out=D),(y=a.inflate(C,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&T&&(k=typeof T=="string"?l.string2buf(T):m.call(T)==="[object ArrayBuffer]"?new Uint8Array(T):T,y=a.inflateSetDictionary(this.strm,k)),y===c.Z_BUF_ERROR&&R===!0&&(y=c.Z_OK,R=!1),y!==c.Z_STREAM_END&&y!==c.Z_OK)return this.onEnd(y),!(this.ended=!0);C.next_out&&(C.avail_out!==0&&y!==c.Z_STREAM_END&&(C.avail_in!==0||S!==c.Z_FINISH&&S!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(M=l.utf8border(C.output,C.next_out),N=C.next_out-M,A=l.buf2string(C.output,M),C.next_out=N,C.avail_out=D-N,N&&o.arraySet(C.output,C.output,M,N,0),this.onData(A)):this.onData(o.shrinkBuf(C.output,C.next_out)))),C.avail_in===0&&C.avail_out===0&&(R=!0)}while((0<C.avail_in||C.avail_out===0)&&y!==c.Z_STREAM_END);return y===c.Z_STREAM_END&&(S=c.Z_FINISH),S===c.Z_FINISH?(y=a.inflateEnd(this.strm),this.onEnd(y),this.ended=!0,y===c.Z_OK):S!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(C.avail_out=0))},p.prototype.onData=function(v){this.chunks.push(v)},p.prototype.onEnd=function(v){v===c.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=v,this.msg=this.strm.msg},i.Inflate=p,i.inflate=b,i.inflateRaw=function(v,x){return(x=x||{}).raw=!0,b(v,x)},i.ungzip=b},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(n,r,i){var a=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";i.assign=function(c){for(var u=Array.prototype.slice.call(arguments,1);u.length;){var d=u.shift();if(d){if(typeof d!="object")throw new TypeError(d+"must be non-object");for(var f in d)d.hasOwnProperty(f)&&(c[f]=d[f])}}return c},i.shrinkBuf=function(c,u){return c.length===u?c:c.subarray?c.subarray(0,u):(c.length=u,c)};var o={arraySet:function(c,u,d,f,m){if(u.subarray&&c.subarray)c.set(u.subarray(d,d+f),m);else for(var p=0;p<f;p++)c[m+p]=u[d+p]},flattenChunks:function(c){var u,d,f,m,p,b;for(u=f=0,d=c.length;u<d;u++)f+=c[u].length;for(b=new Uint8Array(f),u=m=0,d=c.length;u<d;u++)p=c[u],b.set(p,m),m+=p.length;return b}},l={arraySet:function(c,u,d,f,m){for(var p=0;p<f;p++)c[m+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,m){if(m<65537&&(f.subarray&&l||!f.subarray&&o))return String.fromCharCode.apply(null,a.shrinkBuf(f,m));for(var p="",b=0;b<m;b++)p+=String.fromCharCode(f[b]);return p}c[254]=c[254]=1,i.string2buf=function(f){var m,p,b,v,x,y=f.length,S=0;for(v=0;v<y;v++)(64512&(p=f.charCodeAt(v)))==55296&&v+1<y&&(64512&(b=f.charCodeAt(v+1)))==56320&&(p=65536+(p-55296<<10)+(b-56320),v++),S+=p<128?1:p<2048?2:p<65536?3:4;for(m=new a.Buf8(S),v=x=0;x<S;v++)(64512&(p=f.charCodeAt(v)))==55296&&v+1<y&&(64512&(b=f.charCodeAt(v+1)))==56320&&(p=65536+(p-55296<<10)+(b-56320),v++),p<128?m[x++]=p:(p<2048?m[x++]=192|p>>>6:(p<65536?m[x++]=224|p>>>12:(m[x++]=240|p>>>18,m[x++]=128|p>>>12&63),m[x++]=128|p>>>6&63),m[x++]=128|63&p);return m},i.buf2binstring=function(f){return d(f,f.length)},i.binstring2buf=function(f){for(var m=new a.Buf8(f.length),p=0,b=m.length;p<b;p++)m[p]=f.charCodeAt(p);return m},i.buf2string=function(f,m){var p,b,v,x,y=m||f.length,S=new Array(2*y);for(p=b=0;p<y;)if((v=f[p++])<128)S[b++]=v;else if(4<(x=c[v]))S[b++]=65533,p+=x-1;else{for(v&=x===2?31:x===3?15:7;1<x&&p<y;)v=v<<6|63&f[p++],x--;1<x?S[b++]=65533:v<65536?S[b++]=v:(v-=65536,S[b++]=55296|v>>10&1023,S[b++]=56320|1023&v)}return d(S,b)},i.utf8border=function(f,m){var p;for((m=m||f.length)>f.length&&(m=f.length),p=m-1;0<=p&&(192&f[p])==128;)p--;return p<0||p===0?m:p+c[f[p]]>m?p:m}},{"./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 m=u;m<f;m++)o=o>>>8^d[255&(o^l[m])];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,m=4,p=0,b=-2,v=-1,x=4,y=2,S=8,M=9,N=286,A=30,k=19,C=2*N+1,D=15,T=3,R=258,U=R+T+1,L=42,q=113,j=1,W=2,K=3,V=4;function J(G,ie){return G.msg=d[ie],ie}function ne(G){return(G<<1)-(4<G?9:0)}function te(G){for(var ie=G.length;0<=--ie;)G[ie]=0}function z(G){var ie=G.state,X=ie.pending;X>G.avail_out&&(X=G.avail_out),X!==0&&(o.arraySet(G.output,ie.pending_buf,ie.pending_out,X,G.next_out),G.next_out+=X,ie.pending_out+=X,G.total_out+=X,G.avail_out-=X,ie.pending-=X,ie.pending===0&&(ie.pending_out=0))}function H(G,ie){l._tr_flush_block(G,0<=G.block_start?G.block_start:-1,G.strstart-G.block_start,ie),G.block_start=G.strstart,z(G.strm)}function Z(G,ie){G.pending_buf[G.pending++]=ie}function ee(G,ie){G.pending_buf[G.pending++]=ie>>>8&255,G.pending_buf[G.pending++]=255&ie}function he(G,ie){var X,$,I=G.max_chain_length,ce=G.strstart,Ee=G.prev_length,Ie=G.nice_match,le=G.strstart>G.w_size-U?G.strstart-(G.w_size-U):0,B=G.window,O=G.w_mask,Y=G.prev,pe=G.strstart+R,we=B[ce+Ee-1],ae=B[ce+Ee];G.prev_length>=G.good_match&&(I>>=2),Ie>G.lookahead&&(Ie=G.lookahead);do if(B[(X=ie)+Ee]===ae&&B[X+Ee-1]===we&&B[X]===B[ce]&&B[++X]===B[ce+1]){ce+=2,X++;do;while(B[++ce]===B[++X]&&B[++ce]===B[++X]&&B[++ce]===B[++X]&&B[++ce]===B[++X]&&B[++ce]===B[++X]&&B[++ce]===B[++X]&&B[++ce]===B[++X]&&B[++ce]===B[++X]&&ce<pe);if($=R-(pe-ce),ce=pe-R,Ee<$){if(G.match_start=ie,Ie<=(Ee=$))break;we=B[ce+Ee-1],ae=B[ce+Ee]}}while((ie=Y[ie&O])>le&&--I!=0);return Ee<=G.lookahead?Ee:G.lookahead}function fe(G){var ie,X,$,I,ce,Ee,Ie,le,B,O,Y=G.w_size;do{if(I=G.window_size-G.lookahead-G.strstart,G.strstart>=Y+(Y-U)){for(o.arraySet(G.window,G.window,Y,Y,0),G.match_start-=Y,G.strstart-=Y,G.block_start-=Y,ie=X=G.hash_size;$=G.head[--ie],G.head[ie]=Y<=$?$-Y:0,--X;);for(ie=X=Y;$=G.prev[--ie],G.prev[ie]=Y<=$?$-Y:0,--X;);I+=Y}if(G.strm.avail_in===0)break;if(Ee=G.strm,Ie=G.window,le=G.strstart+G.lookahead,B=I,O=void 0,O=Ee.avail_in,B<O&&(O=B),X=O===0?0:(Ee.avail_in-=O,o.arraySet(Ie,Ee.input,Ee.next_in,O,le),Ee.state.wrap===1?Ee.adler=c(Ee.adler,Ie,O,le):Ee.state.wrap===2&&(Ee.adler=u(Ee.adler,Ie,O,le)),Ee.next_in+=O,Ee.total_in+=O,O),G.lookahead+=X,G.lookahead+G.insert>=T)for(ce=G.strstart-G.insert,G.ins_h=G.window[ce],G.ins_h=(G.ins_h<<G.hash_shift^G.window[ce+1])&G.hash_mask;G.insert&&(G.ins_h=(G.ins_h<<G.hash_shift^G.window[ce+T-1])&G.hash_mask,G.prev[ce&G.w_mask]=G.head[G.ins_h],G.head[G.ins_h]=ce,ce++,G.insert--,!(G.lookahead+G.insert<T)););}while(G.lookahead<U&&G.strm.avail_in!==0)}function oe(G,ie){for(var X,$;;){if(G.lookahead<U){if(fe(G),G.lookahead<U&&ie===f)return j;if(G.lookahead===0)break}if(X=0,G.lookahead>=T&&(G.ins_h=(G.ins_h<<G.hash_shift^G.window[G.strstart+T-1])&G.hash_mask,X=G.prev[G.strstart&G.w_mask]=G.head[G.ins_h],G.head[G.ins_h]=G.strstart),X!==0&&G.strstart-X<=G.w_size-U&&(G.match_length=he(G,X)),G.match_length>=T)if($=l._tr_tally(G,G.strstart-G.match_start,G.match_length-T),G.lookahead-=G.match_length,G.match_length<=G.max_lazy_match&&G.lookahead>=T){for(G.match_length--;G.strstart++,G.ins_h=(G.ins_h<<G.hash_shift^G.window[G.strstart+T-1])&G.hash_mask,X=G.prev[G.strstart&G.w_mask]=G.head[G.ins_h],G.head[G.ins_h]=G.strstart,--G.match_length!=0;);G.strstart++}else G.strstart+=G.match_length,G.match_length=0,G.ins_h=G.window[G.strstart],G.ins_h=(G.ins_h<<G.hash_shift^G.window[G.strstart+1])&G.hash_mask;else $=l._tr_tally(G,0,G.window[G.strstart]),G.lookahead--,G.strstart++;if($&&(H(G,!1),G.strm.avail_out===0))return j}return G.insert=G.strstart<T-1?G.strstart:T-1,ie===m?(H(G,!0),G.strm.avail_out===0?K:V):G.last_lit&&(H(G,!1),G.strm.avail_out===0)?j:W}function Ne(G,ie){for(var X,$,I;;){if(G.lookahead<U){if(fe(G),G.lookahead<U&&ie===f)return j;if(G.lookahead===0)break}if(X=0,G.lookahead>=T&&(G.ins_h=(G.ins_h<<G.hash_shift^G.window[G.strstart+T-1])&G.hash_mask,X=G.prev[G.strstart&G.w_mask]=G.head[G.ins_h],G.head[G.ins_h]=G.strstart),G.prev_length=G.match_length,G.prev_match=G.match_start,G.match_length=T-1,X!==0&&G.prev_length<G.max_lazy_match&&G.strstart-X<=G.w_size-U&&(G.match_length=he(G,X),G.match_length<=5&&(G.strategy===1||G.match_length===T&&4096<G.strstart-G.match_start)&&(G.match_length=T-1)),G.prev_length>=T&&G.match_length<=G.prev_length){for(I=G.strstart+G.lookahead-T,$=l._tr_tally(G,G.strstart-1-G.prev_match,G.prev_length-T),G.lookahead-=G.prev_length-1,G.prev_length-=2;++G.strstart<=I&&(G.ins_h=(G.ins_h<<G.hash_shift^G.window[G.strstart+T-1])&G.hash_mask,X=G.prev[G.strstart&G.w_mask]=G.head[G.ins_h],G.head[G.ins_h]=G.strstart),--G.prev_length!=0;);if(G.match_available=0,G.match_length=T-1,G.strstart++,$&&(H(G,!1),G.strm.avail_out===0))return j}else if(G.match_available){if(($=l._tr_tally(G,0,G.window[G.strstart-1]))&&H(G,!1),G.strstart++,G.lookahead--,G.strm.avail_out===0)return j}else G.match_available=1,G.strstart++,G.lookahead--}return G.match_available&&($=l._tr_tally(G,0,G.window[G.strstart-1]),G.match_available=0),G.insert=G.strstart<T-1?G.strstart:T-1,ie===m?(H(G,!0),G.strm.avail_out===0?K:V):G.last_lit&&(H(G,!1),G.strm.avail_out===0)?j:W}function ge(G,ie,X,$,I){this.good_length=G,this.max_lazy=ie,this.nice_length=X,this.max_chain=$,this.func=I}function Se(){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=S,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*C),this.dyn_dtree=new o.Buf16(2*(2*A+1)),this.bl_tree=new o.Buf16(2*(2*k+1)),te(this.dyn_ltree),te(this.dyn_dtree),te(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new o.Buf16(D+1),this.heap=new o.Buf16(2*N+1),te(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new o.Buf16(2*N+1),te(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function Re(G){var ie;return G&&G.state?(G.total_in=G.total_out=0,G.data_type=y,(ie=G.state).pending=0,ie.pending_out=0,ie.wrap<0&&(ie.wrap=-ie.wrap),ie.status=ie.wrap?L:q,G.adler=ie.wrap===2?0:1,ie.last_flush=f,l._tr_init(ie),p):J(G,b)}function de(G){var ie=Re(G);return ie===p&&(function(X){X.window_size=2*X.w_size,te(X.head),X.max_lazy_match=a[X.level].max_lazy,X.good_match=a[X.level].good_length,X.nice_match=a[X.level].nice_length,X.max_chain_length=a[X.level].max_chain,X.strstart=0,X.block_start=0,X.lookahead=0,X.insert=0,X.match_length=X.prev_length=T-1,X.match_available=0,X.ins_h=0})(G.state),ie}function Qe(G,ie,X,$,I,ce){if(!G)return b;var Ee=1;if(ie===v&&(ie=6),$<0?(Ee=0,$=-$):15<$&&(Ee=2,$-=16),I<1||M<I||X!==S||$<8||15<$||ie<0||9<ie||ce<0||x<ce)return J(G,b);$===8&&($=9);var Ie=new Se;return(G.state=Ie).strm=G,Ie.wrap=Ee,Ie.gzhead=null,Ie.w_bits=$,Ie.w_size=1<<Ie.w_bits,Ie.w_mask=Ie.w_size-1,Ie.hash_bits=I+7,Ie.hash_size=1<<Ie.hash_bits,Ie.hash_mask=Ie.hash_size-1,Ie.hash_shift=~~((Ie.hash_bits+T-1)/T),Ie.window=new o.Buf8(2*Ie.w_size),Ie.head=new o.Buf16(Ie.hash_size),Ie.prev=new o.Buf16(Ie.w_size),Ie.lit_bufsize=1<<I+6,Ie.pending_buf_size=4*Ie.lit_bufsize,Ie.pending_buf=new o.Buf8(Ie.pending_buf_size),Ie.d_buf=1*Ie.lit_bufsize,Ie.l_buf=3*Ie.lit_bufsize,Ie.level=ie,Ie.strategy=ce,Ie.method=X,de(G)}a=[new ge(0,0,0,0,function(G,ie){var X=65535;for(X>G.pending_buf_size-5&&(X=G.pending_buf_size-5);;){if(G.lookahead<=1){if(fe(G),G.lookahead===0&&ie===f)return j;if(G.lookahead===0)break}G.strstart+=G.lookahead,G.lookahead=0;var $=G.block_start+X;if((G.strstart===0||G.strstart>=$)&&(G.lookahead=G.strstart-$,G.strstart=$,H(G,!1),G.strm.avail_out===0)||G.strstart-G.block_start>=G.w_size-U&&(H(G,!1),G.strm.avail_out===0))return j}return G.insert=0,ie===m?(H(G,!0),G.strm.avail_out===0?K:V):(G.strstart>G.block_start&&(H(G,!1),G.strm.avail_out),j)}),new ge(4,4,8,4,oe),new ge(4,5,16,8,oe),new ge(4,6,32,32,oe),new ge(4,4,16,16,Ne),new ge(8,16,32,32,Ne),new ge(8,16,128,128,Ne),new ge(8,32,128,256,Ne),new ge(32,128,258,1024,Ne),new ge(32,258,258,4096,Ne)],i.deflateInit=function(G,ie){return Qe(G,ie,S,15,8,0)},i.deflateInit2=Qe,i.deflateReset=de,i.deflateResetKeep=Re,i.deflateSetHeader=function(G,ie){return G&&G.state?G.state.wrap!==2?b:(G.state.gzhead=ie,p):b},i.deflate=function(G,ie){var X,$,I,ce;if(!G||!G.state||5<ie||ie<0)return G?J(G,b):b;if($=G.state,!G.output||!G.input&&G.avail_in!==0||$.status===666&&ie!==m)return J(G,G.avail_out===0?-5:b);if($.strm=G,X=$.last_flush,$.last_flush=ie,$.status===L)if($.wrap===2)G.adler=0,Z($,31),Z($,139),Z($,8),$.gzhead?(Z($,($.gzhead.text?1:0)+($.gzhead.hcrc?2:0)+($.gzhead.extra?4:0)+($.gzhead.name?8:0)+($.gzhead.comment?16:0)),Z($,255&$.gzhead.time),Z($,$.gzhead.time>>8&255),Z($,$.gzhead.time>>16&255),Z($,$.gzhead.time>>24&255),Z($,$.level===9?2:2<=$.strategy||$.level<2?4:0),Z($,255&$.gzhead.os),$.gzhead.extra&&$.gzhead.extra.length&&(Z($,255&$.gzhead.extra.length),Z($,$.gzhead.extra.length>>8&255)),$.gzhead.hcrc&&(G.adler=u(G.adler,$.pending_buf,$.pending,0)),$.gzindex=0,$.status=69):(Z($,0),Z($,0),Z($,0),Z($,0),Z($,0),Z($,$.level===9?2:2<=$.strategy||$.level<2?4:0),Z($,3),$.status=q);else{var Ee=S+($.w_bits-8<<4)<<8;Ee|=(2<=$.strategy||$.level<2?0:$.level<6?1:$.level===6?2:3)<<6,$.strstart!==0&&(Ee|=32),Ee+=31-Ee%31,$.status=q,ee($,Ee),$.strstart!==0&&(ee($,G.adler>>>16),ee($,65535&G.adler)),G.adler=1}if($.status===69)if($.gzhead.extra){for(I=$.pending;$.gzindex<(65535&$.gzhead.extra.length)&&($.pending!==$.pending_buf_size||($.gzhead.hcrc&&$.pending>I&&(G.adler=u(G.adler,$.pending_buf,$.pending-I,I)),z(G),I=$.pending,$.pending!==$.pending_buf_size));)Z($,255&$.gzhead.extra[$.gzindex]),$.gzindex++;$.gzhead.hcrc&&$.pending>I&&(G.adler=u(G.adler,$.pending_buf,$.pending-I,I)),$.gzindex===$.gzhead.extra.length&&($.gzindex=0,$.status=73)}else $.status=73;if($.status===73)if($.gzhead.name){I=$.pending;do{if($.pending===$.pending_buf_size&&($.gzhead.hcrc&&$.pending>I&&(G.adler=u(G.adler,$.pending_buf,$.pending-I,I)),z(G),I=$.pending,$.pending===$.pending_buf_size)){ce=1;break}ce=$.gzindex<$.gzhead.name.length?255&$.gzhead.name.charCodeAt($.gzindex++):0,Z($,ce)}while(ce!==0);$.gzhead.hcrc&&$.pending>I&&(G.adler=u(G.adler,$.pending_buf,$.pending-I,I)),ce===0&&($.gzindex=0,$.status=91)}else $.status=91;if($.status===91)if($.gzhead.comment){I=$.pending;do{if($.pending===$.pending_buf_size&&($.gzhead.hcrc&&$.pending>I&&(G.adler=u(G.adler,$.pending_buf,$.pending-I,I)),z(G),I=$.pending,$.pending===$.pending_buf_size)){ce=1;break}ce=$.gzindex<$.gzhead.comment.length?255&$.gzhead.comment.charCodeAt($.gzindex++):0,Z($,ce)}while(ce!==0);$.gzhead.hcrc&&$.pending>I&&(G.adler=u(G.adler,$.pending_buf,$.pending-I,I)),ce===0&&($.status=103)}else $.status=103;if($.status===103&&($.gzhead.hcrc?($.pending+2>$.pending_buf_size&&z(G),$.pending+2<=$.pending_buf_size&&(Z($,255&G.adler),Z($,G.adler>>8&255),G.adler=0,$.status=q)):$.status=q),$.pending!==0){if(z(G),G.avail_out===0)return $.last_flush=-1,p}else if(G.avail_in===0&&ne(ie)<=ne(X)&&ie!==m)return J(G,-5);if($.status===666&&G.avail_in!==0)return J(G,-5);if(G.avail_in!==0||$.lookahead!==0||ie!==f&&$.status!==666){var Ie=$.strategy===2?(function(le,B){for(var O;;){if(le.lookahead===0&&(fe(le),le.lookahead===0)){if(B===f)return j;break}if(le.match_length=0,O=l._tr_tally(le,0,le.window[le.strstart]),le.lookahead--,le.strstart++,O&&(H(le,!1),le.strm.avail_out===0))return j}return le.insert=0,B===m?(H(le,!0),le.strm.avail_out===0?K:V):le.last_lit&&(H(le,!1),le.strm.avail_out===0)?j:W})($,ie):$.strategy===3?(function(le,B){for(var O,Y,pe,we,ae=le.window;;){if(le.lookahead<=R){if(fe(le),le.lookahead<=R&&B===f)return j;if(le.lookahead===0)break}if(le.match_length=0,le.lookahead>=T&&0<le.strstart&&(Y=ae[pe=le.strstart-1])===ae[++pe]&&Y===ae[++pe]&&Y===ae[++pe]){we=le.strstart+R;do;while(Y===ae[++pe]&&Y===ae[++pe]&&Y===ae[++pe]&&Y===ae[++pe]&&Y===ae[++pe]&&Y===ae[++pe]&&Y===ae[++pe]&&Y===ae[++pe]&&pe<we);le.match_length=R-(we-pe),le.match_length>le.lookahead&&(le.match_length=le.lookahead)}if(le.match_length>=T?(O=l._tr_tally(le,1,le.match_length-T),le.lookahead-=le.match_length,le.strstart+=le.match_length,le.match_length=0):(O=l._tr_tally(le,0,le.window[le.strstart]),le.lookahead--,le.strstart++),O&&(H(le,!1),le.strm.avail_out===0))return j}return le.insert=0,B===m?(H(le,!0),le.strm.avail_out===0?K:V):le.last_lit&&(H(le,!1),le.strm.avail_out===0)?j:W})($,ie):a[$.level].func($,ie);if(Ie!==K&&Ie!==V||($.status=666),Ie===j||Ie===K)return G.avail_out===0&&($.last_flush=-1),p;if(Ie===W&&(ie===1?l._tr_align($):ie!==5&&(l._tr_stored_block($,0,0,!1),ie===3&&(te($.head),$.lookahead===0&&($.strstart=0,$.block_start=0,$.insert=0))),z(G),G.avail_out===0))return $.last_flush=-1,p}return ie!==m?p:$.wrap<=0?1:($.wrap===2?(Z($,255&G.adler),Z($,G.adler>>8&255),Z($,G.adler>>16&255),Z($,G.adler>>24&255),Z($,255&G.total_in),Z($,G.total_in>>8&255),Z($,G.total_in>>16&255),Z($,G.total_in>>24&255)):(ee($,G.adler>>>16),ee($,65535&G.adler)),z(G),0<$.wrap&&($.wrap=-$.wrap),$.pending!==0?p:1)},i.deflateEnd=function(G){var ie;return G&&G.state?(ie=G.state.status)!==L&&ie!==69&&ie!==73&&ie!==91&&ie!==103&&ie!==q&&ie!==666?J(G,b):(G.state=null,ie===q?J(G,-3):p):b},i.deflateSetDictionary=function(G,ie){var X,$,I,ce,Ee,Ie,le,B,O=ie.length;if(!G||!G.state||(ce=(X=G.state).wrap)===2||ce===1&&X.status!==L||X.lookahead)return b;for(ce===1&&(G.adler=c(G.adler,ie,O,0)),X.wrap=0,O>=X.w_size&&(ce===0&&(te(X.head),X.strstart=0,X.block_start=0,X.insert=0),B=new o.Buf8(X.w_size),o.arraySet(B,ie,O-X.w_size,X.w_size,0),ie=B,O=X.w_size),Ee=G.avail_in,Ie=G.next_in,le=G.input,G.avail_in=O,G.next_in=0,G.input=ie,fe(X);X.lookahead>=T;){for($=X.strstart,I=X.lookahead-(T-1);X.ins_h=(X.ins_h<<X.hash_shift^X.window[$+T-1])&X.hash_mask,X.prev[$&X.w_mask]=X.head[X.ins_h],X.head[X.ins_h]=$,$++,--I;);X.strstart=$,X.lookahead=T-1,fe(X)}return X.strstart+=X.lookahead,X.block_start=X.strstart,X.insert=X.lookahead,X.lookahead=0,X.match_length=X.prev_length=T-1,X.match_available=0,G.next_in=Ie,G.input=le,G.avail_in=Ee,X.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,m,p,b,v,x,y,S,M,N,A,k,C,D,T,R,U,L,q,j,W;l=a.state,c=a.next_in,j=a.input,u=c+(a.avail_in-5),d=a.next_out,W=a.output,f=d-(o-a.avail_out),m=d+(a.avail_out-257),p=l.dmax,b=l.wsize,v=l.whave,x=l.wnext,y=l.window,S=l.hold,M=l.bits,N=l.lencode,A=l.distcode,k=(1<<l.lenbits)-1,C=(1<<l.distbits)-1;e:do{M<15&&(S+=j[c++]<<M,M+=8,S+=j[c++]<<M,M+=8),D=N[S&k];t:for(;;){if(S>>>=T=D>>>24,M-=T,(T=D>>>16&255)===0)W[d++]=65535&D;else{if(!(16&T)){if((64&T)==0){D=N[(65535&D)+(S&(1<<T)-1)];continue t}if(32&T){l.mode=12;break e}a.msg="invalid literal/length code",l.mode=30;break e}R=65535&D,(T&=15)&&(M<T&&(S+=j[c++]<<M,M+=8),R+=S&(1<<T)-1,S>>>=T,M-=T),M<15&&(S+=j[c++]<<M,M+=8,S+=j[c++]<<M,M+=8),D=A[S&C];n:for(;;){if(S>>>=T=D>>>24,M-=T,!(16&(T=D>>>16&255))){if((64&T)==0){D=A[(65535&D)+(S&(1<<T)-1)];continue n}a.msg="invalid distance code",l.mode=30;break e}if(U=65535&D,M<(T&=15)&&(S+=j[c++]<<M,(M+=8)<T&&(S+=j[c++]<<M,M+=8)),p<(U+=S&(1<<T)-1)){a.msg="invalid distance too far back",l.mode=30;break e}if(S>>>=T,M-=T,(T=d-f)<U){if(v<(T=U-T)&&l.sane){a.msg="invalid distance too far back",l.mode=30;break e}if(q=y,(L=0)===x){if(L+=b-T,T<R){for(R-=T;W[d++]=y[L++],--T;);L=d-U,q=W}}else if(x<T){if(L+=b+x-T,(T-=x)<R){for(R-=T;W[d++]=y[L++],--T;);if(L=0,x<R){for(R-=T=x;W[d++]=y[L++],--T;);L=d-U,q=W}}}else if(L+=x-T,T<R){for(R-=T;W[d++]=y[L++],--T;);L=d-U,q=W}for(;2<R;)W[d++]=q[L++],W[d++]=q[L++],W[d++]=q[L++],R-=3;R&&(W[d++]=q[L++],1<R&&(W[d++]=q[L++]))}else{for(L=d-U;W[d++]=W[L++],W[d++]=W[L++],W[d++]=W[L++],2<(R-=3););R&&(W[d++]=W[L++],1<R&&(W[d++]=W[L++]))}break}}break}}while(c<u&&d<m);c-=R=M>>3,S&=(1<<(M-=R<<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<m?m-d+257:257-(d-m),l.hold=S,l.bits=M}},{}],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,m=0,p=-2,b=1,v=852,x=592;function y(L){return(L>>>24&255)+(L>>>8&65280)+((65280&L)<<8)+((255&L)<<24)}function S(){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 M(L){var q;return L&&L.state?(q=L.state,L.total_in=L.total_out=q.total=0,L.msg="",q.wrap&&(L.adler=1&q.wrap),q.mode=b,q.last=0,q.havedict=0,q.dmax=32768,q.head=null,q.hold=0,q.bits=0,q.lencode=q.lendyn=new a.Buf32(v),q.distcode=q.distdyn=new a.Buf32(x),q.sane=1,q.back=-1,m):p}function N(L){var q;return L&&L.state?((q=L.state).wsize=0,q.whave=0,q.wnext=0,M(L)):p}function A(L,q){var j,W;return L&&L.state?(W=L.state,q<0?(j=0,q=-q):(j=1+(q>>4),q<48&&(q&=15)),q&&(q<8||15<q)?p:(W.window!==null&&W.wbits!==q&&(W.window=null),W.wrap=j,W.wbits=q,N(L))):p}function k(L,q){var j,W;return L?(W=new S,(L.state=W).window=null,(j=A(L,q))!==m&&(L.state=null),j):p}var C,D,T=!0;function R(L){if(T){var q;for(C=new a.Buf32(512),D=new a.Buf32(32),q=0;q<144;)L.lens[q++]=8;for(;q<256;)L.lens[q++]=9;for(;q<280;)L.lens[q++]=7;for(;q<288;)L.lens[q++]=8;for(u(d,L.lens,0,288,C,0,L.work,{bits:9}),q=0;q<32;)L.lens[q++]=5;u(f,L.lens,0,32,D,0,L.work,{bits:5}),T=!1}L.lencode=C,L.lenbits=9,L.distcode=D,L.distbits=5}function U(L,q,j,W){var K,V=L.state;return V.window===null&&(V.wsize=1<<V.wbits,V.wnext=0,V.whave=0,V.window=new a.Buf8(V.wsize)),W>=V.wsize?(a.arraySet(V.window,q,j-V.wsize,V.wsize,0),V.wnext=0,V.whave=V.wsize):(W<(K=V.wsize-V.wnext)&&(K=W),a.arraySet(V.window,q,j-W,K,V.wnext),(W-=K)?(a.arraySet(V.window,q,j-W,W,0),V.wnext=W,V.whave=V.wsize):(V.wnext+=K,V.wnext===V.wsize&&(V.wnext=0),V.whave<V.wsize&&(V.whave+=K))),0}i.inflateReset=N,i.inflateReset2=A,i.inflateResetKeep=M,i.inflateInit=function(L){return k(L,15)},i.inflateInit2=k,i.inflate=function(L,q){var j,W,K,V,J,ne,te,z,H,Z,ee,he,fe,oe,Ne,ge,Se,Re,de,Qe,G,ie,X,$,I=0,ce=new a.Buf8(4),Ee=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!L||!L.state||!L.output||!L.input&&L.avail_in!==0)return p;(j=L.state).mode===12&&(j.mode=13),J=L.next_out,K=L.output,te=L.avail_out,V=L.next_in,W=L.input,ne=L.avail_in,z=j.hold,H=j.bits,Z=ne,ee=te,ie=m;e:for(;;)switch(j.mode){case b:if(j.wrap===0){j.mode=13;break}for(;H<16;){if(ne===0)break e;ne--,z+=W[V++]<<H,H+=8}if(2&j.wrap&&z===35615){ce[j.check=0]=255&z,ce[1]=z>>>8&255,j.check=l(j.check,ce,2,0),H=z=0,j.mode=2;break}if(j.flags=0,j.head&&(j.head.done=!1),!(1&j.wrap)||(((255&z)<<8)+(z>>8))%31){L.msg="incorrect header check",j.mode=30;break}if((15&z)!=8){L.msg="unknown compression method",j.mode=30;break}if(H-=4,G=8+(15&(z>>>=4)),j.wbits===0)j.wbits=G;else if(G>j.wbits){L.msg="invalid window size",j.mode=30;break}j.dmax=1<<G,L.adler=j.check=1,j.mode=512&z?10:12,H=z=0;break;case 2:for(;H<16;){if(ne===0)break e;ne--,z+=W[V++]<<H,H+=8}if(j.flags=z,(255&j.flags)!=8){L.msg="unknown compression method",j.mode=30;break}if(57344&j.flags){L.msg="unknown header flags set",j.mode=30;break}j.head&&(j.head.text=z>>8&1),512&j.flags&&(ce[0]=255&z,ce[1]=z>>>8&255,j.check=l(j.check,ce,2,0)),H=z=0,j.mode=3;case 3:for(;H<32;){if(ne===0)break e;ne--,z+=W[V++]<<H,H+=8}j.head&&(j.head.time=z),512&j.flags&&(ce[0]=255&z,ce[1]=z>>>8&255,ce[2]=z>>>16&255,ce[3]=z>>>24&255,j.check=l(j.check,ce,4,0)),H=z=0,j.mode=4;case 4:for(;H<16;){if(ne===0)break e;ne--,z+=W[V++]<<H,H+=8}j.head&&(j.head.xflags=255&z,j.head.os=z>>8),512&j.flags&&(ce[0]=255&z,ce[1]=z>>>8&255,j.check=l(j.check,ce,2,0)),H=z=0,j.mode=5;case 5:if(1024&j.flags){for(;H<16;){if(ne===0)break e;ne--,z+=W[V++]<<H,H+=8}j.length=z,j.head&&(j.head.extra_len=z),512&j.flags&&(ce[0]=255&z,ce[1]=z>>>8&255,j.check=l(j.check,ce,2,0)),H=z=0}else j.head&&(j.head.extra=null);j.mode=6;case 6:if(1024&j.flags&&(ne<(he=j.length)&&(he=ne),he&&(j.head&&(G=j.head.extra_len-j.length,j.head.extra||(j.head.extra=new Array(j.head.extra_len)),a.arraySet(j.head.extra,W,V,he,G)),512&j.flags&&(j.check=l(j.check,W,he,V)),ne-=he,V+=he,j.length-=he),j.length))break e;j.length=0,j.mode=7;case 7:if(2048&j.flags){if(ne===0)break e;for(he=0;G=W[V+he++],j.head&&G&&j.length<65536&&(j.head.name+=String.fromCharCode(G)),G&&he<ne;);if(512&j.flags&&(j.check=l(j.check,W,he,V)),ne-=he,V+=he,G)break e}else j.head&&(j.head.name=null);j.length=0,j.mode=8;case 8:if(4096&j.flags){if(ne===0)break e;for(he=0;G=W[V+he++],j.head&&G&&j.length<65536&&(j.head.comment+=String.fromCharCode(G)),G&&he<ne;);if(512&j.flags&&(j.check=l(j.check,W,he,V)),ne-=he,V+=he,G)break e}else j.head&&(j.head.comment=null);j.mode=9;case 9:if(512&j.flags){for(;H<16;){if(ne===0)break e;ne--,z+=W[V++]<<H,H+=8}if(z!==(65535&j.check)){L.msg="header crc mismatch",j.mode=30;break}H=z=0}j.head&&(j.head.hcrc=j.flags>>9&1,j.head.done=!0),L.adler=j.check=0,j.mode=12;break;case 10:for(;H<32;){if(ne===0)break e;ne--,z+=W[V++]<<H,H+=8}L.adler=j.check=y(z),H=z=0,j.mode=11;case 11:if(j.havedict===0)return L.next_out=J,L.avail_out=te,L.next_in=V,L.avail_in=ne,j.hold=z,j.bits=H,2;L.adler=j.check=1,j.mode=12;case 12:if(q===5||q===6)break e;case 13:if(j.last){z>>>=7&H,H-=7&H,j.mode=27;break}for(;H<3;){if(ne===0)break e;ne--,z+=W[V++]<<H,H+=8}switch(j.last=1&z,H-=1,3&(z>>>=1)){case 0:j.mode=14;break;case 1:if(R(j),j.mode=20,q!==6)break;z>>>=2,H-=2;break e;case 2:j.mode=17;break;case 3:L.msg="invalid block type",j.mode=30}z>>>=2,H-=2;break;case 14:for(z>>>=7&H,H-=7&H;H<32;){if(ne===0)break e;ne--,z+=W[V++]<<H,H+=8}if((65535&z)!=(z>>>16^65535)){L.msg="invalid stored block lengths",j.mode=30;break}if(j.length=65535&z,H=z=0,j.mode=15,q===6)break e;case 15:j.mode=16;case 16:if(he=j.length){if(ne<he&&(he=ne),te<he&&(he=te),he===0)break e;a.arraySet(K,W,V,he,J),ne-=he,V+=he,te-=he,J+=he,j.length-=he;break}j.mode=12;break;case 17:for(;H<14;){if(ne===0)break e;ne--,z+=W[V++]<<H,H+=8}if(j.nlen=257+(31&z),z>>>=5,H-=5,j.ndist=1+(31&z),z>>>=5,H-=5,j.ncode=4+(15&z),z>>>=4,H-=4,286<j.nlen||30<j.ndist){L.msg="too many length or distance symbols",j.mode=30;break}j.have=0,j.mode=18;case 18:for(;j.have<j.ncode;){for(;H<3;){if(ne===0)break e;ne--,z+=W[V++]<<H,H+=8}j.lens[Ee[j.have++]]=7&z,z>>>=3,H-=3}for(;j.have<19;)j.lens[Ee[j.have++]]=0;if(j.lencode=j.lendyn,j.lenbits=7,X={bits:j.lenbits},ie=u(0,j.lens,0,19,j.lencode,0,j.work,X),j.lenbits=X.bits,ie){L.msg="invalid code lengths set",j.mode=30;break}j.have=0,j.mode=19;case 19:for(;j.have<j.nlen+j.ndist;){for(;ge=(I=j.lencode[z&(1<<j.lenbits)-1])>>>16&255,Se=65535&I,!((Ne=I>>>24)<=H);){if(ne===0)break e;ne--,z+=W[V++]<<H,H+=8}if(Se<16)z>>>=Ne,H-=Ne,j.lens[j.have++]=Se;else{if(Se===16){for($=Ne+2;H<$;){if(ne===0)break e;ne--,z+=W[V++]<<H,H+=8}if(z>>>=Ne,H-=Ne,j.have===0){L.msg="invalid bit length repeat",j.mode=30;break}G=j.lens[j.have-1],he=3+(3&z),z>>>=2,H-=2}else if(Se===17){for($=Ne+3;H<$;){if(ne===0)break e;ne--,z+=W[V++]<<H,H+=8}H-=Ne,G=0,he=3+(7&(z>>>=Ne)),z>>>=3,H-=3}else{for($=Ne+7;H<$;){if(ne===0)break e;ne--,z+=W[V++]<<H,H+=8}H-=Ne,G=0,he=11+(127&(z>>>=Ne)),z>>>=7,H-=7}if(j.have+he>j.nlen+j.ndist){L.msg="invalid bit length repeat",j.mode=30;break}for(;he--;)j.lens[j.have++]=G}}if(j.mode===30)break;if(j.lens[256]===0){L.msg="invalid code -- missing end-of-block",j.mode=30;break}if(j.lenbits=9,X={bits:j.lenbits},ie=u(d,j.lens,0,j.nlen,j.lencode,0,j.work,X),j.lenbits=X.bits,ie){L.msg="invalid literal/lengths set",j.mode=30;break}if(j.distbits=6,j.distcode=j.distdyn,X={bits:j.distbits},ie=u(f,j.lens,j.nlen,j.ndist,j.distcode,0,j.work,X),j.distbits=X.bits,ie){L.msg="invalid distances set",j.mode=30;break}if(j.mode=20,q===6)break e;case 20:j.mode=21;case 21:if(6<=ne&&258<=te){L.next_out=J,L.avail_out=te,L.next_in=V,L.avail_in=ne,j.hold=z,j.bits=H,c(L,ee),J=L.next_out,K=L.output,te=L.avail_out,V=L.next_in,W=L.input,ne=L.avail_in,z=j.hold,H=j.bits,j.mode===12&&(j.back=-1);break}for(j.back=0;ge=(I=j.lencode[z&(1<<j.lenbits)-1])>>>16&255,Se=65535&I,!((Ne=I>>>24)<=H);){if(ne===0)break e;ne--,z+=W[V++]<<H,H+=8}if(ge&&(240&ge)==0){for(Re=Ne,de=ge,Qe=Se;ge=(I=j.lencode[Qe+((z&(1<<Re+de)-1)>>Re)])>>>16&255,Se=65535&I,!(Re+(Ne=I>>>24)<=H);){if(ne===0)break e;ne--,z+=W[V++]<<H,H+=8}z>>>=Re,H-=Re,j.back+=Re}if(z>>>=Ne,H-=Ne,j.back+=Ne,j.length=Se,ge===0){j.mode=26;break}if(32&ge){j.back=-1,j.mode=12;break}if(64&ge){L.msg="invalid literal/length code",j.mode=30;break}j.extra=15&ge,j.mode=22;case 22:if(j.extra){for($=j.extra;H<$;){if(ne===0)break e;ne--,z+=W[V++]<<H,H+=8}j.length+=z&(1<<j.extra)-1,z>>>=j.extra,H-=j.extra,j.back+=j.extra}j.was=j.length,j.mode=23;case 23:for(;ge=(I=j.distcode[z&(1<<j.distbits)-1])>>>16&255,Se=65535&I,!((Ne=I>>>24)<=H);){if(ne===0)break e;ne--,z+=W[V++]<<H,H+=8}if((240&ge)==0){for(Re=Ne,de=ge,Qe=Se;ge=(I=j.distcode[Qe+((z&(1<<Re+de)-1)>>Re)])>>>16&255,Se=65535&I,!(Re+(Ne=I>>>24)<=H);){if(ne===0)break e;ne--,z+=W[V++]<<H,H+=8}z>>>=Re,H-=Re,j.back+=Re}if(z>>>=Ne,H-=Ne,j.back+=Ne,64&ge){L.msg="invalid distance code",j.mode=30;break}j.offset=Se,j.extra=15&ge,j.mode=24;case 24:if(j.extra){for($=j.extra;H<$;){if(ne===0)break e;ne--,z+=W[V++]<<H,H+=8}j.offset+=z&(1<<j.extra)-1,z>>>=j.extra,H-=j.extra,j.back+=j.extra}if(j.offset>j.dmax){L.msg="invalid distance too far back",j.mode=30;break}j.mode=25;case 25:if(te===0)break e;if(he=ee-te,j.offset>he){if((he=j.offset-he)>j.whave&&j.sane){L.msg="invalid distance too far back",j.mode=30;break}fe=he>j.wnext?(he-=j.wnext,j.wsize-he):j.wnext-he,he>j.length&&(he=j.length),oe=j.window}else oe=K,fe=J-j.offset,he=j.length;for(te<he&&(he=te),te-=he,j.length-=he;K[J++]=oe[fe++],--he;);j.length===0&&(j.mode=21);break;case 26:if(te===0)break e;K[J++]=j.length,te--,j.mode=21;break;case 27:if(j.wrap){for(;H<32;){if(ne===0)break e;ne--,z|=W[V++]<<H,H+=8}if(ee-=te,L.total_out+=ee,j.total+=ee,ee&&(L.adler=j.check=j.flags?l(j.check,K,ee,J-ee):o(j.check,K,ee,J-ee)),ee=te,(j.flags?z:y(z))!==j.check){L.msg="incorrect data check",j.mode=30;break}H=z=0}j.mode=28;case 28:if(j.wrap&&j.flags){for(;H<32;){if(ne===0)break e;ne--,z+=W[V++]<<H,H+=8}if(z!==(4294967295&j.total)){L.msg="incorrect length check",j.mode=30;break}H=z=0}j.mode=29;case 29:ie=1;break e;case 30:ie=-3;break e;case 31:return-4;default:return p}return L.next_out=J,L.avail_out=te,L.next_in=V,L.avail_in=ne,j.hold=z,j.bits=H,(j.wsize||ee!==L.avail_out&&j.mode<30&&(j.mode<27||q!==4))&&U(L,L.output,L.next_out,ee-L.avail_out)?(j.mode=31,-4):(Z-=L.avail_in,ee-=L.avail_out,L.total_in+=Z,L.total_out+=ee,j.total+=ee,j.wrap&&ee&&(L.adler=j.check=j.flags?l(j.check,K,ee,L.next_out-ee):o(j.check,K,ee,L.next_out-ee)),L.data_type=j.bits+(j.last?64:0)+(j.mode===12?128:0)+(j.mode===20||j.mode===15?256:0),(Z==0&&ee===0||q===4)&&ie===m&&(ie=-5),ie)},i.inflateEnd=function(L){if(!L||!L.state)return p;var q=L.state;return q.window&&(q.window=null),L.state=null,m},i.inflateGetHeader=function(L,q){var j;return L&&L.state?(2&(j=L.state).wrap)==0?p:((j.head=q).done=!1,m):p},i.inflateSetDictionary=function(L,q){var j,W=q.length;return L&&L.state?(j=L.state).wrap!==0&&j.mode!==11?p:j.mode===11&&o(1,q,W,0)!==j.check?-3:U(L,q,W,W)?(j.mode=31,-4):(j.havedict=1,m):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,m,p,b,v,x,y){var S,M,N,A,k,C,D,T,R,U=y.bits,L=0,q=0,j=0,W=0,K=0,V=0,J=0,ne=0,te=0,z=0,H=null,Z=0,ee=new a.Buf16(16),he=new a.Buf16(16),fe=null,oe=0;for(L=0;L<=15;L++)ee[L]=0;for(q=0;q<p;q++)ee[f[m+q]]++;for(K=U,W=15;1<=W&&ee[W]===0;W--);if(W<K&&(K=W),W===0)return b[v++]=20971520,b[v++]=20971520,y.bits=1,0;for(j=1;j<W&&ee[j]===0;j++);for(K<j&&(K=j),L=ne=1;L<=15;L++)if(ne<<=1,(ne-=ee[L])<0)return-1;if(0<ne&&(d===0||W!==1))return-1;for(he[1]=0,L=1;L<15;L++)he[L+1]=he[L]+ee[L];for(q=0;q<p;q++)f[m+q]!==0&&(x[he[f[m+q]]++]=q);if(C=d===0?(H=fe=x,19):d===1?(H=o,Z-=257,fe=l,oe-=257,256):(H=c,fe=u,-1),L=j,k=v,J=q=z=0,N=-1,A=(te=1<<(V=K))-1,d===1&&852<te||d===2&&592<te)return 1;for(;;){for(D=L-J,R=x[q]<C?(T=0,x[q]):x[q]>C?(T=fe[oe+x[q]],H[Z+x[q]]):(T=96,0),S=1<<L-J,j=M=1<<V;b[k+(z>>J)+(M-=S)]=D<<24|T<<16|R|0,M!==0;);for(S=1<<L-1;z&S;)S>>=1;if(S!==0?(z&=S-1,z+=S):z=0,q++,--ee[L]==0){if(L===W)break;L=f[m+x[q]]}if(K<L&&(z&A)!==N){for(J===0&&(J=K),k+=j,ne=1<<(V=L-J);V+J<W&&!((ne-=ee[V+J])<=0);)V++,ne<<=1;if(te+=1<<V,d===1&&852<te||d===2&&592<te)return 1;b[N=z&A]=K<<24|V<<16|k-v|0}}return z!==0&&(b[k+z]=L-J<<24|64<<16|0),y.bits=K,0}},{"../utils/common":41}],51:[function(n,r,i){r.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(n,r,i){var a=n("../utils/common"),o=0,l=1;function c(I){for(var ce=I.length;0<=--ce;)I[ce]=0}var u=0,d=29,f=256,m=f+1+d,p=30,b=19,v=2*m+1,x=15,y=16,S=7,M=256,N=16,A=17,k=18,C=[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],D=[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],T=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],R=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],U=new Array(2*(m+2));c(U);var L=new Array(2*p);c(L);var q=new Array(512);c(q);var j=new Array(256);c(j);var W=new Array(d);c(W);var K,V,J,ne=new Array(p);function te(I,ce,Ee,Ie,le){this.static_tree=I,this.extra_bits=ce,this.extra_base=Ee,this.elems=Ie,this.max_length=le,this.has_stree=I&&I.length}function z(I,ce){this.dyn_tree=I,this.max_code=0,this.stat_desc=ce}function H(I){return I<256?q[I]:q[256+(I>>>7)]}function Z(I,ce){I.pending_buf[I.pending++]=255&ce,I.pending_buf[I.pending++]=ce>>>8&255}function ee(I,ce,Ee){I.bi_valid>y-Ee?(I.bi_buf|=ce<<I.bi_valid&65535,Z(I,I.bi_buf),I.bi_buf=ce>>y-I.bi_valid,I.bi_valid+=Ee-y):(I.bi_buf|=ce<<I.bi_valid&65535,I.bi_valid+=Ee)}function he(I,ce,Ee){ee(I,Ee[2*ce],Ee[2*ce+1])}function fe(I,ce){for(var Ee=0;Ee|=1&I,I>>>=1,Ee<<=1,0<--ce;);return Ee>>>1}function oe(I,ce,Ee){var Ie,le,B=new Array(x+1),O=0;for(Ie=1;Ie<=x;Ie++)B[Ie]=O=O+Ee[Ie-1]<<1;for(le=0;le<=ce;le++){var Y=I[2*le+1];Y!==0&&(I[2*le]=fe(B[Y]++,Y))}}function Ne(I){var ce;for(ce=0;ce<m;ce++)I.dyn_ltree[2*ce]=0;for(ce=0;ce<p;ce++)I.dyn_dtree[2*ce]=0;for(ce=0;ce<b;ce++)I.bl_tree[2*ce]=0;I.dyn_ltree[2*M]=1,I.opt_len=I.static_len=0,I.last_lit=I.matches=0}function ge(I){8<I.bi_valid?Z(I,I.bi_buf):0<I.bi_valid&&(I.pending_buf[I.pending++]=I.bi_buf),I.bi_buf=0,I.bi_valid=0}function Se(I,ce,Ee,Ie){var le=2*ce,B=2*Ee;return I[le]<I[B]||I[le]===I[B]&&Ie[ce]<=Ie[Ee]}function Re(I,ce,Ee){for(var Ie=I.heap[Ee],le=Ee<<1;le<=I.heap_len&&(le<I.heap_len&&Se(ce,I.heap[le+1],I.heap[le],I.depth)&&le++,!Se(ce,Ie,I.heap[le],I.depth));)I.heap[Ee]=I.heap[le],Ee=le,le<<=1;I.heap[Ee]=Ie}function de(I,ce,Ee){var Ie,le,B,O,Y=0;if(I.last_lit!==0)for(;Ie=I.pending_buf[I.d_buf+2*Y]<<8|I.pending_buf[I.d_buf+2*Y+1],le=I.pending_buf[I.l_buf+Y],Y++,Ie===0?he(I,le,ce):(he(I,(B=j[le])+f+1,ce),(O=C[B])!==0&&ee(I,le-=W[B],O),he(I,B=H(--Ie),Ee),(O=D[B])!==0&&ee(I,Ie-=ne[B],O)),Y<I.last_lit;);he(I,M,ce)}function Qe(I,ce){var Ee,Ie,le,B=ce.dyn_tree,O=ce.stat_desc.static_tree,Y=ce.stat_desc.has_stree,pe=ce.stat_desc.elems,we=-1;for(I.heap_len=0,I.heap_max=v,Ee=0;Ee<pe;Ee++)B[2*Ee]!==0?(I.heap[++I.heap_len]=we=Ee,I.depth[Ee]=0):B[2*Ee+1]=0;for(;I.heap_len<2;)B[2*(le=I.heap[++I.heap_len]=we<2?++we:0)]=1,I.depth[le]=0,I.opt_len--,Y&&(I.static_len-=O[2*le+1]);for(ce.max_code=we,Ee=I.heap_len>>1;1<=Ee;Ee--)Re(I,B,Ee);for(le=pe;Ee=I.heap[1],I.heap[1]=I.heap[I.heap_len--],Re(I,B,1),Ie=I.heap[1],I.heap[--I.heap_max]=Ee,I.heap[--I.heap_max]=Ie,B[2*le]=B[2*Ee]+B[2*Ie],I.depth[le]=(I.depth[Ee]>=I.depth[Ie]?I.depth[Ee]:I.depth[Ie])+1,B[2*Ee+1]=B[2*Ie+1]=le,I.heap[1]=le++,Re(I,B,1),2<=I.heap_len;);I.heap[--I.heap_max]=I.heap[1],(function(ae,ke){var De,Ke,et,Ye,se,ye,Ce=ke.dyn_tree,Ue=ke.max_code,dt=ke.stat_desc.static_tree,re=ke.stat_desc.has_stree,Fe=ke.stat_desc.extra_bits,ve=ke.stat_desc.extra_base,$e=ke.stat_desc.max_length,Le=0;for(Ye=0;Ye<=x;Ye++)ae.bl_count[Ye]=0;for(Ce[2*ae.heap[ae.heap_max]+1]=0,De=ae.heap_max+1;De<v;De++)$e<(Ye=Ce[2*Ce[2*(Ke=ae.heap[De])+1]+1]+1)&&(Ye=$e,Le++),Ce[2*Ke+1]=Ye,Ue<Ke||(ae.bl_count[Ye]++,se=0,ve<=Ke&&(se=Fe[Ke-ve]),ye=Ce[2*Ke],ae.opt_len+=ye*(Ye+se),re&&(ae.static_len+=ye*(dt[2*Ke+1]+se)));if(Le!==0){do{for(Ye=$e-1;ae.bl_count[Ye]===0;)Ye--;ae.bl_count[Ye]--,ae.bl_count[Ye+1]+=2,ae.bl_count[$e]--,Le-=2}while(0<Le);for(Ye=$e;Ye!==0;Ye--)for(Ke=ae.bl_count[Ye];Ke!==0;)Ue<(et=ae.heap[--De])||(Ce[2*et+1]!==Ye&&(ae.opt_len+=(Ye-Ce[2*et+1])*Ce[2*et],Ce[2*et+1]=Ye),Ke--)}})(I,ce),oe(B,we,I.bl_count)}function G(I,ce,Ee){var Ie,le,B=-1,O=ce[1],Y=0,pe=7,we=4;for(O===0&&(pe=138,we=3),ce[2*(Ee+1)+1]=65535,Ie=0;Ie<=Ee;Ie++)le=O,O=ce[2*(Ie+1)+1],++Y<pe&&le===O||(Y<we?I.bl_tree[2*le]+=Y:le!==0?(le!==B&&I.bl_tree[2*le]++,I.bl_tree[2*N]++):Y<=10?I.bl_tree[2*A]++:I.bl_tree[2*k]++,B=le,we=(Y=0)===O?(pe=138,3):le===O?(pe=6,3):(pe=7,4))}function ie(I,ce,Ee){var Ie,le,B=-1,O=ce[1],Y=0,pe=7,we=4;for(O===0&&(pe=138,we=3),Ie=0;Ie<=Ee;Ie++)if(le=O,O=ce[2*(Ie+1)+1],!(++Y<pe&&le===O)){if(Y<we)for(;he(I,le,I.bl_tree),--Y!=0;);else le!==0?(le!==B&&(he(I,le,I.bl_tree),Y--),he(I,N,I.bl_tree),ee(I,Y-3,2)):Y<=10?(he(I,A,I.bl_tree),ee(I,Y-3,3)):(he(I,k,I.bl_tree),ee(I,Y-11,7));B=le,we=(Y=0)===O?(pe=138,3):le===O?(pe=6,3):(pe=7,4)}}c(ne);var X=!1;function $(I,ce,Ee,Ie){ee(I,(u<<1)+(Ie?1:0),3),(function(le,B,O,Y){ge(le),Z(le,O),Z(le,~O),a.arraySet(le.pending_buf,le.window,B,O,le.pending),le.pending+=O})(I,ce,Ee)}i._tr_init=function(I){X||((function(){var ce,Ee,Ie,le,B,O=new Array(x+1);for(le=Ie=0;le<d-1;le++)for(W[le]=Ie,ce=0;ce<1<<C[le];ce++)j[Ie++]=le;for(j[Ie-1]=le,le=B=0;le<16;le++)for(ne[le]=B,ce=0;ce<1<<D[le];ce++)q[B++]=le;for(B>>=7;le<p;le++)for(ne[le]=B<<7,ce=0;ce<1<<D[le]-7;ce++)q[256+B++]=le;for(Ee=0;Ee<=x;Ee++)O[Ee]=0;for(ce=0;ce<=143;)U[2*ce+1]=8,ce++,O[8]++;for(;ce<=255;)U[2*ce+1]=9,ce++,O[9]++;for(;ce<=279;)U[2*ce+1]=7,ce++,O[7]++;for(;ce<=287;)U[2*ce+1]=8,ce++,O[8]++;for(oe(U,m+1,O),ce=0;ce<p;ce++)L[2*ce+1]=5,L[2*ce]=fe(ce,5);K=new te(U,C,f+1,m,x),V=new te(L,D,0,p,x),J=new te(new Array(0),T,0,b,S)})(),X=!0),I.l_desc=new z(I.dyn_ltree,K),I.d_desc=new z(I.dyn_dtree,V),I.bl_desc=new z(I.bl_tree,J),I.bi_buf=0,I.bi_valid=0,Ne(I)},i._tr_stored_block=$,i._tr_flush_block=function(I,ce,Ee,Ie){var le,B,O=0;0<I.level?(I.strm.data_type===2&&(I.strm.data_type=(function(Y){var pe,we=4093624447;for(pe=0;pe<=31;pe++,we>>>=1)if(1&we&&Y.dyn_ltree[2*pe]!==0)return o;if(Y.dyn_ltree[18]!==0||Y.dyn_ltree[20]!==0||Y.dyn_ltree[26]!==0)return l;for(pe=32;pe<f;pe++)if(Y.dyn_ltree[2*pe]!==0)return l;return o})(I)),Qe(I,I.l_desc),Qe(I,I.d_desc),O=(function(Y){var pe;for(G(Y,Y.dyn_ltree,Y.l_desc.max_code),G(Y,Y.dyn_dtree,Y.d_desc.max_code),Qe(Y,Y.bl_desc),pe=b-1;3<=pe&&Y.bl_tree[2*R[pe]+1]===0;pe--);return Y.opt_len+=3*(pe+1)+5+5+4,pe})(I),le=I.opt_len+3+7>>>3,(B=I.static_len+3+7>>>3)<=le&&(le=B)):le=B=Ee+5,Ee+4<=le&&ce!==-1?$(I,ce,Ee,Ie):I.strategy===4||B===le?(ee(I,2+(Ie?1:0),3),de(I,U,L)):(ee(I,4+(Ie?1:0),3),(function(Y,pe,we,ae){var ke;for(ee(Y,pe-257,5),ee(Y,we-1,5),ee(Y,ae-4,4),ke=0;ke<ae;ke++)ee(Y,Y.bl_tree[2*R[ke]+1],3);ie(Y,Y.dyn_ltree,pe-1),ie(Y,Y.dyn_dtree,we-1)})(I,I.l_desc.max_code+1,I.d_desc.max_code+1,O+1),de(I,I.dyn_ltree,I.dyn_dtree)),Ne(I),Ie&&ge(I)},i._tr_tally=function(I,ce,Ee){return I.pending_buf[I.d_buf+2*I.last_lit]=ce>>>8&255,I.pending_buf[I.d_buf+2*I.last_lit+1]=255&ce,I.pending_buf[I.l_buf+I.last_lit]=255&Ee,I.last_lit++,ce===0?I.dyn_ltree[2*Ee]++:(I.matches++,ce--,I.dyn_ltree[2*(j[Ee]+f+1)]++,I.dyn_dtree[2*H(ce)]++),I.last_lit===I.lit_bufsize-1},i._tr_align=function(I){ee(I,2,3),he(I,M,U),(function(ce){ce.bi_valid===16?(Z(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)})(I)}},{"../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,m=1,p={},b=!1,v=o.document,x=Object.getPrototypeOf&&Object.getPrototypeOf(o);x=x&&x.setTimeout?x:o,c={}.toString.call(o.process)==="[object process]"?function(N){process.nextTick(function(){S(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",M,!1):o.attachEvent("onmessage",M),function(N){o.postMessage(f+N,"*")}):o.MessageChannel?((d=new MessageChannel).port1.onmessage=function(N){S(N.data)},function(N){d.port2.postMessage(N)}):v&&"onreadystatechange"in v.createElement("script")?(u=v.documentElement,function(N){var A=v.createElement("script");A.onreadystatechange=function(){S(N),A.onreadystatechange=null,u.removeChild(A),A=null},u.appendChild(A)}):function(N){setTimeout(S,0,N)},x.setImmediate=function(N){typeof N!="function"&&(N=new Function(""+N));for(var A=new Array(arguments.length-1),k=0;k<A.length;k++)A[k]=arguments[k+1];var C={callback:N,args:A};return p[m]=C,c(m),m++},x.clearImmediate=y}function y(N){delete p[N]}function S(N){if(b)setTimeout(S,0,N);else{var A=p[N];if(A){b=!0;try{(function(k){var C=k.callback,D=k.args;switch(D.length){case 0:C();break;case 1:C(D[0]);break;case 2:C(D[0],D[1]);break;case 3:C(D[0],D[1],D[2]);break;default:C.apply(l,D)}})(A)}finally{y(N),b=!1}}}}function M(N){N.source===o&&typeof N.data=="string"&&N.data.indexOf(f)===0&&S(+N.data.slice(f.length))}})(typeof self>"u"?a===void 0?this:a:self)}).call(this,typeof c_<"u"?c_:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(Nk)),Nk.exports}var DIe=RIe();const OIe=ml(DIe);function LIe(t){const e=new mi;if(!t)return e;const n=t.trim().split(/\s+/).map(parseFloat);return n.length>=12&&e.set(n[0],n[1],n[2],n[9],n[3],n[4],n[5],n[10],n[6],n[7],n[8],n[11],0,0,0,1),e}const MG=LIe;async function EG(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 IIe(t){const e=await OIe.loadAsync(t),n=new Map,r=[],i=new DOMParser;async function a(p){const b=p.startsWith("/")?p.slice(1):p,v=e.files[b];if(!v)return null;const x=await v.async("string");return i.parseFromString(x,"application/xml")}const o=new Map,l=new Map,c=e.files["Metadata/model_settings.config"];if(c)try{const p=await c.async("string"),v=i.parseFromString(p,"application/xml").getElementsByTagName("object");for(let x=0;x<v.length;x++){const y=v[x],S=y.getAttribute("id");if(!S)continue;const M=Array.from(y.children).filter(A=>A.tagName==="metadata"&&A.getAttribute("key")==="extruder");if(M.length>0){const A=M[0].getAttribute("value");A&&o.set(S,Math.max(0,parseInt(A,10)-1))}const N=y.getElementsByTagName("part");for(let A=0;A<N.length;A++){const k=N[A],C=k.getAttribute("id");if(!C)continue;const D=Array.from(k.children).filter(T=>T.tagName==="metadata"&&T.getAttribute("key")==="extruder");if(D.length>0){const T=D[0].getAttribute("value");T&&l.set(`${S}:${C}`,Math.max(0,parseInt(T,10)-1))}}}}catch{}const u=Object.keys(e.files).find(p=>p==="3D/3dmodel.model"||p.endsWith("/3dmodel.model"));if(!u){const p=Object.keys(e.files).find(b=>b.endsWith(".model"));if(p){const b=await a(p);if(b){const v=await EG(b,0);v.length>0&&n.set("1",{id:"1",meshes:v,defaultExtruder:0})}}return{objects:n,buildItems:r}}const d=await a(u);if(!d)return{objects:n,buildItems:r};const f=d.getElementsByTagName("object");for(let p=0;p<f.length;p++){const b=f[p],v=b.getAttribute("id");if(!v)continue;let x=o.get(v)??-1;if(x<0){const N=b.getAttribute("p:extruder")||b.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","extruder")||"1";x=Math.max(0,parseInt(N,10)-1)}const y=[],S=b.getElementsByTagName("mesh");for(let N=0;N<S.length;N++){const A=S[N],k=[],C=[],D=A.getElementsByTagName("vertex");for(let R=0;R<D.length;R++){const U=D[R];k.push(parseFloat(U.getAttribute("x")||"0"),parseFloat(U.getAttribute("y")||"0"),parseFloat(U.getAttribute("z")||"0"))}const T=A.getElementsByTagName("triangle");for(let R=0;R<T.length;R++){const U=T[R];C.push(parseInt(U.getAttribute("v1")||"0"),parseInt(U.getAttribute("v2")||"0"),parseInt(U.getAttribute("v3")||"0"))}k.length>0&&C.length>0&&y.push({vertices:k,triangles:C,extruder:x})}const M=b.getElementsByTagName("component");for(let N=0;N<M.length;N++){const A=M[N],k=A.getAttribute("p:path")||A.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","path"),C=A.getAttribute("objectid");if(k){const D=await a(k);if(D){const T=C?`${v}:${C}`:null,R=T?l.get(T)??x:x,U=await EG(D,R),L=A.getAttribute("transform"),q=MG(L);for(const j of U)if(L){const W=[];for(let K=0;K<j.vertices.length;K+=3){const V=new nt(j.vertices[K],j.vertices[K+1],j.vertices[K+2]);V.applyMatrix4(q),W.push(V.x,V.y,V.z)}y.push({vertices:W,triangles:j.triangles,extruder:j.extruder})}else y.push(j)}}}y.length>0&&n.set(v,{id:v,meshes:y,defaultExtruder:x})}const m=d.getElementsByTagName("build");if(m.length>0){const p=m[0].getElementsByTagName("item");for(let b=0;b<p.length;b++){const v=p[b],x=v.getAttribute("objectid");if(!x)continue;const y=MG(v.getAttribute("transform"));r.push({objectId:x,transform:y})}}return{objects:n,buildItems:r}}function NG(t){const e=new yl,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 Co(n,3)),e.setIndex(t.triangles),e.computeVertexNormals(),e}function FIe({url:t,buildVolume:e={x:256,y:256,z:256},filamentColors:n,className:r=""}){const i=w.useRef(null),a=w.useRef(null),o=w.useRef(null),l=w.useRef(null),c=w.useRef(null),[u,d]=w.useState(!0),[f,m]=w.useState(null);w.useEffect(()=>{if(!i.current)return;const v=i.current,x=v.clientWidth,y=v.clientHeight,S=new iRe;S.background=new Rn(1710618),o.current=S;const M=new So(45,x/y,.1,1e4);M.position.set(150,150,150),l.current=M;const N=new xIe({antialias:!0});N.setSize(x,y),N.setPixelRatio(window.devicePixelRatio),v.appendChild(N.domElement),a.current=N;const A=new yIe(M,N.domElement);A.enableDamping=!0,A.dampingFactor=.05,c.current=A;const k=new bRe(16777215,.6);S.add(k);const C=new KV(16777215,.8);C.position.set(100,100,100),S.add(C);const D=new KV(16777215,.4);D.position.set(-100,50,-100),S.add(D);const T=Math.max(e.x,e.y),R=Math.ceil(T/16),U=new vRe(T,R,4473924,3355443);S.add(U);const L=new cL(e.x,e.y),q=new sL({color:44610,transparent:!0,opacity:.15,side:Il}),j=new hl(L,q);j.rotation.x=-Math.PI/2,j.position.y=-.5,S.add(j);let W;const K=()=>{W=requestAnimationFrame(K),A.update(),N.render(S,M)};K(),fetch(t).then(J=>{if(!J.ok)throw new Error("Failed to load file");return J.arrayBuffer()}).then(IIe).then(({objects:J,buildItems:ne})=>{if(J.size===0)throw new Error("No meshes found in 3MF file");const te=Se=>{const de=n?.[Se]||"#00ae42",Qe=new Rn(de);return new fRe({color:Qe,shininess:30,flatShading:!1})},z=new $b,H=new Map;if(ne.length>0)for(const Se of ne){const Re=J.get(Se.objectId);if(Re)for(const de of Re.meshes){const Qe=Se.extruder??de.extruder,G=[];for(let X=0;X<de.vertices.length;X+=3){const $=new nt(de.vertices[X],de.vertices[X+1],de.vertices[X+2]);$.applyMatrix4(Se.transform),G.push($.x,$.y,$.z)}const ie=NG({vertices:G,triangles:de.triangles});H.has(Qe)||H.set(Qe,[]),H.get(Qe).push(ie)}}else for(const Se of J.values())for(const Re of Se.meshes){const de=Re.extruder,Qe=NG(Re);H.has(de)||H.set(de,[]),H.get(de).push(Qe)}for(const[Se,Re]of H){if(Re.length===0)continue;const de=Re.length===1?Re[0]:PIe(Re,!1);if(de){const Qe=te(Se),G=new hl(de,Qe);z.add(G)}if(Re.length>1)for(const Qe of Re)Qe.dispose()}const Z=new Jf().setFromObject(z),ee=Z.getCenter(new nt);z.position.y=-Z.min.y,ne.length===0&&(z.position.x=-ee.x,z.position.z=-ee.z),S.add(z);const he=new Jf().setFromObject(z),fe=he.getCenter(new nt),oe=he.getSize(new nt),ge=Math.max(oe.x,oe.y,oe.z)*1.8;M.position.set(fe.x+ge*.7,fe.y+ge*.5,fe.z+ge*.7),A.target.copy(fe),A.update(),d(!1)}).catch(J=>{m(J.message),d(!1)});const V=()=>{if(!v)return;const J=v.clientWidth,ne=v.clientHeight;M.aspect=J/ne,M.updateProjectionMatrix(),N.setSize(J,ne)};return window.addEventListener("resize",V),()=>{window.removeEventListener("resize",V),cancelAnimationFrame(W),A.dispose(),N.dispose(),v.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())},b=v=>{l.current&&l.current.position.multiplyScalar(v)};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(mt,{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(Me,{variant:"secondary",size:"sm",onClick:()=>b(.8),children:s.jsx(HD,{className:"w-4 h-4"})}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>b(1.25),children:s.jsx(VD,{className:"w-4 h-4"})}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:p,children:s.jsx(lm,{className:"w-4 h-4"})})]})]})}const hN="159",fp={ROTATE:0,DOLLY:1,PAN:2},mp={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},UIe=0,AG=1,zIe=2,Oee=1,BIe=2,Hc=3,th=0,ws=1,Xc=2,Bd=0,sg=1,TG=2,CG=3,kG=4,$Ie=5,tf=100,HIe=101,VIe=102,jG=103,PG=104,GIe=200,WIe=201,qIe=202,KIe=203,vR=204,_R=205,XIe=206,YIe=207,ZIe=208,QIe=209,JIe=210,eFe=211,tFe=212,nFe=213,rFe=214,iFe=0,aFe=1,sFe=2,VS=3,oFe=4,lFe=5,cFe=6,uFe=7,hL=0,dFe=1,hFe=2,$d=0,fFe=1,mFe=2,pFe=3,gFe=4,xFe=5,Lee=300,jg=301,Pg=302,wR=303,SR=304,fN=306,MR=1e3,Qo=1001,ER=1002,ba=1003,RG=1004,Ak=1005,Mo=1006,bFe=1007,Y0=1008,Hd=1009,yFe=1010,vFe=1011,fL=1012,Iee=1013,kd=1014,eu=1015,Z0=1016,Fee=1017,Uee=1018,Nf=1020,_Fe=1021,Eo=1023,wFe=1024,SFe=1025,Af=1026,Rg=1027,MFe=1028,zee=1029,EFe=1030,Bee=1031,$ee=1033,Tk=33776,Ck=33777,kk=33778,jk=33779,DG=35840,OG=35841,LG=35842,IG=35843,Hee=36196,FG=37492,UG=37496,zG=37808,BG=37809,$G=37810,HG=37811,VG=37812,GG=37813,WG=37814,qG=37815,KG=37816,XG=37817,YG=37818,ZG=37819,QG=37820,JG=37821,Pk=36492,e7=36494,t7=36495,NFe=36283,n7=36284,r7=36285,i7=36286,Vee=3e3,Tf=3001,AFe=3200,TFe=3201,Gee=0,CFe=1,No="",ya="srgb",_u="srgb-linear",mL="display-p3",mN="display-p3-linear",GS="linear",Dr="srgb",WS="rec709",qS="p3",pp=7680,a7=519,kFe=512,jFe=513,PFe=514,Wee=515,RFe=516,DFe=517,OFe=518,LFe=519,NR=35044,s7="300 es",AR=1035,Vl=2e3,Q0=2001;class hm{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 Pa=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let o7=1234567;const r0=Math.PI/180,J0=180/Math.PI;function ou(){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 va(t,e,n){return Math.max(e,Math.min(n,t))}function pL(t,e){return(t%e+e)%e}function IFe(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)}function FFe(t,e,n){return t!==e?(n-t)/(e-t):0}function i0(t,e,n){return(1-n)*t+n*e}function UFe(t,e,n,r){return i0(t,e,1-Math.exp(-n*r))}function zFe(t,e=1){return e-Math.abs(pL(t,e*2)-e)}function BFe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*(3-2*t))}function $Fe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*t*(t*(t*6-15)+10))}function HFe(t,e){return t+Math.floor(Math.random()*(e-t+1))}function VFe(t,e){return t+Math.random()*(e-t)}function GFe(t){return t*(.5-Math.random())}function WFe(t){t!==void 0&&(o7=t);let e=o7+=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 qFe(t){return t*r0}function KFe(t){return t*J0}function TR(t){return(t&t-1)===0&&t!==0}function XFe(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function KS(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function YFe(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),m=o((e-r)/2),p=a((r-e)/2),b=o((r-e)/2);switch(i){case"XYX":t.set(l*d,c*f,c*m,l*u);break;case"YZY":t.set(c*m,l*d,c*f,l*u);break;case"ZXZ":t.set(c*f,c*m,l*d,l*u);break;case"XZX":t.set(l*d,c*b,c*p,l*u);break;case"YXY":t.set(c*p,l*d,c*b,l*u);break;case"ZYZ":t.set(c*b,c*p,l*d,l*u);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Fl(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 mr(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 qee={DEG2RAD:r0,RAD2DEG:J0,generateUUID:ou,clamp:va,euclideanModulo:pL,mapLinear:IFe,inverseLerp:FFe,lerp:i0,damp:UFe,pingpong:zFe,smoothstep:BFe,smootherstep:$Fe,randInt:HFe,randFloat:VFe,randFloatSpread:GFe,seededRandom:WFe,degToRad:qFe,radToDeg:KFe,isPowerOfTwo:TR,ceilPowerOfTwo:XFe,floorPowerOfTwo:KS,setQuaternionFromProperEuler:YFe,normalize:mr,denormalize:Fl};class mn{constructor(e=0,n=0){mn.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(va(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 An{constructor(e,n,r,i,a,o,l,c,u){An.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],m=r[2],p=r[5],b=r[8],v=i[0],x=i[3],y=i[6],S=i[1],M=i[4],N=i[7],A=i[2],k=i[5],C=i[8];return a[0]=o*v+l*S+c*A,a[3]=o*x+l*M+c*k,a[6]=o*y+l*N+c*C,a[1]=u*v+d*S+f*A,a[4]=u*x+d*M+f*k,a[7]=u*y+d*N+f*C,a[2]=m*v+p*S+b*A,a[5]=m*x+p*M+b*k,a[8]=m*y+p*N+b*C,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,m=l*c-d*a,p=u*a-o*c,b=n*f+r*m+i*p;if(b===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/b;return e[0]=f*v,e[1]=(i*u-d*r)*v,e[2]=(l*r-i*o)*v,e[3]=m*v,e[4]=(d*n-i*c)*v,e[5]=(i*a-l*n)*v,e[6]=p*v,e[7]=(r*c-u*n)*v,e[8]=(o*n-r*a)*v,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,i,a,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(Rk.makeScale(e,n)),this}rotate(e){return this.premultiply(Rk.makeRotation(-e)),this}translate(e,n){return this.premultiply(Rk.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 Rk=new An;function Kee(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function XS(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function ZFe(){const t=XS("canvas");return t.style.display="block",t}const l7={};function a0(t){t in l7||(l7[t]=!0,console.warn(t))}const c7=new An().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),u7=new An().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),t1={[_u]:{transfer:GS,primaries:WS,toReference:t=>t,fromReference:t=>t},[ya]:{transfer:Dr,primaries:WS,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[mN]:{transfer:GS,primaries:qS,toReference:t=>t.applyMatrix3(u7),fromReference:t=>t.applyMatrix3(c7)},[mL]:{transfer:Dr,primaries:qS,toReference:t=>t.convertSRGBToLinear().applyMatrix3(u7),fromReference:t=>t.applyMatrix3(c7).convertLinearToSRGB()}},QFe=new Set([_u,mN]),pr={enabled:!0,_workingColorSpace:_u,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(!QFe.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=t1[e].toReference,i=t1[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 t1[t].primaries},getTransfer:function(t){return t===No?GS:t1[t].transfer}};function og(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function Dk(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let gp;class Xee{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{gp===void 0&&(gp=XS("canvas")),gp.width=e.width,gp.height=e.height;const r=gp.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=gp}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=XS("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]=og(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(og(n[r]/255)*255):n[r]=og(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 JFe=0;class Yee{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:JFe++}),this.uuid=ou(),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(Ok(i[o].image)):a.push(Ok(i[o]))}else a=Ok(i);r.url=a}return n||(e.images[this.uuid]=r),r}}function Ok(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?Xee.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 e5e=0;class Ss extends hm{constructor(e=Ss.DEFAULT_IMAGE,n=Ss.DEFAULT_MAPPING,r=Qo,i=Qo,a=Mo,o=Y0,l=Eo,c=Hd,u=Ss.DEFAULT_ANISOTROPY,d=No){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:e5e++}),this.uuid=ou(),this.name="",this.source=new Yee(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 mn(0,0),this.repeat=new mn(1,1),this.center=new mn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new An,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,typeof d=="string"?this.colorSpace=d:(a0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=d===Tf?ya:No),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!==Lee)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case MR:e.x=e.x-Math.floor(e.x);break;case Qo:e.x=e.x<0?0:1;break;case ER: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 MR:e.y=e.y-Math.floor(e.y);break;case Qo:e.y=e.y<0?0:1;break;case ER: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 a0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===ya?Tf:Vee}set encoding(e){a0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===Tf?ya:No}}Ss.DEFAULT_IMAGE=null;Ss.DEFAULT_MAPPING=Lee;Ss.DEFAULT_ANISOTROPY=1;class xr{constructor(e=0,n=0,r=0,i=1){xr.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],m=c[1],p=c[5],b=c[9],v=c[2],x=c[6],y=c[10];if(Math.abs(d-m)<.01&&Math.abs(f-v)<.01&&Math.abs(b-x)<.01){if(Math.abs(d+m)<.1&&Math.abs(f+v)<.1&&Math.abs(b+x)<.1&&Math.abs(u+p+y-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const M=(u+1)/2,N=(p+1)/2,A=(y+1)/2,k=(d+m)/4,C=(f+v)/4,D=(b+x)/4;return M>N&&M>A?M<.01?(r=0,i=.707106781,a=.707106781):(r=Math.sqrt(M),i=k/r,a=C/r):N>A?N<.01?(r=.707106781,i=0,a=.707106781):(i=Math.sqrt(N),r=k/i,a=D/i):A<.01?(r=.707106781,i=.707106781,a=0):(a=Math.sqrt(A),r=C/a,i=D/a),this.set(r,i,a,n),this}let S=Math.sqrt((x-b)*(x-b)+(f-v)*(f-v)+(m-d)*(m-d));return Math.abs(S)<.001&&(S=1),this.x=(x-b)/S,this.y=(f-v)/S,this.z=(m-d)/S,this.w=Math.acos((u+p+y-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this.w=Math.max(e.w,Math.min(n.w,this.w)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this.w=Math.max(e,Math.min(n,this.w)),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this.w+=(e.w-this.w)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this.w=e.w+(n.w-e.w)*r,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this.w=e[n+3],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e[n+3]=this.w,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this.w=e.getW(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class t5e extends hm{constructor(e=1,n=1,r={}){super(),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=1,this.scissor=new xr(0,0,e,n),this.scissorTest=!1,this.viewport=new xr(0,0,e,n);const i={width:e,height:n,depth:1};r.encoding!==void 0&&(a0("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),r.colorSpace=r.encoding===Tf?ya:No),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Mo,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},r),this.texture=new Ss(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 Yee(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 em extends t5e{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}}class Zee extends Ss{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=ba,this.minFilter=ba,this.wrapR=Qo,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class n5e extends Ss{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=ba,this.minFilter=ba,this.wrapR=Qo,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class tm{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 m=a[o+0],p=a[o+1],b=a[o+2],v=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]=m,e[n+1]=p,e[n+2]=b,e[n+3]=v;return}if(f!==v||c!==m||u!==p||d!==b){let x=1-l;const y=c*m+u*p+d*b+f*v,S=y>=0?1:-1,M=1-y*y;if(M>Number.EPSILON){const A=Math.sqrt(M),k=Math.atan2(A,y*S);x=Math.sin(x*k)/A,l=Math.sin(l*k)/A}const N=l*S;if(c=c*x+m*N,u=u*x+p*N,d=d*x+b*N,f=f*x+v*N,x===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],m=a[o+1],p=a[o+2],b=a[o+3];return e[n]=l*b+d*f+c*p-u*m,e[n+1]=c*b+d*m+u*f-l*p,e[n+2]=u*b+d*p+l*m-c*f,e[n+3]=d*b-l*f-c*m-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),m=c(r/2),p=c(i/2),b=c(a/2);switch(o){case"XYZ":this._x=m*d*f+u*p*b,this._y=u*p*f-m*d*b,this._z=u*d*b+m*p*f,this._w=u*d*f-m*p*b;break;case"YXZ":this._x=m*d*f+u*p*b,this._y=u*p*f-m*d*b,this._z=u*d*b-m*p*f,this._w=u*d*f+m*p*b;break;case"ZXY":this._x=m*d*f-u*p*b,this._y=u*p*f+m*d*b,this._z=u*d*b+m*p*f,this._w=u*d*f-m*p*b;break;case"ZYX":this._x=m*d*f-u*p*b,this._y=u*p*f+m*d*b,this._z=u*d*b-m*p*f,this._w=u*d*f+m*p*b;break;case"YZX":this._x=m*d*f+u*p*b,this._y=u*p*f+m*d*b,this._z=u*d*b-m*p*f,this._w=u*d*f-m*p*b;break;case"XZY":this._x=m*d*f-u*p*b,this._y=u*p*f-m*d*b,this._z=u*d*b+m*p*f,this._w=u*d*f+m*p*b;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],m=r+l+f;if(m>0){const p=.5/Math.sqrt(m+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(va(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,m=Math.sin(n*d)/u;return this._w=o*f+this._w*m,this._x=r*f+this._x*m,this._y=i*f+this._y*m,this._z=a*f+this._z*m,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 Be{constructor(e=0,n=0,r=0){Be.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(d7.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(d7.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 Lk.copy(this).projectOnVector(e),this.sub(Lk)}reflect(e){return this.sub(Lk.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(va(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 Lk=new Be,d7=new tm;class ko{constructor(e=new Be(1/0,1/0,1/0),n=new Be(-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(Go.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(Go.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=Go.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,Go):Go.fromBufferAttribute(a,o),Go.applyMatrix4(e.matrixWorld),this.expandByPoint(Go);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),n1.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),n1.copy(r.boundingBox)),n1.applyMatrix4(e.matrixWorld),this.union(n1)}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,Go),Go.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(Eb),r1.subVectors(this.max,Eb),xp.subVectors(e.a,Eb),bp.subVectors(e.b,Eb),yp.subVectors(e.c,Eb),ad.subVectors(bp,xp),sd.subVectors(yp,bp),$h.subVectors(xp,yp);let n=[0,-ad.z,ad.y,0,-sd.z,sd.y,0,-$h.z,$h.y,ad.z,0,-ad.x,sd.z,0,-sd.x,$h.z,0,-$h.x,-ad.y,ad.x,0,-sd.y,sd.x,0,-$h.y,$h.x,0];return!Ik(n,xp,bp,yp,r1)||(n=[1,0,0,0,1,0,0,0,1],!Ik(n,xp,bp,yp,r1))?!1:(i1.crossVectors(ad,sd),n=[i1.x,i1.y,i1.z],Ik(n,xp,bp,yp,r1))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Go).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Go).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Oc[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Oc[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Oc[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Oc[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Oc[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Oc[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Oc[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Oc[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Oc),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const Oc=[new Be,new Be,new Be,new Be,new Be,new Be,new Be,new Be],Go=new Be,n1=new ko,xp=new Be,bp=new Be,yp=new Be,ad=new Be,sd=new Be,$h=new Be,Eb=new Be,r1=new Be,i1=new Be,Hh=new Be;function Ik(t,e,n,r,i){for(let a=0,o=t.length-3;a<=o;a+=3){Hh.fromArray(t,a);const l=i.x*Math.abs(Hh.x)+i.y*Math.abs(Hh.y)+i.z*Math.abs(Hh.z),c=e.dot(Hh),u=n.dot(Hh),d=r.dot(Hh);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>l)return!1}return!0}const r5e=new ko,Nb=new Be,Fk=new Be;class Xl{constructor(e=new Be,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):r5e.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;Nb.subVectors(e,this.center);const n=Nb.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(Nb,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):(Fk.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Nb.copy(e.center).add(Fk)),this.expandByPoint(Nb.copy(e.center).sub(Fk))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Lc=new Be,Uk=new Be,a1=new Be,od=new Be,zk=new Be,s1=new Be,Bk=new Be;class gL{constructor(e=new Be,n=new Be(0,0,-1)){this.origin=e,this.direction=n}set(e,n){return this.origin.copy(e),this.direction.copy(n),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,n){return n.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Lc)),this}closestPointToPoint(e,n){n.subVectors(e,this.origin);const r=n.dot(this.direction);return r<0?n.copy(this.origin):n.copy(this.origin).addScaledVector(this.direction,r)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const n=Lc.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(Lc.copy(this.origin).addScaledVector(this.direction,n),Lc.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){Uk.copy(e).add(n).multiplyScalar(.5),a1.copy(n).sub(e).normalize(),od.copy(this.origin).sub(Uk);const a=e.distanceTo(n)*.5,o=-this.direction.dot(a1),l=od.dot(this.direction),c=-od.dot(a1),u=od.lengthSq(),d=Math.abs(1-o*o);let f,m,p,b;if(d>0)if(f=o*c-l,m=o*l-c,b=a*d,f>=0)if(m>=-b)if(m<=b){const v=1/d;f*=v,m*=v,p=f*(f+o*m+2*l)+m*(o*f+m+2*c)+u}else m=a,f=Math.max(0,-(o*m+l)),p=-f*f+m*(m+2*c)+u;else m=-a,f=Math.max(0,-(o*m+l)),p=-f*f+m*(m+2*c)+u;else m<=-b?(f=Math.max(0,-(-o*a+l)),m=f>0?-a:Math.min(Math.max(-a,-c),a),p=-f*f+m*(m+2*c)+u):m<=b?(f=0,m=Math.min(Math.max(-a,-c),a),p=m*(m+2*c)+u):(f=Math.max(0,-(o*a+l)),m=f>0?a:Math.min(Math.max(-a,-c),a),p=-f*f+m*(m+2*c)+u);else m=o>0?-a:a,f=Math.max(0,-(o*m+l)),p=-f*f+m*(m+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(Uk).addScaledVector(a1,m),p}intersectSphere(e,n){Lc.subVectors(e.center,this.origin);const r=Lc.dot(this.direction),i=Lc.dot(Lc)-r*r,a=e.radius*e.radius;if(i>a)return null;const 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,m=this.origin;return u>=0?(r=(e.min.x-m.x)*u,i=(e.max.x-m.x)*u):(r=(e.max.x-m.x)*u,i=(e.min.x-m.x)*u),d>=0?(a=(e.min.y-m.y)*d,o=(e.max.y-m.y)*d):(a=(e.max.y-m.y)*d,o=(e.min.y-m.y)*d),r>o||a>i||((a>r||isNaN(r))&&(r=a),(o<i||isNaN(i))&&(i=o),f>=0?(l=(e.min.z-m.z)*f,c=(e.max.z-m.z)*f):(l=(e.max.z-m.z)*f,c=(e.min.z-m.z)*f),r>c||l>i)||((l>r||r!==r)&&(r=l),(c<i||i!==i)&&(i=c),i<0)?null:this.at(r>=0?r:i,n)}intersectsBox(e){return this.intersectBox(e,Lc)!==null}intersectTriangle(e,n,r,i,a){zk.subVectors(n,e),s1.subVectors(r,e),Bk.crossVectors(zk,s1);let o=this.direction.dot(Bk),l;if(o>0){if(i)return null;l=1}else if(o<0)l=-1,o=-o;else return null;od.subVectors(this.origin,e);const c=l*this.direction.dot(s1.crossVectors(od,s1));if(c<0)return null;const u=l*this.direction.dot(zk.cross(od));if(u<0||c+u>o)return null;const d=-l*od.dot(Bk);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 Tr{constructor(e,n,r,i,a,o,l,c,u,d,f,m,p,b,v,x){Tr.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,m,p,b,v,x)}set(e,n,r,i,a,o,l,c,u,d,f,m,p,b,v,x){const y=this.elements;return y[0]=e,y[4]=n,y[8]=r,y[12]=i,y[1]=a,y[5]=o,y[9]=l,y[13]=c,y[2]=u,y[6]=d,y[10]=f,y[14]=m,y[3]=p,y[7]=b,y[11]=v,y[15]=x,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Tr().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/vp.setFromMatrixColumn(e,0).length(),a=1/vp.setFromMatrixColumn(e,1).length(),o=1/vp.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 m=o*d,p=o*f,b=l*d,v=l*f;n[0]=c*d,n[4]=-c*f,n[8]=u,n[1]=p+b*u,n[5]=m-v*u,n[9]=-l*c,n[2]=v-m*u,n[6]=b+p*u,n[10]=o*c}else if(e.order==="YXZ"){const m=c*d,p=c*f,b=u*d,v=u*f;n[0]=m+v*l,n[4]=b*l-p,n[8]=o*u,n[1]=o*f,n[5]=o*d,n[9]=-l,n[2]=p*l-b,n[6]=v+m*l,n[10]=o*c}else if(e.order==="ZXY"){const m=c*d,p=c*f,b=u*d,v=u*f;n[0]=m-v*l,n[4]=-o*f,n[8]=b+p*l,n[1]=p+b*l,n[5]=o*d,n[9]=v-m*l,n[2]=-o*u,n[6]=l,n[10]=o*c}else if(e.order==="ZYX"){const m=o*d,p=o*f,b=l*d,v=l*f;n[0]=c*d,n[4]=b*u-p,n[8]=m*u+v,n[1]=c*f,n[5]=v*u+m,n[9]=p*u-b,n[2]=-u,n[6]=l*c,n[10]=o*c}else if(e.order==="YZX"){const m=o*c,p=o*u,b=l*c,v=l*u;n[0]=c*d,n[4]=v-m*f,n[8]=b*f+p,n[1]=f,n[5]=o*d,n[9]=-l*d,n[2]=-u*d,n[6]=p*f+b,n[10]=m-v*f}else if(e.order==="XZY"){const m=o*c,p=o*u,b=l*c,v=l*u;n[0]=c*d,n[4]=-f,n[8]=u*d,n[1]=m*f+v,n[5]=o*d,n[9]=p*f-b,n[2]=b*f-p,n[6]=l*d,n[10]=v*f+m}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(i5e,e,a5e)}lookAt(e,n,r){const i=this.elements;return Fs.subVectors(e,n),Fs.lengthSq()===0&&(Fs.z=1),Fs.normalize(),ld.crossVectors(r,Fs),ld.lengthSq()===0&&(Math.abs(r.z)===1?Fs.x+=1e-4:Fs.z+=1e-4,Fs.normalize(),ld.crossVectors(r,Fs)),ld.normalize(),o1.crossVectors(Fs,ld),i[0]=ld.x,i[4]=o1.x,i[8]=Fs.x,i[1]=ld.y,i[5]=o1.y,i[9]=Fs.y,i[2]=ld.z,i[6]=o1.z,i[10]=Fs.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],m=r[9],p=r[13],b=r[2],v=r[6],x=r[10],y=r[14],S=r[3],M=r[7],N=r[11],A=r[15],k=i[0],C=i[4],D=i[8],T=i[12],R=i[1],U=i[5],L=i[9],q=i[13],j=i[2],W=i[6],K=i[10],V=i[14],J=i[3],ne=i[7],te=i[11],z=i[15];return a[0]=o*k+l*R+c*j+u*J,a[4]=o*C+l*U+c*W+u*ne,a[8]=o*D+l*L+c*K+u*te,a[12]=o*T+l*q+c*V+u*z,a[1]=d*k+f*R+m*j+p*J,a[5]=d*C+f*U+m*W+p*ne,a[9]=d*D+f*L+m*K+p*te,a[13]=d*T+f*q+m*V+p*z,a[2]=b*k+v*R+x*j+y*J,a[6]=b*C+v*U+x*W+y*ne,a[10]=b*D+v*L+x*K+y*te,a[14]=b*T+v*q+x*V+y*z,a[3]=S*k+M*R+N*j+A*J,a[7]=S*C+M*U+N*W+A*ne,a[11]=S*D+M*L+N*K+A*te,a[15]=S*T+M*q+N*V+A*z,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[4],i=e[8],a=e[12],o=e[1],l=e[5],c=e[9],u=e[13],d=e[2],f=e[6],m=e[10],p=e[14],b=e[3],v=e[7],x=e[11],y=e[15];return b*(+a*c*f-i*u*f-a*l*m+r*u*m+i*l*p-r*c*p)+v*(+n*c*p-n*u*m+a*o*m-i*o*p+i*u*d-a*c*d)+x*(+n*u*f-n*l*p-a*o*f+r*o*p+a*l*d-r*u*d)+y*(-i*l*d-n*c*f+n*l*m+i*o*f-r*o*m+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],m=e[10],p=e[11],b=e[12],v=e[13],x=e[14],y=e[15],S=f*x*u-v*m*u+v*c*p-l*x*p-f*c*y+l*m*y,M=b*m*u-d*x*u-b*c*p+o*x*p+d*c*y-o*m*y,N=d*v*u-b*f*u+b*l*p-o*v*p-d*l*y+o*f*y,A=b*f*c-d*v*c-b*l*m+o*v*m+d*l*x-o*f*x,k=n*S+r*M+i*N+a*A;if(k===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const C=1/k;return e[0]=S*C,e[1]=(v*m*a-f*x*a-v*i*p+r*x*p+f*i*y-r*m*y)*C,e[2]=(l*x*a-v*c*a+v*i*u-r*x*u-l*i*y+r*c*y)*C,e[3]=(f*c*a-l*m*a-f*i*u+r*m*u+l*i*p-r*c*p)*C,e[4]=M*C,e[5]=(d*x*a-b*m*a+b*i*p-n*x*p-d*i*y+n*m*y)*C,e[6]=(b*c*a-o*x*a-b*i*u+n*x*u+o*i*y-n*c*y)*C,e[7]=(o*m*a-d*c*a+d*i*u-n*m*u-o*i*p+n*c*p)*C,e[8]=N*C,e[9]=(b*f*a-d*v*a-b*r*p+n*v*p+d*r*y-n*f*y)*C,e[10]=(o*v*a-b*l*a+b*r*u-n*v*u-o*r*y+n*l*y)*C,e[11]=(d*l*a-o*f*a-d*r*u+n*f*u+o*r*p-n*l*p)*C,e[12]=A*C,e[13]=(d*v*i-b*f*i+b*r*m-n*v*m-d*r*x+n*f*x)*C,e[14]=(b*l*i-o*v*i-b*r*c+n*v*c+o*r*x-n*l*x)*C,e[15]=(o*f*i-d*l*i+d*r*c-n*f*c-o*r*m+n*l*m)*C,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,m=a*u,p=a*d,b=a*f,v=o*d,x=o*f,y=l*f,S=c*u,M=c*d,N=c*f,A=r.x,k=r.y,C=r.z;return i[0]=(1-(v+y))*A,i[1]=(p+N)*A,i[2]=(b-M)*A,i[3]=0,i[4]=(p-N)*k,i[5]=(1-(m+y))*k,i[6]=(x+S)*k,i[7]=0,i[8]=(b+M)*C,i[9]=(x-S)*C,i[10]=(1-(m+v))*C,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=vp.set(i[0],i[1],i[2]).length();const o=vp.set(i[4],i[5],i[6]).length(),l=vp.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],Wo.copy(this);const u=1/a,d=1/o,f=1/l;return Wo.elements[0]*=u,Wo.elements[1]*=u,Wo.elements[2]*=u,Wo.elements[4]*=d,Wo.elements[5]*=d,Wo.elements[6]*=d,Wo.elements[8]*=f,Wo.elements[9]*=f,Wo.elements[10]*=f,n.setFromRotationMatrix(Wo),r.x=a,r.y=o,r.z=l,this}makePerspective(e,n,r,i,a,o,l=Vl){const c=this.elements,u=2*a/(n-e),d=2*a/(r-i),f=(n+e)/(n-e),m=(r+i)/(r-i);let p,b;if(l===Vl)p=-(o+a)/(o-a),b=-2*o*a/(o-a);else if(l===Q0)p=-o/(o-a),b=-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]=m,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=b,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,n,r,i,a,o,l=Vl){const c=this.elements,u=1/(n-e),d=1/(r-i),f=1/(o-a),m=(n+e)*u,p=(r+i)*d;let b,v;if(l===Vl)b=(o+a)*f,v=-2*f;else if(l===Q0)b=a*f,v=-1*f;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+l);return c[0]=2*u,c[4]=0,c[8]=0,c[12]=-m,c[1]=0,c[5]=2*d,c[9]=0,c[13]=-p,c[2]=0,c[6]=0,c[10]=v,c[14]=-b,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<16;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<16;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e[n+9]=r[9],e[n+10]=r[10],e[n+11]=r[11],e[n+12]=r[12],e[n+13]=r[13],e[n+14]=r[14],e[n+15]=r[15],e}}const vp=new Be,Wo=new Tr,i5e=new Be(0,0,0),a5e=new Be(1,1,1),ld=new Be,o1=new Be,Fs=new Be,h7=new Tr,f7=new tm;class Vy{constructor(e=0,n=0,r=0,i=Vy.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],m=i[6],p=i[10];switch(n){case"XYZ":this._y=Math.asin(va(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,p),this._z=Math.atan2(-o,a)):(this._x=Math.atan2(m,u),this._z=0);break;case"YXZ":this._x=Math.asin(-va(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(va(m,-1,1)),Math.abs(m)<.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(-va(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(m,p),this._z=Math.atan2(c,a)):(this._x=0,this._z=Math.atan2(-o,u));break;case"YZX":this._z=Math.asin(va(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(-va(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(m,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 h7.makeRotationFromQuaternion(e),this.setFromRotationMatrix(h7,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return f7.setFromEuler(this),this.setFromQuaternion(f7,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}}Vy.DEFAULT_ORDER="XYZ";class Qee{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 s5e=0;const m7=new Be,_p=new tm,Ic=new Tr,l1=new Be,Ab=new Be,o5e=new Be,l5e=new tm,p7=new Be(1,0,0),g7=new Be(0,1,0),x7=new Be(0,0,1),c5e={type:"added"},u5e={type:"removed"};class es extends hm{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:s5e++}),this.uuid=ou(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=es.DEFAULT_UP.clone();const e=new Be,n=new Vy,r=new tm,i=new Be(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 Tr},normalMatrix:{value:new An}}),this.matrix=new Tr,this.matrixWorld=new Tr,this.matrixAutoUpdate=es.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=es.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Qee,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 _p.setFromAxisAngle(e,n),this.quaternion.multiply(_p),this}rotateOnWorldAxis(e,n){return _p.setFromAxisAngle(e,n),this.quaternion.premultiply(_p),this}rotateX(e){return this.rotateOnAxis(p7,e)}rotateY(e){return this.rotateOnAxis(g7,e)}rotateZ(e){return this.rotateOnAxis(x7,e)}translateOnAxis(e,n){return m7.copy(e).applyQuaternion(this.quaternion),this.position.add(m7.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(p7,e)}translateY(e){return this.translateOnAxis(g7,e)}translateZ(e){return this.translateOnAxis(x7,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Ic.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?l1.copy(e):l1.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),Ab.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ic.lookAt(Ab,l1,this.up):Ic.lookAt(l1,Ab,this.up),this.quaternion.setFromRotationMatrix(Ic),i&&(Ic.extractRotation(i.matrixWorld),_p.setFromRotationMatrix(Ic),this.quaternion.premultiply(_p.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(c5e)):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(u5e)),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),Ic.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Ic.multiply(e.parent.matrixWorld)),e.applyMatrix4(Ic),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(Ab,e,o5e),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ab,l5e,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),m=o(e.skeletons),p=o(e.animations),b=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),m.length>0&&(r.skeletons=m),p.length>0&&(r.animations=p),b.length>0&&(r.nodes=b)}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}}es.DEFAULT_UP=new Be(0,1,0);es.DEFAULT_MATRIX_AUTO_UPDATE=!0;es.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const qo=new Be,Fc=new Be,$k=new Be,Uc=new Be,wp=new Be,Sp=new Be,b7=new Be,Hk=new Be,Vk=new Be,Gk=new Be;let c1=!1;class Ko{constructor(e=new Be,n=new Be,r=new Be){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),qo.subVectors(e,n),i.cross(qo);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){qo.subVectors(i,n),Fc.subVectors(r,n),$k.subVectors(e,n);const o=qo.dot(qo),l=qo.dot(Fc),c=qo.dot($k),u=Fc.dot(Fc),d=Fc.dot($k),f=o*u-l*l;if(f===0)return a.set(-2,-1,-1);const m=1/f,p=(u*c-l*d)*m,b=(o*d-l*c)*m;return a.set(1-p-b,b,p)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,Uc),Uc.x>=0&&Uc.y>=0&&Uc.x+Uc.y<=1}static getUV(e,n,r,i,a,o,l,c){return c1===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),c1=!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,Uc),c.setScalar(0),c.addScaledVector(a,Uc.x),c.addScaledVector(o,Uc.y),c.addScaledVector(l,Uc.z),c}static isFrontFacing(e,n,r,i){return qo.subVectors(r,n),Fc.subVectors(e,n),qo.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 qo.subVectors(this.c,this.b),Fc.subVectors(this.a,this.b),qo.cross(Fc).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Ko.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return Ko.getBarycoord(e,this.a,this.b,this.c,n)}getUV(e,n,r,i,a){return c1===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),c1=!0),Ko.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}getInterpolation(e,n,r,i,a){return Ko.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}containsPoint(e){return Ko.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Ko.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;wp.subVectors(i,r),Sp.subVectors(a,r),Hk.subVectors(e,r);const c=wp.dot(Hk),u=Sp.dot(Hk);if(c<=0&&u<=0)return n.copy(r);Vk.subVectors(e,i);const d=wp.dot(Vk),f=Sp.dot(Vk);if(d>=0&&f<=d)return n.copy(i);const m=c*f-d*u;if(m<=0&&c>=0&&d<=0)return o=c/(c-d),n.copy(r).addScaledVector(wp,o);Gk.subVectors(e,a);const p=wp.dot(Gk),b=Sp.dot(Gk);if(b>=0&&p<=b)return n.copy(a);const v=p*u-c*b;if(v<=0&&u>=0&&b<=0)return l=u/(u-b),n.copy(r).addScaledVector(Sp,l);const x=d*b-p*f;if(x<=0&&f-d>=0&&p-b>=0)return b7.subVectors(a,i),l=(f-d)/(f-d+(p-b)),n.copy(i).addScaledVector(b7,l);const y=1/(x+v+m);return o=v*y,l=m*y,n.copy(r).addScaledVector(wp,o).addScaledVector(Sp,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const Jee={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},cd={h:0,s:0,l:0},u1={h:0,s:0,l:0};function Wk(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 rn=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=ya){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,pr.toWorkingColorSpace(this,n),this}setRGB(e,n,r,i=pr.workingColorSpace){return this.r=e,this.g=n,this.b=r,pr.toWorkingColorSpace(this,i),this}setHSL(e,n,r,i=pr.workingColorSpace){if(e=pL(e,1),n=va(n,0,1),r=va(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=Wk(o,a,e+1/3),this.g=Wk(o,a,e),this.b=Wk(o,a,e-1/3)}return pr.toWorkingColorSpace(this,i),this}setStyle(e,n=ya){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=ya){const r=Jee[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=og(e.r),this.g=og(e.g),this.b=og(e.b),this}copyLinearToSRGB(e){return this.r=Dk(e.r),this.g=Dk(e.g),this.b=Dk(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=ya){return pr.fromWorkingColorSpace(Ra.copy(this),e),Math.round(va(Ra.r*255,0,255))*65536+Math.round(va(Ra.g*255,0,255))*256+Math.round(va(Ra.b*255,0,255))}getHexString(e=ya){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=pr.workingColorSpace){pr.fromWorkingColorSpace(Ra.copy(this),n);const r=Ra.r,i=Ra.g,a=Ra.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=pr.workingColorSpace){return pr.fromWorkingColorSpace(Ra.copy(this),n),e.r=Ra.r,e.g=Ra.g,e.b=Ra.b,e}getStyle(e=ya){pr.fromWorkingColorSpace(Ra.copy(this),e);const n=Ra.r,r=Ra.g,i=Ra.b;return e!==ya?`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(cd),this.setHSL(cd.h+e,cd.s+n,cd.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(cd),e.getHSL(u1);const r=i0(cd.h,u1.h,n),i=i0(cd.s,u1.s,n),a=i0(cd.l,u1.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 Ra=new rn;rn.NAMES=Jee;let d5e=0;class ux extends hm{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:d5e++}),this.uuid=ou(),this.name="",this.type="Material",this.blending=sg,this.side=th,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=vR,this.blendDst=_R,this.blendEquation=tf,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new rn(0,0,0),this.blendAlpha=0,this.depthFunc=VS,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=a7,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=pp,this.stencilZFail=pp,this.stencilZPass=pp,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!==sg&&(r.blending=this.blending),this.side!==th&&(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!==vR&&(r.blendSrc=this.blendSrc),this.blendDst!==_R&&(r.blendDst=this.blendDst),this.blendEquation!==tf&&(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!==VS&&(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!==a7&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==pp&&(r.stencilFail=this.stencilFail),this.stencilZFail!==pp&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==pp&&(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 ete extends ux{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new rn(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=hL,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 wi=new Be,d1=new mn;class Xs{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=NR,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=eu,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++)d1.fromBufferAttribute(this,n),d1.applyMatrix3(e),this.setXY(n,d1.x,d1.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)wi.fromBufferAttribute(this,n),wi.applyMatrix3(e),this.setXYZ(n,wi.x,wi.y,wi.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)wi.fromBufferAttribute(this,n),wi.applyMatrix4(e),this.setXYZ(n,wi.x,wi.y,wi.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)wi.fromBufferAttribute(this,n),wi.applyNormalMatrix(e),this.setXYZ(n,wi.x,wi.y,wi.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)wi.fromBufferAttribute(this,n),wi.transformDirection(e),this.setXYZ(n,wi.x,wi.y,wi.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=Fl(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=mr(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=Fl(n,this.array)),n}setX(e,n){return this.normalized&&(n=mr(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=Fl(n,this.array)),n}setY(e,n){return this.normalized&&(n=mr(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=Fl(n,this.array)),n}setZ(e,n){return this.normalized&&(n=mr(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=Fl(n,this.array)),n}setW(e,n){return this.normalized&&(n=mr(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=mr(n,this.array),r=mr(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=mr(n,this.array),r=mr(r,this.array),i=mr(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=mr(n,this.array),r=mr(r,this.array),i=mr(i,this.array),a=mr(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!==NR&&(e.usage=this.usage),e}}class tte extends Xs{constructor(e,n,r){super(new Uint16Array(e),n,r)}}class nte extends Xs{constructor(e,n,r){super(new Uint32Array(e),n,r)}}class pi extends Xs{constructor(e,n,r){super(new Float32Array(e),n,r)}}let h5e=0;const mo=new Tr,qk=new es,Mp=new Be,Us=new ko,Tb=new ko,qi=new Be;class Ha extends hm{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:h5e++}),this.uuid=ou(),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(Kee(e)?nte:tte)(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 An().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 mo.makeRotationFromQuaternion(e),this.applyMatrix4(mo),this}rotateX(e){return mo.makeRotationX(e),this.applyMatrix4(mo),this}rotateY(e){return mo.makeRotationY(e),this.applyMatrix4(mo),this}rotateZ(e){return mo.makeRotationZ(e),this.applyMatrix4(mo),this}translate(e,n,r){return mo.makeTranslation(e,n,r),this.applyMatrix4(mo),this}scale(e,n,r){return mo.makeScale(e,n,r),this.applyMatrix4(mo),this}lookAt(e){return qk.lookAt(e),qk.updateMatrix(),this.applyMatrix4(qk.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Mp).negate(),this.translate(Mp.x,Mp.y,Mp.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 pi(n,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ko);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 Be(-1/0,-1/0,-1/0),new Be(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];Us.setFromBufferAttribute(a),this.morphTargetsRelative?(qi.addVectors(this.boundingBox.min,Us.min),this.boundingBox.expandByPoint(qi),qi.addVectors(this.boundingBox.max,Us.max),this.boundingBox.expandByPoint(qi)):(this.boundingBox.expandByPoint(Us.min),this.boundingBox.expandByPoint(Us.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 Xl);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 Be,1/0);return}if(e){const r=this.boundingSphere.center;if(Us.setFromBufferAttribute(e),n)for(let a=0,o=n.length;a<o;a++){const l=n[a];Tb.setFromBufferAttribute(l),this.morphTargetsRelative?(qi.addVectors(Us.min,Tb.min),Us.expandByPoint(qi),qi.addVectors(Us.max,Tb.max),Us.expandByPoint(qi)):(Us.expandByPoint(Tb.min),Us.expandByPoint(Tb.max))}Us.getCenter(r);let i=0;for(let a=0,o=e.count;a<o;a++)qi.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(qi));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++)qi.fromBufferAttribute(l,u),c&&(Mp.fromBufferAttribute(e,u),qi.add(Mp)),i=Math.max(i,r.distanceToSquared(qi))}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 Xs(new Float32Array(4*l),4));const c=this.getAttribute("tangent").array,u=[],d=[];for(let R=0;R<l;R++)u[R]=new Be,d[R]=new Be;const f=new Be,m=new Be,p=new Be,b=new mn,v=new mn,x=new mn,y=new Be,S=new Be;function M(R,U,L){f.fromArray(i,R*3),m.fromArray(i,U*3),p.fromArray(i,L*3),b.fromArray(o,R*2),v.fromArray(o,U*2),x.fromArray(o,L*2),m.sub(f),p.sub(f),v.sub(b),x.sub(b);const q=1/(v.x*x.y-x.x*v.y);isFinite(q)&&(y.copy(m).multiplyScalar(x.y).addScaledVector(p,-v.y).multiplyScalar(q),S.copy(p).multiplyScalar(v.x).addScaledVector(m,-x.x).multiplyScalar(q),u[R].add(y),u[U].add(y),u[L].add(y),d[R].add(S),d[U].add(S),d[L].add(S))}let N=this.groups;N.length===0&&(N=[{start:0,count:r.length}]);for(let R=0,U=N.length;R<U;++R){const L=N[R],q=L.start,j=L.count;for(let W=q,K=q+j;W<K;W+=3)M(r[W+0],r[W+1],r[W+2])}const A=new Be,k=new Be,C=new Be,D=new Be;function T(R){C.fromArray(a,R*3),D.copy(C);const U=u[R];A.copy(U),A.sub(C.multiplyScalar(C.dot(U))).normalize(),k.crossVectors(D,U);const q=k.dot(d[R])<0?-1:1;c[R*4]=A.x,c[R*4+1]=A.y,c[R*4+2]=A.z,c[R*4+3]=q}for(let R=0,U=N.length;R<U;++R){const L=N[R],q=L.start,j=L.count;for(let W=q,K=q+j;W<K;W+=3)T(r[W+0]),T(r[W+1]),T(r[W+2])}}computeVertexNormals(){const e=this.index,n=this.getAttribute("position");if(n!==void 0){let r=this.getAttribute("normal");if(r===void 0)r=new Xs(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let m=0,p=r.count;m<p;m++)r.setXYZ(m,0,0,0);const i=new Be,a=new Be,o=new Be,l=new Be,c=new Be,u=new Be,d=new Be,f=new Be;if(e)for(let m=0,p=e.count;m<p;m+=3){const b=e.getX(m+0),v=e.getX(m+1),x=e.getX(m+2);i.fromBufferAttribute(n,b),a.fromBufferAttribute(n,v),o.fromBufferAttribute(n,x),d.subVectors(o,a),f.subVectors(i,a),d.cross(f),l.fromBufferAttribute(r,b),c.fromBufferAttribute(r,v),u.fromBufferAttribute(r,x),l.add(d),c.add(d),u.add(d),r.setXYZ(b,l.x,l.y,l.z),r.setXYZ(v,c.x,c.y,c.z),r.setXYZ(x,u.x,u.y,u.z)}else for(let m=0,p=n.count;m<p;m+=3)i.fromBufferAttribute(n,m+0),a.fromBufferAttribute(n,m+1),o.fromBufferAttribute(n,m+2),d.subVectors(o,a),f.subVectors(i,a),d.cross(f),r.setXYZ(m+0,d.x,d.y,d.z),r.setXYZ(m+1,d.x,d.y,d.z),r.setXYZ(m+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++)qi.fromBufferAttribute(e,n),qi.normalize(),e.setXYZ(n,qi.x,qi.y,qi.z)}toNonIndexed(){function e(l,c){const u=l.array,d=l.itemSize,f=l.normalized,m=new u.constructor(c.length*d);let p=0,b=0;for(let v=0,x=c.length;v<x;v++){l.isInterleavedBufferAttribute?p=c[v]*l.data.stride+l.offset:p=c[v]*d;for(let y=0;y<d;y++)m[b++]=u[p++]}return new Xs(m,d,f)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new Ha,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 m=u[d],p=e(m,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,m=u.length;f<m;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 m=0,p=f.length;m<p;m++)d.push(f[m].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 y7=new Tr,Vh=new gL,h1=new Xl,v7=new Be,Ep=new Be,Np=new Be,Ap=new Be,Kk=new Be,f1=new Be,m1=new mn,p1=new mn,g1=new mn,_7=new Be,w7=new Be,S7=new Be,x1=new Be,b1=new Be;class tl extends es{constructor(e=new Ha,n=new ete){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){f1.set(0,0,0);for(let c=0,u=a.length;c<u;c++){const d=l[c],f=a[c];d!==0&&(Kk.fromBufferAttribute(f,e),o?f1.addScaledVector(Kk,d):f1.addScaledVector(Kk.sub(n),d))}n.add(f1)}return n}raycast(e,n){const r=this.geometry,i=this.material,a=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),h1.copy(r.boundingSphere),h1.applyMatrix4(a),Vh.copy(e.ray).recast(e.near),!(h1.containsPoint(Vh.origin)===!1&&(Vh.intersectSphere(h1,v7)===null||Vh.origin.distanceToSquared(v7)>(e.far-e.near)**2))&&(y7.copy(a).invert(),Vh.copy(e.ray).applyMatrix4(y7),!(r.boundingBox!==null&&Vh.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,Vh)))}_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,m=a.groups,p=a.drawRange;if(l!==null)if(Array.isArray(o))for(let b=0,v=m.length;b<v;b++){const x=m[b],y=o[x.materialIndex],S=Math.max(x.start,p.start),M=Math.min(l.count,Math.min(x.start+x.count,p.start+p.count));for(let N=S,A=M;N<A;N+=3){const k=l.getX(N),C=l.getX(N+1),D=l.getX(N+2);i=y1(this,y,e,r,u,d,f,k,C,D),i&&(i.faceIndex=Math.floor(N/3),i.face.materialIndex=x.materialIndex,n.push(i))}}else{const b=Math.max(0,p.start),v=Math.min(l.count,p.start+p.count);for(let x=b,y=v;x<y;x+=3){const S=l.getX(x),M=l.getX(x+1),N=l.getX(x+2);i=y1(this,o,e,r,u,d,f,S,M,N),i&&(i.faceIndex=Math.floor(x/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(o))for(let b=0,v=m.length;b<v;b++){const x=m[b],y=o[x.materialIndex],S=Math.max(x.start,p.start),M=Math.min(c.count,Math.min(x.start+x.count,p.start+p.count));for(let N=S,A=M;N<A;N+=3){const k=N,C=N+1,D=N+2;i=y1(this,y,e,r,u,d,f,k,C,D),i&&(i.faceIndex=Math.floor(N/3),i.face.materialIndex=x.materialIndex,n.push(i))}}else{const b=Math.max(0,p.start),v=Math.min(c.count,p.start+p.count);for(let x=b,y=v;x<y;x+=3){const S=x,M=x+1,N=x+2;i=y1(this,o,e,r,u,d,f,S,M,N),i&&(i.faceIndex=Math.floor(x/3),n.push(i))}}}}function f5e(t,e,n,r,i,a,o,l){let c;if(e.side===ws?c=r.intersectTriangle(o,a,i,!0,l):c=r.intersectTriangle(i,a,o,e.side===th,l),c===null)return null;b1.copy(l),b1.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(b1);return u<n.near||u>n.far?null:{distance:u,point:b1.clone(),object:t}}function y1(t,e,n,r,i,a,o,l,c,u){t.getVertexPosition(l,Ep),t.getVertexPosition(c,Np),t.getVertexPosition(u,Ap);const d=f5e(t,e,n,r,Ep,Np,Ap,x1);if(d){i&&(m1.fromBufferAttribute(i,l),p1.fromBufferAttribute(i,c),g1.fromBufferAttribute(i,u),d.uv=Ko.getInterpolation(x1,Ep,Np,Ap,m1,p1,g1,new mn)),a&&(m1.fromBufferAttribute(a,l),p1.fromBufferAttribute(a,c),g1.fromBufferAttribute(a,u),d.uv1=Ko.getInterpolation(x1,Ep,Np,Ap,m1,p1,g1,new mn),d.uv2=d.uv1),o&&(_7.fromBufferAttribute(o,l),w7.fromBufferAttribute(o,c),S7.fromBufferAttribute(o,u),d.normal=Ko.getInterpolation(x1,Ep,Np,Ap,_7,w7,S7,new Be),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const f={a:l,b:c,c:u,normal:new Be,materialIndex:0};Ko.getNormal(Ep,Np,Ap,f.normal),d.face=f}return d}class Gy extends Ha{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 m=0,p=0;b("z","y","x",-1,-1,r,n,e,o,a,0),b("z","y","x",1,-1,r,n,-e,o,a,1),b("x","z","y",1,1,e,r,n,i,o,2),b("x","z","y",1,-1,e,r,-n,i,o,3),b("x","y","z",1,-1,e,n,r,i,a,4),b("x","y","z",-1,-1,e,n,-r,i,a,5),this.setIndex(c),this.setAttribute("position",new pi(u,3)),this.setAttribute("normal",new pi(d,3)),this.setAttribute("uv",new pi(f,2));function b(v,x,y,S,M,N,A,k,C,D,T){const R=N/C,U=A/D,L=N/2,q=A/2,j=k/2,W=C+1,K=D+1;let V=0,J=0;const ne=new Be;for(let te=0;te<K;te++){const z=te*U-q;for(let H=0;H<W;H++){const Z=H*R-L;ne[v]=Z*S,ne[x]=z*M,ne[y]=j,u.push(ne.x,ne.y,ne.z),ne[v]=0,ne[x]=0,ne[y]=k>0?1:-1,d.push(ne.x,ne.y,ne.z),f.push(H/C),f.push(1-te/D),V+=1}}for(let te=0;te<D;te++)for(let z=0;z<C;z++){const H=m+z+W*te,Z=m+z+W*(te+1),ee=m+(z+1)+W*(te+1),he=m+(z+1)+W*te;c.push(H,Z,he),c.push(Z,ee,he),J+=6}l.addGroup(p,J,T),p+=J,m+=V}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Gy(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Dg(t){const e={};for(const n in t){e[n]={};for(const r in t[n]){const i=t[n][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[n][r]=null):e[n][r]=i.clone():Array.isArray(i)?e[n][r]=i.slice():e[n][r]=i}}return e}function Ka(t){const e={};for(let n=0;n<t.length;n++){const r=Dg(t[n]);for(const i in r)e[i]=r[i]}return e}function m5e(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function rte(t){return t.getRenderTarget()===null?t.outputColorSpace:pr.workingColorSpace}const xL={clone:Dg,merge:Ka};var p5e=`void main() {
  3968. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  3969. }`,g5e=`void main() {
  3970. gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
  3971. }`;class nh extends ux{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=p5e,this.fragmentShader=g5e,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=Dg(e.uniforms),this.uniformsGroups=m5e(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 ite extends es{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Tr,this.projectionMatrix=new Tr,this.projectionMatrixInverse=new Tr,this.coordinateSystem=Vl}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 zs extends ite{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=J0*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(r0*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return J0*2*Math.atan(Math.tan(r0*.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(r0*.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 Tp=-90,Cp=1;class x5e extends es{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new zs(Tp,Cp,e,n);i.layers=this.layers,this.add(i);const a=new zs(Tp,Cp,e,n);a.layers=this.layers,this.add(a);const o=new zs(Tp,Cp,e,n);o.layers=this.layers,this.add(o);const l=new zs(Tp,Cp,e,n);l.layers=this.layers,this.add(l);const c=new zs(Tp,Cp,e,n);c.layers=this.layers,this.add(c);const u=new zs(Tp,Cp,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===Vl)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===Q0)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(),m=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),b=e.xr.enabled;e.xr.enabled=!1;const v=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(n,a),e.setRenderTarget(r,1,i),e.render(n,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=v,e.setRenderTarget(r,5,i),e.render(n,d),e.setRenderTarget(f,m,p),e.xr.enabled=b,r.texture.needsPMREMUpdate=!0}}class ate extends Ss{constructor(e,n,r,i,a,o,l,c,u,d){e=e!==void 0?e:[],n=n!==void 0?n:jg,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 b5e extends em{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&&(a0("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===Tf?ya:No),this.texture=new ate(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:Mo}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:`
  3972. varying vec3 vWorldDirection;
  3973. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  3974. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  3975. }
  3976. void main() {
  3977. vWorldDirection = transformDirection( position, modelMatrix );
  3978. #include <begin_vertex>
  3979. #include <project_vertex>
  3980. }
  3981. `,fragmentShader:`
  3982. uniform sampler2D tEquirect;
  3983. varying vec3 vWorldDirection;
  3984. #include <common>
  3985. void main() {
  3986. vec3 direction = normalize( vWorldDirection );
  3987. vec2 sampleUV = equirectUv( direction );
  3988. gl_FragColor = texture2D( tEquirect, sampleUV );
  3989. }
  3990. `},i=new Gy(5,5,5),a=new nh({name:"CubemapFromEquirect",uniforms:Dg(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:ws,blending:Bd});a.uniforms.tEquirect.value=n;const o=new tl(i,a),l=n.minFilter;return n.minFilter===Y0&&(n.minFilter=Mo),new x5e(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 Xk=new Be,y5e=new Be,v5e=new An;class bd{constructor(e=new Be(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=Xk.subVectors(r,n).cross(y5e.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(Xk),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||v5e.getNormalMatrix(e),i=this.coplanarPoint(Xk).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 Gh=new Xl,v1=new Be;class pN{constructor(e=new bd,n=new bd,r=new bd,i=new bd,a=new bd,o=new bd){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=Vl){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],m=i[7],p=i[8],b=i[9],v=i[10],x=i[11],y=i[12],S=i[13],M=i[14],N=i[15];if(r[0].setComponents(c-a,m-u,x-p,N-y).normalize(),r[1].setComponents(c+a,m+u,x+p,N+y).normalize(),r[2].setComponents(c+o,m+d,x+b,N+S).normalize(),r[3].setComponents(c-o,m-d,x-b,N-S).normalize(),r[4].setComponents(c-l,m-f,x-v,N-M).normalize(),n===Vl)r[5].setComponents(c+l,m+f,x+v,N+M).normalize();else if(n===Q0)r[5].setComponents(l,f,v,M).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(),Gh.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Gh.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Gh)}intersectsSprite(e){return Gh.center.set(0,0,0),Gh.radius=.7071067811865476,Gh.applyMatrix4(e.matrixWorld),this.intersectsSphere(Gh)}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(v1.x=i.normal.x>0?e.max.x:e.min.x,v1.y=i.normal.y>0?e.max.y:e.min.y,v1.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(v1)<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 ste(){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 _5e(t,e){const n=e.isWebGL2,r=new WeakMap;function i(u,d){const f=u.array,m=u.usage,p=f.byteLength,b=t.createBuffer();t.bindBuffer(d,b),t.bufferData(d,f,m),u.onUploadCallback();let v;if(f instanceof Float32Array)v=t.FLOAT;else if(f instanceof Uint16Array)if(u.isFloat16BufferAttribute)if(n)v=t.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else v=t.UNSIGNED_SHORT;else if(f instanceof Int16Array)v=t.SHORT;else if(f instanceof Uint32Array)v=t.UNSIGNED_INT;else if(f instanceof Int32Array)v=t.INT;else if(f instanceof Int8Array)v=t.BYTE;else if(f instanceof Uint8Array)v=t.UNSIGNED_BYTE;else if(f instanceof Uint8ClampedArray)v=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+f);return{buffer:b,type:v,bytesPerElement:f.BYTES_PER_ELEMENT,version:u.version,size:p}}function a(u,d,f){const m=d.array,p=d._updateRange,b=d.updateRanges;if(t.bindBuffer(f,u),p.count===-1&&b.length===0&&t.bufferSubData(f,0,m),b.length!==0){for(let v=0,x=b.length;v<x;v++){const y=b[v];n?t.bufferSubData(f,y.start*m.BYTES_PER_ELEMENT,m,y.start,y.count):t.bufferSubData(f,y.start*m.BYTES_PER_ELEMENT,m.subarray(y.start,y.start+y.count))}d.clearUpdateRanges()}p.count!==-1&&(n?t.bufferSubData(f,p.offset*m.BYTES_PER_ELEMENT,m,p.offset,p.count):t.bufferSubData(f,p.offset*m.BYTES_PER_ELEMENT,m.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 m=r.get(u);(!m||m.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 bL extends Ha{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,m=n/c,p=[],b=[],v=[],x=[];for(let y=0;y<d;y++){const S=y*m-o;for(let M=0;M<u;M++){const N=M*f-a;b.push(N,-S,0),v.push(0,0,1),x.push(M/l),x.push(1-y/c)}}for(let y=0;y<c;y++)for(let S=0;S<l;S++){const M=S+u*y,N=S+u*(y+1),A=S+1+u*(y+1),k=S+1+u*y;p.push(M,N,k),p.push(N,A,k)}this.setIndex(p),this.setAttribute("position",new pi(b,3)),this.setAttribute("normal",new pi(v,3)),this.setAttribute("uv",new pi(x,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new bL(e.width,e.height,e.widthSegments,e.heightSegments)}}var w5e=`#ifdef USE_ALPHAHASH
  3991. if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
  3992. #endif`,S5e=`#ifdef USE_ALPHAHASH
  3993. const float ALPHA_HASH_SCALE = 0.05;
  3994. float hash2D( vec2 value ) {
  3995. return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
  3996. }
  3997. float hash3D( vec3 value ) {
  3998. return hash2D( vec2( hash2D( value.xy ), value.z ) );
  3999. }
  4000. float getAlphaHashThreshold( vec3 position ) {
  4001. float maxDeriv = max(
  4002. length( dFdx( position.xyz ) ),
  4003. length( dFdy( position.xyz ) )
  4004. );
  4005. float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
  4006. vec2 pixScales = vec2(
  4007. exp2( floor( log2( pixScale ) ) ),
  4008. exp2( ceil( log2( pixScale ) ) )
  4009. );
  4010. vec2 alpha = vec2(
  4011. hash3D( floor( pixScales.x * position.xyz ) ),
  4012. hash3D( floor( pixScales.y * position.xyz ) )
  4013. );
  4014. float lerpFactor = fract( log2( pixScale ) );
  4015. float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
  4016. float a = min( lerpFactor, 1.0 - lerpFactor );
  4017. vec3 cases = vec3(
  4018. x * x / ( 2.0 * a * ( 1.0 - a ) ),
  4019. ( x - 0.5 * a ) / ( 1.0 - a ),
  4020. 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
  4021. );
  4022. float threshold = ( x < ( 1.0 - a ) )
  4023. ? ( ( x < a ) ? cases.x : cases.y )
  4024. : cases.z;
  4025. return clamp( threshold , 1.0e-6, 1.0 );
  4026. }
  4027. #endif`,M5e=`#ifdef USE_ALPHAMAP
  4028. diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
  4029. #endif`,E5e=`#ifdef USE_ALPHAMAP
  4030. uniform sampler2D alphaMap;
  4031. #endif`,N5e=`#ifdef USE_ALPHATEST
  4032. if ( diffuseColor.a < alphaTest ) discard;
  4033. #endif`,A5e=`#ifdef USE_ALPHATEST
  4034. uniform float alphaTest;
  4035. #endif`,T5e=`#ifdef USE_AOMAP
  4036. float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
  4037. reflectedLight.indirectDiffuse *= ambientOcclusion;
  4038. #if defined( USE_CLEARCOAT )
  4039. clearcoatSpecularIndirect *= ambientOcclusion;
  4040. #endif
  4041. #if defined( USE_SHEEN )
  4042. sheenSpecularIndirect *= ambientOcclusion;
  4043. #endif
  4044. #if defined( USE_ENVMAP ) && defined( STANDARD )
  4045. float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
  4046. reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
  4047. #endif
  4048. #endif`,C5e=`#ifdef USE_AOMAP
  4049. uniform sampler2D aoMap;
  4050. uniform float aoMapIntensity;
  4051. #endif`,k5e=`#ifdef USE_BATCHING
  4052. attribute float batchId;
  4053. uniform highp sampler2D batchingTexture;
  4054. mat4 getBatchingMatrix( const in float i ) {
  4055. int size = textureSize( batchingTexture, 0 ).x;
  4056. int j = int( i ) * 4;
  4057. int x = j % size;
  4058. int y = j / size;
  4059. vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
  4060. vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
  4061. vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
  4062. vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
  4063. return mat4( v1, v2, v3, v4 );
  4064. }
  4065. #endif`,j5e=`#ifdef USE_BATCHING
  4066. mat4 batchingMatrix = getBatchingMatrix( batchId );
  4067. #endif`,P5e=`vec3 transformed = vec3( position );
  4068. #ifdef USE_ALPHAHASH
  4069. vPosition = vec3( position );
  4070. #endif`,R5e=`vec3 objectNormal = vec3( normal );
  4071. #ifdef USE_TANGENT
  4072. vec3 objectTangent = vec3( tangent.xyz );
  4073. #endif`,D5e=`float G_BlinnPhong_Implicit( ) {
  4074. return 0.25;
  4075. }
  4076. float D_BlinnPhong( const in float shininess, const in float dotNH ) {
  4077. return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
  4078. }
  4079. vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
  4080. vec3 halfDir = normalize( lightDir + viewDir );
  4081. float dotNH = saturate( dot( normal, halfDir ) );
  4082. float dotVH = saturate( dot( viewDir, halfDir ) );
  4083. vec3 F = F_Schlick( specularColor, 1.0, dotVH );
  4084. float G = G_BlinnPhong_Implicit( );
  4085. float D = D_BlinnPhong( shininess, dotNH );
  4086. return F * ( G * D );
  4087. } // validated`,O5e=`#ifdef USE_IRIDESCENCE
  4088. const mat3 XYZ_TO_REC709 = mat3(
  4089. 3.2404542, -0.9692660, 0.0556434,
  4090. -1.5371385, 1.8760108, -0.2040259,
  4091. -0.4985314, 0.0415560, 1.0572252
  4092. );
  4093. vec3 Fresnel0ToIor( vec3 fresnel0 ) {
  4094. vec3 sqrtF0 = sqrt( fresnel0 );
  4095. return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
  4096. }
  4097. vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
  4098. return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
  4099. }
  4100. float IorToFresnel0( float transmittedIor, float incidentIor ) {
  4101. return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
  4102. }
  4103. vec3 evalSensitivity( float OPD, vec3 shift ) {
  4104. float phase = 2.0 * PI * OPD * 1.0e-9;
  4105. vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
  4106. vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
  4107. vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
  4108. vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
  4109. 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 ) );
  4110. xyz /= 1.0685e-7;
  4111. vec3 rgb = XYZ_TO_REC709 * xyz;
  4112. return rgb;
  4113. }
  4114. vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
  4115. vec3 I;
  4116. float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
  4117. float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
  4118. float cosTheta2Sq = 1.0 - sinTheta2Sq;
  4119. if ( cosTheta2Sq < 0.0 ) {
  4120. return vec3( 1.0 );
  4121. }
  4122. float cosTheta2 = sqrt( cosTheta2Sq );
  4123. float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
  4124. float R12 = F_Schlick( R0, 1.0, cosTheta1 );
  4125. float T121 = 1.0 - R12;
  4126. float phi12 = 0.0;
  4127. if ( iridescenceIOR < outsideIOR ) phi12 = PI;
  4128. float phi21 = PI - phi12;
  4129. vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
  4130. vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
  4131. vec3 phi23 = vec3( 0.0 );
  4132. if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
  4133. if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
  4134. if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
  4135. float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
  4136. vec3 phi = vec3( phi21 ) + phi23;
  4137. vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
  4138. vec3 r123 = sqrt( R123 );
  4139. vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
  4140. vec3 C0 = R12 + Rs;
  4141. I = C0;
  4142. vec3 Cm = Rs - T121;
  4143. for ( int m = 1; m <= 2; ++ m ) {
  4144. Cm *= r123;
  4145. vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
  4146. I += Cm * Sm;
  4147. }
  4148. return max( I, vec3( 0.0 ) );
  4149. }
  4150. #endif`,L5e=`#ifdef USE_BUMPMAP
  4151. uniform sampler2D bumpMap;
  4152. uniform float bumpScale;
  4153. vec2 dHdxy_fwd() {
  4154. vec2 dSTdx = dFdx( vBumpMapUv );
  4155. vec2 dSTdy = dFdy( vBumpMapUv );
  4156. float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
  4157. float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
  4158. float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
  4159. return vec2( dBx, dBy );
  4160. }
  4161. vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
  4162. vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
  4163. vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
  4164. vec3 vN = surf_norm;
  4165. vec3 R1 = cross( vSigmaY, vN );
  4166. vec3 R2 = cross( vN, vSigmaX );
  4167. float fDet = dot( vSigmaX, R1 ) * faceDirection;
  4168. vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
  4169. return normalize( abs( fDet ) * surf_norm - vGrad );
  4170. }
  4171. #endif`,I5e=`#if NUM_CLIPPING_PLANES > 0
  4172. vec4 plane;
  4173. #pragma unroll_loop_start
  4174. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  4175. plane = clippingPlanes[ i ];
  4176. if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
  4177. }
  4178. #pragma unroll_loop_end
  4179. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  4180. bool clipped = true;
  4181. #pragma unroll_loop_start
  4182. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  4183. plane = clippingPlanes[ i ];
  4184. clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
  4185. }
  4186. #pragma unroll_loop_end
  4187. if ( clipped ) discard;
  4188. #endif
  4189. #endif`,F5e=`#if NUM_CLIPPING_PLANES > 0
  4190. varying vec3 vClipPosition;
  4191. uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
  4192. #endif`,U5e=`#if NUM_CLIPPING_PLANES > 0
  4193. varying vec3 vClipPosition;
  4194. #endif`,z5e=`#if NUM_CLIPPING_PLANES > 0
  4195. vClipPosition = - mvPosition.xyz;
  4196. #endif`,B5e=`#if defined( USE_COLOR_ALPHA )
  4197. diffuseColor *= vColor;
  4198. #elif defined( USE_COLOR )
  4199. diffuseColor.rgb *= vColor;
  4200. #endif`,$5e=`#if defined( USE_COLOR_ALPHA )
  4201. varying vec4 vColor;
  4202. #elif defined( USE_COLOR )
  4203. varying vec3 vColor;
  4204. #endif`,H5e=`#if defined( USE_COLOR_ALPHA )
  4205. varying vec4 vColor;
  4206. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
  4207. varying vec3 vColor;
  4208. #endif`,V5e=`#if defined( USE_COLOR_ALPHA )
  4209. vColor = vec4( 1.0 );
  4210. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
  4211. vColor = vec3( 1.0 );
  4212. #endif
  4213. #ifdef USE_COLOR
  4214. vColor *= color;
  4215. #endif
  4216. #ifdef USE_INSTANCING_COLOR
  4217. vColor.xyz *= instanceColor.xyz;
  4218. #endif`,G5e=`#define PI 3.141592653589793
  4219. #define PI2 6.283185307179586
  4220. #define PI_HALF 1.5707963267948966
  4221. #define RECIPROCAL_PI 0.3183098861837907
  4222. #define RECIPROCAL_PI2 0.15915494309189535
  4223. #define EPSILON 1e-6
  4224. #ifndef saturate
  4225. #define saturate( a ) clamp( a, 0.0, 1.0 )
  4226. #endif
  4227. #define whiteComplement( a ) ( 1.0 - saturate( a ) )
  4228. float pow2( const in float x ) { return x*x; }
  4229. vec3 pow2( const in vec3 x ) { return x*x; }
  4230. float pow3( const in float x ) { return x*x*x; }
  4231. float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
  4232. float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
  4233. float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
  4234. highp float rand( const in vec2 uv ) {
  4235. const highp float a = 12.9898, b = 78.233, c = 43758.5453;
  4236. highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
  4237. return fract( sin( sn ) * c );
  4238. }
  4239. #ifdef HIGH_PRECISION
  4240. float precisionSafeLength( vec3 v ) { return length( v ); }
  4241. #else
  4242. float precisionSafeLength( vec3 v ) {
  4243. float maxComponent = max3( abs( v ) );
  4244. return length( v / maxComponent ) * maxComponent;
  4245. }
  4246. #endif
  4247. struct IncidentLight {
  4248. vec3 color;
  4249. vec3 direction;
  4250. bool visible;
  4251. };
  4252. struct ReflectedLight {
  4253. vec3 directDiffuse;
  4254. vec3 directSpecular;
  4255. vec3 indirectDiffuse;
  4256. vec3 indirectSpecular;
  4257. };
  4258. #ifdef USE_ALPHAHASH
  4259. varying vec3 vPosition;
  4260. #endif
  4261. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  4262. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  4263. }
  4264. vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
  4265. return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
  4266. }
  4267. mat3 transposeMat3( const in mat3 m ) {
  4268. mat3 tmp;
  4269. tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
  4270. tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
  4271. tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
  4272. return tmp;
  4273. }
  4274. float luminance( const in vec3 rgb ) {
  4275. const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );
  4276. return dot( weights, rgb );
  4277. }
  4278. bool isPerspectiveMatrix( mat4 m ) {
  4279. return m[ 2 ][ 3 ] == - 1.0;
  4280. }
  4281. vec2 equirectUv( in vec3 dir ) {
  4282. float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
  4283. float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
  4284. return vec2( u, v );
  4285. }
  4286. vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
  4287. return RECIPROCAL_PI * diffuseColor;
  4288. }
  4289. vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
  4290. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  4291. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  4292. }
  4293. float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
  4294. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  4295. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  4296. } // validated`,W5e=`#ifdef ENVMAP_TYPE_CUBE_UV
  4297. #define cubeUV_minMipLevel 4.0
  4298. #define cubeUV_minTileSize 16.0
  4299. float getFace( vec3 direction ) {
  4300. vec3 absDirection = abs( direction );
  4301. float face = - 1.0;
  4302. if ( absDirection.x > absDirection.z ) {
  4303. if ( absDirection.x > absDirection.y )
  4304. face = direction.x > 0.0 ? 0.0 : 3.0;
  4305. else
  4306. face = direction.y > 0.0 ? 1.0 : 4.0;
  4307. } else {
  4308. if ( absDirection.z > absDirection.y )
  4309. face = direction.z > 0.0 ? 2.0 : 5.0;
  4310. else
  4311. face = direction.y > 0.0 ? 1.0 : 4.0;
  4312. }
  4313. return face;
  4314. }
  4315. vec2 getUV( vec3 direction, float face ) {
  4316. vec2 uv;
  4317. if ( face == 0.0 ) {
  4318. uv = vec2( direction.z, direction.y ) / abs( direction.x );
  4319. } else if ( face == 1.0 ) {
  4320. uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
  4321. } else if ( face == 2.0 ) {
  4322. uv = vec2( - direction.x, direction.y ) / abs( direction.z );
  4323. } else if ( face == 3.0 ) {
  4324. uv = vec2( - direction.z, direction.y ) / abs( direction.x );
  4325. } else if ( face == 4.0 ) {
  4326. uv = vec2( - direction.x, direction.z ) / abs( direction.y );
  4327. } else {
  4328. uv = vec2( direction.x, direction.y ) / abs( direction.z );
  4329. }
  4330. return 0.5 * ( uv + 1.0 );
  4331. }
  4332. vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
  4333. float face = getFace( direction );
  4334. float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
  4335. mipInt = max( mipInt, cubeUV_minMipLevel );
  4336. float faceSize = exp2( mipInt );
  4337. highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
  4338. if ( face > 2.0 ) {
  4339. uv.y += faceSize;
  4340. face -= 3.0;
  4341. }
  4342. uv.x += face * faceSize;
  4343. uv.x += filterInt * 3.0 * cubeUV_minTileSize;
  4344. uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
  4345. uv.x *= CUBEUV_TEXEL_WIDTH;
  4346. uv.y *= CUBEUV_TEXEL_HEIGHT;
  4347. #ifdef texture2DGradEXT
  4348. return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
  4349. #else
  4350. return texture2D( envMap, uv ).rgb;
  4351. #endif
  4352. }
  4353. #define cubeUV_r0 1.0
  4354. #define cubeUV_v0 0.339
  4355. #define cubeUV_m0 - 2.0
  4356. #define cubeUV_r1 0.8
  4357. #define cubeUV_v1 0.276
  4358. #define cubeUV_m1 - 1.0
  4359. #define cubeUV_r4 0.4
  4360. #define cubeUV_v4 0.046
  4361. #define cubeUV_m4 2.0
  4362. #define cubeUV_r5 0.305
  4363. #define cubeUV_v5 0.016
  4364. #define cubeUV_m5 3.0
  4365. #define cubeUV_r6 0.21
  4366. #define cubeUV_v6 0.0038
  4367. #define cubeUV_m6 4.0
  4368. float roughnessToMip( float roughness ) {
  4369. float mip = 0.0;
  4370. if ( roughness >= cubeUV_r1 ) {
  4371. mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
  4372. } else if ( roughness >= cubeUV_r4 ) {
  4373. mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
  4374. } else if ( roughness >= cubeUV_r5 ) {
  4375. mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
  4376. } else if ( roughness >= cubeUV_r6 ) {
  4377. mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
  4378. } else {
  4379. mip = - 2.0 * log2( 1.16 * roughness ); }
  4380. return mip;
  4381. }
  4382. vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
  4383. float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
  4384. float mipF = fract( mip );
  4385. float mipInt = floor( mip );
  4386. vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
  4387. if ( mipF == 0.0 ) {
  4388. return vec4( color0, 1.0 );
  4389. } else {
  4390. vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
  4391. return vec4( mix( color0, color1, mipF ), 1.0 );
  4392. }
  4393. }
  4394. #endif`,q5e=`vec3 transformedNormal = objectNormal;
  4395. #ifdef USE_TANGENT
  4396. vec3 transformedTangent = objectTangent;
  4397. #endif
  4398. #ifdef USE_BATCHING
  4399. mat3 bm = mat3( batchingMatrix );
  4400. transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
  4401. transformedNormal = bm * transformedNormal;
  4402. #ifdef USE_TANGENT
  4403. transformedTangent = bm * transformedTangent;
  4404. #endif
  4405. #endif
  4406. #ifdef USE_INSTANCING
  4407. mat3 im = mat3( instanceMatrix );
  4408. transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
  4409. transformedNormal = im * transformedNormal;
  4410. #ifdef USE_TANGENT
  4411. transformedTangent = im * transformedTangent;
  4412. #endif
  4413. #endif
  4414. transformedNormal = normalMatrix * transformedNormal;
  4415. #ifdef FLIP_SIDED
  4416. transformedNormal = - transformedNormal;
  4417. #endif
  4418. #ifdef USE_TANGENT
  4419. transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
  4420. #ifdef FLIP_SIDED
  4421. transformedTangent = - transformedTangent;
  4422. #endif
  4423. #endif`,K5e=`#ifdef USE_DISPLACEMENTMAP
  4424. uniform sampler2D displacementMap;
  4425. uniform float displacementScale;
  4426. uniform float displacementBias;
  4427. #endif`,X5e=`#ifdef USE_DISPLACEMENTMAP
  4428. transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
  4429. #endif`,Y5e=`#ifdef USE_EMISSIVEMAP
  4430. vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
  4431. totalEmissiveRadiance *= emissiveColor.rgb;
  4432. #endif`,Z5e=`#ifdef USE_EMISSIVEMAP
  4433. uniform sampler2D emissiveMap;
  4434. #endif`,Q5e="gl_FragColor = linearToOutputTexel( gl_FragColor );",J5e=`
  4435. const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(
  4436. vec3( 0.8224621, 0.177538, 0.0 ),
  4437. vec3( 0.0331941, 0.9668058, 0.0 ),
  4438. vec3( 0.0170827, 0.0723974, 0.9105199 )
  4439. );
  4440. const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(
  4441. vec3( 1.2249401, - 0.2249404, 0.0 ),
  4442. vec3( - 0.0420569, 1.0420571, 0.0 ),
  4443. vec3( - 0.0196376, - 0.0786361, 1.0982735 )
  4444. );
  4445. vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {
  4446. return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );
  4447. }
  4448. vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {
  4449. return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );
  4450. }
  4451. vec4 LinearTransferOETF( in vec4 value ) {
  4452. return value;
  4453. }
  4454. vec4 sRGBTransferOETF( in vec4 value ) {
  4455. 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 );
  4456. }
  4457. vec4 LinearToLinear( in vec4 value ) {
  4458. return value;
  4459. }
  4460. vec4 LinearTosRGB( in vec4 value ) {
  4461. return sRGBTransferOETF( value );
  4462. }`,eUe=`#ifdef USE_ENVMAP
  4463. #ifdef ENV_WORLDPOS
  4464. vec3 cameraToFrag;
  4465. if ( isOrthographic ) {
  4466. cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  4467. } else {
  4468. cameraToFrag = normalize( vWorldPosition - cameraPosition );
  4469. }
  4470. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  4471. #ifdef ENVMAP_MODE_REFLECTION
  4472. vec3 reflectVec = reflect( cameraToFrag, worldNormal );
  4473. #else
  4474. vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
  4475. #endif
  4476. #else
  4477. vec3 reflectVec = vReflect;
  4478. #endif
  4479. #ifdef ENVMAP_TYPE_CUBE
  4480. vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
  4481. #else
  4482. vec4 envColor = vec4( 0.0 );
  4483. #endif
  4484. #ifdef ENVMAP_BLENDING_MULTIPLY
  4485. outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
  4486. #elif defined( ENVMAP_BLENDING_MIX )
  4487. outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
  4488. #elif defined( ENVMAP_BLENDING_ADD )
  4489. outgoingLight += envColor.xyz * specularStrength * reflectivity;
  4490. #endif
  4491. #endif`,tUe=`#ifdef USE_ENVMAP
  4492. uniform float envMapIntensity;
  4493. uniform float flipEnvMap;
  4494. #ifdef ENVMAP_TYPE_CUBE
  4495. uniform samplerCube envMap;
  4496. #else
  4497. uniform sampler2D envMap;
  4498. #endif
  4499. #endif`,nUe=`#ifdef USE_ENVMAP
  4500. uniform float reflectivity;
  4501. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  4502. #define ENV_WORLDPOS
  4503. #endif
  4504. #ifdef ENV_WORLDPOS
  4505. varying vec3 vWorldPosition;
  4506. uniform float refractionRatio;
  4507. #else
  4508. varying vec3 vReflect;
  4509. #endif
  4510. #endif`,rUe=`#ifdef USE_ENVMAP
  4511. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  4512. #define ENV_WORLDPOS
  4513. #endif
  4514. #ifdef ENV_WORLDPOS
  4515. varying vec3 vWorldPosition;
  4516. #else
  4517. varying vec3 vReflect;
  4518. uniform float refractionRatio;
  4519. #endif
  4520. #endif`,iUe=`#ifdef USE_ENVMAP
  4521. #ifdef ENV_WORLDPOS
  4522. vWorldPosition = worldPosition.xyz;
  4523. #else
  4524. vec3 cameraToVertex;
  4525. if ( isOrthographic ) {
  4526. cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  4527. } else {
  4528. cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
  4529. }
  4530. vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  4531. #ifdef ENVMAP_MODE_REFLECTION
  4532. vReflect = reflect( cameraToVertex, worldNormal );
  4533. #else
  4534. vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
  4535. #endif
  4536. #endif
  4537. #endif`,aUe=`#ifdef USE_FOG
  4538. vFogDepth = - mvPosition.z;
  4539. #endif`,sUe=`#ifdef USE_FOG
  4540. varying float vFogDepth;
  4541. #endif`,oUe=`#ifdef USE_FOG
  4542. #ifdef FOG_EXP2
  4543. float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
  4544. #else
  4545. float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
  4546. #endif
  4547. gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
  4548. #endif`,lUe=`#ifdef USE_FOG
  4549. uniform vec3 fogColor;
  4550. varying float vFogDepth;
  4551. #ifdef FOG_EXP2
  4552. uniform float fogDensity;
  4553. #else
  4554. uniform float fogNear;
  4555. uniform float fogFar;
  4556. #endif
  4557. #endif`,cUe=`#ifdef USE_GRADIENTMAP
  4558. uniform sampler2D gradientMap;
  4559. #endif
  4560. vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
  4561. float dotNL = dot( normal, lightDirection );
  4562. vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
  4563. #ifdef USE_GRADIENTMAP
  4564. return vec3( texture2D( gradientMap, coord ).r );
  4565. #else
  4566. vec2 fw = fwidth( coord ) * 0.5;
  4567. return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
  4568. #endif
  4569. }`,uUe=`#ifdef USE_LIGHTMAP
  4570. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  4571. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  4572. reflectedLight.indirectDiffuse += lightMapIrradiance;
  4573. #endif`,dUe=`#ifdef USE_LIGHTMAP
  4574. uniform sampler2D lightMap;
  4575. uniform float lightMapIntensity;
  4576. #endif`,hUe=`LambertMaterial material;
  4577. material.diffuseColor = diffuseColor.rgb;
  4578. material.specularStrength = specularStrength;`,fUe=`varying vec3 vViewPosition;
  4579. struct LambertMaterial {
  4580. vec3 diffuseColor;
  4581. float specularStrength;
  4582. };
  4583. 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 ) {
  4584. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  4585. vec3 irradiance = dotNL * directLight.color;
  4586. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4587. }
  4588. 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 ) {
  4589. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4590. }
  4591. #define RE_Direct RE_Direct_Lambert
  4592. #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,mUe=`uniform bool receiveShadow;
  4593. uniform vec3 ambientLightColor;
  4594. #if defined( USE_LIGHT_PROBES )
  4595. uniform vec3 lightProbe[ 9 ];
  4596. #endif
  4597. vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
  4598. float x = normal.x, y = normal.y, z = normal.z;
  4599. vec3 result = shCoefficients[ 0 ] * 0.886227;
  4600. result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
  4601. result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
  4602. result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
  4603. result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
  4604. result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
  4605. result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
  4606. result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
  4607. result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
  4608. return result;
  4609. }
  4610. vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
  4611. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  4612. vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
  4613. return irradiance;
  4614. }
  4615. vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
  4616. vec3 irradiance = ambientLightColor;
  4617. return irradiance;
  4618. }
  4619. float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
  4620. #if defined ( LEGACY_LIGHTS )
  4621. if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
  4622. return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );
  4623. }
  4624. return 1.0;
  4625. #else
  4626. float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
  4627. if ( cutoffDistance > 0.0 ) {
  4628. distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
  4629. }
  4630. return distanceFalloff;
  4631. #endif
  4632. }
  4633. float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
  4634. return smoothstep( coneCosine, penumbraCosine, angleCosine );
  4635. }
  4636. #if NUM_DIR_LIGHTS > 0
  4637. struct DirectionalLight {
  4638. vec3 direction;
  4639. vec3 color;
  4640. };
  4641. uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
  4642. void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
  4643. light.color = directionalLight.color;
  4644. light.direction = directionalLight.direction;
  4645. light.visible = true;
  4646. }
  4647. #endif
  4648. #if NUM_POINT_LIGHTS > 0
  4649. struct PointLight {
  4650. vec3 position;
  4651. vec3 color;
  4652. float distance;
  4653. float decay;
  4654. };
  4655. uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
  4656. void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
  4657. vec3 lVector = pointLight.position - geometryPosition;
  4658. light.direction = normalize( lVector );
  4659. float lightDistance = length( lVector );
  4660. light.color = pointLight.color;
  4661. light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
  4662. light.visible = ( light.color != vec3( 0.0 ) );
  4663. }
  4664. #endif
  4665. #if NUM_SPOT_LIGHTS > 0
  4666. struct SpotLight {
  4667. vec3 position;
  4668. vec3 direction;
  4669. vec3 color;
  4670. float distance;
  4671. float decay;
  4672. float coneCos;
  4673. float penumbraCos;
  4674. };
  4675. uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
  4676. void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
  4677. vec3 lVector = spotLight.position - geometryPosition;
  4678. light.direction = normalize( lVector );
  4679. float angleCos = dot( light.direction, spotLight.direction );
  4680. float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
  4681. if ( spotAttenuation > 0.0 ) {
  4682. float lightDistance = length( lVector );
  4683. light.color = spotLight.color * spotAttenuation;
  4684. light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
  4685. light.visible = ( light.color != vec3( 0.0 ) );
  4686. } else {
  4687. light.color = vec3( 0.0 );
  4688. light.visible = false;
  4689. }
  4690. }
  4691. #endif
  4692. #if NUM_RECT_AREA_LIGHTS > 0
  4693. struct RectAreaLight {
  4694. vec3 color;
  4695. vec3 position;
  4696. vec3 halfWidth;
  4697. vec3 halfHeight;
  4698. };
  4699. uniform sampler2D ltc_1; uniform sampler2D ltc_2;
  4700. uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
  4701. #endif
  4702. #if NUM_HEMI_LIGHTS > 0
  4703. struct HemisphereLight {
  4704. vec3 direction;
  4705. vec3 skyColor;
  4706. vec3 groundColor;
  4707. };
  4708. uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
  4709. vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
  4710. float dotNL = dot( normal, hemiLight.direction );
  4711. float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
  4712. vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
  4713. return irradiance;
  4714. }
  4715. #endif`,pUe=`#ifdef USE_ENVMAP
  4716. vec3 getIBLIrradiance( const in vec3 normal ) {
  4717. #ifdef ENVMAP_TYPE_CUBE_UV
  4718. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  4719. vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );
  4720. return PI * envMapColor.rgb * envMapIntensity;
  4721. #else
  4722. return vec3( 0.0 );
  4723. #endif
  4724. }
  4725. vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
  4726. #ifdef ENVMAP_TYPE_CUBE_UV
  4727. vec3 reflectVec = reflect( - viewDir, normal );
  4728. reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
  4729. reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
  4730. vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
  4731. return envMapColor.rgb * envMapIntensity;
  4732. #else
  4733. return vec3( 0.0 );
  4734. #endif
  4735. }
  4736. #ifdef USE_ANISOTROPY
  4737. vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
  4738. #ifdef ENVMAP_TYPE_CUBE_UV
  4739. vec3 bentNormal = cross( bitangent, viewDir );
  4740. bentNormal = normalize( cross( bentNormal, bitangent ) );
  4741. bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
  4742. return getIBLRadiance( viewDir, bentNormal, roughness );
  4743. #else
  4744. return vec3( 0.0 );
  4745. #endif
  4746. }
  4747. #endif
  4748. #endif`,gUe=`ToonMaterial material;
  4749. material.diffuseColor = diffuseColor.rgb;`,xUe=`varying vec3 vViewPosition;
  4750. struct ToonMaterial {
  4751. vec3 diffuseColor;
  4752. };
  4753. 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 ) {
  4754. vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
  4755. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4756. }
  4757. 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 ) {
  4758. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4759. }
  4760. #define RE_Direct RE_Direct_Toon
  4761. #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,bUe=`BlinnPhongMaterial material;
  4762. material.diffuseColor = diffuseColor.rgb;
  4763. material.specularColor = specular;
  4764. material.specularShininess = shininess;
  4765. material.specularStrength = specularStrength;`,yUe=`varying vec3 vViewPosition;
  4766. struct BlinnPhongMaterial {
  4767. vec3 diffuseColor;
  4768. vec3 specularColor;
  4769. float specularShininess;
  4770. float specularStrength;
  4771. };
  4772. 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 ) {
  4773. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  4774. vec3 irradiance = dotNL * directLight.color;
  4775. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4776. reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
  4777. }
  4778. 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 ) {
  4779. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4780. }
  4781. #define RE_Direct RE_Direct_BlinnPhong
  4782. #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,vUe=`PhysicalMaterial material;
  4783. material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
  4784. vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
  4785. float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
  4786. material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
  4787. material.roughness = min( material.roughness, 1.0 );
  4788. #ifdef IOR
  4789. material.ior = ior;
  4790. #ifdef USE_SPECULAR
  4791. float specularIntensityFactor = specularIntensity;
  4792. vec3 specularColorFactor = specularColor;
  4793. #ifdef USE_SPECULAR_COLORMAP
  4794. specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
  4795. #endif
  4796. #ifdef USE_SPECULAR_INTENSITYMAP
  4797. specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
  4798. #endif
  4799. material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
  4800. #else
  4801. float specularIntensityFactor = 1.0;
  4802. vec3 specularColorFactor = vec3( 1.0 );
  4803. material.specularF90 = 1.0;
  4804. #endif
  4805. material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
  4806. #else
  4807. material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
  4808. material.specularF90 = 1.0;
  4809. #endif
  4810. #ifdef USE_CLEARCOAT
  4811. material.clearcoat = clearcoat;
  4812. material.clearcoatRoughness = clearcoatRoughness;
  4813. material.clearcoatF0 = vec3( 0.04 );
  4814. material.clearcoatF90 = 1.0;
  4815. #ifdef USE_CLEARCOATMAP
  4816. material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
  4817. #endif
  4818. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  4819. material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
  4820. #endif
  4821. material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
  4822. material.clearcoatRoughness += geometryRoughness;
  4823. material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
  4824. #endif
  4825. #ifdef USE_IRIDESCENCE
  4826. material.iridescence = iridescence;
  4827. material.iridescenceIOR = iridescenceIOR;
  4828. #ifdef USE_IRIDESCENCEMAP
  4829. material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
  4830. #endif
  4831. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  4832. material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
  4833. #else
  4834. material.iridescenceThickness = iridescenceThicknessMaximum;
  4835. #endif
  4836. #endif
  4837. #ifdef USE_SHEEN
  4838. material.sheenColor = sheenColor;
  4839. #ifdef USE_SHEEN_COLORMAP
  4840. material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
  4841. #endif
  4842. material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
  4843. #ifdef USE_SHEEN_ROUGHNESSMAP
  4844. material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
  4845. #endif
  4846. #endif
  4847. #ifdef USE_ANISOTROPY
  4848. #ifdef USE_ANISOTROPYMAP
  4849. mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
  4850. vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
  4851. vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
  4852. #else
  4853. vec2 anisotropyV = anisotropyVector;
  4854. #endif
  4855. material.anisotropy = length( anisotropyV );
  4856. if( material.anisotropy == 0.0 ) {
  4857. anisotropyV = vec2( 1.0, 0.0 );
  4858. } else {
  4859. anisotropyV /= material.anisotropy;
  4860. material.anisotropy = saturate( material.anisotropy );
  4861. }
  4862. material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
  4863. material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
  4864. material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
  4865. #endif`,_Ue=`struct PhysicalMaterial {
  4866. vec3 diffuseColor;
  4867. float roughness;
  4868. vec3 specularColor;
  4869. float specularF90;
  4870. #ifdef USE_CLEARCOAT
  4871. float clearcoat;
  4872. float clearcoatRoughness;
  4873. vec3 clearcoatF0;
  4874. float clearcoatF90;
  4875. #endif
  4876. #ifdef USE_IRIDESCENCE
  4877. float iridescence;
  4878. float iridescenceIOR;
  4879. float iridescenceThickness;
  4880. vec3 iridescenceFresnel;
  4881. vec3 iridescenceF0;
  4882. #endif
  4883. #ifdef USE_SHEEN
  4884. vec3 sheenColor;
  4885. float sheenRoughness;
  4886. #endif
  4887. #ifdef IOR
  4888. float ior;
  4889. #endif
  4890. #ifdef USE_TRANSMISSION
  4891. float transmission;
  4892. float transmissionAlpha;
  4893. float thickness;
  4894. float attenuationDistance;
  4895. vec3 attenuationColor;
  4896. #endif
  4897. #ifdef USE_ANISOTROPY
  4898. float anisotropy;
  4899. float alphaT;
  4900. vec3 anisotropyT;
  4901. vec3 anisotropyB;
  4902. #endif
  4903. };
  4904. vec3 clearcoatSpecularDirect = vec3( 0.0 );
  4905. vec3 clearcoatSpecularIndirect = vec3( 0.0 );
  4906. vec3 sheenSpecularDirect = vec3( 0.0 );
  4907. vec3 sheenSpecularIndirect = vec3(0.0 );
  4908. vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
  4909. float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
  4910. float x2 = x * x;
  4911. float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
  4912. return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
  4913. }
  4914. float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
  4915. float a2 = pow2( alpha );
  4916. float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
  4917. float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
  4918. return 0.5 / max( gv + gl, EPSILON );
  4919. }
  4920. float D_GGX( const in float alpha, const in float dotNH ) {
  4921. float a2 = pow2( alpha );
  4922. float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
  4923. return RECIPROCAL_PI * a2 / pow2( denom );
  4924. }
  4925. #ifdef USE_ANISOTROPY
  4926. 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 ) {
  4927. float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
  4928. float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
  4929. float v = 0.5 / ( gv + gl );
  4930. return saturate(v);
  4931. }
  4932. float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
  4933. float a2 = alphaT * alphaB;
  4934. highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
  4935. highp float v2 = dot( v, v );
  4936. float w2 = a2 / v2;
  4937. return RECIPROCAL_PI * a2 * pow2 ( w2 );
  4938. }
  4939. #endif
  4940. #ifdef USE_CLEARCOAT
  4941. vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
  4942. vec3 f0 = material.clearcoatF0;
  4943. float f90 = material.clearcoatF90;
  4944. float roughness = material.clearcoatRoughness;
  4945. float alpha = pow2( roughness );
  4946. vec3 halfDir = normalize( lightDir + viewDir );
  4947. float dotNL = saturate( dot( normal, lightDir ) );
  4948. float dotNV = saturate( dot( normal, viewDir ) );
  4949. float dotNH = saturate( dot( normal, halfDir ) );
  4950. float dotVH = saturate( dot( viewDir, halfDir ) );
  4951. vec3 F = F_Schlick( f0, f90, dotVH );
  4952. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  4953. float D = D_GGX( alpha, dotNH );
  4954. return F * ( V * D );
  4955. }
  4956. #endif
  4957. vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
  4958. vec3 f0 = material.specularColor;
  4959. float f90 = material.specularF90;
  4960. float roughness = material.roughness;
  4961. float alpha = pow2( roughness );
  4962. vec3 halfDir = normalize( lightDir + viewDir );
  4963. float dotNL = saturate( dot( normal, lightDir ) );
  4964. float dotNV = saturate( dot( normal, viewDir ) );
  4965. float dotNH = saturate( dot( normal, halfDir ) );
  4966. float dotVH = saturate( dot( viewDir, halfDir ) );
  4967. vec3 F = F_Schlick( f0, f90, dotVH );
  4968. #ifdef USE_IRIDESCENCE
  4969. F = mix( F, material.iridescenceFresnel, material.iridescence );
  4970. #endif
  4971. #ifdef USE_ANISOTROPY
  4972. float dotTL = dot( material.anisotropyT, lightDir );
  4973. float dotTV = dot( material.anisotropyT, viewDir );
  4974. float dotTH = dot( material.anisotropyT, halfDir );
  4975. float dotBL = dot( material.anisotropyB, lightDir );
  4976. float dotBV = dot( material.anisotropyB, viewDir );
  4977. float dotBH = dot( material.anisotropyB, halfDir );
  4978. float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
  4979. float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
  4980. #else
  4981. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  4982. float D = D_GGX( alpha, dotNH );
  4983. #endif
  4984. return F * ( V * D );
  4985. }
  4986. vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
  4987. const float LUT_SIZE = 64.0;
  4988. const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
  4989. const float LUT_BIAS = 0.5 / LUT_SIZE;
  4990. float dotNV = saturate( dot( N, V ) );
  4991. vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
  4992. uv = uv * LUT_SCALE + LUT_BIAS;
  4993. return uv;
  4994. }
  4995. float LTC_ClippedSphereFormFactor( const in vec3 f ) {
  4996. float l = length( f );
  4997. return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
  4998. }
  4999. vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
  5000. float x = dot( v1, v2 );
  5001. float y = abs( x );
  5002. float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
  5003. float b = 3.4175940 + ( 4.1616724 + y ) * y;
  5004. float v = a / b;
  5005. float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
  5006. return cross( v1, v2 ) * theta_sintheta;
  5007. }
  5008. vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
  5009. vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
  5010. vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
  5011. vec3 lightNormal = cross( v1, v2 );
  5012. if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
  5013. vec3 T1, T2;
  5014. T1 = normalize( V - N * dot( V, N ) );
  5015. T2 = - cross( N, T1 );
  5016. mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
  5017. vec3 coords[ 4 ];
  5018. coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
  5019. coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
  5020. coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
  5021. coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
  5022. coords[ 0 ] = normalize( coords[ 0 ] );
  5023. coords[ 1 ] = normalize( coords[ 1 ] );
  5024. coords[ 2 ] = normalize( coords[ 2 ] );
  5025. coords[ 3 ] = normalize( coords[ 3 ] );
  5026. vec3 vectorFormFactor = vec3( 0.0 );
  5027. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
  5028. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
  5029. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
  5030. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
  5031. float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
  5032. return vec3( result );
  5033. }
  5034. #if defined( USE_SHEEN )
  5035. float D_Charlie( float roughness, float dotNH ) {
  5036. float alpha = pow2( roughness );
  5037. float invAlpha = 1.0 / alpha;
  5038. float cos2h = dotNH * dotNH;
  5039. float sin2h = max( 1.0 - cos2h, 0.0078125 );
  5040. return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
  5041. }
  5042. float V_Neubelt( float dotNV, float dotNL ) {
  5043. return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
  5044. }
  5045. vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
  5046. vec3 halfDir = normalize( lightDir + viewDir );
  5047. float dotNL = saturate( dot( normal, lightDir ) );
  5048. float dotNV = saturate( dot( normal, viewDir ) );
  5049. float dotNH = saturate( dot( normal, halfDir ) );
  5050. float D = D_Charlie( sheenRoughness, dotNH );
  5051. float V = V_Neubelt( dotNV, dotNL );
  5052. return sheenColor * ( D * V );
  5053. }
  5054. #endif
  5055. float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  5056. float dotNV = saturate( dot( normal, viewDir ) );
  5057. float r2 = roughness * roughness;
  5058. float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
  5059. float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
  5060. float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
  5061. return saturate( DG * RECIPROCAL_PI );
  5062. }
  5063. vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  5064. float dotNV = saturate( dot( normal, viewDir ) );
  5065. const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
  5066. const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
  5067. vec4 r = roughness * c0 + c1;
  5068. float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
  5069. vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
  5070. return fab;
  5071. }
  5072. vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
  5073. vec2 fab = DFGApprox( normal, viewDir, roughness );
  5074. return specularColor * fab.x + specularF90 * fab.y;
  5075. }
  5076. #ifdef USE_IRIDESCENCE
  5077. 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 ) {
  5078. #else
  5079. 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 ) {
  5080. #endif
  5081. vec2 fab = DFGApprox( normal, viewDir, roughness );
  5082. #ifdef USE_IRIDESCENCE
  5083. vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
  5084. #else
  5085. vec3 Fr = specularColor;
  5086. #endif
  5087. vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
  5088. float Ess = fab.x + fab.y;
  5089. float Ems = 1.0 - Ess;
  5090. vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
  5091. singleScatter += FssEss;
  5092. multiScatter += Fms * Ems;
  5093. }
  5094. #if NUM_RECT_AREA_LIGHTS > 0
  5095. 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 ) {
  5096. vec3 normal = geometryNormal;
  5097. vec3 viewDir = geometryViewDir;
  5098. vec3 position = geometryPosition;
  5099. vec3 lightPos = rectAreaLight.position;
  5100. vec3 halfWidth = rectAreaLight.halfWidth;
  5101. vec3 halfHeight = rectAreaLight.halfHeight;
  5102. vec3 lightColor = rectAreaLight.color;
  5103. float roughness = material.roughness;
  5104. vec3 rectCoords[ 4 ];
  5105. rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
  5106. rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
  5107. rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
  5108. vec2 uv = LTC_Uv( normal, viewDir, roughness );
  5109. vec4 t1 = texture2D( ltc_1, uv );
  5110. vec4 t2 = texture2D( ltc_2, uv );
  5111. mat3 mInv = mat3(
  5112. vec3( t1.x, 0, t1.y ),
  5113. vec3( 0, 1, 0 ),
  5114. vec3( t1.z, 0, t1.w )
  5115. );
  5116. vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
  5117. reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
  5118. reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
  5119. }
  5120. #endif
  5121. 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 ) {
  5122. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  5123. vec3 irradiance = dotNL * directLight.color;
  5124. #ifdef USE_CLEARCOAT
  5125. float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
  5126. vec3 ccIrradiance = dotNLcc * directLight.color;
  5127. clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
  5128. #endif
  5129. #ifdef USE_SHEEN
  5130. sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
  5131. #endif
  5132. reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
  5133. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  5134. }
  5135. 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 ) {
  5136. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  5137. }
  5138. 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) {
  5139. #ifdef USE_CLEARCOAT
  5140. clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
  5141. #endif
  5142. #ifdef USE_SHEEN
  5143. sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
  5144. #endif
  5145. vec3 singleScattering = vec3( 0.0 );
  5146. vec3 multiScattering = vec3( 0.0 );
  5147. vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
  5148. #ifdef USE_IRIDESCENCE
  5149. computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
  5150. #else
  5151. computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
  5152. #endif
  5153. vec3 totalScattering = singleScattering + multiScattering;
  5154. vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
  5155. reflectedLight.indirectSpecular += radiance * singleScattering;
  5156. reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
  5157. reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
  5158. }
  5159. #define RE_Direct RE_Direct_Physical
  5160. #define RE_Direct_RectArea RE_Direct_RectArea_Physical
  5161. #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
  5162. #define RE_IndirectSpecular RE_IndirectSpecular_Physical
  5163. float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
  5164. return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
  5165. }`,wUe=`
  5166. vec3 geometryPosition = - vViewPosition;
  5167. vec3 geometryNormal = normal;
  5168. vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
  5169. vec3 geometryClearcoatNormal = vec3( 0.0 );
  5170. #ifdef USE_CLEARCOAT
  5171. geometryClearcoatNormal = clearcoatNormal;
  5172. #endif
  5173. #ifdef USE_IRIDESCENCE
  5174. float dotNVi = saturate( dot( normal, geometryViewDir ) );
  5175. if ( material.iridescenceThickness == 0.0 ) {
  5176. material.iridescence = 0.0;
  5177. } else {
  5178. material.iridescence = saturate( material.iridescence );
  5179. }
  5180. if ( material.iridescence > 0.0 ) {
  5181. material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
  5182. material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
  5183. }
  5184. #endif
  5185. IncidentLight directLight;
  5186. #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
  5187. PointLight pointLight;
  5188. #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
  5189. PointLightShadow pointLightShadow;
  5190. #endif
  5191. #pragma unroll_loop_start
  5192. for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
  5193. pointLight = pointLights[ i ];
  5194. getPointLightInfo( pointLight, geometryPosition, directLight );
  5195. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
  5196. pointLightShadow = pointLightShadows[ i ];
  5197. directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
  5198. #endif
  5199. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5200. }
  5201. #pragma unroll_loop_end
  5202. #endif
  5203. #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
  5204. SpotLight spotLight;
  5205. vec4 spotColor;
  5206. vec3 spotLightCoord;
  5207. bool inSpotLightMap;
  5208. #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
  5209. SpotLightShadow spotLightShadow;
  5210. #endif
  5211. #pragma unroll_loop_start
  5212. for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
  5213. spotLight = spotLights[ i ];
  5214. getSpotLightInfo( spotLight, geometryPosition, directLight );
  5215. #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  5216. #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
  5217. #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  5218. #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
  5219. #else
  5220. #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  5221. #endif
  5222. #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
  5223. spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
  5224. inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
  5225. spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
  5226. directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
  5227. #endif
  5228. #undef SPOT_LIGHT_MAP_INDEX
  5229. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  5230. spotLightShadow = spotLightShadows[ i ];
  5231. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  5232. #endif
  5233. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5234. }
  5235. #pragma unroll_loop_end
  5236. #endif
  5237. #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
  5238. DirectionalLight directionalLight;
  5239. #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
  5240. DirectionalLightShadow directionalLightShadow;
  5241. #endif
  5242. #pragma unroll_loop_start
  5243. for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
  5244. directionalLight = directionalLights[ i ];
  5245. getDirectionalLightInfo( directionalLight, directLight );
  5246. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
  5247. directionalLightShadow = directionalLightShadows[ i ];
  5248. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  5249. #endif
  5250. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5251. }
  5252. #pragma unroll_loop_end
  5253. #endif
  5254. #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
  5255. RectAreaLight rectAreaLight;
  5256. #pragma unroll_loop_start
  5257. for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
  5258. rectAreaLight = rectAreaLights[ i ];
  5259. RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5260. }
  5261. #pragma unroll_loop_end
  5262. #endif
  5263. #if defined( RE_IndirectDiffuse )
  5264. vec3 iblIrradiance = vec3( 0.0 );
  5265. vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
  5266. #if defined( USE_LIGHT_PROBES )
  5267. irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
  5268. #endif
  5269. #if ( NUM_HEMI_LIGHTS > 0 )
  5270. #pragma unroll_loop_start
  5271. for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
  5272. irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
  5273. }
  5274. #pragma unroll_loop_end
  5275. #endif
  5276. #endif
  5277. #if defined( RE_IndirectSpecular )
  5278. vec3 radiance = vec3( 0.0 );
  5279. vec3 clearcoatRadiance = vec3( 0.0 );
  5280. #endif`,SUe=`#if defined( RE_IndirectDiffuse )
  5281. #ifdef USE_LIGHTMAP
  5282. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  5283. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  5284. irradiance += lightMapIrradiance;
  5285. #endif
  5286. #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
  5287. iblIrradiance += getIBLIrradiance( geometryNormal );
  5288. #endif
  5289. #endif
  5290. #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
  5291. #ifdef USE_ANISOTROPY
  5292. radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
  5293. #else
  5294. radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
  5295. #endif
  5296. #ifdef USE_CLEARCOAT
  5297. clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
  5298. #endif
  5299. #endif`,MUe=`#if defined( RE_IndirectDiffuse )
  5300. RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5301. #endif
  5302. #if defined( RE_IndirectSpecular )
  5303. RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5304. #endif`,EUe=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
  5305. gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
  5306. #endif`,NUe=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
  5307. uniform float logDepthBufFC;
  5308. varying float vFragDepth;
  5309. varying float vIsPerspective;
  5310. #endif`,AUe=`#ifdef USE_LOGDEPTHBUF
  5311. #ifdef USE_LOGDEPTHBUF_EXT
  5312. varying float vFragDepth;
  5313. varying float vIsPerspective;
  5314. #else
  5315. uniform float logDepthBufFC;
  5316. #endif
  5317. #endif`,TUe=`#ifdef USE_LOGDEPTHBUF
  5318. #ifdef USE_LOGDEPTHBUF_EXT
  5319. vFragDepth = 1.0 + gl_Position.w;
  5320. vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
  5321. #else
  5322. if ( isPerspectiveMatrix( projectionMatrix ) ) {
  5323. gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
  5324. gl_Position.z *= gl_Position.w;
  5325. }
  5326. #endif
  5327. #endif`,CUe=`#ifdef USE_MAP
  5328. vec4 sampledDiffuseColor = texture2D( map, vMapUv );
  5329. #ifdef DECODE_VIDEO_TEXTURE
  5330. 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 );
  5331. #endif
  5332. diffuseColor *= sampledDiffuseColor;
  5333. #endif`,kUe=`#ifdef USE_MAP
  5334. uniform sampler2D map;
  5335. #endif`,jUe=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  5336. #if defined( USE_POINTS_UV )
  5337. vec2 uv = vUv;
  5338. #else
  5339. vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
  5340. #endif
  5341. #endif
  5342. #ifdef USE_MAP
  5343. diffuseColor *= texture2D( map, uv );
  5344. #endif
  5345. #ifdef USE_ALPHAMAP
  5346. diffuseColor.a *= texture2D( alphaMap, uv ).g;
  5347. #endif`,PUe=`#if defined( USE_POINTS_UV )
  5348. varying vec2 vUv;
  5349. #else
  5350. #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  5351. uniform mat3 uvTransform;
  5352. #endif
  5353. #endif
  5354. #ifdef USE_MAP
  5355. uniform sampler2D map;
  5356. #endif
  5357. #ifdef USE_ALPHAMAP
  5358. uniform sampler2D alphaMap;
  5359. #endif`,RUe=`float metalnessFactor = metalness;
  5360. #ifdef USE_METALNESSMAP
  5361. vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
  5362. metalnessFactor *= texelMetalness.b;
  5363. #endif`,DUe=`#ifdef USE_METALNESSMAP
  5364. uniform sampler2D metalnessMap;
  5365. #endif`,OUe=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
  5366. vColor *= morphTargetBaseInfluence;
  5367. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  5368. #if defined( USE_COLOR_ALPHA )
  5369. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
  5370. #elif defined( USE_COLOR )
  5371. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
  5372. #endif
  5373. }
  5374. #endif`,LUe=`#ifdef USE_MORPHNORMALS
  5375. objectNormal *= morphTargetBaseInfluence;
  5376. #ifdef MORPHTARGETS_TEXTURE
  5377. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  5378. if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
  5379. }
  5380. #else
  5381. objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
  5382. objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
  5383. objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
  5384. objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
  5385. #endif
  5386. #endif`,IUe=`#ifdef USE_MORPHTARGETS
  5387. uniform float morphTargetBaseInfluence;
  5388. #ifdef MORPHTARGETS_TEXTURE
  5389. uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  5390. uniform sampler2DArray morphTargetsTexture;
  5391. uniform ivec2 morphTargetsTextureSize;
  5392. vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
  5393. int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
  5394. int y = texelIndex / morphTargetsTextureSize.x;
  5395. int x = texelIndex - y * morphTargetsTextureSize.x;
  5396. ivec3 morphUV = ivec3( x, y, morphTargetIndex );
  5397. return texelFetch( morphTargetsTexture, morphUV, 0 );
  5398. }
  5399. #else
  5400. #ifndef USE_MORPHNORMALS
  5401. uniform float morphTargetInfluences[ 8 ];
  5402. #else
  5403. uniform float morphTargetInfluences[ 4 ];
  5404. #endif
  5405. #endif
  5406. #endif`,FUe=`#ifdef USE_MORPHTARGETS
  5407. transformed *= morphTargetBaseInfluence;
  5408. #ifdef MORPHTARGETS_TEXTURE
  5409. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  5410. if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
  5411. }
  5412. #else
  5413. transformed += morphTarget0 * morphTargetInfluences[ 0 ];
  5414. transformed += morphTarget1 * morphTargetInfluences[ 1 ];
  5415. transformed += morphTarget2 * morphTargetInfluences[ 2 ];
  5416. transformed += morphTarget3 * morphTargetInfluences[ 3 ];
  5417. #ifndef USE_MORPHNORMALS
  5418. transformed += morphTarget4 * morphTargetInfluences[ 4 ];
  5419. transformed += morphTarget5 * morphTargetInfluences[ 5 ];
  5420. transformed += morphTarget6 * morphTargetInfluences[ 6 ];
  5421. transformed += morphTarget7 * morphTargetInfluences[ 7 ];
  5422. #endif
  5423. #endif
  5424. #endif`,UUe=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
  5425. #ifdef FLAT_SHADED
  5426. vec3 fdx = dFdx( vViewPosition );
  5427. vec3 fdy = dFdy( vViewPosition );
  5428. vec3 normal = normalize( cross( fdx, fdy ) );
  5429. #else
  5430. vec3 normal = normalize( vNormal );
  5431. #ifdef DOUBLE_SIDED
  5432. normal *= faceDirection;
  5433. #endif
  5434. #endif
  5435. #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
  5436. #ifdef USE_TANGENT
  5437. mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  5438. #else
  5439. mat3 tbn = getTangentFrame( - vViewPosition, normal,
  5440. #if defined( USE_NORMALMAP )
  5441. vNormalMapUv
  5442. #elif defined( USE_CLEARCOAT_NORMALMAP )
  5443. vClearcoatNormalMapUv
  5444. #else
  5445. vUv
  5446. #endif
  5447. );
  5448. #endif
  5449. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  5450. tbn[0] *= faceDirection;
  5451. tbn[1] *= faceDirection;
  5452. #endif
  5453. #endif
  5454. #ifdef USE_CLEARCOAT_NORMALMAP
  5455. #ifdef USE_TANGENT
  5456. mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  5457. #else
  5458. mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
  5459. #endif
  5460. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  5461. tbn2[0] *= faceDirection;
  5462. tbn2[1] *= faceDirection;
  5463. #endif
  5464. #endif
  5465. vec3 nonPerturbedNormal = normal;`,zUe=`#ifdef USE_NORMALMAP_OBJECTSPACE
  5466. normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  5467. #ifdef FLIP_SIDED
  5468. normal = - normal;
  5469. #endif
  5470. #ifdef DOUBLE_SIDED
  5471. normal = normal * faceDirection;
  5472. #endif
  5473. normal = normalize( normalMatrix * normal );
  5474. #elif defined( USE_NORMALMAP_TANGENTSPACE )
  5475. vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  5476. mapN.xy *= normalScale;
  5477. normal = normalize( tbn * mapN );
  5478. #elif defined( USE_BUMPMAP )
  5479. normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
  5480. #endif`,BUe=`#ifndef FLAT_SHADED
  5481. varying vec3 vNormal;
  5482. #ifdef USE_TANGENT
  5483. varying vec3 vTangent;
  5484. varying vec3 vBitangent;
  5485. #endif
  5486. #endif`,$Ue=`#ifndef FLAT_SHADED
  5487. varying vec3 vNormal;
  5488. #ifdef USE_TANGENT
  5489. varying vec3 vTangent;
  5490. varying vec3 vBitangent;
  5491. #endif
  5492. #endif`,HUe=`#ifndef FLAT_SHADED
  5493. vNormal = normalize( transformedNormal );
  5494. #ifdef USE_TANGENT
  5495. vTangent = normalize( transformedTangent );
  5496. vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
  5497. #endif
  5498. #endif`,VUe=`#ifdef USE_NORMALMAP
  5499. uniform sampler2D normalMap;
  5500. uniform vec2 normalScale;
  5501. #endif
  5502. #ifdef USE_NORMALMAP_OBJECTSPACE
  5503. uniform mat3 normalMatrix;
  5504. #endif
  5505. #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
  5506. mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
  5507. vec3 q0 = dFdx( eye_pos.xyz );
  5508. vec3 q1 = dFdy( eye_pos.xyz );
  5509. vec2 st0 = dFdx( uv.st );
  5510. vec2 st1 = dFdy( uv.st );
  5511. vec3 N = surf_norm;
  5512. vec3 q1perp = cross( q1, N );
  5513. vec3 q0perp = cross( N, q0 );
  5514. vec3 T = q1perp * st0.x + q0perp * st1.x;
  5515. vec3 B = q1perp * st0.y + q0perp * st1.y;
  5516. float det = max( dot( T, T ), dot( B, B ) );
  5517. float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
  5518. return mat3( T * scale, B * scale, N );
  5519. }
  5520. #endif`,GUe=`#ifdef USE_CLEARCOAT
  5521. vec3 clearcoatNormal = nonPerturbedNormal;
  5522. #endif`,WUe=`#ifdef USE_CLEARCOAT_NORMALMAP
  5523. vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
  5524. clearcoatMapN.xy *= clearcoatNormalScale;
  5525. clearcoatNormal = normalize( tbn2 * clearcoatMapN );
  5526. #endif`,qUe=`#ifdef USE_CLEARCOATMAP
  5527. uniform sampler2D clearcoatMap;
  5528. #endif
  5529. #ifdef USE_CLEARCOAT_NORMALMAP
  5530. uniform sampler2D clearcoatNormalMap;
  5531. uniform vec2 clearcoatNormalScale;
  5532. #endif
  5533. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  5534. uniform sampler2D clearcoatRoughnessMap;
  5535. #endif`,KUe=`#ifdef USE_IRIDESCENCEMAP
  5536. uniform sampler2D iridescenceMap;
  5537. #endif
  5538. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  5539. uniform sampler2D iridescenceThicknessMap;
  5540. #endif`,XUe=`#ifdef OPAQUE
  5541. diffuseColor.a = 1.0;
  5542. #endif
  5543. #ifdef USE_TRANSMISSION
  5544. diffuseColor.a *= material.transmissionAlpha;
  5545. #endif
  5546. gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,YUe=`vec3 packNormalToRGB( const in vec3 normal ) {
  5547. return normalize( normal ) * 0.5 + 0.5;
  5548. }
  5549. vec3 unpackRGBToNormal( const in vec3 rgb ) {
  5550. return 2.0 * rgb.xyz - 1.0;
  5551. }
  5552. const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
  5553. const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
  5554. const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
  5555. const float ShiftRight8 = 1. / 256.;
  5556. vec4 packDepthToRGBA( const in float v ) {
  5557. vec4 r = vec4( fract( v * PackFactors ), v );
  5558. r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;
  5559. }
  5560. float unpackRGBAToDepth( const in vec4 v ) {
  5561. return dot( v, UnpackFactors );
  5562. }
  5563. vec2 packDepthToRG( in highp float v ) {
  5564. return packDepthToRGBA( v ).yx;
  5565. }
  5566. float unpackRGToDepth( const in highp vec2 v ) {
  5567. return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );
  5568. }
  5569. vec4 pack2HalfToRGBA( vec2 v ) {
  5570. vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
  5571. return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
  5572. }
  5573. vec2 unpackRGBATo2Half( vec4 v ) {
  5574. return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
  5575. }
  5576. float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
  5577. return ( viewZ + near ) / ( near - far );
  5578. }
  5579. float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
  5580. return depth * ( near - far ) - near;
  5581. }
  5582. float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
  5583. return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
  5584. }
  5585. float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
  5586. return ( near * far ) / ( ( far - near ) * depth - far );
  5587. }`,ZUe=`#ifdef PREMULTIPLIED_ALPHA
  5588. gl_FragColor.rgb *= gl_FragColor.a;
  5589. #endif`,QUe=`vec4 mvPosition = vec4( transformed, 1.0 );
  5590. #ifdef USE_BATCHING
  5591. mvPosition = batchingMatrix * mvPosition;
  5592. #endif
  5593. #ifdef USE_INSTANCING
  5594. mvPosition = instanceMatrix * mvPosition;
  5595. #endif
  5596. mvPosition = modelViewMatrix * mvPosition;
  5597. gl_Position = projectionMatrix * mvPosition;`,JUe=`#ifdef DITHERING
  5598. gl_FragColor.rgb = dithering( gl_FragColor.rgb );
  5599. #endif`,eze=`#ifdef DITHERING
  5600. vec3 dithering( vec3 color ) {
  5601. float grid_position = rand( gl_FragCoord.xy );
  5602. vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
  5603. dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
  5604. return color + dither_shift_RGB;
  5605. }
  5606. #endif`,tze=`float roughnessFactor = roughness;
  5607. #ifdef USE_ROUGHNESSMAP
  5608. vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
  5609. roughnessFactor *= texelRoughness.g;
  5610. #endif`,nze=`#ifdef USE_ROUGHNESSMAP
  5611. uniform sampler2D roughnessMap;
  5612. #endif`,rze=`#if NUM_SPOT_LIGHT_COORDS > 0
  5613. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  5614. #endif
  5615. #if NUM_SPOT_LIGHT_MAPS > 0
  5616. uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
  5617. #endif
  5618. #ifdef USE_SHADOWMAP
  5619. #if NUM_DIR_LIGHT_SHADOWS > 0
  5620. uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
  5621. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  5622. struct DirectionalLightShadow {
  5623. float shadowBias;
  5624. float shadowNormalBias;
  5625. float shadowRadius;
  5626. vec2 shadowMapSize;
  5627. };
  5628. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  5629. #endif
  5630. #if NUM_SPOT_LIGHT_SHADOWS > 0
  5631. uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
  5632. struct SpotLightShadow {
  5633. float shadowBias;
  5634. float shadowNormalBias;
  5635. float shadowRadius;
  5636. vec2 shadowMapSize;
  5637. };
  5638. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  5639. #endif
  5640. #if NUM_POINT_LIGHT_SHADOWS > 0
  5641. uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
  5642. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  5643. struct PointLightShadow {
  5644. float shadowBias;
  5645. float shadowNormalBias;
  5646. float shadowRadius;
  5647. vec2 shadowMapSize;
  5648. float shadowCameraNear;
  5649. float shadowCameraFar;
  5650. };
  5651. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  5652. #endif
  5653. float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
  5654. return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
  5655. }
  5656. vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
  5657. return unpackRGBATo2Half( texture2D( shadow, uv ) );
  5658. }
  5659. float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
  5660. float occlusion = 1.0;
  5661. vec2 distribution = texture2DDistribution( shadow, uv );
  5662. float hard_shadow = step( compare , distribution.x );
  5663. if (hard_shadow != 1.0 ) {
  5664. float distance = compare - distribution.x ;
  5665. float variance = max( 0.00000, distribution.y * distribution.y );
  5666. 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 );
  5667. }
  5668. return occlusion;
  5669. }
  5670. float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
  5671. float shadow = 1.0;
  5672. shadowCoord.xyz /= shadowCoord.w;
  5673. shadowCoord.z += shadowBias;
  5674. bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
  5675. bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
  5676. if ( frustumTest ) {
  5677. #if defined( SHADOWMAP_TYPE_PCF )
  5678. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  5679. float dx0 = - texelSize.x * shadowRadius;
  5680. float dy0 = - texelSize.y * shadowRadius;
  5681. float dx1 = + texelSize.x * shadowRadius;
  5682. float dy1 = + texelSize.y * shadowRadius;
  5683. float dx2 = dx0 / 2.0;
  5684. float dy2 = dy0 / 2.0;
  5685. float dx3 = dx1 / 2.0;
  5686. float dy3 = dy1 / 2.0;
  5687. shadow = (
  5688. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
  5689. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
  5690. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
  5691. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
  5692. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
  5693. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
  5694. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
  5695. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
  5696. texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
  5697. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
  5698. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
  5699. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
  5700. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
  5701. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
  5702. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
  5703. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
  5704. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
  5705. ) * ( 1.0 / 17.0 );
  5706. #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
  5707. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  5708. float dx = texelSize.x;
  5709. float dy = texelSize.y;
  5710. vec2 uv = shadowCoord.xy;
  5711. vec2 f = fract( uv * shadowMapSize + 0.5 );
  5712. uv -= f * texelSize;
  5713. shadow = (
  5714. texture2DCompare( shadowMap, uv, shadowCoord.z ) +
  5715. texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
  5716. texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
  5717. texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
  5718. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
  5719. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
  5720. f.x ) +
  5721. mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
  5722. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
  5723. f.x ) +
  5724. mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
  5725. texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
  5726. f.y ) +
  5727. mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
  5728. texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
  5729. f.y ) +
  5730. mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
  5731. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
  5732. f.x ),
  5733. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
  5734. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
  5735. f.x ),
  5736. f.y )
  5737. ) * ( 1.0 / 9.0 );
  5738. #elif defined( SHADOWMAP_TYPE_VSM )
  5739. shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
  5740. #else
  5741. shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
  5742. #endif
  5743. }
  5744. return shadow;
  5745. }
  5746. vec2 cubeToUV( vec3 v, float texelSizeY ) {
  5747. vec3 absV = abs( v );
  5748. float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
  5749. absV *= scaleToCube;
  5750. v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
  5751. vec2 planar = v.xy;
  5752. float almostATexel = 1.5 * texelSizeY;
  5753. float almostOne = 1.0 - almostATexel;
  5754. if ( absV.z >= almostOne ) {
  5755. if ( v.z > 0.0 )
  5756. planar.x = 4.0 - v.x;
  5757. } else if ( absV.x >= almostOne ) {
  5758. float signX = sign( v.x );
  5759. planar.x = v.z * signX + 2.0 * signX;
  5760. } else if ( absV.y >= almostOne ) {
  5761. float signY = sign( v.y );
  5762. planar.x = v.x + 2.0 * signY + 2.0;
  5763. planar.y = v.z * signY - 2.0;
  5764. }
  5765. return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
  5766. }
  5767. float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
  5768. vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
  5769. vec3 lightToPosition = shadowCoord.xyz;
  5770. float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
  5771. vec3 bd3D = normalize( lightToPosition );
  5772. #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
  5773. vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
  5774. return (
  5775. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
  5776. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
  5777. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
  5778. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
  5779. texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
  5780. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
  5781. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
  5782. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
  5783. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
  5784. ) * ( 1.0 / 9.0 );
  5785. #else
  5786. return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
  5787. #endif
  5788. }
  5789. #endif`,ize=`#if NUM_SPOT_LIGHT_COORDS > 0
  5790. uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
  5791. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  5792. #endif
  5793. #ifdef USE_SHADOWMAP
  5794. #if NUM_DIR_LIGHT_SHADOWS > 0
  5795. uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
  5796. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  5797. struct DirectionalLightShadow {
  5798. float shadowBias;
  5799. float shadowNormalBias;
  5800. float shadowRadius;
  5801. vec2 shadowMapSize;
  5802. };
  5803. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  5804. #endif
  5805. #if NUM_SPOT_LIGHT_SHADOWS > 0
  5806. struct SpotLightShadow {
  5807. float shadowBias;
  5808. float shadowNormalBias;
  5809. float shadowRadius;
  5810. vec2 shadowMapSize;
  5811. };
  5812. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  5813. #endif
  5814. #if NUM_POINT_LIGHT_SHADOWS > 0
  5815. uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
  5816. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  5817. struct PointLightShadow {
  5818. float shadowBias;
  5819. float shadowNormalBias;
  5820. float shadowRadius;
  5821. vec2 shadowMapSize;
  5822. float shadowCameraNear;
  5823. float shadowCameraFar;
  5824. };
  5825. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  5826. #endif
  5827. #endif`,aze=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
  5828. vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  5829. vec4 shadowWorldPosition;
  5830. #endif
  5831. #if defined( USE_SHADOWMAP )
  5832. #if NUM_DIR_LIGHT_SHADOWS > 0
  5833. #pragma unroll_loop_start
  5834. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  5835. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
  5836. vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
  5837. }
  5838. #pragma unroll_loop_end
  5839. #endif
  5840. #if NUM_POINT_LIGHT_SHADOWS > 0
  5841. #pragma unroll_loop_start
  5842. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  5843. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
  5844. vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
  5845. }
  5846. #pragma unroll_loop_end
  5847. #endif
  5848. #endif
  5849. #if NUM_SPOT_LIGHT_COORDS > 0
  5850. #pragma unroll_loop_start
  5851. for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
  5852. shadowWorldPosition = worldPosition;
  5853. #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  5854. shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
  5855. #endif
  5856. vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
  5857. }
  5858. #pragma unroll_loop_end
  5859. #endif`,sze=`float getShadowMask() {
  5860. float shadow = 1.0;
  5861. #ifdef USE_SHADOWMAP
  5862. #if NUM_DIR_LIGHT_SHADOWS > 0
  5863. DirectionalLightShadow directionalLight;
  5864. #pragma unroll_loop_start
  5865. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  5866. directionalLight = directionalLightShadows[ i ];
  5867. shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  5868. }
  5869. #pragma unroll_loop_end
  5870. #endif
  5871. #if NUM_SPOT_LIGHT_SHADOWS > 0
  5872. SpotLightShadow spotLight;
  5873. #pragma unroll_loop_start
  5874. for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
  5875. spotLight = spotLightShadows[ i ];
  5876. shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  5877. }
  5878. #pragma unroll_loop_end
  5879. #endif
  5880. #if NUM_POINT_LIGHT_SHADOWS > 0
  5881. PointLightShadow pointLight;
  5882. #pragma unroll_loop_start
  5883. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  5884. pointLight = pointLightShadows[ i ];
  5885. shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
  5886. }
  5887. #pragma unroll_loop_end
  5888. #endif
  5889. #endif
  5890. return shadow;
  5891. }`,oze=`#ifdef USE_SKINNING
  5892. mat4 boneMatX = getBoneMatrix( skinIndex.x );
  5893. mat4 boneMatY = getBoneMatrix( skinIndex.y );
  5894. mat4 boneMatZ = getBoneMatrix( skinIndex.z );
  5895. mat4 boneMatW = getBoneMatrix( skinIndex.w );
  5896. #endif`,lze=`#ifdef USE_SKINNING
  5897. uniform mat4 bindMatrix;
  5898. uniform mat4 bindMatrixInverse;
  5899. uniform highp sampler2D boneTexture;
  5900. mat4 getBoneMatrix( const in float i ) {
  5901. int size = textureSize( boneTexture, 0 ).x;
  5902. int j = int( i ) * 4;
  5903. int x = j % size;
  5904. int y = j / size;
  5905. vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
  5906. vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
  5907. vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
  5908. vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
  5909. return mat4( v1, v2, v3, v4 );
  5910. }
  5911. #endif`,cze=`#ifdef USE_SKINNING
  5912. vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
  5913. vec4 skinned = vec4( 0.0 );
  5914. skinned += boneMatX * skinVertex * skinWeight.x;
  5915. skinned += boneMatY * skinVertex * skinWeight.y;
  5916. skinned += boneMatZ * skinVertex * skinWeight.z;
  5917. skinned += boneMatW * skinVertex * skinWeight.w;
  5918. transformed = ( bindMatrixInverse * skinned ).xyz;
  5919. #endif`,uze=`#ifdef USE_SKINNING
  5920. mat4 skinMatrix = mat4( 0.0 );
  5921. skinMatrix += skinWeight.x * boneMatX;
  5922. skinMatrix += skinWeight.y * boneMatY;
  5923. skinMatrix += skinWeight.z * boneMatZ;
  5924. skinMatrix += skinWeight.w * boneMatW;
  5925. skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
  5926. objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
  5927. #ifdef USE_TANGENT
  5928. objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
  5929. #endif
  5930. #endif`,dze=`float specularStrength;
  5931. #ifdef USE_SPECULARMAP
  5932. vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
  5933. specularStrength = texelSpecular.r;
  5934. #else
  5935. specularStrength = 1.0;
  5936. #endif`,hze=`#ifdef USE_SPECULARMAP
  5937. uniform sampler2D specularMap;
  5938. #endif`,fze=`#if defined( TONE_MAPPING )
  5939. gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
  5940. #endif`,mze=`#ifndef saturate
  5941. #define saturate( a ) clamp( a, 0.0, 1.0 )
  5942. #endif
  5943. uniform float toneMappingExposure;
  5944. vec3 LinearToneMapping( vec3 color ) {
  5945. return saturate( toneMappingExposure * color );
  5946. }
  5947. vec3 ReinhardToneMapping( vec3 color ) {
  5948. color *= toneMappingExposure;
  5949. return saturate( color / ( vec3( 1.0 ) + color ) );
  5950. }
  5951. vec3 OptimizedCineonToneMapping( vec3 color ) {
  5952. color *= toneMappingExposure;
  5953. color = max( vec3( 0.0 ), color - 0.004 );
  5954. return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
  5955. }
  5956. vec3 RRTAndODTFit( vec3 v ) {
  5957. vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
  5958. vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
  5959. return a / b;
  5960. }
  5961. vec3 ACESFilmicToneMapping( vec3 color ) {
  5962. const mat3 ACESInputMat = mat3(
  5963. vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
  5964. vec3( 0.04823, 0.01566, 0.83777 )
  5965. );
  5966. const mat3 ACESOutputMat = mat3(
  5967. vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
  5968. vec3( -0.07367, -0.00605, 1.07602 )
  5969. );
  5970. color *= toneMappingExposure / 0.6;
  5971. color = ACESInputMat * color;
  5972. color = RRTAndODTFit( color );
  5973. color = ACESOutputMat * color;
  5974. return saturate( color );
  5975. }
  5976. vec3 CustomToneMapping( vec3 color ) { return color; }`,pze=`#ifdef USE_TRANSMISSION
  5977. material.transmission = transmission;
  5978. material.transmissionAlpha = 1.0;
  5979. material.thickness = thickness;
  5980. material.attenuationDistance = attenuationDistance;
  5981. material.attenuationColor = attenuationColor;
  5982. #ifdef USE_TRANSMISSIONMAP
  5983. material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
  5984. #endif
  5985. #ifdef USE_THICKNESSMAP
  5986. material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
  5987. #endif
  5988. vec3 pos = vWorldPosition;
  5989. vec3 v = normalize( cameraPosition - pos );
  5990. vec3 n = inverseTransformDirection( normal, viewMatrix );
  5991. vec4 transmitted = getIBLVolumeRefraction(
  5992. n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
  5993. pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,
  5994. material.attenuationColor, material.attenuationDistance );
  5995. material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
  5996. totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
  5997. #endif`,gze=`#ifdef USE_TRANSMISSION
  5998. uniform float transmission;
  5999. uniform float thickness;
  6000. uniform float attenuationDistance;
  6001. uniform vec3 attenuationColor;
  6002. #ifdef USE_TRANSMISSIONMAP
  6003. uniform sampler2D transmissionMap;
  6004. #endif
  6005. #ifdef USE_THICKNESSMAP
  6006. uniform sampler2D thicknessMap;
  6007. #endif
  6008. uniform vec2 transmissionSamplerSize;
  6009. uniform sampler2D transmissionSamplerMap;
  6010. uniform mat4 modelMatrix;
  6011. uniform mat4 projectionMatrix;
  6012. varying vec3 vWorldPosition;
  6013. float w0( float a ) {
  6014. return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
  6015. }
  6016. float w1( float a ) {
  6017. return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
  6018. }
  6019. float w2( float a ){
  6020. return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
  6021. }
  6022. float w3( float a ) {
  6023. return ( 1.0 / 6.0 ) * ( a * a * a );
  6024. }
  6025. float g0( float a ) {
  6026. return w0( a ) + w1( a );
  6027. }
  6028. float g1( float a ) {
  6029. return w2( a ) + w3( a );
  6030. }
  6031. float h0( float a ) {
  6032. return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
  6033. }
  6034. float h1( float a ) {
  6035. return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
  6036. }
  6037. vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
  6038. uv = uv * texelSize.zw + 0.5;
  6039. vec2 iuv = floor( uv );
  6040. vec2 fuv = fract( uv );
  6041. float g0x = g0( fuv.x );
  6042. float g1x = g1( fuv.x );
  6043. float h0x = h0( fuv.x );
  6044. float h1x = h1( fuv.x );
  6045. float h0y = h0( fuv.y );
  6046. float h1y = h1( fuv.y );
  6047. vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  6048. vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  6049. vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  6050. vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  6051. return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
  6052. g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
  6053. }
  6054. vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
  6055. vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
  6056. vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
  6057. vec2 fLodSizeInv = 1.0 / fLodSize;
  6058. vec2 cLodSizeInv = 1.0 / cLodSize;
  6059. vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
  6060. vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
  6061. return mix( fSample, cSample, fract( lod ) );
  6062. }
  6063. vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
  6064. vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
  6065. vec3 modelScale;
  6066. modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
  6067. modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
  6068. modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
  6069. return normalize( refractionVector ) * thickness * modelScale;
  6070. }
  6071. float applyIorToRoughness( const in float roughness, const in float ior ) {
  6072. return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
  6073. }
  6074. vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
  6075. float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
  6076. return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
  6077. }
  6078. vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
  6079. if ( isinf( attenuationDistance ) ) {
  6080. return vec3( 1.0 );
  6081. } else {
  6082. vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
  6083. vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
  6084. }
  6085. }
  6086. vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
  6087. const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
  6088. const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,
  6089. const in vec3 attenuationColor, const in float attenuationDistance ) {
  6090. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
  6091. vec3 refractedRayExit = position + transmissionRay;
  6092. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  6093. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  6094. refractionCoords += 1.0;
  6095. refractionCoords /= 2.0;
  6096. vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
  6097. vec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
  6098. vec3 attenuatedColor = transmittance * transmittedLight.rgb;
  6099. vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
  6100. float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
  6101. return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
  6102. }
  6103. #endif`,xze=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  6104. varying vec2 vUv;
  6105. #endif
  6106. #ifdef USE_MAP
  6107. varying vec2 vMapUv;
  6108. #endif
  6109. #ifdef USE_ALPHAMAP
  6110. varying vec2 vAlphaMapUv;
  6111. #endif
  6112. #ifdef USE_LIGHTMAP
  6113. varying vec2 vLightMapUv;
  6114. #endif
  6115. #ifdef USE_AOMAP
  6116. varying vec2 vAoMapUv;
  6117. #endif
  6118. #ifdef USE_BUMPMAP
  6119. varying vec2 vBumpMapUv;
  6120. #endif
  6121. #ifdef USE_NORMALMAP
  6122. varying vec2 vNormalMapUv;
  6123. #endif
  6124. #ifdef USE_EMISSIVEMAP
  6125. varying vec2 vEmissiveMapUv;
  6126. #endif
  6127. #ifdef USE_METALNESSMAP
  6128. varying vec2 vMetalnessMapUv;
  6129. #endif
  6130. #ifdef USE_ROUGHNESSMAP
  6131. varying vec2 vRoughnessMapUv;
  6132. #endif
  6133. #ifdef USE_ANISOTROPYMAP
  6134. varying vec2 vAnisotropyMapUv;
  6135. #endif
  6136. #ifdef USE_CLEARCOATMAP
  6137. varying vec2 vClearcoatMapUv;
  6138. #endif
  6139. #ifdef USE_CLEARCOAT_NORMALMAP
  6140. varying vec2 vClearcoatNormalMapUv;
  6141. #endif
  6142. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  6143. varying vec2 vClearcoatRoughnessMapUv;
  6144. #endif
  6145. #ifdef USE_IRIDESCENCEMAP
  6146. varying vec2 vIridescenceMapUv;
  6147. #endif
  6148. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  6149. varying vec2 vIridescenceThicknessMapUv;
  6150. #endif
  6151. #ifdef USE_SHEEN_COLORMAP
  6152. varying vec2 vSheenColorMapUv;
  6153. #endif
  6154. #ifdef USE_SHEEN_ROUGHNESSMAP
  6155. varying vec2 vSheenRoughnessMapUv;
  6156. #endif
  6157. #ifdef USE_SPECULARMAP
  6158. varying vec2 vSpecularMapUv;
  6159. #endif
  6160. #ifdef USE_SPECULAR_COLORMAP
  6161. varying vec2 vSpecularColorMapUv;
  6162. #endif
  6163. #ifdef USE_SPECULAR_INTENSITYMAP
  6164. varying vec2 vSpecularIntensityMapUv;
  6165. #endif
  6166. #ifdef USE_TRANSMISSIONMAP
  6167. uniform mat3 transmissionMapTransform;
  6168. varying vec2 vTransmissionMapUv;
  6169. #endif
  6170. #ifdef USE_THICKNESSMAP
  6171. uniform mat3 thicknessMapTransform;
  6172. varying vec2 vThicknessMapUv;
  6173. #endif`,bze=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  6174. varying vec2 vUv;
  6175. #endif
  6176. #ifdef USE_MAP
  6177. uniform mat3 mapTransform;
  6178. varying vec2 vMapUv;
  6179. #endif
  6180. #ifdef USE_ALPHAMAP
  6181. uniform mat3 alphaMapTransform;
  6182. varying vec2 vAlphaMapUv;
  6183. #endif
  6184. #ifdef USE_LIGHTMAP
  6185. uniform mat3 lightMapTransform;
  6186. varying vec2 vLightMapUv;
  6187. #endif
  6188. #ifdef USE_AOMAP
  6189. uniform mat3 aoMapTransform;
  6190. varying vec2 vAoMapUv;
  6191. #endif
  6192. #ifdef USE_BUMPMAP
  6193. uniform mat3 bumpMapTransform;
  6194. varying vec2 vBumpMapUv;
  6195. #endif
  6196. #ifdef USE_NORMALMAP
  6197. uniform mat3 normalMapTransform;
  6198. varying vec2 vNormalMapUv;
  6199. #endif
  6200. #ifdef USE_DISPLACEMENTMAP
  6201. uniform mat3 displacementMapTransform;
  6202. varying vec2 vDisplacementMapUv;
  6203. #endif
  6204. #ifdef USE_EMISSIVEMAP
  6205. uniform mat3 emissiveMapTransform;
  6206. varying vec2 vEmissiveMapUv;
  6207. #endif
  6208. #ifdef USE_METALNESSMAP
  6209. uniform mat3 metalnessMapTransform;
  6210. varying vec2 vMetalnessMapUv;
  6211. #endif
  6212. #ifdef USE_ROUGHNESSMAP
  6213. uniform mat3 roughnessMapTransform;
  6214. varying vec2 vRoughnessMapUv;
  6215. #endif
  6216. #ifdef USE_ANISOTROPYMAP
  6217. uniform mat3 anisotropyMapTransform;
  6218. varying vec2 vAnisotropyMapUv;
  6219. #endif
  6220. #ifdef USE_CLEARCOATMAP
  6221. uniform mat3 clearcoatMapTransform;
  6222. varying vec2 vClearcoatMapUv;
  6223. #endif
  6224. #ifdef USE_CLEARCOAT_NORMALMAP
  6225. uniform mat3 clearcoatNormalMapTransform;
  6226. varying vec2 vClearcoatNormalMapUv;
  6227. #endif
  6228. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  6229. uniform mat3 clearcoatRoughnessMapTransform;
  6230. varying vec2 vClearcoatRoughnessMapUv;
  6231. #endif
  6232. #ifdef USE_SHEEN_COLORMAP
  6233. uniform mat3 sheenColorMapTransform;
  6234. varying vec2 vSheenColorMapUv;
  6235. #endif
  6236. #ifdef USE_SHEEN_ROUGHNESSMAP
  6237. uniform mat3 sheenRoughnessMapTransform;
  6238. varying vec2 vSheenRoughnessMapUv;
  6239. #endif
  6240. #ifdef USE_IRIDESCENCEMAP
  6241. uniform mat3 iridescenceMapTransform;
  6242. varying vec2 vIridescenceMapUv;
  6243. #endif
  6244. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  6245. uniform mat3 iridescenceThicknessMapTransform;
  6246. varying vec2 vIridescenceThicknessMapUv;
  6247. #endif
  6248. #ifdef USE_SPECULARMAP
  6249. uniform mat3 specularMapTransform;
  6250. varying vec2 vSpecularMapUv;
  6251. #endif
  6252. #ifdef USE_SPECULAR_COLORMAP
  6253. uniform mat3 specularColorMapTransform;
  6254. varying vec2 vSpecularColorMapUv;
  6255. #endif
  6256. #ifdef USE_SPECULAR_INTENSITYMAP
  6257. uniform mat3 specularIntensityMapTransform;
  6258. varying vec2 vSpecularIntensityMapUv;
  6259. #endif
  6260. #ifdef USE_TRANSMISSIONMAP
  6261. uniform mat3 transmissionMapTransform;
  6262. varying vec2 vTransmissionMapUv;
  6263. #endif
  6264. #ifdef USE_THICKNESSMAP
  6265. uniform mat3 thicknessMapTransform;
  6266. varying vec2 vThicknessMapUv;
  6267. #endif`,yze=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  6268. vUv = vec3( uv, 1 ).xy;
  6269. #endif
  6270. #ifdef USE_MAP
  6271. vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
  6272. #endif
  6273. #ifdef USE_ALPHAMAP
  6274. vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
  6275. #endif
  6276. #ifdef USE_LIGHTMAP
  6277. vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
  6278. #endif
  6279. #ifdef USE_AOMAP
  6280. vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
  6281. #endif
  6282. #ifdef USE_BUMPMAP
  6283. vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
  6284. #endif
  6285. #ifdef USE_NORMALMAP
  6286. vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
  6287. #endif
  6288. #ifdef USE_DISPLACEMENTMAP
  6289. vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
  6290. #endif
  6291. #ifdef USE_EMISSIVEMAP
  6292. vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
  6293. #endif
  6294. #ifdef USE_METALNESSMAP
  6295. vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
  6296. #endif
  6297. #ifdef USE_ROUGHNESSMAP
  6298. vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
  6299. #endif
  6300. #ifdef USE_ANISOTROPYMAP
  6301. vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
  6302. #endif
  6303. #ifdef USE_CLEARCOATMAP
  6304. vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
  6305. #endif
  6306. #ifdef USE_CLEARCOAT_NORMALMAP
  6307. vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
  6308. #endif
  6309. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  6310. vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
  6311. #endif
  6312. #ifdef USE_IRIDESCENCEMAP
  6313. vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
  6314. #endif
  6315. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  6316. vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
  6317. #endif
  6318. #ifdef USE_SHEEN_COLORMAP
  6319. vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
  6320. #endif
  6321. #ifdef USE_SHEEN_ROUGHNESSMAP
  6322. vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
  6323. #endif
  6324. #ifdef USE_SPECULARMAP
  6325. vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
  6326. #endif
  6327. #ifdef USE_SPECULAR_COLORMAP
  6328. vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
  6329. #endif
  6330. #ifdef USE_SPECULAR_INTENSITYMAP
  6331. vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
  6332. #endif
  6333. #ifdef USE_TRANSMISSIONMAP
  6334. vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
  6335. #endif
  6336. #ifdef USE_THICKNESSMAP
  6337. vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
  6338. #endif`,vze=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
  6339. vec4 worldPosition = vec4( transformed, 1.0 );
  6340. #ifdef USE_BATCHING
  6341. worldPosition = batchingMatrix * worldPosition;
  6342. #endif
  6343. #ifdef USE_INSTANCING
  6344. worldPosition = instanceMatrix * worldPosition;
  6345. #endif
  6346. worldPosition = modelMatrix * worldPosition;
  6347. #endif`;const _ze=`varying vec2 vUv;
  6348. uniform mat3 uvTransform;
  6349. void main() {
  6350. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  6351. gl_Position = vec4( position.xy, 1.0, 1.0 );
  6352. }`,wze=`uniform sampler2D t2D;
  6353. uniform float backgroundIntensity;
  6354. varying vec2 vUv;
  6355. void main() {
  6356. vec4 texColor = texture2D( t2D, vUv );
  6357. #ifdef DECODE_VIDEO_TEXTURE
  6358. 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 );
  6359. #endif
  6360. texColor.rgb *= backgroundIntensity;
  6361. gl_FragColor = texColor;
  6362. #include <tonemapping_fragment>
  6363. #include <colorspace_fragment>
  6364. }`,Sze=`varying vec3 vWorldDirection;
  6365. #include <common>
  6366. void main() {
  6367. vWorldDirection = transformDirection( position, modelMatrix );
  6368. #include <begin_vertex>
  6369. #include <project_vertex>
  6370. gl_Position.z = gl_Position.w;
  6371. }`,Mze=`#ifdef ENVMAP_TYPE_CUBE
  6372. uniform samplerCube envMap;
  6373. #elif defined( ENVMAP_TYPE_CUBE_UV )
  6374. uniform sampler2D envMap;
  6375. #endif
  6376. uniform float flipEnvMap;
  6377. uniform float backgroundBlurriness;
  6378. uniform float backgroundIntensity;
  6379. varying vec3 vWorldDirection;
  6380. #include <cube_uv_reflection_fragment>
  6381. void main() {
  6382. #ifdef ENVMAP_TYPE_CUBE
  6383. vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
  6384. #elif defined( ENVMAP_TYPE_CUBE_UV )
  6385. vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );
  6386. #else
  6387. vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  6388. #endif
  6389. texColor.rgb *= backgroundIntensity;
  6390. gl_FragColor = texColor;
  6391. #include <tonemapping_fragment>
  6392. #include <colorspace_fragment>
  6393. }`,Eze=`varying vec3 vWorldDirection;
  6394. #include <common>
  6395. void main() {
  6396. vWorldDirection = transformDirection( position, modelMatrix );
  6397. #include <begin_vertex>
  6398. #include <project_vertex>
  6399. gl_Position.z = gl_Position.w;
  6400. }`,Nze=`uniform samplerCube tCube;
  6401. uniform float tFlip;
  6402. uniform float opacity;
  6403. varying vec3 vWorldDirection;
  6404. void main() {
  6405. vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
  6406. gl_FragColor = texColor;
  6407. gl_FragColor.a *= opacity;
  6408. #include <tonemapping_fragment>
  6409. #include <colorspace_fragment>
  6410. }`,Aze=`#include <common>
  6411. #include <batching_pars_vertex>
  6412. #include <uv_pars_vertex>
  6413. #include <displacementmap_pars_vertex>
  6414. #include <morphtarget_pars_vertex>
  6415. #include <skinning_pars_vertex>
  6416. #include <logdepthbuf_pars_vertex>
  6417. #include <clipping_planes_pars_vertex>
  6418. varying vec2 vHighPrecisionZW;
  6419. void main() {
  6420. #include <uv_vertex>
  6421. #include <batching_vertex>
  6422. #include <skinbase_vertex>
  6423. #ifdef USE_DISPLACEMENTMAP
  6424. #include <beginnormal_vertex>
  6425. #include <morphnormal_vertex>
  6426. #include <skinnormal_vertex>
  6427. #endif
  6428. #include <begin_vertex>
  6429. #include <morphtarget_vertex>
  6430. #include <skinning_vertex>
  6431. #include <displacementmap_vertex>
  6432. #include <project_vertex>
  6433. #include <logdepthbuf_vertex>
  6434. #include <clipping_planes_vertex>
  6435. vHighPrecisionZW = gl_Position.zw;
  6436. }`,Tze=`#if DEPTH_PACKING == 3200
  6437. uniform float opacity;
  6438. #endif
  6439. #include <common>
  6440. #include <packing>
  6441. #include <uv_pars_fragment>
  6442. #include <map_pars_fragment>
  6443. #include <alphamap_pars_fragment>
  6444. #include <alphatest_pars_fragment>
  6445. #include <alphahash_pars_fragment>
  6446. #include <logdepthbuf_pars_fragment>
  6447. #include <clipping_planes_pars_fragment>
  6448. varying vec2 vHighPrecisionZW;
  6449. void main() {
  6450. #include <clipping_planes_fragment>
  6451. vec4 diffuseColor = vec4( 1.0 );
  6452. #if DEPTH_PACKING == 3200
  6453. diffuseColor.a = opacity;
  6454. #endif
  6455. #include <map_fragment>
  6456. #include <alphamap_fragment>
  6457. #include <alphatest_fragment>
  6458. #include <alphahash_fragment>
  6459. #include <logdepthbuf_fragment>
  6460. float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
  6461. #if DEPTH_PACKING == 3200
  6462. gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
  6463. #elif DEPTH_PACKING == 3201
  6464. gl_FragColor = packDepthToRGBA( fragCoordZ );
  6465. #endif
  6466. }`,Cze=`#define DISTANCE
  6467. varying vec3 vWorldPosition;
  6468. #include <common>
  6469. #include <batching_pars_vertex>
  6470. #include <uv_pars_vertex>
  6471. #include <displacementmap_pars_vertex>
  6472. #include <morphtarget_pars_vertex>
  6473. #include <skinning_pars_vertex>
  6474. #include <clipping_planes_pars_vertex>
  6475. void main() {
  6476. #include <uv_vertex>
  6477. #include <batching_vertex>
  6478. #include <skinbase_vertex>
  6479. #ifdef USE_DISPLACEMENTMAP
  6480. #include <beginnormal_vertex>
  6481. #include <morphnormal_vertex>
  6482. #include <skinnormal_vertex>
  6483. #endif
  6484. #include <begin_vertex>
  6485. #include <morphtarget_vertex>
  6486. #include <skinning_vertex>
  6487. #include <displacementmap_vertex>
  6488. #include <project_vertex>
  6489. #include <worldpos_vertex>
  6490. #include <clipping_planes_vertex>
  6491. vWorldPosition = worldPosition.xyz;
  6492. }`,kze=`#define DISTANCE
  6493. uniform vec3 referencePosition;
  6494. uniform float nearDistance;
  6495. uniform float farDistance;
  6496. varying vec3 vWorldPosition;
  6497. #include <common>
  6498. #include <packing>
  6499. #include <uv_pars_fragment>
  6500. #include <map_pars_fragment>
  6501. #include <alphamap_pars_fragment>
  6502. #include <alphatest_pars_fragment>
  6503. #include <alphahash_pars_fragment>
  6504. #include <clipping_planes_pars_fragment>
  6505. void main () {
  6506. #include <clipping_planes_fragment>
  6507. vec4 diffuseColor = vec4( 1.0 );
  6508. #include <map_fragment>
  6509. #include <alphamap_fragment>
  6510. #include <alphatest_fragment>
  6511. #include <alphahash_fragment>
  6512. float dist = length( vWorldPosition - referencePosition );
  6513. dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
  6514. dist = saturate( dist );
  6515. gl_FragColor = packDepthToRGBA( dist );
  6516. }`,jze=`varying vec3 vWorldDirection;
  6517. #include <common>
  6518. void main() {
  6519. vWorldDirection = transformDirection( position, modelMatrix );
  6520. #include <begin_vertex>
  6521. #include <project_vertex>
  6522. }`,Pze=`uniform sampler2D tEquirect;
  6523. varying vec3 vWorldDirection;
  6524. #include <common>
  6525. void main() {
  6526. vec3 direction = normalize( vWorldDirection );
  6527. vec2 sampleUV = equirectUv( direction );
  6528. gl_FragColor = texture2D( tEquirect, sampleUV );
  6529. #include <tonemapping_fragment>
  6530. #include <colorspace_fragment>
  6531. }`,Rze=`uniform float scale;
  6532. attribute float lineDistance;
  6533. varying float vLineDistance;
  6534. #include <common>
  6535. #include <uv_pars_vertex>
  6536. #include <color_pars_vertex>
  6537. #include <fog_pars_vertex>
  6538. #include <morphtarget_pars_vertex>
  6539. #include <logdepthbuf_pars_vertex>
  6540. #include <clipping_planes_pars_vertex>
  6541. void main() {
  6542. vLineDistance = scale * lineDistance;
  6543. #include <uv_vertex>
  6544. #include <color_vertex>
  6545. #include <morphcolor_vertex>
  6546. #include <begin_vertex>
  6547. #include <morphtarget_vertex>
  6548. #include <project_vertex>
  6549. #include <logdepthbuf_vertex>
  6550. #include <clipping_planes_vertex>
  6551. #include <fog_vertex>
  6552. }`,Dze=`uniform vec3 diffuse;
  6553. uniform float opacity;
  6554. uniform float dashSize;
  6555. uniform float totalSize;
  6556. varying float vLineDistance;
  6557. #include <common>
  6558. #include <color_pars_fragment>
  6559. #include <uv_pars_fragment>
  6560. #include <map_pars_fragment>
  6561. #include <fog_pars_fragment>
  6562. #include <logdepthbuf_pars_fragment>
  6563. #include <clipping_planes_pars_fragment>
  6564. void main() {
  6565. #include <clipping_planes_fragment>
  6566. if ( mod( vLineDistance, totalSize ) > dashSize ) {
  6567. discard;
  6568. }
  6569. vec3 outgoingLight = vec3( 0.0 );
  6570. vec4 diffuseColor = vec4( diffuse, opacity );
  6571. #include <logdepthbuf_fragment>
  6572. #include <map_fragment>
  6573. #include <color_fragment>
  6574. outgoingLight = diffuseColor.rgb;
  6575. #include <opaque_fragment>
  6576. #include <tonemapping_fragment>
  6577. #include <colorspace_fragment>
  6578. #include <fog_fragment>
  6579. #include <premultiplied_alpha_fragment>
  6580. }`,Oze=`#include <common>
  6581. #include <batching_pars_vertex>
  6582. #include <uv_pars_vertex>
  6583. #include <envmap_pars_vertex>
  6584. #include <color_pars_vertex>
  6585. #include <fog_pars_vertex>
  6586. #include <morphtarget_pars_vertex>
  6587. #include <skinning_pars_vertex>
  6588. #include <logdepthbuf_pars_vertex>
  6589. #include <clipping_planes_pars_vertex>
  6590. void main() {
  6591. #include <uv_vertex>
  6592. #include <color_vertex>
  6593. #include <morphcolor_vertex>
  6594. #include <batching_vertex>
  6595. #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
  6596. #include <beginnormal_vertex>
  6597. #include <morphnormal_vertex>
  6598. #include <skinbase_vertex>
  6599. #include <skinnormal_vertex>
  6600. #include <defaultnormal_vertex>
  6601. #endif
  6602. #include <begin_vertex>
  6603. #include <morphtarget_vertex>
  6604. #include <skinning_vertex>
  6605. #include <project_vertex>
  6606. #include <logdepthbuf_vertex>
  6607. #include <clipping_planes_vertex>
  6608. #include <worldpos_vertex>
  6609. #include <envmap_vertex>
  6610. #include <fog_vertex>
  6611. }`,Lze=`uniform vec3 diffuse;
  6612. uniform float opacity;
  6613. #ifndef FLAT_SHADED
  6614. varying vec3 vNormal;
  6615. #endif
  6616. #include <common>
  6617. #include <dithering_pars_fragment>
  6618. #include <color_pars_fragment>
  6619. #include <uv_pars_fragment>
  6620. #include <map_pars_fragment>
  6621. #include <alphamap_pars_fragment>
  6622. #include <alphatest_pars_fragment>
  6623. #include <alphahash_pars_fragment>
  6624. #include <aomap_pars_fragment>
  6625. #include <lightmap_pars_fragment>
  6626. #include <envmap_common_pars_fragment>
  6627. #include <envmap_pars_fragment>
  6628. #include <fog_pars_fragment>
  6629. #include <specularmap_pars_fragment>
  6630. #include <logdepthbuf_pars_fragment>
  6631. #include <clipping_planes_pars_fragment>
  6632. void main() {
  6633. #include <clipping_planes_fragment>
  6634. vec4 diffuseColor = vec4( diffuse, opacity );
  6635. #include <logdepthbuf_fragment>
  6636. #include <map_fragment>
  6637. #include <color_fragment>
  6638. #include <alphamap_fragment>
  6639. #include <alphatest_fragment>
  6640. #include <alphahash_fragment>
  6641. #include <specularmap_fragment>
  6642. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6643. #ifdef USE_LIGHTMAP
  6644. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  6645. reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
  6646. #else
  6647. reflectedLight.indirectDiffuse += vec3( 1.0 );
  6648. #endif
  6649. #include <aomap_fragment>
  6650. reflectedLight.indirectDiffuse *= diffuseColor.rgb;
  6651. vec3 outgoingLight = reflectedLight.indirectDiffuse;
  6652. #include <envmap_fragment>
  6653. #include <opaque_fragment>
  6654. #include <tonemapping_fragment>
  6655. #include <colorspace_fragment>
  6656. #include <fog_fragment>
  6657. #include <premultiplied_alpha_fragment>
  6658. #include <dithering_fragment>
  6659. }`,Ize=`#define LAMBERT
  6660. varying vec3 vViewPosition;
  6661. #include <common>
  6662. #include <batching_pars_vertex>
  6663. #include <uv_pars_vertex>
  6664. #include <displacementmap_pars_vertex>
  6665. #include <envmap_pars_vertex>
  6666. #include <color_pars_vertex>
  6667. #include <fog_pars_vertex>
  6668. #include <normal_pars_vertex>
  6669. #include <morphtarget_pars_vertex>
  6670. #include <skinning_pars_vertex>
  6671. #include <shadowmap_pars_vertex>
  6672. #include <logdepthbuf_pars_vertex>
  6673. #include <clipping_planes_pars_vertex>
  6674. void main() {
  6675. #include <uv_vertex>
  6676. #include <color_vertex>
  6677. #include <morphcolor_vertex>
  6678. #include <batching_vertex>
  6679. #include <beginnormal_vertex>
  6680. #include <morphnormal_vertex>
  6681. #include <skinbase_vertex>
  6682. #include <skinnormal_vertex>
  6683. #include <defaultnormal_vertex>
  6684. #include <normal_vertex>
  6685. #include <begin_vertex>
  6686. #include <morphtarget_vertex>
  6687. #include <skinning_vertex>
  6688. #include <displacementmap_vertex>
  6689. #include <project_vertex>
  6690. #include <logdepthbuf_vertex>
  6691. #include <clipping_planes_vertex>
  6692. vViewPosition = - mvPosition.xyz;
  6693. #include <worldpos_vertex>
  6694. #include <envmap_vertex>
  6695. #include <shadowmap_vertex>
  6696. #include <fog_vertex>
  6697. }`,Fze=`#define LAMBERT
  6698. uniform vec3 diffuse;
  6699. uniform vec3 emissive;
  6700. uniform float opacity;
  6701. #include <common>
  6702. #include <packing>
  6703. #include <dithering_pars_fragment>
  6704. #include <color_pars_fragment>
  6705. #include <uv_pars_fragment>
  6706. #include <map_pars_fragment>
  6707. #include <alphamap_pars_fragment>
  6708. #include <alphatest_pars_fragment>
  6709. #include <alphahash_pars_fragment>
  6710. #include <aomap_pars_fragment>
  6711. #include <lightmap_pars_fragment>
  6712. #include <emissivemap_pars_fragment>
  6713. #include <envmap_common_pars_fragment>
  6714. #include <envmap_pars_fragment>
  6715. #include <fog_pars_fragment>
  6716. #include <bsdfs>
  6717. #include <lights_pars_begin>
  6718. #include <normal_pars_fragment>
  6719. #include <lights_lambert_pars_fragment>
  6720. #include <shadowmap_pars_fragment>
  6721. #include <bumpmap_pars_fragment>
  6722. #include <normalmap_pars_fragment>
  6723. #include <specularmap_pars_fragment>
  6724. #include <logdepthbuf_pars_fragment>
  6725. #include <clipping_planes_pars_fragment>
  6726. void main() {
  6727. #include <clipping_planes_fragment>
  6728. vec4 diffuseColor = vec4( diffuse, opacity );
  6729. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6730. vec3 totalEmissiveRadiance = emissive;
  6731. #include <logdepthbuf_fragment>
  6732. #include <map_fragment>
  6733. #include <color_fragment>
  6734. #include <alphamap_fragment>
  6735. #include <alphatest_fragment>
  6736. #include <alphahash_fragment>
  6737. #include <specularmap_fragment>
  6738. #include <normal_fragment_begin>
  6739. #include <normal_fragment_maps>
  6740. #include <emissivemap_fragment>
  6741. #include <lights_lambert_fragment>
  6742. #include <lights_fragment_begin>
  6743. #include <lights_fragment_maps>
  6744. #include <lights_fragment_end>
  6745. #include <aomap_fragment>
  6746. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  6747. #include <envmap_fragment>
  6748. #include <opaque_fragment>
  6749. #include <tonemapping_fragment>
  6750. #include <colorspace_fragment>
  6751. #include <fog_fragment>
  6752. #include <premultiplied_alpha_fragment>
  6753. #include <dithering_fragment>
  6754. }`,Uze=`#define MATCAP
  6755. varying vec3 vViewPosition;
  6756. #include <common>
  6757. #include <batching_pars_vertex>
  6758. #include <uv_pars_vertex>
  6759. #include <color_pars_vertex>
  6760. #include <displacementmap_pars_vertex>
  6761. #include <fog_pars_vertex>
  6762. #include <normal_pars_vertex>
  6763. #include <morphtarget_pars_vertex>
  6764. #include <skinning_pars_vertex>
  6765. #include <logdepthbuf_pars_vertex>
  6766. #include <clipping_planes_pars_vertex>
  6767. void main() {
  6768. #include <uv_vertex>
  6769. #include <color_vertex>
  6770. #include <morphcolor_vertex>
  6771. #include <batching_vertex>
  6772. #include <beginnormal_vertex>
  6773. #include <morphnormal_vertex>
  6774. #include <skinbase_vertex>
  6775. #include <skinnormal_vertex>
  6776. #include <defaultnormal_vertex>
  6777. #include <normal_vertex>
  6778. #include <begin_vertex>
  6779. #include <morphtarget_vertex>
  6780. #include <skinning_vertex>
  6781. #include <displacementmap_vertex>
  6782. #include <project_vertex>
  6783. #include <logdepthbuf_vertex>
  6784. #include <clipping_planes_vertex>
  6785. #include <fog_vertex>
  6786. vViewPosition = - mvPosition.xyz;
  6787. }`,zze=`#define MATCAP
  6788. uniform vec3 diffuse;
  6789. uniform float opacity;
  6790. uniform sampler2D matcap;
  6791. varying vec3 vViewPosition;
  6792. #include <common>
  6793. #include <dithering_pars_fragment>
  6794. #include <color_pars_fragment>
  6795. #include <uv_pars_fragment>
  6796. #include <map_pars_fragment>
  6797. #include <alphamap_pars_fragment>
  6798. #include <alphatest_pars_fragment>
  6799. #include <alphahash_pars_fragment>
  6800. #include <fog_pars_fragment>
  6801. #include <normal_pars_fragment>
  6802. #include <bumpmap_pars_fragment>
  6803. #include <normalmap_pars_fragment>
  6804. #include <logdepthbuf_pars_fragment>
  6805. #include <clipping_planes_pars_fragment>
  6806. void main() {
  6807. #include <clipping_planes_fragment>
  6808. vec4 diffuseColor = vec4( diffuse, opacity );
  6809. #include <logdepthbuf_fragment>
  6810. #include <map_fragment>
  6811. #include <color_fragment>
  6812. #include <alphamap_fragment>
  6813. #include <alphatest_fragment>
  6814. #include <alphahash_fragment>
  6815. #include <normal_fragment_begin>
  6816. #include <normal_fragment_maps>
  6817. vec3 viewDir = normalize( vViewPosition );
  6818. vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
  6819. vec3 y = cross( viewDir, x );
  6820. vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
  6821. #ifdef USE_MATCAP
  6822. vec4 matcapColor = texture2D( matcap, uv );
  6823. #else
  6824. vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
  6825. #endif
  6826. vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
  6827. #include <opaque_fragment>
  6828. #include <tonemapping_fragment>
  6829. #include <colorspace_fragment>
  6830. #include <fog_fragment>
  6831. #include <premultiplied_alpha_fragment>
  6832. #include <dithering_fragment>
  6833. }`,Bze=`#define NORMAL
  6834. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  6835. varying vec3 vViewPosition;
  6836. #endif
  6837. #include <common>
  6838. #include <batching_pars_vertex>
  6839. #include <uv_pars_vertex>
  6840. #include <displacementmap_pars_vertex>
  6841. #include <normal_pars_vertex>
  6842. #include <morphtarget_pars_vertex>
  6843. #include <skinning_pars_vertex>
  6844. #include <logdepthbuf_pars_vertex>
  6845. #include <clipping_planes_pars_vertex>
  6846. void main() {
  6847. #include <uv_vertex>
  6848. #include <batching_vertex>
  6849. #include <beginnormal_vertex>
  6850. #include <morphnormal_vertex>
  6851. #include <skinbase_vertex>
  6852. #include <skinnormal_vertex>
  6853. #include <defaultnormal_vertex>
  6854. #include <normal_vertex>
  6855. #include <begin_vertex>
  6856. #include <morphtarget_vertex>
  6857. #include <skinning_vertex>
  6858. #include <displacementmap_vertex>
  6859. #include <project_vertex>
  6860. #include <logdepthbuf_vertex>
  6861. #include <clipping_planes_vertex>
  6862. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  6863. vViewPosition = - mvPosition.xyz;
  6864. #endif
  6865. }`,$ze=`#define NORMAL
  6866. uniform float opacity;
  6867. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  6868. varying vec3 vViewPosition;
  6869. #endif
  6870. #include <packing>
  6871. #include <uv_pars_fragment>
  6872. #include <normal_pars_fragment>
  6873. #include <bumpmap_pars_fragment>
  6874. #include <normalmap_pars_fragment>
  6875. #include <logdepthbuf_pars_fragment>
  6876. #include <clipping_planes_pars_fragment>
  6877. void main() {
  6878. #include <clipping_planes_fragment>
  6879. #include <logdepthbuf_fragment>
  6880. #include <normal_fragment_begin>
  6881. #include <normal_fragment_maps>
  6882. gl_FragColor = vec4( packNormalToRGB( normal ), opacity );
  6883. #ifdef OPAQUE
  6884. gl_FragColor.a = 1.0;
  6885. #endif
  6886. }`,Hze=`#define PHONG
  6887. varying vec3 vViewPosition;
  6888. #include <common>
  6889. #include <batching_pars_vertex>
  6890. #include <uv_pars_vertex>
  6891. #include <displacementmap_pars_vertex>
  6892. #include <envmap_pars_vertex>
  6893. #include <color_pars_vertex>
  6894. #include <fog_pars_vertex>
  6895. #include <normal_pars_vertex>
  6896. #include <morphtarget_pars_vertex>
  6897. #include <skinning_pars_vertex>
  6898. #include <shadowmap_pars_vertex>
  6899. #include <logdepthbuf_pars_vertex>
  6900. #include <clipping_planes_pars_vertex>
  6901. void main() {
  6902. #include <uv_vertex>
  6903. #include <color_vertex>
  6904. #include <morphcolor_vertex>
  6905. #include <batching_vertex>
  6906. #include <beginnormal_vertex>
  6907. #include <morphnormal_vertex>
  6908. #include <skinbase_vertex>
  6909. #include <skinnormal_vertex>
  6910. #include <defaultnormal_vertex>
  6911. #include <normal_vertex>
  6912. #include <begin_vertex>
  6913. #include <morphtarget_vertex>
  6914. #include <skinning_vertex>
  6915. #include <displacementmap_vertex>
  6916. #include <project_vertex>
  6917. #include <logdepthbuf_vertex>
  6918. #include <clipping_planes_vertex>
  6919. vViewPosition = - mvPosition.xyz;
  6920. #include <worldpos_vertex>
  6921. #include <envmap_vertex>
  6922. #include <shadowmap_vertex>
  6923. #include <fog_vertex>
  6924. }`,Vze=`#define PHONG
  6925. uniform vec3 diffuse;
  6926. uniform vec3 emissive;
  6927. uniform vec3 specular;
  6928. uniform float shininess;
  6929. uniform float opacity;
  6930. #include <common>
  6931. #include <packing>
  6932. #include <dithering_pars_fragment>
  6933. #include <color_pars_fragment>
  6934. #include <uv_pars_fragment>
  6935. #include <map_pars_fragment>
  6936. #include <alphamap_pars_fragment>
  6937. #include <alphatest_pars_fragment>
  6938. #include <alphahash_pars_fragment>
  6939. #include <aomap_pars_fragment>
  6940. #include <lightmap_pars_fragment>
  6941. #include <emissivemap_pars_fragment>
  6942. #include <envmap_common_pars_fragment>
  6943. #include <envmap_pars_fragment>
  6944. #include <fog_pars_fragment>
  6945. #include <bsdfs>
  6946. #include <lights_pars_begin>
  6947. #include <normal_pars_fragment>
  6948. #include <lights_phong_pars_fragment>
  6949. #include <shadowmap_pars_fragment>
  6950. #include <bumpmap_pars_fragment>
  6951. #include <normalmap_pars_fragment>
  6952. #include <specularmap_pars_fragment>
  6953. #include <logdepthbuf_pars_fragment>
  6954. #include <clipping_planes_pars_fragment>
  6955. void main() {
  6956. #include <clipping_planes_fragment>
  6957. vec4 diffuseColor = vec4( diffuse, opacity );
  6958. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6959. vec3 totalEmissiveRadiance = emissive;
  6960. #include <logdepthbuf_fragment>
  6961. #include <map_fragment>
  6962. #include <color_fragment>
  6963. #include <alphamap_fragment>
  6964. #include <alphatest_fragment>
  6965. #include <alphahash_fragment>
  6966. #include <specularmap_fragment>
  6967. #include <normal_fragment_begin>
  6968. #include <normal_fragment_maps>
  6969. #include <emissivemap_fragment>
  6970. #include <lights_phong_fragment>
  6971. #include <lights_fragment_begin>
  6972. #include <lights_fragment_maps>
  6973. #include <lights_fragment_end>
  6974. #include <aomap_fragment>
  6975. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
  6976. #include <envmap_fragment>
  6977. #include <opaque_fragment>
  6978. #include <tonemapping_fragment>
  6979. #include <colorspace_fragment>
  6980. #include <fog_fragment>
  6981. #include <premultiplied_alpha_fragment>
  6982. #include <dithering_fragment>
  6983. }`,Gze=`#define STANDARD
  6984. varying vec3 vViewPosition;
  6985. #ifdef USE_TRANSMISSION
  6986. varying vec3 vWorldPosition;
  6987. #endif
  6988. #include <common>
  6989. #include <batching_pars_vertex>
  6990. #include <uv_pars_vertex>
  6991. #include <displacementmap_pars_vertex>
  6992. #include <color_pars_vertex>
  6993. #include <fog_pars_vertex>
  6994. #include <normal_pars_vertex>
  6995. #include <morphtarget_pars_vertex>
  6996. #include <skinning_pars_vertex>
  6997. #include <shadowmap_pars_vertex>
  6998. #include <logdepthbuf_pars_vertex>
  6999. #include <clipping_planes_pars_vertex>
  7000. void main() {
  7001. #include <uv_vertex>
  7002. #include <color_vertex>
  7003. #include <morphcolor_vertex>
  7004. #include <batching_vertex>
  7005. #include <beginnormal_vertex>
  7006. #include <morphnormal_vertex>
  7007. #include <skinbase_vertex>
  7008. #include <skinnormal_vertex>
  7009. #include <defaultnormal_vertex>
  7010. #include <normal_vertex>
  7011. #include <begin_vertex>
  7012. #include <morphtarget_vertex>
  7013. #include <skinning_vertex>
  7014. #include <displacementmap_vertex>
  7015. #include <project_vertex>
  7016. #include <logdepthbuf_vertex>
  7017. #include <clipping_planes_vertex>
  7018. vViewPosition = - mvPosition.xyz;
  7019. #include <worldpos_vertex>
  7020. #include <shadowmap_vertex>
  7021. #include <fog_vertex>
  7022. #ifdef USE_TRANSMISSION
  7023. vWorldPosition = worldPosition.xyz;
  7024. #endif
  7025. }`,Wze=`#define STANDARD
  7026. #ifdef PHYSICAL
  7027. #define IOR
  7028. #define USE_SPECULAR
  7029. #endif
  7030. uniform vec3 diffuse;
  7031. uniform vec3 emissive;
  7032. uniform float roughness;
  7033. uniform float metalness;
  7034. uniform float opacity;
  7035. #ifdef IOR
  7036. uniform float ior;
  7037. #endif
  7038. #ifdef USE_SPECULAR
  7039. uniform float specularIntensity;
  7040. uniform vec3 specularColor;
  7041. #ifdef USE_SPECULAR_COLORMAP
  7042. uniform sampler2D specularColorMap;
  7043. #endif
  7044. #ifdef USE_SPECULAR_INTENSITYMAP
  7045. uniform sampler2D specularIntensityMap;
  7046. #endif
  7047. #endif
  7048. #ifdef USE_CLEARCOAT
  7049. uniform float clearcoat;
  7050. uniform float clearcoatRoughness;
  7051. #endif
  7052. #ifdef USE_IRIDESCENCE
  7053. uniform float iridescence;
  7054. uniform float iridescenceIOR;
  7055. uniform float iridescenceThicknessMinimum;
  7056. uniform float iridescenceThicknessMaximum;
  7057. #endif
  7058. #ifdef USE_SHEEN
  7059. uniform vec3 sheenColor;
  7060. uniform float sheenRoughness;
  7061. #ifdef USE_SHEEN_COLORMAP
  7062. uniform sampler2D sheenColorMap;
  7063. #endif
  7064. #ifdef USE_SHEEN_ROUGHNESSMAP
  7065. uniform sampler2D sheenRoughnessMap;
  7066. #endif
  7067. #endif
  7068. #ifdef USE_ANISOTROPY
  7069. uniform vec2 anisotropyVector;
  7070. #ifdef USE_ANISOTROPYMAP
  7071. uniform sampler2D anisotropyMap;
  7072. #endif
  7073. #endif
  7074. varying vec3 vViewPosition;
  7075. #include <common>
  7076. #include <packing>
  7077. #include <dithering_pars_fragment>
  7078. #include <color_pars_fragment>
  7079. #include <uv_pars_fragment>
  7080. #include <map_pars_fragment>
  7081. #include <alphamap_pars_fragment>
  7082. #include <alphatest_pars_fragment>
  7083. #include <alphahash_pars_fragment>
  7084. #include <aomap_pars_fragment>
  7085. #include <lightmap_pars_fragment>
  7086. #include <emissivemap_pars_fragment>
  7087. #include <iridescence_fragment>
  7088. #include <cube_uv_reflection_fragment>
  7089. #include <envmap_common_pars_fragment>
  7090. #include <envmap_physical_pars_fragment>
  7091. #include <fog_pars_fragment>
  7092. #include <lights_pars_begin>
  7093. #include <normal_pars_fragment>
  7094. #include <lights_physical_pars_fragment>
  7095. #include <transmission_pars_fragment>
  7096. #include <shadowmap_pars_fragment>
  7097. #include <bumpmap_pars_fragment>
  7098. #include <normalmap_pars_fragment>
  7099. #include <clearcoat_pars_fragment>
  7100. #include <iridescence_pars_fragment>
  7101. #include <roughnessmap_pars_fragment>
  7102. #include <metalnessmap_pars_fragment>
  7103. #include <logdepthbuf_pars_fragment>
  7104. #include <clipping_planes_pars_fragment>
  7105. void main() {
  7106. #include <clipping_planes_fragment>
  7107. vec4 diffuseColor = vec4( diffuse, opacity );
  7108. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  7109. vec3 totalEmissiveRadiance = emissive;
  7110. #include <logdepthbuf_fragment>
  7111. #include <map_fragment>
  7112. #include <color_fragment>
  7113. #include <alphamap_fragment>
  7114. #include <alphatest_fragment>
  7115. #include <alphahash_fragment>
  7116. #include <roughnessmap_fragment>
  7117. #include <metalnessmap_fragment>
  7118. #include <normal_fragment_begin>
  7119. #include <normal_fragment_maps>
  7120. #include <clearcoat_normal_fragment_begin>
  7121. #include <clearcoat_normal_fragment_maps>
  7122. #include <emissivemap_fragment>
  7123. #include <lights_physical_fragment>
  7124. #include <lights_fragment_begin>
  7125. #include <lights_fragment_maps>
  7126. #include <lights_fragment_end>
  7127. #include <aomap_fragment>
  7128. vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
  7129. vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
  7130. #include <transmission_fragment>
  7131. vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
  7132. #ifdef USE_SHEEN
  7133. float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
  7134. outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
  7135. #endif
  7136. #ifdef USE_CLEARCOAT
  7137. float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
  7138. vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
  7139. outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
  7140. #endif
  7141. #include <opaque_fragment>
  7142. #include <tonemapping_fragment>
  7143. #include <colorspace_fragment>
  7144. #include <fog_fragment>
  7145. #include <premultiplied_alpha_fragment>
  7146. #include <dithering_fragment>
  7147. }`,qze=`#define TOON
  7148. varying vec3 vViewPosition;
  7149. #include <common>
  7150. #include <batching_pars_vertex>
  7151. #include <uv_pars_vertex>
  7152. #include <displacementmap_pars_vertex>
  7153. #include <color_pars_vertex>
  7154. #include <fog_pars_vertex>
  7155. #include <normal_pars_vertex>
  7156. #include <morphtarget_pars_vertex>
  7157. #include <skinning_pars_vertex>
  7158. #include <shadowmap_pars_vertex>
  7159. #include <logdepthbuf_pars_vertex>
  7160. #include <clipping_planes_pars_vertex>
  7161. void main() {
  7162. #include <uv_vertex>
  7163. #include <color_vertex>
  7164. #include <morphcolor_vertex>
  7165. #include <batching_vertex>
  7166. #include <beginnormal_vertex>
  7167. #include <morphnormal_vertex>
  7168. #include <skinbase_vertex>
  7169. #include <skinnormal_vertex>
  7170. #include <defaultnormal_vertex>
  7171. #include <normal_vertex>
  7172. #include <begin_vertex>
  7173. #include <morphtarget_vertex>
  7174. #include <skinning_vertex>
  7175. #include <displacementmap_vertex>
  7176. #include <project_vertex>
  7177. #include <logdepthbuf_vertex>
  7178. #include <clipping_planes_vertex>
  7179. vViewPosition = - mvPosition.xyz;
  7180. #include <worldpos_vertex>
  7181. #include <shadowmap_vertex>
  7182. #include <fog_vertex>
  7183. }`,Kze=`#define TOON
  7184. uniform vec3 diffuse;
  7185. uniform vec3 emissive;
  7186. uniform float opacity;
  7187. #include <common>
  7188. #include <packing>
  7189. #include <dithering_pars_fragment>
  7190. #include <color_pars_fragment>
  7191. #include <uv_pars_fragment>
  7192. #include <map_pars_fragment>
  7193. #include <alphamap_pars_fragment>
  7194. #include <alphatest_pars_fragment>
  7195. #include <alphahash_pars_fragment>
  7196. #include <aomap_pars_fragment>
  7197. #include <lightmap_pars_fragment>
  7198. #include <emissivemap_pars_fragment>
  7199. #include <gradientmap_pars_fragment>
  7200. #include <fog_pars_fragment>
  7201. #include <bsdfs>
  7202. #include <lights_pars_begin>
  7203. #include <normal_pars_fragment>
  7204. #include <lights_toon_pars_fragment>
  7205. #include <shadowmap_pars_fragment>
  7206. #include <bumpmap_pars_fragment>
  7207. #include <normalmap_pars_fragment>
  7208. #include <logdepthbuf_pars_fragment>
  7209. #include <clipping_planes_pars_fragment>
  7210. void main() {
  7211. #include <clipping_planes_fragment>
  7212. vec4 diffuseColor = vec4( diffuse, opacity );
  7213. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  7214. vec3 totalEmissiveRadiance = emissive;
  7215. #include <logdepthbuf_fragment>
  7216. #include <map_fragment>
  7217. #include <color_fragment>
  7218. #include <alphamap_fragment>
  7219. #include <alphatest_fragment>
  7220. #include <alphahash_fragment>
  7221. #include <normal_fragment_begin>
  7222. #include <normal_fragment_maps>
  7223. #include <emissivemap_fragment>
  7224. #include <lights_toon_fragment>
  7225. #include <lights_fragment_begin>
  7226. #include <lights_fragment_maps>
  7227. #include <lights_fragment_end>
  7228. #include <aomap_fragment>
  7229. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  7230. #include <opaque_fragment>
  7231. #include <tonemapping_fragment>
  7232. #include <colorspace_fragment>
  7233. #include <fog_fragment>
  7234. #include <premultiplied_alpha_fragment>
  7235. #include <dithering_fragment>
  7236. }`,Xze=`uniform float size;
  7237. uniform float scale;
  7238. #include <common>
  7239. #include <color_pars_vertex>
  7240. #include <fog_pars_vertex>
  7241. #include <morphtarget_pars_vertex>
  7242. #include <logdepthbuf_pars_vertex>
  7243. #include <clipping_planes_pars_vertex>
  7244. #ifdef USE_POINTS_UV
  7245. varying vec2 vUv;
  7246. uniform mat3 uvTransform;
  7247. #endif
  7248. void main() {
  7249. #ifdef USE_POINTS_UV
  7250. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  7251. #endif
  7252. #include <color_vertex>
  7253. #include <morphcolor_vertex>
  7254. #include <begin_vertex>
  7255. #include <morphtarget_vertex>
  7256. #include <project_vertex>
  7257. gl_PointSize = size;
  7258. #ifdef USE_SIZEATTENUATION
  7259. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  7260. if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
  7261. #endif
  7262. #include <logdepthbuf_vertex>
  7263. #include <clipping_planes_vertex>
  7264. #include <worldpos_vertex>
  7265. #include <fog_vertex>
  7266. }`,Yze=`uniform vec3 diffuse;
  7267. uniform float opacity;
  7268. #include <common>
  7269. #include <color_pars_fragment>
  7270. #include <map_particle_pars_fragment>
  7271. #include <alphatest_pars_fragment>
  7272. #include <alphahash_pars_fragment>
  7273. #include <fog_pars_fragment>
  7274. #include <logdepthbuf_pars_fragment>
  7275. #include <clipping_planes_pars_fragment>
  7276. void main() {
  7277. #include <clipping_planes_fragment>
  7278. vec3 outgoingLight = vec3( 0.0 );
  7279. vec4 diffuseColor = vec4( diffuse, opacity );
  7280. #include <logdepthbuf_fragment>
  7281. #include <map_particle_fragment>
  7282. #include <color_fragment>
  7283. #include <alphatest_fragment>
  7284. #include <alphahash_fragment>
  7285. outgoingLight = diffuseColor.rgb;
  7286. #include <opaque_fragment>
  7287. #include <tonemapping_fragment>
  7288. #include <colorspace_fragment>
  7289. #include <fog_fragment>
  7290. #include <premultiplied_alpha_fragment>
  7291. }`,Zze=`#include <common>
  7292. #include <batching_pars_vertex>
  7293. #include <fog_pars_vertex>
  7294. #include <morphtarget_pars_vertex>
  7295. #include <skinning_pars_vertex>
  7296. #include <logdepthbuf_pars_vertex>
  7297. #include <shadowmap_pars_vertex>
  7298. void main() {
  7299. #include <batching_vertex>
  7300. #include <beginnormal_vertex>
  7301. #include <morphnormal_vertex>
  7302. #include <skinbase_vertex>
  7303. #include <skinnormal_vertex>
  7304. #include <defaultnormal_vertex>
  7305. #include <begin_vertex>
  7306. #include <morphtarget_vertex>
  7307. #include <skinning_vertex>
  7308. #include <project_vertex>
  7309. #include <logdepthbuf_vertex>
  7310. #include <worldpos_vertex>
  7311. #include <shadowmap_vertex>
  7312. #include <fog_vertex>
  7313. }`,Qze=`uniform vec3 color;
  7314. uniform float opacity;
  7315. #include <common>
  7316. #include <packing>
  7317. #include <fog_pars_fragment>
  7318. #include <bsdfs>
  7319. #include <lights_pars_begin>
  7320. #include <logdepthbuf_pars_fragment>
  7321. #include <shadowmap_pars_fragment>
  7322. #include <shadowmask_pars_fragment>
  7323. void main() {
  7324. #include <logdepthbuf_fragment>
  7325. gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
  7326. #include <tonemapping_fragment>
  7327. #include <colorspace_fragment>
  7328. #include <fog_fragment>
  7329. }`,Jze=`uniform float rotation;
  7330. uniform vec2 center;
  7331. #include <common>
  7332. #include <uv_pars_vertex>
  7333. #include <fog_pars_vertex>
  7334. #include <logdepthbuf_pars_vertex>
  7335. #include <clipping_planes_pars_vertex>
  7336. void main() {
  7337. #include <uv_vertex>
  7338. vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
  7339. vec2 scale;
  7340. scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
  7341. scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
  7342. #ifndef USE_SIZEATTENUATION
  7343. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  7344. if ( isPerspective ) scale *= - mvPosition.z;
  7345. #endif
  7346. vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
  7347. vec2 rotatedPosition;
  7348. rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
  7349. rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
  7350. mvPosition.xy += rotatedPosition;
  7351. gl_Position = projectionMatrix * mvPosition;
  7352. #include <logdepthbuf_vertex>
  7353. #include <clipping_planes_vertex>
  7354. #include <fog_vertex>
  7355. }`,eBe=`uniform vec3 diffuse;
  7356. uniform float opacity;
  7357. #include <common>
  7358. #include <uv_pars_fragment>
  7359. #include <map_pars_fragment>
  7360. #include <alphamap_pars_fragment>
  7361. #include <alphatest_pars_fragment>
  7362. #include <alphahash_pars_fragment>
  7363. #include <fog_pars_fragment>
  7364. #include <logdepthbuf_pars_fragment>
  7365. #include <clipping_planes_pars_fragment>
  7366. void main() {
  7367. #include <clipping_planes_fragment>
  7368. vec3 outgoingLight = vec3( 0.0 );
  7369. vec4 diffuseColor = vec4( diffuse, opacity );
  7370. #include <logdepthbuf_fragment>
  7371. #include <map_fragment>
  7372. #include <alphamap_fragment>
  7373. #include <alphatest_fragment>
  7374. #include <alphahash_fragment>
  7375. outgoingLight = diffuseColor.rgb;
  7376. #include <opaque_fragment>
  7377. #include <tonemapping_fragment>
  7378. #include <colorspace_fragment>
  7379. #include <fog_fragment>
  7380. }`,Sn={alphahash_fragment:w5e,alphahash_pars_fragment:S5e,alphamap_fragment:M5e,alphamap_pars_fragment:E5e,alphatest_fragment:N5e,alphatest_pars_fragment:A5e,aomap_fragment:T5e,aomap_pars_fragment:C5e,batching_pars_vertex:k5e,batching_vertex:j5e,begin_vertex:P5e,beginnormal_vertex:R5e,bsdfs:D5e,iridescence_fragment:O5e,bumpmap_pars_fragment:L5e,clipping_planes_fragment:I5e,clipping_planes_pars_fragment:F5e,clipping_planes_pars_vertex:U5e,clipping_planes_vertex:z5e,color_fragment:B5e,color_pars_fragment:$5e,color_pars_vertex:H5e,color_vertex:V5e,common:G5e,cube_uv_reflection_fragment:W5e,defaultnormal_vertex:q5e,displacementmap_pars_vertex:K5e,displacementmap_vertex:X5e,emissivemap_fragment:Y5e,emissivemap_pars_fragment:Z5e,colorspace_fragment:Q5e,colorspace_pars_fragment:J5e,envmap_fragment:eUe,envmap_common_pars_fragment:tUe,envmap_pars_fragment:nUe,envmap_pars_vertex:rUe,envmap_physical_pars_fragment:pUe,envmap_vertex:iUe,fog_vertex:aUe,fog_pars_vertex:sUe,fog_fragment:oUe,fog_pars_fragment:lUe,gradientmap_pars_fragment:cUe,lightmap_fragment:uUe,lightmap_pars_fragment:dUe,lights_lambert_fragment:hUe,lights_lambert_pars_fragment:fUe,lights_pars_begin:mUe,lights_toon_fragment:gUe,lights_toon_pars_fragment:xUe,lights_phong_fragment:bUe,lights_phong_pars_fragment:yUe,lights_physical_fragment:vUe,lights_physical_pars_fragment:_Ue,lights_fragment_begin:wUe,lights_fragment_maps:SUe,lights_fragment_end:MUe,logdepthbuf_fragment:EUe,logdepthbuf_pars_fragment:NUe,logdepthbuf_pars_vertex:AUe,logdepthbuf_vertex:TUe,map_fragment:CUe,map_pars_fragment:kUe,map_particle_fragment:jUe,map_particle_pars_fragment:PUe,metalnessmap_fragment:RUe,metalnessmap_pars_fragment:DUe,morphcolor_vertex:OUe,morphnormal_vertex:LUe,morphtarget_pars_vertex:IUe,morphtarget_vertex:FUe,normal_fragment_begin:UUe,normal_fragment_maps:zUe,normal_pars_fragment:BUe,normal_pars_vertex:$Ue,normal_vertex:HUe,normalmap_pars_fragment:VUe,clearcoat_normal_fragment_begin:GUe,clearcoat_normal_fragment_maps:WUe,clearcoat_pars_fragment:qUe,iridescence_pars_fragment:KUe,opaque_fragment:XUe,packing:YUe,premultiplied_alpha_fragment:ZUe,project_vertex:QUe,dithering_fragment:JUe,dithering_pars_fragment:eze,roughnessmap_fragment:tze,roughnessmap_pars_fragment:nze,shadowmap_pars_fragment:rze,shadowmap_pars_vertex:ize,shadowmap_vertex:aze,shadowmask_pars_fragment:sze,skinbase_vertex:oze,skinning_pars_vertex:lze,skinning_vertex:cze,skinnormal_vertex:uze,specularmap_fragment:dze,specularmap_pars_fragment:hze,tonemapping_fragment:fze,tonemapping_pars_fragment:mze,transmission_fragment:pze,transmission_pars_fragment:gze,uv_pars_fragment:xze,uv_pars_vertex:bze,uv_vertex:yze,worldpos_vertex:vze,background_vert:_ze,background_frag:wze,backgroundCube_vert:Sze,backgroundCube_frag:Mze,cube_vert:Eze,cube_frag:Nze,depth_vert:Aze,depth_frag:Tze,distanceRGBA_vert:Cze,distanceRGBA_frag:kze,equirect_vert:jze,equirect_frag:Pze,linedashed_vert:Rze,linedashed_frag:Dze,meshbasic_vert:Oze,meshbasic_frag:Lze,meshlambert_vert:Ize,meshlambert_frag:Fze,meshmatcap_vert:Uze,meshmatcap_frag:zze,meshnormal_vert:Bze,meshnormal_frag:$ze,meshphong_vert:Hze,meshphong_frag:Vze,meshphysical_vert:Gze,meshphysical_frag:Wze,meshtoon_vert:qze,meshtoon_frag:Kze,points_vert:Xze,points_frag:Yze,shadow_vert:Zze,shadow_frag:Qze,sprite_vert:Jze,sprite_frag:eBe},Lt={common:{diffuse:{value:new rn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new An},alphaMap:{value:null},alphaMapTransform:{value:new An},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new An}},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 An}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new An}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new An},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new An},normalScale:{value:new mn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new An},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new An}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new An}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new An}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new rn(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 rn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new An},alphaTest:{value:0},uvTransform:{value:new An}},sprite:{diffuse:{value:new rn(16777215)},opacity:{value:1},center:{value:new mn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new An},alphaMap:{value:null},alphaMapTransform:{value:new An},alphaTest:{value:0}}},gs={basic:{uniforms:Ka([Lt.common,Lt.specularmap,Lt.envmap,Lt.aomap,Lt.lightmap,Lt.fog]),vertexShader:Sn.meshbasic_vert,fragmentShader:Sn.meshbasic_frag},lambert:{uniforms:Ka([Lt.common,Lt.specularmap,Lt.envmap,Lt.aomap,Lt.lightmap,Lt.emissivemap,Lt.bumpmap,Lt.normalmap,Lt.displacementmap,Lt.fog,Lt.lights,{emissive:{value:new rn(0)}}]),vertexShader:Sn.meshlambert_vert,fragmentShader:Sn.meshlambert_frag},phong:{uniforms:Ka([Lt.common,Lt.specularmap,Lt.envmap,Lt.aomap,Lt.lightmap,Lt.emissivemap,Lt.bumpmap,Lt.normalmap,Lt.displacementmap,Lt.fog,Lt.lights,{emissive:{value:new rn(0)},specular:{value:new rn(1118481)},shininess:{value:30}}]),vertexShader:Sn.meshphong_vert,fragmentShader:Sn.meshphong_frag},standard:{uniforms:Ka([Lt.common,Lt.envmap,Lt.aomap,Lt.lightmap,Lt.emissivemap,Lt.bumpmap,Lt.normalmap,Lt.displacementmap,Lt.roughnessmap,Lt.metalnessmap,Lt.fog,Lt.lights,{emissive:{value:new rn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Sn.meshphysical_vert,fragmentShader:Sn.meshphysical_frag},toon:{uniforms:Ka([Lt.common,Lt.aomap,Lt.lightmap,Lt.emissivemap,Lt.bumpmap,Lt.normalmap,Lt.displacementmap,Lt.gradientmap,Lt.fog,Lt.lights,{emissive:{value:new rn(0)}}]),vertexShader:Sn.meshtoon_vert,fragmentShader:Sn.meshtoon_frag},matcap:{uniforms:Ka([Lt.common,Lt.bumpmap,Lt.normalmap,Lt.displacementmap,Lt.fog,{matcap:{value:null}}]),vertexShader:Sn.meshmatcap_vert,fragmentShader:Sn.meshmatcap_frag},points:{uniforms:Ka([Lt.points,Lt.fog]),vertexShader:Sn.points_vert,fragmentShader:Sn.points_frag},dashed:{uniforms:Ka([Lt.common,Lt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Sn.linedashed_vert,fragmentShader:Sn.linedashed_frag},depth:{uniforms:Ka([Lt.common,Lt.displacementmap]),vertexShader:Sn.depth_vert,fragmentShader:Sn.depth_frag},normal:{uniforms:Ka([Lt.common,Lt.bumpmap,Lt.normalmap,Lt.displacementmap,{opacity:{value:1}}]),vertexShader:Sn.meshnormal_vert,fragmentShader:Sn.meshnormal_frag},sprite:{uniforms:Ka([Lt.sprite,Lt.fog]),vertexShader:Sn.sprite_vert,fragmentShader:Sn.sprite_frag},background:{uniforms:{uvTransform:{value:new An},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Sn.background_vert,fragmentShader:Sn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:Sn.backgroundCube_vert,fragmentShader:Sn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Sn.cube_vert,fragmentShader:Sn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Sn.equirect_vert,fragmentShader:Sn.equirect_frag},distanceRGBA:{uniforms:Ka([Lt.common,Lt.displacementmap,{referencePosition:{value:new Be},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Sn.distanceRGBA_vert,fragmentShader:Sn.distanceRGBA_frag},shadow:{uniforms:Ka([Lt.lights,Lt.fog,{color:{value:new rn(0)},opacity:{value:1}}]),vertexShader:Sn.shadow_vert,fragmentShader:Sn.shadow_frag}};gs.physical={uniforms:Ka([gs.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new An},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new An},clearcoatNormalScale:{value:new mn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new An},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new An},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new An},sheen:{value:0},sheenColor:{value:new rn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new An},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new An},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new An},transmissionSamplerSize:{value:new mn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new An},attenuationDistance:{value:0},attenuationColor:{value:new rn(0)},specularColor:{value:new rn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new An},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new An},anisotropyVector:{value:new mn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new An}}]),vertexShader:Sn.meshphysical_vert,fragmentShader:Sn.meshphysical_frag};const _1={r:0,b:0,g:0};function tBe(t,e,n,r,i,a,o){const l=new rn(0);let c=a===!0?0:1,u,d,f=null,m=0,p=null;function b(x,y){let S=!1,M=y.isScene===!0?y.background:null;M&&M.isTexture&&(M=(y.backgroundBlurriness>0?n:e).get(M)),M===null?v(l,c):M&&M.isColor&&(v(M,1),S=!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||S)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),M&&(M.isCubeTexture||M.mapping===fN)?(d===void 0&&(d=new tl(new Gy(1,1,1),new nh({name:"BackgroundCubeMaterial",uniforms:Dg(gs.backgroundCube.uniforms),vertexShader:gs.backgroundCube.vertexShader,fragmentShader:gs.backgroundCube.fragmentShader,side:ws,depthTest:!1,depthWrite:!1,fog:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(A,k,C){this.matrixWorld.copyPosition(C.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),d.material.uniforms.envMap.value=M,d.material.uniforms.flipEnvMap.value=M.isCubeTexture&&M.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=y.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,d.material.toneMapped=pr.getTransfer(M.colorSpace)!==Dr,(f!==M||m!==M.version||p!==t.toneMapping)&&(d.material.needsUpdate=!0,f=M,m=M.version,p=t.toneMapping),d.layers.enableAll(),x.unshift(d,d.geometry,d.material,0,0,null)):M&&M.isTexture&&(u===void 0&&(u=new tl(new bL(2,2),new nh({name:"BackgroundMaterial",uniforms:Dg(gs.background.uniforms),vertexShader:gs.background.vertexShader,fragmentShader:gs.background.fragmentShader,side:th,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=M,u.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,u.material.toneMapped=pr.getTransfer(M.colorSpace)!==Dr,M.matrixAutoUpdate===!0&&M.updateMatrix(),u.material.uniforms.uvTransform.value.copy(M.matrix),(f!==M||m!==M.version||p!==t.toneMapping)&&(u.material.needsUpdate=!0,f=M,m=M.version,p=t.toneMapping),u.layers.enableAll(),x.unshift(u,u.geometry,u.material,0,0,null))}function v(x,y){x.getRGB(_1,rte(t)),r.buffers.color.setClear(_1.r,_1.g,_1.b,y,o)}return{getClearColor:function(){return l},setClearColor:function(x,y=1){l.set(x),c=y,v(l,c)},getClearAlpha:function(){return c},setClearAlpha:function(x){c=x,v(l,c)},render:b}}function nBe(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=x(null);let u=c,d=!1;function f(j,W,K,V,J){let ne=!1;if(o){const te=v(V,K,W);u!==te&&(u=te,p(u.object)),ne=y(j,V,K,J),ne&&S(j,V,K,J)}else{const te=W.wireframe===!0;(u.geometry!==V.id||u.program!==K.id||u.wireframe!==te)&&(u.geometry=V.id,u.program=K.id,u.wireframe=te,ne=!0)}J!==null&&n.update(J,t.ELEMENT_ARRAY_BUFFER),(ne||d)&&(d=!1,D(j,W,K,V),J!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n.get(J).buffer))}function m(){return r.isWebGL2?t.createVertexArray():a.createVertexArrayOES()}function p(j){return r.isWebGL2?t.bindVertexArray(j):a.bindVertexArrayOES(j)}function b(j){return r.isWebGL2?t.deleteVertexArray(j):a.deleteVertexArrayOES(j)}function v(j,W,K){const V=K.wireframe===!0;let J=l[j.id];J===void 0&&(J={},l[j.id]=J);let ne=J[W.id];ne===void 0&&(ne={},J[W.id]=ne);let te=ne[V];return te===void 0&&(te=x(m()),ne[V]=te),te}function x(j){const W=[],K=[],V=[];for(let J=0;J<i;J++)W[J]=0,K[J]=0,V[J]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:W,enabledAttributes:K,attributeDivisors:V,object:j,attributes:{},index:null}}function y(j,W,K,V){const J=u.attributes,ne=W.attributes;let te=0;const z=K.getAttributes();for(const H in z)if(z[H].location>=0){const ee=J[H];let he=ne[H];if(he===void 0&&(H==="instanceMatrix"&&j.instanceMatrix&&(he=j.instanceMatrix),H==="instanceColor"&&j.instanceColor&&(he=j.instanceColor)),ee===void 0||ee.attribute!==he||he&&ee.data!==he.data)return!0;te++}return u.attributesNum!==te||u.index!==V}function S(j,W,K,V){const J={},ne=W.attributes;let te=0;const z=K.getAttributes();for(const H in z)if(z[H].location>=0){let ee=ne[H];ee===void 0&&(H==="instanceMatrix"&&j.instanceMatrix&&(ee=j.instanceMatrix),H==="instanceColor"&&j.instanceColor&&(ee=j.instanceColor));const he={};he.attribute=ee,ee&&ee.data&&(he.data=ee.data),J[H]=he,te++}u.attributes=J,u.attributesNum=te,u.index=V}function M(){const j=u.newAttributes;for(let W=0,K=j.length;W<K;W++)j[W]=0}function N(j){A(j,0)}function A(j,W){const K=u.newAttributes,V=u.enabledAttributes,J=u.attributeDivisors;K[j]=1,V[j]===0&&(t.enableVertexAttribArray(j),V[j]=1),J[j]!==W&&((r.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](j,W),J[j]=W)}function k(){const j=u.newAttributes,W=u.enabledAttributes;for(let K=0,V=W.length;K<V;K++)W[K]!==j[K]&&(t.disableVertexAttribArray(K),W[K]=0)}function C(j,W,K,V,J,ne,te){te===!0?t.vertexAttribIPointer(j,W,K,J,ne):t.vertexAttribPointer(j,W,K,V,J,ne)}function D(j,W,K,V){if(r.isWebGL2===!1&&(j.isInstancedMesh||V.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;M();const J=V.attributes,ne=K.getAttributes(),te=W.defaultAttributeValues;for(const z in ne){const H=ne[z];if(H.location>=0){let Z=J[z];if(Z===void 0&&(z==="instanceMatrix"&&j.instanceMatrix&&(Z=j.instanceMatrix),z==="instanceColor"&&j.instanceColor&&(Z=j.instanceColor)),Z!==void 0){const ee=Z.normalized,he=Z.itemSize,fe=n.get(Z);if(fe===void 0)continue;const oe=fe.buffer,Ne=fe.type,ge=fe.bytesPerElement,Se=r.isWebGL2===!0&&(Ne===t.INT||Ne===t.UNSIGNED_INT||Z.gpuType===Iee);if(Z.isInterleavedBufferAttribute){const Re=Z.data,de=Re.stride,Qe=Z.offset;if(Re.isInstancedInterleavedBuffer){for(let G=0;G<H.locationSize;G++)A(H.location+G,Re.meshPerAttribute);j.isInstancedMesh!==!0&&V._maxInstanceCount===void 0&&(V._maxInstanceCount=Re.meshPerAttribute*Re.count)}else for(let G=0;G<H.locationSize;G++)N(H.location+G);t.bindBuffer(t.ARRAY_BUFFER,oe);for(let G=0;G<H.locationSize;G++)C(H.location+G,he/H.locationSize,Ne,ee,de*ge,(Qe+he/H.locationSize*G)*ge,Se)}else{if(Z.isInstancedBufferAttribute){for(let Re=0;Re<H.locationSize;Re++)A(H.location+Re,Z.meshPerAttribute);j.isInstancedMesh!==!0&&V._maxInstanceCount===void 0&&(V._maxInstanceCount=Z.meshPerAttribute*Z.count)}else for(let Re=0;Re<H.locationSize;Re++)N(H.location+Re);t.bindBuffer(t.ARRAY_BUFFER,oe);for(let Re=0;Re<H.locationSize;Re++)C(H.location+Re,he/H.locationSize,Ne,ee,he*ge,he/H.locationSize*Re*ge,Se)}}else if(te!==void 0){const ee=te[z];if(ee!==void 0)switch(ee.length){case 2:t.vertexAttrib2fv(H.location,ee);break;case 3:t.vertexAttrib3fv(H.location,ee);break;case 4:t.vertexAttrib4fv(H.location,ee);break;default:t.vertexAttrib1fv(H.location,ee)}}}}k()}function T(){L();for(const j in l){const W=l[j];for(const K in W){const V=W[K];for(const J in V)b(V[J].object),delete V[J];delete W[K]}delete l[j]}}function R(j){if(l[j.id]===void 0)return;const W=l[j.id];for(const K in W){const V=W[K];for(const J in V)b(V[J].object),delete V[J];delete W[K]}delete l[j.id]}function U(j){for(const W in l){const K=l[W];if(K[j.id]===void 0)continue;const V=K[j.id];for(const J in V)b(V[J].object),delete V[J];delete K[j.id]}}function L(){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:L,resetDefaultState:q,dispose:T,releaseStatesOfGeometry:R,releaseStatesOfProgram:U,initAttributes:M,enableAttribute:N,disableUnusedAttributes:k}}function rBe(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,m){if(m===0)return;let p,b;if(i)p=t,b="drawArraysInstanced";else if(p=e.get("ANGLE_instanced_arrays"),b="drawArraysInstancedANGLE",p===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}p[b](a,d,f,m),n.update(f,a,m)}function u(d,f,m){if(m===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let b=0;b<m;b++)this.render(d[b],f[b]);else{p.multiDrawArraysWEBGL(a,d,0,f,0,m);let b=0;for(let v=0;v<m;v++)b+=f[v];n.update(b,a,1)}}this.setMode=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=u}function iBe(t,e,n){let r;function i(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const C=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(C.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(C){if(C==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";C="mediump"}return C==="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),m=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),p=t.getParameter(t.MAX_TEXTURE_SIZE),b=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),v=t.getParameter(t.MAX_VERTEX_ATTRIBS),x=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),y=t.getParameter(t.MAX_VARYING_VECTORS),S=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),M=m>0,N=o||e.has("OES_texture_float"),A=M&&N,k=o?t.getParameter(t.MAX_SAMPLES):0;return{isWebGL2:o,drawBuffers:u,getMaxAnisotropy:i,getMaxPrecision:a,precision:l,logarithmicDepthBuffer:d,maxTextures:f,maxVertexTextures:m,maxTextureSize:p,maxCubemapSize:b,maxAttributes:v,maxVertexUniforms:x,maxVaryings:y,maxFragmentUniforms:S,vertexTextures:M,floatFragmentTextures:N,floatVertexTextures:A,maxSamples:k}}function aBe(t){const e=this;let n=null,r=0,i=!1,a=!1;const o=new bd,l=new An,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,m){const p=f.length!==0||m||r!==0||i;return i=m,r=f.length,p},this.beginShadows=function(){a=!0,d(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(f,m){n=d(f,m,0)},this.setState=function(f,m,p){const b=f.clippingPlanes,v=f.clipIntersection,x=f.clipShadows,y=t.get(f);if(!i||b===null||b.length===0||a&&!x)a?d(null):u();else{const S=a?0:r,M=S*4;let N=y.clippingState||null;c.value=N,N=d(b,m,M,p);for(let A=0;A!==M;++A)N[A]=n[A];y.clippingState=N,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=S}};function u(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function d(f,m,p,b){const v=f!==null?f.length:0;let x=null;if(v!==0){if(x=c.value,b!==!0||x===null){const y=p+v*4,S=m.matrixWorldInverse;l.getNormalMatrix(S),(x===null||x.length<y)&&(x=new Float32Array(y));for(let M=0,N=p;M!==v;++M,N+=4)o.copy(f[M]).applyMatrix4(S,l),o.normal.toArray(x,N),x[N+3]=o.constant}c.value=x,c.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,x}}function sBe(t){let e=new WeakMap;function n(o,l){return l===wR?o.mapping=jg:l===SR&&(o.mapping=Pg),o}function r(o){if(o&&o.isTexture){const l=o.mapping;if(l===wR||l===SR)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 b5e(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 oBe extends ite{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 Xp=4,M7=[.125,.215,.35,.446,.526,.582],nf=20,Yk=new oBe,E7=new rn;let Zk=null,Qk=0,Jk=0;const Qh=(1+Math.sqrt(5))/2,kp=1/Qh,N7=[new Be(1,1,1),new Be(-1,1,1),new Be(1,1,-1),new Be(-1,1,-1),new Be(0,Qh,kp),new Be(0,Qh,-kp),new Be(kp,0,Qh),new Be(-kp,0,Qh),new Be(Qh,kp,0),new Be(-Qh,kp,0)];class A7{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){Zk=this._renderer.getRenderTarget(),Qk=this._renderer.getActiveCubeFace(),Jk=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=k7(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=C7(),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(Zk,Qk,Jk),e.scissorTest=!1,w1(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===jg||e.mapping===Pg?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Zk=this._renderer.getRenderTarget(),Qk=this._renderer.getActiveCubeFace(),Jk=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:Mo,minFilter:Mo,generateMipmaps:!1,type:Z0,format:Eo,colorSpace:_u,depthBuffer:!1},i=T7(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=T7(e,n,r);const{_lodMax:a}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=lBe(a)),this._blurMaterial=cBe(a,e,n)}return i}_compileMaterial(e){const n=new tl(this._lodPlanes[0],e);this._renderer.compile(n,Yk)}_sceneToCubeUV(e,n,r,i){const l=new zs(90,1,n,r),c=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],d=this._renderer,f=d.autoClear,m=d.toneMapping;d.getClearColor(E7),d.toneMapping=$d,d.autoClear=!1;const p=new ete({name:"PMREM.Background",side:ws,depthWrite:!1,depthTest:!1}),b=new tl(new Gy,p);let v=!1;const x=e.background;x?x.isColor&&(p.color.copy(x),e.background=null,v=!0):(p.color.copy(E7),v=!0);for(let y=0;y<6;y++){const S=y%3;S===0?(l.up.set(0,c[y],0),l.lookAt(u[y],0,0)):S===1?(l.up.set(0,0,c[y]),l.lookAt(0,u[y],0)):(l.up.set(0,c[y],0),l.lookAt(0,0,u[y]));const M=this._cubeSize;w1(i,S*M,y>2?M:0,M,M),d.setRenderTarget(i),v&&d.render(b,l),d.render(e,l)}b.geometry.dispose(),b.material.dispose(),d.toneMapping=m,d.autoClear=f,e.background=x}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===jg||e.mapping===Pg;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=k7()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=C7());const a=i?this._cubemapMaterial:this._equirectMaterial,o=new tl(this._lodPlanes[0],a),l=a.uniforms;l.envMap.value=e;const c=this._cubeSize;w1(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(o,Yk)}_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=N7[(i-1)%N7.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 tl(this._lodPlanes[i],u),m=u.uniforms,p=this._sizeLods[r]-1,b=isFinite(a)?Math.PI/(2*p):2*Math.PI/(2*nf-1),v=a/b,x=isFinite(a)?1+Math.floor(d*v):nf;x>nf&&console.warn(`sigmaRadians, ${a}, is too large and will clip, as it requested ${x} samples when the maximum is set to ${nf}`);const y=[];let S=0;for(let C=0;C<nf;++C){const D=C/v,T=Math.exp(-D*D/2);y.push(T),C===0?S+=T:C<x&&(S+=2*T)}for(let C=0;C<y.length;C++)y[C]=y[C]/S;m.envMap.value=e.texture,m.samples.value=x,m.weights.value=y,m.latitudinal.value=o==="latitudinal",l&&(m.poleAxis.value=l);const{_lodMax:M}=this;m.dTheta.value=b,m.mipInt.value=M-r;const N=this._sizeLods[i],A=3*N*(i>M-Xp?i-M+Xp:0),k=4*(this._cubeSize-N);w1(n,A,k,3*N,2*N),c.setRenderTarget(n),c.render(f,Yk)}}function lBe(t){const e=[],n=[],r=[];let i=t;const a=t-Xp+1+M7.length;for(let o=0;o<a;o++){const l=Math.pow(2,i);n.push(l);let c=1/l;o>t-Xp?c=M7[o-t+Xp-1]:o===0&&(c=0),r.push(c);const u=1/(l-2),d=-u,f=1+u,m=[d,d,f,d,f,f,d,d,f,f,d,f],p=6,b=6,v=3,x=2,y=1,S=new Float32Array(v*b*p),M=new Float32Array(x*b*p),N=new Float32Array(y*b*p);for(let k=0;k<p;k++){const C=k%3*2/3-1,D=k>2?0:-1,T=[C,D,0,C+2/3,D,0,C+2/3,D+1,0,C,D,0,C+2/3,D+1,0,C,D+1,0];S.set(T,v*b*k),M.set(m,x*b*k);const R=[k,k,k,k,k,k];N.set(R,y*b*k)}const A=new Ha;A.setAttribute("position",new Xs(S,v)),A.setAttribute("uv",new Xs(M,x)),A.setAttribute("faceIndex",new Xs(N,y)),e.push(A),i>Xp&&i--}return{lodPlanes:e,sizeLods:n,sigmas:r}}function T7(t,e,n){const r=new em(t,e,n);return r.texture.mapping=fN,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function w1(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function cBe(t,e,n){const r=new Float32Array(nf),i=new Be(0,1,0);return new nh({name:"SphericalGaussianBlur",defines:{n:nf,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:yL(),fragmentShader:`
  7381. precision mediump float;
  7382. precision mediump int;
  7383. varying vec3 vOutputDirection;
  7384. uniform sampler2D envMap;
  7385. uniform int samples;
  7386. uniform float weights[ n ];
  7387. uniform bool latitudinal;
  7388. uniform float dTheta;
  7389. uniform float mipInt;
  7390. uniform vec3 poleAxis;
  7391. #define ENVMAP_TYPE_CUBE_UV
  7392. #include <cube_uv_reflection_fragment>
  7393. vec3 getSample( float theta, vec3 axis ) {
  7394. float cosTheta = cos( theta );
  7395. // Rodrigues' axis-angle rotation
  7396. vec3 sampleDirection = vOutputDirection * cosTheta
  7397. + cross( axis, vOutputDirection ) * sin( theta )
  7398. + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
  7399. return bilinearCubeUV( envMap, sampleDirection, mipInt );
  7400. }
  7401. void main() {
  7402. vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
  7403. if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
  7404. axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
  7405. }
  7406. axis = normalize( axis );
  7407. gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  7408. gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
  7409. for ( int i = 1; i < n; i++ ) {
  7410. if ( i >= samples ) {
  7411. break;
  7412. }
  7413. float theta = dTheta * float( i );
  7414. gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
  7415. gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
  7416. }
  7417. }
  7418. `,blending:Bd,depthTest:!1,depthWrite:!1})}function C7(){return new nh({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:yL(),fragmentShader:`
  7419. precision mediump float;
  7420. precision mediump int;
  7421. varying vec3 vOutputDirection;
  7422. uniform sampler2D envMap;
  7423. #include <common>
  7424. void main() {
  7425. vec3 outputDirection = normalize( vOutputDirection );
  7426. vec2 uv = equirectUv( outputDirection );
  7427. gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
  7428. }
  7429. `,blending:Bd,depthTest:!1,depthWrite:!1})}function k7(){return new nh({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:yL(),fragmentShader:`
  7430. precision mediump float;
  7431. precision mediump int;
  7432. uniform float flipEnvMap;
  7433. varying vec3 vOutputDirection;
  7434. uniform samplerCube envMap;
  7435. void main() {
  7436. gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
  7437. }
  7438. `,blending:Bd,depthTest:!1,depthWrite:!1})}function yL(){return`
  7439. precision mediump float;
  7440. precision mediump int;
  7441. attribute float faceIndex;
  7442. varying vec3 vOutputDirection;
  7443. // RH coordinate system; PMREM face-indexing convention
  7444. vec3 getDirection( vec2 uv, float face ) {
  7445. uv = 2.0 * uv - 1.0;
  7446. vec3 direction = vec3( uv, 1.0 );
  7447. if ( face == 0.0 ) {
  7448. direction = direction.zyx; // ( 1, v, u ) pos x
  7449. } else if ( face == 1.0 ) {
  7450. direction = direction.xzy;
  7451. direction.xz *= -1.0; // ( -u, 1, -v ) pos y
  7452. } else if ( face == 2.0 ) {
  7453. direction.x *= -1.0; // ( -u, v, 1 ) pos z
  7454. } else if ( face == 3.0 ) {
  7455. direction = direction.zyx;
  7456. direction.xz *= -1.0; // ( -1, v, -u ) neg x
  7457. } else if ( face == 4.0 ) {
  7458. direction = direction.xzy;
  7459. direction.xy *= -1.0; // ( -u, -1, v ) neg y
  7460. } else if ( face == 5.0 ) {
  7461. direction.z *= -1.0; // ( u, v, -1 ) neg z
  7462. }
  7463. return direction;
  7464. }
  7465. void main() {
  7466. vOutputDirection = getDirection( uv, faceIndex );
  7467. gl_Position = vec4( position, 1.0 );
  7468. }
  7469. `}function uBe(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,u=c===wR||c===SR,d=c===jg||c===Pg;if(u||d)if(l.isRenderTargetTexture&&l.needsPMREMUpdate===!0){l.needsPMREMUpdate=!1;let f=e.get(l);return n===null&&(n=new A7(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 A7(t));const m=u?n.fromEquirectangular(l):n.fromCubemap(l);return e.set(l,m),l.addEventListener("dispose",a),m.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 dBe(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 hBe(t,e,n,r){const i={},a=new WeakMap;function o(f){const m=f.target;m.index!==null&&e.remove(m.index);for(const b in m.attributes)e.remove(m.attributes[b]);for(const b in m.morphAttributes){const v=m.morphAttributes[b];for(let x=0,y=v.length;x<y;x++)e.remove(v[x])}m.removeEventListener("dispose",o),delete i[m.id];const p=a.get(m);p&&(e.remove(p),a.delete(m)),r.releaseStatesOfGeometry(m),m.isInstancedBufferGeometry===!0&&delete m._maxInstanceCount,n.memory.geometries--}function l(f,m){return i[m.id]===!0||(m.addEventListener("dispose",o),i[m.id]=!0,n.memory.geometries++),m}function c(f){const m=f.attributes;for(const b in m)e.update(m[b],t.ARRAY_BUFFER);const p=f.morphAttributes;for(const b in p){const v=p[b];for(let x=0,y=v.length;x<y;x++)e.update(v[x],t.ARRAY_BUFFER)}}function u(f){const m=[],p=f.index,b=f.attributes.position;let v=0;if(p!==null){const S=p.array;v=p.version;for(let M=0,N=S.length;M<N;M+=3){const A=S[M+0],k=S[M+1],C=S[M+2];m.push(A,k,k,C,C,A)}}else if(b!==void 0){const S=b.array;v=b.version;for(let M=0,N=S.length/3-1;M<N;M+=3){const A=M+0,k=M+1,C=M+2;m.push(A,k,k,C,C,A)}}else return;const x=new(Kee(m)?nte:tte)(m,1);x.version=v;const y=a.get(f);y&&e.remove(y),a.set(f,x)}function d(f){const m=a.get(f);if(m){const p=f.index;p!==null&&m.version<p.version&&u(f)}else u(f);return a.get(f)}return{get:l,update:c,getWireframeAttribute:d}}function fBe(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,b){t.drawElements(a,b,l,p*c),n.update(b,a,1)}function f(p,b,v){if(v===0)return;let x,y;if(i)x=t,y="drawElementsInstanced";else if(x=e.get("ANGLE_instanced_arrays"),y="drawElementsInstancedANGLE",x===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}x[y](a,b,l,p*c,v),n.update(b,a,v)}function m(p,b,v){if(v===0)return;const x=e.get("WEBGL_multi_draw");if(x===null)for(let y=0;y<v;y++)this.render(p[y]/c,b[y]);else{x.multiDrawElementsWEBGL(a,b,0,l,p,0,v);let y=0;for(let S=0;S<v;S++)y+=b[S];n.update(y,a,1)}}this.setMode=o,this.setIndex=u,this.render=d,this.renderInstances=f,this.renderMultiDraw=m}function mBe(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 pBe(t,e){return t[0]-e[0]}function gBe(t,e){return Math.abs(e[1])-Math.abs(t[1])}function xBe(t,e,n){const r={},i=new Float32Array(8),a=new WeakMap,o=new xr,l=[];for(let u=0;u<8;u++)l[u]=[u,0];function c(u,d,f){const m=u.morphTargetInfluences;if(e.isWebGL2===!0){const b=d.morphAttributes.position||d.morphAttributes.normal||d.morphAttributes.color,v=b!==void 0?b.length:0;let x=a.get(d);if(x===void 0||x.count!==v){let W=function(){q.dispose(),a.delete(d),d.removeEventListener("dispose",W)};var p=W;x!==void 0&&x.texture.dispose();const M=d.morphAttributes.position!==void 0,N=d.morphAttributes.normal!==void 0,A=d.morphAttributes.color!==void 0,k=d.morphAttributes.position||[],C=d.morphAttributes.normal||[],D=d.morphAttributes.color||[];let T=0;M===!0&&(T=1),N===!0&&(T=2),A===!0&&(T=3);let R=d.attributes.position.count*T,U=1;R>e.maxTextureSize&&(U=Math.ceil(R/e.maxTextureSize),R=e.maxTextureSize);const L=new Float32Array(R*U*4*v),q=new Zee(L,R,U,v);q.type=eu,q.needsUpdate=!0;const j=T*4;for(let K=0;K<v;K++){const V=k[K],J=C[K],ne=D[K],te=R*U*4*K;for(let z=0;z<V.count;z++){const H=z*j;M===!0&&(o.fromBufferAttribute(V,z),L[te+H+0]=o.x,L[te+H+1]=o.y,L[te+H+2]=o.z,L[te+H+3]=0),N===!0&&(o.fromBufferAttribute(J,z),L[te+H+4]=o.x,L[te+H+5]=o.y,L[te+H+6]=o.z,L[te+H+7]=0),A===!0&&(o.fromBufferAttribute(ne,z),L[te+H+8]=o.x,L[te+H+9]=o.y,L[te+H+10]=o.z,L[te+H+11]=ne.itemSize===4?o.w:1)}}x={count:v,texture:q,size:new mn(R,U)},a.set(d,x),d.addEventListener("dispose",W)}let y=0;for(let M=0;M<m.length;M++)y+=m[M];const S=d.morphTargetsRelative?1:1-y;f.getUniforms().setValue(t,"morphTargetBaseInfluence",S),f.getUniforms().setValue(t,"morphTargetInfluences",m),f.getUniforms().setValue(t,"morphTargetsTexture",x.texture,n),f.getUniforms().setValue(t,"morphTargetsTextureSize",x.size)}else{const b=m===void 0?0:m.length;let v=r[d.id];if(v===void 0||v.length!==b){v=[];for(let N=0;N<b;N++)v[N]=[N,0];r[d.id]=v}for(let N=0;N<b;N++){const A=v[N];A[0]=N,A[1]=m[N]}v.sort(gBe);for(let N=0;N<8;N++)N<b&&v[N][1]?(l[N][0]=v[N][0],l[N][1]=v[N][1]):(l[N][0]=Number.MAX_SAFE_INTEGER,l[N][1]=0);l.sort(pBe);const x=d.morphAttributes.position,y=d.morphAttributes.normal;let S=0;for(let N=0;N<8;N++){const A=l[N],k=A[0],C=A[1];k!==Number.MAX_SAFE_INTEGER&&C?(x&&d.getAttribute("morphTarget"+N)!==x[k]&&d.setAttribute("morphTarget"+N,x[k]),y&&d.getAttribute("morphNormal"+N)!==y[k]&&d.setAttribute("morphNormal"+N,y[k]),i[N]=C,S+=C):(x&&d.hasAttribute("morphTarget"+N)===!0&&d.deleteAttribute("morphTarget"+N),y&&d.hasAttribute("morphNormal"+N)===!0&&d.deleteAttribute("morphNormal"+N),i[N]=0)}const M=d.morphTargetsRelative?1:1-S;f.getUniforms().setValue(t,"morphTargetBaseInfluence",M),f.getUniforms().setValue(t,"morphTargetInfluences",i)}}return{update:c}}function bBe(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 m=c.skeleton;i.get(m)!==u&&(m.update(),i.set(m,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 ote extends Ss{constructor(e,n,r,i,a,o,l,c,u,d){if(d=d!==void 0?d:Af,d!==Af&&d!==Rg)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&d===Af&&(r=kd),r===void 0&&d===Rg&&(r=Nf),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:ba,this.minFilter=c!==void 0?c:ba,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 lte=new Ss,cte=new ote(1,1);cte.compareFunction=Wee;const ute=new Zee,dte=new n5e,hte=new ate,j7=[],P7=[],R7=new Float32Array(16),D7=new Float32Array(9),O7=new Float32Array(4);function dx(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let a=j7[i];if(a===void 0&&(a=new Float32Array(i),j7[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 Fi(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 Ui(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function gN(t,e){let n=P7[e];n===void 0&&(n=new Int32Array(e),P7[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function yBe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function vBe(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(Fi(n,e))return;t.uniform2fv(this.addr,e),Ui(n,e)}}function _Be(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(Fi(n,e))return;t.uniform3fv(this.addr,e),Ui(n,e)}}function wBe(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(Fi(n,e))return;t.uniform4fv(this.addr,e),Ui(n,e)}}function SBe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Fi(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),Ui(n,e)}else{if(Fi(n,r))return;O7.set(r),t.uniformMatrix2fv(this.addr,!1,O7),Ui(n,r)}}function MBe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Fi(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),Ui(n,e)}else{if(Fi(n,r))return;D7.set(r),t.uniformMatrix3fv(this.addr,!1,D7),Ui(n,r)}}function EBe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Fi(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),Ui(n,e)}else{if(Fi(n,r))return;R7.set(r),t.uniformMatrix4fv(this.addr,!1,R7),Ui(n,r)}}function NBe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function ABe(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(Fi(n,e))return;t.uniform2iv(this.addr,e),Ui(n,e)}}function TBe(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(Fi(n,e))return;t.uniform3iv(this.addr,e),Ui(n,e)}}function CBe(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(Fi(n,e))return;t.uniform4iv(this.addr,e),Ui(n,e)}}function kBe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function jBe(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(Fi(n,e))return;t.uniform2uiv(this.addr,e),Ui(n,e)}}function PBe(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(Fi(n,e))return;t.uniform3uiv(this.addr,e),Ui(n,e)}}function RBe(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(Fi(n,e))return;t.uniform4uiv(this.addr,e),Ui(n,e)}}function DBe(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?cte:lte;n.setTexture2D(e||a,i)}function OBe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||dte,i)}function LBe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||hte,i)}function IBe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||ute,i)}function FBe(t){switch(t){case 5126:return yBe;case 35664:return vBe;case 35665:return _Be;case 35666:return wBe;case 35674:return SBe;case 35675:return MBe;case 35676:return EBe;case 5124:case 35670:return NBe;case 35667:case 35671:return ABe;case 35668:case 35672:return TBe;case 35669:case 35673:return CBe;case 5125:return kBe;case 36294:return jBe;case 36295:return PBe;case 36296:return RBe;case 35678:case 36198:case 36298:case 36306:case 35682:return DBe;case 35679:case 36299:case 36307:return OBe;case 35680:case 36300:case 36308:case 36293:return LBe;case 36289:case 36303:case 36311:case 36292:return IBe}}function UBe(t,e){t.uniform1fv(this.addr,e)}function zBe(t,e){const n=dx(e,this.size,2);t.uniform2fv(this.addr,n)}function BBe(t,e){const n=dx(e,this.size,3);t.uniform3fv(this.addr,n)}function $Be(t,e){const n=dx(e,this.size,4);t.uniform4fv(this.addr,n)}function HBe(t,e){const n=dx(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function VBe(t,e){const n=dx(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function GBe(t,e){const n=dx(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function WBe(t,e){t.uniform1iv(this.addr,e)}function qBe(t,e){t.uniform2iv(this.addr,e)}function KBe(t,e){t.uniform3iv(this.addr,e)}function XBe(t,e){t.uniform4iv(this.addr,e)}function YBe(t,e){t.uniform1uiv(this.addr,e)}function ZBe(t,e){t.uniform2uiv(this.addr,e)}function QBe(t,e){t.uniform3uiv(this.addr,e)}function JBe(t,e){t.uniform4uiv(this.addr,e)}function e8e(t,e,n){const r=this.cache,i=e.length,a=gN(n,i);Fi(r,a)||(t.uniform1iv(this.addr,a),Ui(r,a));for(let o=0;o!==i;++o)n.setTexture2D(e[o]||lte,a[o])}function t8e(t,e,n){const r=this.cache,i=e.length,a=gN(n,i);Fi(r,a)||(t.uniform1iv(this.addr,a),Ui(r,a));for(let o=0;o!==i;++o)n.setTexture3D(e[o]||dte,a[o])}function n8e(t,e,n){const r=this.cache,i=e.length,a=gN(n,i);Fi(r,a)||(t.uniform1iv(this.addr,a),Ui(r,a));for(let o=0;o!==i;++o)n.setTextureCube(e[o]||hte,a[o])}function r8e(t,e,n){const r=this.cache,i=e.length,a=gN(n,i);Fi(r,a)||(t.uniform1iv(this.addr,a),Ui(r,a));for(let o=0;o!==i;++o)n.setTexture2DArray(e[o]||ute,a[o])}function i8e(t){switch(t){case 5126:return UBe;case 35664:return zBe;case 35665:return BBe;case 35666:return $Be;case 35674:return HBe;case 35675:return VBe;case 35676:return GBe;case 5124:case 35670:return WBe;case 35667:case 35671:return qBe;case 35668:case 35672:return KBe;case 35669:case 35673:return XBe;case 5125:return YBe;case 36294:return ZBe;case 36295:return QBe;case 36296:return JBe;case 35678:case 36198:case 36298:case 36306:case 35682:return e8e;case 35679:case 36299:case 36307:return t8e;case 35680:case 36300:case 36308:case 36293:return n8e;case 36289:case 36303:case 36311:case 36292:return r8e}}class a8e{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=FBe(n.type)}}class s8e{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=i8e(n.type)}}class o8e{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 ej=/(\w+)(\])?(\[|\.)?/g;function L7(t,e){t.seq.push(e),t.map[e.id]=e}function l8e(t,e,n){const r=t.name,i=r.length;for(ej.lastIndex=0;;){const a=ej.exec(r),o=ej.lastIndex;let l=a[1];const c=a[2]==="]",u=a[3];if(c&&(l=l|0),u===void 0||u==="["&&o+2===i){L7(n,u===void 0?new a8e(l,t,e):new s8e(l,t,e));break}else{let f=n.map[l];f===void 0&&(f=new o8e(l),L7(n,f)),n=f}}}class gw{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);l8e(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 I7(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const c8e=37297;let u8e=0;function d8e(t,e){const n=t.split(`
  7470. `),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(`
  7471. `)}function h8e(t){const e=pr.getPrimaries(pr.workingColorSpace),n=pr.getPrimaries(t);let r;switch(e===n?r="":e===qS&&n===WS?r="LinearDisplayP3ToLinearSRGB":e===WS&&n===qS&&(r="LinearSRGBToLinearDisplayP3"),t){case _u:case mN:return[r,"LinearTransferOETF"];case ya:case mL:return[r,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",t),[r,"LinearTransferOETF"]}}function F7(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()+`
  7472. `+i+`
  7473. `+d8e(t.getShaderSource(e),o)}else return i}function f8e(t,e){const n=h8e(e);return`vec4 ${t}( vec4 value ) { return ${n[0]}( ${n[1]}( value ) ); }`}function m8e(t,e){let n;switch(e){case fFe:n="Linear";break;case mFe:n="Reinhard";break;case pFe:n="OptimizedCineon";break;case gFe:n="ACESFilmic";break;case xFe:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function p8e(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(Vb).join(`
  7474. `)}function g8e(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
  7475. `)}function x8e(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 Vb(t){return t!==""}function U7(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 z7(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const b8e=/^[ \t]*#include +<([\w\d./]+)>/gm;function CR(t){return t.replace(b8e,v8e)}const y8e=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function v8e(t,e){let n=Sn[e];if(n===void 0){const r=y8e.get(e);if(r!==void 0)n=Sn[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 CR(n)}const _8e=/#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 B7(t){return t.replace(_8e,w8e)}function w8e(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 $7(t){let e="precision "+t.precision+` float;
  7476. precision `+t.precision+" int;";return t.precision==="highp"?e+=`
  7477. #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
  7478. #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
  7479. #define LOW_PRECISION`),e}function S8e(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===Oee?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===BIe?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===Hc&&(e="SHADOWMAP_TYPE_VSM"),e}function M8e(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case jg:case Pg:e="ENVMAP_TYPE_CUBE";break;case fN:e="ENVMAP_TYPE_CUBE_UV";break}return e}function E8e(t){let e="ENVMAP_MODE_REFLECTION";return t.envMap&&t.envMapMode===Pg&&(e="ENVMAP_MODE_REFRACTION"),e}function N8e(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case hL:e="ENVMAP_BLENDING_MULTIPLY";break;case dFe:e="ENVMAP_BLENDING_MIX";break;case hFe:e="ENVMAP_BLENDING_ADD";break}return e}function A8e(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 T8e(t,e,n,r){const i=t.getContext(),a=n.defines;let o=n.vertexShader,l=n.fragmentShader;const c=S8e(n),u=M8e(n),d=E8e(n),f=N8e(n),m=A8e(n),p=n.isWebGL2?"":p8e(n),b=g8e(a),v=i.createProgram();let x,y,S=n.glslVersion?"#version "+n.glslVersion+`
  7480. `:"";n.isRawShaderMaterial?(x=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(Vb).join(`
  7481. `),x.length>0&&(x+=`
  7482. `),y=[p,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(Vb).join(`
  7483. `),y.length>0&&(y+=`
  7484. `)):(x=[$7(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b,n.batching?"#define USE_BATCHING":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors&&n.isWebGL2?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
  7485. `].filter(Vb).join(`
  7486. `),y=[p,$7(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",n.envMap?"#define "+f:"",m?"#define CUBEUV_TEXEL_WIDTH "+m.texelWidth:"",m?"#define CUBEUV_TEXEL_HEIGHT "+m.texelHeight:"",m?"#define CUBEUV_MAX_MIP "+m.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!==$d?"#define TONE_MAPPING":"",n.toneMapping!==$d?Sn.tonemapping_pars_fragment:"",n.toneMapping!==$d?m8e("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Sn.colorspace_pars_fragment,f8e("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
  7487. `].filter(Vb).join(`
  7488. `)),o=CR(o),o=U7(o,n),o=z7(o,n),l=CR(l),l=U7(l,n),l=z7(l,n),o=B7(o),l=B7(l),n.isWebGL2&&n.isRawShaderMaterial!==!0&&(S=`#version 300 es
  7489. `,x=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
  7490. `)+`
  7491. `+x,y=["precision mediump sampler2DArray;","#define varying in",n.glslVersion===s7?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===s7?"":"#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(`
  7492. `)+`
  7493. `+y);const M=S+x+o,N=S+y+l,A=I7(i,i.VERTEX_SHADER,M),k=I7(i,i.FRAGMENT_SHADER,N);i.attachShader(v,A),i.attachShader(v,k),n.index0AttributeName!==void 0?i.bindAttribLocation(v,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(v,0,"position"),i.linkProgram(v);function C(U){if(t.debug.checkShaderErrors){const L=i.getProgramInfoLog(v).trim(),q=i.getShaderInfoLog(A).trim(),j=i.getShaderInfoLog(k).trim();let W=!0,K=!0;if(i.getProgramParameter(v,i.LINK_STATUS)===!1)if(W=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,v,A,k);else{const V=F7(i,A,"vertex"),J=F7(i,k,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(v,i.VALIDATE_STATUS)+`
  7494. Program Info Log: `+L+`
  7495. `+V+`
  7496. `+J)}else L!==""?console.warn("THREE.WebGLProgram: Program Info Log:",L):(q===""||j==="")&&(K=!1);K&&(U.diagnostics={runnable:W,programLog:L,vertexShader:{log:q,prefix:x},fragmentShader:{log:j,prefix:y}})}i.deleteShader(A),i.deleteShader(k),D=new gw(i,v),T=x8e(i,v)}let D;this.getUniforms=function(){return D===void 0&&C(this),D};let T;this.getAttributes=function(){return T===void 0&&C(this),T};let R=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return R===!1&&(R=i.getProgramParameter(v,c8e)),R},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(v),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=u8e++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=A,this.fragmentShader=k,this}let C8e=0;class k8e{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 j8e(e),n.set(e,r)),r}}class j8e{constructor(e){this.id=C8e++,this.code=e,this.usedTimes=0}}function P8e(t,e,n,r,i,a,o){const l=new Qee,c=new k8e,u=[],d=i.isWebGL2,f=i.logarithmicDepthBuffer,m=i.vertexTextures;let p=i.precision;const b={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function v(T){return T===0?"uv":`uv${T}`}function x(T,R,U,L,q){const j=L.fog,W=q.geometry,K=T.isMeshStandardMaterial?L.environment:null,V=(T.isMeshStandardMaterial?n:e).get(T.envMap||K),J=V&&V.mapping===fN?V.image.height:null,ne=b[T.type];T.precision!==null&&(p=i.getMaxPrecision(T.precision),p!==T.precision&&console.warn("THREE.WebGLProgram.getParameters:",T.precision,"not supported, using",p,"instead."));const te=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,z=te!==void 0?te.length:0;let H=0;W.morphAttributes.position!==void 0&&(H=1),W.morphAttributes.normal!==void 0&&(H=2),W.morphAttributes.color!==void 0&&(H=3);let Z,ee,he,fe;if(ne){const on=gs[ne];Z=on.vertexShader,ee=on.fragmentShader}else Z=T.vertexShader,ee=T.fragmentShader,c.update(T),he=c.getVertexShaderID(T),fe=c.getFragmentShaderID(T);const oe=t.getRenderTarget(),Ne=q.isInstancedMesh===!0,ge=q.isBatchedMesh===!0,Se=!!T.map,Re=!!T.matcap,de=!!V,Qe=!!T.aoMap,G=!!T.lightMap,ie=!!T.bumpMap,X=!!T.normalMap,$=!!T.displacementMap,I=!!T.emissiveMap,ce=!!T.metalnessMap,Ee=!!T.roughnessMap,Ie=T.anisotropy>0,le=T.clearcoat>0,B=T.iridescence>0,O=T.sheen>0,Y=T.transmission>0,pe=Ie&&!!T.anisotropyMap,we=le&&!!T.clearcoatMap,ae=le&&!!T.clearcoatNormalMap,ke=le&&!!T.clearcoatRoughnessMap,De=B&&!!T.iridescenceMap,Ke=B&&!!T.iridescenceThicknessMap,et=O&&!!T.sheenColorMap,Ye=O&&!!T.sheenRoughnessMap,se=!!T.specularMap,ye=!!T.specularColorMap,Ce=!!T.specularIntensityMap,Ue=Y&&!!T.transmissionMap,dt=Y&&!!T.thicknessMap,re=!!T.gradientMap,Fe=!!T.alphaMap,ve=T.alphaTest>0,$e=!!T.alphaHash,Le=!!T.extensions,Ae=!!W.attributes.uv1,Ge=!!W.attributes.uv2,it=!!W.attributes.uv3;let Ot=$d;return T.toneMapped&&(oe===null||oe.isXRRenderTarget===!0)&&(Ot=t.toneMapping),{isWebGL2:d,shaderID:ne,shaderType:T.type,shaderName:T.name,vertexShader:Z,fragmentShader:ee,defines:T.defines,customVertexShaderID:he,customFragmentShaderID:fe,isRawShaderMaterial:T.isRawShaderMaterial===!0,glslVersion:T.glslVersion,precision:p,batching:ge,instancing:Ne,instancingColor:Ne&&q.instanceColor!==null,supportsVertexTextures:m,outputColorSpace:oe===null?t.outputColorSpace:oe.isXRRenderTarget===!0?oe.texture.colorSpace:_u,map:Se,matcap:Re,envMap:de,envMapMode:de&&V.mapping,envMapCubeUVHeight:J,aoMap:Qe,lightMap:G,bumpMap:ie,normalMap:X,displacementMap:m&&$,emissiveMap:I,normalMapObjectSpace:X&&T.normalMapType===CFe,normalMapTangentSpace:X&&T.normalMapType===Gee,metalnessMap:ce,roughnessMap:Ee,anisotropy:Ie,anisotropyMap:pe,clearcoat:le,clearcoatMap:we,clearcoatNormalMap:ae,clearcoatRoughnessMap:ke,iridescence:B,iridescenceMap:De,iridescenceThicknessMap:Ke,sheen:O,sheenColorMap:et,sheenRoughnessMap:Ye,specularMap:se,specularColorMap:ye,specularIntensityMap:Ce,transmission:Y,transmissionMap:Ue,thicknessMap:dt,gradientMap:re,opaque:T.transparent===!1&&T.blending===sg,alphaMap:Fe,alphaTest:ve,alphaHash:$e,combine:T.combine,mapUv:Se&&v(T.map.channel),aoMapUv:Qe&&v(T.aoMap.channel),lightMapUv:G&&v(T.lightMap.channel),bumpMapUv:ie&&v(T.bumpMap.channel),normalMapUv:X&&v(T.normalMap.channel),displacementMapUv:$&&v(T.displacementMap.channel),emissiveMapUv:I&&v(T.emissiveMap.channel),metalnessMapUv:ce&&v(T.metalnessMap.channel),roughnessMapUv:Ee&&v(T.roughnessMap.channel),anisotropyMapUv:pe&&v(T.anisotropyMap.channel),clearcoatMapUv:we&&v(T.clearcoatMap.channel),clearcoatNormalMapUv:ae&&v(T.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ke&&v(T.clearcoatRoughnessMap.channel),iridescenceMapUv:De&&v(T.iridescenceMap.channel),iridescenceThicknessMapUv:Ke&&v(T.iridescenceThicknessMap.channel),sheenColorMapUv:et&&v(T.sheenColorMap.channel),sheenRoughnessMapUv:Ye&&v(T.sheenRoughnessMap.channel),specularMapUv:se&&v(T.specularMap.channel),specularColorMapUv:ye&&v(T.specularColorMap.channel),specularIntensityMapUv:Ce&&v(T.specularIntensityMap.channel),transmissionMapUv:Ue&&v(T.transmissionMap.channel),thicknessMapUv:dt&&v(T.thicknessMap.channel),alphaMapUv:Fe&&v(T.alphaMap.channel),vertexTangents:!!W.attributes.tangent&&(X||Ie),vertexColors:T.vertexColors,vertexAlphas:T.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,vertexUv1s:Ae,vertexUv2s:Ge,vertexUv3s:it,pointsUvs:q.isPoints===!0&&!!W.attributes.uv&&(Se||Fe),fog:!!j,useFog:T.fog===!0,fogExp2:j&&j.isFogExp2,flatShading:T.flatShading===!0,sizeAttenuation:T.sizeAttenuation===!0,logarithmicDepthBuffer:f,skinning:q.isSkinnedMesh===!0,morphTargets:W.morphAttributes.position!==void 0,morphNormals:W.morphAttributes.normal!==void 0,morphColors:W.morphAttributes.color!==void 0,morphTargetsCount:z,morphTextureStride:H,numDirLights:R.directional.length,numPointLights:R.point.length,numSpotLights:R.spot.length,numSpotLightMaps:R.spotLightMap.length,numRectAreaLights:R.rectArea.length,numHemiLights:R.hemi.length,numDirLightShadows:R.directionalShadowMap.length,numPointLightShadows:R.pointShadowMap.length,numSpotLightShadows:R.spotShadowMap.length,numSpotLightShadowsWithMaps:R.numSpotLightShadowsWithMaps,numLightProbes:R.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:T.dithering,shadowMapEnabled:t.shadowMap.enabled&&U.length>0,shadowMapType:t.shadowMap.type,toneMapping:Ot,useLegacyLights:t._useLegacyLights,decodeVideoTexture:Se&&T.map.isVideoTexture===!0&&pr.getTransfer(T.map.colorSpace)===Dr,premultipliedAlpha:T.premultipliedAlpha,doubleSided:T.side===Xc,flipSided:T.side===ws,useDepthPacking:T.depthPacking>=0,depthPacking:T.depthPacking||0,index0AttributeName:T.index0AttributeName,extensionDerivatives:Le&&T.extensions.derivatives===!0,extensionFragDepth:Le&&T.extensions.fragDepth===!0,extensionDrawBuffers:Le&&T.extensions.drawBuffers===!0,extensionShaderTextureLOD:Le&&T.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:T.customProgramCacheKey()}}function y(T){const R=[];if(T.shaderID?R.push(T.shaderID):(R.push(T.customVertexShaderID),R.push(T.customFragmentShaderID)),T.defines!==void 0)for(const U in T.defines)R.push(U),R.push(T.defines[U]);return T.isRawShaderMaterial===!1&&(S(R,T),M(R,T),R.push(t.outputColorSpace)),R.push(T.customProgramCacheKey),R.join()}function S(T,R){T.push(R.precision),T.push(R.outputColorSpace),T.push(R.envMapMode),T.push(R.envMapCubeUVHeight),T.push(R.mapUv),T.push(R.alphaMapUv),T.push(R.lightMapUv),T.push(R.aoMapUv),T.push(R.bumpMapUv),T.push(R.normalMapUv),T.push(R.displacementMapUv),T.push(R.emissiveMapUv),T.push(R.metalnessMapUv),T.push(R.roughnessMapUv),T.push(R.anisotropyMapUv),T.push(R.clearcoatMapUv),T.push(R.clearcoatNormalMapUv),T.push(R.clearcoatRoughnessMapUv),T.push(R.iridescenceMapUv),T.push(R.iridescenceThicknessMapUv),T.push(R.sheenColorMapUv),T.push(R.sheenRoughnessMapUv),T.push(R.specularMapUv),T.push(R.specularColorMapUv),T.push(R.specularIntensityMapUv),T.push(R.transmissionMapUv),T.push(R.thicknessMapUv),T.push(R.combine),T.push(R.fogExp2),T.push(R.sizeAttenuation),T.push(R.morphTargetsCount),T.push(R.morphAttributeCount),T.push(R.numDirLights),T.push(R.numPointLights),T.push(R.numSpotLights),T.push(R.numSpotLightMaps),T.push(R.numHemiLights),T.push(R.numRectAreaLights),T.push(R.numDirLightShadows),T.push(R.numPointLightShadows),T.push(R.numSpotLightShadows),T.push(R.numSpotLightShadowsWithMaps),T.push(R.numLightProbes),T.push(R.shadowMapType),T.push(R.toneMapping),T.push(R.numClippingPlanes),T.push(R.numClipIntersection),T.push(R.depthPacking)}function M(T,R){l.disableAll(),R.isWebGL2&&l.enable(0),R.supportsVertexTextures&&l.enable(1),R.instancing&&l.enable(2),R.instancingColor&&l.enable(3),R.matcap&&l.enable(4),R.envMap&&l.enable(5),R.normalMapObjectSpace&&l.enable(6),R.normalMapTangentSpace&&l.enable(7),R.clearcoat&&l.enable(8),R.iridescence&&l.enable(9),R.alphaTest&&l.enable(10),R.vertexColors&&l.enable(11),R.vertexAlphas&&l.enable(12),R.vertexUv1s&&l.enable(13),R.vertexUv2s&&l.enable(14),R.vertexUv3s&&l.enable(15),R.vertexTangents&&l.enable(16),R.anisotropy&&l.enable(17),R.alphaHash&&l.enable(18),R.batching&&l.enable(19),T.push(l.mask),l.disableAll(),R.fog&&l.enable(0),R.useFog&&l.enable(1),R.flatShading&&l.enable(2),R.logarithmicDepthBuffer&&l.enable(3),R.skinning&&l.enable(4),R.morphTargets&&l.enable(5),R.morphNormals&&l.enable(6),R.morphColors&&l.enable(7),R.premultipliedAlpha&&l.enable(8),R.shadowMapEnabled&&l.enable(9),R.useLegacyLights&&l.enable(10),R.doubleSided&&l.enable(11),R.flipSided&&l.enable(12),R.useDepthPacking&&l.enable(13),R.dithering&&l.enable(14),R.transmission&&l.enable(15),R.sheen&&l.enable(16),R.opaque&&l.enable(17),R.pointsUvs&&l.enable(18),R.decodeVideoTexture&&l.enable(19),T.push(l.mask)}function N(T){const R=b[T.type];let U;if(R){const L=gs[R];U=xL.clone(L.uniforms)}else U=T.uniforms;return U}function A(T,R){let U;for(let L=0,q=u.length;L<q;L++){const j=u[L];if(j.cacheKey===R){U=j,++U.usedTimes;break}}return U===void 0&&(U=new T8e(t,R,T,a),u.push(U)),U}function k(T){if(--T.usedTimes===0){const R=u.indexOf(T);u[R]=u[u.length-1],u.pop(),T.destroy()}}function C(T){c.remove(T)}function D(){c.dispose()}return{getParameters:x,getProgramCacheKey:y,getUniforms:N,acquireProgram:A,releaseProgram:k,releaseShaderCache:C,programs:u,dispose:D}}function R8e(){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 D8e(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 H7(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 V7(){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,m,p,b,v,x){let y=t[e];return y===void 0?(y={id:f.id,object:f,geometry:m,material:p,groupOrder:b,renderOrder:f.renderOrder,z:v,group:x},t[e]=y):(y.id=f.id,y.object=f,y.geometry=m,y.material=p,y.groupOrder=b,y.renderOrder=f.renderOrder,y.z=v,y.group=x),e++,y}function l(f,m,p,b,v,x){const y=o(f,m,p,b,v,x);p.transmission>0?r.push(y):p.transparent===!0?i.push(y):n.push(y)}function c(f,m,p,b,v,x){const y=o(f,m,p,b,v,x);p.transmission>0?r.unshift(y):p.transparent===!0?i.unshift(y):n.unshift(y)}function u(f,m){n.length>1&&n.sort(f||D8e),r.length>1&&r.sort(m||H7),i.length>1&&i.sort(m||H7)}function d(){for(let f=e,m=t.length;f<m;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 O8e(){let t=new WeakMap;function e(r,i){const a=t.get(r);let o;return a===void 0?(o=new V7,t.set(r,[o])):i>=a.length?(o=new V7,a.push(o)):o=a[i],o}function n(){t=new WeakMap}return{get:e,dispose:n}}function L8e(){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 Be,color:new rn};break;case"SpotLight":n={position:new Be,direction:new Be,color:new rn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Be,color:new rn,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Be,skyColor:new rn,groundColor:new rn};break;case"RectAreaLight":n={color:new rn,position:new Be,halfWidth:new Be,halfHeight:new Be};break}return t[e.id]=n,n}}}function I8e(){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 mn};break;case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new mn};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new mn,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let F8e=0;function U8e(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function z8e(t,e){const n=new L8e,r=I8e(),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 Be);const a=new Be,o=new Tr,l=new Tr;function c(d,f){let m=0,p=0,b=0;for(let L=0;L<9;L++)i.probe[L].set(0,0,0);let v=0,x=0,y=0,S=0,M=0,N=0,A=0,k=0,C=0,D=0,T=0;d.sort(U8e);const R=f===!0?Math.PI:1;for(let L=0,q=d.length;L<q;L++){const j=d[L],W=j.color,K=j.intensity,V=j.distance,J=j.shadow&&j.shadow.map?j.shadow.map.texture:null;if(j.isAmbientLight)m+=W.r*K*R,p+=W.g*K*R,b+=W.b*K*R;else if(j.isLightProbe){for(let ne=0;ne<9;ne++)i.probe[ne].addScaledVector(j.sh.coefficients[ne],K);T++}else if(j.isDirectionalLight){const ne=n.get(j);if(ne.color.copy(j.color).multiplyScalar(j.intensity*R),j.castShadow){const te=j.shadow,z=r.get(j);z.shadowBias=te.bias,z.shadowNormalBias=te.normalBias,z.shadowRadius=te.radius,z.shadowMapSize=te.mapSize,i.directionalShadow[v]=z,i.directionalShadowMap[v]=J,i.directionalShadowMatrix[v]=j.shadow.matrix,N++}i.directional[v]=ne,v++}else if(j.isSpotLight){const ne=n.get(j);ne.position.setFromMatrixPosition(j.matrixWorld),ne.color.copy(W).multiplyScalar(K*R),ne.distance=V,ne.coneCos=Math.cos(j.angle),ne.penumbraCos=Math.cos(j.angle*(1-j.penumbra)),ne.decay=j.decay,i.spot[y]=ne;const te=j.shadow;if(j.map&&(i.spotLightMap[C]=j.map,C++,te.updateMatrices(j),j.castShadow&&D++),i.spotLightMatrix[y]=te.matrix,j.castShadow){const z=r.get(j);z.shadowBias=te.bias,z.shadowNormalBias=te.normalBias,z.shadowRadius=te.radius,z.shadowMapSize=te.mapSize,i.spotShadow[y]=z,i.spotShadowMap[y]=J,k++}y++}else if(j.isRectAreaLight){const ne=n.get(j);ne.color.copy(W).multiplyScalar(K),ne.halfWidth.set(j.width*.5,0,0),ne.halfHeight.set(0,j.height*.5,0),i.rectArea[S]=ne,S++}else if(j.isPointLight){const ne=n.get(j);if(ne.color.copy(j.color).multiplyScalar(j.intensity*R),ne.distance=j.distance,ne.decay=j.decay,j.castShadow){const te=j.shadow,z=r.get(j);z.shadowBias=te.bias,z.shadowNormalBias=te.normalBias,z.shadowRadius=te.radius,z.shadowMapSize=te.mapSize,z.shadowCameraNear=te.camera.near,z.shadowCameraFar=te.camera.far,i.pointShadow[x]=z,i.pointShadowMap[x]=J,i.pointShadowMatrix[x]=j.shadow.matrix,A++}i.point[x]=ne,x++}else if(j.isHemisphereLight){const ne=n.get(j);ne.skyColor.copy(j.color).multiplyScalar(K*R),ne.groundColor.copy(j.groundColor).multiplyScalar(K*R),i.hemi[M]=ne,M++}}S>0&&(e.isWebGL2||t.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Lt.LTC_FLOAT_1,i.rectAreaLTC2=Lt.LTC_FLOAT_2):t.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=Lt.LTC_HALF_1,i.rectAreaLTC2=Lt.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=m,i.ambient[1]=p,i.ambient[2]=b;const U=i.hash;(U.directionalLength!==v||U.pointLength!==x||U.spotLength!==y||U.rectAreaLength!==S||U.hemiLength!==M||U.numDirectionalShadows!==N||U.numPointShadows!==A||U.numSpotShadows!==k||U.numSpotMaps!==C||U.numLightProbes!==T)&&(i.directional.length=v,i.spot.length=y,i.rectArea.length=S,i.point.length=x,i.hemi.length=M,i.directionalShadow.length=N,i.directionalShadowMap.length=N,i.pointShadow.length=A,i.pointShadowMap.length=A,i.spotShadow.length=k,i.spotShadowMap.length=k,i.directionalShadowMatrix.length=N,i.pointShadowMatrix.length=A,i.spotLightMatrix.length=k+C-D,i.spotLightMap.length=C,i.numSpotLightShadowsWithMaps=D,i.numLightProbes=T,U.directionalLength=v,U.pointLength=x,U.spotLength=y,U.rectAreaLength=S,U.hemiLength=M,U.numDirectionalShadows=N,U.numPointShadows=A,U.numSpotShadows=k,U.numSpotMaps=C,U.numLightProbes=T,i.version=F8e++)}function u(d,f){let m=0,p=0,b=0,v=0,x=0;const y=f.matrixWorldInverse;for(let S=0,M=d.length;S<M;S++){const N=d[S];if(N.isDirectionalLight){const A=i.directional[m];A.direction.setFromMatrixPosition(N.matrixWorld),a.setFromMatrixPosition(N.target.matrixWorld),A.direction.sub(a),A.direction.transformDirection(y),m++}else if(N.isSpotLight){const A=i.spot[b];A.position.setFromMatrixPosition(N.matrixWorld),A.position.applyMatrix4(y),A.direction.setFromMatrixPosition(N.matrixWorld),a.setFromMatrixPosition(N.target.matrixWorld),A.direction.sub(a),A.direction.transformDirection(y),b++}else if(N.isRectAreaLight){const A=i.rectArea[v];A.position.setFromMatrixPosition(N.matrixWorld),A.position.applyMatrix4(y),l.identity(),o.copy(N.matrixWorld),o.premultiply(y),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),v++}else if(N.isPointLight){const A=i.point[p];A.position.setFromMatrixPosition(N.matrixWorld),A.position.applyMatrix4(y),p++}else if(N.isHemisphereLight){const A=i.hemi[x];A.direction.setFromMatrixPosition(N.matrixWorld),A.direction.transformDirection(y),x++}}}return{setup:c,setupView:u,state:i}}function G7(t,e){const n=new z8e(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 B8e(t,e){let n=new WeakMap;function r(a,o=0){const l=n.get(a);let c;return l===void 0?(c=new G7(t,e),n.set(a,[c])):o>=l.length?(c=new G7(t,e),l.push(c)):c=l[o],c}function i(){n=new WeakMap}return{get:r,dispose:i}}class $8e extends ux{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=AFe,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 H8e extends ux{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 V8e=`void main() {
  7497. gl_Position = vec4( position, 1.0 );
  7498. }`,G8e=`uniform sampler2D shadow_pass;
  7499. uniform vec2 resolution;
  7500. uniform float radius;
  7501. #include <packing>
  7502. void main() {
  7503. const float samples = float( VSM_SAMPLES );
  7504. float mean = 0.0;
  7505. float squared_mean = 0.0;
  7506. float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
  7507. float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
  7508. for ( float i = 0.0; i < samples; i ++ ) {
  7509. float uvOffset = uvStart + i * uvStride;
  7510. #ifdef HORIZONTAL_PASS
  7511. vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
  7512. mean += distribution.x;
  7513. squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
  7514. #else
  7515. float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
  7516. mean += depth;
  7517. squared_mean += depth * depth;
  7518. #endif
  7519. }
  7520. mean = mean / samples;
  7521. squared_mean = squared_mean / samples;
  7522. float std_dev = sqrt( squared_mean - mean * mean );
  7523. gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
  7524. }`;function W8e(t,e,n){let r=new pN;const i=new mn,a=new mn,o=new xr,l=new $8e({depthPacking:TFe}),c=new H8e,u={},d=n.maxTextureSize,f={[th]:ws,[ws]:th,[Xc]:Xc},m=new nh({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new mn},radius:{value:4}},vertexShader:V8e,fragmentShader:G8e}),p=m.clone();p.defines.HORIZONTAL_PASS=1;const b=new Ha;b.setAttribute("position",new Xs(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new tl(b,m),x=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Oee;let y=this.type;this.render=function(A,k,C){if(x.enabled===!1||x.autoUpdate===!1&&x.needsUpdate===!1||A.length===0)return;const D=t.getRenderTarget(),T=t.getActiveCubeFace(),R=t.getActiveMipmapLevel(),U=t.state;U.setBlending(Bd),U.buffers.color.setClear(1,1,1,1),U.buffers.depth.setTest(!0),U.setScissorTest(!1);const L=y!==Hc&&this.type===Hc,q=y===Hc&&this.type!==Hc;for(let j=0,W=A.length;j<W;j++){const K=A[j],V=K.shadow;if(V===void 0){console.warn("THREE.WebGLShadowMap:",K,"has no shadow.");continue}if(V.autoUpdate===!1&&V.needsUpdate===!1)continue;i.copy(V.mapSize);const J=V.getFrameExtents();if(i.multiply(J),a.copy(V.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(a.x=Math.floor(d/J.x),i.x=a.x*J.x,V.mapSize.x=a.x),i.y>d&&(a.y=Math.floor(d/J.y),i.y=a.y*J.y,V.mapSize.y=a.y)),V.map===null||L===!0||q===!0){const te=this.type!==Hc?{minFilter:ba,magFilter:ba}:{};V.map!==null&&V.map.dispose(),V.map=new em(i.x,i.y,te),V.map.texture.name=K.name+".shadowMap",V.camera.updateProjectionMatrix()}t.setRenderTarget(V.map),t.clear();const ne=V.getViewportCount();for(let te=0;te<ne;te++){const z=V.getViewport(te);o.set(a.x*z.x,a.y*z.y,a.x*z.z,a.y*z.w),U.viewport(o),V.updateMatrices(K,te),r=V.getFrustum(),N(k,C,V.camera,K,this.type)}V.isPointLightShadow!==!0&&this.type===Hc&&S(V,C),V.needsUpdate=!1}y=this.type,x.needsUpdate=!1,t.setRenderTarget(D,T,R)};function S(A,k){const C=e.update(v);m.defines.VSM_SAMPLES!==A.blurSamples&&(m.defines.VSM_SAMPLES=A.blurSamples,p.defines.VSM_SAMPLES=A.blurSamples,m.needsUpdate=!0,p.needsUpdate=!0),A.mapPass===null&&(A.mapPass=new em(i.x,i.y)),m.uniforms.shadow_pass.value=A.map.texture,m.uniforms.resolution.value=A.mapSize,m.uniforms.radius.value=A.radius,t.setRenderTarget(A.mapPass),t.clear(),t.renderBufferDirect(k,null,C,m,v,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(k,null,C,p,v,null)}function M(A,k,C,D){let T=null;const R=C.isPointLight===!0?A.customDistanceMaterial:A.customDepthMaterial;if(R!==void 0)T=R;else if(T=C.isPointLight===!0?c:l,t.localClippingEnabled&&k.clipShadows===!0&&Array.isArray(k.clippingPlanes)&&k.clippingPlanes.length!==0||k.displacementMap&&k.displacementScale!==0||k.alphaMap&&k.alphaTest>0||k.map&&k.alphaTest>0){const U=T.uuid,L=k.uuid;let q=u[U];q===void 0&&(q={},u[U]=q);let j=q[L];j===void 0&&(j=T.clone(),q[L]=j),T=j}if(T.visible=k.visible,T.wireframe=k.wireframe,D===Hc?T.side=k.shadowSide!==null?k.shadowSide:k.side:T.side=k.shadowSide!==null?k.shadowSide:f[k.side],T.alphaMap=k.alphaMap,T.alphaTest=k.alphaTest,T.map=k.map,T.clipShadows=k.clipShadows,T.clippingPlanes=k.clippingPlanes,T.clipIntersection=k.clipIntersection,T.displacementMap=k.displacementMap,T.displacementScale=k.displacementScale,T.displacementBias=k.displacementBias,T.wireframeLinewidth=k.wireframeLinewidth,T.linewidth=k.linewidth,C.isPointLight===!0&&T.isMeshDistanceMaterial===!0){const U=t.properties.get(T);U.light=C}return T}function N(A,k,C,D,T){if(A.visible===!1)return;if(A.layers.test(k.layers)&&(A.isMesh||A.isLine||A.isPoints)&&(A.castShadow||A.receiveShadow&&T===Hc)&&(!A.frustumCulled||r.intersectsObject(A))){A.modelViewMatrix.multiplyMatrices(C.matrixWorldInverse,A.matrixWorld);const L=e.update(A),q=A.material;if(Array.isArray(q)){const j=L.groups;for(let W=0,K=j.length;W<K;W++){const V=j[W],J=q[V.materialIndex];if(J&&J.visible){const ne=M(A,J,D,T);A.onBeforeShadow(t,A,k,C,L,ne,V),t.renderBufferDirect(C,null,L,ne,A,V),A.onAfterShadow(t,A,k,C,L,ne,V)}}}else if(q.visible){const j=M(A,q,D,T);A.onBeforeShadow(t,A,k,C,L,j,null),t.renderBufferDirect(C,null,L,j,A,null),A.onAfterShadow(t,A,k,C,L,j,null)}}const U=A.children;for(let L=0,q=U.length;L<q;L++)N(U[L],k,C,D,T)}}function q8e(t,e,n){const r=n.isWebGL2;function i(){let ve=!1;const $e=new xr;let Le=null;const Ae=new xr(0,0,0,0);return{setMask:function(Ge){Le!==Ge&&!ve&&(t.colorMask(Ge,Ge,Ge,Ge),Le=Ge)},setLocked:function(Ge){ve=Ge},setClear:function(Ge,it,Ot,kt,on){on===!0&&(Ge*=kt,it*=kt,Ot*=kt),$e.set(Ge,it,Ot,kt),Ae.equals($e)===!1&&(t.clearColor(Ge,it,Ot,kt),Ae.copy($e))},reset:function(){ve=!1,Le=null,Ae.set(-1,0,0,0)}}}function a(){let ve=!1,$e=null,Le=null,Ae=null;return{setTest:function(Ge){Ge?ge(t.DEPTH_TEST):Se(t.DEPTH_TEST)},setMask:function(Ge){$e!==Ge&&!ve&&(t.depthMask(Ge),$e=Ge)},setFunc:function(Ge){if(Le!==Ge){switch(Ge){case iFe:t.depthFunc(t.NEVER);break;case aFe:t.depthFunc(t.ALWAYS);break;case sFe:t.depthFunc(t.LESS);break;case VS:t.depthFunc(t.LEQUAL);break;case oFe:t.depthFunc(t.EQUAL);break;case lFe:t.depthFunc(t.GEQUAL);break;case cFe:t.depthFunc(t.GREATER);break;case uFe:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}Le=Ge}},setLocked:function(Ge){ve=Ge},setClear:function(Ge){Ae!==Ge&&(t.clearDepth(Ge),Ae=Ge)},reset:function(){ve=!1,$e=null,Le=null,Ae=null}}}function o(){let ve=!1,$e=null,Le=null,Ae=null,Ge=null,it=null,Ot=null,kt=null,on=null;return{setTest:function(Ut){ve||(Ut?ge(t.STENCIL_TEST):Se(t.STENCIL_TEST))},setMask:function(Ut){$e!==Ut&&!ve&&(t.stencilMask(Ut),$e=Ut)},setFunc:function(Ut,yn,xt){(Le!==Ut||Ae!==yn||Ge!==xt)&&(t.stencilFunc(Ut,yn,xt),Le=Ut,Ae=yn,Ge=xt)},setOp:function(Ut,yn,xt){(it!==Ut||Ot!==yn||kt!==xt)&&(t.stencilOp(Ut,yn,xt),it=Ut,Ot=yn,kt=xt)},setLocked:function(Ut){ve=Ut},setClear:function(Ut){on!==Ut&&(t.clearStencil(Ut),on=Ut)},reset:function(){ve=!1,$e=null,Le=null,Ae=null,Ge=null,it=null,Ot=null,kt=null,on=null}}}const l=new i,c=new a,u=new o,d=new WeakMap,f=new WeakMap;let m={},p={},b=new WeakMap,v=[],x=null,y=!1,S=null,M=null,N=null,A=null,k=null,C=null,D=null,T=new rn(0,0,0),R=0,U=!1,L=null,q=null,j=null,W=null,K=null;const V=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let J=!1,ne=0;const te=t.getParameter(t.VERSION);te.indexOf("WebGL")!==-1?(ne=parseFloat(/^WebGL (\d)/.exec(te)[1]),J=ne>=1):te.indexOf("OpenGL ES")!==-1&&(ne=parseFloat(/^OpenGL ES (\d)/.exec(te)[1]),J=ne>=2);let z=null,H={};const Z=t.getParameter(t.SCISSOR_BOX),ee=t.getParameter(t.VIEWPORT),he=new xr().fromArray(Z),fe=new xr().fromArray(ee);function oe(ve,$e,Le,Ae){const Ge=new Uint8Array(4),it=t.createTexture();t.bindTexture(ve,it),t.texParameteri(ve,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(ve,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let Ot=0;Ot<Le;Ot++)r&&(ve===t.TEXTURE_3D||ve===t.TEXTURE_2D_ARRAY)?t.texImage3D($e,0,t.RGBA,1,1,Ae,0,t.RGBA,t.UNSIGNED_BYTE,Ge):t.texImage2D($e+Ot,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Ge);return it}const Ne={};Ne[t.TEXTURE_2D]=oe(t.TEXTURE_2D,t.TEXTURE_2D,1),Ne[t.TEXTURE_CUBE_MAP]=oe(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),r&&(Ne[t.TEXTURE_2D_ARRAY]=oe(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),Ne[t.TEXTURE_3D]=oe(t.TEXTURE_3D,t.TEXTURE_3D,1,1)),l.setClear(0,0,0,1),c.setClear(1),u.setClear(0),ge(t.DEPTH_TEST),c.setFunc(VS),I(!1),ce(AG),ge(t.CULL_FACE),X(Bd);function ge(ve){m[ve]!==!0&&(t.enable(ve),m[ve]=!0)}function Se(ve){m[ve]!==!1&&(t.disable(ve),m[ve]=!1)}function Re(ve,$e){return p[ve]!==$e?(t.bindFramebuffer(ve,$e),p[ve]=$e,r&&(ve===t.DRAW_FRAMEBUFFER&&(p[t.FRAMEBUFFER]=$e),ve===t.FRAMEBUFFER&&(p[t.DRAW_FRAMEBUFFER]=$e)),!0):!1}function de(ve,$e){let Le=v,Ae=!1;if(ve)if(Le=b.get($e),Le===void 0&&(Le=[],b.set($e,Le)),ve.isWebGLMultipleRenderTargets){const Ge=ve.texture;if(Le.length!==Ge.length||Le[0]!==t.COLOR_ATTACHMENT0){for(let it=0,Ot=Ge.length;it<Ot;it++)Le[it]=t.COLOR_ATTACHMENT0+it;Le.length=Ge.length,Ae=!0}}else Le[0]!==t.COLOR_ATTACHMENT0&&(Le[0]=t.COLOR_ATTACHMENT0,Ae=!0);else Le[0]!==t.BACK&&(Le[0]=t.BACK,Ae=!0);Ae&&(n.isWebGL2?t.drawBuffers(Le):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(Le))}function Qe(ve){return x!==ve?(t.useProgram(ve),x=ve,!0):!1}const G={[tf]:t.FUNC_ADD,[HIe]:t.FUNC_SUBTRACT,[VIe]:t.FUNC_REVERSE_SUBTRACT};if(r)G[jG]=t.MIN,G[PG]=t.MAX;else{const ve=e.get("EXT_blend_minmax");ve!==null&&(G[jG]=ve.MIN_EXT,G[PG]=ve.MAX_EXT)}const ie={[GIe]:t.ZERO,[WIe]:t.ONE,[qIe]:t.SRC_COLOR,[vR]:t.SRC_ALPHA,[JIe]:t.SRC_ALPHA_SATURATE,[ZIe]:t.DST_COLOR,[XIe]:t.DST_ALPHA,[KIe]:t.ONE_MINUS_SRC_COLOR,[_R]:t.ONE_MINUS_SRC_ALPHA,[QIe]:t.ONE_MINUS_DST_COLOR,[YIe]:t.ONE_MINUS_DST_ALPHA,[eFe]:t.CONSTANT_COLOR,[tFe]:t.ONE_MINUS_CONSTANT_COLOR,[nFe]:t.CONSTANT_ALPHA,[rFe]:t.ONE_MINUS_CONSTANT_ALPHA};function X(ve,$e,Le,Ae,Ge,it,Ot,kt,on,Ut){if(ve===Bd){y===!0&&(Se(t.BLEND),y=!1);return}if(y===!1&&(ge(t.BLEND),y=!0),ve!==$Ie){if(ve!==S||Ut!==U){if((M!==tf||k!==tf)&&(t.blendEquation(t.FUNC_ADD),M=tf,k=tf),Ut)switch(ve){case sg:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case TG:t.blendFunc(t.ONE,t.ONE);break;case CG:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case kG:t.blendFuncSeparate(t.ZERO,t.SRC_COLOR,t.ZERO,t.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",ve);break}else switch(ve){case sg:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case TG:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case CG:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case kG:t.blendFunc(t.ZERO,t.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",ve);break}N=null,A=null,C=null,D=null,T.set(0,0,0),R=0,S=ve,U=Ut}return}Ge=Ge||$e,it=it||Le,Ot=Ot||Ae,($e!==M||Ge!==k)&&(t.blendEquationSeparate(G[$e],G[Ge]),M=$e,k=Ge),(Le!==N||Ae!==A||it!==C||Ot!==D)&&(t.blendFuncSeparate(ie[Le],ie[Ae],ie[it],ie[Ot]),N=Le,A=Ae,C=it,D=Ot),(kt.equals(T)===!1||on!==R)&&(t.blendColor(kt.r,kt.g,kt.b,on),T.copy(kt),R=on),S=ve,U=!1}function $(ve,$e){ve.side===Xc?Se(t.CULL_FACE):ge(t.CULL_FACE);let Le=ve.side===ws;$e&&(Le=!Le),I(Le),ve.blending===sg&&ve.transparent===!1?X(Bd):X(ve.blending,ve.blendEquation,ve.blendSrc,ve.blendDst,ve.blendEquationAlpha,ve.blendSrcAlpha,ve.blendDstAlpha,ve.blendColor,ve.blendAlpha,ve.premultipliedAlpha),c.setFunc(ve.depthFunc),c.setTest(ve.depthTest),c.setMask(ve.depthWrite),l.setMask(ve.colorWrite);const Ae=ve.stencilWrite;u.setTest(Ae),Ae&&(u.setMask(ve.stencilWriteMask),u.setFunc(ve.stencilFunc,ve.stencilRef,ve.stencilFuncMask),u.setOp(ve.stencilFail,ve.stencilZFail,ve.stencilZPass)),Ie(ve.polygonOffset,ve.polygonOffsetFactor,ve.polygonOffsetUnits),ve.alphaToCoverage===!0?ge(t.SAMPLE_ALPHA_TO_COVERAGE):Se(t.SAMPLE_ALPHA_TO_COVERAGE)}function I(ve){L!==ve&&(ve?t.frontFace(t.CW):t.frontFace(t.CCW),L=ve)}function ce(ve){ve!==UIe?(ge(t.CULL_FACE),ve!==q&&(ve===AG?t.cullFace(t.BACK):ve===zIe?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):Se(t.CULL_FACE),q=ve}function Ee(ve){ve!==j&&(J&&t.lineWidth(ve),j=ve)}function Ie(ve,$e,Le){ve?(ge(t.POLYGON_OFFSET_FILL),(W!==$e||K!==Le)&&(t.polygonOffset($e,Le),W=$e,K=Le)):Se(t.POLYGON_OFFSET_FILL)}function le(ve){ve?ge(t.SCISSOR_TEST):Se(t.SCISSOR_TEST)}function B(ve){ve===void 0&&(ve=t.TEXTURE0+V-1),z!==ve&&(t.activeTexture(ve),z=ve)}function O(ve,$e,Le){Le===void 0&&(z===null?Le=t.TEXTURE0+V-1:Le=z);let Ae=H[Le];Ae===void 0&&(Ae={type:void 0,texture:void 0},H[Le]=Ae),(Ae.type!==ve||Ae.texture!==$e)&&(z!==Le&&(t.activeTexture(Le),z=Le),t.bindTexture(ve,$e||Ne[ve]),Ae.type=ve,Ae.texture=$e)}function Y(){const ve=H[z];ve!==void 0&&ve.type!==void 0&&(t.bindTexture(ve.type,null),ve.type=void 0,ve.texture=void 0)}function pe(){try{t.compressedTexImage2D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function we(){try{t.compressedTexImage3D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function ae(){try{t.texSubImage2D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function ke(){try{t.texSubImage3D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function De(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function Ke(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function et(){try{t.texStorage2D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function Ye(){try{t.texStorage3D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function se(){try{t.texImage2D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function ye(){try{t.texImage3D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function Ce(ve){he.equals(ve)===!1&&(t.scissor(ve.x,ve.y,ve.z,ve.w),he.copy(ve))}function Ue(ve){fe.equals(ve)===!1&&(t.viewport(ve.x,ve.y,ve.z,ve.w),fe.copy(ve))}function dt(ve,$e){let Le=f.get($e);Le===void 0&&(Le=new WeakMap,f.set($e,Le));let Ae=Le.get(ve);Ae===void 0&&(Ae=t.getUniformBlockIndex($e,ve.name),Le.set(ve,Ae))}function re(ve,$e){const Ae=f.get($e).get(ve);d.get($e)!==Ae&&(t.uniformBlockBinding($e,Ae,ve.__bindingPointIndex),d.set($e,Ae))}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),m={},z=null,H={},p={},b=new WeakMap,v=[],x=null,y=!1,S=null,M=null,N=null,A=null,k=null,C=null,D=null,T=new rn(0,0,0),R=0,U=!1,L=null,q=null,j=null,W=null,K=null,he.set(0,0,t.canvas.width,t.canvas.height),fe.set(0,0,t.canvas.width,t.canvas.height),l.reset(),c.reset(),u.reset()}return{buffers:{color:l,depth:c,stencil:u},enable:ge,disable:Se,bindFramebuffer:Re,drawBuffers:de,useProgram:Qe,setBlending:X,setMaterial:$,setFlipSided:I,setCullFace:ce,setLineWidth:Ee,setPolygonOffset:Ie,setScissorTest:le,activeTexture:B,bindTexture:O,unbindTexture:Y,compressedTexImage2D:pe,compressedTexImage3D:we,texImage2D:se,texImage3D:ye,updateUBOMapping:dt,uniformBlockBinding:re,texStorage2D:et,texStorage3D:Ye,texSubImage2D:ae,texSubImage3D:ke,compressedTexSubImage2D:De,compressedTexSubImage3D:Ke,scissor:Ce,viewport:Ue,reset:Fe}}function K8e(t,e,n,r,i,a,o){const l=i.isWebGL2,c=i.maxTextures,u=i.maxCubemapSize,d=i.maxTextureSize,f=i.maxSamples,m=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,p=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),b=new WeakMap;let v;const x=new WeakMap;let y=!1;try{y=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function S(B,O){return y?new OffscreenCanvas(B,O):XS("canvas")}function M(B,O,Y,pe){let we=1;if((B.width>pe||B.height>pe)&&(we=pe/Math.max(B.width,B.height)),we<1||O===!0)if(typeof HTMLImageElement<"u"&&B instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&B instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&B instanceof ImageBitmap){const ae=O?KS:Math.floor,ke=ae(we*B.width),De=ae(we*B.height);v===void 0&&(v=S(ke,De));const Ke=Y?S(ke,De):v;return Ke.width=ke,Ke.height=De,Ke.getContext("2d").drawImage(B,0,0,ke,De),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+B.width+"x"+B.height+") to ("+ke+"x"+De+")."),Ke}else return"data"in B&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+B.width+"x"+B.height+")."),B;return B}function N(B){return TR(B.width)&&TR(B.height)}function A(B){return l?!1:B.wrapS!==Qo||B.wrapT!==Qo||B.minFilter!==ba&&B.minFilter!==Mo}function k(B,O){return B.generateMipmaps&&O&&B.minFilter!==ba&&B.minFilter!==Mo}function C(B){t.generateMipmap(B)}function D(B,O,Y,pe,we=!1){if(l===!1)return O;if(B!==null){if(t[B]!==void 0)return t[B];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+B+"'")}let ae=O;if(O===t.RED&&(Y===t.FLOAT&&(ae=t.R32F),Y===t.HALF_FLOAT&&(ae=t.R16F),Y===t.UNSIGNED_BYTE&&(ae=t.R8)),O===t.RED_INTEGER&&(Y===t.UNSIGNED_BYTE&&(ae=t.R8UI),Y===t.UNSIGNED_SHORT&&(ae=t.R16UI),Y===t.UNSIGNED_INT&&(ae=t.R32UI),Y===t.BYTE&&(ae=t.R8I),Y===t.SHORT&&(ae=t.R16I),Y===t.INT&&(ae=t.R32I)),O===t.RG&&(Y===t.FLOAT&&(ae=t.RG32F),Y===t.HALF_FLOAT&&(ae=t.RG16F),Y===t.UNSIGNED_BYTE&&(ae=t.RG8)),O===t.RGBA){const ke=we?GS:pr.getTransfer(pe);Y===t.FLOAT&&(ae=t.RGBA32F),Y===t.HALF_FLOAT&&(ae=t.RGBA16F),Y===t.UNSIGNED_BYTE&&(ae=ke===Dr?t.SRGB8_ALPHA8:t.RGBA8),Y===t.UNSIGNED_SHORT_4_4_4_4&&(ae=t.RGBA4),Y===t.UNSIGNED_SHORT_5_5_5_1&&(ae=t.RGB5_A1)}return(ae===t.R16F||ae===t.R32F||ae===t.RG16F||ae===t.RG32F||ae===t.RGBA16F||ae===t.RGBA32F)&&e.get("EXT_color_buffer_float"),ae}function T(B,O,Y){return k(B,Y)===!0||B.isFramebufferTexture&&B.minFilter!==ba&&B.minFilter!==Mo?Math.log2(Math.max(O.width,O.height))+1:B.mipmaps!==void 0&&B.mipmaps.length>0?B.mipmaps.length:B.isCompressedTexture&&Array.isArray(B.image)?O.mipmaps.length:1}function R(B){return B===ba||B===RG||B===Ak?t.NEAREST:t.LINEAR}function U(B){const O=B.target;O.removeEventListener("dispose",U),q(O),O.isVideoTexture&&b.delete(O)}function L(B){const O=B.target;O.removeEventListener("dispose",L),W(O)}function q(B){const O=r.get(B);if(O.__webglInit===void 0)return;const Y=B.source,pe=x.get(Y);if(pe){const we=pe[O.__cacheKey];we.usedTimes--,we.usedTimes===0&&j(B),Object.keys(pe).length===0&&x.delete(Y)}r.remove(B)}function j(B){const O=r.get(B);t.deleteTexture(O.__webglTexture);const Y=B.source,pe=x.get(Y);delete pe[O.__cacheKey],o.memory.textures--}function W(B){const O=B.texture,Y=r.get(B),pe=r.get(O);if(pe.__webglTexture!==void 0&&(t.deleteTexture(pe.__webglTexture),o.memory.textures--),B.depthTexture&&B.depthTexture.dispose(),B.isWebGLCubeRenderTarget)for(let we=0;we<6;we++){if(Array.isArray(Y.__webglFramebuffer[we]))for(let ae=0;ae<Y.__webglFramebuffer[we].length;ae++)t.deleteFramebuffer(Y.__webglFramebuffer[we][ae]);else t.deleteFramebuffer(Y.__webglFramebuffer[we]);Y.__webglDepthbuffer&&t.deleteRenderbuffer(Y.__webglDepthbuffer[we])}else{if(Array.isArray(Y.__webglFramebuffer))for(let we=0;we<Y.__webglFramebuffer.length;we++)t.deleteFramebuffer(Y.__webglFramebuffer[we]);else t.deleteFramebuffer(Y.__webglFramebuffer);if(Y.__webglDepthbuffer&&t.deleteRenderbuffer(Y.__webglDepthbuffer),Y.__webglMultisampledFramebuffer&&t.deleteFramebuffer(Y.__webglMultisampledFramebuffer),Y.__webglColorRenderbuffer)for(let we=0;we<Y.__webglColorRenderbuffer.length;we++)Y.__webglColorRenderbuffer[we]&&t.deleteRenderbuffer(Y.__webglColorRenderbuffer[we]);Y.__webglDepthRenderbuffer&&t.deleteRenderbuffer(Y.__webglDepthRenderbuffer)}if(B.isWebGLMultipleRenderTargets)for(let we=0,ae=O.length;we<ae;we++){const ke=r.get(O[we]);ke.__webglTexture&&(t.deleteTexture(ke.__webglTexture),o.memory.textures--),r.remove(O[we])}r.remove(O),r.remove(B)}let K=0;function V(){K=0}function J(){const B=K;return B>=c&&console.warn("THREE.WebGLTextures: Trying to use "+B+" texture units while this GPU supports only "+c),K+=1,B}function ne(B){const O=[];return O.push(B.wrapS),O.push(B.wrapT),O.push(B.wrapR||0),O.push(B.magFilter),O.push(B.minFilter),O.push(B.anisotropy),O.push(B.internalFormat),O.push(B.format),O.push(B.type),O.push(B.generateMipmaps),O.push(B.premultiplyAlpha),O.push(B.flipY),O.push(B.unpackAlignment),O.push(B.colorSpace),O.join()}function te(B,O){const Y=r.get(B);if(B.isVideoTexture&&Ie(B),B.isRenderTargetTexture===!1&&B.version>0&&Y.__version!==B.version){const pe=B.image;if(pe===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(pe.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ge(Y,B,O);return}}n.bindTexture(t.TEXTURE_2D,Y.__webglTexture,t.TEXTURE0+O)}function z(B,O){const Y=r.get(B);if(B.version>0&&Y.__version!==B.version){ge(Y,B,O);return}n.bindTexture(t.TEXTURE_2D_ARRAY,Y.__webglTexture,t.TEXTURE0+O)}function H(B,O){const Y=r.get(B);if(B.version>0&&Y.__version!==B.version){ge(Y,B,O);return}n.bindTexture(t.TEXTURE_3D,Y.__webglTexture,t.TEXTURE0+O)}function Z(B,O){const Y=r.get(B);if(B.version>0&&Y.__version!==B.version){Se(Y,B,O);return}n.bindTexture(t.TEXTURE_CUBE_MAP,Y.__webglTexture,t.TEXTURE0+O)}const ee={[MR]:t.REPEAT,[Qo]:t.CLAMP_TO_EDGE,[ER]:t.MIRRORED_REPEAT},he={[ba]:t.NEAREST,[RG]:t.NEAREST_MIPMAP_NEAREST,[Ak]:t.NEAREST_MIPMAP_LINEAR,[Mo]:t.LINEAR,[bFe]:t.LINEAR_MIPMAP_NEAREST,[Y0]:t.LINEAR_MIPMAP_LINEAR},fe={[kFe]:t.NEVER,[LFe]:t.ALWAYS,[jFe]:t.LESS,[Wee]:t.LEQUAL,[PFe]:t.EQUAL,[OFe]:t.GEQUAL,[RFe]:t.GREATER,[DFe]:t.NOTEQUAL};function oe(B,O,Y){if(Y?(t.texParameteri(B,t.TEXTURE_WRAP_S,ee[O.wrapS]),t.texParameteri(B,t.TEXTURE_WRAP_T,ee[O.wrapT]),(B===t.TEXTURE_3D||B===t.TEXTURE_2D_ARRAY)&&t.texParameteri(B,t.TEXTURE_WRAP_R,ee[O.wrapR]),t.texParameteri(B,t.TEXTURE_MAG_FILTER,he[O.magFilter]),t.texParameteri(B,t.TEXTURE_MIN_FILTER,he[O.minFilter])):(t.texParameteri(B,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(B,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),(B===t.TEXTURE_3D||B===t.TEXTURE_2D_ARRAY)&&t.texParameteri(B,t.TEXTURE_WRAP_R,t.CLAMP_TO_EDGE),(O.wrapS!==Qo||O.wrapT!==Qo)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),t.texParameteri(B,t.TEXTURE_MAG_FILTER,R(O.magFilter)),t.texParameteri(B,t.TEXTURE_MIN_FILTER,R(O.minFilter)),O.minFilter!==ba&&O.minFilter!==Mo&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),O.compareFunction&&(t.texParameteri(B,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(B,t.TEXTURE_COMPARE_FUNC,fe[O.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const pe=e.get("EXT_texture_filter_anisotropic");if(O.magFilter===ba||O.minFilter!==Ak&&O.minFilter!==Y0||O.type===eu&&e.has("OES_texture_float_linear")===!1||l===!1&&O.type===Z0&&e.has("OES_texture_half_float_linear")===!1)return;(O.anisotropy>1||r.get(O).__currentAnisotropy)&&(t.texParameterf(B,pe.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(O.anisotropy,i.getMaxAnisotropy())),r.get(O).__currentAnisotropy=O.anisotropy)}}function Ne(B,O){let Y=!1;B.__webglInit===void 0&&(B.__webglInit=!0,O.addEventListener("dispose",U));const pe=O.source;let we=x.get(pe);we===void 0&&(we={},x.set(pe,we));const ae=ne(O);if(ae!==B.__cacheKey){we[ae]===void 0&&(we[ae]={texture:t.createTexture(),usedTimes:0},o.memory.textures++,Y=!0),we[ae].usedTimes++;const ke=we[B.__cacheKey];ke!==void 0&&(we[B.__cacheKey].usedTimes--,ke.usedTimes===0&&j(O)),B.__cacheKey=ae,B.__webglTexture=we[ae].texture}return Y}function ge(B,O,Y){let pe=t.TEXTURE_2D;(O.isDataArrayTexture||O.isCompressedArrayTexture)&&(pe=t.TEXTURE_2D_ARRAY),O.isData3DTexture&&(pe=t.TEXTURE_3D);const we=Ne(B,O),ae=O.source;n.bindTexture(pe,B.__webglTexture,t.TEXTURE0+Y);const ke=r.get(ae);if(ae.version!==ke.__version||we===!0){n.activeTexture(t.TEXTURE0+Y);const De=pr.getPrimaries(pr.workingColorSpace),Ke=O.colorSpace===No?null:pr.getPrimaries(O.colorSpace),et=O.colorSpace===No||De===Ke?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,O.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,O.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,O.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,et);const Ye=A(O)&&N(O.image)===!1;let se=M(O.image,Ye,!1,d);se=le(O,se);const ye=N(se)||l,Ce=a.convert(O.format,O.colorSpace);let Ue=a.convert(O.type),dt=D(O.internalFormat,Ce,Ue,O.colorSpace,O.isVideoTexture);oe(pe,O,ye);let re;const Fe=O.mipmaps,ve=l&&O.isVideoTexture!==!0&&dt!==Hee,$e=ke.__version===void 0||we===!0,Le=T(O,se,ye);if(O.isDepthTexture)dt=t.DEPTH_COMPONENT,l?O.type===eu?dt=t.DEPTH_COMPONENT32F:O.type===kd?dt=t.DEPTH_COMPONENT24:O.type===Nf?dt=t.DEPTH24_STENCIL8:dt=t.DEPTH_COMPONENT16:O.type===eu&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),O.format===Af&&dt===t.DEPTH_COMPONENT&&O.type!==fL&&O.type!==kd&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),O.type=kd,Ue=a.convert(O.type)),O.format===Rg&&dt===t.DEPTH_COMPONENT&&(dt=t.DEPTH_STENCIL,O.type!==Nf&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),O.type=Nf,Ue=a.convert(O.type))),$e&&(ve?n.texStorage2D(t.TEXTURE_2D,1,dt,se.width,se.height):n.texImage2D(t.TEXTURE_2D,0,dt,se.width,se.height,0,Ce,Ue,null));else if(O.isDataTexture)if(Fe.length>0&&ye){ve&&$e&&n.texStorage2D(t.TEXTURE_2D,Le,dt,Fe[0].width,Fe[0].height);for(let Ae=0,Ge=Fe.length;Ae<Ge;Ae++)re=Fe[Ae],ve?n.texSubImage2D(t.TEXTURE_2D,Ae,0,0,re.width,re.height,Ce,Ue,re.data):n.texImage2D(t.TEXTURE_2D,Ae,dt,re.width,re.height,0,Ce,Ue,re.data);O.generateMipmaps=!1}else ve?($e&&n.texStorage2D(t.TEXTURE_2D,Le,dt,se.width,se.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,se.width,se.height,Ce,Ue,se.data)):n.texImage2D(t.TEXTURE_2D,0,dt,se.width,se.height,0,Ce,Ue,se.data);else if(O.isCompressedTexture)if(O.isCompressedArrayTexture){ve&&$e&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Le,dt,Fe[0].width,Fe[0].height,se.depth);for(let Ae=0,Ge=Fe.length;Ae<Ge;Ae++)re=Fe[Ae],O.format!==Eo?Ce!==null?ve?n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Ae,0,0,0,re.width,re.height,se.depth,Ce,re.data,0,0):n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,Ae,dt,re.width,re.height,se.depth,0,re.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ve?n.texSubImage3D(t.TEXTURE_2D_ARRAY,Ae,0,0,0,re.width,re.height,se.depth,Ce,Ue,re.data):n.texImage3D(t.TEXTURE_2D_ARRAY,Ae,dt,re.width,re.height,se.depth,0,Ce,Ue,re.data)}else{ve&&$e&&n.texStorage2D(t.TEXTURE_2D,Le,dt,Fe[0].width,Fe[0].height);for(let Ae=0,Ge=Fe.length;Ae<Ge;Ae++)re=Fe[Ae],O.format!==Eo?Ce!==null?ve?n.compressedTexSubImage2D(t.TEXTURE_2D,Ae,0,0,re.width,re.height,Ce,re.data):n.compressedTexImage2D(t.TEXTURE_2D,Ae,dt,re.width,re.height,0,re.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ve?n.texSubImage2D(t.TEXTURE_2D,Ae,0,0,re.width,re.height,Ce,Ue,re.data):n.texImage2D(t.TEXTURE_2D,Ae,dt,re.width,re.height,0,Ce,Ue,re.data)}else if(O.isDataArrayTexture)ve?($e&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Le,dt,se.width,se.height,se.depth),n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,se.width,se.height,se.depth,Ce,Ue,se.data)):n.texImage3D(t.TEXTURE_2D_ARRAY,0,dt,se.width,se.height,se.depth,0,Ce,Ue,se.data);else if(O.isData3DTexture)ve?($e&&n.texStorage3D(t.TEXTURE_3D,Le,dt,se.width,se.height,se.depth),n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,se.width,se.height,se.depth,Ce,Ue,se.data)):n.texImage3D(t.TEXTURE_3D,0,dt,se.width,se.height,se.depth,0,Ce,Ue,se.data);else if(O.isFramebufferTexture){if($e)if(ve)n.texStorage2D(t.TEXTURE_2D,Le,dt,se.width,se.height);else{let Ae=se.width,Ge=se.height;for(let it=0;it<Le;it++)n.texImage2D(t.TEXTURE_2D,it,dt,Ae,Ge,0,Ce,Ue,null),Ae>>=1,Ge>>=1}}else if(Fe.length>0&&ye){ve&&$e&&n.texStorage2D(t.TEXTURE_2D,Le,dt,Fe[0].width,Fe[0].height);for(let Ae=0,Ge=Fe.length;Ae<Ge;Ae++)re=Fe[Ae],ve?n.texSubImage2D(t.TEXTURE_2D,Ae,0,0,Ce,Ue,re):n.texImage2D(t.TEXTURE_2D,Ae,dt,Ce,Ue,re);O.generateMipmaps=!1}else ve?($e&&n.texStorage2D(t.TEXTURE_2D,Le,dt,se.width,se.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,Ce,Ue,se)):n.texImage2D(t.TEXTURE_2D,0,dt,Ce,Ue,se);k(O,ye)&&C(pe),ke.__version=ae.version,O.onUpdate&&O.onUpdate(O)}B.__version=O.version}function Se(B,O,Y){if(O.image.length!==6)return;const pe=Ne(B,O),we=O.source;n.bindTexture(t.TEXTURE_CUBE_MAP,B.__webglTexture,t.TEXTURE0+Y);const ae=r.get(we);if(we.version!==ae.__version||pe===!0){n.activeTexture(t.TEXTURE0+Y);const ke=pr.getPrimaries(pr.workingColorSpace),De=O.colorSpace===No?null:pr.getPrimaries(O.colorSpace),Ke=O.colorSpace===No||ke===De?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,O.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,O.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,O.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ke);const et=O.isCompressedTexture||O.image[0].isCompressedTexture,Ye=O.image[0]&&O.image[0].isDataTexture,se=[];for(let Ae=0;Ae<6;Ae++)!et&&!Ye?se[Ae]=M(O.image[Ae],!1,!0,u):se[Ae]=Ye?O.image[Ae].image:O.image[Ae],se[Ae]=le(O,se[Ae]);const ye=se[0],Ce=N(ye)||l,Ue=a.convert(O.format,O.colorSpace),dt=a.convert(O.type),re=D(O.internalFormat,Ue,dt,O.colorSpace),Fe=l&&O.isVideoTexture!==!0,ve=ae.__version===void 0||pe===!0;let $e=T(O,ye,Ce);oe(t.TEXTURE_CUBE_MAP,O,Ce);let Le;if(et){Fe&&ve&&n.texStorage2D(t.TEXTURE_CUBE_MAP,$e,re,ye.width,ye.height);for(let Ae=0;Ae<6;Ae++){Le=se[Ae].mipmaps;for(let Ge=0;Ge<Le.length;Ge++){const it=Le[Ge];O.format!==Eo?Ue!==null?Fe?n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Ge,0,0,it.width,it.height,Ue,it.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Ge,re,it.width,it.height,0,it.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Fe?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Ge,0,0,it.width,it.height,Ue,dt,it.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Ge,re,it.width,it.height,0,Ue,dt,it.data)}}}else{Le=O.mipmaps,Fe&&ve&&(Le.length>0&&$e++,n.texStorage2D(t.TEXTURE_CUBE_MAP,$e,re,se[0].width,se[0].height));for(let Ae=0;Ae<6;Ae++)if(Ye){Fe?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,0,0,0,se[Ae].width,se[Ae].height,Ue,dt,se[Ae].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,0,re,se[Ae].width,se[Ae].height,0,Ue,dt,se[Ae].data);for(let Ge=0;Ge<Le.length;Ge++){const Ot=Le[Ge].image[Ae].image;Fe?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Ge+1,0,0,Ot.width,Ot.height,Ue,dt,Ot.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Ge+1,re,Ot.width,Ot.height,0,Ue,dt,Ot.data)}}else{Fe?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,0,0,0,Ue,dt,se[Ae]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,0,re,Ue,dt,se[Ae]);for(let Ge=0;Ge<Le.length;Ge++){const it=Le[Ge];Fe?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Ge+1,0,0,Ue,dt,it.image[Ae]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Ge+1,re,Ue,dt,it.image[Ae])}}}k(O,Ce)&&C(t.TEXTURE_CUBE_MAP),ae.__version=we.version,O.onUpdate&&O.onUpdate(O)}B.__version=O.version}function Re(B,O,Y,pe,we,ae){const ke=a.convert(Y.format,Y.colorSpace),De=a.convert(Y.type),Ke=D(Y.internalFormat,ke,De,Y.colorSpace);if(!r.get(O).__hasExternalTextures){const Ye=Math.max(1,O.width>>ae),se=Math.max(1,O.height>>ae);we===t.TEXTURE_3D||we===t.TEXTURE_2D_ARRAY?n.texImage3D(we,ae,Ke,Ye,se,O.depth,0,ke,De,null):n.texImage2D(we,ae,Ke,Ye,se,0,ke,De,null)}n.bindFramebuffer(t.FRAMEBUFFER,B),Ee(O)?m.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,pe,we,r.get(Y).__webglTexture,0,ce(O)):(we===t.TEXTURE_2D||we>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&we<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,pe,we,r.get(Y).__webglTexture,ae),n.bindFramebuffer(t.FRAMEBUFFER,null)}function de(B,O,Y){if(t.bindRenderbuffer(t.RENDERBUFFER,B),O.depthBuffer&&!O.stencilBuffer){let pe=l===!0?t.DEPTH_COMPONENT24:t.DEPTH_COMPONENT16;if(Y||Ee(O)){const we=O.depthTexture;we&&we.isDepthTexture&&(we.type===eu?pe=t.DEPTH_COMPONENT32F:we.type===kd&&(pe=t.DEPTH_COMPONENT24));const ae=ce(O);Ee(O)?m.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ae,pe,O.width,O.height):t.renderbufferStorageMultisample(t.RENDERBUFFER,ae,pe,O.width,O.height)}else t.renderbufferStorage(t.RENDERBUFFER,pe,O.width,O.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,B)}else if(O.depthBuffer&&O.stencilBuffer){const pe=ce(O);Y&&Ee(O)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,pe,t.DEPTH24_STENCIL8,O.width,O.height):Ee(O)?m.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,pe,t.DEPTH24_STENCIL8,O.width,O.height):t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,O.width,O.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,B)}else{const pe=O.isWebGLMultipleRenderTargets===!0?O.texture:[O.texture];for(let we=0;we<pe.length;we++){const ae=pe[we],ke=a.convert(ae.format,ae.colorSpace),De=a.convert(ae.type),Ke=D(ae.internalFormat,ke,De,ae.colorSpace),et=ce(O);Y&&Ee(O)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,et,Ke,O.width,O.height):Ee(O)?m.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,et,Ke,O.width,O.height):t.renderbufferStorage(t.RENDERBUFFER,Ke,O.width,O.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function Qe(B,O){if(O&&O.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,B),!(O.depthTexture&&O.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(O.depthTexture).__webglTexture||O.depthTexture.image.width!==O.width||O.depthTexture.image.height!==O.height)&&(O.depthTexture.image.width=O.width,O.depthTexture.image.height=O.height,O.depthTexture.needsUpdate=!0),te(O.depthTexture,0);const pe=r.get(O.depthTexture).__webglTexture,we=ce(O);if(O.depthTexture.format===Af)Ee(O)?m.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,pe,0,we):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,pe,0);else if(O.depthTexture.format===Rg)Ee(O)?m.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,pe,0,we):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,pe,0);else throw new Error("Unknown depthTexture format")}function G(B){const O=r.get(B),Y=B.isWebGLCubeRenderTarget===!0;if(B.depthTexture&&!O.__autoAllocateDepthBuffer){if(Y)throw new Error("target.depthTexture not supported in Cube render targets");Qe(O.__webglFramebuffer,B)}else if(Y){O.__webglDepthbuffer=[];for(let pe=0;pe<6;pe++)n.bindFramebuffer(t.FRAMEBUFFER,O.__webglFramebuffer[pe]),O.__webglDepthbuffer[pe]=t.createRenderbuffer(),de(O.__webglDepthbuffer[pe],B,!1)}else n.bindFramebuffer(t.FRAMEBUFFER,O.__webglFramebuffer),O.__webglDepthbuffer=t.createRenderbuffer(),de(O.__webglDepthbuffer,B,!1);n.bindFramebuffer(t.FRAMEBUFFER,null)}function ie(B,O,Y){const pe=r.get(B);O!==void 0&&Re(pe.__webglFramebuffer,B,B.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),Y!==void 0&&G(B)}function X(B){const O=B.texture,Y=r.get(B),pe=r.get(O);B.addEventListener("dispose",L),B.isWebGLMultipleRenderTargets!==!0&&(pe.__webglTexture===void 0&&(pe.__webglTexture=t.createTexture()),pe.__version=O.version,o.memory.textures++);const we=B.isWebGLCubeRenderTarget===!0,ae=B.isWebGLMultipleRenderTargets===!0,ke=N(B)||l;if(we){Y.__webglFramebuffer=[];for(let De=0;De<6;De++)if(l&&O.mipmaps&&O.mipmaps.length>0){Y.__webglFramebuffer[De]=[];for(let Ke=0;Ke<O.mipmaps.length;Ke++)Y.__webglFramebuffer[De][Ke]=t.createFramebuffer()}else Y.__webglFramebuffer[De]=t.createFramebuffer()}else{if(l&&O.mipmaps&&O.mipmaps.length>0){Y.__webglFramebuffer=[];for(let De=0;De<O.mipmaps.length;De++)Y.__webglFramebuffer[De]=t.createFramebuffer()}else Y.__webglFramebuffer=t.createFramebuffer();if(ae)if(i.drawBuffers){const De=B.texture;for(let Ke=0,et=De.length;Ke<et;Ke++){const Ye=r.get(De[Ke]);Ye.__webglTexture===void 0&&(Ye.__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&&B.samples>0&&Ee(B)===!1){const De=ae?O:[O];Y.__webglMultisampledFramebuffer=t.createFramebuffer(),Y.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,Y.__webglMultisampledFramebuffer);for(let Ke=0;Ke<De.length;Ke++){const et=De[Ke];Y.__webglColorRenderbuffer[Ke]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,Y.__webglColorRenderbuffer[Ke]);const Ye=a.convert(et.format,et.colorSpace),se=a.convert(et.type),ye=D(et.internalFormat,Ye,se,et.colorSpace,B.isXRRenderTarget===!0),Ce=ce(B);t.renderbufferStorageMultisample(t.RENDERBUFFER,Ce,ye,B.width,B.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ke,t.RENDERBUFFER,Y.__webglColorRenderbuffer[Ke])}t.bindRenderbuffer(t.RENDERBUFFER,null),B.depthBuffer&&(Y.__webglDepthRenderbuffer=t.createRenderbuffer(),de(Y.__webglDepthRenderbuffer,B,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(we){n.bindTexture(t.TEXTURE_CUBE_MAP,pe.__webglTexture),oe(t.TEXTURE_CUBE_MAP,O,ke);for(let De=0;De<6;De++)if(l&&O.mipmaps&&O.mipmaps.length>0)for(let Ke=0;Ke<O.mipmaps.length;Ke++)Re(Y.__webglFramebuffer[De][Ke],B,O,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+De,Ke);else Re(Y.__webglFramebuffer[De],B,O,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+De,0);k(O,ke)&&C(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(ae){const De=B.texture;for(let Ke=0,et=De.length;Ke<et;Ke++){const Ye=De[Ke],se=r.get(Ye);n.bindTexture(t.TEXTURE_2D,se.__webglTexture),oe(t.TEXTURE_2D,Ye,ke),Re(Y.__webglFramebuffer,B,Ye,t.COLOR_ATTACHMENT0+Ke,t.TEXTURE_2D,0),k(Ye,ke)&&C(t.TEXTURE_2D)}n.unbindTexture()}else{let De=t.TEXTURE_2D;if((B.isWebGL3DRenderTarget||B.isWebGLArrayRenderTarget)&&(l?De=B.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(De,pe.__webglTexture),oe(De,O,ke),l&&O.mipmaps&&O.mipmaps.length>0)for(let Ke=0;Ke<O.mipmaps.length;Ke++)Re(Y.__webglFramebuffer[Ke],B,O,t.COLOR_ATTACHMENT0,De,Ke);else Re(Y.__webglFramebuffer,B,O,t.COLOR_ATTACHMENT0,De,0);k(O,ke)&&C(De),n.unbindTexture()}B.depthBuffer&&G(B)}function $(B){const O=N(B)||l,Y=B.isWebGLMultipleRenderTargets===!0?B.texture:[B.texture];for(let pe=0,we=Y.length;pe<we;pe++){const ae=Y[pe];if(k(ae,O)){const ke=B.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,De=r.get(ae).__webglTexture;n.bindTexture(ke,De),C(ke),n.unbindTexture()}}}function I(B){if(l&&B.samples>0&&Ee(B)===!1){const O=B.isWebGLMultipleRenderTargets?B.texture:[B.texture],Y=B.width,pe=B.height;let we=t.COLOR_BUFFER_BIT;const ae=[],ke=B.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,De=r.get(B),Ke=B.isWebGLMultipleRenderTargets===!0;if(Ke)for(let et=0;et<O.length;et++)n.bindFramebuffer(t.FRAMEBUFFER,De.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+et,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,De.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+et,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,De.__webglMultisampledFramebuffer),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,De.__webglFramebuffer);for(let et=0;et<O.length;et++){ae.push(t.COLOR_ATTACHMENT0+et),B.depthBuffer&&ae.push(ke);const Ye=De.__ignoreDepthValues!==void 0?De.__ignoreDepthValues:!1;if(Ye===!1&&(B.depthBuffer&&(we|=t.DEPTH_BUFFER_BIT),B.stencilBuffer&&(we|=t.STENCIL_BUFFER_BIT)),Ke&&t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,De.__webglColorRenderbuffer[et]),Ye===!0&&(t.invalidateFramebuffer(t.READ_FRAMEBUFFER,[ke]),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[ke])),Ke){const se=r.get(O[et]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,se,0)}t.blitFramebuffer(0,0,Y,pe,0,0,Y,pe,we,t.NEAREST),p&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,ae)}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Ke)for(let et=0;et<O.length;et++){n.bindFramebuffer(t.FRAMEBUFFER,De.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+et,t.RENDERBUFFER,De.__webglColorRenderbuffer[et]);const Ye=r.get(O[et]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,De.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+et,t.TEXTURE_2D,Ye,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,De.__webglMultisampledFramebuffer)}}function ce(B){return Math.min(f,B.samples)}function Ee(B){const O=r.get(B);return l&&B.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&O.__useRenderToTexture!==!1}function Ie(B){const O=o.render.frame;b.get(B)!==O&&(b.set(B,O),B.update())}function le(B,O){const Y=B.colorSpace,pe=B.format,we=B.type;return B.isCompressedTexture===!0||B.isVideoTexture===!0||B.format===AR||Y!==_u&&Y!==No&&(pr.getTransfer(Y)===Dr?l===!1?e.has("EXT_sRGB")===!0&&pe===Eo?(B.format=AR,B.minFilter=Mo,B.generateMipmaps=!1):O=Xee.sRGBToLinear(O):(pe!==Eo||we!==Hd)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",Y)),O}this.allocateTextureUnit=J,this.resetTextureUnits=V,this.setTexture2D=te,this.setTexture2DArray=z,this.setTexture3D=H,this.setTextureCube=Z,this.rebindTextures=ie,this.setupRenderTarget=X,this.updateRenderTargetMipmap=$,this.updateMultisampleRenderTarget=I,this.setupDepthRenderbuffer=G,this.setupFrameBufferTexture=Re,this.useMultisampledRTT=Ee}function X8e(t,e,n){const r=n.isWebGL2;function i(a,o=No){let l;const c=pr.getTransfer(o);if(a===Hd)return t.UNSIGNED_BYTE;if(a===Fee)return t.UNSIGNED_SHORT_4_4_4_4;if(a===Uee)return t.UNSIGNED_SHORT_5_5_5_1;if(a===yFe)return t.BYTE;if(a===vFe)return t.SHORT;if(a===fL)return t.UNSIGNED_SHORT;if(a===Iee)return t.INT;if(a===kd)return t.UNSIGNED_INT;if(a===eu)return t.FLOAT;if(a===Z0)return r?t.HALF_FLOAT:(l=e.get("OES_texture_half_float"),l!==null?l.HALF_FLOAT_OES:null);if(a===_Fe)return t.ALPHA;if(a===Eo)return t.RGBA;if(a===wFe)return t.LUMINANCE;if(a===SFe)return t.LUMINANCE_ALPHA;if(a===Af)return t.DEPTH_COMPONENT;if(a===Rg)return t.DEPTH_STENCIL;if(a===AR)return l=e.get("EXT_sRGB"),l!==null?l.SRGB_ALPHA_EXT:null;if(a===MFe)return t.RED;if(a===zee)return t.RED_INTEGER;if(a===EFe)return t.RG;if(a===Bee)return t.RG_INTEGER;if(a===$ee)return t.RGBA_INTEGER;if(a===Tk||a===Ck||a===kk||a===jk)if(c===Dr)if(l=e.get("WEBGL_compressed_texture_s3tc_srgb"),l!==null){if(a===Tk)return l.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(a===Ck)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(a===kk)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(a===jk)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(l=e.get("WEBGL_compressed_texture_s3tc"),l!==null){if(a===Tk)return l.COMPRESSED_RGB_S3TC_DXT1_EXT;if(a===Ck)return l.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(a===kk)return l.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(a===jk)return l.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(a===DG||a===OG||a===LG||a===IG)if(l=e.get("WEBGL_compressed_texture_pvrtc"),l!==null){if(a===DG)return l.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(a===OG)return l.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(a===LG)return l.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(a===IG)return l.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(a===Hee)return l=e.get("WEBGL_compressed_texture_etc1"),l!==null?l.COMPRESSED_RGB_ETC1_WEBGL:null;if(a===FG||a===UG)if(l=e.get("WEBGL_compressed_texture_etc"),l!==null){if(a===FG)return c===Dr?l.COMPRESSED_SRGB8_ETC2:l.COMPRESSED_RGB8_ETC2;if(a===UG)return c===Dr?l.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:l.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(a===zG||a===BG||a===$G||a===HG||a===VG||a===GG||a===WG||a===qG||a===KG||a===XG||a===YG||a===ZG||a===QG||a===JG)if(l=e.get("WEBGL_compressed_texture_astc"),l!==null){if(a===zG)return c===Dr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:l.COMPRESSED_RGBA_ASTC_4x4_KHR;if(a===BG)return c===Dr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:l.COMPRESSED_RGBA_ASTC_5x4_KHR;if(a===$G)return c===Dr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:l.COMPRESSED_RGBA_ASTC_5x5_KHR;if(a===HG)return c===Dr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:l.COMPRESSED_RGBA_ASTC_6x5_KHR;if(a===VG)return c===Dr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:l.COMPRESSED_RGBA_ASTC_6x6_KHR;if(a===GG)return c===Dr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:l.COMPRESSED_RGBA_ASTC_8x5_KHR;if(a===WG)return c===Dr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:l.COMPRESSED_RGBA_ASTC_8x6_KHR;if(a===qG)return c===Dr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:l.COMPRESSED_RGBA_ASTC_8x8_KHR;if(a===KG)return c===Dr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:l.COMPRESSED_RGBA_ASTC_10x5_KHR;if(a===XG)return c===Dr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:l.COMPRESSED_RGBA_ASTC_10x6_KHR;if(a===YG)return c===Dr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:l.COMPRESSED_RGBA_ASTC_10x8_KHR;if(a===ZG)return c===Dr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:l.COMPRESSED_RGBA_ASTC_10x10_KHR;if(a===QG)return c===Dr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:l.COMPRESSED_RGBA_ASTC_12x10_KHR;if(a===JG)return c===Dr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:l.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(a===Pk||a===e7||a===t7)if(l=e.get("EXT_texture_compression_bptc"),l!==null){if(a===Pk)return c===Dr?l.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:l.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(a===e7)return l.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(a===t7)return l.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(a===NFe||a===n7||a===r7||a===i7)if(l=e.get("EXT_texture_compression_rgtc"),l!==null){if(a===Pk)return l.COMPRESSED_RED_RGTC1_EXT;if(a===n7)return l.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(a===r7)return l.COMPRESSED_RED_GREEN_RGTC2_EXT;if(a===i7)return l.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return a===Nf?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 Y8e extends zs{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Gb extends es{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Z8e={type:"move"};class tj{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Gb,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 Gb,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Be,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Be),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Gb,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Be,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Be),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 v of e.hand.values()){const x=n.getJointPose(v,r),y=this._getHandJoint(u,v);x!==null&&(y.matrix.fromArray(x.transform.matrix),y.matrix.decompose(y.position,y.rotation,y.scale),y.matrixWorldNeedsUpdate=!0,y.jointRadius=x.radius),y.visible=x!==null}const d=u.joints["index-finger-tip"],f=u.joints["thumb-tip"],m=d.position.distanceTo(f.position),p=.02,b=.005;u.inputState.pinching&&m>p+b?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&m<=p-b&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(a=n.getPose(e.gripSpace,r),a!==null&&(c.matrix.fromArray(a.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,a.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(a.linearVelocity)):c.hasLinearVelocity=!1,a.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(a.angularVelocity)):c.hasAngularVelocity=!1));l!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&a!==null&&(i=a),i!==null&&(l.matrix.fromArray(i.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,i.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(i.linearVelocity)):l.hasLinearVelocity=!1,i.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(i.angularVelocity)):l.hasAngularVelocity=!1,this.dispatchEvent(Z8e)))}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 Gb;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}}class Q8e extends hm{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,m=null,p=null,b=null;const v=n.getContextAttributes();let x=null,y=null;const S=[],M=[],N=new mn;let A=null;const k=new zs;k.layers.enable(1),k.viewport=new xr;const C=new zs;C.layers.enable(2),C.viewport=new xr;const D=[k,C],T=new Y8e;T.layers.enable(1),T.layers.enable(2);let R=null,U=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Z){let ee=S[Z];return ee===void 0&&(ee=new tj,S[Z]=ee),ee.getTargetRaySpace()},this.getControllerGrip=function(Z){let ee=S[Z];return ee===void 0&&(ee=new tj,S[Z]=ee),ee.getGripSpace()},this.getHand=function(Z){let ee=S[Z];return ee===void 0&&(ee=new tj,S[Z]=ee),ee.getHandSpace()};function L(Z){const ee=M.indexOf(Z.inputSource);if(ee===-1)return;const he=S[ee];he!==void 0&&(he.update(Z.inputSource,Z.frame,u||o),he.dispatchEvent({type:Z.type,data:Z.inputSource}))}function q(){i.removeEventListener("select",L),i.removeEventListener("selectstart",L),i.removeEventListener("selectend",L),i.removeEventListener("squeeze",L),i.removeEventListener("squeezestart",L),i.removeEventListener("squeezeend",L),i.removeEventListener("end",q),i.removeEventListener("inputsourceschange",j);for(let Z=0;Z<S.length;Z++){const ee=M[Z];ee!==null&&(M[Z]=null,S[Z].disconnect(ee))}R=null,U=null,e.setRenderTarget(x),p=null,m=null,f=null,i=null,y=null,H.stop(),r.isPresenting=!1,e.setPixelRatio(A),e.setSize(N.width,N.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Z){a=Z,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Z){l=Z,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(Z){u=Z},this.getBaseLayer=function(){return m!==null?m:p},this.getBinding=function(){return f},this.getFrame=function(){return b},this.getSession=function(){return i},this.setSession=async function(Z){if(i=Z,i!==null){if(x=e.getRenderTarget(),i.addEventListener("select",L),i.addEventListener("selectstart",L),i.addEventListener("selectend",L),i.addEventListener("squeeze",L),i.addEventListener("squeezestart",L),i.addEventListener("squeezeend",L),i.addEventListener("end",q),i.addEventListener("inputsourceschange",j),v.xrCompatible!==!0&&await n.makeXRCompatible(),A=e.getPixelRatio(),e.getSize(N),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const ee={antialias:i.renderState.layers===void 0?v.antialias:!0,alpha:!0,depth:v.depth,stencil:v.stencil,framebufferScaleFactor:a};p=new XRWebGLLayer(i,n,ee),i.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),y=new em(p.framebufferWidth,p.framebufferHeight,{format:Eo,type:Hd,colorSpace:e.outputColorSpace,stencilBuffer:v.stencil})}else{let ee=null,he=null,fe=null;v.depth&&(fe=v.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,ee=v.stencil?Rg:Af,he=v.stencil?Nf:kd);const oe={colorFormat:n.RGBA8,depthFormat:fe,scaleFactor:a};f=new XRWebGLBinding(i,n),m=f.createProjectionLayer(oe),i.updateRenderState({layers:[m]}),e.setPixelRatio(1),e.setSize(m.textureWidth,m.textureHeight,!1),y=new em(m.textureWidth,m.textureHeight,{format:Eo,type:Hd,depthTexture:new ote(m.textureWidth,m.textureHeight,he,void 0,void 0,void 0,void 0,void 0,void 0,ee),stencilBuffer:v.stencil,colorSpace:e.outputColorSpace,samples:v.antialias?4:0});const Ne=e.properties.get(y);Ne.__ignoreDepthValues=m.ignoreDepthValues}y.isXRRenderTarget=!0,this.setFoveation(c),u=null,o=await i.requestReferenceSpace(l),H.setContext(i),H.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode};function j(Z){for(let ee=0;ee<Z.removed.length;ee++){const he=Z.removed[ee],fe=M.indexOf(he);fe>=0&&(M[fe]=null,S[fe].disconnect(he))}for(let ee=0;ee<Z.added.length;ee++){const he=Z.added[ee];let fe=M.indexOf(he);if(fe===-1){for(let Ne=0;Ne<S.length;Ne++)if(Ne>=M.length){M.push(he),fe=Ne;break}else if(M[Ne]===null){M[Ne]=he,fe=Ne;break}if(fe===-1)break}const oe=S[fe];oe&&oe.connect(he)}}const W=new Be,K=new Be;function V(Z,ee,he){W.setFromMatrixPosition(ee.matrixWorld),K.setFromMatrixPosition(he.matrixWorld);const fe=W.distanceTo(K),oe=ee.projectionMatrix.elements,Ne=he.projectionMatrix.elements,ge=oe[14]/(oe[10]-1),Se=oe[14]/(oe[10]+1),Re=(oe[9]+1)/oe[5],de=(oe[9]-1)/oe[5],Qe=(oe[8]-1)/oe[0],G=(Ne[8]+1)/Ne[0],ie=ge*Qe,X=ge*G,$=fe/(-Qe+G),I=$*-Qe;ee.matrixWorld.decompose(Z.position,Z.quaternion,Z.scale),Z.translateX(I),Z.translateZ($),Z.matrixWorld.compose(Z.position,Z.quaternion,Z.scale),Z.matrixWorldInverse.copy(Z.matrixWorld).invert();const ce=ge+$,Ee=Se+$,Ie=ie-I,le=X+(fe-I),B=Re*Se/Ee*ce,O=de*Se/Ee*ce;Z.projectionMatrix.makePerspective(Ie,le,B,O,ce,Ee),Z.projectionMatrixInverse.copy(Z.projectionMatrix).invert()}function J(Z,ee){ee===null?Z.matrixWorld.copy(Z.matrix):Z.matrixWorld.multiplyMatrices(ee.matrixWorld,Z.matrix),Z.matrixWorldInverse.copy(Z.matrixWorld).invert()}this.updateCamera=function(Z){if(i===null)return;T.near=C.near=k.near=Z.near,T.far=C.far=k.far=Z.far,(R!==T.near||U!==T.far)&&(i.updateRenderState({depthNear:T.near,depthFar:T.far}),R=T.near,U=T.far);const ee=Z.parent,he=T.cameras;J(T,ee);for(let fe=0;fe<he.length;fe++)J(he[fe],ee);he.length===2?V(T,k,C):T.projectionMatrix.copy(k.projectionMatrix),ne(Z,T,ee)};function ne(Z,ee,he){he===null?Z.matrix.copy(ee.matrixWorld):(Z.matrix.copy(he.matrixWorld),Z.matrix.invert(),Z.matrix.multiply(ee.matrixWorld)),Z.matrix.decompose(Z.position,Z.quaternion,Z.scale),Z.updateMatrixWorld(!0),Z.projectionMatrix.copy(ee.projectionMatrix),Z.projectionMatrixInverse.copy(ee.projectionMatrixInverse),Z.isPerspectiveCamera&&(Z.fov=J0*2*Math.atan(1/Z.projectionMatrix.elements[5]),Z.zoom=1)}this.getCamera=function(){return T},this.getFoveation=function(){if(!(m===null&&p===null))return c},this.setFoveation=function(Z){c=Z,m!==null&&(m.fixedFoveation=Z),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=Z)};let te=null;function z(Z,ee){if(d=ee.getViewerPose(u||o),b=ee,d!==null){const he=d.views;p!==null&&(e.setRenderTargetFramebuffer(y,p.framebuffer),e.setRenderTarget(y));let fe=!1;he.length!==T.cameras.length&&(T.cameras.length=0,fe=!0);for(let oe=0;oe<he.length;oe++){const Ne=he[oe];let ge=null;if(p!==null)ge=p.getViewport(Ne);else{const Re=f.getViewSubImage(m,Ne);ge=Re.viewport,oe===0&&(e.setRenderTargetTextures(y,Re.colorTexture,m.ignoreDepthValues?void 0:Re.depthStencilTexture),e.setRenderTarget(y))}let Se=D[oe];Se===void 0&&(Se=new zs,Se.layers.enable(oe),Se.viewport=new xr,D[oe]=Se),Se.matrix.fromArray(Ne.transform.matrix),Se.matrix.decompose(Se.position,Se.quaternion,Se.scale),Se.projectionMatrix.fromArray(Ne.projectionMatrix),Se.projectionMatrixInverse.copy(Se.projectionMatrix).invert(),Se.viewport.set(ge.x,ge.y,ge.width,ge.height),oe===0&&(T.matrix.copy(Se.matrix),T.matrix.decompose(T.position,T.quaternion,T.scale)),fe===!0&&T.cameras.push(Se)}}for(let he=0;he<S.length;he++){const fe=M[he],oe=S[he];fe!==null&&oe!==void 0&&oe.update(fe,ee,u||o)}te&&te(Z,ee),ee.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:ee}),b=null}const H=new ste;H.setAnimationLoop(z),this.setAnimationLoop=function(Z){te=Z},this.dispose=function(){}}}function J8e(t,e){function n(x,y){x.matrixAutoUpdate===!0&&x.updateMatrix(),y.value.copy(x.matrix)}function r(x,y){y.color.getRGB(x.fogColor.value,rte(t)),y.isFog?(x.fogNear.value=y.near,x.fogFar.value=y.far):y.isFogExp2&&(x.fogDensity.value=y.density)}function i(x,y,S,M,N){y.isMeshBasicMaterial||y.isMeshLambertMaterial?a(x,y):y.isMeshToonMaterial?(a(x,y),f(x,y)):y.isMeshPhongMaterial?(a(x,y),d(x,y)):y.isMeshStandardMaterial?(a(x,y),m(x,y),y.isMeshPhysicalMaterial&&p(x,y,N)):y.isMeshMatcapMaterial?(a(x,y),b(x,y)):y.isMeshDepthMaterial?a(x,y):y.isMeshDistanceMaterial?(a(x,y),v(x,y)):y.isMeshNormalMaterial?a(x,y):y.isLineBasicMaterial?(o(x,y),y.isLineDashedMaterial&&l(x,y)):y.isPointsMaterial?c(x,y,S,M):y.isSpriteMaterial?u(x,y):y.isShadowMaterial?(x.color.value.copy(y.color),x.opacity.value=y.opacity):y.isShaderMaterial&&(y.uniformsNeedUpdate=!1)}function a(x,y){x.opacity.value=y.opacity,y.color&&x.diffuse.value.copy(y.color),y.emissive&&x.emissive.value.copy(y.emissive).multiplyScalar(y.emissiveIntensity),y.map&&(x.map.value=y.map,n(y.map,x.mapTransform)),y.alphaMap&&(x.alphaMap.value=y.alphaMap,n(y.alphaMap,x.alphaMapTransform)),y.bumpMap&&(x.bumpMap.value=y.bumpMap,n(y.bumpMap,x.bumpMapTransform),x.bumpScale.value=y.bumpScale,y.side===ws&&(x.bumpScale.value*=-1)),y.normalMap&&(x.normalMap.value=y.normalMap,n(y.normalMap,x.normalMapTransform),x.normalScale.value.copy(y.normalScale),y.side===ws&&x.normalScale.value.negate()),y.displacementMap&&(x.displacementMap.value=y.displacementMap,n(y.displacementMap,x.displacementMapTransform),x.displacementScale.value=y.displacementScale,x.displacementBias.value=y.displacementBias),y.emissiveMap&&(x.emissiveMap.value=y.emissiveMap,n(y.emissiveMap,x.emissiveMapTransform)),y.specularMap&&(x.specularMap.value=y.specularMap,n(y.specularMap,x.specularMapTransform)),y.alphaTest>0&&(x.alphaTest.value=y.alphaTest);const S=e.get(y).envMap;if(S&&(x.envMap.value=S,x.flipEnvMap.value=S.isCubeTexture&&S.isRenderTargetTexture===!1?-1:1,x.reflectivity.value=y.reflectivity,x.ior.value=y.ior,x.refractionRatio.value=y.refractionRatio),y.lightMap){x.lightMap.value=y.lightMap;const M=t._useLegacyLights===!0?Math.PI:1;x.lightMapIntensity.value=y.lightMapIntensity*M,n(y.lightMap,x.lightMapTransform)}y.aoMap&&(x.aoMap.value=y.aoMap,x.aoMapIntensity.value=y.aoMapIntensity,n(y.aoMap,x.aoMapTransform))}function o(x,y){x.diffuse.value.copy(y.color),x.opacity.value=y.opacity,y.map&&(x.map.value=y.map,n(y.map,x.mapTransform))}function l(x,y){x.dashSize.value=y.dashSize,x.totalSize.value=y.dashSize+y.gapSize,x.scale.value=y.scale}function c(x,y,S,M){x.diffuse.value.copy(y.color),x.opacity.value=y.opacity,x.size.value=y.size*S,x.scale.value=M*.5,y.map&&(x.map.value=y.map,n(y.map,x.uvTransform)),y.alphaMap&&(x.alphaMap.value=y.alphaMap,n(y.alphaMap,x.alphaMapTransform)),y.alphaTest>0&&(x.alphaTest.value=y.alphaTest)}function u(x,y){x.diffuse.value.copy(y.color),x.opacity.value=y.opacity,x.rotation.value=y.rotation,y.map&&(x.map.value=y.map,n(y.map,x.mapTransform)),y.alphaMap&&(x.alphaMap.value=y.alphaMap,n(y.alphaMap,x.alphaMapTransform)),y.alphaTest>0&&(x.alphaTest.value=y.alphaTest)}function d(x,y){x.specular.value.copy(y.specular),x.shininess.value=Math.max(y.shininess,1e-4)}function f(x,y){y.gradientMap&&(x.gradientMap.value=y.gradientMap)}function m(x,y){x.metalness.value=y.metalness,y.metalnessMap&&(x.metalnessMap.value=y.metalnessMap,n(y.metalnessMap,x.metalnessMapTransform)),x.roughness.value=y.roughness,y.roughnessMap&&(x.roughnessMap.value=y.roughnessMap,n(y.roughnessMap,x.roughnessMapTransform)),e.get(y).envMap&&(x.envMapIntensity.value=y.envMapIntensity)}function p(x,y,S){x.ior.value=y.ior,y.sheen>0&&(x.sheenColor.value.copy(y.sheenColor).multiplyScalar(y.sheen),x.sheenRoughness.value=y.sheenRoughness,y.sheenColorMap&&(x.sheenColorMap.value=y.sheenColorMap,n(y.sheenColorMap,x.sheenColorMapTransform)),y.sheenRoughnessMap&&(x.sheenRoughnessMap.value=y.sheenRoughnessMap,n(y.sheenRoughnessMap,x.sheenRoughnessMapTransform))),y.clearcoat>0&&(x.clearcoat.value=y.clearcoat,x.clearcoatRoughness.value=y.clearcoatRoughness,y.clearcoatMap&&(x.clearcoatMap.value=y.clearcoatMap,n(y.clearcoatMap,x.clearcoatMapTransform)),y.clearcoatRoughnessMap&&(x.clearcoatRoughnessMap.value=y.clearcoatRoughnessMap,n(y.clearcoatRoughnessMap,x.clearcoatRoughnessMapTransform)),y.clearcoatNormalMap&&(x.clearcoatNormalMap.value=y.clearcoatNormalMap,n(y.clearcoatNormalMap,x.clearcoatNormalMapTransform),x.clearcoatNormalScale.value.copy(y.clearcoatNormalScale),y.side===ws&&x.clearcoatNormalScale.value.negate())),y.iridescence>0&&(x.iridescence.value=y.iridescence,x.iridescenceIOR.value=y.iridescenceIOR,x.iridescenceThicknessMinimum.value=y.iridescenceThicknessRange[0],x.iridescenceThicknessMaximum.value=y.iridescenceThicknessRange[1],y.iridescenceMap&&(x.iridescenceMap.value=y.iridescenceMap,n(y.iridescenceMap,x.iridescenceMapTransform)),y.iridescenceThicknessMap&&(x.iridescenceThicknessMap.value=y.iridescenceThicknessMap,n(y.iridescenceThicknessMap,x.iridescenceThicknessMapTransform))),y.transmission>0&&(x.transmission.value=y.transmission,x.transmissionSamplerMap.value=S.texture,x.transmissionSamplerSize.value.set(S.width,S.height),y.transmissionMap&&(x.transmissionMap.value=y.transmissionMap,n(y.transmissionMap,x.transmissionMapTransform)),x.thickness.value=y.thickness,y.thicknessMap&&(x.thicknessMap.value=y.thicknessMap,n(y.thicknessMap,x.thicknessMapTransform)),x.attenuationDistance.value=y.attenuationDistance,x.attenuationColor.value.copy(y.attenuationColor)),y.anisotropy>0&&(x.anisotropyVector.value.set(y.anisotropy*Math.cos(y.anisotropyRotation),y.anisotropy*Math.sin(y.anisotropyRotation)),y.anisotropyMap&&(x.anisotropyMap.value=y.anisotropyMap,n(y.anisotropyMap,x.anisotropyMapTransform))),x.specularIntensity.value=y.specularIntensity,x.specularColor.value.copy(y.specularColor),y.specularColorMap&&(x.specularColorMap.value=y.specularColorMap,n(y.specularColorMap,x.specularColorMapTransform)),y.specularIntensityMap&&(x.specularIntensityMap.value=y.specularIntensityMap,n(y.specularIntensityMap,x.specularIntensityMapTransform))}function b(x,y){y.matcap&&(x.matcap.value=y.matcap)}function v(x,y){const S=e.get(y).light;x.referencePosition.value.setFromMatrixPosition(S.matrixWorld),x.nearDistance.value=S.shadow.camera.near,x.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function e6e(t,e,n,r){let i={},a={},o=[];const l=n.isWebGL2?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0;function c(S,M){const N=M.program;r.uniformBlockBinding(S,N)}function u(S,M){let N=i[S.id];N===void 0&&(b(S),N=d(S),i[S.id]=N,S.addEventListener("dispose",x));const A=M.program;r.updateUBOMapping(S,A);const k=e.render.frame;a[S.id]!==k&&(m(S),a[S.id]=k)}function d(S){const M=f();S.__bindingPointIndex=M;const N=t.createBuffer(),A=S.__size,k=S.usage;return t.bindBuffer(t.UNIFORM_BUFFER,N),t.bufferData(t.UNIFORM_BUFFER,A,k),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,M,N),N}function f(){for(let S=0;S<l;S++)if(o.indexOf(S)===-1)return o.push(S),S;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function m(S){const M=i[S.id],N=S.uniforms,A=S.__cache;t.bindBuffer(t.UNIFORM_BUFFER,M);for(let k=0,C=N.length;k<C;k++){const D=N[k];if(p(D,k,A)===!0){const T=D.__offset,R=Array.isArray(D.value)?D.value:[D.value];let U=0;for(let L=0;L<R.length;L++){const q=R[L],j=v(q);typeof q=="number"?(D.__data[0]=q,t.bufferSubData(t.UNIFORM_BUFFER,T+U,D.__data)):q.isMatrix3?(D.__data[0]=q.elements[0],D.__data[1]=q.elements[1],D.__data[2]=q.elements[2],D.__data[3]=q.elements[0],D.__data[4]=q.elements[3],D.__data[5]=q.elements[4],D.__data[6]=q.elements[5],D.__data[7]=q.elements[0],D.__data[8]=q.elements[6],D.__data[9]=q.elements[7],D.__data[10]=q.elements[8],D.__data[11]=q.elements[0]):(q.toArray(D.__data,U),U+=j.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,T,D.__data)}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function p(S,M,N){const A=S.value;if(N[M]===void 0){if(typeof A=="number")N[M]=A;else{const k=Array.isArray(A)?A:[A],C=[];for(let D=0;D<k.length;D++)C.push(k[D].clone());N[M]=C}return!0}else if(typeof A=="number"){if(N[M]!==A)return N[M]=A,!0}else{const k=Array.isArray(N[M])?N[M]:[N[M]],C=Array.isArray(A)?A:[A];for(let D=0;D<k.length;D++){const T=k[D];if(T.equals(C[D])===!1)return T.copy(C[D]),!0}}return!1}function b(S){const M=S.uniforms;let N=0;const A=16;let k=0;for(let C=0,D=M.length;C<D;C++){const T=M[C],R={boundary:0,storage:0},U=Array.isArray(T.value)?T.value:[T.value];for(let L=0,q=U.length;L<q;L++){const j=U[L],W=v(j);R.boundary+=W.boundary,R.storage+=W.storage}if(T.__data=new Float32Array(R.storage/Float32Array.BYTES_PER_ELEMENT),T.__offset=N,C>0){k=N%A;const L=A-k;k!==0&&L-R.boundary<0&&(N+=A-k,T.__offset=N)}N+=R.storage}return k=N%A,k>0&&(N+=A-k),S.__size=N,S.__cache={},this}function v(S){const M={boundary:0,storage:0};return typeof S=="number"?(M.boundary=4,M.storage=4):S.isVector2?(M.boundary=8,M.storage=8):S.isVector3||S.isColor?(M.boundary=16,M.storage=12):S.isVector4?(M.boundary=16,M.storage=16):S.isMatrix3?(M.boundary=48,M.storage=48):S.isMatrix4?(M.boundary=64,M.storage=64):S.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",S),M}function x(S){const M=S.target;M.removeEventListener("dispose",x);const N=o.indexOf(M.__bindingPointIndex);o.splice(N,1),t.deleteBuffer(i[M.id]),delete i[M.id],delete a[M.id]}function y(){for(const S in i)t.deleteBuffer(i[S]);o=[],i={},a={}}return{bind:c,update:u,dispose:y}}class kR{constructor(e={}){const{canvas:n=ZFe(),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 m;r!==null?m=r.getContextAttributes().alpha:m=o;const p=new Uint32Array(4),b=new Int32Array(4);let v=null,x=null;const y=[],S=[];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=ya,this._useLegacyLights=!1,this.toneMapping=$d,this.toneMappingExposure=1;const M=this;let N=!1,A=0,k=0,C=null,D=-1,T=null;const R=new xr,U=new xr;let L=null;const q=new rn(0);let j=0,W=n.width,K=n.height,V=1,J=null,ne=null;const te=new xr(0,0,W,K),z=new xr(0,0,W,K);let H=!1;const Z=new pN;let ee=!1,he=!1,fe=null;const oe=new Tr,Ne=new mn,ge=new Be,Se={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Re(){return C===null?V:1}let de=r;function Qe(_e,Je){for(let Ze=0;Ze<_e.length;Ze++){const lt=_e[Ze],st=n.getContext(lt,Je);if(st!==null)return st}return null}try{const _e={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${hN}`),n.addEventListener("webglcontextlost",Fe,!1),n.addEventListener("webglcontextrestored",ve,!1),n.addEventListener("webglcontextcreationerror",$e,!1),de===null){const Je=["webgl2","webgl","experimental-webgl"];if(M.isWebGL1Renderer===!0&&Je.shift(),de=Qe(Je,_e),de===null)throw Qe(Je)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&de instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),de.getShaderPrecisionFormat===void 0&&(de.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(_e){throw console.error("THREE.WebGLRenderer: "+_e.message),_e}let G,ie,X,$,I,ce,Ee,Ie,le,B,O,Y,pe,we,ae,ke,De,Ke,et,Ye,se,ye,Ce,Ue;function dt(){G=new dBe(de),ie=new iBe(de,G,e),G.init(ie),ye=new X8e(de,G,ie),X=new q8e(de,G,ie),$=new mBe(de),I=new R8e,ce=new K8e(de,G,X,I,ie,ye,$),Ee=new sBe(M),Ie=new uBe(M),le=new _5e(de,ie),Ce=new nBe(de,G,le,ie),B=new hBe(de,le,$,Ce),O=new bBe(de,B,le,$),et=new xBe(de,ie,ce),ke=new aBe(I),Y=new P8e(M,Ee,Ie,G,ie,Ce,ke),pe=new J8e(M,I),we=new O8e,ae=new B8e(G,ie),Ke=new tBe(M,Ee,Ie,X,O,m,c),De=new W8e(M,O,ie),Ue=new e6e(de,$,ie,X),Ye=new rBe(de,G,$,ie),se=new fBe(de,G,$,ie),$.programs=Y.programs,M.capabilities=ie,M.extensions=G,M.properties=I,M.renderLists=we,M.shadowMap=De,M.state=X,M.info=$}dt();const re=new Q8e(M,de);this.xr=re,this.getContext=function(){return de},this.getContextAttributes=function(){return de.getContextAttributes()},this.forceContextLoss=function(){const _e=G.get("WEBGL_lose_context");_e&&_e.loseContext()},this.forceContextRestore=function(){const _e=G.get("WEBGL_lose_context");_e&&_e.restoreContext()},this.getPixelRatio=function(){return V},this.setPixelRatio=function(_e){_e!==void 0&&(V=_e,this.setSize(W,K,!1))},this.getSize=function(_e){return _e.set(W,K)},this.setSize=function(_e,Je,Ze=!0){if(re.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}W=_e,K=Je,n.width=Math.floor(_e*V),n.height=Math.floor(Je*V),Ze===!0&&(n.style.width=_e+"px",n.style.height=Je+"px"),this.setViewport(0,0,_e,Je)},this.getDrawingBufferSize=function(_e){return _e.set(W*V,K*V).floor()},this.setDrawingBufferSize=function(_e,Je,Ze){W=_e,K=Je,V=Ze,n.width=Math.floor(_e*Ze),n.height=Math.floor(Je*Ze),this.setViewport(0,0,_e,Je)},this.getCurrentViewport=function(_e){return _e.copy(R)},this.getViewport=function(_e){return _e.copy(te)},this.setViewport=function(_e,Je,Ze,lt){_e.isVector4?te.set(_e.x,_e.y,_e.z,_e.w):te.set(_e,Je,Ze,lt),X.viewport(R.copy(te).multiplyScalar(V).floor())},this.getScissor=function(_e){return _e.copy(z)},this.setScissor=function(_e,Je,Ze,lt){_e.isVector4?z.set(_e.x,_e.y,_e.z,_e.w):z.set(_e,Je,Ze,lt),X.scissor(U.copy(z).multiplyScalar(V).floor())},this.getScissorTest=function(){return H},this.setScissorTest=function(_e){X.setScissorTest(H=_e)},this.setOpaqueSort=function(_e){J=_e},this.setTransparentSort=function(_e){ne=_e},this.getClearColor=function(_e){return _e.copy(Ke.getClearColor())},this.setClearColor=function(){Ke.setClearColor.apply(Ke,arguments)},this.getClearAlpha=function(){return Ke.getClearAlpha()},this.setClearAlpha=function(){Ke.setClearAlpha.apply(Ke,arguments)},this.clear=function(_e=!0,Je=!0,Ze=!0){let lt=0;if(_e){let st=!1;if(C!==null){const Pt=C.texture.format;st=Pt===$ee||Pt===Bee||Pt===zee}if(st){const Pt=C.texture.type,Bt=Pt===Hd||Pt===kd||Pt===fL||Pt===Nf||Pt===Fee||Pt===Uee,Ht=Ke.getClearColor(),Jt=Ke.getClearAlpha(),ue=Ht.r,je=Ht.g,Ve=Ht.b;Bt?(p[0]=ue,p[1]=je,p[2]=Ve,p[3]=Jt,de.clearBufferuiv(de.COLOR,0,p)):(b[0]=ue,b[1]=je,b[2]=Ve,b[3]=Jt,de.clearBufferiv(de.COLOR,0,b))}else lt|=de.COLOR_BUFFER_BIT}Je&&(lt|=de.DEPTH_BUFFER_BIT),Ze&&(lt|=de.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),de.clear(lt)},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",ve,!1),n.removeEventListener("webglcontextcreationerror",$e,!1),we.dispose(),ae.dispose(),I.dispose(),Ee.dispose(),Ie.dispose(),O.dispose(),Ce.dispose(),Ue.dispose(),Y.dispose(),re.dispose(),re.removeEventListener("sessionstart",on),re.removeEventListener("sessionend",Ut),fe&&(fe.dispose(),fe=null),yn.stop()};function Fe(_e){_e.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),N=!0}function ve(){console.log("THREE.WebGLRenderer: Context Restored."),N=!1;const _e=$.autoReset,Je=De.enabled,Ze=De.autoUpdate,lt=De.needsUpdate,st=De.type;dt(),$.autoReset=_e,De.enabled=Je,De.autoUpdate=Ze,De.needsUpdate=lt,De.type=st}function $e(_e){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",_e.statusMessage)}function Le(_e){const Je=_e.target;Je.removeEventListener("dispose",Le),Ae(Je)}function Ae(_e){Ge(_e),I.remove(_e)}function Ge(_e){const Je=I.get(_e).programs;Je!==void 0&&(Je.forEach(function(Ze){Y.releaseProgram(Ze)}),_e.isShaderMaterial&&Y.releaseShaderCache(_e))}this.renderBufferDirect=function(_e,Je,Ze,lt,st,Pt){Je===null&&(Je=Se);const Bt=st.isMesh&&st.matrixWorld.determinant()<0,Ht=yr(_e,Je,Ze,lt,st);X.setMaterial(lt,Bt);let Jt=Ze.index,ue=1;if(lt.wireframe===!0){if(Jt=B.getWireframeAttribute(Ze),Jt===void 0)return;ue=2}const je=Ze.drawRange,Ve=Ze.attributes.position;let We=je.start*ue,He=(je.start+je.count)*ue;Pt!==null&&(We=Math.max(We,Pt.start*ue),He=Math.min(He,(Pt.start+Pt.count)*ue)),Jt!==null?(We=Math.max(We,0),He=Math.min(He,Jt.count)):Ve!=null&&(We=Math.max(We,0),He=Math.min(He,Ve.count));const wt=He-We;if(wt<0||wt===1/0)return;Ce.setup(st,lt,Ht,Ze,Jt);let Dt,Et=Ye;if(Jt!==null&&(Dt=le.get(Jt),Et=se,Et.setIndex(Dt)),st.isMesh)lt.wireframe===!0?(X.setLineWidth(lt.wireframeLinewidth*Re()),Et.setMode(de.LINES)):Et.setMode(de.TRIANGLES);else if(st.isLine){let St=lt.linewidth;St===void 0&&(St=1),X.setLineWidth(St*Re()),st.isLineSegments?Et.setMode(de.LINES):st.isLineLoop?Et.setMode(de.LINE_LOOP):Et.setMode(de.LINE_STRIP)}else st.isPoints?Et.setMode(de.POINTS):st.isSprite&&Et.setMode(de.TRIANGLES);if(st.isBatchedMesh)Et.renderMultiDraw(st._multiDrawStarts,st._multiDrawCounts,st._multiDrawCount);else if(st.isInstancedMesh)Et.renderInstances(We,wt,st.count);else if(Ze.isInstancedBufferGeometry){const St=Ze._maxInstanceCount!==void 0?Ze._maxInstanceCount:1/0,Mt=Math.min(Ze.instanceCount,St);Et.renderInstances(We,wt,Mt)}else Et.render(We,wt)};function it(_e,Je,Ze){_e.transparent===!0&&_e.side===Xc&&_e.forceSinglePass===!1?(_e.side=ws,_e.needsUpdate=!0,Cr(_e,Je,Ze),_e.side=th,_e.needsUpdate=!0,Cr(_e,Je,Ze),_e.side=Xc):Cr(_e,Je,Ze)}this.compile=function(_e,Je,Ze=null){Ze===null&&(Ze=_e),x=ae.get(Ze),x.init(),S.push(x),Ze.traverseVisible(function(st){st.isLight&&st.layers.test(Je.layers)&&(x.pushLight(st),st.castShadow&&x.pushShadow(st))}),_e!==Ze&&_e.traverseVisible(function(st){st.isLight&&st.layers.test(Je.layers)&&(x.pushLight(st),st.castShadow&&x.pushShadow(st))}),x.setupLights(M._useLegacyLights);const lt=new Set;return _e.traverse(function(st){const Pt=st.material;if(Pt)if(Array.isArray(Pt))for(let Bt=0;Bt<Pt.length;Bt++){const Ht=Pt[Bt];it(Ht,Ze,st),lt.add(Ht)}else it(Pt,Ze,st),lt.add(Pt)}),S.pop(),x=null,lt},this.compileAsync=function(_e,Je,Ze=null){const lt=this.compile(_e,Je,Ze);return new Promise(st=>{function Pt(){if(lt.forEach(function(Bt){I.get(Bt).currentProgram.isReady()&&lt.delete(Bt)}),lt.size===0){st(_e);return}setTimeout(Pt,10)}G.get("KHR_parallel_shader_compile")!==null?Pt():setTimeout(Pt,10)})};let Ot=null;function kt(_e){Ot&&Ot(_e)}function on(){yn.stop()}function Ut(){yn.start()}const yn=new ste;yn.setAnimationLoop(kt),typeof self<"u"&&yn.setContext(self),this.setAnimationLoop=function(_e){Ot=_e,re.setAnimationLoop(_e),_e===null?yn.stop():yn.start()},re.addEventListener("sessionstart",on),re.addEventListener("sessionend",Ut),this.render=function(_e,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;_e.matrixWorldAutoUpdate===!0&&_e.updateMatrixWorld(),Je.parent===null&&Je.matrixWorldAutoUpdate===!0&&Je.updateMatrixWorld(),re.enabled===!0&&re.isPresenting===!0&&(re.cameraAutoUpdate===!0&&re.updateCamera(Je),Je=re.getCamera()),_e.isScene===!0&&_e.onBeforeRender(M,_e,Je,C),x=ae.get(_e,S.length),x.init(),S.push(x),oe.multiplyMatrices(Je.projectionMatrix,Je.matrixWorldInverse),Z.setFromProjectionMatrix(oe),he=this.localClippingEnabled,ee=ke.init(this.clippingPlanes,he),v=we.get(_e,y.length),v.init(),y.push(v),xt(_e,Je,0,M.sortObjects),v.finish(),M.sortObjects===!0&&v.sort(J,ne),this.info.render.frame++,ee===!0&&ke.beginShadows();const Ze=x.state.shadowsArray;if(De.render(Ze,_e,Je),ee===!0&&ke.endShadows(),this.info.autoReset===!0&&this.info.reset(),Ke.render(v,_e),x.setupLights(M._useLegacyLights),Je.isArrayCamera){const lt=Je.cameras;for(let st=0,Pt=lt.length;st<Pt;st++){const Bt=lt[st];Yt(v,_e,Bt,Bt.viewport)}}else Yt(v,_e,Je);C!==null&&(ce.updateMultisampleRenderTarget(C),ce.updateRenderTargetMipmap(C)),_e.isScene===!0&&_e.onAfterRender(M,_e,Je),Ce.resetDefaultState(),D=-1,T=null,S.pop(),S.length>0?x=S[S.length-1]:x=null,y.pop(),y.length>0?v=y[y.length-1]:v=null};function xt(_e,Je,Ze,lt){if(_e.visible===!1)return;if(_e.layers.test(Je.layers)){if(_e.isGroup)Ze=_e.renderOrder;else if(_e.isLOD)_e.autoUpdate===!0&&_e.update(Je);else if(_e.isLight)x.pushLight(_e),_e.castShadow&&x.pushShadow(_e);else if(_e.isSprite){if(!_e.frustumCulled||Z.intersectsSprite(_e)){lt&&ge.setFromMatrixPosition(_e.matrixWorld).applyMatrix4(oe);const Bt=O.update(_e),Ht=_e.material;Ht.visible&&v.push(_e,Bt,Ht,Ze,ge.z,null)}}else if((_e.isMesh||_e.isLine||_e.isPoints)&&(!_e.frustumCulled||Z.intersectsObject(_e))){const Bt=O.update(_e),Ht=_e.material;if(lt&&(_e.boundingSphere!==void 0?(_e.boundingSphere===null&&_e.computeBoundingSphere(),ge.copy(_e.boundingSphere.center)):(Bt.boundingSphere===null&&Bt.computeBoundingSphere(),ge.copy(Bt.boundingSphere.center)),ge.applyMatrix4(_e.matrixWorld).applyMatrix4(oe)),Array.isArray(Ht)){const Jt=Bt.groups;for(let ue=0,je=Jt.length;ue<je;ue++){const Ve=Jt[ue],We=Ht[Ve.materialIndex];We&&We.visible&&v.push(_e,Bt,We,Ze,ge.z,Ve)}}else Ht.visible&&v.push(_e,Bt,Ht,Ze,ge.z,null)}}const Pt=_e.children;for(let Bt=0,Ht=Pt.length;Bt<Ht;Bt++)xt(Pt[Bt],Je,Ze,lt)}function Yt(_e,Je,Ze,lt){const st=_e.opaque,Pt=_e.transmissive,Bt=_e.transparent;x.setupLightsView(Ze),ee===!0&&ke.setGlobalState(M.clippingPlanes,Ze),Pt.length>0&&sn(st,Pt,Je,Ze),lt&&X.viewport(R.copy(lt)),st.length>0&&Tt(st,Je,Ze),Pt.length>0&&Tt(Pt,Je,Ze),Bt.length>0&&Tt(Bt,Je,Ze),X.buffers.depth.setTest(!0),X.buffers.depth.setMask(!0),X.buffers.color.setMask(!0),X.setPolygonOffset(!1)}function sn(_e,Je,Ze,lt){if((Ze.isScene===!0?Ze.overrideMaterial:null)!==null)return;const Pt=ie.isWebGL2;fe===null&&(fe=new em(1,1,{generateMipmaps:!0,type:G.has("EXT_color_buffer_half_float")?Z0:Hd,minFilter:Y0,samples:Pt?4:0})),M.getDrawingBufferSize(Ne),Pt?fe.setSize(Ne.x,Ne.y):fe.setSize(KS(Ne.x),KS(Ne.y));const Bt=M.getRenderTarget();M.setRenderTarget(fe),M.getClearColor(q),j=M.getClearAlpha(),j<1&&M.setClearColor(16777215,.5),M.clear();const Ht=M.toneMapping;M.toneMapping=$d,Tt(_e,Ze,lt),ce.updateMultisampleRenderTarget(fe),ce.updateRenderTargetMipmap(fe);let Jt=!1;for(let ue=0,je=Je.length;ue<je;ue++){const Ve=Je[ue],We=Ve.object,He=Ve.geometry,wt=Ve.material,Dt=Ve.group;if(wt.side===Xc&&We.layers.test(lt.layers)){const Et=wt.side;wt.side=ws,wt.needsUpdate=!0,Cn(We,Ze,lt,He,wt,Dt),wt.side=Et,wt.needsUpdate=!0,Jt=!0}}Jt===!0&&(ce.updateMultisampleRenderTarget(fe),ce.updateRenderTargetMipmap(fe)),M.setRenderTarget(Bt),M.setClearColor(q,j),M.toneMapping=Ht}function Tt(_e,Je,Ze){const lt=Je.isScene===!0?Je.overrideMaterial:null;for(let st=0,Pt=_e.length;st<Pt;st++){const Bt=_e[st],Ht=Bt.object,Jt=Bt.geometry,ue=lt===null?Bt.material:lt,je=Bt.group;Ht.layers.test(Ze.layers)&&Cn(Ht,Je,Ze,Jt,ue,je)}}function Cn(_e,Je,Ze,lt,st,Pt){_e.onBeforeRender(M,Je,Ze,lt,st,Pt),_e.modelViewMatrix.multiplyMatrices(Ze.matrixWorldInverse,_e.matrixWorld),_e.normalMatrix.getNormalMatrix(_e.modelViewMatrix),st.onBeforeRender(M,Je,Ze,lt,_e,Pt),st.transparent===!0&&st.side===Xc&&st.forceSinglePass===!1?(st.side=ws,st.needsUpdate=!0,M.renderBufferDirect(Ze,Je,lt,st,_e,Pt),st.side=th,st.needsUpdate=!0,M.renderBufferDirect(Ze,Je,lt,st,_e,Pt),st.side=Xc):M.renderBufferDirect(Ze,Je,lt,st,_e,Pt),_e.onAfterRender(M,Je,Ze,lt,st,Pt)}function Cr(_e,Je,Ze){Je.isScene!==!0&&(Je=Se);const lt=I.get(_e),st=x.state.lights,Pt=x.state.shadowsArray,Bt=st.state.version,Ht=Y.getParameters(_e,st.state,Pt,Je,Ze),Jt=Y.getProgramCacheKey(Ht);let ue=lt.programs;lt.environment=_e.isMeshStandardMaterial?Je.environment:null,lt.fog=Je.fog,lt.envMap=(_e.isMeshStandardMaterial?Ie:Ee).get(_e.envMap||lt.environment),ue===void 0&&(_e.addEventListener("dispose",Le),ue=new Map,lt.programs=ue);let je=ue.get(Jt);if(je!==void 0){if(lt.currentProgram===je&&lt.lightsStateVersion===Bt)return Un(_e,Ht),je}else Ht.uniforms=Y.getUniforms(_e),_e.onBuild(Ze,Ht,M),_e.onBeforeCompile(Ht,M),je=Y.acquireProgram(Ht,Jt),ue.set(Jt,je),lt.uniforms=Ht.uniforms;const Ve=lt.uniforms;return(!_e.isShaderMaterial&&!_e.isRawShaderMaterial||_e.clipping===!0)&&(Ve.clippingPlanes=ke.uniform),Un(_e,Ht),lt.needsLights=gi(_e),lt.lightsStateVersion=Bt,lt.needsLights&&(Ve.ambientLightColor.value=st.state.ambient,Ve.lightProbe.value=st.state.probe,Ve.directionalLights.value=st.state.directional,Ve.directionalLightShadows.value=st.state.directionalShadow,Ve.spotLights.value=st.state.spot,Ve.spotLightShadows.value=st.state.spotShadow,Ve.rectAreaLights.value=st.state.rectArea,Ve.ltc_1.value=st.state.rectAreaLTC1,Ve.ltc_2.value=st.state.rectAreaLTC2,Ve.pointLights.value=st.state.point,Ve.pointLightShadows.value=st.state.pointShadow,Ve.hemisphereLights.value=st.state.hemi,Ve.directionalShadowMap.value=st.state.directionalShadowMap,Ve.directionalShadowMatrix.value=st.state.directionalShadowMatrix,Ve.spotShadowMap.value=st.state.spotShadowMap,Ve.spotLightMatrix.value=st.state.spotLightMatrix,Ve.spotLightMap.value=st.state.spotLightMap,Ve.pointShadowMap.value=st.state.pointShadowMap,Ve.pointShadowMatrix.value=st.state.pointShadowMatrix),lt.currentProgram=je,lt.uniformsList=null,je}function er(_e){if(_e.uniformsList===null){const Je=_e.currentProgram.getUniforms();_e.uniformsList=gw.seqWithValue(Je.seq,_e.uniforms)}return _e.uniformsList}function Un(_e,Je){const Ze=I.get(_e);Ze.outputColorSpace=Je.outputColorSpace,Ze.batching=Je.batching,Ze.instancing=Je.instancing,Ze.instancingColor=Je.instancingColor,Ze.skinning=Je.skinning,Ze.morphTargets=Je.morphTargets,Ze.morphNormals=Je.morphNormals,Ze.morphColors=Je.morphColors,Ze.morphTargetsCount=Je.morphTargetsCount,Ze.numClippingPlanes=Je.numClippingPlanes,Ze.numIntersection=Je.numClipIntersection,Ze.vertexAlphas=Je.vertexAlphas,Ze.vertexTangents=Je.vertexTangents,Ze.toneMapping=Je.toneMapping}function yr(_e,Je,Ze,lt,st){Je.isScene!==!0&&(Je=Se),ce.resetTextureUnits();const Pt=Je.fog,Bt=lt.isMeshStandardMaterial?Je.environment:null,Ht=C===null?M.outputColorSpace:C.isXRRenderTarget===!0?C.texture.colorSpace:_u,Jt=(lt.isMeshStandardMaterial?Ie:Ee).get(lt.envMap||Bt),ue=lt.vertexColors===!0&&!!Ze.attributes.color&&Ze.attributes.color.itemSize===4,je=!!Ze.attributes.tangent&&(!!lt.normalMap||lt.anisotropy>0),Ve=!!Ze.morphAttributes.position,We=!!Ze.morphAttributes.normal,He=!!Ze.morphAttributes.color;let wt=$d;lt.toneMapped&&(C===null||C.isXRRenderTarget===!0)&&(wt=M.toneMapping);const Dt=Ze.morphAttributes.position||Ze.morphAttributes.normal||Ze.morphAttributes.color,Et=Dt!==void 0?Dt.length:0,St=I.get(lt),Mt=x.state.lights;if(ee===!0&&(he===!0||_e!==T)){const It=_e===T&&lt.id===D;ke.setState(lt,_e,It)}let Oe=!1;lt.version===St.__version?(St.needsLights&&St.lightsStateVersion!==Mt.state.version||St.outputColorSpace!==Ht||st.isBatchedMesh&&St.batching===!1||!st.isBatchedMesh&&St.batching===!0||st.isInstancedMesh&&St.instancing===!1||!st.isInstancedMesh&&St.instancing===!0||st.isSkinnedMesh&&St.skinning===!1||!st.isSkinnedMesh&&St.skinning===!0||st.isInstancedMesh&&St.instancingColor===!0&&st.instanceColor===null||st.isInstancedMesh&&St.instancingColor===!1&&st.instanceColor!==null||St.envMap!==Jt||lt.fog===!0&&St.fog!==Pt||St.numClippingPlanes!==void 0&&(St.numClippingPlanes!==ke.numPlanes||St.numIntersection!==ke.numIntersection)||St.vertexAlphas!==ue||St.vertexTangents!==je||St.morphTargets!==Ve||St.morphNormals!==We||St.morphColors!==He||St.toneMapping!==wt||ie.isWebGL2===!0&&St.morphTargetsCount!==Et)&&(Oe=!0):(Oe=!0,St.__version=lt.version);let gt=St.currentProgram;Oe===!0&&(gt=Cr(lt,Je,st));let Rt=!1,ct=!1,Zt=!1;const Kt=gt.getUniforms(),be=St.uniforms;if(X.useProgram(gt.program)&&(Rt=!0,ct=!0,Zt=!0),lt.id!==D&&(D=lt.id,ct=!0),Rt||T!==_e){Kt.setValue(de,"projectionMatrix",_e.projectionMatrix),Kt.setValue(de,"viewMatrix",_e.matrixWorldInverse);const It=Kt.map.cameraPosition;It!==void 0&&It.setValue(de,ge.setFromMatrixPosition(_e.matrixWorld)),ie.logarithmicDepthBuffer&&Kt.setValue(de,"logDepthBufFC",2/(Math.log(_e.far+1)/Math.LN2)),(lt.isMeshPhongMaterial||lt.isMeshToonMaterial||lt.isMeshLambertMaterial||lt.isMeshBasicMaterial||lt.isMeshStandardMaterial||lt.isShaderMaterial)&&Kt.setValue(de,"isOrthographic",_e.isOrthographicCamera===!0),T!==_e&&(T=_e,ct=!0,Zt=!0)}if(st.isSkinnedMesh){Kt.setOptional(de,st,"bindMatrix"),Kt.setOptional(de,st,"bindMatrixInverse");const It=st.skeleton;It&&(ie.floatVertexTextures?(It.boneTexture===null&&It.computeBoneTexture(),Kt.setValue(de,"boneTexture",It.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."))}st.isBatchedMesh&&(Kt.setOptional(de,st,"batchingTexture"),Kt.setValue(de,"batchingTexture",st._matricesTexture,ce));const ut=Ze.morphAttributes;if((ut.position!==void 0||ut.normal!==void 0||ut.color!==void 0&&ie.isWebGL2===!0)&&et.update(st,Ze,gt),(ct||St.receiveShadow!==st.receiveShadow)&&(St.receiveShadow=st.receiveShadow,Kt.setValue(de,"receiveShadow",st.receiveShadow)),lt.isMeshGouraudMaterial&&lt.envMap!==null&&(be.envMap.value=Jt,be.flipEnvMap.value=Jt.isCubeTexture&&Jt.isRenderTargetTexture===!1?-1:1),ct&&(Kt.setValue(de,"toneMappingExposure",M.toneMappingExposure),St.needsLights&&Ci(be,Zt),Pt&&lt.fog===!0&&pe.refreshFogUniforms(be,Pt),pe.refreshMaterialUniforms(be,lt,V,K,fe),gw.upload(de,er(St),be,ce)),lt.isShaderMaterial&&lt.uniformsNeedUpdate===!0&&(gw.upload(de,er(St),be,ce),lt.uniformsNeedUpdate=!1),lt.isSpriteMaterial&&Kt.setValue(de,"center",st.center),Kt.setValue(de,"modelViewMatrix",st.modelViewMatrix),Kt.setValue(de,"normalMatrix",st.normalMatrix),Kt.setValue(de,"modelMatrix",st.matrixWorld),lt.isShaderMaterial||lt.isRawShaderMaterial){const It=lt.uniformsGroups;for(let yt=0,Xt=It.length;yt<Xt;yt++)if(ie.isWebGL2){const tr=It[yt];Ue.update(tr,gt),Ue.bind(tr,gt)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return gt}function Ci(_e,Je){_e.ambientLightColor.needsUpdate=Je,_e.lightProbe.needsUpdate=Je,_e.directionalLights.needsUpdate=Je,_e.directionalLightShadows.needsUpdate=Je,_e.pointLights.needsUpdate=Je,_e.pointLightShadows.needsUpdate=Je,_e.spotLights.needsUpdate=Je,_e.spotLightShadows.needsUpdate=Je,_e.rectAreaLights.needsUpdate=Je,_e.hemisphereLights.needsUpdate=Je}function gi(_e){return _e.isMeshLambertMaterial||_e.isMeshToonMaterial||_e.isMeshPhongMaterial||_e.isMeshStandardMaterial||_e.isShadowMaterial||_e.isShaderMaterial&&_e.lights===!0}this.getActiveCubeFace=function(){return A},this.getActiveMipmapLevel=function(){return k},this.getRenderTarget=function(){return C},this.setRenderTargetTextures=function(_e,Je,Ze){I.get(_e.texture).__webglTexture=Je,I.get(_e.depthTexture).__webglTexture=Ze;const lt=I.get(_e);lt.__hasExternalTextures=!0,lt.__hasExternalTextures&&(lt.__autoAllocateDepthBuffer=Ze===void 0,lt.__autoAllocateDepthBuffer||G.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),lt.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(_e,Je){const Ze=I.get(_e);Ze.__webglFramebuffer=Je,Ze.__useDefaultFramebuffer=Je===void 0},this.setRenderTarget=function(_e,Je=0,Ze=0){C=_e,A=Je,k=Ze;let lt=!0,st=null,Pt=!1,Bt=!1;if(_e){const Jt=I.get(_e);Jt.__useDefaultFramebuffer!==void 0?(X.bindFramebuffer(de.FRAMEBUFFER,null),lt=!1):Jt.__webglFramebuffer===void 0?ce.setupRenderTarget(_e):Jt.__hasExternalTextures&&ce.rebindTextures(_e,I.get(_e.texture).__webglTexture,I.get(_e.depthTexture).__webglTexture);const ue=_e.texture;(ue.isData3DTexture||ue.isDataArrayTexture||ue.isCompressedArrayTexture)&&(Bt=!0);const je=I.get(_e).__webglFramebuffer;_e.isWebGLCubeRenderTarget?(Array.isArray(je[Je])?st=je[Je][Ze]:st=je[Je],Pt=!0):ie.isWebGL2&&_e.samples>0&&ce.useMultisampledRTT(_e)===!1?st=I.get(_e).__webglMultisampledFramebuffer:Array.isArray(je)?st=je[Ze]:st=je,R.copy(_e.viewport),U.copy(_e.scissor),L=_e.scissorTest}else R.copy(te).multiplyScalar(V).floor(),U.copy(z).multiplyScalar(V).floor(),L=H;if(X.bindFramebuffer(de.FRAMEBUFFER,st)&&ie.drawBuffers&&lt&&X.drawBuffers(_e,st),X.viewport(R),X.scissor(U),X.setScissorTest(L),Pt){const Jt=I.get(_e.texture);de.framebufferTexture2D(de.FRAMEBUFFER,de.COLOR_ATTACHMENT0,de.TEXTURE_CUBE_MAP_POSITIVE_X+Je,Jt.__webglTexture,Ze)}else if(Bt){const Jt=I.get(_e.texture),ue=Je||0;de.framebufferTextureLayer(de.FRAMEBUFFER,de.COLOR_ATTACHMENT0,Jt.__webglTexture,Ze||0,ue)}D=-1},this.readRenderTargetPixels=function(_e,Je,Ze,lt,st,Pt,Bt){if(!(_e&&_e.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ht=I.get(_e).__webglFramebuffer;if(_e.isWebGLCubeRenderTarget&&Bt!==void 0&&(Ht=Ht[Bt]),Ht){X.bindFramebuffer(de.FRAMEBUFFER,Ht);try{const Jt=_e.texture,ue=Jt.format,je=Jt.type;if(ue!==Eo&&ye.convert(ue)!==de.getParameter(de.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const Ve=je===Z0&&(G.has("EXT_color_buffer_half_float")||ie.isWebGL2&&G.has("EXT_color_buffer_float"));if(je!==Hd&&ye.convert(je)!==de.getParameter(de.IMPLEMENTATION_COLOR_READ_TYPE)&&!(je===eu&&(ie.isWebGL2||G.has("OES_texture_float")||G.has("WEBGL_color_buffer_float")))&&!Ve){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Je>=0&&Je<=_e.width-lt&&Ze>=0&&Ze<=_e.height-st&&de.readPixels(Je,Ze,lt,st,ye.convert(ue),ye.convert(je),Pt)}finally{const Jt=C!==null?I.get(C).__webglFramebuffer:null;X.bindFramebuffer(de.FRAMEBUFFER,Jt)}}},this.copyFramebufferToTexture=function(_e,Je,Ze=0){const lt=Math.pow(2,-Ze),st=Math.floor(Je.image.width*lt),Pt=Math.floor(Je.image.height*lt);ce.setTexture2D(Je,0),de.copyTexSubImage2D(de.TEXTURE_2D,Ze,0,0,_e.x,_e.y,st,Pt),X.unbindTexture()},this.copyTextureToTexture=function(_e,Je,Ze,lt=0){const st=Je.image.width,Pt=Je.image.height,Bt=ye.convert(Ze.format),Ht=ye.convert(Ze.type);ce.setTexture2D(Ze,0),de.pixelStorei(de.UNPACK_FLIP_Y_WEBGL,Ze.flipY),de.pixelStorei(de.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Ze.premultiplyAlpha),de.pixelStorei(de.UNPACK_ALIGNMENT,Ze.unpackAlignment),Je.isDataTexture?de.texSubImage2D(de.TEXTURE_2D,lt,_e.x,_e.y,st,Pt,Bt,Ht,Je.image.data):Je.isCompressedTexture?de.compressedTexSubImage2D(de.TEXTURE_2D,lt,_e.x,_e.y,Je.mipmaps[0].width,Je.mipmaps[0].height,Bt,Je.mipmaps[0].data):de.texSubImage2D(de.TEXTURE_2D,lt,_e.x,_e.y,Bt,Ht,Je.image),lt===0&&Ze.generateMipmaps&&de.generateMipmap(de.TEXTURE_2D),X.unbindTexture()},this.copyTextureToTexture3D=function(_e,Je,Ze,lt,st=0){if(M.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const Pt=_e.max.x-_e.min.x+1,Bt=_e.max.y-_e.min.y+1,Ht=_e.max.z-_e.min.z+1,Jt=ye.convert(lt.format),ue=ye.convert(lt.type);let je;if(lt.isData3DTexture)ce.setTexture3D(lt,0),je=de.TEXTURE_3D;else if(lt.isDataArrayTexture)ce.setTexture2DArray(lt,0),je=de.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}de.pixelStorei(de.UNPACK_FLIP_Y_WEBGL,lt.flipY),de.pixelStorei(de.UNPACK_PREMULTIPLY_ALPHA_WEBGL,lt.premultiplyAlpha),de.pixelStorei(de.UNPACK_ALIGNMENT,lt.unpackAlignment);const Ve=de.getParameter(de.UNPACK_ROW_LENGTH),We=de.getParameter(de.UNPACK_IMAGE_HEIGHT),He=de.getParameter(de.UNPACK_SKIP_PIXELS),wt=de.getParameter(de.UNPACK_SKIP_ROWS),Dt=de.getParameter(de.UNPACK_SKIP_IMAGES),Et=Ze.isCompressedTexture?Ze.mipmaps[0]:Ze.image;de.pixelStorei(de.UNPACK_ROW_LENGTH,Et.width),de.pixelStorei(de.UNPACK_IMAGE_HEIGHT,Et.height),de.pixelStorei(de.UNPACK_SKIP_PIXELS,_e.min.x),de.pixelStorei(de.UNPACK_SKIP_ROWS,_e.min.y),de.pixelStorei(de.UNPACK_SKIP_IMAGES,_e.min.z),Ze.isDataTexture||Ze.isData3DTexture?de.texSubImage3D(je,st,Je.x,Je.y,Je.z,Pt,Bt,Ht,Jt,ue,Et.data):Ze.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),de.compressedTexSubImage3D(je,st,Je.x,Je.y,Je.z,Pt,Bt,Ht,Jt,Et.data)):de.texSubImage3D(je,st,Je.x,Je.y,Je.z,Pt,Bt,Ht,Jt,ue,Et),de.pixelStorei(de.UNPACK_ROW_LENGTH,Ve),de.pixelStorei(de.UNPACK_IMAGE_HEIGHT,We),de.pixelStorei(de.UNPACK_SKIP_PIXELS,He),de.pixelStorei(de.UNPACK_SKIP_ROWS,wt),de.pixelStorei(de.UNPACK_SKIP_IMAGES,Dt),st===0&&lt.generateMipmaps&&de.generateMipmap(je),X.unbindTexture()},this.initTexture=function(_e){_e.isCubeTexture?ce.setTextureCube(_e,0):_e.isData3DTexture?ce.setTexture3D(_e,0):_e.isDataArrayTexture||_e.isCompressedArrayTexture?ce.setTexture2DArray(_e,0):ce.setTexture2D(_e,0),X.unbindTexture()},this.resetState=function(){A=0,k=0,C=null,X.reset(),Ce.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Vl}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=e===mL?"display-p3":"srgb",n.unpackColorSpace=pr.workingColorSpace===mN?"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===ya?Tf:Vee}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===Tf?ya:_u}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 t6e extends kR{}t6e.prototype.isWebGL1Renderer=!0;class vL{constructor(e,n=1,r=1e3){this.isFog=!0,this.name="",this.color=new rn(e),this.near=n,this.far=r}clone(){return new vL(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class n6e extends es{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 r6e{constructor(e,n){this.isInterleavedBuffer=!0,this.array=e,this.stride=n,this.count=e!==void 0?e.length/n:0,this.usage=NR,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=ou()}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=ou()),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=ou()),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 Wa=new Be;class jd{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++)Wa.fromBufferAttribute(this,n),Wa.applyMatrix4(e),this.setXYZ(n,Wa.x,Wa.y,Wa.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)Wa.fromBufferAttribute(this,n),Wa.applyNormalMatrix(e),this.setXYZ(n,Wa.x,Wa.y,Wa.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)Wa.fromBufferAttribute(this,n),Wa.transformDirection(e),this.setXYZ(n,Wa.x,Wa.y,Wa.z);return this}setX(e,n){return this.normalized&&(n=mr(n,this.array)),this.data.array[e*this.data.stride+this.offset]=n,this}setY(e,n){return this.normalized&&(n=mr(n,this.array)),this.data.array[e*this.data.stride+this.offset+1]=n,this}setZ(e,n){return this.normalized&&(n=mr(n,this.array)),this.data.array[e*this.data.stride+this.offset+2]=n,this}setW(e,n){return this.normalized&&(n=mr(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=Fl(n,this.array)),n}getY(e){let n=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(n=Fl(n,this.array)),n}getZ(e){let n=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(n=Fl(n,this.array)),n}getW(e){let n=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(n=Fl(n,this.array)),n}setXY(e,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(n=mr(n,this.array),r=mr(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=mr(n,this.array),r=mr(r,this.array),i=mr(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=mr(n,this.array),r=mr(r,this.array),i=mr(i,this.array),a=mr(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 Xs(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 jd(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 i6e extends Ss{constructor(e=null,n=1,r=1,i,a,o,l,c,u=ba,d=ba,f,m){super(null,o,l,c,u,d,i,a,f,m),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}function a6e(t,e){return t.z-e.z}function s6e(t,e){return e.z-t.z}class o6e{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 jp="batchId",ud=new Tr,W7=new Tr,l6e=new Tr,q7=new Tr,nj=new pN,S1=new ko,Wh=new Xl,Cb=new Be,rj=new o6e,Da=new tl,M1=[];function c6e(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 u6e extends tl{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,n,r=n*2,i){super(new Ha,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 i6e(n,e,e,Eo,eu);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,m=new u.constructor(r*d),p=new c.constructor(m,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 Xs(l,1))}const o=i>65536?new Uint32Array(r):new Uint16Array(r);n.setAttribute(jp,new Xs(o,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(jp))throw new Error(`BatchedMesh: Geometry cannot use attribute "${jp}"`);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===jp)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 ko);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,ud),this.getBoundingBoxAt(i,S1).applyMatrix4(ud),n.union(S1))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Xl);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,ud),this.getBoundingSphereAt(i,Wh).applyMatrix4(ud),n.union(Wh))}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,m=this._active,p=this._matricesTexture,b=this._matricesTexture.image.data;f.push(!0),m.push(!0);const v=this._geometryCount;this._geometryCount++,l6e.toArray(b,v*16),p.needsUpdate=!0,o.push(i),l.push({start:d?i.indexStart:i.vertexStart,count:-1}),c.push({boxInitialized:!1,box:new ko,sphereInitialized:!1,sphere:new Xl});const x=this.geometry.getAttribute(jp);for(let y=0;y<i.vertexCount;y++)x.setX(i.vertexStart+y,v);return x.needsUpdate=!0,this.setGeometryAt(v,e),v}setGeometryAt(e,n){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(n);const r=this.geometry,i=r.getIndex()!==null,a=r.getIndex(),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===jp)continue;const b=n.getAttribute(p),v=r.getAttribute(p);c6e(b,v,c);const x=b.itemSize;for(let y=b.count,S=u;y<S;y++){const M=c+y;for(let N=0;N<x;N++)v.setComponent(M,N,0)}v.needsUpdate=!0}if(i){const p=l.indexStart;for(let b=0;b<o.count;b++)a.setX(p+b,c+o.getX(b));for(let b=o.count,v=l.indexCount;b<v;b++)a.setX(p+b,c);a.needsUpdate=!0}const d=this._bounds[e];n.boundingBox!==null?(d.box.copy(n.boundingBox),d.boxInitialized=!0):d.boxInitialized=!1,n.boundingSphere!==null?(d.sphere.copy(n.boundingSphere),d.sphereInitialized=!0):d.sphereInitialized=!1;const f=this._drawRanges[e],m=n.getAttribute("position");return f.count=i?o.count:m.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 m=d;l&&(m=l.getX(m)),a.expandByPoint(Cb.fromBufferAttribute(c,m))}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,S1),S1.getCenter(a.center);const l=o.index,c=o.attributes.position,u=this._drawRanges[e];let d=0;for(let f=u.start,m=u.start+u.count;f<m;f++){let p=f;l&&(p=l.getX(p)),Cb.fromBufferAttribute(c,p),d=Math.max(d,a.center.distanceToSquared(Cb))}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;Da.material=this.material,Da.geometry.index=c.index,Da.geometry.attributes=c.attributes,Da.geometry.boundingBox===null&&(Da.geometry.boundingBox=new ko),Da.geometry.boundingSphere===null&&(Da.geometry.boundingSphere=new Xl);for(let u=0;u<o;u++){if(!r[u]||!i[u])continue;const d=a[u];Da.geometry.setDrawRange(d.start,d.count),this.getMatrixAt(u,Da.matrixWorld).premultiply(l),this.getBoundingBoxAt(u,Da.geometry.boundingBox),this.getBoundingSphereAt(u,Da.geometry.boundingSphere),Da.raycast(e,M1);for(let f=0,m=M1.length;f<m;f++){const p=M1[f];p.object=this,p.batchId=u,n.push(p)}M1.length=0}Da.material=null,Da.geometry.index=null,Da.geometry.attributes={},Da.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,m=this.perObjectFrustumCulled;m&&(q7.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse).multiply(this.matrixWorld),nj.setFromProjectionMatrix(q7,e.isWebGPURenderer?Q0:Vl));let p=0;if(this.sortObjects){W7.copy(this.matrixWorld).invert(),Cb.setFromMatrixPosition(r.matrixWorld).applyMatrix4(W7);for(let x=0,y=c.length;x<y;x++)if(c[x]){this.getMatrixAt(x,ud),this.getBoundingSphereAt(x,Wh).applyMatrix4(ud);let S=!1;if(m&&(S=!nj.intersectsSphere(Wh)),!S){const M=Cb.distanceTo(Wh.center);rj.push(f[x],M)}}const b=rj.list,v=this.customSort;v===null?b.sort(a.transparent?s6e:a6e):v.call(this,b,r);for(let x=0,y=b.length;x<y;x++){const S=b[x];u[p]=S.start*l,d[p]=S.count,p++}rj.reset()}else for(let b=0,v=c.length;b<v;b++)if(c[b]){let x=!1;if(m&&(this.getMatrixAt(b,ud),this.getBoundingSphereAt(b,Wh).applyMatrix4(ud),x=!nj.intersectsSphere(Wh)),!x){const y=f[b];u[p]=y.start*l,d[p]=y.count,p++}}this._multiDrawCount=p,this._visibilityChanged=!1}onBeforeShadow(e,n,r,i,a,o){this.onBeforeRender(e,null,i,a,o)}}class Wy extends ux{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new rn(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 K7=new Be,X7=new Be,Y7=new Tr,ij=new gL,E1=new Xl;class d6e extends es{constructor(e=new Ha,n=new Wy){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++)K7.fromBufferAttribute(n,i-1),X7.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=K7.distanceTo(X7);e.setAttribute("lineDistance",new pi(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(),E1.copy(r.boundingSphere),E1.applyMatrix4(i),E1.radius+=a,e.ray.intersectsSphere(E1)===!1)return;Y7.copy(i).invert(),ij.copy(e.ray).applyMatrix4(Y7);const l=a/((this.scale.x+this.scale.y+this.scale.z)/3),c=l*l,u=new Be,d=new Be,f=new Be,m=new Be,p=this.isLineSegments?2:1,b=r.index,x=r.attributes.position;if(b!==null){const y=Math.max(0,o.start),S=Math.min(b.count,o.start+o.count);for(let M=y,N=S-1;M<N;M+=p){const A=b.getX(M),k=b.getX(M+1);if(u.fromBufferAttribute(x,A),d.fromBufferAttribute(x,k),ij.distanceSqToSegment(u,d,m,f)>c)continue;m.applyMatrix4(this.matrixWorld);const D=e.ray.origin.distanceTo(m);D<e.near||D>e.far||n.push({distance:D,point:f.clone().applyMatrix4(this.matrixWorld),index:M,face:null,faceIndex:null,object:this})}}else{const y=Math.max(0,o.start),S=Math.min(x.count,o.start+o.count);for(let M=y,N=S-1;M<N;M+=p){if(u.fromBufferAttribute(x,M),d.fromBufferAttribute(x,M+1),ij.distanceSqToSegment(u,d,m,f)>c)continue;m.applyMatrix4(this.matrixWorld);const k=e.ray.origin.distanceTo(m);k<e.near||k>e.far||n.push({distance:k,point:f.clone().applyMatrix4(this.matrixWorld),index:M,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 Z7=new Be,Q7=new Be;class xN extends d6e{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)Z7.fromBufferAttribute(n,i),Q7.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+Z7.distanceTo(Q7);e.setAttribute("lineDistance",new pi(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class h6e extends Ha{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const n=[],r=new Set,i=new Be,a=new Be;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],m=f.start,p=f.count;for(let b=m,v=m+p;b<v;b+=3)for(let x=0;x<3;x++){const y=l.getX(b+x),S=l.getX(b+(x+1)%3);i.fromBufferAttribute(o,y),a.fromBufferAttribute(o,S),J7(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),J7(i,a,r)===!0&&(n.push(i.x,i.y,i.z),n.push(a.x,a.y,a.z))}}this.setAttribute("position",new pi(n,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function J7(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 f6e extends ux{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new rn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new rn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Gee,this.normalScale=new mn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=hL,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 m6e extends Wy{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 fte extends es{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new rn(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 aj=new Tr,e9=new Be,t9=new Be;class p6e{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new mn(512,512),this.map=null,this.mapPass=null,this.matrix=new Tr,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new pN,this._frameExtents=new mn(1,1),this._viewportCount=1,this._viewports=[new xr(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;e9.setFromMatrixPosition(e.matrixWorld),n.position.copy(e9),t9.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(t9),n.updateMatrixWorld(),aj.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(aj),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(aj)}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 n9=new Tr,kb=new Be,sj=new Be;class g6e extends p6e{constructor(){super(new zs(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new mn(4,2),this._viewportCount=6,this._viewports=[new xr(2,1,1,1),new xr(0,1,1,1),new xr(3,1,1,1),new xr(1,1,1,1),new xr(3,0,1,1),new xr(1,0,1,1)],this._cubeDirections=[new Be(1,0,0),new Be(-1,0,0),new Be(0,0,1),new Be(0,0,-1),new Be(0,1,0),new Be(0,-1,0)],this._cubeUps=[new Be(0,1,0),new Be(0,1,0),new Be(0,1,0),new Be(0,1,0),new Be(0,0,1),new Be(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()),kb.setFromMatrixPosition(e.matrixWorld),r.position.copy(kb),sj.copy(r.position),sj.add(this._cubeDirections[n]),r.up.copy(this._cubeUps[n]),r.lookAt(sj),r.updateMatrixWorld(),i.makeTranslation(-kb.x,-kb.y,-kb.z),n9.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(n9)}}class x6e extends fte{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 g6e}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 b6e extends fte{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}}class y6e extends Ha{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 jR extends r6e{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 r9{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(va(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const i9=new Be,N1=new Be;class v6e{constructor(e=new Be,n=new Be){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){i9.subVectors(e,this.start),N1.subVectors(this.end,this.start);const r=N1.dot(N1);let a=N1.dot(i9)/r;return n&&(a=va(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 _6e extends xN{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 Ha;i.setAttribute("position",new pi(n,3)),i.setAttribute("color",new pi(r,3));const a=new Wy({vertexColors:!0,toneMapped:!1});super(i,a),this.type="AxesHelper"}setColors(e,n,r){const i=new rn,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:hN}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=hN);class Yl{constructor(e,n,r,i,a="div"){this.parent=e,this.object=n,this.property=r,this._disabled=!1,this._hidden=!1,this.initialValue=this.getValue(),this.domElement=document.createElement(a),this.domElement.classList.add("controller"),this.domElement.classList.add(i),this.$name=document.createElement("div"),this.$name.classList.add("name"),Yl.nextNameID=Yl.nextNameID||0,this.$name.id=`lil-gui-name-${++Yl.nextNameID}`,this.$widget=document.createElement("div"),this.$widget.classList.add("widget"),this.$disable=this.$widget,this.domElement.appendChild(this.$name),this.domElement.appendChild(this.$widget),this.domElement.addEventListener("keydown",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 w6e extends Yl{constructor(e,n,r){super(e,n,r,"boolean","label"),this.$input=document.createElement("input"),this.$input.setAttribute("type","checkbox"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$widget.appendChild(this.$input),this.$input.addEventListener("change",()=>{this.setValue(this.$input.checked),this._callOnFinishChange()}),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.checked=this.getValue(),this}}function PR(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 S6e={isPrimitive:!0,match:t=>typeof t=="string",fromHexString:PR,toHexString:PR},ey={isPrimitive:!0,match:t=>typeof t=="number",fromHexString:t=>parseInt(t.substring(1),16),toHexString:t=>"#"+t.toString(16).padStart(6,0)},M6e={isPrimitive:!1,match:t=>Array.isArray(t),fromHexString(t,e,n=1){const r=ey.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 ey.toHexString(i)}},E6e={isPrimitive:!1,match:t=>Object(t)===t,fromHexString(t,e,n=1){const r=ey.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 ey.toHexString(i)}},N6e=[S6e,ey,M6e,E6e];function A6e(t){return N6e.find(e=>e.match(t))}class T6e extends Yl{constructor(e,n,r,i){super(e,n,r,"color"),this.$input=document.createElement("input"),this.$input.setAttribute("type","color"),this.$input.setAttribute("tabindex",-1),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$text=document.createElement("input"),this.$text.setAttribute("type","text"),this.$text.setAttribute("spellcheck","false"),this.$text.setAttribute("aria-labelledby",this.$name.id),this.$display=document.createElement("div"),this.$display.classList.add("display"),this.$display.appendChild(this.$input),this.$widget.appendChild(this.$display),this.$widget.appendChild(this.$text),this._format=A6e(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=PR(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 oj extends Yl{constructor(e,n,r){super(e,n,r,"function"),this.$button=document.createElement("button"),this.$button.appendChild(this.$name),this.$widget.appendChild(this.$button),this.$button.addEventListener("click",i=>{i.preventDefault(),this.getValue().call(this.object),this._callOnChange()}),this.$button.addEventListener("touchstart",()=>{},{passive:!0}),this.$disable=this.$button}}class C6e extends Yl{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 S=parseFloat(this.$input.value);isNaN(S)||(this._stepExplicit&&(S=this._snap(S)),this.setValue(this._clamp(S)))},r=S=>{const M=parseFloat(this.$input.value);isNaN(M)||(this._snapClampSetValue(M+S),this.$input.value=this.getValue())},i=S=>{S.key==="Enter"&&this.$input.blur(),S.code==="ArrowUp"&&(S.preventDefault(),r(this._step*this._arrowKeyMultiplier(S))),S.code==="ArrowDown"&&(S.preventDefault(),r(this._step*this._arrowKeyMultiplier(S)*-1))},a=S=>{this._inputFocused&&(S.preventDefault(),r(this._step*this._normalizeMouseWheel(S)))};let o=!1,l,c,u,d,f;const m=5,p=S=>{l=S.clientX,c=u=S.clientY,o=!0,d=this.getValue(),f=0,window.addEventListener("mousemove",b),window.addEventListener("mouseup",v)},b=S=>{if(o){const M=S.clientX-l,N=S.clientY-c;Math.abs(N)>m?(S.preventDefault(),this.$input.blur(),o=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(M)>m&&v()}if(!o){const M=S.clientY-u;f-=M*this._step*this._arrowKeyMultiplier(S),d+f>this._max?f=this._max-d:d+f<this._min&&(f=this._min-d),this._snapClampSetValue(d+f)}u=S.clientY},v=()=>{this._setDraggingStyle(!1,"vertical"),this._callOnFinishChange(),window.removeEventListener("mousemove",b),window.removeEventListener("mouseup",v)},x=()=>{this._inputFocused=!0},y=()=>{this._inputFocused=!1,this.updateDisplay(),this._callOnFinishChange()};this.$input.addEventListener("input",n),this.$input.addEventListener("keydown",i),this.$input.addEventListener("wheel",a,{passive:!1}),this.$input.addEventListener("mousedown",p),this.$input.addEventListener("focus",x),this.$input.addEventListener("blur",y)}_initSlider(){this._hasSlider=!0,this.$slider=document.createElement("div"),this.$slider.classList.add("slider"),this.$fill=document.createElement("div"),this.$fill.classList.add("fill"),this.$slider.appendChild(this.$fill),this.$widget.insertBefore(this.$slider,this.$input),this.domElement.classList.add("hasSlider");const e=(y,S,M,N,A)=>(y-S)/(M-S)*(A-N)+N,n=y=>{const S=this.$slider.getBoundingClientRect();let M=e(y,S.left,S.right,this._min,this._max);this._snapClampSetValue(M)},r=y=>{this._setDraggingStyle(!0),n(y.clientX),window.addEventListener("mousemove",i),window.addEventListener("mouseup",a)},i=y=>{n(y.clientX)},a=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",a)};let o=!1,l,c;const u=y=>{y.preventDefault(),this._setDraggingStyle(!0),n(y.touches[0].clientX),o=!1},d=y=>{y.touches.length>1||(this._hasScrollBar?(l=y.touches[0].clientX,c=y.touches[0].clientY,o=!0):u(y),window.addEventListener("touchmove",f,{passive:!1}),window.addEventListener("touchend",m))},f=y=>{if(o){const S=y.touches[0].clientX-l,M=y.touches[0].clientY-c;Math.abs(S)>Math.abs(M)?u(y):(window.removeEventListener("touchmove",f),window.removeEventListener("touchend",m))}else y.preventDefault(),n(y.touches[0].clientX)},m=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("touchmove",f),window.removeEventListener("touchend",m)},p=this._callOnFinishChange.bind(this),b=400;let v;const x=y=>{if(Math.abs(y.deltaX)<Math.abs(y.deltaY)&&this._hasScrollBar)return;y.preventDefault();const M=this._normalizeMouseWheel(y)*this._step;this._snapClampSetValue(this.getValue()+M),this.$input.value=this.getValue(),clearTimeout(v),v=setTimeout(p,b)};this.$slider.addEventListener("mousedown",r),this.$slider.addEventListener("touchstart",d,{passive:!1}),this.$slider.addEventListener("wheel",x,{passive:!1})}_setDraggingStyle(e,n="horizontal"){this.$slider&&this.$slider.classList.toggle("active",e),document.body.classList.toggle("lil-gui-dragging",e),document.body.classList.toggle(`lil-gui-${n}`,e)}_getImplicitStep(){return this._hasMin&&this._hasMax?(this._max-this._min)/1e3:.1}_onUpdateMinMax(){!this._hasSlider&&this._hasMin&&this._hasMax&&(this._stepExplicit||this.step(this._getImplicitStep(),!1),this._initSlider(),this.updateDisplay())}_normalizeMouseWheel(e){let{deltaX:n,deltaY:r}=e;return Math.floor(e.deltaY)!==e.deltaY&&e.wheelDelta&&(n=0,r=-e.wheelDelta/120,r*=this._stepExplicit?1:10),n+-r}_arrowKeyMultiplier(e){let n=this._stepExplicit?1:10;return e.shiftKey?n*=10:e.altKey&&(n/=10),n}_snap(e){const n=Math.round(e/this._step)*this._step;return parseFloat(n.toPrecision(15))}_clamp(e){return e<this._min&&(e=this._min),e>this._max&&(e=this._max),e}_snapClampSetValue(e){this.setValue(this._clamp(this._snap(e)))}get _hasScrollBar(){const e=this.parent.root.$children;return e.scrollHeight>e.clientHeight}get _hasMin(){return this._min!==void 0}get _hasMax(){return this._max!==void 0}}class k6e extends Yl{constructor(e,n,r,i){super(e,n,r,"option"),this.$select=document.createElement("select"),this.$select.setAttribute("aria-labelledby",this.$name.id),this.$display=document.createElement("div"),this.$display.classList.add("display"),this.$select.addEventListener("change",()=>{this.setValue(this._values[this.$select.selectedIndex]),this._callOnFinishChange()}),this.$select.addEventListener("focus",()=>{this.$display.classList.add("focus")}),this.$select.addEventListener("blur",()=>{this.$display.classList.remove("focus")}),this.$widget.appendChild(this.$select),this.$widget.appendChild(this.$display),this.$disable=this.$select,this.options(i)}options(e){return this._values=Array.isArray(e)?e:Object.values(e),this._names=Array.isArray(e)?e:Object.keys(e),this.$select.replaceChildren(),this._names.forEach(n=>{const r=document.createElement("option");r.textContent=n,this.$select.appendChild(r)}),this.updateDisplay(),this}updateDisplay(){const e=this.getValue(),n=this._values.indexOf(e);return this.$select.selectedIndex=n,this.$display.textContent=n===-1?e:this._names[n],this}}class j6e extends Yl{constructor(e,n,r){super(e,n,r,"string"),this.$input=document.createElement("input"),this.$input.setAttribute("type","text"),this.$input.setAttribute("spellcheck","false"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$input.addEventListener("input",()=>{this.setValue(this.$input.value)}),this.$input.addEventListener("keydown",i=>{i.code==="Enter"&&this.$input.blur()}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$widget.appendChild(this.$input),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.value=this.getValue(),this}}const P6e=`.lil-gui {
  7525. font-family: var(--font-family);
  7526. font-size: var(--font-size);
  7527. line-height: 1;
  7528. font-weight: normal;
  7529. font-style: normal;
  7530. text-align: left;
  7531. color: var(--text-color);
  7532. user-select: none;
  7533. -webkit-user-select: none;
  7534. touch-action: manipulation;
  7535. --background-color: #1f1f1f;
  7536. --text-color: #ebebeb;
  7537. --title-background-color: #111111;
  7538. --title-text-color: #ebebeb;
  7539. --widget-color: #424242;
  7540. --hover-color: #4f4f4f;
  7541. --focus-color: #595959;
  7542. --number-color: #2cc9ff;
  7543. --string-color: #a2db3c;
  7544. --font-size: 11px;
  7545. --input-font-size: 11px;
  7546. --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  7547. --font-family-mono: Menlo, Monaco, Consolas, "Droid Sans Mono", monospace;
  7548. --padding: 4px;
  7549. --spacing: 4px;
  7550. --widget-height: 20px;
  7551. --title-height: calc(var(--widget-height) + var(--spacing) * 1.25);
  7552. --name-width: 45%;
  7553. --slider-knob-width: 2px;
  7554. --slider-input-width: 27%;
  7555. --color-input-width: 27%;
  7556. --slider-input-min-width: 45px;
  7557. --color-input-min-width: 45px;
  7558. --folder-indent: 7px;
  7559. --widget-padding: 0 0 0 3px;
  7560. --widget-border-radius: 2px;
  7561. --checkbox-size: calc(0.75 * var(--widget-height));
  7562. --scrollbar-width: 5px;
  7563. }
  7564. .lil-gui, .lil-gui * {
  7565. box-sizing: border-box;
  7566. margin: 0;
  7567. padding: 0;
  7568. }
  7569. .lil-gui.root {
  7570. width: var(--width, 245px);
  7571. display: flex;
  7572. flex-direction: column;
  7573. background: var(--background-color);
  7574. }
  7575. .lil-gui.root > .title {
  7576. background: var(--title-background-color);
  7577. color: var(--title-text-color);
  7578. }
  7579. .lil-gui.root > .children {
  7580. overflow-x: hidden;
  7581. overflow-y: auto;
  7582. }
  7583. .lil-gui.root > .children::-webkit-scrollbar {
  7584. width: var(--scrollbar-width);
  7585. height: var(--scrollbar-width);
  7586. background: var(--background-color);
  7587. }
  7588. .lil-gui.root > .children::-webkit-scrollbar-thumb {
  7589. border-radius: var(--scrollbar-width);
  7590. background: var(--focus-color);
  7591. }
  7592. @media (pointer: coarse) {
  7593. .lil-gui.allow-touch-styles, .lil-gui.allow-touch-styles .lil-gui {
  7594. --widget-height: 28px;
  7595. --padding: 6px;
  7596. --spacing: 6px;
  7597. --font-size: 13px;
  7598. --input-font-size: 16px;
  7599. --folder-indent: 10px;
  7600. --scrollbar-width: 7px;
  7601. --slider-input-min-width: 50px;
  7602. --color-input-min-width: 65px;
  7603. }
  7604. }
  7605. .lil-gui.force-touch-styles, .lil-gui.force-touch-styles .lil-gui {
  7606. --widget-height: 28px;
  7607. --padding: 6px;
  7608. --spacing: 6px;
  7609. --font-size: 13px;
  7610. --input-font-size: 16px;
  7611. --folder-indent: 10px;
  7612. --scrollbar-width: 7px;
  7613. --slider-input-min-width: 50px;
  7614. --color-input-min-width: 65px;
  7615. }
  7616. .lil-gui.autoPlace {
  7617. max-height: 100%;
  7618. position: fixed;
  7619. top: 0;
  7620. right: 15px;
  7621. z-index: 1001;
  7622. }
  7623. .lil-gui .controller {
  7624. display: flex;
  7625. align-items: center;
  7626. padding: 0 var(--padding);
  7627. margin: var(--spacing) 0;
  7628. }
  7629. .lil-gui .controller.disabled {
  7630. opacity: 0.5;
  7631. }
  7632. .lil-gui .controller.disabled, .lil-gui .controller.disabled * {
  7633. pointer-events: none !important;
  7634. }
  7635. .lil-gui .controller > .name {
  7636. min-width: var(--name-width);
  7637. flex-shrink: 0;
  7638. white-space: pre;
  7639. padding-right: var(--spacing);
  7640. line-height: var(--widget-height);
  7641. }
  7642. .lil-gui .controller .widget {
  7643. position: relative;
  7644. display: flex;
  7645. align-items: center;
  7646. width: 100%;
  7647. min-height: var(--widget-height);
  7648. }
  7649. .lil-gui .controller.string input {
  7650. color: var(--string-color);
  7651. }
  7652. .lil-gui .controller.boolean {
  7653. cursor: pointer;
  7654. }
  7655. .lil-gui .controller.color .display {
  7656. width: 100%;
  7657. height: var(--widget-height);
  7658. border-radius: var(--widget-border-radius);
  7659. position: relative;
  7660. }
  7661. @media (hover: hover) {
  7662. .lil-gui .controller.color .display:hover:before {
  7663. content: " ";
  7664. display: block;
  7665. position: absolute;
  7666. border-radius: var(--widget-border-radius);
  7667. border: 1px solid #fff9;
  7668. top: 0;
  7669. right: 0;
  7670. bottom: 0;
  7671. left: 0;
  7672. }
  7673. }
  7674. .lil-gui .controller.color input[type=color] {
  7675. opacity: 0;
  7676. width: 100%;
  7677. height: 100%;
  7678. cursor: pointer;
  7679. }
  7680. .lil-gui .controller.color input[type=text] {
  7681. margin-left: var(--spacing);
  7682. font-family: var(--font-family-mono);
  7683. min-width: var(--color-input-min-width);
  7684. width: var(--color-input-width);
  7685. flex-shrink: 0;
  7686. }
  7687. .lil-gui .controller.option select {
  7688. opacity: 0;
  7689. position: absolute;
  7690. width: 100%;
  7691. max-width: 100%;
  7692. }
  7693. .lil-gui .controller.option .display {
  7694. position: relative;
  7695. pointer-events: none;
  7696. border-radius: var(--widget-border-radius);
  7697. height: var(--widget-height);
  7698. line-height: var(--widget-height);
  7699. max-width: 100%;
  7700. overflow: hidden;
  7701. word-break: break-all;
  7702. padding-left: 0.55em;
  7703. padding-right: 1.75em;
  7704. background: var(--widget-color);
  7705. }
  7706. @media (hover: hover) {
  7707. .lil-gui .controller.option .display.focus {
  7708. background: var(--focus-color);
  7709. }
  7710. }
  7711. .lil-gui .controller.option .display.active {
  7712. background: var(--focus-color);
  7713. }
  7714. .lil-gui .controller.option .display:after {
  7715. font-family: "lil-gui";
  7716. content: "↕";
  7717. position: absolute;
  7718. top: 0;
  7719. right: 0;
  7720. bottom: 0;
  7721. padding-right: 0.375em;
  7722. }
  7723. .lil-gui .controller.option .widget,
  7724. .lil-gui .controller.option select {
  7725. cursor: pointer;
  7726. }
  7727. @media (hover: hover) {
  7728. .lil-gui .controller.option .widget:hover .display {
  7729. background: var(--hover-color);
  7730. }
  7731. }
  7732. .lil-gui .controller.number input {
  7733. color: var(--number-color);
  7734. }
  7735. .lil-gui .controller.number.hasSlider input {
  7736. margin-left: var(--spacing);
  7737. width: var(--slider-input-width);
  7738. min-width: var(--slider-input-min-width);
  7739. flex-shrink: 0;
  7740. }
  7741. .lil-gui .controller.number .slider {
  7742. width: 100%;
  7743. height: var(--widget-height);
  7744. background: var(--widget-color);
  7745. border-radius: var(--widget-border-radius);
  7746. padding-right: var(--slider-knob-width);
  7747. overflow: hidden;
  7748. cursor: ew-resize;
  7749. touch-action: pan-y;
  7750. }
  7751. @media (hover: hover) {
  7752. .lil-gui .controller.number .slider:hover {
  7753. background: var(--hover-color);
  7754. }
  7755. }
  7756. .lil-gui .controller.number .slider.active {
  7757. background: var(--focus-color);
  7758. }
  7759. .lil-gui .controller.number .slider.active .fill {
  7760. opacity: 0.95;
  7761. }
  7762. .lil-gui .controller.number .fill {
  7763. height: 100%;
  7764. border-right: var(--slider-knob-width) solid var(--number-color);
  7765. box-sizing: content-box;
  7766. }
  7767. .lil-gui-dragging .lil-gui {
  7768. --hover-color: var(--widget-color);
  7769. }
  7770. .lil-gui-dragging * {
  7771. cursor: ew-resize !important;
  7772. }
  7773. .lil-gui-dragging.lil-gui-vertical * {
  7774. cursor: ns-resize !important;
  7775. }
  7776. .lil-gui .title {
  7777. height: var(--title-height);
  7778. line-height: calc(var(--title-height) - 4px);
  7779. font-weight: 600;
  7780. padding: 0 var(--padding);
  7781. -webkit-tap-highlight-color: transparent;
  7782. cursor: pointer;
  7783. outline: none;
  7784. text-decoration-skip: objects;
  7785. }
  7786. .lil-gui .title:before {
  7787. font-family: "lil-gui";
  7788. content: "▾";
  7789. padding-right: 2px;
  7790. display: inline-block;
  7791. }
  7792. .lil-gui .title:active {
  7793. background: var(--title-background-color);
  7794. opacity: 0.75;
  7795. }
  7796. @media (hover: hover) {
  7797. body:not(.lil-gui-dragging) .lil-gui .title:hover {
  7798. background: var(--title-background-color);
  7799. opacity: 0.85;
  7800. }
  7801. .lil-gui .title:focus {
  7802. text-decoration: underline var(--focus-color);
  7803. }
  7804. }
  7805. .lil-gui.root > .title:focus {
  7806. text-decoration: none !important;
  7807. }
  7808. .lil-gui.closed > .title:before {
  7809. content: "▸";
  7810. }
  7811. .lil-gui.closed > .children {
  7812. transform: translateY(-7px);
  7813. opacity: 0;
  7814. }
  7815. .lil-gui.closed:not(.transition) > .children {
  7816. display: none;
  7817. }
  7818. .lil-gui.transition > .children {
  7819. transition-duration: 300ms;
  7820. transition-property: height, opacity, transform;
  7821. transition-timing-function: cubic-bezier(0.2, 0.6, 0.35, 1);
  7822. overflow: hidden;
  7823. pointer-events: none;
  7824. }
  7825. .lil-gui .children:empty:before {
  7826. content: "Empty";
  7827. padding: 0 var(--padding);
  7828. margin: var(--spacing) 0;
  7829. display: block;
  7830. height: var(--widget-height);
  7831. font-style: italic;
  7832. line-height: var(--widget-height);
  7833. opacity: 0.5;
  7834. }
  7835. .lil-gui.root > .children > .lil-gui > .title {
  7836. border: 0 solid var(--widget-color);
  7837. border-width: 1px 0;
  7838. transition: border-color 300ms;
  7839. }
  7840. .lil-gui.root > .children > .lil-gui.closed > .title {
  7841. border-bottom-color: transparent;
  7842. }
  7843. .lil-gui + .controller {
  7844. border-top: 1px solid var(--widget-color);
  7845. margin-top: 0;
  7846. padding-top: var(--spacing);
  7847. }
  7848. .lil-gui .lil-gui .lil-gui > .title {
  7849. border: none;
  7850. }
  7851. .lil-gui .lil-gui .lil-gui > .children {
  7852. border: none;
  7853. margin-left: var(--folder-indent);
  7854. border-left: 2px solid var(--widget-color);
  7855. }
  7856. .lil-gui .lil-gui .controller {
  7857. border: none;
  7858. }
  7859. .lil-gui label, .lil-gui input, .lil-gui button {
  7860. -webkit-tap-highlight-color: transparent;
  7861. }
  7862. .lil-gui input {
  7863. border: 0;
  7864. outline: none;
  7865. font-family: var(--font-family);
  7866. font-size: var(--input-font-size);
  7867. border-radius: var(--widget-border-radius);
  7868. height: var(--widget-height);
  7869. background: var(--widget-color);
  7870. color: var(--text-color);
  7871. width: 100%;
  7872. }
  7873. @media (hover: hover) {
  7874. .lil-gui input:hover {
  7875. background: var(--hover-color);
  7876. }
  7877. .lil-gui input:active {
  7878. background: var(--focus-color);
  7879. }
  7880. }
  7881. .lil-gui input:disabled {
  7882. opacity: 1;
  7883. }
  7884. .lil-gui input[type=text],
  7885. .lil-gui input[type=number] {
  7886. padding: var(--widget-padding);
  7887. -moz-appearance: textfield;
  7888. }
  7889. .lil-gui input[type=text]:focus,
  7890. .lil-gui input[type=number]:focus {
  7891. background: var(--focus-color);
  7892. }
  7893. .lil-gui input[type=checkbox] {
  7894. appearance: none;
  7895. width: var(--checkbox-size);
  7896. height: var(--checkbox-size);
  7897. border-radius: var(--widget-border-radius);
  7898. text-align: center;
  7899. cursor: pointer;
  7900. }
  7901. .lil-gui input[type=checkbox]:checked:before {
  7902. font-family: "lil-gui";
  7903. content: "✓";
  7904. font-size: var(--checkbox-size);
  7905. line-height: var(--checkbox-size);
  7906. }
  7907. @media (hover: hover) {
  7908. .lil-gui input[type=checkbox]:focus {
  7909. box-shadow: inset 0 0 0 1px var(--focus-color);
  7910. }
  7911. }
  7912. .lil-gui button {
  7913. outline: none;
  7914. cursor: pointer;
  7915. font-family: var(--font-family);
  7916. font-size: var(--font-size);
  7917. color: var(--text-color);
  7918. width: 100%;
  7919. height: var(--widget-height);
  7920. text-transform: none;
  7921. background: var(--widget-color);
  7922. border-radius: var(--widget-border-radius);
  7923. border: none;
  7924. }
  7925. @media (hover: hover) {
  7926. .lil-gui button:hover {
  7927. background: var(--hover-color);
  7928. }
  7929. .lil-gui button:focus {
  7930. box-shadow: inset 0 0 0 1px var(--focus-color);
  7931. }
  7932. }
  7933. .lil-gui button:active {
  7934. background: var(--focus-color);
  7935. }
  7936. @font-face {
  7937. font-family: "lil-gui";
  7938. 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");
  7939. }`;function R6e(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 a9=!1;class YS{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"),!a9&&l&&(R6e(P6e),a9=!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 k6e(this,e,n,r);const o=e[n];switch(typeof o){case"number":return new C6e(this,e,n,r,i,a);case"boolean":return new w6e(this,e,n);case"string":return new j6e(this,e,n);case"function":return new oj(this,e,n)}console.error(`gui.add failed
  7940. property:`,n,`
  7941. object:`,e,`
  7942. value:`,o)}addColor(e,n,r=1){return new T6e(this,e,n,r)}addFolder(e){const n=new YS({parent:this,title:e});return this.root._closeFolders&&n.close(),n}load(e,n=!0){return e.controllers&&this.controllers.forEach(r=>{r instanceof oj||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 oj)){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 lj(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 _L{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 _L(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 wL{constructor(e,n,r,i){this.src=e,this.gcode=n,this.params=r,this.comment=i}}class s9 extends wL{constructor(e,n,r,i){super(e,n,r,i),this.params=r}}class dd extends wL{constructor(e,n,r,i){super(e,n,void 0,r),this.toolIndex=i}}class o9{constructor(e,n,r,i=0){this.layer=e,this.commands=n,this.lineNumber=r,this.height=i}}class ZS{constructor(e){this.lines=[],this.preamble=new o9(-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(`
  7943. `);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 s9(e,c,u,o);case"t0":return new dd(e,c,o,0);case"t1":return new dd(e,c,o,1);case"t2":return new dd(e,c,o,2);case"t3":return new dd(e,c,o,3);case"t4":return new dd(e,c,o,4);case"t5":return new dd(e,c,o,5);case"t6":return new dd(e,c,o,6);case"t7":return new dd(e,c,o,7);default:return new wL(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 s9){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 o9(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=_L.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}}}ZS.prototype.parseGcode=ZS.prototype.parseGCode;const l9={type:"change"},cj={type:"start"},c9={type:"end"},A1=new gL,u9=new bd,D6e=Math.cos(70*qee.DEG2RAD);class O6e extends hm{constructor(e,n){super(),this.object=e,this.domElement=n,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new Be,this.cursor=new Be,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:fp.ROTATE,MIDDLE:fp.DOLLY,RIGHT:fp.PAN},this.touches={ONE:mp.ROTATE,TWO:mp.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(ie){ie.addEventListener("keydown",Re),this._domElementKeyEvents=ie},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",Re),this._domElementKeyEvents=null},this.saveState=function(){r.target0.copy(r.target),r.position0.copy(r.object.position),r.zoom0=r.object.zoom},this.reset=function(){r.target.copy(r.target0),r.object.position.copy(r.position0),r.object.zoom=r.zoom0,r.object.updateProjectionMatrix(),r.dispatchEvent(l9),r.update(),a=i.NONE},this.update=(function(){const ie=new Be,X=new tm().setFromUnitVectors(e.up,new Be(0,1,0)),$=X.clone().invert(),I=new Be,ce=new tm,Ee=new Be,Ie=2*Math.PI;return function(le=null){const B=r.object.position;ie.copy(B).sub(r.target),ie.applyQuaternion(X),l.setFromVector3(ie),r.autoRotate&&a===i.NONE&&R((function(we){return we!==null?2*Math.PI/60*r.autoRotateSpeed*we:2*Math.PI/60/60*r.autoRotateSpeed})(le)),r.enableDamping?(l.theta+=c.theta*r.dampingFactor,l.phi+=c.phi*r.dampingFactor):(l.theta+=c.theta,l.phi+=c.phi);let O=r.minAzimuthAngle,Y=r.maxAzimuthAngle;isFinite(O)&&isFinite(Y)&&(O<-Math.PI?O+=Ie:O>Math.PI&&(O-=Ie),Y<-Math.PI?Y+=Ie:Y>Math.PI&&(Y-=Ie),l.theta=O<=Y?Math.max(O,Math.min(Y,l.theta)):l.theta>(O+Y)/2?Math.max(O,l.theta):Math.min(Y,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&&k||r.object.isOrthographicCamera?l.radius=J(l.radius):l.radius=J(l.radius*u),ie.setFromSpherical(l),ie.applyQuaternion($),B.copy(r.target).add(ie),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 pe=!1;if(r.zoomToCursor&&k){let we=null;if(r.object.isPerspectiveCamera){const ae=ie.length();we=J(ae*u);const ke=ae-we;r.object.position.addScaledVector(N,ke),r.object.updateMatrixWorld()}else if(r.object.isOrthographicCamera){const ae=new Be(A.x,A.y,0);ae.unproject(r.object),r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),pe=!0;const ke=new Be(A.x,A.y,0);ke.unproject(r.object),r.object.position.sub(ke).add(ae),r.object.updateMatrixWorld(),we=ie.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):(A1.origin.copy(r.object.position),A1.direction.set(0,0,-1).transformDirection(r.object.matrix),Math.abs(r.object.up.dot(A1.direction))<D6e?e.lookAt(r.target):(u9.setFromNormalAndCoplanarPoint(r.object.up,r.target),A1.intersectPlane(u9,r.target))))}else r.object.isOrthographicCamera&&(r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),pe=!0);return u=1,k=!1,!!(pe||I.distanceToSquared(r.object.position)>o||8*(1-ce.dot(r.object.quaternion))>o||Ee.distanceToSquared(r.target)>0)&&(r.dispatchEvent(l9),I.copy(r.object.position),ce.copy(r.object.quaternion),Ee.copy(r.target),!0)}})(),this.dispose=function(){r.domElement.removeEventListener("contextmenu",de),r.domElement.removeEventListener("pointerdown",oe),r.domElement.removeEventListener("pointercancel",ge),r.domElement.removeEventListener("wheel",Se),r.domElement.removeEventListener("pointermove",Ne),r.domElement.removeEventListener("pointerup",ge),r._domElementKeyEvents!==null&&(r._domElementKeyEvents.removeEventListener("keydown",Re),r._domElementKeyEvents=null)};const r=this,i={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let a=i.NONE;const o=1e-6,l=new r9,c=new r9;let u=1;const d=new Be,f=new mn,m=new mn,p=new mn,b=new mn,v=new mn,x=new mn,y=new mn,S=new mn,M=new mn,N=new Be,A=new mn;let k=!1;const C=[],D={};function T(){return Math.pow(.95,r.zoomSpeed)}function R(ie){c.theta-=ie}function U(ie){c.phi-=ie}const L=(function(){const ie=new Be;return function(X,$){ie.setFromMatrixColumn($,0),ie.multiplyScalar(-X),d.add(ie)}})(),q=(function(){const ie=new Be;return function(X,$){r.screenSpacePanning===!0?ie.setFromMatrixColumn($,1):(ie.setFromMatrixColumn($,0),ie.crossVectors(r.object.up,ie)),ie.multiplyScalar(X),d.add(ie)}})(),j=(function(){const ie=new Be;return function(X,$){const I=r.domElement;if(r.object.isPerspectiveCamera){const ce=r.object.position;ie.copy(ce).sub(r.target);let Ee=ie.length();Ee*=Math.tan(r.object.fov/2*Math.PI/180),L(2*X*Ee/I.clientHeight,r.object.matrix),q(2*$*Ee/I.clientHeight,r.object.matrix)}else r.object.isOrthographicCamera?(L(X*(r.object.right-r.object.left)/r.object.zoom/I.clientWidth,r.object.matrix),q($*(r.object.top-r.object.bottom)/r.object.zoom/I.clientHeight,r.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),r.enablePan=!1)}})();function W(ie){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u/=ie:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function K(ie){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u*=ie:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function V(ie){if(!r.zoomToCursor)return;k=!0;const X=r.domElement.getBoundingClientRect(),$=ie.clientX-X.left,I=ie.clientY-X.top,ce=X.width,Ee=X.height;A.x=$/ce*2-1,A.y=-I/Ee*2+1,N.set(A.x,A.y,1).unproject(r.object).sub(r.object.position).normalize()}function J(ie){return Math.max(r.minDistance,Math.min(r.maxDistance,ie))}function ne(ie){f.set(ie.clientX,ie.clientY)}function te(ie){b.set(ie.clientX,ie.clientY)}function z(){if(C.length===1)f.set(C[0].pageX,C[0].pageY);else{const ie=.5*(C[0].pageX+C[1].pageX),X=.5*(C[0].pageY+C[1].pageY);f.set(ie,X)}}function H(){if(C.length===1)b.set(C[0].pageX,C[0].pageY);else{const ie=.5*(C[0].pageX+C[1].pageX),X=.5*(C[0].pageY+C[1].pageY);b.set(ie,X)}}function Z(){const ie=C[0].pageX-C[1].pageX,X=C[0].pageY-C[1].pageY,$=Math.sqrt(ie*ie+X*X);y.set(0,$)}function ee(ie){if(C.length==1)m.set(ie.pageX,ie.pageY);else{const $=G(ie),I=.5*(ie.pageX+$.x),ce=.5*(ie.pageY+$.y);m.set(I,ce)}p.subVectors(m,f).multiplyScalar(r.rotateSpeed);const X=r.domElement;R(2*Math.PI*p.x/X.clientHeight),U(2*Math.PI*p.y/X.clientHeight),f.copy(m)}function he(ie){if(C.length===1)v.set(ie.pageX,ie.pageY);else{const X=G(ie),$=.5*(ie.pageX+X.x),I=.5*(ie.pageY+X.y);v.set($,I)}x.subVectors(v,b).multiplyScalar(r.panSpeed),j(x.x,x.y),b.copy(v)}function fe(ie){const X=G(ie),$=ie.pageX-X.x,I=ie.pageY-X.y,ce=Math.sqrt($*$+I*I);S.set(0,ce),M.set(0,Math.pow(S.y/y.y,r.zoomSpeed)),W(M.y),y.copy(S)}function oe(ie){r.enabled!==!1&&(C.length===0&&(r.domElement.setPointerCapture(ie.pointerId),r.domElement.addEventListener("pointermove",Ne),r.domElement.addEventListener("pointerup",ge)),(function(X){C.push(X)})(ie),ie.pointerType==="touch"?(function(X){switch(Qe(X),C.length){case 1:switch(r.touches.ONE){case mp.ROTATE:if(r.enableRotate===!1)return;z(),a=i.TOUCH_ROTATE;break;case mp.PAN:if(r.enablePan===!1)return;H(),a=i.TOUCH_PAN;break;default:a=i.NONE}break;case 2:switch(r.touches.TWO){case mp.DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;r.enableZoom&&Z(),r.enablePan&&H(),a=i.TOUCH_DOLLY_PAN;break;case mp.DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;r.enableZoom&&Z(),r.enableRotate&&z(),a=i.TOUCH_DOLLY_ROTATE;break;default:a=i.NONE}break;default:a=i.NONE}a!==i.NONE&&r.dispatchEvent(cj)})(ie):(function(X){let $;switch(X.button){case 0:$=r.mouseButtons.LEFT;break;case 1:$=r.mouseButtons.MIDDLE;break;case 2:$=r.mouseButtons.RIGHT;break;default:$=-1}switch($){case fp.DOLLY:if(r.enableZoom===!1)return;(function(I){V(I),y.set(I.clientX,I.clientY)})(X),a=i.DOLLY;break;case fp.ROTATE:if(X.ctrlKey||X.metaKey||X.shiftKey){if(r.enablePan===!1)return;te(X),a=i.PAN}else{if(r.enableRotate===!1)return;ne(X),a=i.ROTATE}break;case fp.PAN:if(X.ctrlKey||X.metaKey||X.shiftKey){if(r.enableRotate===!1)return;ne(X),a=i.ROTATE}else{if(r.enablePan===!1)return;te(X),a=i.PAN}break;default:a=i.NONE}a!==i.NONE&&r.dispatchEvent(cj)})(ie))}function Ne(ie){r.enabled!==!1&&(ie.pointerType==="touch"?(function(X){switch(Qe(X),a){case i.TOUCH_ROTATE:if(r.enableRotate===!1)return;ee(X),r.update();break;case i.TOUCH_PAN:if(r.enablePan===!1)return;he(X),r.update();break;case i.TOUCH_DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;(function($){r.enableZoom&&fe($),r.enablePan&&he($)})(X),r.update();break;case i.TOUCH_DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;(function($){r.enableZoom&&fe($),r.enableRotate&&ee($)})(X),r.update();break;default:a=i.NONE}})(ie):(function(X){switch(a){case i.ROTATE:if(r.enableRotate===!1)return;(function($){m.set($.clientX,$.clientY),p.subVectors(m,f).multiplyScalar(r.rotateSpeed);const I=r.domElement;R(2*Math.PI*p.x/I.clientHeight),U(2*Math.PI*p.y/I.clientHeight),f.copy(m),r.update()})(X);break;case i.DOLLY:if(r.enableZoom===!1)return;(function($){S.set($.clientX,$.clientY),M.subVectors(S,y),M.y>0?W(T()):M.y<0&&K(T()),y.copy(S),r.update()})(X);break;case i.PAN:if(r.enablePan===!1)return;(function($){v.set($.clientX,$.clientY),x.subVectors(v,b).multiplyScalar(r.panSpeed),j(x.x,x.y),b.copy(v),r.update()})(X)}})(ie))}function ge(ie){(function(X){delete D[X.pointerId];for(let $=0;$<C.length;$++)if(C[$].pointerId==X.pointerId)return void C.splice($,1)})(ie),C.length===0&&(r.domElement.releasePointerCapture(ie.pointerId),r.domElement.removeEventListener("pointermove",Ne),r.domElement.removeEventListener("pointerup",ge)),r.dispatchEvent(c9),a=i.NONE}function Se(ie){r.enabled!==!1&&r.enableZoom!==!1&&a===i.NONE&&(ie.preventDefault(),r.dispatchEvent(cj),(function(X){V(X),X.deltaY<0?K(T()):X.deltaY>0&&W(T()),r.update()})(ie),r.dispatchEvent(c9))}function Re(ie){r.enabled!==!1&&r.enablePan!==!1&&(function(X){let $=!1;switch(X.code){case r.keys.UP:X.ctrlKey||X.metaKey||X.shiftKey?U(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):j(0,r.keyPanSpeed),$=!0;break;case r.keys.BOTTOM:X.ctrlKey||X.metaKey||X.shiftKey?U(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):j(0,-r.keyPanSpeed),$=!0;break;case r.keys.LEFT:X.ctrlKey||X.metaKey||X.shiftKey?R(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):j(r.keyPanSpeed,0),$=!0;break;case r.keys.RIGHT:X.ctrlKey||X.metaKey||X.shiftKey?R(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):j(-r.keyPanSpeed,0),$=!0}$&&(X.preventDefault(),r.update())})(ie)}function de(ie){r.enabled!==!1&&ie.preventDefault()}function Qe(ie){let X=D[ie.pointerId];X===void 0&&(X=new mn,D[ie.pointerId]=X),X.set(ie.pageX,ie.pageY)}function G(ie){const X=ie.pointerId===C[0].pointerId?C[1]:C[0];return D[X.pointerId]}r.domElement.addEventListener("contextmenu",de),r.domElement.addEventListener("pointerdown",oe),r.domElement.addEventListener("pointercancel",ge),r.domElement.addEventListener("wheel",Se,{passive:!1}),this.update()}}Lt.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new mn(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},gs.line={uniforms:xL.merge([Lt.common,Lt.fog,Lt.line]),vertexShader:`
  7944. #include <common>
  7945. #include <color_pars_vertex>
  7946. #include <fog_pars_vertex>
  7947. #include <logdepthbuf_pars_vertex>
  7948. #include <clipping_planes_pars_vertex>
  7949. uniform float linewidth;
  7950. uniform vec2 resolution;
  7951. attribute vec3 instanceStart;
  7952. attribute vec3 instanceEnd;
  7953. attribute vec3 instanceColorStart;
  7954. attribute vec3 instanceColorEnd;
  7955. #ifdef WORLD_UNITS
  7956. varying vec4 worldPos;
  7957. varying vec3 worldStart;
  7958. varying vec3 worldEnd;
  7959. #ifdef USE_DASH
  7960. varying vec2 vUv;
  7961. #endif
  7962. #else
  7963. varying vec2 vUv;
  7964. #endif
  7965. #ifdef USE_DASH
  7966. uniform float dashScale;
  7967. attribute float instanceDistanceStart;
  7968. attribute float instanceDistanceEnd;
  7969. varying float vLineDistance;
  7970. #endif
  7971. void trimSegment( const in vec4 start, inout vec4 end ) {
  7972. // trim end segment so it terminates between the camera plane and the near plane
  7973. // conservative estimate of the near plane
  7974. float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
  7975. float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
  7976. float nearEstimate = - 0.5 * b / a;
  7977. float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );
  7978. end.xyz = mix( start.xyz, end.xyz, alpha );
  7979. }
  7980. void main() {
  7981. #ifdef USE_COLOR
  7982. vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
  7983. #endif
  7984. #ifdef USE_DASH
  7985. vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
  7986. vUv = uv;
  7987. #endif
  7988. float aspect = resolution.x / resolution.y;
  7989. // camera space
  7990. vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
  7991. vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
  7992. #ifdef WORLD_UNITS
  7993. worldStart = start.xyz;
  7994. worldEnd = end.xyz;
  7995. #else
  7996. vUv = uv;
  7997. #endif
  7998. // special case for perspective projection, and segments that terminate either in, or behind, the camera plane
  7999. // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
  8000. // but we need to perform ndc-space calculations in the shader, so we must address this issue directly
  8001. // perhaps there is a more elegant solution -- WestLangley
  8002. bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
  8003. if ( perspective ) {
  8004. if ( start.z < 0.0 && end.z >= 0.0 ) {
  8005. trimSegment( start, end );
  8006. } else if ( end.z < 0.0 && start.z >= 0.0 ) {
  8007. trimSegment( end, start );
  8008. }
  8009. }
  8010. // clip space
  8011. vec4 clipStart = projectionMatrix * start;
  8012. vec4 clipEnd = projectionMatrix * end;
  8013. // ndc space
  8014. vec3 ndcStart = clipStart.xyz / clipStart.w;
  8015. vec3 ndcEnd = clipEnd.xyz / clipEnd.w;
  8016. // direction
  8017. vec2 dir = ndcEnd.xy - ndcStart.xy;
  8018. // account for clip-space aspect ratio
  8019. dir.x *= aspect;
  8020. dir = normalize( dir );
  8021. #ifdef WORLD_UNITS
  8022. // get the offset direction as perpendicular to the view vector
  8023. vec3 worldDir = normalize( end.xyz - start.xyz );
  8024. vec3 offset;
  8025. if ( position.y < 0.5 ) {
  8026. offset = normalize( cross( start.xyz, worldDir ) );
  8027. } else {
  8028. offset = normalize( cross( end.xyz, worldDir ) );
  8029. }
  8030. // sign flip
  8031. if ( position.x < 0.0 ) offset *= - 1.0;
  8032. float forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) );
  8033. // don't extend the line if we're rendering dashes because we
  8034. // won't be rendering the endcaps
  8035. #ifndef USE_DASH
  8036. // extend the line bounds to encompass endcaps
  8037. start.xyz += - worldDir * linewidth * 0.5;
  8038. end.xyz += worldDir * linewidth * 0.5;
  8039. // shift the position of the quad so it hugs the forward edge of the line
  8040. offset.xy -= dir * forwardOffset;
  8041. offset.z += 0.5;
  8042. #endif
  8043. // endcaps
  8044. if ( position.y > 1.0 || position.y < 0.0 ) {
  8045. offset.xy += dir * 2.0 * forwardOffset;
  8046. }
  8047. // adjust for linewidth
  8048. offset *= linewidth * 0.5;
  8049. // set the world position
  8050. worldPos = ( position.y < 0.5 ) ? start : end;
  8051. worldPos.xyz += offset;
  8052. // project the worldpos
  8053. vec4 clip = projectionMatrix * worldPos;
  8054. // shift the depth of the projected points so the line
  8055. // segments overlap neatly
  8056. vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
  8057. clip.z = clipPose.z * clip.w;
  8058. #else
  8059. vec2 offset = vec2( dir.y, - dir.x );
  8060. // undo aspect ratio adjustment
  8061. dir.x /= aspect;
  8062. offset.x /= aspect;
  8063. // sign flip
  8064. if ( position.x < 0.0 ) offset *= - 1.0;
  8065. // endcaps
  8066. if ( position.y < 0.0 ) {
  8067. offset += - dir;
  8068. } else if ( position.y > 1.0 ) {
  8069. offset += dir;
  8070. }
  8071. // adjust for linewidth
  8072. offset *= linewidth;
  8073. // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
  8074. offset /= resolution.y;
  8075. // select end
  8076. vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
  8077. // back to clip space
  8078. offset *= clip.w;
  8079. clip.xy += offset;
  8080. #endif
  8081. gl_Position = clip;
  8082. vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
  8083. #include <logdepthbuf_vertex>
  8084. #include <clipping_planes_vertex>
  8085. #include <fog_vertex>
  8086. }
  8087. `,fragmentShader:`
  8088. uniform vec3 diffuse;
  8089. uniform float opacity;
  8090. uniform float linewidth;
  8091. #ifdef USE_DASH
  8092. uniform float dashOffset;
  8093. uniform float dashSize;
  8094. uniform float gapSize;
  8095. #endif
  8096. varying float vLineDistance;
  8097. #ifdef WORLD_UNITS
  8098. varying vec4 worldPos;
  8099. varying vec3 worldStart;
  8100. varying vec3 worldEnd;
  8101. #ifdef USE_DASH
  8102. varying vec2 vUv;
  8103. #endif
  8104. #else
  8105. varying vec2 vUv;
  8106. #endif
  8107. #include <common>
  8108. #include <color_pars_fragment>
  8109. #include <fog_pars_fragment>
  8110. #include <logdepthbuf_pars_fragment>
  8111. #include <clipping_planes_pars_fragment>
  8112. vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
  8113. float mua;
  8114. float mub;
  8115. vec3 p13 = p1 - p3;
  8116. vec3 p43 = p4 - p3;
  8117. vec3 p21 = p2 - p1;
  8118. float d1343 = dot( p13, p43 );
  8119. float d4321 = dot( p43, p21 );
  8120. float d1321 = dot( p13, p21 );
  8121. float d4343 = dot( p43, p43 );
  8122. float d2121 = dot( p21, p21 );
  8123. float denom = d2121 * d4343 - d4321 * d4321;
  8124. float numer = d1343 * d4321 - d1321 * d4343;
  8125. mua = numer / denom;
  8126. mua = clamp( mua, 0.0, 1.0 );
  8127. mub = ( d1343 + d4321 * ( mua ) ) / d4343;
  8128. mub = clamp( mub, 0.0, 1.0 );
  8129. return vec2( mua, mub );
  8130. }
  8131. void main() {
  8132. #include <clipping_planes_fragment>
  8133. #ifdef USE_DASH
  8134. if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
  8135. if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
  8136. #endif
  8137. float alpha = opacity;
  8138. #ifdef WORLD_UNITS
  8139. // Find the closest points on the view ray and the line segment
  8140. vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
  8141. vec3 lineDir = worldEnd - worldStart;
  8142. vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );
  8143. vec3 p1 = worldStart + lineDir * params.x;
  8144. vec3 p2 = rayEnd * params.y;
  8145. vec3 delta = p1 - p2;
  8146. float len = length( delta );
  8147. float norm = len / linewidth;
  8148. #ifndef USE_DASH
  8149. #ifdef USE_ALPHA_TO_COVERAGE
  8150. float dnorm = fwidth( norm );
  8151. alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
  8152. #else
  8153. if ( norm > 0.5 ) {
  8154. discard;
  8155. }
  8156. #endif
  8157. #endif
  8158. #else
  8159. #ifdef USE_ALPHA_TO_COVERAGE
  8160. // artifacts appear on some hardware if a derivative is taken within a conditional
  8161. float a = vUv.x;
  8162. float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
  8163. float len2 = a * a + b * b;
  8164. float dlen = fwidth( len2 );
  8165. if ( abs( vUv.y ) > 1.0 ) {
  8166. alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );
  8167. }
  8168. #else
  8169. if ( abs( vUv.y ) > 1.0 ) {
  8170. float a = vUv.x;
  8171. float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
  8172. float len2 = a * a + b * b;
  8173. if ( len2 > 1.0 ) discard;
  8174. }
  8175. #endif
  8176. #endif
  8177. vec4 diffuseColor = vec4( diffuse, alpha );
  8178. #include <logdepthbuf_fragment>
  8179. #include <color_fragment>
  8180. gl_FragColor = vec4( diffuseColor.rgb, alpha );
  8181. #include <tonemapping_fragment>
  8182. #include <colorspace_fragment>
  8183. #include <fog_fragment>
  8184. #include <premultiplied_alpha_fragment>
  8185. }
  8186. `};class mte extends nh{constructor(e){super({type:"LineMaterial",uniforms:xL.clone(gs.line.uniforms),vertexShader:gs.line.vertexShader,fragmentShader:gs.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 d9=new ko,T1=new Be;class pte extends y6e{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 pi([-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 pi([-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 jR(n,6,1);return this.setAttribute("instanceStart",new jd(r,3,0)),this.setAttribute("instanceEnd",new jd(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 jR(n,6,1);return this.setAttribute("instanceColorStart",new jd(r,3,0)),this.setAttribute("instanceColorEnd",new jd(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 h6e(e.geometry)),this}fromLineSegments(e){const n=e.geometry;return this.setPositions(n.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ko);const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;e!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(e),d9.setFromBufferAttribute(n),this.boundingBox.union(d9))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Xl),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++)T1.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(T1)),T1.fromBufferAttribute(n,a),i=Math.max(i,r.distanceToSquared(T1));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 h9=new Be,f9=new Be,ha=new xr,fa=new xr,Cl=new xr,uj=new Be,dj=new Tr,ma=new v6e,m9=new Be,C1=new ko,k1=new Xl,kl=new xr;let jl,rf;function p9(t,e,n){return kl.set(0,0,-e,1).applyMatrix4(t.projectionMatrix),kl.multiplyScalar(1/kl.w),kl.x=rf/n.width,kl.y=rf/n.height,kl.applyMatrix4(t.projectionMatrixInverse),kl.multiplyScalar(1/kl.w),Math.abs(Math.max(kl.x,kl.y))}class L6e extends tl{constructor(e=new pte,n=new mte({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)h9.fromBufferAttribute(n,o),f9.fromBufferAttribute(r,o),i[l]=l===0?0:i[l-1],i[l+1]=i[l]+h9.distanceTo(f9);const a=new jR(i,2,1);return e.setAttribute("instanceDistanceStart",new jd(a,1,0)),e.setAttribute("instanceDistanceEnd",new jd(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;jl=e.ray;const o=this.matrixWorld,l=this.geometry,c=this.material;let u,d;rf=c.linewidth+a,l.boundingSphere===null&&l.computeBoundingSphere(),k1.copy(l.boundingSphere).applyMatrix4(o),r?u=.5*rf:u=p9(i,Math.max(i.near,k1.distanceToPoint(jl.origin)),c.resolution),k1.radius+=u,jl.intersectsSphere(k1)!==!1&&(l.boundingBox===null&&l.computeBoundingBox(),C1.copy(l.boundingBox).applyMatrix4(o),r?d=.5*rf:d=p9(i,Math.max(i.near,C1.distanceToPoint(jl.origin)),c.resolution),C1.expandByScalar(d),jl.intersectsBox(C1)!==!1&&(r?(function(f,m){const p=f.matrixWorld,b=f.geometry,v=b.attributes.instanceStart,x=b.attributes.instanceEnd;for(let y=0,S=Math.min(b.instanceCount,v.count);y<S;y++){ma.start.fromBufferAttribute(v,y),ma.end.fromBufferAttribute(x,y),ma.applyMatrix4(p);const M=new Be,N=new Be;jl.distanceSqToSegment(ma.start,ma.end,N,M),N.distanceTo(M)<.5*rf&&m.push({point:N,pointOnLine:M,distance:jl.origin.distanceTo(N),object:f,face:null,faceIndex:y,uv:null,uv1:null})}})(this,n):(function(f,m,p){const b=m.projectionMatrix,v=f.material.resolution,x=f.matrixWorld,y=f.geometry,S=y.attributes.instanceStart,M=y.attributes.instanceEnd,N=Math.min(y.instanceCount,S.count),A=-m.near;jl.at(1,Cl),Cl.w=1,Cl.applyMatrix4(m.matrixWorldInverse),Cl.applyMatrix4(b),Cl.multiplyScalar(1/Cl.w),Cl.x*=v.x/2,Cl.y*=v.y/2,Cl.z=0,uj.copy(Cl),dj.multiplyMatrices(m.matrixWorldInverse,x);for(let k=0,C=N;k<C;k++){if(ha.fromBufferAttribute(S,k),fa.fromBufferAttribute(M,k),ha.w=1,fa.w=1,ha.applyMatrix4(dj),fa.applyMatrix4(dj),ha.z>A&&fa.z>A)continue;if(ha.z>A){const L=ha.z-fa.z,q=(ha.z-A)/L;ha.lerp(fa,q)}else if(fa.z>A){const L=fa.z-ha.z,q=(fa.z-A)/L;fa.lerp(ha,q)}ha.applyMatrix4(b),fa.applyMatrix4(b),ha.multiplyScalar(1/ha.w),fa.multiplyScalar(1/fa.w),ha.x*=v.x/2,ha.y*=v.y/2,fa.x*=v.x/2,fa.y*=v.y/2,ma.start.copy(ha),ma.start.z=0,ma.end.copy(fa),ma.end.z=0;const D=ma.closestPointToPointParameter(uj,!0);ma.at(D,m9);const T=qee.lerp(ha.z,fa.z,D),R=T>=-1&&T<=1,U=uj.distanceTo(m9)<.5*rf;if(R&&U){ma.start.fromBufferAttribute(S,k),ma.end.fromBufferAttribute(M,k),ma.start.applyMatrix4(x),ma.end.applyMatrix4(x);const L=new Be,q=new Be;jl.distanceSqToSegment(ma.start,ma.end,q,L),p.push({point:q,pointOnLine:L,distance:jl.origin.distanceTo(q),object:f,face:null,faceIndex:k,uv:null,uv1:null})}}})(this,i,n)))}}class I6e extends xN{constructor(e,n,r,i,a=4473924,o=8947848){a=new rn(a),o=new rn(o);const l=Math.round(e/n);r=Math.round(r/i)*i/2;const c=[],u=[];let d=0;for(let m=-1*(e=l*n/2);m<=e;m+=n){c.push(m,0,-1*r,m,0,r);const p=m===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 m=-1*r;m<=r;m+=i){c.push(-1*e,0,m,e,0,m);const p=m===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 Ha;f.setAttribute("position",new pi(c,3)),f.setAttribute("color",new pi(u,3)),super(f,new Wy({vertexColors:!0,toneMapped:!1}))}}function F6e(t,e,n,r){const i=(function(o,l,c){o*=.5,l*=.5,c*=.5;const u=new Ha,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 pi(d,3)),u})(t,e,n),a=new xN(i,new m6e({color:new rn(r),dashSize:3,gapSize:1}));return a.computeLineDistances(),a}var s0=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 s0.Panel("FPS","#0ff","#002")),c=n(new s0.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var u=n(new s0.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}};s0.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,m=15*o,p=74*o,b=30*o,v=document.createElement("canvas");v.width=l,v.height=c,v.style.cssText="width:80px;height:48px";var x=v.getContext("2d");return x.font="bold "+9*o+"px Helvetica,Arial,sans-serif",x.textBaseline="top",x.fillStyle=n,x.fillRect(0,0,l,c),x.fillStyle=e,x.fillText(t,u,d),x.fillRect(f,m,p,b),x.fillStyle=n,x.globalAlpha=.9,x.fillRect(f,m,p,b),{dom:v,update:function(y,S){r=Math.min(r,y),i=Math.max(i,y),x.fillStyle=n,x.globalAlpha=1,x.fillRect(0,0,l,m),x.fillStyle=e,x.fillText(a(y)+" "+t+" ("+a(r)+"-"+a(i)+")",u,d),x.drawImage(v,f+o,m,p-o,b,f,m,p-o,b),x.fillRect(f+p-o,m,o,b),x.fillStyle=n,x.globalAlpha=.9,x.fillRect(f+p-o,m,o,a((1-y/S)*b))}}};var U6e=s0;class g9{constructor(e,n){this.openFolders=[],this.watchedObject=e,this.options=n,this.gui=new YS,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 YS,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 z6e extends Ha{constructor(e=[new Be],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 Be,o=new Be,l=new mn,c=[],u=[],d=[],f=[];function m(p){const[b,v,x]=(function(y){const S=e[y],M=new Be,N=new Be,A=new Be,k=new Be;M.copy(S).sub(e[y-1]||S).normalize().add((e[y+1]||S).clone().sub(S).normalize()).normalize();let C=Number.MAX_VALUE;const D=Math.abs(M.x),T=Math.abs(M.y),R=Math.abs(M.z);return D<=C&&(C=D,N.set(1,0,0)),T<=C&&(C=T,N.set(0,1,0)),R<=C&&N.set(0,0,1),k.crossVectors(M,N).normalize(),N.crossVectors(M,k),A.crossVectors(M,N),[S,N,A]})(p);for(let y=0;y<=i;y++){const S=y/i*Math.PI*2,M=Math.sin(S),N=-Math.cos(S);o.x=N*v.x+M*x.x,o.y=N*v.y+M*x.y,o.z=N*v.z+M*x.z,o.normalize(),u.push(o.x,o.y,o.z),a.x=b.x+n*o.x*.5,a.y=b.y+n*o.y*.5,a.z=b.z+r*o.z*.5,c.push(a.x,a.y,a.z)}}(function(){for(let p=0;p<e.length;p++)m(p);m(closed===!1?e.length-1:0),(function(){for(let p=0;p<e.length;p++)for(let b=0;b<=i;b++)l.x=p/e.length,l.y=b/i,d.push(l.x,l.y)})(),(function(){for(let p=1;p<e.length;p++)for(let b=1;b<=i;b++){const v=(i+1)*(p-1)+(b-1),x=(i+1)*p+(b-1),y=(i+1)*p+b,S=(i+1)*(p-1)+b;f.push(v,x,S),f.push(x,y,S)}})()})(),this.setIndex(f),this.setAttribute("position",new pi(c,3)),this.setAttribute("normal",new pi(u,3)),this.setAttribute("uv",new pi(d,2))}}class o0{static get initial(){const e=new o0;return Object.assign(e,{x:0,y:0,z:0,r:0,e:0,i:0,j:0,t:0}),e}}const hj={h:0,s:0,l:0};class lg{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=o0.initial,this.beyondFirstMove=!1,this.disposables=[],this._extrusionColor=lg.defaultExtrusionColor,this.renderLayerIndex=0,this._geometries={},this._backgroundColor=new rn(14737632),this._travelColor=new rn(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 ZS(this.minLayerThreshold),this.scene=new n6e,this.scene.background=this._backgroundColor,e.backgroundColor!==void 0&&(this.backgroundColor=new rn(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 U6e:void 0,e.extrusionColor!==void 0&&(this.extrusionColor=e.extrusionColor),e.travelColor!==void 0&&(this.travelColor=new rn(e.travelColor)),e.topLayerColor!==void 0&&(this.topLayerColor=new rn(e.topLayerColor)),e.lastSegmentColor!==void 0&&(this.lastSegmentColor=new rn(e.lastSegmentColor)),e.toolColors){this._toolColors={};for(const[p,b]of Object.entries(e.toolColors))this._toolColors[parseInt(p)]=new rn(b)}if(e.disableGradient!==void 0&&(this.disableGradient=e.disableGradient),console.info("Using THREE r"+hN),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 kR({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 kR({preserveDrawingBuffer:!0}),this.canvas=this.renderer.domElement,p.appendChild(this.canvas)}this.camera=new zs(25,this.canvas.offsetWidth/this.canvas.offsetHeight,10,5e3),this.camera.position.fromArray(this.initialCameraPosition);const f=this.camera.far,m=.8*f;this.scene.fog=new vL(this._backgroundColor,m,f),this.resize(),this.controls=new O6e(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 rn(r)}else this._extrusionColor=new rn(e)}get currentToolColor(){var e;return this._extrusionColor===void 0?lg.defaultExtrusionColor:this._extrusionColor instanceof rn?this._extrusionColor:(e=this._extrusionColor[this.state.t])!==null&&e!==void 0?e:lg.defaultExtrusionColor}get backgroundColor(){return this._backgroundColor}set backgroundColor(e){this._backgroundColor=new rn(e),this.scene.background=this._backgroundColor}get travelColor(){return this._travelColor}set travelColor(e){this._travelColor=new rn(e)}get topLayerColor(){return this._topLayerColor}set topLayerColor(e){this._topLayerColor=e!==void 0?new rn(e):void 0}get lastSegmentColor(){return this._lastSegmentColor}set lastSegmentColor(e){this._lastSegmentColor=e!==void 0?new rn(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 _6e(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 b6e(13421772,.3*Math.PI),n=new x6e(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 Gb;return n.name=e,n.quaternion.setFromEuler(new Vy(-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=o0.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 lj(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 m of d.commands)if(m.gcode!="g20"){if(m.gcode.startsWith("t")){this.doRenderExtrusion(f,e),f.extrusion=[];const p=m;this.state.t=p.toolIndex}else if(["g0","g00","g1","g01","g2","g02","g3","g03"].indexOf(m.gcode)>-1){const p=m,b={x:(n=p.params.x)!==null&&n!==void 0?n:this.state.x,y:(r=p.params.y)!==null&&r!==void 0?r:this.state.y,z:(i=p.params.z)!==null&&i!==void 0?i:this.state.z,r:(a=p.params.r)!==null&&a!==void 0?a:this.state.r,e:(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 v=((u=p.params.e)!==null&&u!==void 0?u:0)>0||this.nonTravelmoves.indexOf(m.gcode)>-1;(b.x!=this.state.x||b.y!=this.state.y||b.z!=this.state.z)&&(v&&this.renderExtrusion||!v&&this.renderTravel)&&(m.gcode=="g2"||m.gcode=="g3"||m.gcode=="g02"||m.gcode=="g03"?this.addArcSegment(f,this.state,b,v,m.gcode=="g2"||m.gcode=="g02"):this.addLineSegment(f,this.state,b,v))}this.state.x=b.x,this.state.y=b.y,this.state.z=b.z,this.beyondFirstMove||(this.beyondFirstMove=!0)}}else this.setInches();this.doRenderExtrusion(f,e)}doRenderExtrusion(e,n){var r,i;if(this.renderExtrusion){let a=this.currentToolColor;if(!this.singleLayerMode&&!this.renderTubes&&!this.disableGradient){const o=.1+.7*n/this.layers.length;a.getHSL(hj),a=new rn().setHSL(hj.h,hj.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 I6e(this.buildVolume.x,10,this.buildVolume.y,10));const e=F6e(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 ZS(this.minLayerThreshold)}resetState(){var e;this.startLayer=1,this.endLayer=1/0,this.singleLayerMode=!1,this.beyondFirstMove=!1,this.state=o0.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,m=r.z;let p=r.r,b=r.i,v=r.j;if(p){const W=d-l,K=f-c,V=Math.sqrt(Math.pow(W/2,2)+Math.pow(K/2,2));p=Math.max(p,V);const J=Math.pow(W,2)+Math.pow(K,2),ne=Math.pow(p,2)-J/4;let te=Math.sqrt(ne/J);(a&&p<0||!a&&p>0)&&(te=-te),b=W/2+K*te,v=K/2-W*te}const x=l==d&&c==f,y=l+b,S=c+v,M=Math.sqrt(b*b+v*v),N=Math.atan2(-v,-b),A=Math.atan2(f-S,d-y);let k;x?k=2*Math.PI:(k=a?N-A:A-N,k<0&&(k+=2*Math.PI));let C=M*k/1.8;this.inches&&(C*=25),C<1&&(C=1);let D=k/C;D*=a?-1:1;const T=[];T.push({x:l,y:c,z:u});const R=(u-m)/C;let U=l,L=c,q=u,j=N;for(let W=0;W<C-1;W++)j+=D,U=y+M*Math.cos(j),L=S+M*Math.sin(j),q+=R,T.push({x:U,y:L,z:q});T.push({x:r.x,y:r.y,z:r.z});for(let W=0;W<T.length-1;W++)o.push(T[W].x,T[W].y,T[W].z,T[W+1].x,T[W+1].y,T[W+1].z)}addLine(e,n){var r;if(typeof this.lineWidth=="number"&&this.lineWidth>0)return void this.addThickLine(e,n);const i=new Ha;i.setAttribute("position",new pi(e,3)),this.disposables.push(i);const a=new Wy({color:n});this.disposables.push(a);const o=new xN(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 Be(l[0],l[1],l[2]),u=new Be(l[3],l[4],l[5]),d=new Be(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 z6e(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 pte;this.disposables.push(i);const a=new mte({color:n,linewidth:this.lineWidth/(1e3*window.devicePixelRatio)});this.disposables.push(a),i.setPositions(e);const o=new L6e(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=>lj(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 f6e({color:e,wireframe:this._wireframe});this.disposables.push(i);const a=r.reduce(((l,c)=>3*c.attributes.position.count+l),0),o=new u6e(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 lj(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(`
  8187. `),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 g9(this):typeof this.devMode=="object"&&(this.devGui=new g9(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())}}lg.defaultExtrusionColor=new rn("hotpink");function B6e({gcodeUrl:t,buildVolume:e={x:256,y:256,z:256},filamentColors:n,className:r=""}){const i=w.useRef(null),a=w.useRef(null),o=w.useRef(null),l=w.useRef(!1),[c,u]=w.useState(!0),[d,f]=w.useState(null),[m,p]=w.useState(!1),[b,v]=w.useState(0),[x,y]=w.useState(0),S=w.useMemo(()=>JSON.stringify(n),[n]);w.useEffect(()=>{if(!i.current||l.current)return;l.current=!0;const A=i.current,k=A.parentElement?.getBoundingClientRect();k&&(A.width=k.width,A.height=k.height);const C=n&&n.length>1,D=n?.[0]||"#00ae42",T=new lg({canvas:A,buildVolume:e,backgroundColor:1710618,extrusionColor:C?n:D,disableGradient:!0,lineHeight:.2,lineWidth:2,renderTravel:!1,renderExtrusion:!0});a.current=T,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 L=new Set,q=/^(\s*)T(\d+)(\s*;.*)?$/gim;let j;for(;(j=q.exec(U))!==null;){const te=parseInt(j[2],10);te<=15&&L.add(te)}const W=new Map,K=Array.from(L).sort((te,z)=>te-z);K.forEach((te,z)=>{W.set(te,z%8)});const V=[];K.forEach((te,z)=>{const H=n?.[te]||"#00ae42";V[z%8]=H});const J=U.split(`
  8188. `).map(te=>{const z=te.match(/^(\s*)T(\d+)(\s*;.*)?$/i);if(z){const H=parseInt(z[2],10);if(H>15)return`; FILTERED: ${te.trim()}`;const Z=W.get(H)??0;return`${z[1]}T${Z}${z[3]||""}`}return te}).join(`
  8189. `);V.length>0&&(T.extrusionColor=V),T.processGCode(J);const ne=T.layers?.length||0;y(ne),v(ne),T.render(),u(!1)}).catch(U=>{U.message!=="not_sliced"&&f(U.message),u(!1)});const R=()=>{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",R),()=>{window.removeEventListener("resize",R),o.current&&cancelAnimationFrame(o.current),a.current&&(a.current.dispose(),a.current=null),l.current=!1}},[t,S]);const M=w.useCallback(A=>{if(!a.current)return;const k=Math.max(1,Math.min(A,x));v(k),o.current&&cancelAnimationFrame(o.current),o.current=requestAnimationFrame(()=>{a.current&&(a.current.endLayer=k,a.current.render())})},[x]),N=A=>{M(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(mt,{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..."})]})}),m&&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(Gde,{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&&!m&&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&&!m&&x>0&&s.jsx("div",{className:"mt-4 px-2",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(sl,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("button",{onClick:()=>M(b-1),disabled:b<=1,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:s.jsx(If,{className:"w-4 h-4"})}),s.jsx("input",{type:"range",min:1,max:x,value:b,onChange:N,className:"flex-1 h-2 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer accent-bambu-green"}),s.jsx("button",{onClick:()=>M(b+1),disabled:b>=x,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:s.jsx(Zs,{className:"w-4 h-4"})}),s.jsxs("span",{className:"text-sm text-bambu-gray min-w-[80px] text-right",children:[b," / ",x]})]})})]})}function gte({archiveId:t,title:e,onClose:n}){const[r,i]=w.useState(null),[a,o]=w.useState(null),[l,c]=w.useState(!0);w.useEffect(()=>{const d=f=>{f.key==="Escape"&&n()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n]),w.useEffect(()=>{me.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}${me.getArchiveForSlicer(t,d)}`;Kc(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(Me,{variant:"secondary",size:"sm",onClick:u,children:[s.jsx(Gr,{className:"w-4 h-4"}),"Open in Slicer"]}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:n,children:s.jsx(Gt,{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(Bs,{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(yde,{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(mt,{className:"w-8 h-8 animate-spin text-bambu-green"})}):r==="3d"&&a?s.jsx(FIe,{url:a.has_source?me.getSource3mfDownloadUrl(t):me.getArchiveDownload(t),buildVolume:a.build_volume,filamentColors:a.filament_colors,className:"w-full h-full"}):r==="gcode"&&a?s.jsx(B6e,{gcodeUrl:me.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 x9={"000000":"Black","001489":"Blue","002e96":"Blue","0047bb":"Blue","00482b":"Pine Green","004ea8":"Blue","0056b8":"Cobalt Blue","0069b1":"Lake Blue","0072ce":"Blue","0078bf":"Marine Blue","0085ad":"Light Blue","0086d6":"Cyan","008bda":"Blue","009639":"Green","009bd8":"Cyan","009fa1":"Teal","00a6a0":"Green","00ae42":"Bambu Green","00b1b7":"Turquoise","00bb31":"Green","018814":"Candy Green","042f56":"Dark Blue","0a2989":"Blue","0a2ca5":"Blue","0c2340":"Navy Blue","0c3b95":"Blue",101820:"Black","147bd1":"Blue","164b35":"Green","16b08e":"Malachite Green","1d7c6a":"Oxide Green Metallic","1f79e5":"Lake Blue","2140b4":"Blue","25282a":"Black","2842ad":"Royal Blue","2d2b28":"Onyx Black Sparkle",324585:"Indigo Blue",353533:"Gray","39541a":"Forest Green","39699e":"Cobalt Blue Metallic","3b665e":"Green","3f5443":"Alpine Green Sparkle","3f8e43":"Mistletoe Green",424379:"Nebulae","43403d":"Iron Gray Metallic",482960:"Indigo Purple","483d8b":"Royal Purple Sparkle","489fdf":"Azure","4c241c":"Rosewood","4ce4a0":"Green","4d3324":"Dark Chocolate","4d5054":"Lava Gray","4dafda":"Cyan","4f3f24":"Black Walnut",515151:"Dark Gray","515a6c":"Gray",545454:"Dark Gray",565656:"Titan Gray","56b7e6":"Sky Blue",583061:"Violet Purple","5898dd":"Blue",594177:"Purple","5b492f":"Brown","5b6579":"Blue Gray","5c9748":"Matcha Green","5e43b7":"Purple","5e4b3c":"Copper","5f6367":"Titan Gray","61b0ff":"Translucent Light Blue","61bf36":"Green","61c680":"Grass Green","6667ab":"Lavender Blue","684a43":"Brown",686865:"Black","68724d":"Dark Green",688197:"Blue Gray","69398e":"Iris Purple","6e88bc":"Jeans Blue","6ee53c":"Lime Green","6f5034":"Cocoa Brown","7248bd":"Lavender","748c45":"Translucent Olive",757575:"Nardo Gray","75aed8":"Blue","77edd7":"Translucent Teal","789d4a":"Olive","792b36":"Crimson Red Sparkle","7ac0e9":"Glow Blue","7ae1bf":"Mint","7cd82b":"Lime Green","7d6556":"Dark Brown","8344b0":"Purple","847d48":"Bronze","854ce4":"Purple","8671cb":"Purple",875718:"Peanut Brown","87909a":"Silver","898d8d":"Gray","8a949e":"Gray","8e8e8e":"Translucent Gray","8e9089":"Gray","90ff1a":"Neon Green",918669:"Classic Birch",939393:"Gray",950051:"Plum","951e23":"Burgundy Red",959698:"Silver","96d8af":"Light Jade","96dcb9":"Mint","995f11":"Clay Brown","999d9d":"Gray","9b9ea0":"Ash Gray","9d2235":"Maroon Red","9d432c":"Brown","9e007e":"Purple","9ea2a2":"Gray","9f332a":"Brick Red",a1ffac:"Glow Green",a3d8e1:"Ice Blue",a6a9aa:"Silver",a8a8aa:"Gray",a8c6ee:"Baby Blue",aa6443:"Copper Brown Metallic",ad4e38:"Red Granite",adb1b2:"Gray",ae835b:"Caramel",ae96d4:"Lilac Purple",af1685:"Purple",afb1ae:"Gray",b15533:"Terracotta",b28b33:"Gold",b39b84:"Iridium Gold Metallic",b50011:"Red",b8acd6:"Lavender",b8cde9:"Ice Blue",ba9594:"Rose Gold",bb3d43:"Dark Red",bc0900:"Red",becf00:"Bright Green",c0df16:"Green",c12e1f:"Red",c2e189:"Apple Green",c3e2d6:"Light Cyan",c5ed48:"Lime",c6001a:"Red",c6c6c6:"Gray",c8102e:"Red",c8c8c8:"Silver",c98935:"Ochre Yellow",c9a381:"Translucent Brown",cbc6b8:"Bone White",cdceca:"Gray",cea629:"Classic Gold Sparkle",d02727:"Candy Red",d1d3d5:"Light Gray",d32941:"Red",d3b7a7:"Latte Brown",d6001c:"Red",d6abff:"Translucent Purple",d6cca3:"White Oak",dc3a27:"Orange",dd3c22:"Vermilion Red",de4343:"Scarlet Red",dfd1a7:"Beige",e02928:"Red",e4bd68:"Gold",e5b03d:"Gold",e83100:"Red",e8afcf:"Sakura Pink",e8dbb7:"Desert Tan",eaeae4:"White",eaeceb:"Silver",ec008c:"Magenta",ed0000:"Red",eeb1c1:"Pink",efe255:"Yellow",f0f1a8:"Clear",f17b8f:"Glow Pink",f3cfb2:"Champagne",f3e600:"Yellow",f48438:"Orange",f4a925:"Gold",f4d53f:"Yellow",f4ee2a:"Yellow",f5547c:"Hot Pink",f55a74:"Pink",f5b6cd:"Cherry Pink",f5dbab:"Mellow Yellow",f5f1dd:"White",f68b1b:"Neon Orange",f74e02:"Orange",f75403:"Orange",f7ada6:"Pink",f7d959:"Lemon Yellow",f7e6de:"Beige",f7f3f0:"White Marble",f8ff80:"Glow Yellow",f99963:"Mandarin Orange",f9c1bd:"Translucent Pink",f9dfb9:"Cream",f9ef41:"Yellow",f9f7f2:"Nature",f9f7f4:"White",fce300:"Yellow",fce900:"Yellow",fec600:"Sunflower Yellow",fedb00:"Yellow",ff4800:"Orange",ff671f:"Orange",ff6a13:"Orange",ff7f41:"Orange",ff9016:"Pumpkin Orange",ff911a:"Translucent Orange",ff9d5b:"Glow Orange",ffb549:"Sunflower Yellow",ffc72c:"Tangerine Yellow",ffce00:"Yellow",ffd00b:"Yellow",ffe133:"Yellow",fffaf2:"White",ffffff:"White"};function $6e(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,m=r/255,p=i/255;a===f?c=((m-p)/d+(m<p?6:0))/6:a===m?c=((p-f)/d+2)/6:c=((f-m)/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 Og(t){const e=t.replace("#","").toLowerCase().substring(0,6);return x9[e]?x9[e]:$6e(t)}function QS(t){return t?`#${t.replace("#","").substring(0,6)}`:"#808080"}function ta(t){return t?t.replace("#","").toLowerCase().substring(0,6):""}function rh(t,e,n=40){const r=ta(t),i=ta(e);if(!r||!i||r.length<6||i.length<6)return!1;const a=parseInt(r.substring(0,2),16),o=parseInt(r.substring(2,4),16),l=parseInt(r.substring(4,6),16),c=parseInt(i.substring(0,2),16),u=parseInt(i.substring(2,4),16),d=parseInt(i.substring(4,6),16);return Math.abs(a-c)<=n&&Math.abs(o-u)<=n&&Math.abs(l-d)<=n}function xte(t,e,n,r){const i=String.fromCharCode(65+(t>=128?t-128:t));return n?`HT-${i}`:`AMS-${i} Slot ${e+1}`}function bte(t,e,n){return t*4+e}function H6e(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 V6e(){const t=new Date;return t.setMinutes(t.getMinutes()+1),t.toISOString().slice(0,16)}function b9(t){if(!t)return!1;const e=Date.now()+4320*60*60*1e3;return new Date(t).getTime()>e}function SL(t){const e=[];if(t?.ams?.forEach(n=>{const r=n.tray.length===1;n.tray.forEach(i=>{if(i.tray_type){const a=QS(i.tray_color);e.push({type:i.tray_type,color:a,colorName:Og(a),amsId:n.id,trayId:i.id,isHt:r,isExternal:!1,label:xte(n.id,i.id,r),globalTrayId:bte(n.id,i.id)})}})}),t?.vt_tray?.tray_type){const n=QS(t.vt_tray.tray_color);e.push({type:t.vt_tray.tray_type,color:n,colorName:Og(n),amsId:-1,trayId:0,isHt:!1,isExternal:!0,label:"External",globalTrayId:254})}return e}function y9(t,e){if(!t?.filaments||t.filaments.length===0)return;const n=SL(e);if(n.length===0)return;const r=new Set,i=t.filaments.map(l=>{const c=n.find(m=>!r.has(m.globalTrayId)&&m.type?.toUpperCase()===l.type?.toUpperCase()&&ta(m.color)===ta(l.color)),u=!c&&n.find(m=>!r.has(m.globalTrayId)&&m.type?.toUpperCase()===l.type?.toUpperCase()&&rh(m.color,l.color)),d=!c&&!u&&n.find(m=>!r.has(m.globalTrayId)&&m.type?.toUpperCase()===l.type?.toUpperCase()),f=c||u||d||void 0;return f&&r.add(f.globalTrayId),{slot_id:l.slot_id,globalTrayId:f?.globalTrayId??-1}}),a=Math.max(...i.map(l=>l.slot_id||0));if(a<=0)return;const o=new Array(a).fill(-1);return i.forEach(l=>{l.slot_id&&l.slot_id>0&&(o[l.slot_id-1]=l.globalTrayId)}),o}function G6e(t){return w.useMemo(()=>{const e=[];if(t?.ams?.forEach(n=>{const r=n.tray.length===1;n.tray.forEach(i=>{if(i.tray_type){const a=QS(i.tray_color);e.push({type:i.tray_type,color:a,colorName:Og(a),amsId:n.id,trayId:i.id,isHt:r,isExternal:!1,label:xte(n.id,i.id,r),globalTrayId:bte(n.id,i.id)})}})}),t?.vt_tray?.tray_type){const n=QS(t.vt_tray.tray_color);e.push({type:t.vt_tray.tray_type,color:n,colorName:Og(n),amsId:-1,trayId:0,isHt:!1,isExternal:!0,label:"External",globalTrayId:254})}return e},[t])}function yte(t,e,n){const r=G6e(e),i=w.useMemo(()=>{if(!t?.filaments||t.filaments.length===0)return[];const c=new Set(Object.values(n));return t.filaments.map(u=>{const d=u.slot_id||0;if(d>0&&n[d]!==void 0){const M=n[d],N=r.find(A=>A.globalTrayId===M);if(N){const A=N.type?.toUpperCase()===u.type?.toUpperCase(),k=ta(N.color)===ta(u.color)||rh(N.color,u.color);let C;return A&&k?C="match":A?C="type_only":C="mismatch",{...u,loaded:N,hasFilament:!0,typeMatch:A,colorMatch:k,status:C,isManual:!0}}}const f=r.find(M=>!c.has(M.globalTrayId)&&M.type?.toUpperCase()===u.type?.toUpperCase()&&ta(M.color)===ta(u.color)),m=!f&&r.find(M=>!c.has(M.globalTrayId)&&M.type?.toUpperCase()===u.type?.toUpperCase()&&rh(M.color,u.color)),p=!f&&!m&&r.find(M=>!c.has(M.globalTrayId)&&M.type?.toUpperCase()===u.type?.toUpperCase()),b=f||m||p||void 0;b&&c.add(b.globalTrayId);const v=!!b,x=v,y=!!f||!!m;let S;return f||m?S="match":p?S="type_only":S="mismatch",{...u,loaded:b,hasFilament:v,typeMatch:x,colorMatch:y,status:S,isManual:!1}})},[t,r,n]),a=w.useMemo(()=>{if(i.length===0)return;const c=Math.max(...i.map(d=>d.slot_id||0));if(c<=0)return;const u=new Array(c).fill(-1);return i.forEach(d=>{d.slot_id&&d.slot_id>0&&(u[d.slot_id-1]=d.loaded?.globalTrayId??-1)}),u},[i]),o=i.some(c=>c.status==="mismatch"),l=i.some(c=>c.status==="type_only");return{loadedFilaments:r,filamentComparison:i,amsMapping:a,hasTypeMismatch:o,hasColorMismatch:l}}function W6e(t,e,n){if(!t||t.length===0)return{exactMatches:0,typeOnlyMatches:0,missingTypes:0,totalSlots:0,status:"full"};let r=0,i=0,a=0;const o=new Set(Object.values(n));for(const u of t){const d=u.slot_id||0;if(d>0&&n[d]!==void 0){const v=n[d],x=e.find(y=>y.globalTrayId===v);if(x){const y=x.type?.toUpperCase()===u.type?.toUpperCase(),S=ta(x.color)===ta(u.color)||rh(x.color,u.color);y&&S?r++:y?i++:a++;continue}}const f=e.find(v=>!o.has(v.globalTrayId)&&v.type?.toUpperCase()===u.type?.toUpperCase()&&ta(v.color)===ta(u.color)),m=f?void 0:e.find(v=>!o.has(v.globalTrayId)&&v.type?.toUpperCase()===u.type?.toUpperCase()&&rh(v.color,u.color)),p=f||m?void 0:e.find(v=>!o.has(v.globalTrayId)&&v.type?.toUpperCase()===u.type?.toUpperCase()),b=f??m??p;b&&o.add(b.globalTrayId),f||m?r++:p?i++:a++}const l=t.length;let c="full";return a>0?c="missing":i>0&&(c="partial"),{exactMatches:r,typeOnlyMatches:i,missingTypes:a,totalSlots:l,status:c}}function q6e(t,e,n){if(!t?.filaments||t.filaments.length===0)return;const r=SL(e);if(r.length===0)return;const i=new Set(Object.values(n)),a=[];for(const c of t.filaments){const u=c.slot_id||0;if(u>0&&n[u]!==void 0){a.push({slot_id:u,globalTrayId:n[u]});continue}const d=r.find(b=>!i.has(b.globalTrayId)&&b.type?.toUpperCase()===c.type?.toUpperCase()&&ta(b.color)===ta(c.color)),f=d?void 0:r.find(b=>!i.has(b.globalTrayId)&&b.type?.toUpperCase()===c.type?.toUpperCase()&&rh(b.color,c.color)),m=d||f?void 0:r.find(b=>!i.has(b.globalTrayId)&&b.type?.toUpperCase()===c.type?.toUpperCase()),p=d??f??m;p&&i.add(p.globalTrayId),a.push({slot_id:u,globalTrayId:p?.globalTrayId??-1})}const o=Math.max(...a.map(c=>c.slot_id||0));if(o<=0)return;const l=new Array(o).fill(-1);return a.forEach(c=>{c.slot_id&&c.slot_id>0&&(l[c.slot_id-1]=c.globalTrayId)}),l}const v9={useDefault:!0,manualMappings:{},autoConfigured:!1};function K6e(t,e,n,r,i,a){const o=gue({queries:t.map(b=>({queryKey:["printer-status",b],queryFn:()=>me.getPrinterStatus(b),enabled:t.length>0,staleTime:5e3}))}),l=w.useMemo(()=>t.map((b,v)=>{const x=o[v],y=x?.data,M=e?.find(R=>R.id===b)?.name||`Printer ${b}`,N=SL(y),A=i[b]||v9,k=y9(n,y),C=A.useDefault?r:A.manualMappings,D=q6e(n,y,C),T=W6e(n?.filaments,N,C);return{printerId:b,printerName:M,status:y,isLoading:x?.isLoading??!1,loadedFilaments:N,autoMapping:k,finalMapping:D,matchStatus:T.status,exactMatches:T.exactMatches,typeOnlyMatches:T.typeOnlyMatches,missingTypes:T.missingTypes,totalSlots:T.totalSlots,config:A}}),[t,o,e,n,i,r]),c=o.some(b=>b.isLoading),u=(b,v)=>{a(x=>({...x,[b]:{...x[b]||v9,...v}}))},d=b=>{const v=l.find(S=>S.printerId===b);if(!v||!v.status||!n?.filaments)return;const x=y9(n,v.status);if(!x)return;const y={};x.forEach((S,M)=>{S!==-1&&(y[M+1]=S)}),u(b,{useDefault:!1,manualMappings:y,autoConfigured:!0})},f=()=>{for(const b of t)d(b)},m=b=>l.find(x=>x.printerId===b)?.finalMapping,p=l.every(b=>b.matchStatus!=="missing");return{printerResults:l,isLoading:c,perPrinterConfigs:i,updatePrinterConfig:u,autoConfigureAll:f,autoConfigurePrinter:d,getFinalMapping:m,allPrintersReady:p}}function X6e({printerResult:t,filamentReqs:e,onUpdateConfig:n}){const r=ln(),[i,a]=w.useState(!1),o=(u,d)=>{if(u<=0)return;const f={...t.config.manualMappings};d===""?delete f[u]:f[u]=parseInt(d,10),n({useDefault:!1,manualMappings:f,autoConfigured:!1})},l=async()=>{a(!0);try{await me.refreshPrinterStatus(t.printerId),await new Promise(u=>setTimeout(u,500)),await r.refetchQueries({queryKey:["printer-status",t.printerId]})}finally{a(!1)}},c=e.map(u=>{const d=u.slot_id||0,f=t.config.manualMappings[d];let m,p=!1;if(f!==void 0)m=t.loadedFilaments.find(v=>v.globalTrayId===f),p=!0;else{const v=new Set(Object.values(t.config.manualMappings)),x=t.loadedFilaments.find(M=>!v.has(M.globalTrayId)&&M.type?.toUpperCase()===u.type?.toUpperCase()&&ta(M.color)===ta(u.color)),y=x?void 0:t.loadedFilaments.find(M=>!v.has(M.globalTrayId)&&M.type?.toUpperCase()===u.type?.toUpperCase()&&rh(M.color,u.color)),S=x||y?void 0:t.loadedFilaments.find(M=>!v.has(M.globalTrayId)&&M.type?.toUpperCase()===u.type?.toUpperCase());m=x??y??S}let b="mismatch";if(m){const v=m.type?.toUpperCase()===u.type?.toUpperCase(),x=ta(m.color)===ta(u.color)||rh(m.color,u.color);v&&x?b="match":v&&(b="type_only")}return{req:u,loaded:m,status:b,isManual:p}});return 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:"Custom slot mapping"}),s.jsxs("button",{type:"button",onClick:l,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:i,children:[s.jsx(Ar,{className:`w-3 h-3 ${i?"animate-spin":""}`}),s.jsx("span",{children:"Re-read"})]})]}),c.map(({req:u,loaded:d,status:f,isManual:m},p)=>s.jsxs("div",{className:"grid items-center gap-2 text-xs",style:{gridTemplateColumns:"16px minmax(70px, 1fr) auto 2fr 16px"},children:[s.jsx("span",{title:`Required: ${u.type} - ${Og(u.color)}`,children:s.jsx(fP,{className:"w-3 h-3",fill:u.color,stroke:u.color})}),s.jsxs("span",{className:"text-white truncate",children:[u.type," ",s.jsxs("span",{className:"text-bambu-gray",children:["(",u.used_grams,"g)"]})]}),s.jsx("span",{className:"text-bambu-gray",children:"→"}),s.jsxs("select",{value:d?.globalTrayId??"",onChange:b=>o(u.slot_id||0,b.target.value),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 ${f==="match"?"border-bambu-green/50 text-bambu-green":f==="type_only"?"border-yellow-400/50 text-yellow-400":"border-orange-400/50 text-orange-400"} ${m?"ring-1 ring-blue-400/50":""}`,title:m?"Manually selected":"Auto-matched",children:[s.jsx("option",{value:"",className:"bg-bambu-dark text-bambu-gray",children:"-- Select slot --"}),t.loadedFilaments.map(b=>s.jsxs("option",{value:b.globalTrayId,className:"bg-bambu-dark text-white",children:[b.label,": ",b.type," (",b.colorName,")"]},b.globalTrayId))]}),f==="match"?s.jsx(Es,{className:"w-3 h-3 text-bambu-green"}):f==="type_only"?s.jsx("span",{title:"Same type, different color",children:s.jsx(Tn,{className:"w-3 h-3 text-yellow-400"})}):s.jsx("span",{title:"Filament type not loaded",children:s.jsx(Tn,{className:"w-3 h-3 text-orange-400"})})]},p))]})}function Y6e({printers:t,selectedPrinterIds:e,onMultiSelect:n,isLoading:r=!1,allowMultiple:i=!1,showInactive:a=!1,printerMappingResults:o,filamentReqs:l,onAutoConfigurePrinter:c,onUpdatePrinterConfig:u}){const d=a?t:t.filter(M=>M.is_active),f=i&&e.length>1&&o&&l?.filaments&&l.filaments.length>0&&c&&u;if(r)return s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(mt,{className:"w-6 h-6 text-bambu-green animate-spin"})});if(d.length===0)return s.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm mb-4",children:[s.jsx(aa,{className:"w-4 h-4"}),"No ",a?"":"active ","printers available"]});const m=M=>{i?e.includes(M)?n(e.filter(N=>N!==M)):n([...e,M]):n([M])},p=()=>{n(d.map(M=>M.id))},b=()=>{n([])},v=(M,N,A)=>{A.stopPropagation(),!(!c||!u)&&(N?c(M):u(M,{useDefault:!0,manualMappings:{},autoConfigured:!1}))},x=M=>e.includes(M),y=e.length,S=M=>o?.find(N=>N.printerId===M);return s.jsxs("div",{className:"space-y-2 mb-6",children:[i&&d.length>1&&s.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray mb-2",children:[s.jsx("span",{children:y===0?"Select printers":`${y} printer${y!==1?"s":""} selected`}),s.jsxs("div",{className:"flex gap-2",children:[y<d.length&&s.jsx("button",{type:"button",onClick:p,className:"text-bambu-green hover:text-bambu-green/80 transition-colors",children:"Select all"}),y>0&&s.jsx("button",{type:"button",onClick:b,className:"text-bambu-gray hover:text-white transition-colors",children:"Clear"})]})]}),d.map(M=>{const N=x(M.id),A=S(M.id),k=A&&!A.config.useDefault;return s.jsxs("div",{children:[s.jsxs("button",{type:"button",onClick:()=>m(M.id),className:`w-full flex items-center gap-3 p-3 rounded-lg border transition-colors ${N?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray"} ${M.is_active?"":"opacity-60"}`,children:[s.jsx("div",{className:`p-2 rounded-lg ${N?"bg-bambu-green/20":"bg-bambu-dark-tertiary"}`,children:s.jsx(Wr,{className:`w-5 h-5 ${N?"text-bambu-green":"text-bambu-gray"}`})}),s.jsxs("div",{className:"text-left flex-1",children:[s.jsxs("p",{className:"text-white font-medium",children:[M.name,!M.is_active&&s.jsx("span",{className:"text-bambu-gray text-xs ml-2",children:"(inactive)"})]}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[M.model||"Unknown model"," • ",M.ip_address]})]}),i&&s.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center transition-colors ${N?"bg-bambu-green border-bambu-green":"border-bambu-gray/50"}`,children:N&&s.jsx(Es,{className:"w-3 h-3 text-white"})})]}),N&&f&&A&&s.jsxs("div",{className:"ml-4 mt-2 mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",onClick:C=>C.stopPropagation(),children:[s.jsx("input",{type:"checkbox",checked:k,onChange:C=>v(M.id,C.target.checked,C),className:"w-3.5 h-3.5 rounded border-bambu-gray/30 bg-bambu-dark-secondary text-bambu-green focus:ring-bambu-green focus:ring-offset-0"}),s.jsx("span",{className:"text-xs text-bambu-gray",children:"Custom mapping"})]}),s.jsxs("span",{className:`text-xs ml-2 ${A.matchStatus==="full"?"text-bambu-green":A.matchStatus==="partial"?"text-yellow-400":"text-orange-400"}`,children:["(",A.exactMatches,"/",A.totalSlots," matched)"]}),A.isLoading&&s.jsx(Ar,{className:"w-3 h-3 text-bambu-gray animate-spin"}),k&&s.jsxs("button",{type:"button",onClick:C=>{C.stopPropagation(),c(M.id)},className:"ml-auto 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",children:[s.jsx(Tme,{className:"w-3 h-3"}),"Auto"]})]}),k&&s.jsx(X6e,{printerResult:A,filamentReqs:l.filaments,onUpdateConfig:C=>u(M.id,C)})]})]},M.id)}),y===0&&s.jsxs("p",{className:"text-xs text-orange-400 mt-1 flex items-center gap-1",children:[s.jsx(aa,{className:"w-3 h-3"}),"Select at least one printer"]})]})}function Z6e({plates:t,isMultiPlate:e,selectedPlate:n,onSelect:r}){return!e||t.length<=1?null:s.jsxs("div",{className:"mb-4",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(sl,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("span",{className:"text-sm text-bambu-gray",children:"Select Plate to Print"}),!n&&s.jsxs("span",{className:"text-xs text-orange-400 flex items-center gap-1",children:[s.jsx(Tn,{className:"w-3 h-3"}),"Selection required"]})]}),s.jsx("div",{className:"grid grid-cols-2 gap-2",children:t.map(i=>s.jsxs("button",{type:"button",onClick:()=>r(i.index),className:`flex items-center gap-2 p-2 rounded-lg border transition-colors text-left ${n===i.index?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray"}`,children:[i.has_thumbnail&&i.thumbnail_url!=null?s.jsx("img",{src:i.thumbnail_url,alt:`Plate ${i.index}`,className:"w-10 h-10 rounded object-cover bg-bambu-dark-tertiary"}):s.jsx("div",{className:"w-10 h-10 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:s.jsx(sl,{className:"w-5 h-5 text-bambu-gray"})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-sm text-white font-medium truncate",children:i.name||`Plate ${i.index}`}),s.jsxs("p",{className:"text-xs text-bambu-gray truncate",children:[i.objects.length>0?i.objects.slice(0,3).join(", ")+(i.objects.length>3?"...":""):`${i.filaments.length} filament${i.filaments.length!==1?"s":""}`,i.print_time_seconds!=null?` • ${H6e(i.print_time_seconds)}`:""]})]}),n===i.index&&s.jsx(Es,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]},i.index))})]})}function Q6e({printerId:t,filamentReqs:e,manualMappings:n,onManualMappingChange:r,defaultExpanded:i=!1}){const a=ln(),[o,l]=w.useState(!1),[c,u]=w.useState(i),{data:d}=ft({queryKey:["printer-status",t],queryFn:()=>me.getPrinterStatus(t),enabled:!!t}),{loadedFilaments:f,filamentComparison:m,hasTypeMismatch:p,hasColorMismatch:b}=yte(e,d,n);if(!(e?.filaments&&e.filaments.length>0)||!d)return null;const x=p?"#f97316":b?"#facc15":"#00ae42",y=(M,N)=>{if(M>0)if(N===""){const A={...n};delete A[M],r(A)}else r({...n,[M]:parseInt(N,10)})},S=async()=>{l(!0);try{await me.refreshPrinterStatus(t),await new Promise(M=>setTimeout(M,500)),await a.refetchQueries({queryKey:["printer-status",t]})}finally{l(!1)}};return s.jsxs("div",{className:"mb-4",children:[s.jsxs("button",{type:"button",onClick:()=>u(!c),className:"flex items-center gap-2 text-sm text-bambu-gray hover:text-white transition-colors w-full",children:[s.jsx(fP,{className:"w-4 h-4",fill:x,stroke:"none"}),s.jsx("span",{children:"Filament Mapping"}),p?s.jsx("span",{className:"text-xs text-orange-400",children:"(Type not found)"}):b?s.jsx("span",{className:"text-xs text-yellow-400",children:"(Color mismatch)"}):s.jsx("span",{className:"text-xs text-bambu-green",children:"(Ready)"}),c?s.jsx(du,{className:"w-4 h-4 ml-auto"}):s.jsx(Oi,{className:"w-4 h-4 ml-auto"})]}),c&&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:S,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:o,children:[s.jsx(Ar,{className:`w-3 h-3 ${o?"animate-spin":""}`}),s.jsx("span",{children:"Re-read"})]})]}),m.map((M,N)=>s.jsxs("div",{className:"grid items-center gap-2 text-xs",style:{gridTemplateColumns:"16px minmax(70px, 1fr) auto 2fr 16px"},children:[s.jsx("span",{title:`Required: ${M.type} - ${Og(M.color)}`,children:s.jsx(fP,{className:"w-3 h-3",fill:M.color,stroke:M.color})}),s.jsxs("span",{className:"text-white truncate",children:[M.type," ",s.jsxs("span",{className:"text-bambu-gray",children:["(",M.used_grams,"g)"]})]}),s.jsx("span",{className:"text-bambu-gray",children:"→"}),s.jsxs("select",{value:M.loaded?.globalTrayId??"",onChange:A=>y(M.slot_id||0,A.target.value),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 ${M.status==="match"?"border-bambu-green/50 text-bambu-green":M.status==="type_only"?"border-yellow-400/50 text-yellow-400":"border-orange-400/50 text-orange-400"} ${M.isManual?"ring-1 ring-blue-400/50":""}`,title:M.isManual?"Manually selected":"Auto-matched",children:[s.jsx("option",{value:"",className:"bg-bambu-dark text-bambu-gray",children:"-- Select slot --"}),f.map(A=>s.jsxs("option",{value:A.globalTrayId,className:"bg-bambu-dark text-white",children:[A.label,": ",A.type," (",A.colorName,")"]},A.globalTrayId))]}),M.status==="match"?s.jsx(Es,{className:"w-3 h-3 text-bambu-green"}):M.status==="type_only"?s.jsx("span",{title:"Same type, different color",children:s.jsx(Tn,{className:"w-3 h-3 text-yellow-400"})}):s.jsx("span",{title:"Filament type not loaded",children:s.jsx(Tn,{className:"w-3 h-3 text-orange-400"})})]},N)),p&&s.jsx("p",{className:"text-xs text-orange-400 mt-2",children:"Required filament type not found in printer."})]})]})}const J6e=[{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"}];function e$e({options:t,onChange:e,defaultExpanded:n=!1}){const[r,i]=w.useState(n),a=o=>{e({...t,[o]:!t[o]})};return s.jsxs("div",{className:"mb-4",children:[s.jsxs("button",{type:"button",onClick:()=>i(!r),className:"flex items-center gap-2 text-sm text-bambu-gray hover:text-white transition-colors w-full",children:[s.jsx(dE,{className:"w-4 h-4"}),s.jsx("span",{children:"Print Options"}),r?s.jsx(du,{className:"w-4 h-4 ml-auto"}):s.jsx(Oi,{className:"w-4 h-4 ml-auto"})]}),r&&s.jsx("div",{className:"mt-2 bg-bambu-dark rounded-lg p-3 space-y-2",children:J6e.map(({key:o,label:l,desc:c})=>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:l}),s.jsx("p",{className:"text-xs text-bambu-gray",children:c})]}),s.jsx("div",{className:`relative w-10 h-5 rounded-full transition-colors ${t[o]?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,onClick:()=>a(o),children:s.jsx("div",{className:`absolute top-0.5 w-4 h-4 rounded-full bg-white transition-transform ${t[o]?"translate-x-5":"translate-x-0.5"}`})})]},o))})]})}function t$e({options:t,onChange:e}){const n=r=>{e({...t,scheduleType:r})};return s.jsxs("div",{className:"space-y-4",children:[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 ${t.scheduleType==="asap"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>n("asap"),children:[s.jsx(Jn,{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 ${t.scheduleType==="scheduled"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>n("scheduled"),children:[s.jsx(si,{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 ${t.scheduleType==="manual"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>n("manual"),children:[s.jsx(fK,{className:"w-4 h-4"}),"Queue Only"]})]})]}),t.scheduleType==="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:t.scheduledTime,onChange:r=>e({...t,scheduledTime:r.target.value}),min:V6e(),required:!0})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"requirePrevious",checked:t.requirePreviousSuccess,onChange:r=>e({...t,requirePreviousSuccess:r.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:t.autoOffAfter,onChange:r=>e({...t,autoOffAfter:r.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(wu,{className:"w-3.5 h-3.5"}),"Power off printer when done"]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:t.scheduleType==="asap"?"Print will start as soon as the printer is idle.":t.scheduleType==="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."})]})}const Pp={bed_levelling:!0,flow_cali:!1,vibration_cali:!0,layer_inspect:!1,timelapse:!1},n$e={scheduleType:"asap",scheduledTime:"",requirePreviousSuccess:!1,autoOffAfter:!1};function ih({mode:t,archiveId:e,libraryFileId:n,archiveName:r,queueItem:i,onClose:a,onSuccess:o}){const l=ln(),{showToast:c}=Yn(),u=!!n&&!e,[d,f]=w.useState(()=>t==="edit-queue-item"&&i?.printer_id?[i.printer_id]:[]),[m,p]=w.useState(()=>t==="edit-queue-item"&&i?i.plate_id:null),[b,v]=w.useState(()=>t==="edit-queue-item"&&i?{bed_levelling:i.bed_levelling??Pp.bed_levelling,flow_cali:i.flow_cali??Pp.flow_cali,vibration_cali:i.vibration_cali??Pp.vibration_cali,layer_inspect:i.layer_inspect??Pp.layer_inspect,timelapse:i.timelapse??Pp.timelapse}:Pp),[x,y]=w.useState(()=>{if(t==="edit-queue-item"&&i){let B="asap";i.manual_start?B="manual":i.scheduled_time&&!b9(i.scheduled_time)&&(B="scheduled");let O="";return i.scheduled_time&&!b9(i.scheduled_time)&&(O=new Date(i.scheduled_time).toISOString().slice(0,16)),{scheduleType:B,scheduledTime:O,requirePreviousSuccess:i.require_previous_success,autoOffAfter:i.auto_off_after}}return n$e}),[S,M]=w.useState(()=>{if(t==="edit-queue-item"&&i?.ams_mapping&&Array.isArray(i.ams_mapping)){const B={};return i.ams_mapping.forEach((O,Y)=>{O!==-1&&(B[Y+1]=O)}),B}return{}}),[N,A]=w.useState({}),[k]=w.useState(()=>t==="edit-queue-item"&&i?.printer_id?[i.printer_id]:[]),[C]=w.useState(()=>t==="edit-queue-item"&&i?i.plate_id:null),[D,T]=w.useState(!1),[R,U]=w.useState({current:0,total:0}),[L,q]=w.useState(new Set),j=d.length,W=d.length>0?d[0]:null,{data:K}=ft({queryKey:["settings"],queryFn:me.getSettings}),{data:V,isLoading:J}=ft({queryKey:["printers"],queryFn:me.getPrinters}),{data:ne,isError:te}=ft({queryKey:["archive-plates",e],queryFn:()=>me.getArchivePlates(e),enabled:!!e&&!u,retry:!1}),{data:z}=ft({queryKey:["library-file-plates",n],queryFn:()=>me.getLibraryFilePlates(n),enabled:u&&!!n}),H=u?z:ne,{data:Z,isError:ee}=ft({queryKey:["archive-filaments",e,m],queryFn:()=>me.getArchiveFilamentRequirements(e,m??void 0),enabled:!!e&&!u&&(m!==null||!H?.is_multi_plate),retry:!1}),{data:he}=ft({queryKey:["library-file-filaments",n,m],queryFn:()=>me.getLibraryFileFilamentRequirements(n,m??void 0),enabled:u&&!!n&&(m!==null||!H?.is_multi_plate)}),fe=!u&&(te||ee),oe=u?he:Z,{data:Ne}=ft({queryKey:["printer-status",W],queryFn:()=>me.getPrinterStatus(W),enabled:!!W}),{amsMapping:ge}=yte(oe,Ne,S),Se=K6e(d,V,oe,S,N,A);w.useEffect(()=>{H?.plates?.length===1&&!m&&p(H.plates[0].index)},[H,m]),w.useEffect(()=>{if(t==="edit-queue-item")return;const B=V?.filter(O=>O.is_active)||[];B.length===1&&d.length===0&&f([B[0].id])},[t,V,d.length]),w.useEffect(()=>{t==="edit-queue-item"?(JSON.stringify(d.sort())!==JSON.stringify(k.sort())||m!==C)&&(M({}),A({}),q(new Set)):(M({}),A({}),q(new Set))},[t,d,m,k,C]),w.useEffect(()=>{if(!K?.per_printer_mapping_expanded||d.length<=1)return;const B=d.filter(O=>{if(L.has(O))return!1;const Y=Se.printerResults.find(pe=>pe.printerId===O);return Y&&Y.status&&!Y.isLoading});B.length>0&&(q(O=>{const Y=new Set(O);return B.forEach(pe=>Y.add(pe)),Y}),B.forEach(O=>{Se.autoConfigurePrinter(O)}))},[K?.per_printer_mapping_expanded,d,L,Se]),w.useEffect(()=>{const B=O=>{O.key==="Escape"&&!D&&a()};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[a,D]);const Re=H?.is_multi_plate??!1,de=H?.plates??[],Qe=pt({mutationFn:B=>me.addToQueue(B)}),G=pt({mutationFn:B=>me.updateQueueItem(i.id,B),onSuccess:()=>{l.invalidateQueries({queryKey:["queue"]}),c("Queue item updated"),o?.(),a()},onError:B=>{c(B.message||"Failed to update queue item","error")}}),ie=async B=>{if(B?.preventDefault(),d.length===0){c("Please select at least one printer","error");return}T(!0),U({current:0,total:d.length});const O={success:0,failed:0,errors:[]},Y=we=>{if(d.length>1){const ae=N[we];if(ae&&!ae.useDefault)return Se.getFinalMapping(we)}return ge},pe=we=>({printer_id:we,archive_id:u?void 0:e,library_file_id:u?n:void 0,require_previous_success:x.requirePreviousSuccess,auto_off_after:x.autoOffAfter,manual_start:x.scheduleType==="manual",ams_mapping:Y(we),plate_id:m,scheduled_time:x.scheduleType==="scheduled"&&x.scheduledTime?new Date(x.scheduledTime).toISOString():void 0,...b});for(let we=0;we<d.length;we++){const ae=d[we];U({current:we+1,total:d.length});try{if(t==="reprint"){const ke=Y(ae);u?await me.printLibraryFile(n,ae,{ams_mapping:ke,...b}):await me.reprintArchive(e,ae,{plate_id:m??void 0,ams_mapping:ke,...b})}else if(t==="edit-queue-item"&&we===0){const ke=Y(ae),De={printer_id:ae,require_previous_success:x.requirePreviousSuccess,auto_off_after:x.autoOffAfter,manual_start:x.scheduleType==="manual",ams_mapping:ke,plate_id:m,scheduled_time:x.scheduleType==="scheduled"&&x.scheduledTime?new Date(x.scheduledTime).toISOString():null,...b};await G.mutateAsync(De)}else await Qe.mutateAsync(pe(ae));O.success++}catch(ke){O.failed++;const De=V?.find(Ke=>Ke.id===ae)?.name||`Printer ${ae}`;O.errors.push(`${De}: ${ke.message}`)}}if(T(!1),O.failed===0){const we=t==="reprint"?"sent to":t==="edit-queue-item"?"updated/queued for":"queued for";O.success===1?c(t==="edit-queue-item"?"Queue item updated":`Print ${we} printer`):c(`Print ${we} ${O.success} printers`),l.invalidateQueries({queryKey:["queue"]}),o?.(),a()}else O.success===0?c(`Failed: ${O.errors[0]}`,"error"):(c(`${O.success} succeeded, ${O.failed} failed`,"error"),l.invalidateQueries({queryKey:["queue"]}))},X=D||G.isPending,$=w.useMemo(()=>!(X||d.length===0||!u&&Re&&!m),[d.length,Re,m,X,u]),ce=(()=>{const B=d.length;return t==="reprint"?{title:u?"Print":"Re-print",icon:Wr,submitText:B>1?`Print to ${B} Printers`:"Print",submitIcon:Wr,loadingText:R.total>1?`Sending ${R.current}/${R.total}...`:"Sending..."}:t==="add-to-queue"?{title:"Schedule Print",icon:si,submitText:B>1?`Queue to ${B} Printers`:"Add to Queue",submitIcon:si,loadingText:R.total>1?`Adding ${R.current}/${R.total}...`:"Adding..."}:{title:"Edit Queue Item",icon:Na,submitText:"Save",submitIcon:Na,loadingText:R.total>1?`Saving ${R.current}/${R.total}...`:"Saving..."}})(),Ee=ce.icon,Ie=ce.submitIcon,le=W&&(u||(Re?m!==null:!0));return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:D?void 0:a,children:s.jsx(Nt,{className:"w-full max-w-lg max-h-[90vh] overflow-y-auto",onClick:B=>B.stopPropagation(),children:s.jsxs(Ct,{className:t==="reprint"?"":"p-0",children:[s.jsxs("div",{className:`flex items-center justify-between ${t==="reprint"?"mb-4":"p-4 border-b border-bambu-dark-tertiary"}`,children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ee,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:ce.title})]}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:a,disabled:D,children:s.jsx(Gt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:ie,className:t==="reprint"?"":"p-4 space-y-4",children:[s.jsx("p",{className:`text-sm text-bambu-gray ${t==="reprint"?"mb-4":""}`,children:t==="reprint"?s.jsxs(s.Fragment,{children:["Send ",s.jsx("span",{className:"text-white",children:r})," to printer(s)"]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"block text-bambu-gray mb-1",children:"Print Job"}),s.jsx("span",{className:"text-white font-medium truncate block",children:r})]})}),s.jsx(Z6e,{plates:de,isMultiPlate:Re,selectedPlate:m,onSelect:p}),s.jsx(Y6e,{printers:V||[],selectedPrinterIds:d,onMultiSelect:f,isLoading:J,allowMultiple:!0,showInactive:t==="edit-queue-item",printerMappingResults:Se.printerResults,filamentReqs:oe,onAutoConfigurePrinter:Se.autoConfigurePrinter,onUpdatePrinterConfig:Se.updatePrinterConfig}),fe&&s.jsxs("div",{className:"flex items-start gap-2 p-3 mb-2 bg-orange-500/10 border border-orange-500/30 rounded-lg text-sm",children:[s.jsx(aa,{className:"w-4 h-4 text-orange-400 mt-0.5 flex-shrink-0"}),s.jsx("p",{className:"text-orange-400",children:"Archive data unavailable. The source file may have been deleted. Filament mapping is disabled."})]}),le&&!fe&&d.length===1&&s.jsx(Q6e,{printerId:W,filamentReqs:oe,manualMappings:S,onManualMappingChange:M,defaultExpanded:K?.per_printer_mapping_expanded??!1}),(t==="reprint"||j>0)&&s.jsx(e$e,{options:b,onChange:v}),t!=="reprint"&&s.jsx(t$e,{options:x,onChange:y}),G.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:G.error?.message||"Failed to complete operation"}),s.jsxs("div",{className:`flex gap-3 ${t==="reprint"?"":"pt-2"}`,children:[s.jsx(Me,{type:"button",variant:"secondary",onClick:a,className:"flex-1",disabled:D,children:"Cancel"}),s.jsx(Me,{type:"submit",disabled:!$,className:"flex-1",children:X?s.jsxs(s.Fragment,{children:[s.jsx(mt,{className:"w-4 h-4 animate-spin"}),ce.loadingText]}):s.jsxs(s.Fragment,{children:[s.jsx(Ie,{className:"w-4 h-4"}),ce.submitText]})})]})]})]})})})}function r$e({onClose:t,initialFiles:e}){const n=ln(),{showToast:r}=Yn(),i=w.useRef(null),[a,o]=w.useState(()=>e?.filter(C=>C.name.endsWith(".3mf")).map(C=>({file:C,status:"pending"}))||[]),[l,c]=w.useState(!1),[u,d]=w.useState(),[f,m]=w.useState(null);w.useEffect(()=>{const C=D=>{D.key==="Escape"&&t()};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[t]);const{data:p}=ft({queryKey:["printers"],queryFn:me.getPrinters}),b=pt({mutationFn:C=>me.uploadArchivesBulk(C,u),onSuccess:C=>{m(C),n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["archiveStats"]}),o(D=>D.map(T=>{const R=C.results.find(L=>L.filename===T.file.name),U=C.errors.find(L=>L.filename===T.file.name);return R?{...T,status:"success",archiveId:R.id}:U?{...T,status:"error",error:U.error}:T})),C.failed===0?r(`${C.uploaded} file${C.uploaded!==1?"s":""} uploaded`):C.uploaded===0?r(`Failed to upload ${C.failed} file${C.failed!==1?"s":""}`,"error"):r(`${C.uploaded} uploaded, ${C.failed} failed`,"warning")},onError:()=>{o(C=>C.map(D=>({...D,status:"error",error:"Upload failed"}))),r("Upload failed","error")}}),v=w.useCallback(C=>{C.preventDefault(),c(!0)},[]),x=w.useCallback(C=>{C.preventDefault(),c(!1)},[]),y=w.useCallback(C=>{C.preventDefault(),c(!1);const D=Array.from(C.dataTransfer.files).filter(T=>T.name.endsWith(".3mf"));D.length>0&&o(T=>[...T,...D.map(R=>({file:R,status:"pending"}))])},[]),S=w.useCallback(C=>{const D=Array.from(C.target.files||[]).filter(T=>T.name.endsWith(".3mf"));D.length>0&&o(T=>[...T,...D.map(R=>({file:R,status:"pending"}))]),i.current&&(i.current.value="")},[]),M=w.useCallback(C=>{o(D=>D.filter((T,R)=>R!==C))},[]),N=()=>{if(a.length===0)return;const C=a.filter(D=>D.status==="pending");C.length!==0&&(o(D=>D.map(T=>T.status==="pending"?{...T,status:"uploading"}:T)),b.mutate(C.map(D=>D.file)))},A=a.filter(C=>C.status==="pending").length,k=b.isPending;return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(Nt,{className:"w-full max-w-2xl max-h-[90vh] flex flex-col",children:s.jsxs(Ct,{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(Gt,{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:v,onDragLeave:x,onDrop:y,children:[s.jsx(fi,{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(Me,{variant:"secondary",onClick:()=>i.current?.click(),disabled:k,children:"Browse Files"}),s.jsx("input",{ref:i,type:"file",accept:".3mf",multiple:!0,className:"hidden",onChange:S})]})}),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:C=>d(C.target.value?Number(C.target.value):void 0),disabled:k,children:[s.jsx("option",{value:"",children:"No printer"}),p?.map(C=>s.jsx("option",{value:C.id,children:C.name},C.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((C,D)=>s.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[s.jsx(nE,{className:"w-5 h-5 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"flex-1 text-white text-sm truncate",children:C.file.name}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:[(C.file.size/(1024*1024)).toFixed(1)," MB"]}),C.status==="pending"&&s.jsx("button",{onClick:()=>M(D),className:"text-bambu-gray hover:text-red-400 transition-colors",disabled:k,children:s.jsx(Gt,{className:"w-4 h-4"})}),C.status==="uploading"&&s.jsx(mt,{className:"w-4 h-4 text-bambu-green animate-spin"}),C.status==="success"&&s.jsx(Hn,{className:"w-4 h-4 text-bambu-green"}),C.status==="error"&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-xs text-red-400",children:C.error}),s.jsx(aa,{className:"w-4 h-4 text-red-400"})]})]},`${C.file.name}-${D}`))})}),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(Me,{variant:"secondary",onClick:t,className:"flex-1",children:f?"Close":"Cancel"}),!f&&s.jsx(Me,{onClick:N,disabled:A===0||k,className:"flex-1",children:k?s.jsxs(s.Fragment,{children:[s.jsx(mt,{className:"w-4 h-4 animate-spin"}),"Uploading..."]}):s.jsxs(s.Fragment,{children:[s.jsx(fi,{className:"w-4 h-4"}),"Upload ",A>0&&`(${A})`]})})]})]})})})}const i$e=["Adhesion failure","Spaghetti / Detached","Layer shift","Clogged nozzle","Filament runout","Warping","Stringing","Under-extrusion","Power failure","User cancelled","Other"],a$e=[{value:"completed",label:"Completed"},{value:"failed",label:"Failed"},{value:"aborted",label:"Cancelled"},{value:"printing",label:"Printing"}];function vte({archive:t,onClose:e,existingTags:n=[]}){w.useEffect(()=>{const oe=Ne=>{Ne.key==="Escape"&&e()};return window.addEventListener("keydown",oe),()=>window.removeEventListener("keydown",oe)},[e]);const r=ln(),[i,a]=w.useState(t.print_name||""),[o,l]=w.useState(t.printer_id),[c,u]=w.useState(t.project_id??null),[d,f]=w.useState(t.notes||""),[m,p]=w.useState(t.tags||""),[b,v]=w.useState(t.failure_reason||""),[x,y]=w.useState(t.status),[S,M]=w.useState(t.quantity??1),[N,A]=w.useState(t.photos||[]),[k,C]=w.useState(t.external_url||""),[D,T]=w.useState(!1),[R,U]=w.useState(!1),L=w.useRef(null),q=w.useRef(null),j=w.useRef(null),{data:W}=ft({queryKey:["printers"],queryFn:me.getPrinters}),{data:K}=ft({queryKey:["projects"],queryFn:()=>me.getProjects()}),{data:V}=ft({queryKey:["archives"],queryFn:()=>me.getArchives(void 0,1e3,0),enabled:n.length===0}),J=n.length>0?n:[...new Set(V?.flatMap(oe=>oe.tags?.split(",").map(Ne=>Ne.trim())||[]).filter(Boolean)||[])].sort(),ne=m.split(",").map(oe=>oe.trim()).filter(Boolean),te=J.filter(oe=>!ne.includes(oe)),z=oe=>{if(!ne.includes(oe)){const Ne=[...ne,oe].join(", ");p(Ne)}j.current!==null&&clearTimeout(j.current),L.current?.focus()},H=oe=>{const Ne=ne.filter(ge=>ge!==oe).join(", ");p(Ne)},Z=pt({mutationFn:oe=>me.updateArchive(t.id,oe),onSuccess:()=>{r.invalidateQueries({queryKey:["archives"]}),r.invalidateQueries({queryKey:["projects"]}),e()}}),ee=async oe=>{const Ne=oe.target.files?.[0];if(Ne){T(!0);try{const ge=await me.uploadArchivePhoto(t.id,Ne);A(ge.photos),r.invalidateQueries({queryKey:["archives"]})}catch(ge){console.error("Failed to upload photo:",ge)}finally{T(!1),q.current&&(q.current.value="")}}},he=async oe=>{try{const Ne=await me.deleteArchivePhoto(t.id,oe);A(Ne.photos||[]),r.invalidateQueries({queryKey:["archives"]})}catch(Ne){console.error("Failed to delete photo:",Ne)}},fe=oe=>{oe.preventDefault();const Ne={print_name:i||void 0,printer_id:o,project_id:c,notes:d||void 0,tags:m||void 0,quantity:S,external_url:k||null};x!==t.status&&(Ne.status=x),x==="failed"||x==="aborted"?Ne.failure_reason=b||void 0:(t.status==="failed"||t.status==="aborted")&&(Ne.failure_reason=null),Z.mutate(Ne)};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:oe=>oe.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(Gt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:fe,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:oe=>a(oe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"Print name"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),s.jsxs("select",{value:o??"",onChange:oe=>l(oe.target.value?Number(oe.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"",children:"No printer"}),W?.map(oe=>s.jsx("option",{value:oe.id,children:oe.name},oe.id))]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(Ea,{className:"w-4 h-4 inline mr-1"}),"Project"]}),s.jsxs("select",{value:c??"",onChange:oe=>u(oe.target.value?Number(oe.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"",children:"No project"}),K?.map(oe=>s.jsx("option",{value:oe.id,children:oe.name},oe.id))]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(bhe,{className:"w-4 h-4 inline mr-1"}),"Items Printed"]}),s.jsx("input",{type:"number",min:1,value:S,onChange:oe=>M(Math.max(1,parseInt(oe.target.value)||1)),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"1"}),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:oe=>f(oe.target.value),rows:3,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none resize-none",placeholder:"Add notes about this print..."})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(Xg,{className:"w-4 h-4 inline mr-1"}),"External Link"]}),s.jsx("input",{type:"url",value:k,onChange:oe=>C(oe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"https://printables.com/model/..."}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Link to Printables, Thingiverse, or other source"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Tags"}),ne.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:ne.map(oe=>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(gg,{className:"w-3 h-3"}),oe,s.jsx("button",{type:"button",onClick:()=>H(oe),className:"ml-0.5 text-bambu-gray hover:text-white",children:s.jsx(Gt,{className:"w-3 h-3"})})]},oe))}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{ref:L,type:"text",value:m,onChange:oe=>p(oe.target.value),onFocus:()=>{j.current!==null&&clearTimeout(j.current),U(!0)},onBlur:()=>{j.current=window.setTimeout(()=>U(!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:ne.length>0?"Add more tags...":"Add tags..."}),R&&te.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:te.map(oe=>s.jsx("button",{type:"button",onClick:()=>z(oe),className:"px-2 py-0.5 bg-bambu-dark-tertiary hover:bg-bambu-green/20 rounded text-sm text-bambu-gray hover:text-white transition-colors",children:oe},oe))})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Status"}),s.jsx("select",{value:x,onChange:oe=>{y(oe.target.value),oe.target.value==="completed"&&v("")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:a$e.map(oe=>s.jsx("option",{value:oe.value,children:oe.label},oe.value))})]}),(x==="failed"||x==="aborted")&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Failure Reason"}),s.jsxs("select",{value:b,onChange:oe=>v(oe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"",children:"Select reason..."}),i$e.map(oe=>s.jsx("option",{value:oe,children:oe},oe))]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(fg,{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(oe=>s.jsxs("div",{className:"relative group",children:[s.jsx("img",{src:me.getArchivePhotoUrl(t.id,oe),alt:"Print result",className:"w-20 h-20 object-cover rounded-lg border border-bambu-dark-tertiary"}),s.jsx("button",{type:"button",onClick:()=>he(oe),className:"absolute -top-1 -right-1 p-1 bg-red-500 rounded-full opacity-0 group-hover:opacity-100 transition-opacity",children:s.jsx(hn,{className:"w-3 h-3 text-white"})})]},oe)),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:q,type:"file",accept:"image/jpeg,image/png,image/webp",onChange:ee,className:"hidden",disabled:D}),D?s.jsx(mt,{className:"w-6 h-6 text-bambu-gray animate-spin"}):s.jsx(rr,{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(Me,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(Me,{type:"submit",disabled:Z.isPending,className:"flex-1",children:[s.jsx(bs,{className:"w-4 h-4"}),Z.isPending?"Saving...":"Save"]})]})]})]})})}function _te({x:t,y:e,items:n,onClose:r}){const i=w.useRef(null),[a,o]=w.useState(null),l=w.useRef(null),[c,u]=w.useState({x:t,y:e,visible:!1}),[d,f]=w.useState(!1),[m,p]=w.useState({});w.useEffect(()=>{const x=M=>{i.current&&!i.current.contains(M.target)&&r()},y=M=>{M.key==="Escape"&&r()},S=()=>{r()};return document.addEventListener("mousedown",x),document.addEventListener("keydown",y),document.addEventListener("scroll",S,!0),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",y),document.removeEventListener("scroll",S,!0),l.current&&clearTimeout(l.current)}},[r]),w.useLayoutEffect(()=>{if(i.current){i.current.style.visibility="hidden",i.current.style.display="block";const x=i.current.getBoundingClientRect(),y=window.innerWidth,S=window.innerHeight,M=8;let N=t,A=e;t+x.width>y-M&&(N=Math.max(M,y-x.width-M)),N<M&&(N=M),e+x.height>S-M&&(A=Math.max(M,S-x.height-M)),A<M&&(A=M);const k=180,C=y-N-x.width,D=N;f(C<k&&D>k),u({x:N,y:A,visible:!0})}},[t,e]);const b=(x,y)=>{l.current&&(clearTimeout(l.current),l.current=null);const S=y.getBoundingClientRect(),M=window.innerHeight,N=300,C=M-S.top-8<N&&S.top>N;p(D=>({...D,[x]:C?"bottom":"top"})),o(x)},v=()=>{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((x,y)=>{if(x.divider)return s.jsx("div",{className:"my-1 border-t border-bambu-dark-tertiary"},y);const S=x.submenu&&x.submenu.length>0;return s.jsxs("div",{className:"relative",onMouseEnter:M=>S&&b(y,M.currentTarget),onMouseLeave:()=>S&&v(),children:[s.jsxs("button",{onMouseEnter:M=>S&&b(y,M.currentTarget.parentElement),onClick:()=>{S?o(a===y?null:y):x.disabled||(x.onClick(),r())},disabled:x.disabled,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${x.disabled?"text-bambu-gray cursor-not-allowed":x.danger?"text-red-400 hover:bg-red-400/10":"text-white hover:bg-bambu-dark-tertiary"} ${S&&a===y?"bg-bambu-dark-tertiary":""}`,children:[x.icon&&s.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:x.icon}),s.jsx("span",{className:"flex-1",children:x.label}),S&&s.jsx(Zs,{className:"w-4 h-4 text-bambu-gray"})]}),S&&a===y&&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"} ${m[y]==="bottom"?"bottom-0":"top-0"}`,onMouseEnter:()=>{l.current&&(clearTimeout(l.current),l.current=null)},onMouseLeave:()=>v(),children:x.submenu.map((M,N)=>s.jsxs("button",{onClick:()=>{M.disabled||(M.onClick(),r())},disabled:M.disabled,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${M.disabled?"text-bambu-gray cursor-not-allowed":M.danger?"text-red-400 hover:bg-red-400/10":"text-white hover:bg-bambu-dark-tertiary"}`,children:[M.icon&&s.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:M.icon}),M.label]},N))})]},y)})})}function s$e({selectedIds:t,existingTags:e,onClose:n}){const r=ln(),{showToast:i}=Yn(),[a,o]=w.useState(""),[l,c]=w.useState(new Set),[u,d]=w.useState("add");w.useEffect(()=>{const v=x=>{x.key==="Escape"&&n()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[n]);const f=pt({mutationFn:async()=>{const v=Array.from(l);let x=0;for(const y of t)try{const S=await me.getArchive(y),M=S.tags?S.tags.split(",").map(A=>A.trim()).filter(Boolean):[];let N;u==="add"?N=[...new Set([...M,...v])]:N=M.filter(A=>!l.has(A)),await me.updateArchive(y,{tags:N.join(", ")}),x++}catch(S){throw console.error(`Failed to update archive ${y}:`,S),new Error(`Failed on archive ${y}: ${S instanceof Error?S.message:"Unknown error"}`)}return{count:x,mode:u,tags:v}},onSuccess:({count:v,mode:x,tags:y})=>{r.invalidateQueries({queryKey:["archives"]}),i(`${x==="add"?"Added":"Removed"} ${y.length} tag${y.length!==1?"s":""} ${x==="add"?"to":"from"} ${v} archive${v!==1?"s":""}`),n()},onError:v=>{i(v.message||"Failed to update tags","error")}}),m=v=>{c(x=>{const y=new Set(x);return y.has(v)?y.delete(v):y.add(v),y})},p=()=>{a.trim()&&!l.has(a.trim())&&(c(v=>new Set([...v,a.trim()])),o(""))},b=v=>{v.key==="Enter"&&(v.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(Nt,{className:"w-full max-w-md",children:s.jsxs(Ct,{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(gg,{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(Gt,{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(Me,{size:"sm",variant:u==="add"?"primary":"secondary",onClick:()=>d("add"),children:"Add Tags"}),s.jsx(Me,{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:v=>o(v.target.value),onKeyDown:b}),s.jsx(Me,{size:"sm",variant:"secondary",onClick:p,disabled:!a.trim(),children:s.jsx(rr,{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(v=>s.jsx("button",{onClick:()=>m(v),className:`px-2 py-1 rounded text-sm transition-colors ${l.has(v)?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray-light hover:bg-bambu-dark"}`,children:v},v))})]}),l.size>0&&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(v=>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:[v,s.jsx("button",{onClick:()=>m(v),className:"hover:opacity-70",children:s.jsx(Gt,{className:"w-3 h-3"})})]},v))})]})]}),s.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(Me,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),s.jsx(Me,{onClick:()=>f.mutate(),disabled:l.size===0||f.isPending,className:"flex-1",children:f.isPending?s.jsxs(s.Fragment,{children:[s.jsx(mt,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):s.jsxs(s.Fragment,{children:[s.jsx(gg,{className:"w-4 h-4"}),u==="add"?"Add Tags":"Remove Tags"]})})]})]})})})}function o$e({selectedIds:t,onClose:e}){const n=ln(),{showToast:r}=Yn(),{data:i,isLoading:a}=ft({queryKey:["projects"],queryFn:()=>me.getProjects()});w.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=pt({mutationFn:async d=>(await me.addArchivesToProject(d,t),d),onSuccess:d=>{const f=i?.find(m=>m.id===d);o(),r(`Added ${t.length} archive${t.length!==1?"s":""} to "${f?.name}"`),e()},onError:()=>{r("Failed to assign project","error")}}),c=pt({mutationFn:async()=>{for(const d of t)await me.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(Nt,{className:"w-full max-w-md max-h-[80vh] flex flex-col",children:s.jsxs(Ct,{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(Ea,{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(Gt,{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(mt,{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(za,{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(mt,{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(Ea,{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(mt,{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(Me,{variant:"secondary",onClick:e,className:"flex-1",disabled:u,children:"Cancel"})})]})})})}function l$e(t,e){return new Date(t,e+1,0).getDate()}function c$e(t,e){return new Date(t,e,1).getDay()}const u$e=["January","February","March","April","May","June","July","August","September","October","November","December"],d$e=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function h$e({archives:t,onArchiveClick:e,highlightedArchiveId:n}){const r=new Date,[i,a]=w.useState(r.getMonth()),[o,l]=w.useState(r.getFullYear()),[c,u]=w.useState(null),[d,f]=w.useState(null),m=w.useMemo(()=>{const A=new Map;return t.forEach(k=>{const C=Si(k.completed_at||k.created_at)||new Date,D=`${C.getFullYear()}-${String(C.getMonth()+1).padStart(2,"0")}-${String(C.getDate()).padStart(2,"0")}`,T=A.get(D)||[];T.push(k),A.set(D,T)}),A},[t]),p=l$e(o,i),b=c$e(o,i),v=()=>{i===0?(a(11),l(o-1)):a(i-1)},x=()=>{i===11?(a(0),l(o+1)):a(i+1)},y=()=>{a(r.getMonth()),l(r.getFullYear())},S=[];for(let A=0;A<b;A++)S.push(null);for(let A=1;A<=p;A++)S.push(A);const M=c?m.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:v,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(If,{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:[u$e[i]," ",o]}),s.jsx("button",{onClick:y,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:x,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(Zs,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:d$e.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:S.map((A,k)=>{if(A===null)return s.jsx("div",{className:"aspect-square"},`empty-${k}`);const C=`${o}-${String(i+1).padStart(2,"0")}-${String(A).padStart(2,"0")}`,D=m.get(C)||[],T=D.length>0,R=A===r.getDate()&&i===r.getMonth()&&o===r.getFullYear(),U=C===c,L=D.filter(j=>j.status==="completed").length,q=D.filter(j=>j.status==="failed").length;return s.jsxs("button",{onClick:()=>N(U?null:C),className:`aspect-square rounded-lg p-1 flex flex-col items-center justify-center transition-colors relative ${U?"bg-bambu-green text-white":R?"bg-bambu-green/20 text-white ring-2 ring-bambu-green":T?"bg-bambu-dark-tertiary hover:bg-bambu-dark-tertiary/70 text-white":"hover:bg-bambu-dark-tertiary/50 text-bambu-gray"}`,children:[s.jsx("span",{className:`text-sm font-medium ${R&&!U?"text-bambu-green":""}`,children:A}),T&&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&&L===0?"bg-red-400":q>0?"bg-yellow-400":"bg-green-400"}`}),s.jsx("span",{className:"text-xs font-medium",children:D.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 k=new Date(A.completed_at||A.created_at);return k.getMonth()===i&&k.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 k=new Date(A.completed_at||A.created_at);return k.getMonth()===i&&k.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 k=new Date(A.completed_at||A.created_at);return k.getMonth()===i&&k.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"})}),M.length>0?s.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:M.map(A=>{const k=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 ${k?"":"hover:bg-bambu-dark-tertiary"}`,style:k?{outline:"4px solid #facc15",outlineOffset:"2px"}:void 0,children:[A.thumbnail_path?s.jsx("img",{src:me.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((C,D)=>s.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:C}},D))})]})]})]},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 wte({archiveId:t,archiveName:e,onClose:n}){const r=me.getArchiveQRCodeUrl(t,300);w.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(Gt,{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(Me,{onClick:i,className:"w-full",children:[s.jsx($r,{className:"w-4 h-4"}),"Download QR Code"]})]})]})})}function Ste({archiveId:t,archiveName:e,photos:n,onClose:r,onDelete:i}){const[a,o]=w.useState(0),[l,c]=w.useState(!1);if(w.useEffect(()=>{const p=b=>{b.key==="Escape"&&r(),b.key==="ArrowLeft"&&o(v=>Math.max(0,v-1)),b.key==="ArrowRight"&&o(v=>Math.min(n.length-1,v+1))};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[r,n.length]),w.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=me.getArchivePhotoUrl(t,u),f=()=>{const p=document.createElement("a");p.href=d,p.download=`${e}_photo_${a+1}.jpg`,p.click()},m=()=>{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(Me,{variant:"secondary",size:"sm",onClick:f,children:[s.jsx($r,{className:"w-4 h-4"}),"Download"]}),i&&s.jsx(Me,{variant:"secondary",size:"sm",onClick:m,className:"text-red-400 hover:text-red-300",children:s.jsx(hn,{className:"w-4 h-4"})}),s.jsx("button",{onClick:r,className:"p-2 text-bambu-gray hover:text-white transition-colors",children:s.jsx(Gt,{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(If,{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(Zs,{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,b)=>s.jsx("button",{onClick:()=>o(b),className:`w-16 h-16 rounded-lg overflow-hidden border-2 transition-colors ${b===a?"border-bambu-green":"border-transparent hover:border-bambu-gray"}`,children:s.jsx("img",{src:me.getArchivePhotoUrl(t,p),alt:`Thumbnail ${b+1}`,className:"w-full h-full object-cover"})},p))})]}),l&&s.jsx(zn,{title:"Delete Photo",message:"Delete this photo? This cannot be undone.",confirmText:"Delete",variant:"danger",onConfirm:()=>{i?.(u),c(!1)},onCancel:()=>c(!1)})]})}function ga(t){this.content=t}ga.prototype={constructor:ga,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 ga(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 ga(n)},addToStart:function(t,e){return new ga([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new ga(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 ga(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=ga.from(t),t.size?new ga(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=ga.from(t),t.size?new ga(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=ga.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}};ga.from=function(t){if(t instanceof ga)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new ga(e)};function Mte(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=Mte(i.content,a.content,n+1);if(o!=null)return o}n+=i.nodeSize}}function Ete(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=Ete(o.content,l.content,n-1,r-1);if(u)return u}n-=c,r-=c}}class At{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 At(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 At(r,i)}cutByIndex(e,n){return e==n?At.empty:e==0&&n==this.content.length?this:new At(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 At(i,a)}addToStart(e){return new At([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new At(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 Mte(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Ete(this,e,n,r)}findIndex(e){if(e==0)return j1(0,e);if(e==this.size)return j1(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?j1(n+1,a):j1(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 At.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new At(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return At.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 At(n||e,r)}static from(e){if(!e)return At.empty;if(e instanceof At)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new At([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}At.empty=new At([],0);const fj={index:0,offset:0};function j1(t,e){return fj.index=t,fj.offset=e,fj}function JS(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(!JS(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!JS(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let wr=class RR{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&&JS(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 RR.none;if(e instanceof RR)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};wr.none=[];class eM extends Error{}class $t{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=Ate(this.content,e+this.openStart,n);return r&&new $t(r,this.openStart,this.openEnd)}removeBetween(e,n){return new $t(Nte(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 $t.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 $t(At.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 $t(e,r,i)}}$t.empty=new $t(At.empty,0,0);function Nte(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(Nte(a.content,e-i-1,n-i-1)))}function Ate(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=Ate(o.content,e-a-1,n,o);return l&&t.replaceChild(i,o.copy(l))}function f$e(t,e,n){if(n.openStart>t.depth)throw new eM("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new eM("Inconsistent open depths");return Tte(t,e,n,0)}function Tte(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=Tte(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 kf(o,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=m$e(n,t);return kf(a,kte(t,o,l,e,r))}else return kf(a,tM(t,e,r))}function Cte(t,e){if(!e.type.compatibleContent(t.type))throw new eM("Cannot join "+e.type.name+" onto "+t.type.name)}function DR(t,e,n){let r=t.node(n);return Cte(r,e.node(n)),r}function Cf(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 l0(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&&(Cf(t.nodeAfter,r),a++));for(let l=a;l<o;l++)Cf(i.child(l),r);e&&e.depth==n&&e.textOffset&&Cf(e.nodeBefore,r)}function kf(t,e){return t.type.checkContent(e),t.copy(e)}function kte(t,e,n,r,i){let a=t.depth>i&&DR(t,e,i+1),o=r.depth>i&&DR(n,r,i+1),l=[];return l0(null,t,i,l),a&&o&&e.index(i)==n.index(i)?(Cte(a,o),Cf(kf(a,kte(t,e,n,r,i+1)),l)):(a&&Cf(kf(a,tM(t,e,i+1)),l),l0(e,n,i,l),o&&Cf(kf(o,tM(n,r,i+1)),l)),l0(r,null,i,l),new At(l)}function tM(t,e,n){let r=[];if(l0(null,t,n,r),t.depth>n){let i=DR(t,e,n+1);Cf(kf(i,tM(t,e,n+1)),r)}return l0(e,null,n,r),new At(r)}function m$e(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(At.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class ty{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 wr.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 nM(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 ty(n,r,a)}static resolveCached(e,n){let r=_9.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 _9.set(e,r=new p$e);let i=r.elts[r.i]=ty.resolve(e,n);return r.i=(r.i+1)%g$e,i}}class p$e{constructor(){this.elts=[],this.i=0}}const g$e=12,_9=new WeakMap;class nM{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 x$e=Object.create(null);let Vd=class OR{constructor(e,n,r,i=wr.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||At.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&&JS(this.attrs,n||e.defaultAttrs||x$e)&&wr.sameSet(this.marks,r||wr.none)}copy(e=null){return e==this.content?this:new OR(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new OR(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 $t.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 $t(u,i.depth-o,a.depth-o)}replace(e,n,r){return f$e(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 ty.resolveCached(this,e)}resolveNoCache(e){return ty.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()+")"),jte(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=At.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=wr.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(!wr.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=At.fromJSON(e,n.content),a=e.nodeType(n.type).create(n.attrs,i,r);return a.type.checkAttrs(a.attrs),a}};Vd.prototype.text=void 0;class rM extends Vd{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):jte(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 rM(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new rM(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 jte(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class nm{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new b$e(e,n);if(r.next==null)return nm.empty;let i=Pte(r);r.next&&r.err("Unexpected trailing text");let a=E$e(M$e(i));return N$e(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 At.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 m=a(f,l.concat(d));if(m)return m}}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(`
  8190. `)}}nm.empty=new nm(!0);class b$e{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 Pte(t){let e=[];do e.push(y$e(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function y$e(t){let e=[];do e.push(v$e(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function v$e(t){let e=S$e(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=_$e(t,e);else break;return e}function w9(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function _$e(t,e){let n=w9(t),r=n;return t.eat(",")&&(t.next!="}"?r=w9(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function w$e(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 S$e(t){if(t.eat("(")){let e=Pte(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=w$e(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 M$e(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 Rte(t,e){return e-t}function S9(t,e){let n=[];return r(e),n.sort(Rte);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 E$e(t){let e=Object.create(null);return n(S9(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]);S9(t,c).forEach(d=>{u||i.push([l,u=[]]),u.indexOf(d)==-1&&u.push(d)})})});let a=e[r.join(",")]=new nm(r.indexOf(t.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(Rte);a.next.push({type:i[o][0],next:e[l.join(",")]||n(l)})}return a}}function N$e(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 Dte(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 Ote(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 Lte(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 Ite(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new T$e(t,r,e[r]);return n}let M9=class Fte{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=Ite(e,r.attrs),this.defaultAttrs=Dte(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==nm.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:Ote(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Vd(this,this.computeAttrs(e),At.from(n),wr.setFrom(r))}createChecked(e=null,n,r){return n=At.from(n),this.checkContent(n),new Vd(this,this.computeAttrs(e),n,wr.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=At.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(At.empty,!0);return a?new Vd(this,e,n.append(a),wr.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){Lte(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:wr.none:e}static compile(e,n){let r=Object.create(null);e.forEach((a,o)=>r[a]=new Fte(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 A$e(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 T$e{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?A$e(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class bN{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=Ite(e,i.attrs),this.excluded=null;let a=Dte(this.attrs);this.instance=a?new wr(this,a):null}create(e=null){return!e&&this.instance?this.instance:new wr(this,Ote(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((a,o)=>r[a]=new bN(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){Lte(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Ute{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=ga.from(e.nodes),n.marks=ga.from(e.marks||{}),this.nodes=M9.compile(this.spec.nodes,this),this.marks=bN.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]=nm.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?E9(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==""?[]:E9(this,o.split(" "))}this.nodeFromJSON=i=>Vd.fromJSON(this,i),this.markFromJSON=i=>wr.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 M9){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 rM(r,r.defaultAttrs,e,wr.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 E9(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 C$e(t){return t.tag!=null}function k$e(t){return t.style!=null}let c0=class LR{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(C$e(i))this.tags.push(i);else if(k$e(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 A9(this,n,!1);return r.addAll(e,wr.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new A9(this,n,!0);return r.addAll(e,wr.none,n.from,n.to),$t.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(R$e(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=T9(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=T9(o)),o.node||o.ignore||o.mark||(o.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new LR(e,LR.schemaRules(e)))}};const zte={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},j$e={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Bte={ol:!0,ul:!0},ny=1,IR=2,u0=4;function N9(t,e,n){return e!=null?(e?ny:0)|(e==="full"?IR:0):t&&t.whitespace=="pre"?ny|IR:n&~u0}class P1{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=wr.none,this.match=a||(o&u0?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(At.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&ny)){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=At.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(At.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&&!zte.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class A9{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=N9(null,n.preserveWhitespace,0)|(r?u0:0);i?a=new P1(i.type,i.attrs,wr.none,!0,n.topMatch||i.type.contentMatch,o):r?a=new P1(null,null,wr.none,!0,null,o):a=new P1(e.schema.topNodeType,null,wr.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&IR?"full":this.localPreserveWS||(i.options&ny)>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,`
  8191. `);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;Bte.hasOwnProperty(o)&&this.parser.normalizeLists&&P$e(e);let c=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(c?c.ignore:j$e.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(zte.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(`
  8192. `),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=wr.none;for(let l of i.concat(e.marks))(a.type?a.type.allowsMarkType(l.type):C9(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=N9(e,a,o.options);o.options&u0&&o.content.length==0&&(l|=u0);let c=wr.none;return r=r.filter(u=>(o.type?o.type.allowsMarkType(u.type):C9(u.type,e))?(c=u.addToSet(c),!1):!0),this.nodes.push(new P1(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|=ny)}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 P$e(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Bte.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function R$e(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function T9(t){let e={};for(let n in t)e[n]=t[n];return e}function C9(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 fm{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=mj(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}=xw(mj(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&&xw(mj(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return xw(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new fm(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=k9(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return k9(e.marks)}}function k9(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function mj(t){return t.document||window.document}const j9=new WeakMap;function D$e(t){let e=j9.get(t);return e===void 0&&j9.set(t,e=O$e(t)),e}function O$e(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 xw(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=D$e(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 m=f.indexOf(" ");m>0?c.setAttributeNS(f.slice(0,m),f.slice(m+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 m=e[f];if(m===0){if(f<e.length-1||f>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}else{let{dom:p,contentDOM:b}=xw(t,m,n,r);if(c.appendChild(p),b){if(l)throw new RangeError("Multiple content holes");l=b}}}return{dom:c,contentDOM:l}}const $te=65535,Hte=Math.pow(2,16);function L$e(t,e){return t+e*Hte}function P9(t){return t&$te}function I$e(t){return(t-(t&$te))/Hte}const Vte=1,Gte=2,bw=4,Wte=8;class FR{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Wte)>0}get deletedBefore(){return(this.delInfo&(Vte|bw))>0}get deletedAfter(){return(this.delInfo&(Gte|bw))>0}get deletedAcross(){return(this.delInfo&bw)>0}}class Vs{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Vs.empty)return Vs.empty}recover(e){let n=0,r=P9(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+I$e(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 m=u?e==c?-1:e==f?1:n:n,p=c+i+(m<0?0:d);if(r)return p;let b=e==(n<0?c:f)?null:L$e(l/3,e-c),v=e==c?Gte:e==f?Vte:bw;return(n<0?e!=c:e!=f)&&(v|=Wte),new FR(p,v,b)}i+=d-u}return r?e+i:new FR(e+i,0,null)}touches(e,n){let r=0,i=P9(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 Vs(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Vs.empty:new Vs(e<0?[0,-e,0]:[0,0,e])}}Vs.empty=new Vs([]);class ry{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 ry(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 ry;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 FR(e,i,null)}}const pj=Object.create(null);class Va{getMap(){return Vs.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=pj[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 pj)throw new RangeError("Duplicate use of step JSON ID "+e);return pj[e]=n,n.prototype.jsonID=e,n}}class Ni{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new Ni(e,null)}static fail(e){return new Ni(null,e)}static fromReplace(e,n,r,i){try{return Ni.ok(e.replace(n,r,i))}catch(a){if(a instanceof eM)return Ni.fail(a.message);throw a}}}function ML(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let a=t.child(i);a.content.size&&(a=a.copy(ML(a.content,e,a))),a.isInline&&(a=e(a,n,i)),r.push(a)}return At.fromArray(r)}class Pd extends Va{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 $t(ML(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 Ni.fromReplace(e,this.from,this.to,a)}invert(){return new nl(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 Pd(n.pos,r.pos,this.mark)}merge(e){return e instanceof Pd&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Pd(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 Pd(n.from,n.to,e.markFromJSON(n.mark))}}Va.jsonID("addMark",Pd);class nl extends Va{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 $t(ML(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return Ni.fromReplace(e,this.from,this.to,r)}invert(){return new Pd(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 nl(n.pos,r.pos,this.mark)}merge(e){return e instanceof nl&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new nl(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 nl(n.from,n.to,e.markFromJSON(n.mark))}}Va.jsonID("removeMark",nl);class Rd extends Va{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Ni.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Ni.fromReplace(e,this.pos,this.pos+1,new $t(At.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 Rd(this.pos,n.marks[i]);return new Rd(this.pos,this.mark)}}return new rm(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Rd(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 Rd(n.pos,e.markFromJSON(n.mark))}}Va.jsonID("addNodeMark",Rd);class rm extends Va{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Ni.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return Ni.fromReplace(e,this.pos,this.pos+1,new $t(At.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Rd(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new rm(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 rm(n.pos,e.markFromJSON(n.mark))}}Va.jsonID("removeNodeMark",rm);class Ji extends Va{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&UR(e,this.from,this.to)?Ni.fail("Structure replace would overwrite content"):Ni.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Vs([this.from,this.to-this.from,this.slice.size])}invert(e){return new Ji(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 Ji(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Ji)||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?$t.empty:new $t(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Ji(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?$t.empty:new $t(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Ji(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 Ji(n.from,n.to,$t.fromJSON(e,n.slice),!!n.structure)}}Va.jsonID("replace",Ji);class ra extends Va{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&&(UR(e,this.from,this.gapFrom)||UR(e,this.gapTo,this.to)))return Ni.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return Ni.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?Ni.fromReplace(e,this.from,this.to,r):Ni.fail("Content does not fit in gap")}getMap(){return new Vs([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 ra(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 ra(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 ra(n.from,n.to,n.gapFrom,n.gapTo,$t.fromJSON(e,n.slice),n.insert,!!n.structure)}}Va.jsonID("replaceAround",ra);function UR(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 F$e(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 m=Math.max(u,e),p=Math.min(u+c.nodeSize,n),b=r.addToSet(f);for(let v=0;v<f.length;v++)f[v].isInSet(b)||(o&&o.to==m&&o.mark.eq(f[v])?o.to=p:i.push(o=new nl(m,p,f[v])));l&&l.to==m?l.to=p:a.push(l=new Pd(m,p,r))}}),i.forEach(c=>t.step(c)),a.forEach(c=>t.step(c))}function U$e(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 bN){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],m;for(let p=0;p<i.length;p++){let b=i[p];b.step==a-1&&f.eq(i[p].style)&&(m=b)}m?(m.to=u,m.step=a):i.push({style:f,from:Math.max(l,e),to:u,step:a})}}}),i.forEach(o=>t.step(new nl(o.from,o.to,o.style)))}function EL(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 Ji(l,d,$t.empty));else{r=f;for(let m=0;m<u.marks.length;m++)n.allowsMarkType(u.marks[m].type)||t.step(new nl(l,d,u.marks[m]));if(i&&u.isText&&n.whitespace!="pre"){let m,p=/\r?\n|\r/g,b;for(;m=p.exec(u.text);)b||(b=new $t(At.from(n.schema.text(" ",n.allowedMarks(u.marks))),0,0)),o.push(new Ji(l+m.index,l+m.index+m[0].length,b))}}l=d}if(!r.validEnd){let c=r.fillBefore(At.empty,!0);t.replace(l,l,new $t(c,0,0))}for(let c=o.length-1;c>=0;c--)t.step(o[c])}function z$e(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function hx(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||!z$e(o,l,c))break;l&&(i=1),c<o.childCount&&(a=1)}return null}function B$e(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=At.empty,f=0;for(let b=a,v=!1;b>n;b--)v||r.index(b)>0?(v=!0,d=At.from(r.node(b).copy(d)),f++):c--;let m=At.empty,p=0;for(let b=a,v=!1;b>n;b--)v||i.after(b+1)<i.end(b)?(v=!0,m=At.from(i.node(b).copy(m)),p++):u++;t.step(new ra(c,u,o,l,new $t(d.append(m),f,p),d.size-f,!0))}function NL(t,e,n=null,r=t){let i=$$e(t,e),a=i&&H$e(r,e);return a?i.map(R9).concat({type:e,attrs:n}).concat(a.map(R9)):null}function R9(t){return{type:t,attrs:null}}function $$e(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 H$e(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 V$e(t,e,n){let r=At.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=At.from(n[o].type.create(n[o].attrs,r))}let i=e.start,a=e.end;t.step(new ra(i,a,i,a,new $t(r,0,0),n.length,!0))}function G$e(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)&&W$e(t.doc,t.mapping.slice(a).map(l),r)){let u=null;if(r.schema.linebreakReplacement){let p=r.whitespace=="pre",b=!!r.contentMatch.matchType(r.schema.linebreakReplacement);p&&!b?u=!1:!p&&b&&(u=!0)}u===!1&&Kte(t,o,l,a),EL(t,t.mapping.slice(a).map(l,1),r,void 0,u===null);let d=t.mapping.slice(a),f=d.map(l,1),m=d.map(l+o.nodeSize,1);return t.step(new ra(f,m,f+1,m-1,new $t(At.from(r.create(c,null,o.marks)),0,0),1,!0)),u===!0&&qte(t,o,l,a),!1}})}function qte(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 Kte(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(`
  8193. `))}})}function W$e(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function q$e(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 ra(e,e+a.nodeSize,e+1,e+a.nodeSize-1,new $t(At.from(o),0,0),1,!0))}function lu(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),m=i.index(u);if(f.type.spec.isolating)return!1;let p=f.content.cutByIndex(m,f.childCount),b=r&&r[d+1];b&&(p=p.replaceChild(0,b.type.create(b.attrs)));let v=r&&r[d]||f;if(!f.canReplace(m+1,f.childCount)||!v.type.validContent(p))return!1}let l=i.indexAfter(a),c=r&&r[0];return i.node(a).canReplaceWith(l,l,c?c.type:i.node(a+1).type)}function K$e(t,e,n=1,r){let i=t.doc.resolve(e),a=At.empty,o=At.empty;for(let l=i.depth,c=i.depth-n,u=n-1;l>c;l--,u--){a=At.from(i.node(l).copy(a));let d=r&&r[u];o=At.from(d?d.type.create(d.attrs,o):i.node(l).copy(o))}t.step(new Ji(e,e,new $t(a.append(o),n,n),!0))}function ph(t,e){let n=t.resolve(e),r=n.index();return Xte(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function X$e(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 Xte(t,e){return!!(t&&e&&!t.isLeaf&&X$e(t,e))}function yN(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&&Xte(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 Y$e(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);Kte(t,d.node(),d.before(),l)}o.inlineContent&&EL(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 Ji(u,c.map(e+n,-1),$t.empty,!0)),r===!0){let d=t.doc.resolve(u);qte(t,d.node(),d.before(),t.steps.length)}return t}function Z$e(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 Yte(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 vN(t,e,n=e,r=$t.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),a=t.resolve(n);return Zte(i,a,r)?new Ji(e,n,r):new Q$e(i,a,r).fit()}function Zte(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class Q$e{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=At.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=At.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 $t(a,o,l);return e>-1?new ra(r.pos,e,this.$to.pos,this.$to.end(),c,n):c.size||r.pos!=this.$to.pos?new Ji(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=gj(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(At.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=gj(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new $t(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=gj(e,n);if(i.childCount<=1&&n>0){let a=e.size-n<=n+i.size;this.unplaced=new $t(Wb(e,n-1,1),n-1,a?n-1:r)}else this.unplaced=new $t(Wb(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:a}){for(;this.depth>n;)this.closeFrontierNode();if(a)for(let v=0;v<a.length;v++)this.openFrontierNode(a[v]);let o=this.unplaced,l=r?r.content:o.content,c=o.openStart-e,u=0,d=[],{match:f,type:m}=this.frontier[n];if(i){for(let v=0;v<i.childCount;v++)d.push(i.child(v));f=f.matchFragment(i)}let p=l.size+e-(o.content.size-o.openEnd);for(;u<l.childCount;){let v=l.child(u),x=f.matchType(v.type);if(!x)break;u++,(u>1||c==0||v.content.size)&&(f=x,d.push(Qte(v.mark(m.allowedMarks(v.marks)),u==1?c:0,u==l.childCount?p:-1)))}let b=u==l.childCount;b||(p=-1),this.placed=qb(this.placed,n,At.from(d)),this.frontier[n].match=f,b&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let v=0,x=l;v<p;v++){let y=x.lastChild;this.frontier.push({type:y.type,match:y.contentMatchAt(y.childCount)}),x=y.content}this.unplaced=b?e==0?$t.empty:new $t(Wb(o.content,e-1,1),e-1,p<0?o.openEnd:e-1):new $t(Wb(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||!xj(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=xj(e,n,i,r,a);if(o){for(let l=n-1;l>=0;l--){let{match:c,type:u}=this.frontier[l],d=xj(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=qb(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=qb(this.placed,this.depth,At.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(At.empty,!0);n.childCount&&(this.placed=qb(this.placed,this.frontier.length,n))}}function Wb(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Wb(t.firstChild.content,e-1,n)))}function qb(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(qb(t.lastChild.content,e-1,n)))}function gj(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function Qte(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,Qte(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(At.empty,!0)))),t.copy(r)}function xj(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&&!J$e(n,a.content,o)?l:null}function J$e(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function eHe(t){return t.spec.defining||t.spec.definingForContent}function tHe(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),a=t.doc.resolve(n);if(Zte(i,a,r))return t.step(new Ji(e,n,r));let o=ene(i,a);o[o.length-1]==0&&o.pop();let l=-(i.depth+1);o.unshift(l);for(let m=i.depth,p=i.pos-1;m>0;m--,p--){let b=i.node(m).type.spec;if(b.defining||b.definingAsContext||b.isolating)break;o.indexOf(m)>-1?l=m:i.before(m)==p&&o.splice(1,0,-m)}let c=o.indexOf(l),u=[],d=r.openStart;for(let m=r.content,p=0;;p++){let b=m.firstChild;if(u.push(b),p==r.openStart)break;m=b.content}for(let m=d-1;m>=0;m--){let p=u[m],b=eHe(p.type);if(b&&!p.sameMarkup(i.node(Math.abs(l)-1)))d=m;else if(b||!p.type.isTextblock)break}for(let m=r.openStart;m>=0;m--){let p=(m+d+1)%(r.openStart+1),b=u[p];if(b)for(let v=0;v<o.length;v++){let x=o[(v+c)%o.length],y=!0;x<0&&(y=!1,x=-x);let S=i.node(x-1),M=i.index(x-1);if(S.canReplaceWith(M,M,b.type,b.marks))return t.replace(i.before(x),y?a.after(x):n,new $t(Jte(r.content,0,r.openStart,p),p,r.openEnd))}}let f=t.steps.length;for(let m=o.length-1;m>=0&&(t.replace(e,n,r),!(t.steps.length>f));m--){let p=o[m];p<0||(e=i.before(p),n=a.after(p))}}function Jte(t,e,n,r,i){if(e<n){let a=t.firstChild;t=t.replaceChild(0,a.copy(Jte(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(At.empty,!0))}return t}function nHe(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=Z$e(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new $t(At.from(r),0,0))}function rHe(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),a=ene(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 ene(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 cg extends Va{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 Ni.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 Ni.fromReplace(e,this.pos,this.pos+1,new $t(At.from(i),0,n.isLeaf?0:1))}getMap(){return Vs.empty}invert(e){return new cg(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 cg(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 cg(n.pos,n.attr,n.value)}}Va.jsonID("attr",cg);class iy extends Va{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 Ni.ok(r)}getMap(){return Vs.empty}invert(e){return new iy(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 iy(n.attr,n.value)}}Va.jsonID("docAttr",iy);let Lg=class extends Error{};Lg=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Lg.prototype=Object.create(Error.prototype);Lg.prototype.constructor=Lg;Lg.prototype.name="TransformError";class tne{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new ry}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Lg(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}changedRange(){let e=1e9,n=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let i=this.mapping.maps[r];r&&(e=i.map(e,1),n=i.map(n,-1)),i.forEach((a,o,l,c)=>{e=Math.min(e,l),n=Math.max(n,c)})}return e==1e9?null:{from:e,to:n}}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=$t.empty){let i=vN(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new $t(At.from(r),0,0))}delete(e,n){return this.replace(e,n,$t.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return tHe(this,e,n,r),this}replaceRangeWith(e,n,r){return nHe(this,e,n,r),this}deleteRange(e,n){return rHe(this,e,n),this}lift(e,n){return B$e(this,e,n),this}join(e,n=1){return Y$e(this,e,n),this}wrap(e,n){return V$e(this,e,n),this}setBlockType(e,n=e,r,i=null){return G$e(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return q$e(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new cg(e,n,r)),this}setDocAttribute(e,n){return this.step(new iy(e,n)),this}addNodeMark(e,n){return this.step(new Rd(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 wr)n.isInSet(r.marks)&&this.step(new rm(e,n));else{let i=r.marks,a,o=[];for(;a=n.isInSet(i);)o.push(new rm(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 K$e(this,e,n,r),this}addMark(e,n,r){return F$e(this,e,n,r),this}removeMark(e,n,r){return U$e(this,e,n,r),this}clearIncompatible(e,n,r){return EL(this,e,n,r),this}}const bj=Object.create(null);class En{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new iHe(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=$t.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?$t.empty:n),l==0&&L9(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),L9(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new fn(e):Bp(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?Bp(e.node(0),e.node(a),e.before(a+1),e.index(a),n,r):Bp(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 Ys(e.node(0))}static atStart(e){return Bp(e,e,0,0,1)||new Ys(e)}static atEnd(e){return Bp(e,e,e.content.size,e.childCount,-1)||new Ys(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=bj[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 bj)throw new RangeError("Duplicate use of selection JSON ID "+e);return bj[e]=n,n.prototype.jsonID=e,n}getBookmark(){return fn.between(this.$anchor,this.$head).getBookmark()}}En.prototype.visible=!0;class iHe{constructor(e,n){this.$from=e,this.$to=n}}let D9=!1;function O9(t){!D9&&!t.parent.inlineContent&&(D9=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class fn extends En{constructor(e,n=e){O9(e),O9(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 En.near(r);let i=e.resolve(n.map(this.anchor));return new fn(i.parent.inlineContent?i:r,r)}replace(e,n=$t.empty){if(super.replace(e,n),n==$t.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof fn&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new _N(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 fn(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=En.findFrom(n,r,!0)||En.findFrom(n,-r,!0);if(a)n=a.$head;else return En.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(En.findFrom(e,-r,!0)||En.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new fn(e,n)}}En.jsonID("text",fn);class _N{constructor(e,n){this.anchor=e,this.head=n}map(e){return new _N(e.map(this.anchor),e.map(this.head))}resolve(e){return fn.between(e.resolve(this.anchor),e.resolve(this.head))}}class nn extends En{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?En.near(a):new nn(a)}content(){return new $t(At.from(this.node),0,0)}eq(e){return e instanceof nn&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new AL(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new nn(e.resolve(n.anchor))}static create(e,n){return new nn(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}nn.prototype.visible=!1;En.jsonID("node",nn);class AL{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new _N(r,r):new AL(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&nn.isSelectable(r)?new nn(n):En.near(n)}}class Ys extends En{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=$t.empty){if(n==$t.empty){e.delete(0,e.doc.content.size);let r=En.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new Ys(e)}map(e){return new Ys(e)}eq(e){return e instanceof Ys}getBookmark(){return aHe}}En.jsonID("all",Ys);const aHe={map(){return this},resolve(t){return new Ys(t)}};function Bp(t,e,n,r,i,a=!1){if(e.inlineContent)return fn.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&&nn.isSelectable(l))return nn.create(t,n-(i<0?l.nodeSize:0))}else{let c=Bp(t,l,n+i,i<0?l.childCount:0,i,a);if(c)return c}n+=l.nodeSize*i}return null}function L9(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof Ji||i instanceof ra))return;let a=t.mapping.maps[r],o;a.forEach((l,c,u,d)=>{o==null&&(o=d)}),t.setSelection(En.near(t.doc.resolve(o),n))}const I9=1,R1=2,F9=4;class sHe extends tne{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|I9)&~R1,this.storedMarks=null,this}get selectionSet(){return(this.updated&I9)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=R1,this}ensureMarks(e){return wr.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&R1)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~R1,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)||wr.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(En.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|=F9,this}get scrolledIntoView(){return(this.updated&F9)>0}}function U9(t,e){return!e||!t?t:t.bind(e)}class Kb{constructor(e,n,r){this.name=e,this.init=U9(n.init,r),this.apply=U9(n.apply,r)}}const oHe=[new Kb("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Kb("selection",{init(t,e){return t.selection||En.atStart(e.doc)},apply(t){return t.selection}}),new Kb("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Kb("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class yj{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=oHe.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 Kb(r.key,r.spec.state,r))})}}class Yp{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 Yp(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 sHe(this)}static create(e){let n=new yj(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Yp(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 yj(this.schema,e.plugins),r=n.fields,i=new Yp(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 yj(e.schema,e.plugins),a=new Yp(i);return i.fields.forEach(o=>{if(o.name=="doc")a.doc=Vd.fromJSON(e.schema,n.doc);else if(o.name=="selection")a.selection=En.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 nne(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=nne(i,e,{})),n[r]=i}return n}class Yr{constructor(e){this.spec=e,this.props={},e.props&&nne(e.props,this,this.props),this.key=e.key?e.key.key:rne("plugin")}getState(e){return e[this.key]}}const vj=Object.create(null);function rne(t){return t in vj?t+"$"+ ++vj[t]:(vj[t]=0,t+"$")}class Vi{constructor(e="key"){this.key=rne(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const TL=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function ine(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const ane=(t,e,n)=>{let r=ine(t,n);if(!r)return!1;let i=CL(r);if(!i){let o=r.blockRange(),l=o&&hx(o);return l==null?!1:(e&&e(t.tr.lift(o,l).scrollIntoView()),!0)}let a=i.nodeBefore;if(mne(t,i,e,-1))return!0;if(r.parent.content.size==0&&(Ig(a,"end")||nn.isSelectable(a)))for(let o=r.depth;;o--){let l=vN(t.doc,r.before(o),r.after(o),$t.empty);if(l&&l.slice.size<l.to-l.from){if(e){let c=t.tr.step(l);c.setSelection(Ig(a,"end")?En.findFrom(c.doc.resolve(c.mapping.map(i.pos,-1)),-1):nn.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},lHe=(t,e,n)=>{let r=ine(t,n);if(!r)return!1;let i=CL(r);return i?sne(t,i,e):!1},cHe=(t,e,n)=>{let r=lne(t,n);if(!r)return!1;let i=kL(r);return i?sne(t,i,e):!1};function sne(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=vN(t.doc,a,c,$t.empty);if(!u||u.from!=a||u instanceof Ji&&u.slice.size>=c-a)return!1;if(n){let d=t.tr.step(u);d.setSelection(fn.create(d.doc,a)),n(d.scrollIntoView())}return!0}function Ig(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 one=(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=CL(r)}let o=a&&a.nodeBefore;return!o||!nn.isSelectable(o)?!1:(e&&e(t.tr.setSelection(nn.create(t.doc,a.pos-o.nodeSize)).scrollIntoView()),!0)};function CL(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 lne(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const cne=(t,e,n)=>{let r=lne(t,n);if(!r)return!1;let i=kL(r);if(!i)return!1;let a=i.nodeAfter;if(mne(t,i,e,1))return!0;if(r.parent.content.size==0&&(Ig(a,"start")||nn.isSelectable(a))){let o=vN(t.doc,r.before(),r.after(),$t.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(Ig(a,"start")?En.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):nn.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},une=(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=kL(r)}let o=a&&a.nodeAfter;return!o||!nn.isSelectable(o)?!1:(e&&e(t.tr.setSelection(nn.create(t.doc,a.pos)).scrollIntoView()),!0)};function kL(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 uHe=(t,e)=>{let n=t.selection,r=n instanceof nn,i;if(r){if(n.node.isTextblock||!ph(t.doc,n.from))return!1;i=n.from}else if(i=yN(t.doc,n.from,-1),i==null)return!1;if(e){let a=t.tr.join(i);r&&a.setSelection(nn.create(a.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(a.scrollIntoView())}return!0},dHe=(t,e)=>{let n=t.selection,r;if(n instanceof nn){if(n.node.isTextblock||!ph(t.doc,n.to))return!1;r=n.to}else if(r=yN(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},hHe=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),a=i&&hx(i);return a==null?!1:(e&&e(t.tr.lift(i,a).scrollIntoView()),!0)},dne=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
  8194. `).scrollIntoView()),!0)};function jL(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 fHe=(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=jL(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(En.near(c.doc.resolve(l),1)),e(c.scrollIntoView())}return!0},hne=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof Ys||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=jL(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(fn.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},fne=(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(lu(t.doc,a))return e&&e(t.tr.split(a).scrollIntoView()),!0}let r=n.blockRange(),i=r&&hx(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function mHe(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof nn&&e.selection.node.isBlock)return!r.parentOffset||!lu(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=jL(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 fn||e.selection instanceof Ys)&&d.deleteSelection();let f=d.mapping.map(r.pos),m=lu(d.doc,f,a.length,a);if(m||(a[0]=l?{type:l}:null,m=lu(d.doc,f,a.length,a)),!m)return!1;if(d.split(f,a.length,a),!c&&u&&r.node(o).type!=l){let p=d.mapping.map(r.before(o)),b=d.doc.resolve(p);l&&r.node(o-1).canReplaceWith(b.index(),b.index()+1,l)&&d.setNodeMarkup(d.mapping.map(r.before(o)),l)}return n&&n(d.scrollIntoView()),!0}}const pHe=mHe(),gHe=(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(nn.create(t.doc,i))),!0)};function xHe(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||ph(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function mne(t,e,n,r){let i=e.nodeBefore,a=e.nodeAfter,o,l,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&xHe(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,b=At.empty;for(let y=o.length-1;y>=0;y--)b=At.from(o[y].create(null,b));b=At.from(i.copy(b));let v=t.tr.step(new ra(e.pos-1,p,e.pos,p,new $t(b,1,0),o.length,!0)),x=v.doc.resolve(p+2*o.length);x.nodeAfter&&x.nodeAfter.type==i.type&&ph(v.doc,x.pos)&&v.join(x.pos),n(v.scrollIntoView())}return!0}let d=a.type.spec.isolating||r>0&&c?null:En.findFrom(e,1),f=d&&d.$from.blockRange(d.$to),m=f&&hx(f);if(m!=null&&m>=e.depth)return n&&n(t.tr.lift(f,m).scrollIntoView()),!0;if(u&&Ig(a,"start",!0)&&Ig(i,"end")){let p=i,b=[];for(;b.push(p),!p.isTextblock;)p=p.lastChild;let v=a,x=1;for(;!v.isTextblock;v=v.firstChild)x++;if(p.canReplace(p.childCount,p.childCount,v.content)){if(n){let y=At.empty;for(let M=b.length-1;M>=0;M--)y=At.from(b[M].copy(y));let S=t.tr.step(new ra(e.pos-b.length,e.pos+a.nodeSize,e.pos+x,e.pos+a.nodeSize-x,new $t(y,b.length,0),0,!0));n(S.scrollIntoView())}return!0}}return!1}function pne(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(fn.create(e.doc,t<0?i.start(a):i.end(a)))),!0):!1}}const bHe=pne(-1),yHe=pne(1);function vHe(t,e=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),l=o&&NL(o,t,e);return l?(r&&r(n.tr.wrap(o,l).scrollIntoView()),!0):!1}}function z9(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 PL(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}PL(TL,ane,one);PL(TL,cne,une);PL(dne,hne,fne,pHe);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function _He(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 wHe(l,o,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function wHe(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 nM(c,c,e.depth),e.endIndex<e.parent.childCount&&(e=new nM(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=NL(a,n,r,e);return l?(t&&SHe(t,e,l,i,n),!0):!1}function SHe(t,e,n,r,i){let a=At.empty;for(let d=n.length-1;d>=0;d--)a=At.from(n[d].type.create(n[d].attrs,a));t.step(new ra(e.start-(r?2:0),e.end,e.start,e.end,new $t(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,m=!0;d<f;d++,m=!1)!m&&lu(t.doc,c,l)&&(t.split(c,l),c+=2*l),c+=u.child(d).nodeSize;return t}function MHe(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?EHe(e,n,t,a):NHe(e,n,a):!0:!1}}function EHe(t,e,n,r){let i=t.tr,a=r.end,o=r.$to.end(r.depth);a<o&&(i.step(new ra(a-1,o,a,o,new $t(At.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new nM(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));const l=hx(r);if(l==null)return!1;i.lift(r,l);let c=i.doc.resolve(i.mapping.map(a,-1)-1);return ph(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos),e(i.scrollIntoView()),!0}function NHe(t,e,n){let r=t.tr,i=n.parent;for(let p=n.end,b=n.endIndex-1,v=n.startIndex;b>v;b--)p-=i.child(b).nodeSize,r.delete(p-1,p+1);let a=r.doc.resolve(n.start),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?At.empty:At.from(i))))return!1;let f=a.pos,m=f+o.nodeSize;return r.step(new ra(f-(l?1:0),m+(c?1:0),f+1,m-1,new $t((l?At.empty:At.from(i.copy(At.empty))).append(c?At.empty:At.from(i.copy(At.empty))),l?0:1,c?0:1),l?0:1)),e(r.scrollIntoView()),!0}function AHe(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=At.from(u?t.create():null),f=new $t(At.from(t.create(null,At.from(l.type.create(null,d)))),u?3:1,0),m=a.start,p=a.end;n(e.tr.step(new ra(m-(u?3:1),p,m,p,f,1,!0)).scrollIntoView())}return!0}}const _a=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Fg=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let zR=null;const Gc=function(t,e,n){let r=zR||(zR=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},THe=function(){zR=null},im=function(t,e,n,r){return n&&(B9(t,e,n,r,-1)||B9(t,e,n,r,1))},CHe=/^(img|br|input|textarea|hr)$/i;function B9(t,e,n,r,i){for(var a;;){if(t==n&&e==r)return!0;if(e==(i<0?0:Ao(t))){let o=t.parentNode;if(!o||o.nodeType!=1||qy(t)||CHe.test(t.nodeName)||t.contentEditable=="false")return!1;e=_a(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?Ao(t):0}else return!1}}function Ao(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function kHe(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=Ao(t)}else if(t.parentNode&&!qy(t))e=_a(t),t=t.parentNode;else return null}}function jHe(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&&!qy(t))e=_a(t)+1,t=t.parentNode;else return null}}function PHe(t,e,n){for(let r=e==0,i=e==Ao(t);r||i;){if(t==n)return!0;let a=_a(t);if(t=t.parentNode,!t)return!1;r=r&&a==0,i=i&&a==Ao(t)}}function qy(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 wN=function(t){return t.focusNode&&im(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function af(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function RHe(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function DHe(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(Ao(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(Ao(r.startContainer),r.startOffset)}}}const ac=typeof navigator<"u"?navigator:null,$9=typeof document<"u"?document:null,gh=ac&&ac.userAgent||"",BR=/Edge\/(\d+)/.exec(gh),gne=/MSIE \d/.exec(gh),$R=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(gh),Ms=!!(gne||$R||BR),Gd=gne?document.documentMode:$R?+$R[1]:BR?+BR[1]:0,jo=!Ms&&/gecko\/(\d+)/i.test(gh);jo&&+(/Firefox\/(\d+)/.exec(gh)||[0,0])[1];const HR=!Ms&&/Chrome\/(\d+)/.exec(gh),na=!!HR,xne=HR?+HR[1]:0,Ta=!Ms&&!!ac&&/Apple Computer/.test(ac.vendor),Ug=Ta&&(/Mobile\/\w+/.test(gh)||!!ac&&ac.maxTouchPoints>2),_o=Ug||(ac?/Mac/.test(ac.platform):!1),bne=ac?/Win/.test(ac.platform):!1,tu=/Android \d/.test(gh),Ky=!!$9&&"webkitFontSmoothing"in $9.documentElement.style,OHe=Ky?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function LHe(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 zc(t,e){return typeof t=="number"?t:t[e]}function IHe(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 H9(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=Fg(o);continue}let l=o,c=l==a.body,u=c?LHe(a):IHe(l),d=0,f=0;if(e.top<u.top+zc(r,"top")?f=-(u.top-e.top+zc(i,"top")):e.bottom>u.bottom-zc(r,"bottom")&&(f=e.bottom-e.top>u.bottom-u.top?e.top+zc(i,"top")-u.top:e.bottom-u.bottom+zc(i,"bottom")),e.left<u.left+zc(r,"left")?d=-(u.left-e.left+zc(i,"left")):e.right>u.right-zc(r,"right")&&(d=e.right-u.right+zc(i,"right")),d||f)if(c)a.defaultView.scrollBy(d,f);else{let p=l.scrollLeft,b=l.scrollTop;f&&(l.scrollTop+=f),d&&(l.scrollLeft+=d);let v=l.scrollLeft-p,x=l.scrollTop-b;e={left:e.left-v,top:e.top-x,right:e.right-v,bottom:e.bottom-x}}let m=c?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(m))break;o=m=="absolute"?o.offsetParent:Fg(o)}}function FHe(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:yne(t.dom)}}function yne(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Fg(r));return e}function UHe({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;vne(n,r==0?0:r-e)}function vne(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 Rp=null;function zHe(t){if(t.setActive)return t.setActive();if(Rp)return t.focus(Rp);let e=yne(t);t.focus(Rp==null?{get preventScroll(){return Rp={preventScroll:!0},!0}}:void 0),Rp||(Rp=!1,vne(e,0))}function _ne(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 m;if(d.nodeType==1)m=d.getClientRects();else if(d.nodeType==3)m=Gc(d).getClientRects();else continue;for(let p=0;p<m.length;p++){let b=m[p];if(b.top<=o&&b.bottom>=l){o=Math.max(b.bottom,o),l=Math.min(b.top,l);let v=b.left>e.left?b.left-e.left:b.right<e.left?e.left-b.right:0;if(v<r){n=d,r=v,i=v&&n.nodeType==3?{left:b.right<e.left?b.right:b.left,top:e.top}:e,d.nodeType==1&&v&&(a=f+(e.left>=(b.left+b.right)/2?1:0));continue}}else b.top>e.top&&!c&&b.left<=e.left&&b.right>=e.left&&(c=d,u={left:Math.max(b.left,Math.min(b.right,e.left)),top:b.top});!n&&(e.left>=b.right&&e.top>=b.top||e.left>=b.left&&e.top>=b.bottom)&&(a=f+1)}}return!n&&c&&(n=c,i=u,r=0),n&&n.nodeType==3?BHe(n,i):!n||r&&n.nodeType==1?{node:t,offset:a}:_ne(n,i)}function BHe(t,e){let n=t.nodeValue.length,r=document.createRange(),i;for(let a=0;a<n;a++){r.setEnd(t,a+1),r.setStart(t,a);let o=md(r,1);if(o.top!=o.bottom&&RL(e,o)){i={node:t,offset:a+(e.left>=(o.left+o.right)/2?1:0)};break}}return r.detach(),i||{node:t,offset:0}}function RL(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function $He(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function HHe(t,e,n){let{node:r,offset:i}=_ne(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 VHe(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 wne(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(RL(e,u))return wne(o,e,u)}}if((a=(a+1)%r)==i)break}return t}function GHe(t,e){let n=t.dom.ownerDocument,r,i=0,a=DHe(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(!RL(e,u)||(o=wne(t.dom,e,u),!o))return null}if(Ta)for(let u=o;r&&u;u=Fg(u))u.draggable&&(r=void 0);if(o=$He(o,e),r){if(jo&&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;Ky&&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=VHe(t,r,i,e))}l==null&&(l=HHe(t,o,e));let c=t.docView.nearestDesc(o,!0);return{pos:l,inside:c?c.posAtStart-c.border:-1}}function V9(t){return t.top<t.bottom||t.left<t.right}function md(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(V9(r))return r}return Array.prototype.find.call(n,V9)||t.getBoundingClientRect()}const WHe=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Sne(t,e,n){let{node:r,offset:i,atom:a}=t.docView.domFromPos(e,n<0?-1:1),o=Ky||jo;if(r.nodeType==3)if(o&&(WHe.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let c=md(Gc(r,i,i),n);if(jo&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let u=md(Gc(r,i-1,i-1),-1);if(u.top==c.top){let d=md(Gc(r,i,i+1),-1);if(d.top!=c.top)return jb(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++,jb(md(Gc(r,c,u),d),d<0)}if(!t.state.doc.resolve(e-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==Ao(r))){let c=r.childNodes[i-1];if(c.nodeType==1)return _j(c.getBoundingClientRect(),!1)}if(a==null&&i<Ao(r)){let c=r.childNodes[i];if(c.nodeType==1)return _j(c.getBoundingClientRect(),!0)}return _j(r.getBoundingClientRect(),n>=0)}if(a==null&&i&&(n<0||i==Ao(r))){let c=r.childNodes[i-1],u=c.nodeType==3?Gc(c,Ao(c)-(o?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(u)return jb(md(u,1),!1)}if(a==null&&i<Ao(r)){let c=r.childNodes[i];for(;c.pmViewDesc&&c.pmViewDesc.ignoreForCoords;)c=c.nextSibling;let u=c?c.nodeType==3?Gc(c,0,o?0:1):c.nodeType==1?c:null:null;if(u)return jb(md(u,-1),!0)}return jb(md(r.nodeType==3?Gc(r):r,-n),n>=0)}function jb(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 _j(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 Mne(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 qHe(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return Mne(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=Sne(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=Gc(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 KHe=/[\u0590-\u08ac]/;function XHe(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?!KHe.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?a:o:Mne(t,e,()=>{let{focusNode:c,focusOffset:u,anchorNode:d,anchorOffset:f}=t.domSelectionRange(),m=l.caretBidiLevel;l.modify("move",n,"character");let p=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:b,focusOffset:v}=t.domSelectionRange(),x=b&&!p.contains(b.nodeType==1?b:b.parentNode)||c==b&&u==v;try{l.collapse(d,f),c&&(c!=d||u!=f)&&l.extend&&l.extend(c,u)}catch{}return m!=null&&(l.caretBidiLevel=m),x}):r.pos==r.start()||r.pos==r.end()}let G9=null,W9=null,q9=!1;function YHe(t,e,n){return G9==e&&W9==n?q9:(G9=e,W9=n,q9=n=="up"||n=="down"?qHe(t,e,n):XHe(t,e,n))}const Po=0,K9=1,gf=2,sc=3;class Xy{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=Po,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let i=this.children[n];if(i==e)return r;r+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let a,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>_a(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 Nne){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 Ene&&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?_a(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?_a(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 m=this.children[f-1];if(m.size&&m.dom.parentNode==this.contentDOM&&!m.emptyChildAt(1)){i=_a(m.dom)+1;break}e-=m.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=_a(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,b=0;p<this.children.length;p++){let v=this.children[p],x=b+v.size;if(a>b&&o<x)return v.setSelection(e-b-v.border,n-b-v.border,r,i);b=x}let l=this.domFromPos(e,e?-1:1),c=n==e?l:this.domFromPos(n,n?-1:1),u=r.root.getSelection(),d=r.domSelectionRange(),f=!1;if((jo||Ta)&&e==n){let{node:p,offset:b}=l;if(p.nodeType==3){if(f=!!(b&&p.nodeValue[b-1]==`
  8195. `),f&&b==p.nodeValue.length)for(let v=p,x;v;v=v.parentNode){if(x=v.nextSibling){x.nodeName=="BR"&&(l=c={node:x.parentNode,offset:_a(x)+1});break}let y=v.pmViewDesc;if(y&&y.node&&y.node.isBlock)break}}else{let v=p.childNodes[b-1];f=v&&(v.nodeName=="BR"||v.contentEditable=="false")}}if(jo&&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&&Ta)&&im(l.node,l.offset,d.anchorNode,d.anchorOffset)&&im(c.node,c.offset,d.focusNode,d.focusOffset))return;let m=!1;if((u.extend||e==n)&&!(f&&jo)){u.collapse(l.node,l.offset);try{e!=n&&u.extend(c.node,c.offset),m=!0}catch{}}if(!m){if(e>n){let b=l;l=c,c=b}let p=document.createRange();p.setEnd(c.node,c.offset),p.setStart(l.node,l.offset),u.removeAllRanges(),u.addRange(p)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,i=0;i<this.children.length;i++){let a=this.children[i],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?gf:K9,e==l&&n==c&&(a.contentLost||a.dom.parentNode!=this.contentDOM)?a.dirty=sc:a.markDirty(e-l,n-l);return}else a.dirty=a.dom==a.contentDOM&&a.dom.parentNode==this.contentDOM&&!a.children.length?gf:sc}r=o}this.dirty=gf}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?gf:K9;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Ene extends Xy{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==Po&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class ZHe extends Xy{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 am extends Xy{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=fm.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new am(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&sc||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=sc&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=Po){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Po}}slice(e,n,r){let i=am.create(this.parent,this.mark,!0,r),a=this.children,o=this.size;n<o&&(a=GR(a,n,o,r)),e>0&&(a=GR(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 Wd extends Xy{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}=fm.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 m=d;return d=Cne(d,r,n),u?c=new QHe(e,n,r,i,d,f||null,m,u,a,o+1):n.isText?new SN(e,n,r,i,d,m,a):new Wd(e,n,r,i,d,f||null,m,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=()=>At.empty)}return e}matchesNode(e,n,r){return this.dirty==Po&&e.eq(this.node)&&iM(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 eVe(this,o&&o.node,e);rVe(this.node,this.innerDeco,(u,d,f)=>{u.spec.marks?c.syncToMarks(u.spec.marks,r,e,d):u.type.side>=0&&!f&&c.syncToMarks(d==this.node.childCount?wr.none:this.node.child(d).marks,r,e,d),c.placeWidget(u,e,i)},(u,d,f,m)=>{c.syncToMarks(u.marks,r,e,m);let p;c.findNodeMatch(u,d,f,m)||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,m,i)||c.addNode(u,d,f,e,i),i+=u.nodeSize}),c.syncToMarks([],r,e,0),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||this.dirty==gf)&&(o&&this.protectLocalComposition(e,o),Ane(this.contentDOM,this.children,e),Ug&&iVe(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof fn)||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=aVe(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 ZHe(this,a,n,i);e.input.compositionNodes.push(o),this.children=GR(this.children,r,r+i.length,e,o)}update(e,n,r,i){return this.dirty==sc||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,i),!0)}updateInner(e,n,r,i){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=Po}updateOuterDeco(e){if(iM(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Tne(this.dom,this.nodeDOM,VR(this.outerDeco,this.node,n),VR(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 X9(t,e,n,r,i){Cne(r,e,t);let a=new Wd(void 0,t,e,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}class SN extends Wd{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==sc||this.dirty!=Po&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Po||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=Po,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let i=this.node.cut(e,n),a=document.createTextNode(i.text);return new SN(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=sc)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Nne extends Xy{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Po&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class QHe extends Wd{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==sc)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 Ane(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=Y9(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(l,r);if(o instanceof am){let c=r?r.previousSibling:t.lastChild;Ane(o.contentDOM,o.children,n),r=c?c.nextSibling:t.firstChild}}for(;r;)r=Y9(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const d0=function(t){t&&(this.nodeName=t)};d0.prototype=Object.create(null);const xf=[new d0];function VR(t,e,n){if(t.length==0)return xf;let r=n?xf[0]:new d0,i=[r];for(let a=0;a<t.length;a++){let o=t[a].type.attrs;if(o){o.nodeName&&i.push(r=new d0(o.nodeName));for(let l in o){let c=o[l];c!=null&&(n&&i.length==1&&i.push(r=new d0(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 Tne(t,e,n,r){if(n==xf&&r==xf)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=xf[0]),i=c}JHe(i,l||xf[0],o)}return i}function JHe(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 Cne(t,e,n){return Tne(t,t,xf,VR(e,n,t.nodeType!=1))}function iM(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 Y9(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class eVe{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=tVe(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,i){let a=0,o=this.stack.length>>1,l=Math.min(o,e.length);for(;a<l&&(a==o-1?this.top:this.stack[a+1<<1]).matchesMark(e[a])&&e[a].type.spec.spanning!==!1;)a++;for(;a<o;)this.destroyRest(),this.top.dirty=Po,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let c=-1,u=this.top.children.length;i<this.preMatch.index&&(u=Math.min(this.index+3,u));for(let d=this.index;d<u;d++){let f=this.top.children[d];if(f.matchesMark(e[o])&&!this.isLocked(f.dom)){c=d;break}}if(c>-1)c>this.index&&(this.changed=!0,this.destroyBetween(this.index,c)),this.top=this.top.children[this.index];else{let d=am.create(this.top,e[o],n,r);this.top.children.splice(this.index,0,d),this.top=d,this.changed=!0}this.index=0,o++}}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==sc&&o.dom==o.contentDOM&&(o.dirty=gf),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 Wd){let u=this.preMatch.matched.get(c);if(u!=null&&u!=a)return!1;let d=c.dom,f,m=this.isLocked(d)&&!(e.isText&&c.node&&c.node.isText&&c.nodeDOM.nodeValue==e.text&&c.dirty!=sc&&iM(n,c.outerDeco));if(!m&&c.update(e,n,r,i))return this.destroyBetween(this.index,l),c.dom!=d&&(this.changed=!0),this.index++,!0;if(!m&&(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=gf,f.updateChildren(i,o+1),f.dirty=Po),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)||!iM(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=Wd.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=Wd.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 Ene(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 am;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof SN)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Ta||na)&&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 Nne(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 tVe(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 am)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 nVe(t,e){return t.type.side-e.type.side}function rVe(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 x=i[o++];x.widget&&(d?(f||(f=[d])).push(x):d=x)}if(d)if(f){f.sort(nVe);for(let x=0;x<f.length;x++)n(f[x],u,!!c)}else n(d,u,!!c);let m,p;if(c)p=-1,m=c,c=null;else if(u<t.childCount)p=u,m=t.child(u++);else break;for(let x=0;x<l.length;x++)l[x].to<=a&&l.splice(x--,1);for(;o<i.length&&i[o].from<=a&&i[o].to>a;)l.push(i[o++]);let b=a+m.nodeSize;if(m.isText){let x=b;o<i.length&&i[o].from<x&&(x=i[o].from);for(let y=0;y<l.length;y++)l[y].to<x&&(x=l[y].to);x<b&&(c=m.cut(x-a),m=m.cut(0,x-a),b=x,p=-1)}else for(;o<i.length&&i[o].to<b;)o++;let v=m.isInline&&!m.isLeaf?l.filter(x=>!x.inline):l.slice();r(m,v,e.forChild(a,m),p),a=b}}function iVe(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 aVe(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 GR(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 DL(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(wN(n)){for(c=o;i&&!i.node;)i=i.parent;let f=i.node;if(i&&f.isAtom&&nn.isSelectable(f)&&i.parent&&!(f.isInline&&PHe(n.focusNode,n.focusOffset,i.dom))){let m=i.posBefore;u=new nn(o==m?l:r.resolve(m))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let f=o,m=o;for(let p=0;p<n.rangeCount;p++){let b=n.getRangeAt(p);f=Math.min(f,t.docView.posFromDOM(b.startContainer,b.startOffset,1)),m=Math.max(m,t.docView.posFromDOM(b.endContainer,b.endOffset,-1))}if(f<0)return null;[c,o]=m==t.state.selection.anchor?[m,f]:[f,m],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=OL(t,d,l,f)}return u}function kne(t){return t.editable?t.hasFocus():Pne(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function cu(t,e=!1){let n=t.state.selection;if(jne(t,n),!!kne(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&na){let r=t.domSelectionRange(),i=t.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&im(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)oVe(t);else{let{anchor:r,head:i}=n,a,o;Z9&&!(n instanceof fn)&&(n.$from.parent.inlineContent||(a=Q9(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=Q9(t,n.to))),t.docView.setSelection(r,i,t,e),Z9&&(a&&J9(a),o&&J9(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&sVe(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const Z9=Ta||na&&xne<63;function Q9(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(Ta&&i&&i.contentEditable=="false")return wj(i);if((!i||i.contentEditable=="false")&&(!a||a.contentEditable=="false")){if(i)return wj(i);if(a)return wj(a)}}function wj(t){return t.contentEditable="true",Ta&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function J9(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function sVe(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(()=>{(!kne(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function oVe(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,_a(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Ms&&Gd<=11&&(n.disabled=!0,n.disabled=!1)}function jne(t,e){if(e instanceof nn){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(eW(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else eW(t)}function eW(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function OL(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||fn.between(e,n,r)}function tW(t){return t.editable&&!t.hasFocus()?!1:Pne(t)}function Pne(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 lVe(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return im(e.node,e.offset,n.anchorNode,n.anchorOffset)}function WR(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&&En.findFrom(a,e)}function yd(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function nW(t,e,n){let r=t.state.selection;if(r instanceof fn)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 yd(t,new fn(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=WR(t.state,e);return i&&i instanceof nn?yd(t,i):!1}else if(!(_o&&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?nn.isSelectable(a)?yd(t,new nn(e<0?t.state.doc.resolve(i.pos-a.nodeSize):i)):Ky?yd(t,new fn(t.state.doc.resolve(e<0?l:l+a.nodeSize))):!1:!1}}else return!1;else{if(r instanceof nn&&r.node.isInline)return yd(t,new fn(e>0?r.$to:r.$from));{let i=WR(t.state,e);return i?yd(t,i):!1}}}function aM(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function h0(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Dp(t,e){return e<0?cVe(t):uVe(t)}function cVe(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,a,o=!1;for(jo&&n.nodeType==1&&r<aM(n)&&h0(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(h0(l,-1))i=n,a=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(Rne(n))break;{let l=n.previousSibling;for(;l&&h0(l,-1);)i=n.parentNode,a=_a(l),l=l.previousSibling;if(l)n=l,r=aM(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?qR(t,n,r):i&&qR(t,i,a)}function uVe(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=aM(n),a,o;for(;;)if(r<i){if(n.nodeType!=1)break;let l=n.childNodes[r];if(h0(l,1))a=n,o=++r;else break}else{if(Rne(n))break;{let l=n.nextSibling;for(;l&&h0(l,1);)a=l.parentNode,o=_a(l)+1,l=l.nextSibling;if(l)n=l,r=0,i=aM(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}a&&qR(t,a,o)}function Rne(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function dVe(t,e){for(;t&&e==t.childNodes.length&&!qy(t);)e=_a(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 hVe(t,e){for(;t&&!e&&!qy(t);)e=_a(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 qR(t,e,n){if(e.nodeType!=3){let a,o;(o=dVe(e,n))?(e=o,n=0):(a=hVe(e,n))&&(e=a,n=a.nodeValue.length)}let r=t.domSelection();if(!r)return;if(wN(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&&cu(t)},50)}function rW(t,e){let n=t.state.doc.resolve(e);if(!(na||bne)&&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 iW(t,e,n){let r=t.state.selection;if(r instanceof fn&&!r.empty||n.indexOf("s")>-1||_o&&n.indexOf("m")>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=WR(t.state,e);if(o&&o instanceof nn)return yd(t,o)}if(!i.parent.inlineContent){let o=e<0?i:a,l=r instanceof Ys?En.near(o,e):En.findFrom(o,e);return l?yd(t,l):!1}return!1}function aW(t,e){if(!(t.state.selection instanceof fn))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 sW(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function fVe(t){if(!Ta||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;sW(t,r,"true"),setTimeout(()=>sW(t,r,"false"),20)}return!1}function mVe(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function pVe(t,e){let n=e.keyCode,r=mVe(e);if(n==8||_o&&n==72&&r=="c")return aW(t,-1)||Dp(t,-1);if(n==46&&!e.shiftKey||_o&&n==68&&r=="c")return aW(t,1)||Dp(t,1);if(n==13||n==27)return!0;if(n==37||_o&&n==66&&r=="c"){let i=n==37?rW(t,t.state.selection.from)=="ltr"?-1:1:-1;return nW(t,i,r)||Dp(t,i)}else if(n==39||_o&&n==70&&r=="c"){let i=n==39?rW(t,t.state.selection.from)=="ltr"?1:-1:1;return nW(t,i,r)||Dp(t,i)}else{if(n==38||_o&&n==80&&r=="c")return iW(t,-1,r)||Dp(t,-1);if(n==40||_o&&n==78&&r=="c")return fVe(t)||iW(t,1,r)||Dp(t,1);if(r==(_o?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function LL(t,e){t.someProp("transformCopied",p=>{e=p(e,t)});let n=[],{content:r,openStart:i,openEnd:a}=e;for(;i>1&&a>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,a--;let p=r.firstChild;n.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let o=t.someProp("clipboardSerializer")||fm.fromSchema(t.state.schema),l=Une(),c=l.createElement("div");c.appendChild(o.serializeFragment(r,{document:l}));let u=c.firstChild,d,f=0;for(;u&&u.nodeType==1&&(d=Fne[u.nodeName.toLowerCase()]);){for(let p=d.length-1;p>=0;p--){let b=l.createElement(d[p]);for(;c.firstChild;)b.appendChild(c.firstChild);c.appendChild(b),f++}u=c.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${i} ${a}${f?` -${f}`:""} ${JSON.stringify(n)}`);let m=t.someProp("clipboardTextSerializer",p=>p(e,t))||e.content.textBetween(0,e.content.size,`
  8196. `);return{dom:c,text:m,slice:e}}function Dne(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",m=>{e=m(e,a||r,t)}),a)return l=new $t(At.from(t.state.schema.text(e.replace(/\r\n?/g,`
  8197. `))),0,0),t.someProp("transformPasted",m=>{l=m(l,t,!0)}),l;let f=t.someProp("clipboardTextParser",m=>m(e,i,r,t));if(f)l=f;else{let m=i.marks(),{schema:p}=t.state,b=fm.fromSchema(p);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(v=>{let x=o.appendChild(document.createElement("p"));v&&x.appendChild(b.serializeNode(p.text(v,m)))})}}else t.someProp("transformPastedHTML",f=>{n=f(n,t)}),o=yVe(n),Ky&&vVe(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 m=o.firstChild;for(;m&&m.nodeType!=1;)m=m.nextSibling;if(!m)break;o=m}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||c0.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||d),context:i,ruleFromNode(m){return m.nodeName=="BR"&&!m.nextSibling&&m.parentNode&&!gVe.test(m.parentNode.nodeName)?{ignore:!0}:null}})),d)l=_Ve(oW(l,+d[1],+d[2]),d[4]);else if(l=$t.maxOpen(xVe(l.content,i),!0),l.openStart||l.openEnd){let f=0,m=0;for(let p=l.content.firstChild;f<l.openStart&&!p.type.spec.isolating;f++,p=p.firstChild);for(let p=l.content.lastChild;m<l.openEnd&&!p.type.spec.isolating;m++,p=p.lastChild);l=oW(l,f,m)}return t.someProp("transformPasted",f=>{l=f(l,t,c)}),l}const gVe=/^(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 xVe(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&&Lne(c,a,l,o[o.length-1],0))o[o.length-1]=u;else{o.length&&(o[o.length-1]=Ine(o[o.length-1],a.length));let d=One(l,c);o.push(d),i=i.matchType(d.type),a=c}}),o)return At.from(o)}return t}function One(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,At.from(t));return t}function Lne(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let a=Lne(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(At.from(One(n,t,i+1))))}}function Ine(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,Ine(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(At.empty,!0);return t.copy(n.append(r))}function KR(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=KR(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(At.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function oW(t,e,n){return e<t.openStart&&(t=new $t(KR(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new $t(KR(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const Fne={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 lW=null;function Une(){return lW||(lW=document.implementation.createHTMLDocument("title"))}let Sj=null;function bVe(t){let e=window.trustedTypes;return e?(Sj||(Sj=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),Sj.createHTML(t)):t}function yVe(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=Une().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&Fne[r[1].toLowerCase()])&&(t=i.map(a=>"<"+a+">").join("")+t+i.map(a=>"</"+a+">").reverse().join("")),n.innerHTML=bVe(t),i)for(let a=0;a<i.length;a++)n=n.querySelector(i[a])||n;return n}function vVe(t){let e=t.querySelectorAll(na?"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 _Ve(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=At.from(c.create(r[l+1],i)),a++,o++}return new $t(i,a,o)}const rs={},is={},wVe={touchstart:!0,touchmove:!0};class SVe{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.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function MVe(t){for(let e in rs){let n=rs[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{NVe(t,r)&&!IL(t,r)&&(t.editable||!(r.type in is))&&n(t,r)},wVe[e]?{passive:!0}:void 0)}Ta&&t.dom.addEventListener("input",()=>null),XR(t)}function Dd(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function EVe(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 XR(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>IL(t,r))})}function IL(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function NVe(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 AVe(t,e){!IL(t,e)&&rs[e.type]&&(t.editable||!(e.type in is))&&rs[e.type](t,e)}is.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Bne(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(tu&&na&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Ug&&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,af(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||pVe(t,n)?n.preventDefault():Dd(t,"key")};is.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};is.keypress=(t,e)=>{let n=e;if(Bne(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||_o&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof fn)||!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 MN(t){return{left:t.clientX,top:t.clientY}}function TVe(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function FL(t,e,n,r,i){if(r==-1)return!1;let a=t.state.doc.resolve(r);for(let 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 ug(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 CVe(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&nn.isSelectable(r)?(ug(t,new nn(n)),!0):!1}function kVe(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof nn&&(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(nn.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?(ug(t,nn.create(t.state.doc,i)),!0):!1}function jVe(t,e,n,r,i){return FL(t,"handleClickOn",e,n,r)||t.someProp("handleClick",a=>a(t,e,r))||(i?kVe(t,n):CVe(t,n))}function PVe(t,e,n,r){return FL(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function RVe(t,e,n,r){return FL(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||DVe(t,n,r)}function DVe(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(ug(t,fn.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)ug(t,fn.create(r,l+1,l+1+o.content.size));else if(nn.isSelectable(o))ug(t,nn.create(r,l));else continue;return!0}}function UL(t){return sM(t)}const zne=_o?"metaKey":"ctrlKey";rs.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=UL(t),i=Date.now(),a="singleClick";i-t.input.lastClick.time<500&&TVe(n,t.input.lastClick)&&!n[zne]&&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(MN(n));o&&(a=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new OVe(t,o,n,!!r)):(a=="doubleClick"?PVe:RVe)(t,o.pos,o.inside,n)?n.preventDefault():Dd(t,"pointer"))};class OVe{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[zne],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 nn&&u.from<=o&&u.to>o)&&(this.mightDrag={node:a,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&jo&&!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)),Dd(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(()=>cu(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(MN(e))),this.updateAllowDefault(e),this.allowDefault||!n?Dd(this.view,"pointer"):jVe(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Ta&&this.mightDrag&&!this.mightDrag.node.isAtom||na&&!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)?(ug(this.view,En.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Dd(this.view,"pointer")}move(e){this.updateAllowDefault(e),Dd(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)}}rs.touchstart=t=>{t.input.lastTouch=Date.now(),UL(t),Dd(t,"pointer")};rs.touchmove=t=>{t.input.lastTouch=Date.now(),Dd(t,"pointer")};rs.contextmenu=t=>UL(t);function Bne(t,e){return t.composing?!0:Ta&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const LVe=tu?5e3:-1;is.compositionstart=is.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof fn&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||na&&bne&&IVe(t)))t.markCursor=t.state.storedMarks||n.marks(),sM(t,!0),t.markCursor=null;else if(sM(t,!e.selection.empty),jo&&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}$ne(t,LVe)};function IVe(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||e.nodeType!=1||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}is.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.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,$ne(t,20))};function $ne(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>sM(t),e))}function Hne(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=UVe());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function FVe(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=kHe(e.focusNode,e.focusOffset),r=jHe(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 UVe(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function sM(t,e=!1){if(!(tu&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Hne(t),e||t.docView&&t.docView.dirty){let n=DL(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 zVe(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 ay=Ms&&Gd<15||Ug&&OHe<604;rs.copy=is.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let a=ay?null:n.clipboardData,o=r.content(),{dom:l,text:c}=LL(t,o);a?(n.preventDefault(),a.clearData(),a.setData("text/html",l.innerHTML),a.setData("text/plain",c)):zVe(t,l),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function BVe(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function $Ve(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?sy(t,r.value,null,i,e):sy(t,r.textContent,r.innerHTML,i,e)},50)}function sy(t,e,n,r,i){let a=Dne(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",c=>c(t,i,a||$t.empty)))return!0;if(!a)return!1;let o=BVe(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 Vne(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," "):""}is.paste=(t,e)=>{let n=e;if(t.composing&&!tu)return;let r=ay?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&sy(t,Vne(r),r.getData("text/html"),i,n)?n.preventDefault():$Ve(t,n)};class Gne{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const HVe=_o?"altKey":"ctrlKey";function Wne(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[HVe]}rs.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(MN(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof nn?i.to-1:i.to))){if(r&&r.mightDrag)o=nn.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=nn.create(t.state.doc,f.posBefore))}}let l=(o||t.state.selection).content(),{dom:c,text:u,slice:d}=LL(t,l);(!n.dataTransfer.files.length||!na||xne>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(ay?"Text":"text/html",c.innerHTML),n.dataTransfer.effectAllowed="copyMove",ay||n.dataTransfer.setData("text/plain",u),t.dragging=new Gne(d,Wne(t,n),o)};rs.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};is.dragover=is.dragenter=(t,e)=>e.preventDefault();is.drop=(t,e)=>{try{VVe(t,e,t.dragging)}finally{t.dragging=null}};function VVe(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(MN(e));if(!r)return;let i=t.state.doc.resolve(r.pos),a=n&&n.slice;a?t.someProp("transformPasted",p=>{a=p(a,t,!1)}):a=Dne(t,Vne(e.dataTransfer),ay?null:e.dataTransfer.getData("text/html"),!1,i);let o=!!(n&&Wne(t,e));if(t.someProp("handleDrop",p=>p(t,e,a||$t.empty,o))){e.preventDefault();return}if(!a)return;e.preventDefault();let l=a?Yte(t.state.doc,i.pos,a):i.pos;l==null&&(l=i.pos);let c=t.state.tr;if(o){let{node:p}=n;p?p.replace(c):c.deleteSelection()}let u=c.mapping.map(l),d=a.openStart==0&&a.openEnd==0&&a.content.childCount==1,f=c.doc;if(d?c.replaceRangeWith(u,u,a.content.firstChild):c.replaceRange(u,u,a),c.doc.eq(f))return;let m=c.doc.resolve(u);if(d&&nn.isSelectable(a.content.firstChild)&&m.nodeAfter&&m.nodeAfter.sameMarkup(a.content.firstChild))c.setSelection(new nn(m));else{let p=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach((b,v,x,y)=>p=y),c.setSelection(OL(t,m,c.doc.resolve(p)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))}rs.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())&&cu(t)},20))};rs.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)};rs.beforeinput=(t,e)=>{if(na&&tu&&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,af(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 is)rs[t]=is[t];function oy(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 oM{constructor(e,n){this.toDOM=e,this.spec=n||jf,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 Qa(a-r,a-r,this)}valid(){return!0}eq(e){return this==e||e instanceof oM&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&oy(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class qd{constructor(e,n){this.attrs=e,this.spec=n||jf}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 Qa(a,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof qd&&oy(this.attrs,e.attrs)&&oy(this.spec,e.spec)}static is(e){return e.type instanceof qd}destroy(){}}class zL{constructor(e,n){this.attrs=e,this.spec=n||jf}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 Qa(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 zL&&oy(this.attrs,e.attrs)&&oy(this.spec,e.spec)}destroy(){}}class Qa{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Qa(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 Qa(e,e,new oM(n,r))}static inline(e,n,r,i){return new Qa(e,n,new qd(r,i))}static node(e,n,r,i){return new Qa(e,n,new zL(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof qd}get widget(){return this.type instanceof oM}}const $p=[],jf={};class Vr{constructor(e,n){this.local=e.length?e:$p,this.children=n.length?n:$p}static create(e,n){return n.length?lM(n,e,0,jf):La}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==La||e.maps.length==0?this:this.mapInner(e,n,0,0,r||jf)}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?GVe(this.children,o||[],e,n,r,i,a):o?new Vr(o.sort(Pf),$p):La}add(e,n){return n.length?this==La?Vr.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=Kne(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,lM(d,l,u+1,jf)),a+=3}});let o=qne(a?Xne(n):n,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new Vr(o.length?this.local.concat(o).sort(Pf):this.local,i||this.children)}remove(e){return e.length==0||this==La?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!=La?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 Vr(i,r):La}forChild(e,n){if(this==La)return this;if(n.isLeaf)return Vr.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 qd){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 Vr(i.sort(Pf),$p);return r?new Ed([l,r]):l}return r||La}eq(e){if(this==e)return!0;if(!(e instanceof Vr)||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 BL(this.localsInner(e))}localsInner(e){if(this==La)return $p;if(e.inlineContent||!this.local.some(qd.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof qd||n.push(this.local[r]);return n}forEachSet(e){e(this)}}Vr.empty=new Vr([],[]);Vr.removeOverlap=BL;const La=Vr.empty;class Ed{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,jf));return Ed.from(r)}forChild(e,n){if(n.isLeaf)return Vr.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(e,n);a!=La&&(a instanceof Ed?r=r.concat(a.members):r.push(a))}return Ed.from(r)}eq(e){if(!(e instanceof Ed)||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?BL(r?n:n.sort(Pf)):$p}static from(e){switch(e.length){case 0:return La;case 1:return e[0];default:return new Ed(e.every(n=>n instanceof Vr)?e:e.reduce((n,r)=>n.concat(r instanceof Vr?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function GVe(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((m,p,b,v)=>{let x=v-b-(p-m);for(let y=0;y<l.length;y+=3){let S=l[y+1];if(S<0||m>S+d-f)continue;let M=l[y]+d-f;p>=M?l[y+1]=m<=M?-2:-1:m>=d&&x&&(l[y]+=x,l[y+1]+=x)}f+=x}),d=n.maps[u].map(d,-1)}let c=!1;for(let u=0;u<l.length;u+=3)if(l[u+1]<0){if(l[u+1]==-2){c=!0,l[u+1]=-1;continue}let d=n.map(t[u]+a),f=d-i;if(f<0||f>=r.content.size){c=!0;continue}let m=n.map(t[u+1]+a,-1),p=m-i,{index:b,offset:v}=r.content.findIndex(f),x=r.maybeChild(b);if(x&&v==f&&v+x.nodeSize==p){let y=l[u+2].mapInner(n,x,d+1,t[u]+a+1,o);y!=La?(l[u]=f,l[u+1]=p,l[u+2]=y):(l[u+1]=-2,c=!0)}else c=!0}if(c){let u=WVe(l,t,e,n,i,a,o),d=lM(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,m=0;f<d.children.length;f+=3){let p=d.children[f];for(;m<l.length&&l[m]<p;)m+=3;l.splice(m,0,d.children[f],d.children[f+1],d.children[f+2])}}return new Vr(e.sort(Pf),l)}function qne(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 Qa(i.from+e,i.to+e,i.type))}return n}function WVe(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 Kne(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 Xne(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function lM(t,e,n,r){let i=[],a=!1;e.forEach((l,c)=>{let u=Kne(t,l,c+n);if(u){a=!0;let d=lM(u,l,n+c+1,r);d!=La&&i.push(c,c+l.nodeSize,d)}});let o=qne(a?Xne(t):t,-n).sort(Pf);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 Vr(o,i):La}function Pf(t,e){return t.from-e.from||t.to-e.to}function BL(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),cW(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),cW(e,i,r.copy(a.from,r.to)));break}}}return e}function cW(t,e,n){for(;e<t.length&&Pf(n,t[e])>0;)e++;t.splice(e,0,n)}function Mj(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=La&&e.push(r)}),t.cursorWrapper&&e.push(Vr.create(t.state.doc,[t.cursorWrapper.deco])),Ed.from(e)}const qVe={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},KVe=Ms&&Gd<=11;class XVe{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 YVe{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new XVe,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]);Ms&&Gd<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():Ta&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),KVe&&(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,qVe)),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(tW(this.view)){if(this.suppressingSelectionUpdates)return cu(this.view);if(Ms&&Gd<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&im(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=Fg(a))n.add(a);for(let a=e.anchorNode;a;a=Fg(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)&&tW(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(jo&&c.length){let d=c.filter(f=>f.nodeName=="BR");if(d.length==2){let[f,m]=d;f.parentNode&&f.parentNode.parentNode==m.parentNode?m.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let m of d){let p=m.parentNode;p&&p.nodeName=="LI"&&(!f||JVe(e,f)!=p)&&m.remove()}}}else if((na||Ta)&&c.some(d=>d.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let d of c)if(d.nodeName=="BR"&&d.parentNode){let f=d.nextSibling;f&&f.nodeType==1&&f.contentEditable=="false"&&d.parentNode.removeChild(d)}}let u=null;a<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&wN(r)&&(u=DL(e))&&u.eq(En.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,cu(e),this.currentSelection.set(r),e.scrollToSelection()):(a>-1||i)&&(a>-1&&(e.docView.markDirty(a,o),ZVe(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,eGe(e,c)),this.handleDOMChange(a,o,l,c),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||cu(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(Ms&&Gd<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:f,nextSibling:m}=e.addedNodes[d];(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(i=f),(!m||Array.prototype.indexOf.call(e.addedNodes,m)<0)&&(a=m)}let o=i&&i.parentNode==e.target?_a(i)+1:0,l=r.localPosFromDOM(e.target,o,-1),c=a&&a.parentNode==e.target?_a(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 uW=new WeakMap,dW=!1;function ZVe(t){if(!uW.has(t)&&(uW.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=jo,dW)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."),dW=!0}}function hW(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,a=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return im(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function QVe(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return hW(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?hW(t,n):null}function JVe(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 eGe(t,e){var n;let{focusNode:r,focusOffset:i}=t.domSelectionRange();for(let a of e)if(((n=a.parentNode)===null||n===void 0?void 0:n.nodeName)=="TR"){let o=a.nextSibling;for(;o&&o.nodeName!="TD"&&o.nodeName!="TH";)o=o.nextSibling;if(o){let l=o;for(;;){let c=l.firstChild;if(!c||c.nodeType!=1||c.contentEditable=="false"||/^(BR|IMG)$/.test(c.nodeName))break;l=c}l.insertBefore(a,l.firstChild),r==a&&t.domSelection().collapse(a,i)}else a.parentNode.removeChild(a)}}function tGe(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}],wN(c)||u.push({node:c.focusNode,offset:c.focusOffset})),na&&t.input.lastKeyCode===8)for(let x=a;x>i;x--){let y=r.childNodes[x-1],S=y.pmViewDesc;if(y.nodeName=="BR"&&!S){a=x;break}if(!S||S.size)break}let f=t.state.doc,m=t.someProp("domParser")||c0.fromSchema(t.state.schema),p=f.resolve(o),b=null,v=m.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:nGe,context:p});if(u&&u[0].pos!=null){let x=u[0].pos,y=u[1]&&u[1].pos;y==null&&(y=x),b={anchor:x+o,head:y+o}}return{doc:v,sel:b,from:o,to:l}}function nGe(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Ta&&/^(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||Ta&&/^(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 rGe=/^(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 iGe(t,e,n,r,i){let a=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let C=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,D=DL(t,C);if(D&&!t.state.selection.eq(D)){if(na&&tu&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",R=>R(t,af(13,"Enter"))))return;let T=t.state.tr.setSelection(D);C=="pointer"?T.setMeta("pointer",!0):C=="key"&&T.scrollIntoView(),a&&T.setMeta("composition",a),t.dispatch(T)}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=tGe(t,e,n),d=t.state.doc,f=d.slice(u.from,u.to),m,p;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(m=t.state.selection.to,p="end"):(m=t.state.selection.from,p="start"),t.input.lastKeyCode=null;let b=oGe(f.content,u.doc.content,u.from,m,p);if(b&&t.input.domChangeCount++,(Ug&&t.input.lastIOSEnter>Date.now()-225||tu)&&i.some(C=>C.nodeType==1&&!rGe.test(C.nodeName))&&(!b||b.endA>=b.endB)&&t.someProp("handleKeyDown",C=>C(t,af(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!b)if(r&&c instanceof fn&&!c.empty&&c.$head.sameParent(c.$anchor)&&!t.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))b={start:c.from,endA:c.to,endB:c.to};else{if(u.sel){let C=fW(t,t.state.doc,u.sel);if(C&&!C.eq(t.state.selection)){let D=t.state.tr.setSelection(C);a&&D.setMeta("composition",a),t.dispatch(D)}}return}t.state.selection.from<t.state.selection.to&&b.start==b.endB&&t.state.selection instanceof fn&&(b.start>t.state.selection.from&&b.start<=t.state.selection.from+2&&t.state.selection.from>=u.from?b.start=t.state.selection.from:b.endA<t.state.selection.to&&b.endA>=t.state.selection.to-2&&t.state.selection.to<=u.to&&(b.endB+=t.state.selection.to-b.endA,b.endA=t.state.selection.to)),Ms&&Gd<=11&&b.endB==b.start+1&&b.endA==b.start&&b.start>u.from&&u.doc.textBetween(b.start-u.from-1,b.start-u.from+1)=="  "&&(b.start--,b.endA--,b.endB--);let v=u.doc.resolveNoCache(b.start-u.from),x=u.doc.resolveNoCache(b.endB-u.from),y=d.resolve(b.start),S=v.sameParent(x)&&v.parent.inlineContent&&y.end()>=b.endA;if((Ug&&t.input.lastIOSEnter>Date.now()-225&&(!S||i.some(C=>C.nodeName=="DIV"||C.nodeName=="P"))||!S&&v.pos<u.doc.content.size&&(!v.sameParent(x)||!v.parent.inlineContent)&&v.pos<x.pos&&!/\S/.test(u.doc.textBetween(v.pos,x.pos,"","")))&&t.someProp("handleKeyDown",C=>C(t,af(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>b.start&&sGe(d,b.start,b.endA,v,x)&&t.someProp("handleKeyDown",C=>C(t,af(8,"Backspace")))){tu&&na&&t.domObserver.suppressSelectionUpdates();return}na&&b.endB==b.start&&(t.input.lastChromeDelete=Date.now()),tu&&!S&&v.start()!=x.start()&&x.parentOffset==0&&v.depth==x.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==b.endA&&(b.endB-=2,x=u.doc.resolveNoCache(b.endB-u.from),setTimeout(()=>{t.someProp("handleKeyDown",function(C){return C(t,af(13,"Enter"))})},20));let M=b.start,N=b.endA,A=C=>{let D=C||t.state.tr.replace(M,N,u.doc.slice(b.start-u.from,b.endB-u.from));if(u.sel){let T=fW(t,D.doc,u.sel);T&&!(na&&t.composing&&T.empty&&(b.start!=b.endB||t.input.lastChromeDelete<Date.now()-100)&&(T.head==M||T.head==D.mapping.map(N)-1)||Ms&&T.empty&&T.head==M)&&D.setSelection(T)}return a&&D.setMeta("composition",a),D.scrollIntoView()},k;if(S)if(v.pos==x.pos){Ms&&Gd<=11&&v.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>cu(t),20));let C=A(t.state.tr.delete(M,N)),D=d.resolve(b.start).marksAcross(d.resolve(b.endA));D&&C.ensureMarks(D),t.dispatch(C)}else if(b.endA==b.endB&&(k=aGe(v.parent.content.cut(v.parentOffset,x.parentOffset),y.parent.content.cut(y.parentOffset,b.endA-y.start())))){let C=A(t.state.tr);k.type=="add"?C.addMark(M,N,k.mark):C.removeMark(M,N,k.mark),t.dispatch(C)}else if(v.parent.child(v.index()).isText&&v.index()==x.index()-(x.textOffset?0:1)){let C=v.parent.textBetween(v.parentOffset,x.parentOffset),D=()=>A(t.state.tr.insertText(C,M,N));t.someProp("handleTextInput",T=>T(t,M,N,C,D))||t.dispatch(D())}else t.dispatch(A());else t.dispatch(A())}function fW(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:OL(t,e.resolve(n.anchor),e.resolve(n.head))}function aGe(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(At.from(u).eq(t))return{mark:l,type:o}}function sGe(t,e,n,r,i){if(n-e<=i.pos-r.pos||Ej(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(Ej(a,!0,!0));return!o.parent.isTextblock||o.pos>n||Ej(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Ej(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 oGe(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&&mW(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&&mW(t.textBetween(a-1,a+1))&&(a+=c?1:-1),o=a+(o-l),l=a}return{start:a,endA:o,endB:l}}function mW(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 Yne{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 SVe,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(yW),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=xW(this),gW(this),this.nodeViews=bW(this),this.docView=X9(this.state.doc,pW(this),Mj(this),this.dom,this),this.domObserver=new YVe(this,(r,i,a,o)=>iGe(this,r,i,a,o)),this.domObserver.start(),MVe(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&&XR(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(yW),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&&(Hne(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=bW(this);cGe(p,this.nodeViews)&&(this.nodeViews=p,a=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&XR(this),this.editable=xW(this),gW(this);let c=Mj(this),u=pW(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 m=d=="preserve"&&o&&this.dom.style.overflowAnchor==null&&FHe(this);if(o){this.domObserver.stop();let p=f&&(Ms||na)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&lGe(i.selection,e.selection);if(f){let b=na?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=FVe(this)),(a||!this.docView.update(e.doc,u,c,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=X9(e.doc,u,c,this.dom,this)),b&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&lVe(this))?cu(this,p):(jne(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():m&&UHe(m)}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 nn){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&H9(this,n.getBoundingClientRect(),e)}else H9(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 Gne(e.slice,e.move,i<0?void 0:nn.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(Ms){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&&zHe(this.dom),cu(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 GHe(this,e)}coordsAtPos(e,n=1){return Sne(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 YHe(this,n||this.state,e)}pasteHTML(e,n){return sy(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return sy(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return LL(this,e)}destroy(){this.docView&&(EVe(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Mj(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,THe())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return AVe(this,e)}domSelectionRange(){let e=this.domSelection();return e?Ta&&this.root.nodeType===11&&RHe(this.dom.ownerDocument)==this.dom&&QVe(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}Yne.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function pW(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"),[Qa.node(0,t.state.doc.content.size,e)]}function gW(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:Qa.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function xW(t){return!t.someProp("editable",e=>e(t.state)===!1)}function lGe(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 bW(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 cGe(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 yW(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 ah={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:"'"},cM={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},uGe=typeof navigator<"u"&&/Mac/.test(navigator.platform),dGe=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var wa=0;wa<10;wa++)ah[48+wa]=ah[96+wa]=String(wa);for(var wa=1;wa<=24;wa++)ah[wa+111]="F"+wa;for(var wa=65;wa<=90;wa++)ah[wa]=String.fromCharCode(wa+32),cM[wa]=String.fromCharCode(wa);for(var Nj in ah)cM.hasOwnProperty(Nj)||(cM[Nj]=ah[Nj]);function hGe(t){var e=uGe&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||dGe&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?cM:ah)[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 fGe=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),mGe=typeof navigator<"u"&&/Win/.test(navigator.platform);function pGe(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))fGe?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 gGe(t){let e=Object.create(null);for(let n in t)e[pGe(n)]=t[n];return e}function Aj(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 xGe(t){return new Yr({props:{handleKeyDown:Zne(t)}})}function Zne(t){let e=gGe(t);return function(n,r){let i=hGe(r),a,o=e[Aj(i,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[Aj(i,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(mGe&&r.ctrlKey&&r.altKey)&&(a=ah[r.keyCode])&&a!=i){let l=e[Aj(a,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var bGe=Object.defineProperty,$L=(t,e)=>{for(var n in e)bGe(t,n,{get:e[n],enumerable:!0})};function EN(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 NN=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,m])=>[f,(...b)=>{const v=this.buildProps(c,e),x=m(...b)(v);return o.push(x),d}])),run:u};return d}createCan(t){const{rawCommands:e,state:n}=this,r=!1,i=t||n.tr,a=this.buildProps(i,r);return{...Object.fromEntries(Object.entries(e).map(([l,c])=>[l,(...u)=>c(...u)({...a,dispatch:void 0})])),chain:()=>this.createChain(i,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o={tr:t,editor:r,view:a,state:EN({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}},Qne={};$L(Qne,{blur:()=>yGe,clearContent:()=>vGe,clearNodes:()=>_Ge,command:()=>wGe,createParagraphNear:()=>SGe,cut:()=>MGe,deleteCurrentNode:()=>EGe,deleteNode:()=>NGe,deleteRange:()=>AGe,deleteSelection:()=>TGe,enter:()=>CGe,exitCode:()=>kGe,extendMarkRange:()=>jGe,first:()=>PGe,focus:()=>DGe,forEach:()=>OGe,insertContent:()=>LGe,insertContentAt:()=>UGe,joinBackward:()=>$Ge,joinDown:()=>BGe,joinForward:()=>HGe,joinItemBackward:()=>VGe,joinItemForward:()=>GGe,joinTextblockBackward:()=>WGe,joinTextblockForward:()=>qGe,joinUp:()=>zGe,keyboardShortcut:()=>XGe,lift:()=>YGe,liftEmptyBlock:()=>ZGe,liftListItem:()=>QGe,newlineInCode:()=>JGe,resetAttributes:()=>e7e,scrollIntoView:()=>t7e,selectAll:()=>n7e,selectNodeBackward:()=>r7e,selectNodeForward:()=>i7e,selectParentNode:()=>a7e,selectTextblockEnd:()=>s7e,selectTextblockStart:()=>o7e,setContent:()=>l7e,setMark:()=>T7e,setMeta:()=>C7e,setNode:()=>k7e,setNodeSelection:()=>j7e,setTextDirection:()=>P7e,setTextSelection:()=>R7e,sinkListItem:()=>D7e,splitBlock:()=>O7e,splitListItem:()=>L7e,toggleList:()=>I7e,toggleMark:()=>F7e,toggleNode:()=>U7e,toggleWrap:()=>z7e,undoInputRule:()=>B7e,unsetAllMarks:()=>$7e,unsetMark:()=>H7e,unsetTextDirection:()=>V7e,updateAttributes:()=>G7e,wrapIn:()=>W7e,wrapInList:()=>q7e});var yGe=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),vGe=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),_Ge=()=>({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)),m=u.resolve(d.map(c+l.nodeSize)),p=f.blockRange(m);if(!p)return;const b=hx(p);if(l.type.isTextblock){const{defaultType:v}=f.parent.contentMatchAt(f.index());e.setNodeMarkup(p.start,v)}(b||b===0)&&e.lift(p,b)})}),!0},wGe=t=>e=>t(e),SGe=()=>({state:t,dispatch:e})=>hne(t,e),MGe=(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 fn(r.doc.resolve(Math.max(o-1,0)))),!0},EGe=()=>({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 Ti(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 NGe=t=>({tr:e,state:n,dispatch:r})=>{const i=Ti(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},AGe=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},TGe=()=>({state:t,dispatch:e})=>TL(t,e),CGe=()=>({commands:t})=>t.keyboardShortcut("Enter"),kGe=()=>({state:t,dispatch:e})=>fHe(t,e);function HL(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function uM(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:HL(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function Jne(t,e,n={}){return t.find(r=>r.type===e&&uM(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function vW(t,e,n={}){return!!Jne(t,e,n)}function VL(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),!Jne([...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&&vW([...t.parent.child(o-1).marks],e,n);)o-=1,l-=t.parent.child(o).nodeSize;for(;c<t.parent.childCount&&vW([...t.parent.child(c).marks],e,n);)u+=t.parent.child(c).nodeSize,c+=1;return{from:l,to:u}}function Tu(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}var jGe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const a=Tu(t,r.schema),{doc:o,selection:l}=n,{$from:c,from:u,to:d}=l;if(i){const f=VL(c,a,e);if(f&&f.from<=u&&f.to>=d){const m=fn.create(o,f.from,f.to);n.setSelection(m)}}return!0},PGe=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 ere(t){return t instanceof fn}function bf(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function tre(t,e=null){if(!e)return null;const n=En.atStart(t),r=En.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,a=r.to;return e==="all"?fn.create(t,bf(0,i,a),bf(t.content.size,i,a)):fn.create(t,bf(e,i,a),bf(e,i,a))}function _W(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function dM(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function RGe(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var DGe=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:a})=>{e={scrollIntoView:!0,...e};const o=()=>{(dM()||_W())&&r.dom.focus(),RGe()&&!dM()&&!_W()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};if(r.hasFocus()&&t===null||t===!1)return!0;if(a&&t===null&&!ere(n.state.selection))return o(),!0;const l=tre(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},OGe=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),LGe=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),nre=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&&nre(r)}return t};function D1(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 nre(n)}function ly(t,e,n){if(t instanceof Vd||t instanceof At)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 At.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),ly("",e,n)}if(i){if(n.errorOnInvalidContent){let o=!1,l="";const c=new Ute({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?c0.fromSchema(c).parseSlice(D1(t),n.parseOptions):c0.fromSchema(c).parse(D1(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const a=c0.fromSchema(e);return n.slice?a.parseSlice(D1(t),n.parseOptions).content:a.parse(D1(t),n.parseOptions)}return ly("",e,n)}function IGe(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof Ji||i instanceof ra))return;const a=t.mapping.maps[r];let o=0;a.forEach((l,c,u,d)=>{o===0&&(o=d)}),t.setSelection(En.near(t.doc.resolve(o),n))}var FGe=t=>!("type"in t),UGe=(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=x=>{a.emit("contentError",{editor:a,error:x,disableCollaboration:()=>{"collaboration"in a.storage&&typeof a.storage.collaboration=="object"&&a.storage.collaboration&&(a.storage.collaboration.isDisabled=!0)}})},u={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!a.options.enableContentCheck&&a.options.emitContentError)try{ly(e,a.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(x){c(x)}try{l=ly(e,a.schema,{parseOptions:u,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:a.options.enableContentCheck})}catch(x){return c(x),!1}let{from:d,to:f}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},m=!0,p=!0;if((FGe(l)?l:[l]).forEach(x=>{x.check(),m=m?x.isText&&x.marks.length===0:!1,p=p?x.isBlock:!1}),d===f&&p){const{parent:x}=r.doc.resolve(d);x.isTextblock&&!x.type.spec.code&&!x.childCount&&(d-=1,f+=1)}let v;if(m){if(Array.isArray(e))v=e.map(x=>x.text||"").join("");else if(e instanceof At){let x="";e.forEach(y=>{y.text&&(x+=y.text)}),v=x}else typeof e=="object"&&e&&e.text?v=e.text:v=e;r.insertText(v,d,f)}else{v=l;const x=r.doc.resolve(d),y=x.node(),S=x.parentOffset===0,M=y.isText||y.isTextblock,N=y.content.size>0;S&&M&&N&&(d=Math.max(0,d-1)),r.replaceWith(d,f,v)}n.updateSelection&&IGe(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:v}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:v})}return!0},zGe=()=>({state:t,dispatch:e})=>uHe(t,e),BGe=()=>({state:t,dispatch:e})=>dHe(t,e),$Ge=()=>({state:t,dispatch:e})=>ane(t,e),HGe=()=>({state:t,dispatch:e})=>cne(t,e),VGe=()=>({state:t,dispatch:e,tr:n})=>{try{const r=yN(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},GGe=()=>({state:t,dispatch:e,tr:n})=>{try{const r=yN(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},WGe=()=>({state:t,dispatch:e})=>lHe(t,e),qGe=()=>({state:t,dispatch:e})=>cHe(t,e);function rre(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function KGe(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))dM()||rre()?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 XGe=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const a=KGe(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 sh(t,e,n={}){const{from:r,to:i,empty:a}=t.selection,o=e?Ti(e,t.schema):null,l=[];t.doc.nodesBetween(r,i,(f,m)=>{if(f.isText)return;const p=Math.max(r,m),b=Math.min(i,m+f.nodeSize);l.push({node:f,from:p,to:b})});const c=i-r,u=l.filter(f=>o?o.name===f.node.type.name:!0).filter(f=>uM(f.node.attrs,n,{strict:!1}));return a?!!u.length:u.reduce((f,m)=>f+m.to-m.from,0)>=c}var YGe=(t,e={})=>({state:n,dispatch:r})=>{const i=Ti(t,n.schema);return sh(n,i,e)?hHe(n,r):!1},ZGe=()=>({state:t,dispatch:e})=>fne(t,e),QGe=t=>({state:e,dispatch:n})=>{const r=Ti(t,e.schema);return MHe(r)(e,n)},JGe=()=>({state:t,dispatch:e})=>dne(t,e);function AN(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function wW(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 e7e=(t,e)=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null;const l=AN(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(a=Ti(t,r.schema)),l==="mark"&&(o=Tu(t,r.schema));let c=!1;return n.selection.ranges.forEach(u=>{r.doc.nodesBetween(u.$from.pos,u.$to.pos,(d,f)=>{a&&a===d.type&&(c=!0,i&&n.setNodeMarkup(f,void 0,wW(d.attrs,e))),o&&d.marks.length&&d.marks.forEach(m=>{o===m.type&&(c=!0,i&&n.addMark(f,f+d.nodeSize,o.create(wW(m.attrs,e))))})})}),c},t7e=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),n7e=()=>({tr:t,dispatch:e})=>{if(e){const n=new Ys(t.doc);t.setSelection(n)}return!0},r7e=()=>({state:t,dispatch:e})=>one(t,e),i7e=()=>({state:t,dispatch:e})=>une(t,e),a7e=()=>({state:t,dispatch:e})=>gHe(t,e),s7e=()=>({state:t,dispatch:e})=>yHe(t,e),o7e=()=>({state:t,dispatch:e})=>bHe(t,e);function YR(t,e,n={},r={}){return ly(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var l7e=(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=YR(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 ire(t,e){const n=Tu(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 are(t,e){const n=new tne(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function c7e(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 u7e(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,a)=>{n(i)&&r.push({node:i,pos:a})}),r}function d7e(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 TN(t){return e=>d7e(e.$from,t)}function en(t,e,n){return t.config[e]===void 0&&t.parent?en(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?en(t.parent,e,n):null}):t.config[e]}function GL(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=en(e,"addExtensions",n);return r?[e,...GL(r())]:e}).flat(10)}function WL(t,e){const n=fm.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function sre(t){return typeof t=="function"}function or(t,e=void 0,...n){return sre(t)?e?t.bind(e)(...n):t(...n):t}function h7e(t={}){return Object.keys(t).length===0&&t.constructor===Object}function zg(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 ore(t){const e=[],{nodeExtensions:n,markExtensions:r}=zg(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=en(o,"addGlobalAttributes",l);if(!c)return;c().forEach(d=>{d.types.forEach(f=>{Object.entries(d.attributes).forEach(([m,p])=>{e.push({type:f,name:m,attribute:{...a,...p}})})})})}),i.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage},c=en(o,"addAttributes",l);if(!c)return;const u=c();Object.entries(u).forEach(([d,f])=>{const m={...a,...f};typeof m?.default=="function"&&(m.default=m.default()),m?.isRequired&&m?.default===void 0&&delete m.default,e.push({type:o.name,name:d,attribute:m})})}),e}function li(...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,m]=d.split(":").map(p=>p.trim());u.set(f,m)}),l.forEach(d=>{const[f,m]=d.split(":").map(p=>p.trim());u.set(f,m)}),r[i]=Array.from(u.entries()).map(([d,f])=>`${d}: ${f}`).join("; ")}else r[i]=a}),r},{})}function cy(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)=>li(n,r),{})}function f7e(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function SW(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):f7e(n.getAttribute(o.name));return l==null?a:{...a,[o.name]:l}},{});return{...r,...i}}}}function MW(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&h7e(n)?!1:n!=null))}function EW(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 m7e(t,e){var n;const r=ore(t),{nodeExtensions:i,markExtensions:a}=zg(t),o=(n=i.find(u=>en(u,"topNode")))==null?void 0:n.name,l=Object.fromEntries(i.map(u=>{const d=r.filter(y=>y.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:e},m=t.reduce((y,S)=>{const M=en(S,"extendNodeSchema",f);return{...y,...M?M(u):{}}},{}),p=MW({...m,content:or(en(u,"content",f)),marks:or(en(u,"marks",f)),group:or(en(u,"group",f)),inline:or(en(u,"inline",f)),atom:or(en(u,"atom",f)),selectable:or(en(u,"selectable",f)),draggable:or(en(u,"draggable",f)),code:or(en(u,"code",f)),whitespace:or(en(u,"whitespace",f)),linebreakReplacement:or(en(u,"linebreakReplacement",f)),defining:or(en(u,"defining",f)),isolating:or(en(u,"isolating",f)),attrs:Object.fromEntries(d.map(EW))}),b=or(en(u,"parseHTML",f));b&&(p.parseDOM=b.map(y=>SW(y,d)));const v=en(u,"renderHTML",f);v&&(p.toDOM=y=>v({node:y,HTMLAttributes:cy(y,d)}));const x=en(u,"renderText",f);return x&&(p.toText=x),[u.name,p]})),c=Object.fromEntries(a.map(u=>{const d=r.filter(x=>x.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:e},m=t.reduce((x,y)=>{const S=en(y,"extendMarkSchema",f);return{...x,...S?S(u):{}}},{}),p=MW({...m,inclusive:or(en(u,"inclusive",f)),excludes:or(en(u,"excludes",f)),group:or(en(u,"group",f)),spanning:or(en(u,"spanning",f)),code:or(en(u,"code",f)),attrs:Object.fromEntries(d.map(EW))}),b=or(en(u,"parseHTML",f));b&&(p.parseDOM=b.map(x=>SW(x,d)));const v=en(u,"renderHTML",f);return v&&(p.toDOM=x=>v({mark:x,HTMLAttributes:cy(x,d)})),[u.name,p]}));return new Ute({topNode:o,nodes:l,marks:c})}function p7e(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function hM(t){return t.sort((n,r)=>{const i=en(n,"priority")||100,a=en(r,"priority")||100;return i>a?-1:i<a?1:0})}function lre(t){const e=hM(GL(t)),n=p7e(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 cre(t,e,n){const{from:r,to:i}=e,{blockSeparator:a=`
  8198. `,textSerializers:o={}}=n||{};let l="";return t.nodesBetween(r,i,(c,u,d,f)=>{var m;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+=(m=c?.text)==null?void 0:m.slice(Math.max(r,u)-u,i-u))}),l}function g7e(t,e){const n={from:0,to:t.content.size};return cre(t,n,e)}function ure(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function x7e(t,e){const n=Ti(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 dre(t,e){const n=AN(typeof e=="string"?e:e.name,t.schema);return n==="node"?x7e(t,e):n==="mark"?ire(t,e):{}}function b7e(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 y7e(t){const e=b7e(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 hre(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),m=e.invert().map(d);r.push({oldRange:{from:f,to:m},newRange:{from:u,to:d}})})}),y7e(r)}function qL(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const a=n.resolve(t),o=VL(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 v7e=(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 O1(t,e){return e.nodes[t]||e.marks[t]||null}function yw(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 _7e=(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 ZR(t,e,n={}){const{empty:r,ranges:i}=t.selection,a=e?Tu(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(f=>a?a.name===f.type.name:!0).find(f=>uM(f.attrs,n,{strict:!1}));let o=0;const l=[];if(i.forEach(({$from:f,$to:m})=>{const p=f.pos,b=m.pos;t.doc.nodesBetween(p,b,(v,x)=>{if(!v.isText&&!v.marks.length)return;const y=Math.max(p,x),S=Math.min(b,x+v.nodeSize),M=S-y;o+=M,l.push(...v.marks.map(N=>({mark:N,from:y,to:S})))})}),o===0)return!1;const c=l.filter(f=>a?a.name===f.mark.type.name:!0).filter(f=>uM(f.mark.attrs,n,{strict:!1})).reduce((f,m)=>f+m.to-m.from,0),u=l.filter(f=>a?f.mark.type!==a&&f.mark.type.excludes(a):!0).reduce((f,m)=>f+m.to-m.from,0);return(c>0?c+u:c)>=o}function w7e(t,e,n={}){if(!e)return sh(t,null,n)||ZR(t,null,n);const r=AN(e,t.schema);return r==="node"?sh(t,e,n):r==="mark"?ZR(t,e,n):!1}var S7e=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const a=TN(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)},M7e=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function NW(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function AW(t,e){const{nodeExtensions:n}=zg(e),r=n.find(o=>o.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},a=or(en(r,"group",i));return typeof a!="string"?!1:a.split(" ").includes("list")}function CN(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&&(CN(a,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function fre(t){return t instanceof nn}var mre=class pre{constructor(e){this.position=e}static fromJSON(e){return new pre(e.position)}toJSON(){return{position:this.position}}};function E7e(t,e){const n=e.mapping.mapResult(t.position);return{position:new mre(n.pos),mapResult:n}}function N7e(t){return new mre(t)}function A7e(t,e,n){var r;const{selection:i}=e;let a=null;if(ere(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,m)=>{if(u)return!1;if(d.isInline){const p=!m||m.type.allowsMarkType(n),b=!!n.isInSet(d.marks)||!d.marks.some(v=>v.type.excludes(n));u=p&&b}return!u}),u})}var T7e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:a}=n,{empty:o,ranges:l}=a,c=Tu(t,r.schema);if(i)if(o){const u=ire(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,(m,p)=>{const b=Math.max(p,d),v=Math.min(p+m.nodeSize,f);m.marks.find(y=>y.type===c)?m.marks.forEach(y=>{c===y.type&&n.addMark(b,v,c.create({...y.attrs,...e}))}):n.addMark(b,v,c.create(e))})});return A7e(r,n,c)},C7e=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),k7e=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const a=Ti(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})=>z9(a,{...o,...e})(n)?!0:l.clearNodes()).command(({state:l})=>z9(a,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},j7e=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=bf(t,0,r.content.size),a=nn.create(r,i);e.setSelection(a)}return!0},P7e=(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},R7e=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:a}=typeof t=="number"?{from:t,to:t}:t,o=fn.atStart(r).from,l=fn.atEnd(r).to,c=bf(i,o,l),u=bf(a,o,l),d=fn.create(r,c,u);e.setSelection(d)}return!0},D7e=t=>({state:e,dispatch:n})=>{const r=Ti(t,e.schema);return AHe(r)(e,n)};function TW(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 O7e=({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=yw(u,l.node().type.name,l.node().attrs);if(a instanceof nn&&a.node.isBlock)return!l.parentOffset||!lu(o,l.pos)?!1:(r&&(t&&TW(n,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const f=c.parentOffset===c.parent.content.size,m=l.depth===0?void 0:c7e(l.node(-1).contentMatchAt(l.indexAfter(-1)));let p=f&&m?[{type:m,attrs:d}]:void 0,b=lu(e.doc,e.mapping.map(l.pos),1,p);if(!p&&!b&&lu(e.doc,e.mapping.map(l.pos),1,m?[{type:m}]:void 0)&&(b=!0,p=m?[{type:m,attrs:d}]:void 0),r){if(b&&(a instanceof fn&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,p),m&&!f&&!l.parentOffset&&l.parent.type!==m)){const v=e.mapping.map(l.before()),x=e.doc.resolve(v);l.node(-1).canReplaceWith(x.index(),x.index()+1,m)&&e.setNodeMarkup(e.mapping.map(l.before()),m)}t&&TW(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return b},L7e=(t,e={})=>({tr:n,state:r,dispatch:i,editor:a})=>{var o;const l=Ti(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 m=a.extensionManager.attributes;if(c.parent.content.size===0&&c.node(-1).childCount===c.indexAfter(-1)){if(c.depth===2||c.node(-3).type!==l||c.index(-2)!==c.node(-2).childCount-1)return!1;if(i){let y=At.empty;const S=c.index(-1)?1:c.index(-2)?2:3;for(let D=c.depth-S;D>=c.depth-3;D-=1)y=At.from(c.node(D).copy(y));const M=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,N={...yw(m,c.node().type.name,c.node().attrs),...e},A=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(N))||void 0;y=y.append(At.from(l.createAndFill(null,A)||void 0));const k=c.before(c.depth-(S-1));n.replace(k,c.after(-M),new $t(y,4-S,0));let C=-1;n.doc.nodesBetween(k,n.doc.content.size,(D,T)=>{if(C>-1)return!1;D.isTextblock&&D.content.size===0&&(C=T+1)}),C>-1&&n.setSelection(fn.near(n.doc.resolve(C))),n.scrollIntoView()}return!0}const p=u.pos===c.end()?f.contentMatchAt(0).defaultType:null,b={...yw(m,f.type.name,f.attrs),...e},v={...yw(m,c.node().type.name,c.node().attrs),...e};n.delete(c.pos,u.pos);const x=p?[{type:l,attrs:b},{type:p,attrs:v}]:[{type:l,attrs:b}];if(!lu(n.doc,c.pos,2))return!1;if(i){const{selection:y,storedMarks:S}=r,{splittableMarks:M}=a.extensionManager,N=S||y.$to.parentOffset&&y.$from.marks();if(n.split(c.pos,2,x).scrollIntoView(),!N||!i)return!0;const A=N.filter(k=>M.includes(k.type.name));n.ensureMarks(A)}return!0},Tj=(t,e)=>{const n=TN(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&&ph(t.doc,n.pos)&&t.join(n.pos),!0},Cj=(t,e)=>{const n=TN(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&&ph(t.doc,r)&&t.join(r),!0},I7e=(t,e,n,r={})=>({editor:i,tr:a,state:o,dispatch:l,chain:c,commands:u,can:d})=>{const{extensions:f,splittableMarks:m}=i.extensionManager,p=Ti(t,o.schema),b=Ti(e,o.schema),{selection:v,storedMarks:x}=o,{$from:y,$to:S}=v,M=y.blockRange(S),N=x||v.$to.parentOffset&&v.$from.marks();if(!M)return!1;const A=TN(k=>AW(k.type.name,f))(v);if(M.depth>=1&&A&&M.depth-A.depth<=1){if(A.node.type===p)return u.liftListItem(b);if(AW(A.node.type.name,f)&&p.validContent(A.node.content)&&l)return c().command(()=>(a.setNodeMarkup(A.pos,p),!0)).command(()=>Tj(a,p)).command(()=>Cj(a,p)).run()}return!n||!N||!l?c().command(()=>d().wrapInList(p,r)?!0:u.clearNodes()).wrapInList(p,r).command(()=>Tj(a,p)).command(()=>Cj(a,p)).run():c().command(()=>{const k=d().wrapInList(p,r),C=N.filter(D=>m.includes(D.type.name));return a.ensureMarks(C),k?!0:u.clearNodes()}).wrapInList(p,r).command(()=>Tj(a,p)).command(()=>Cj(a,p)).run()},F7e=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:a=!1}=n,o=Tu(t,r.schema);return ZR(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:a}):i.setMark(o,e)},U7e=(t,e,n={})=>({state:r,commands:i})=>{const a=Ti(t,r.schema),o=Ti(e,r.schema),l=sh(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})},z7e=(t,e={})=>({state:n,commands:r})=>{const i=Ti(t,n.schema);return sh(n,i,e)?r.lift(i):r.wrapIn(i,e)},B7e=()=>({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},$7e=()=>({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},H7e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var a;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=n,c=Tu(t,r.schema),{$from:u,empty:d,ranges:f}=l;if(!i)return!0;if(d&&o){let{from:m,to:p}=l;const b=(a=u.marks().find(x=>x.type===c))==null?void 0:a.attrs,v=VL(u,c,b);v&&(m=v.from,p=v.to),n.removeMark(m,p,c)}else f.forEach(m=>{n.removeMark(m.$from.pos,m.$to.pos,c)});return n.removeStoredMark(c),!0},V7e=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},G7e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null;const l=AN(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(a=Ti(t,r.schema)),l==="mark"&&(o=Tu(t,r.schema));let c=!1;return n.selection.ranges.forEach(u=>{const d=u.$from.pos,f=u.$to.pos;let m,p,b,v;n.selection.empty?r.doc.nodesBetween(d,f,(x,y)=>{a&&a===x.type&&(c=!0,b=Math.max(y,d),v=Math.min(y+x.nodeSize,f),m=y,p=x)}):r.doc.nodesBetween(d,f,(x,y)=>{y<d&&a&&a===x.type&&(c=!0,b=Math.max(y,d),v=Math.min(y+x.nodeSize,f),m=y,p=x),y>=d&&y<=f&&(a&&a===x.type&&(c=!0,i&&n.setNodeMarkup(y,void 0,{...x.attrs,...e})),o&&x.marks.length&&x.marks.forEach(S=>{if(o===S.type&&(c=!0,i)){const M=Math.max(y,d),N=Math.min(y+x.nodeSize,f);n.addMark(M,N,o.create({...S.attrs,...e}))}}))}),p&&(m!==void 0&&i&&n.setNodeMarkup(m,void 0,{...p.attrs,...e}),o&&p.marks.length&&p.marks.forEach(x=>{o===x.type&&i&&n.addMark(b,v,o.create({...x.attrs,...e}))}))}),c},W7e=(t,e={})=>({state:n,dispatch:r})=>{const i=Ti(t,n.schema);return vHe(i,e)(n,r)},q7e=(t,e={})=>({state:n,dispatch:r})=>{const i=Ti(t,n.schema);return _He(i,e)(n,r)},K7e=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={}}},kN=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},X7e=(t,e)=>{if(HL(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 L1(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(m=>m.type.spec.code))return!1;let d=!1;const f=_7e(u)+a;return o.forEach(m=>{if(d)return;const p=X7e(f,m.find);if(!p)return;const b=c.state.tr,v=EN({state:c.state,transaction:b}),x={from:r-(p[0].length-a.length),to:i},{commands:y,chain:S,can:M}=new NN({editor:n,state:v});m.handler({state:v,range:x,match:p,commands:y,chain:S,can:M})===null||!b.steps.length||(m.undoable&&b.setMeta(l,{transform:b,from:r,to:i,text:a}),c.dispatch(b),d=!0)}),d}function Y7e(t){const{editor:e,rules:n}=t,r=new Yr({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=WL(At.from(d),o.schema);const{from:f}=c,m=f+d.length;L1({editor:e,from:f,to:m,text:d,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:a}},props:{handleTextInput(i,a,o,l){return L1({editor:e,from:a,to:o,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:a}=i.state.selection;a&&L1({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?L1({editor:e,from:o.pos,to:o.pos,text:`
  8199. `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function Z7e(t){return Object.prototype.toString.call(t).slice(8,-1)}function I1(t){return Z7e(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function gre(t,e){const n={...t};return I1(t)&&I1(e)&&Object.keys(e).forEach(r=>{I1(e[r])&&I1(t[r])?n[r]=gre(t[r],e[r]):n[r]=e[r]}),n}var KL=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{...or(en(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...or(en(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>gre(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}},xh=class xre extends KL{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new xre(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 Q7e(t){return typeof t=="number"}var J7e=class{constructor(t){this.find=t.find,this.handler=t.handler}},e9e=(t,e,n)=>{if(HL(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 t9e(t){const{editor:e,state:n,from:r,to:i,rule:a,pasteEvent:o,dropEvent:l}=t,{commands:c,chain:u,can:d}=new NN({editor:e,state:n}),f=[];return n.doc.nodesBetween(r,i,(p,b)=>{var v,x,y,S,M;if((x=(v=p.type)==null?void 0:v.spec)!=null&&x.code||!(p.isText||p.isTextblock||p.isInline))return;const N=(M=(S=(y=p.content)==null?void 0:y.size)!=null?S:p.nodeSize)!=null?M:0,A=Math.max(r,b),k=Math.min(i,b+N);if(A>=k)return;const C=p.isText?p.text||"":p.textBetween(A-b,k-b,void 0,"");e9e(C,a.find,o).forEach(T=>{if(T.index===void 0)return;const R=A+T.index+1,U=R+T[0].length,L={from:n.tr.mapping.map(R),to:n.tr.mapping.map(U)},q=a.handler({state:n,range:L,match:T,commands:c,chain:u,can:d,pasteEvent:o,dropEvent:l});f.push(q)})}),f.every(p=>p!==null)}var F1=null,n9e=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function r9e(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:m,rule:p,pasteEvt:b})=>{const v=d.tr,x=EN({state:d,transaction:v});if(!(!t9e({editor:e,state:x,from:Math.max(f-1,0),to:m.b-1,rule:p,pasteEvent:b,dropEvent:l})||!v.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,v}};return n.map(d=>new Yr({view(f){const m=b=>{var v;r=(v=f.dom.parentElement)!=null&&v.contains(b.target)?f.dom.parentElement:null,r&&(F1=e)},p=()=>{F1&&(F1=null)};return window.addEventListener("dragstart",m),window.addEventListener("dragend",p),{destroy(){window.removeEventListener("dragstart",m),window.removeEventListener("dragend",p)}}},props:{handleDOMEvents:{drop:(f,m)=>{if(a=r===f.dom.parentElement,l=m,!a){const p=F1;p?.isEditable&&setTimeout(()=>{const b=p.state.selection;b&&p.commands.deleteRange({from:b.from,to:b.to})},10)}return!1},paste:(f,m)=>{var p;const b=(p=m.clipboardData)==null?void 0:p.getData("text/html");return o=m,i=!!b?.includes("data-pm-slice"),!1}}},appendTransaction:(f,m,p)=>{const b=f[0],v=b.getMeta("uiEvent")==="paste"&&!i,x=b.getMeta("uiEvent")==="drop"&&!a,y=b.getMeta("applyPasteRules"),S=!!y;if(!v&&!x&&!S)return;if(S){let{text:A}=y;typeof A=="string"?A=A:A=WL(At.from(A),p.schema);const{from:k}=y,C=k+A.length,D=n9e(A);return c({rule:d,state:p,from:k,to:{b:C},pasteEvt:D})}const M=m.doc.content.findDiffStart(p.doc.content),N=m.doc.content.findDiffEnd(p.doc.content);if(!(!Q7e(M)||!N||M===N.b))return c({rule:d,state:p,from:M,to:N,pasteEvt:o})}}))}var jN=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=lre(t),this.schema=m7e(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:O1(e.name,this.schema)},r=en(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return hM([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:O1(r.name,this.schema)},a=[],o=en(r,"addKeyboardShortcuts",i);let l={};if(r.type==="mark"&&en(r,"exitable",i)&&(l.ArrowRight=()=>xh.handleExit({editor:t,mark:r})),o){const m=Object.fromEntries(Object.entries(o()).map(([p,b])=>[p,()=>b({editor:t})]));l={...l,...m}}const c=xGe(l);a.push(c);const u=en(r,"addInputRules",i);if(NW(r,t.options.enableInputRules)&&u){const m=u();if(m&&m.length){const p=Y7e({editor:t,rules:m}),b=Array.isArray(p)?p:[p];a.push(...b)}}const d=en(r,"addPasteRules",i);if(NW(r,t.options.enablePasteRules)&&d){const m=d();if(m&&m.length){const p=r9e({editor:t,rules:m});a.push(...p)}}const f=en(r,"addProseMirrorPlugins",i);if(f){const m=f();a.push(...m)}return a})}get attributes(){return ore(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=zg(this.extensions);return Object.fromEntries(e.filter(n=>!!en(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:Ti(n.name,this.schema)},a=en(n,"addNodeView",i);if(!a)return[];const o=a();if(!o)return[];const l=(c,u,d,f,m)=>{const p=cy(c,r);return o({node:c,view:u,getPos:d,decorations:f,innerDecorations:m,editor:t,extension:n,HTMLAttributes:p})};return[n.name,l]}))}dispatchTransaction(t){const{editor:e}=this;return hM([...this.extensions].reverse()).reduceRight((r,i)=>{const a={name:i.name,options:i.options,storage:this.editor.extensionStorage[i.name],editor:e,type:O1(i.name,this.schema)},o=en(i,"dispatchTransaction",a);return o?l=>{o.call(a,{transaction:l,next:r})}:r},t)}get markViews(){const{editor:t}=this,{markExtensions:e}=zg(this.extensions);return Object.fromEntries(e.filter(n=>!!en(n,"addMarkView")).map(n=>{const r=this.attributes.filter(l=>l.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Tu(n.name,this.schema)},a=en(n,"addMarkView",i);if(!a)return[];const o=(l,c,u)=>{const d=cy(l,r);return a()({mark:l,view:c,inline:u,editor:t,extension:n,HTMLAttributes:d,updateAttributes:f=>{b9e(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:O1(e.name,this.schema)};e.type==="mark"&&((n=or(en(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const i=en(e,"onBeforeCreate",r),a=en(e,"onCreate",r),o=en(e,"onUpdate",r),l=en(e,"onSelectionUpdate",r),c=en(e,"onTransaction",r),u=en(e,"onFocus",r),d=en(e,"onBlur",r),f=en(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)})}};jN.resolve=lre;jN.sort=hM;jN.flatten=GL;var i9e={};$L(i9e,{ClipboardTextSerializer:()=>yre,Commands:()=>vre,Delete:()=>_re,Drop:()=>wre,Editable:()=>Sre,FocusEvents:()=>Ere,Keymap:()=>Nre,Paste:()=>Are,Tabindex:()=>Tre,TextDirection:()=>Cre,focusEventsPluginKey:()=>Mre});var br=class bre extends KL{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new bre(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},yre=br.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Yr({key:new Vi("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=ure(n);return cre(r,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),vre=br.create({name:"commands",addCommands(){return{...Qne}}}),_re=br.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=are(t.before,[t,...e]);hre(d).forEach(p=>{d.mapping.mapResult(p.oldRange.from).deletedAfter&&d.mapping.mapResult(p.oldRange.to).deletedBefore&&d.before.nodesBetween(p.oldRange.from,p.oldRange.to,(b,v)=>{const x=v+b.nodeSize-2,y=p.oldRange.from<=v&&x<=p.oldRange.to;this.editor.emit("delete",{type:"node",node:b,from:v,to:x,newFrom:d.mapping.map(v),newTo:d.mapping.map(x),deletedRange:p.oldRange,newRange:p.newRange,partial:!y,editor:this.editor,transaction:t,combinedTransform:d})})});const m=d.mapping;d.steps.forEach((p,b)=>{var v,x;if(p instanceof nl){const y=m.slice(b).map(p.from,-1),S=m.slice(b).map(p.to),M=m.invert().map(y,-1),N=m.invert().map(S),A=(v=d.doc.nodeAt(y-1))==null?void 0:v.marks.some(C=>C.eq(p.mark)),k=(x=d.doc.nodeAt(S))==null?void 0:x.marks.some(C=>C.eq(p.mark));this.editor.emit("delete",{type:"mark",mark:p.mark,from:p.from,to:p.to,deletedRange:{from:M,to:N},newRange:{from:y,to:S},partial:!!(k||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()}}),wre=br.create({name:"drop",addProseMirrorPlugins(){return[new Yr({key:new Vi("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),Sre=br.create({name:"editable",addProseMirrorPlugins(){return[new Yr({key:new Vi("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Mre=new Vi("focusEvents"),Ere=br.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Yr({key:Mre,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}}}})]}}),Nre=br.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:m,parent:p}=f,b=f.parent.isTextblock&&m>0?l.doc.resolve(m-1):f,v=b.parent.type.spec.isolating,x=f.pos-f.parentOffset,y=v&&b.parent.childCount===1?x===f.pos:En.atStart(u).from===m;return!d||!p.type.isTextblock||p.textContent.length||!y||y&&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 dM()||rre()?a:i},addProseMirrorPlugins(){return[new Yr({key:new Vi("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(v=>v.getMeta("composition")))return;const r=t.some(v=>v.docChanged)&&!e.doc.eq(n.doc),i=t.some(v=>v.getMeta("preventClearDocument"));if(!r||i)return;const{empty:a,from:o,to:l}=e.selection,c=En.atStart(e.doc).from,u=En.atEnd(e.doc).to;if(a||!(o===c&&l===u)||!CN(n.doc))return;const m=n.tr,p=EN({state:n,transaction:m}),{commands:b}=new NN({editor:this.editor,state:p});if(b.clearNodes(),!!m.steps.length)return m}})]}}),Are=br.create({name:"paste",addProseMirrorPlugins(){return[new Yr({key:new Vi("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),Tre=br.create({name:"tabindex",addProseMirrorPlugins(){return[new Yr({key:new Vi("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),Cre=br.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=zg(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 Yr({key:new Vi("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),a9e=class Xb{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 Xb(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 Xb(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 Xb(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=n.isInline,l=this.pos+r+(a?0:1);if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;const c=this.resolvedPos.doc.resolve(l);if(!i&&!o&&c.depth<=this.depth)return;const u=new Xb(c,this.editor,i,i||o?n:null);i&&(u.actualDepth=this.depth+1),e.push(u)}),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)}},s9e=`.ProseMirror {
  8200. position: relative;
  8201. }
  8202. .ProseMirror {
  8203. word-wrap: break-word;
  8204. white-space: pre-wrap;
  8205. white-space: break-spaces;
  8206. -webkit-font-variant-ligatures: none;
  8207. font-variant-ligatures: none;
  8208. font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
  8209. }
  8210. .ProseMirror [contenteditable="false"] {
  8211. white-space: normal;
  8212. }
  8213. .ProseMirror [contenteditable="false"] [contenteditable="true"] {
  8214. white-space: pre-wrap;
  8215. }
  8216. .ProseMirror pre {
  8217. white-space: pre-wrap;
  8218. }
  8219. img.ProseMirror-separator {
  8220. display: inline !important;
  8221. border: none !important;
  8222. margin: 0 !important;
  8223. width: 0 !important;
  8224. height: 0 !important;
  8225. }
  8226. .ProseMirror-gapcursor {
  8227. display: none;
  8228. pointer-events: none;
  8229. position: absolute;
  8230. margin: 0;
  8231. }
  8232. .ProseMirror-gapcursor:after {
  8233. content: "";
  8234. display: block;
  8235. position: absolute;
  8236. top: -2px;
  8237. width: 20px;
  8238. border-top: 1px solid black;
  8239. animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
  8240. }
  8241. @keyframes ProseMirror-cursor-blink {
  8242. to {
  8243. visibility: hidden;
  8244. }
  8245. }
  8246. .ProseMirror-hideselection *::selection {
  8247. background: transparent;
  8248. }
  8249. .ProseMirror-hideselection *::-moz-selection {
  8250. background: transparent;
  8251. }
  8252. .ProseMirror-hideselection * {
  8253. caret-color: transparent;
  8254. }
  8255. .ProseMirror-focused .ProseMirror-gapcursor {
  8256. display: block;
  8257. }`;function o9e(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 l9e=class extends K7e{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,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:E7e,createMappablePosition:N7e},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=tre(e,this.options.autofocus);this.editorState=Yp.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=o9e(s9e,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=sre(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?[Sre,yre.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),vre,Ere,Nre,Tre,wre,Are,_re,Cre.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 jN(r,this)}createCommandManager(){this.commandManager=new NN({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=YR(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=YR(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){const{editorProps:e,enableExtensionDispatchTransaction:n}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),i=n?this.extensionManager.dispatchTransaction(r):r;this.editorView=new Yne(t,{...e,attributes:{role:"textbox",...e?.attributes},dispatchTransaction:i,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const a=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(a),this.prependClass(),this.injectCSS();const o=this.view.dom;o.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 dre(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return w7e(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return WL(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
  8258. `,textSerializers:n={}}=t||{};return g7e(this.state.doc,{blockSeparator:e,textSerializers:{...ure(this.schema),...n}})}get isEmpty(){return CN(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 a9e(e,this)}get $doc(){return this.$pos(0)}};function Bg(t){return new kN({find:t.find,handler:({state:e,range:n,match:r})=>{const i=or(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(qL(n.from,n.to,e.doc).filter(p=>p.mark.type.excluded.find(v=>v===t.type&&v!==p.mark.type)).filter(p=>p.to>u).length)return null;d<n.to&&a.delete(d,n.to),u>n.from&&a.delete(n.from+c,u);const m=n.from+c+o.length;a.addMark(n.from+c,m,t.type.create(i||{})),a.removeStoredMark(t.type)}},undoable:t.undoable})}function kre(t){return new kN({find:t.find,handler:({state:e,range:n,match:r})=>{const i=or(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 QR(t){return new kN({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),a=or(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 $g(t){return new kN({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const a=or(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),c=o.doc.resolve(n.from).blockRange(),u=c&&NL(c,t.type,a);if(!u)return null;if(o.wrap(c,u),t.keepMarks&&t.editor){const{selection:f,storedMarks:m}=e,{splittableMarks:p}=t.editor.extensionManager,b=m||f.$to.parentOffset&&f.$from.marks();if(b){const v=b.filter(x=>p.includes(x.type.name));o.ensureMarks(v)}}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&&ph(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,d))&&o.join(n.from-1)},undoable:t.undoable})}var c9e=t=>"touches"in t,u9e=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.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=l=>{if(!this.isResizing||!this.activeHandle)return;const c=l.clientX-this.startX,u=l.clientY-this.startY;this.handleResize(c,u)},this.handleTouchMove=l=>{if(!this.isResizing||!this.activeHandle)return;const c=l.touches[0];if(!c)return;const u=c.clientX-this.startX,d=c.clientY-this.startY;this.handleResize(u,d)},this.handleMouseUp=()=>{if(!this.isResizing)return;const l=this.element.offsetWidth,c=this.element.offsetHeight;this.onCommit(l,c),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=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,n,r,i,a,o;this.node=t.node,this.editor=t.editor,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||""}),(o=t.options)!=null&&o.createCustomHandle&&(this.createCustomHandle=t.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on("update",this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){var t;return(t=this.contentElement)!=null?t:null}handleEditorUpdate(){const t=this.editor.isEditable;t!==this.lastEditableState&&(this.lastEditableState=t,t?t&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())}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.editor.off("update",this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){const t=document.createElement("div");return t.dataset.resizeContainer="",t.dataset.node=this.node.type.name,t.style.display="flex",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=>{let e;this.createCustomHandle?e=this.createCustomHandle(t):e=this.createHandle(t),e instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${t}") did not return an HTMLElement. Falling back to default handle.`),e=this.createHandle(t)),this.createCustomHandle||this.positionHandle(e,t),e.addEventListener("mousedown",n=>this.handleResizeStart(n,t)),e.addEventListener("touchstart",n=>this.handleResizeStart(n,t)),this.handleMap.set(t,e),this.wrapper.appendChild(e)})}removeHandles(){this.handleMap.forEach(t=>t.remove()),this.handleMap.clear()}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,c9e(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 d9e(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof nn){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 h9e={};$L(h9e,{createAtomBlockMarkdownSpec:()=>f9e,createBlockMarkdownSpec:()=>m9e,createInlineMarkdownSpec:()=>x9e,parseAttributes:()=>XL,parseIndentedBlocks:()=>JR,renderNestedMarkdownContent:()=>ZL,serializeAttributes:()=>YL});function XL(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 m=parseInt(((f=d.match(/__QUOTED_(\d+)__/))==null?void 0:f[1])||"0",10),p=n[m];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 YL(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 f9e(t){const{nodeName:e,name:n,parseAttributes:r=XL,serializeAttributes:i=YL,defaultAttributes:a={},requiredAttributes:o=[],allowedAttributes:l}=t,c=n||e,u=d=>{if(!l)return d;const f={};return l.forEach(m=>{m in d&&(f[m]=d[m])}),f};return{parseMarkdown:(d,f)=>{const m={...a,...d.attributes};return f.createNode(e,m,[])},markdownTokenizer:{name:e,level:"block",start(d){var f;const m=new RegExp(`^:::${c}(?:\\s|$)`,"m"),p=(f=d.match(m))==null?void 0:f.index;return p!==void 0?p:-1},tokenize(d,f,m){const p=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),b=d.match(p);if(!b)return;const v=b[1]||"",x=r(v);if(!o.find(S=>!(S in x)))return{type:e,raw:b[0],attributes:x}}},renderMarkdown:d=>{const f=u(d.attrs||{}),m=i(f),p=m?` {${m}}`:"";return`:::${c}${p} :::`}}}function m9e(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=XL,serializeAttributes:a=YL,defaultAttributes:o={},content:l="block",allowedAttributes:c}=t,u=n||e,d=f=>{if(!c)return f;const m={};return c.forEach(p=>{p in f&&(m[p]=f[p])}),m};return{parseMarkdown:(f,m)=>{let p;if(r){const v=r(f);p=typeof v=="string"?[{type:"text",text:v}]:v}else l==="block"?p=m.parseChildren(f.tokens||[]):p=m.parseInline(f.tokens||[]);const b={...o,...f.attributes};return m.createNode(e,b,p)},markdownTokenizer:{name:e,level:"block",start(f){var m;const p=new RegExp(`^:::${u}`,"m"),b=(m=f.match(p))==null?void 0:m.index;return b!==void 0?b:-1},tokenize(f,m,p){var b;const v=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),x=f.match(v);if(!x)return;const[y,S=""]=x,M=i(S);let N=1;const A=y.length;let k="";const C=/^:::([\w-]*)(\s.*)?/gm,D=f.slice(A);for(C.lastIndex=0;;){const T=C.exec(D);if(T===null)break;const R=T.index,U=T[1];if(!((b=T[2])!=null&&b.endsWith(":::"))){if(U)N+=1;else if(N-=1,N===0){const L=D.slice(0,R);k=L.trim();const q=f.slice(0,A+R+T[0].length);let j=[];if(k)if(l==="block")for(j=p.blockTokens(L),j.forEach(W=>{W.text&&(!W.tokens||W.tokens.length===0)&&(W.tokens=p.inlineTokens(W.text))});j.length>0;){const W=j[j.length-1];if(W.type==="paragraph"&&(!W.text||W.text.trim()===""))j.pop();else break}else j=p.inlineTokens(k);return{type:e,raw:q,attributes:M,content:k,tokens:j}}}}}},renderMarkdown:(f,m)=>{const p=d(f.attrs||{}),b=a(p),v=b?` {${b}}`:"",x=m.renderChildren(f.content||[],`
  8259. `);return`:::${u}${v}
  8260. ${x}
  8261. :::`}}}function p9e(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 g9e(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function x9e(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=p9e,serializeAttributes:a=g9e,defaultAttributes:o={},selfClosing:l=!1,allowedAttributes:c}=t,u=n||e,d=m=>{if(!c)return m;const p={};return c.forEach(b=>{const v=typeof b=="string"?b:b.name,x=typeof b=="string"?void 0:b.skipIfDefault;if(v in m){const y=m[v];if(x!==void 0&&y===x)return;p[v]=y}}),p},f=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(m,p)=>{const b={...o,...m.attributes};if(l)return p.createNode(e,b);const v=r?r(m):m.content||"";return v?p.createNode(e,b,[p.createTextNode(v)]):p.createNode(e,b,[])},markdownTokenizer:{name:e,level:"inline",start(m){const p=l?new RegExp(`\\[${f}\\s*[^\\]]*\\]`):new RegExp(`\\[${f}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${f}\\]`),b=m.match(p),v=b?.index;return v!==void 0?v:-1},tokenize(m,p,b){const v=l?new RegExp(`^\\[${f}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${f}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${f}\\]`),x=m.match(v);if(!x)return;let y="",S="";if(l){const[,N]=x;S=N}else{const[,N,A]=x;S=N,y=A||""}const M=i(S.trim());return{type:e,raw:x[0],content:y.trim(),attributes:M}}},renderMarkdown:m=>{let p="";r?p=r(m):m.content&&m.content.length>0&&(p=m.content.filter(y=>y.type==="text").map(y=>y.text).join(""));const b=d(m.attrs||{}),v=a(b),x=v?` ${v}`:"";return l?`[${u}${x}]`:`[${u}${x}]${p}[/${u}]`}}}function JR(t,e,n){var r,i,a,o;const l=t.split(`
  8262. `),c=[];let u="",d=0;const f=e.baseIndentSize||2;for(;d<l.length;){const m=l[d],p=m.match(e.itemPattern);if(!p){if(c.length>0)break;if(m.trim()===""){d+=1,u=`${u}${m}
  8263. `;continue}else return}const b=e.extractItemData(p),{indentLevel:v,mainContent:x}=b;u=`${u}${m}
  8264. `;const y=[x];for(d+=1;d<l.length;){const A=l[d];if(A.trim()===""){const C=l.slice(d+1).findIndex(R=>R.trim()!=="");if(C===-1)break;if((((i=(r=l[d+1+C].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:i.length)||0)>v){y.push(A),u=`${u}${A}
  8265. `,d+=1;continue}else break}if((((o=(a=A.match(/^(\s*)/))==null?void 0:a[1])==null?void 0:o.length)||0)>v)y.push(A),u=`${u}${A}
  8266. `,d+=1;else break}let S;const M=y.slice(1);if(M.length>0){const A=M.map(k=>k.slice(v+f)).join(`
  8267. `);A.trim()&&(e.customNestedParser?S=e.customNestedParser(A):S=n.blockTokens(A))}const N=e.createToken(b,S);c.push(N)}if(c.length!==0)return{items:c,raw:u}}function ZL(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(`
  8268. `).map(m=>m?e.indent(m):"").join(`
  8269. `);c.push(f)}}),c.join(`
  8270. `)}function b9e(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 m=!1;if(Object.keys(n).forEach(p=>{n[p]!==f.attrs[p]&&(m=!0)}),m){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 As=class jre extends KL{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new jre(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function sm(t){return new J7e({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const a=or(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),m=f+l.length;if(qL(n.from,n.to,e.doc).filter(b=>b.mark.type.excluded.find(x=>x===t.type&&x!==b.mark.type)).filter(b=>b.to>f).length)return null;m<n.to&&o.delete(m,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)}}})}const{getOwnPropertyNames:y9e,getOwnPropertySymbols:v9e}=Object,{hasOwnProperty:_9e}=Object.prototype;function kj(t,e){return function(r,i,a){return t(r,i,a)&&e(r,i,a)}}function U1(t){return function(n,r,i){if(!n||!r||typeof n!="object"||typeof r!="object")return t(n,r,i);const{cache:a}=i,o=a.get(n),l=a.get(r);if(o&&l)return o===r&&l===n;a.set(n,r),a.set(r,n);const c=t(n,r,i);return a.delete(n),a.delete(r),c}}function w9e(t){return t?.[Symbol.toStringTag]}function CW(t){return y9e(t).concat(v9e(t))}const S9e=Object.hasOwn||((t,e)=>_9e.call(t,e));function mm(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const M9e="__v",E9e="__o",N9e="_owner",{getOwnPropertyDescriptor:kW,keys:jW}=Object;function A9e(t,e){return t.byteLength===e.byteLength&&fM(new Uint8Array(t),new Uint8Array(e))}function T9e(t,e,n){let r=t.length;if(e.length!==r)return!1;for(;r-- >0;)if(!n.equals(t[r],e[r],r,r,t,e,n))return!1;return!0}function C9e(t,e){return t.byteLength===e.byteLength&&fM(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function k9e(t,e){return mm(t.getTime(),e.getTime())}function j9e(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function P9e(t,e){return t===e}function PW(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const i=new Array(r),a=t.entries();let o,l,c=0;for(;(o=a.next())&&!o.done;){const u=e.entries();let d=!1,f=0;for(;(l=u.next())&&!l.done;){if(i[f]){f++;continue}const m=o.value,p=l.value;if(n.equals(m[0],p[0],c,f,t,e,n)&&n.equals(m[1],p[1],m[0],p[0],t,e,n)){d=i[f]=!0;break}f++}if(!d)return!1;c++}return!0}const R9e=mm;function D9e(t,e,n){const r=jW(t);let i=r.length;if(jW(e).length!==i)return!1;for(;i-- >0;)if(!Pre(t,e,n,r[i]))return!1;return!0}function Pb(t,e,n){const r=CW(t);let i=r.length;if(CW(e).length!==i)return!1;let a,o,l;for(;i-- >0;)if(a=r[i],!Pre(t,e,n,a)||(o=kW(t,a),l=kW(e,a),(o||l)&&(!o||!l||o.configurable!==l.configurable||o.enumerable!==l.enumerable||o.writable!==l.writable)))return!1;return!0}function O9e(t,e){return mm(t.valueOf(),e.valueOf())}function L9e(t,e){return t.source===e.source&&t.flags===e.flags}function RW(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const i=new Array(r),a=t.values();let o,l;for(;(o=a.next())&&!o.done;){const c=e.values();let u=!1,d=0;for(;(l=c.next())&&!l.done;){if(!i[d]&&n.equals(o.value,l.value,o.value,l.value,t,e,n)){u=i[d]=!0;break}d++}if(!u)return!1}return!0}function fM(t,e){let n=t.byteLength;if(e.byteLength!==n||t.byteOffset!==e.byteOffset)return!1;for(;n-- >0;)if(t[n]!==e[n])return!1;return!0}function I9e(t,e){return t.hostname===e.hostname&&t.pathname===e.pathname&&t.protocol===e.protocol&&t.port===e.port&&t.hash===e.hash&&t.username===e.username&&t.password===e.password}function Pre(t,e,n,r){return(r===N9e||r===E9e||r===M9e)&&(t.$$typeof||e.$$typeof)?!0:S9e(e,r)&&n.equals(t[r],e[r],r,r,t,e,n)}const F9e="[object ArrayBuffer]",U9e="[object Arguments]",z9e="[object Boolean]",B9e="[object DataView]",$9e="[object Date]",H9e="[object Error]",V9e="[object Map]",G9e="[object Number]",W9e="[object Object]",q9e="[object RegExp]",K9e="[object Set]",X9e="[object String]",Y9e={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},Z9e="[object URL]",Q9e=Object.prototype.toString;function J9e({areArrayBuffersEqual:t,areArraysEqual:e,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:i,areFunctionsEqual:a,areMapsEqual:o,areNumbersEqual:l,areObjectsEqual:c,arePrimitiveWrappersEqual:u,areRegExpsEqual:d,areSetsEqual:f,areTypedArraysEqual:m,areUrlsEqual:p,unknownTagComparators:b}){return function(x,y,S){if(x===y)return!0;if(x==null||y==null)return!1;const M=typeof x;if(M!==typeof y)return!1;if(M!=="object")return M==="number"?l(x,y,S):M==="function"?a(x,y,S):!1;const N=x.constructor;if(N!==y.constructor)return!1;if(N===Object)return c(x,y,S);if(Array.isArray(x))return e(x,y,S);if(N===Date)return r(x,y,S);if(N===RegExp)return d(x,y,S);if(N===Map)return o(x,y,S);if(N===Set)return f(x,y,S);const A=Q9e.call(x);if(A===$9e)return r(x,y,S);if(A===q9e)return d(x,y,S);if(A===V9e)return o(x,y,S);if(A===K9e)return f(x,y,S);if(A===W9e)return typeof x.then!="function"&&typeof y.then!="function"&&c(x,y,S);if(A===Z9e)return p(x,y,S);if(A===H9e)return i(x,y,S);if(A===U9e)return c(x,y,S);if(Y9e[A])return m(x,y,S);if(A===F9e)return t(x,y,S);if(A===B9e)return n(x,y,S);if(A===z9e||A===G9e||A===X9e)return u(x,y,S);if(b){let k=b[A];if(!k){const C=w9e(x);C&&(k=b[C])}if(k)return k(x,y,S)}return!1}}function eWe({circular:t,createCustomConfig:e,strict:n}){let r={areArrayBuffersEqual:A9e,areArraysEqual:n?Pb:T9e,areDataViewsEqual:C9e,areDatesEqual:k9e,areErrorsEqual:j9e,areFunctionsEqual:P9e,areMapsEqual:n?kj(PW,Pb):PW,areNumbersEqual:R9e,areObjectsEqual:n?Pb:D9e,arePrimitiveWrappersEqual:O9e,areRegExpsEqual:L9e,areSetsEqual:n?kj(RW,Pb):RW,areTypedArraysEqual:n?kj(fM,Pb):fM,areUrlsEqual:I9e,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),t){const i=U1(r.areArraysEqual),a=U1(r.areMapsEqual),o=U1(r.areObjectsEqual),l=U1(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:i,areMapsEqual:a,areObjectsEqual:o,areSetsEqual:l})}return r}function tWe(t){return function(e,n,r,i,a,o,l){return t(e,n,l)}}function nWe({circular:t,comparator:e,createState:n,equals:r,strict:i}){if(n)return function(l,c){const{cache:u=t?new WeakMap:void 0,meta:d}=n();return e(l,c,{cache:u,equals:r,meta:d,strict:i})};if(t)return function(l,c){return e(l,c,{cache:new WeakMap,equals:r,meta:void 0,strict:i})};const a={cache:void 0,equals:r,meta:void 0,strict:i};return function(l,c){return e(l,c,a)}}const rWe=bh();bh({strict:!0});bh({circular:!0});bh({circular:!0,strict:!0});bh({createInternalComparator:()=>mm});bh({strict:!0,createInternalComparator:()=>mm});bh({circular:!0,createInternalComparator:()=>mm});bh({circular:!0,createInternalComparator:()=>mm,strict:!0});function bh(t={}){const{circular:e=!1,createInternalComparator:n,createState:r,strict:i=!1}=t,a=eWe(t),o=J9e(a),l=n?n(o):tWe(o);return nWe({circular:e,comparator:o,createState:r,equals:l,strict:i})}var iWe=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},aWe=({contentComponent:t})=>{const e=vD.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return s.jsx(s.Fragment,{children:Object.values(e)})};function sWe(){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]:Bce.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 oWe=class extends Ur.Component{constructor(t){var e;super(t),this.editorContentRef=Ur.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=t.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var t;const e=this.props.editor;if(e&&!e.isDestroyed&&((t=e.view.dom)!=null&&t.parentNode)){if(e.contentComponent)return;const n=this.editorContentRef.current;n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n}),e.contentComponent=sWe(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(r=>r.hasContentComponentInitialized?r:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),e.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.parentNode))return;const n=document.createElement("div");n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return s.jsxs(s.Fragment,{children:[s.jsx("div",{ref:iWe(e,this.editorContentRef),...n}),t?.contentComponent&&s.jsx(aWe,{contentComponent:t.contentComponent})]})}},lWe=w.forwardRef((t,e)=>{const n=Ur.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return Ur.createElement(oWe,{key:n,innerRef:e,...t})}),cWe=Ur.memo(lWe),uWe=typeof window<"u"?w.useLayoutEffect:w.useEffect,dWe=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 hWe(t){var e;const[n]=w.useState(()=>new dWe(t.editor)),r=hX.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:rWe);return uWe(()=>n.watch(t.editor),[t.editor,n]),w.useDebugValue(r),r}var fWe=!1,eD=typeof window>"u",mWe=eD||!!(typeof window<"u"&&window.next),pWe=class Rre{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?eD||mWe?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 l9e(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?Rre.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 gWe(t={},e=[]){const n=w.useRef(t);n.current=t;const[r]=w.useState(()=>new pWe(n)),i=vD.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return w.useDebugValue(i),w.useEffect(r.onRender(e)),hWe({editor:i,selector:({transactionNumber:a})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&a===0?0:a+1}),i}var xWe=w.createContext({editor:null});xWe.Consumer;var bWe=w.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),yWe=()=>w.useContext(bWe);Ur.forwardRef((t,e)=>{const{onDragStart:n}=yWe(),r=t.as||"div";return s.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});Ur.createContext({markViewContentRef:()=>{}});var mM=(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]},vWe=/^\s*>\s$/,_We=As.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return mM("blockquote",{...li(this.options.HTMLAttributes,t),children:mM("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(`
  8271. `).map(c=>c.trim()===""?n:`${n} ${c}`);r.push(l.join(`
  8272. `))}),r.join(`
  8273. ${n}
  8274. `)},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[$g({find:vWe,type:this.type})]}}),wWe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,SWe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,MWe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,EWe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,NWe=xh.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 mM("strong",{...li(this.options.HTMLAttributes,t),children:mM("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[Bg({find:wWe,type:this.type}),Bg({find:MWe,type:this.type})]},addPasteRules(){return[sm({find:SWe,type:this.type}),sm({find:EWe,type:this.type})]}}),AWe=/(^|[^`])`([^`]+)`(?!`)$/,TWe=/(^|[^`])`([^`]+)`(?!`)/g,CWe=xh.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",li(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[Bg({find:AWe,type:this.type})]},addPasteRules(){return[sm({find:TWe,type:this.type})]}}),jj=4,kWe=/^```([a-z]+)?[\s\n]$/,jWe=/^~~~([a-z]+)?[\s\n]$/,PWe=As.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:jj,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",li(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(`
  8275. `):r=`\`\`\`${i}
  8276. \`\`\``,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:jj,{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,`
  8277. `,`
  8278. `).split(`
  8279. `).map(b=>l+b).join(`
  8280. `);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:jj,{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,`
  8281. `,`
  8282. `).split(`
  8283. `);let b=0,v=0;const x=u-d;for(let k=0;k<p.length;k+=1){if(v+p[k].length>=x){b=k;break}v+=p[k].length+1}const S=((c=p[b].match(/^ */))==null?void 0:c[0])||"",M=Math.min(S.length,n);if(M===0)return!0;let N=d;for(let k=0;k<b;k+=1)N+=p[k].length+1;return l.delete(N,N+M),u-N<=M&&l.setSelection(fn.create(l.doc,N)),!0}):t.commands.command(({tr:l})=>{const{from:c,to:u}=i,m=r.doc.textBetween(c,u,`
  8284. `,`
  8285. `).split(`
  8286. `).map(p=>{var b;const v=((b=p.match(/^ */))==null?void 0:b[0])||"",x=Math.min(v.length,n);return p.slice(x)}).join(`
  8287. `);return l.replaceWith(c,u,r.schema.text(m)),!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(`
  8288. `);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(En.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[QR({find:kWe,type:this.type,getAttributes:t=>({language:t[1]})}),QR({find:jWe,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Yr({key:new Vi("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,`
  8289. `));return o.replaceSelectionWith(this.type.create({language:a},c)),o.selection.$from.parent.type!==this.type&&o.setSelection(fn.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),RWe=As.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
  8290. `):""}),DWe=As.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",li(this.options.HTMLAttributes,t)]},renderText(){return`
  8291. `},renderMarkdown:()=>`
  8292. `,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(m=>l.includes(m.type.name));u.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),OWe=As.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]}`,li(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=>QR({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),LWe=As.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",li(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!d9e(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return fre(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(fn.create(o.doc,c.pos+1)):c.nodeAfter.isBlock?o.setSelection(nn.create(o.doc,c.pos)):o.setSelection(fn.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(fn.create(o.doc,u+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[kre({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),IWe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,FWe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,UWe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,zWe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,BWe=xh.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",li(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[Bg({find:IWe,type:this.type}),Bg({find:UWe,type:this.type})]},addPasteRules(){return[sm({find:FWe,type:this.type}),sm({find:zWe,type:this.type})]}});const $We="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",HWe="ελ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",tD="numeric",nD="ascii",rD="alpha",f0="asciinumeric",Yb="alphanumeric",iD="domain",Dre="emoji",VWe="scheme",GWe="slashscheme",Pj="whitespace";function WWe(t,e){return t in e||(e[t]=[]),e[t]}function yf(t,e,n){e[tD]&&(e[f0]=!0,e[Yb]=!0),e[nD]&&(e[f0]=!0,e[rD]=!0),e[f0]&&(e[Yb]=!0),e[rD]&&(e[Yb]=!0),e[Yb]&&(e[iD]=!0),e[Dre]&&(e[iD]=!0);for(const r in e){const i=WWe(r,n);i.indexOf(t)<0&&i.push(t)}}function qWe(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function xs(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}xs.groups={};xs.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||xs.groups;let i;return e&&e.j?i=e:(i=new xs(e),n&&r&&yf(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||xs.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 xs,Object.assign(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new xs,a){if(r)if(o.t&&typeof o.t=="string"){const c=Object.assign(qWe(o.t,r),n);yf(a,c,r)}else n&&yf(a,n,r);o.t=a}return i.j[t]=o,o}};const _n=(t,e,n,r,i)=>t.ta(e,n,r,i),Jr=(t,e,n,r,i)=>t.tr(e,n,r,i),DW=(t,e,n,r,i)=>t.ts(e,n,r,i),jt=(t,e,n,r,i)=>t.tt(e,n,r,i),Vc="WORD",aD="UWORD",Ore="ASCIINUMERICAL",Lre="ALPHANUMERICAL",uy="LOCALHOST",sD="TLD",oD="UTLD",vw="SCHEME",Hp="SLASH_SCHEME",QL="NUM",lD="WS",JL="NL",m0="OPENBRACE",p0="CLOSEBRACE",pM="OPENBRACKET",gM="CLOSEBRACKET",xM="OPENPAREN",bM="CLOSEPAREN",yM="OPENANGLEBRACKET",vM="CLOSEANGLEBRACKET",_M="FULLWIDTHLEFTPAREN",wM="FULLWIDTHRIGHTPAREN",SM="LEFTCORNERBRACKET",MM="RIGHTCORNERBRACKET",EM="LEFTWHITECORNERBRACKET",NM="RIGHTWHITECORNERBRACKET",AM="FULLWIDTHLESSTHAN",TM="FULLWIDTHGREATERTHAN",CM="AMPERSAND",kM="APOSTROPHE",jM="ASTERISK",vd="AT",PM="BACKSLASH",RM="BACKTICK",DM="CARET",Nd="COLON",eI="COMMA",OM="DOLLAR",Pl="DOT",LM="EQUALS",tI="EXCLAMATION",bo="HYPHEN",g0="PERCENT",IM="PIPE",FM="PLUS",UM="POUND",x0="QUERY",nI="QUOTE",Ire="FULLWIDTHMIDDLEDOT",rI="SEMI",Rl="SLASH",b0="TILDE",zM="UNDERSCORE",Fre="EMOJI",BM="SYM";var Ure=Object.freeze({__proto__:null,ALPHANUMERICAL:Lre,AMPERSAND:CM,APOSTROPHE:kM,ASCIINUMERICAL:Ore,ASTERISK:jM,AT:vd,BACKSLASH:PM,BACKTICK:RM,CARET:DM,CLOSEANGLEBRACKET:vM,CLOSEBRACE:p0,CLOSEBRACKET:gM,CLOSEPAREN:bM,COLON:Nd,COMMA:eI,DOLLAR:OM,DOT:Pl,EMOJI:Fre,EQUALS:LM,EXCLAMATION:tI,FULLWIDTHGREATERTHAN:TM,FULLWIDTHLEFTPAREN:_M,FULLWIDTHLESSTHAN:AM,FULLWIDTHMIDDLEDOT:Ire,FULLWIDTHRIGHTPAREN:wM,HYPHEN:bo,LEFTCORNERBRACKET:SM,LEFTWHITECORNERBRACKET:EM,LOCALHOST:uy,NL:JL,NUM:QL,OPENANGLEBRACKET:yM,OPENBRACE:m0,OPENBRACKET:pM,OPENPAREN:xM,PERCENT:g0,PIPE:IM,PLUS:FM,POUND:UM,QUERY:x0,QUOTE:nI,RIGHTCORNERBRACKET:MM,RIGHTWHITECORNERBRACKET:NM,SCHEME:vw,SEMI:rI,SLASH:Rl,SLASH_SCHEME:Hp,SYM:BM,TILDE:b0,TLD:sD,UNDERSCORE:zM,UTLD:oD,UWORD:aD,WORD:Vc,WS:lD});const Bc=/[a-z]/,Rb=new RegExp("\\p{L}","u"),Rj=new RegExp("\\p{Emoji}","u"),$c=/\d/,Dj=/\s/,OW="\r",Oj=`
  8293. `,KWe="️",XWe="‍",Lj="";let z1=null,B1=null;function YWe(t=[]){const e={};xs.groups=e;const n=new xs;z1==null&&(z1=LW($We)),B1==null&&(B1=LW(HWe)),jt(n,"'",kM),jt(n,"{",m0),jt(n,"}",p0),jt(n,"[",pM),jt(n,"]",gM),jt(n,"(",xM),jt(n,")",bM),jt(n,"<",yM),jt(n,">",vM),jt(n,"(",_M),jt(n,")",wM),jt(n,"「",SM),jt(n,"」",MM),jt(n,"『",EM),jt(n,"』",NM),jt(n,"<",AM),jt(n,">",TM),jt(n,"&",CM),jt(n,"*",jM),jt(n,"@",vd),jt(n,"`",RM),jt(n,"^",DM),jt(n,":",Nd),jt(n,",",eI),jt(n,"$",OM),jt(n,".",Pl),jt(n,"=",LM),jt(n,"!",tI),jt(n,"-",bo),jt(n,"%",g0),jt(n,"|",IM),jt(n,"+",FM),jt(n,"#",UM),jt(n,"?",x0),jt(n,'"',nI),jt(n,"/",Rl),jt(n,";",rI),jt(n,"~",b0),jt(n,"_",zM),jt(n,"\\",PM),jt(n,"・",Ire);const r=Jr(n,$c,QL,{[tD]:!0});Jr(r,$c,r);const i=Jr(r,Bc,Ore,{[f0]:!0}),a=Jr(r,Rb,Lre,{[Yb]:!0}),o=Jr(n,Bc,Vc,{[nD]:!0});Jr(o,$c,i),Jr(o,Bc,o),Jr(i,$c,i),Jr(i,Bc,i);const l=Jr(n,Rb,aD,{[rD]:!0});Jr(l,Bc),Jr(l,$c,a),Jr(l,Rb,l),Jr(a,$c,a),Jr(a,Bc),Jr(a,Rb,a);const c=jt(n,Oj,JL,{[Pj]:!0}),u=jt(n,OW,lD,{[Pj]:!0}),d=Jr(n,Dj,lD,{[Pj]:!0});jt(n,Lj,d),jt(u,Oj,c),jt(u,Lj,d),Jr(u,Dj,d),jt(d,OW),jt(d,Oj),Jr(d,Dj,d),jt(d,Lj,d);const f=Jr(n,Rj,Fre,{[Dre]:!0});jt(f,"#"),Jr(f,Rj,f),jt(f,KWe,f);const m=jt(f,XWe);jt(m,"#"),Jr(m,Rj,f);const p=[[Bc,o],[$c,i]],b=[[Bc,null],[Rb,l],[$c,a]];for(let v=0;v<z1.length;v++)hd(n,z1[v],sD,Vc,p);for(let v=0;v<B1.length;v++)hd(n,B1[v],oD,aD,b);yf(sD,{tld:!0,ascii:!0},e),yf(oD,{utld:!0,alpha:!0},e),hd(n,"file",vw,Vc,p),hd(n,"mailto",vw,Vc,p),hd(n,"http",Hp,Vc,p),hd(n,"https",Hp,Vc,p),hd(n,"ftp",Hp,Vc,p),hd(n,"ftps",Hp,Vc,p),yf(vw,{scheme:!0,ascii:!0},e),yf(Hp,{slashscheme:!0,ascii:!0},e),t=t.sort((v,x)=>v[0]>x[0]?1:-1);for(let v=0;v<t.length;v++){const x=t[v][0],S=t[v][1]?{[VWe]:!0}:{[GWe]:!0};x.indexOf("-")>=0?S[iD]=!0:Bc.test(x)?$c.test(x)?S[f0]=!0:S[nD]=!0:S[tD]=!0,DW(n,x,x,S)}return DW(n,"localhost",uy,{ascii:!0}),n.jd=new xs(BM),{start:n,tokens:Object.assign({groups:e},Ure)}}function zre(t,e){const n=ZWe(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,m=-1;for(;o<r&&(c=l.go(n[o]));)l=c,l.accepts()?(f=0,m=0,d=l):f>=0&&(f+=n[o].length,m++),u+=n[o].length,a+=n[o].length,o++;a-=f,o-=m,u-=f,i.push({t:d.t,v:e.slice(a-u,a),s:a-u,e:a})}return i}function ZWe(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 hd(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 xs(r),a.jr=i.slice(),t.j[c]=a),t=a}return a=new xs(n),a.jr=i.slice(),t.j[e[o-1]]=a,a}function LW(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 dy={defaultProtocol:"http",events:null,format:IW,formatHref:IW,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function iI(t,e=null){let n=Object.assign({},dy);t&&(n=Object.assign(n,t instanceof iI?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}iI.prototype={o:dy,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]:dy[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 IW(t){return t}function Bre(t,e){this.t="token",this.v=t,this.tk=e}Bre.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=dy.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 PN(t,e){class n extends Bre{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 FW=PN("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),UW=PN("text"),QWe=PN("nl"),$1=PN("url",{isLink:!0,toHref(t=dy.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==uy&&t[1].t===Nd}}),po=t=>new xs(t);function JWe({groups:t}){const e=t.domain.concat([CM,jM,vd,PM,RM,DM,OM,LM,bo,QL,g0,IM,FM,UM,Rl,BM,b0,zM]),n=[kM,Nd,eI,Pl,tI,g0,x0,nI,rI,yM,vM,m0,p0,gM,pM,xM,bM,_M,wM,SM,MM,EM,NM,AM,TM],r=[CM,kM,jM,PM,RM,DM,OM,LM,bo,m0,p0,g0,IM,FM,UM,x0,Rl,BM,b0,zM],i=po(),a=jt(i,b0);_n(a,r,a),_n(a,t.domain,a);const o=po(),l=po(),c=po();_n(i,t.domain,o),_n(i,t.scheme,l),_n(i,t.slashscheme,c),_n(o,r,a),_n(o,t.domain,o);const u=jt(o,vd);jt(a,vd,u),jt(l,vd,u),jt(c,vd,u);const d=jt(a,Pl);_n(d,r,a),_n(d,t.domain,a);const f=po();_n(u,t.domain,f),_n(f,t.domain,f);const m=jt(f,Pl);_n(m,t.domain,f);const p=po(FW);_n(m,t.tld,p),_n(m,t.utld,p),jt(u,uy,p);const b=jt(f,bo);jt(b,bo,b),_n(b,t.domain,f),_n(p,t.domain,f),jt(p,Pl,m),jt(p,bo,b);const v=jt(p,Nd);_n(v,t.numeric,FW);const x=jt(o,bo),y=jt(o,Pl);jt(x,bo,x),_n(x,t.domain,o),_n(y,r,a),_n(y,t.domain,o);const S=po($1);_n(y,t.tld,S),_n(y,t.utld,S),_n(S,t.domain,o),_n(S,r,a),jt(S,Pl,y),jt(S,bo,x),jt(S,vd,u);const M=jt(S,Nd),N=po($1);_n(M,t.numeric,N);const A=po($1),k=po();_n(A,e,A),_n(A,n,k),_n(k,e,A),_n(k,n,k),jt(S,Rl,A),jt(N,Rl,A);const C=jt(l,Nd),D=jt(c,Nd),T=jt(D,Rl),R=jt(T,Rl);_n(l,t.domain,o),jt(l,Pl,y),jt(l,bo,x),_n(c,t.domain,o),jt(c,Pl,y),jt(c,bo,x),_n(C,t.domain,A),jt(C,Rl,A),jt(C,x0,A),_n(R,t.domain,A),_n(R,e,A),jt(R,Rl,A);const U=[[m0,p0],[pM,gM],[xM,bM],[yM,vM],[_M,wM],[SM,MM],[EM,NM],[AM,TM]];for(let L=0;L<U.length;L++){const[q,j]=U[L],W=jt(A,q);jt(k,q,W),jt(W,j,A);const K=po($1);_n(W,e,K);const V=po();_n(W,n),_n(K,e,K),_n(K,n,V),_n(V,e,K),_n(V,n,V),jt(K,j,A),jt(V,j,A)}return jt(i,uy,S),jt(i,JL,QWe),{start:i,tokens:Ure}}function eqe(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,m=-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()?(m=0,f=l):m>=0&&m++,i++,d++;if(m<0)i-=d,i<r&&(o.push(n[i]),i++);else{o.length>0&&(a.push(Ij(UW,e,o)),o=[]),i-=m,d-=m;const p=f.t,b=n.slice(i-d,i);a.push(Ij(p,e,b))}}return o.length>0&&a.push(Ij(UW,e,o)),a}function Ij(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 tqe=typeof console<"u"&&console&&console.warn||(()=>{}),nqe="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Or={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function rqe(){return xs.groups={},Or.scanner=null,Or.parser=null,Or.tokenQueue=[],Or.pluginQueue=[],Or.customSchemes=[],Or.initialized=!1,Or}function zW(t,e=!1){if(Or.initialized&&tqe(`linkifyjs: already initialized - will not register custom scheme "${t}" ${nqe}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
  8294. 1. Must only contain digits, lowercase ASCII letters or "-"
  8295. 2. Cannot start or end with "-"
  8296. 3. "-" cannot repeat`);Or.customSchemes.push([t,e])}function iqe(){Or.scanner=YWe(Or.customSchemes);for(let t=0;t<Or.tokenQueue.length;t++)Or.tokenQueue[t][1]({scanner:Or.scanner});Or.parser=JWe(Or.scanner.tokens);for(let t=0;t<Or.pluginQueue.length;t++)Or.pluginQueue[t][1]({scanner:Or.scanner,parser:Or.parser});return Or.initialized=!0,Or}function aI(t){return Or.initialized||iqe(),eqe(Or.parser.start,t,zre(Or.scanner.start,t))}aI.scan=zre;function $re(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 iI(n),i=aI(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 sI="[\0-   ᠎ -\u2029  ]",aqe=new RegExp(sI),sqe=new RegExp(`${sI}$`),oqe=new RegExp(sI,"g");function lqe(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function cqe(t){return new Yr({key:new Vi("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=are(n.doc,[...e]);if(hre(l).forEach(({newRange:u})=>{const d=u7e(r.doc,u,p=>p.isTextblock);let f,m;if(d.length>1)f=d[0],m=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(!sqe.test(p))return;f=d[0],m=r.doc.textBetween(f.pos,u.to,void 0," ")}if(f&&m){const p=m.split(aqe).filter(Boolean);if(p.length<=0)return!1;const b=p[p.length-1],v=f.pos+m.lastIndexOf(b);if(!b)return!1;const x=aI(b).map(y=>y.toObject(t.defaultProtocol));if(!lqe(x))return!1;x.filter(y=>y.isLink).map(y=>({...y,from:v+y.start+1,to:v+y.end+1})).filter(y=>r.schema.marks.code?!r.doc.rangeHasMark(y.from,y.to,r.schema.marks.code):!0).filter(y=>t.validate(y.value)).filter(y=>t.shouldAutoLink(y.value)).forEach(y=>{qL(y.from,y.to,r.doc).some(S=>S.mark.type===t.type)||o.addMark(y.from,y.to,t.type.create({href:y.href}))})}}),!!o.steps.length)return o}})}function uqe(t){return new Yr({key:new Vi("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{const c=r.target;if(!c)return!1;const u=t.editor.view.dom;o=c.closest("a"),o&&!u.contains(o)&&(o=null)}if(!o)return!1;let l=!1;if(t.enableClickSelection&&(l=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){const c=dre(e.state,t.type.name),u=(i=o.href)!=null?i:c.href,d=(a=o.target)!=null?a:c.target;u&&(window.open(u,d),l=!0)}return l}}})}function dqe(t){return new Yr({key:new Vi("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=$re(c,{defaultProtocol:t.defaultProtocol}).find(d=>d.isLink&&d.value===c);return!c||!u||i!==void 0&&!i(u.value)?!1:t.editor.commands.setMark(t.type,{href:u.href})}}})}function qh(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(oqe,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var Hre=xh.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"){zW(t);return}zW(t.scheme,t.optionalSlashes)})},onDestroy(){rqe()},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)=>!!qh(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>{const e=/^[a-z][a-z0-9+.-]*:\/\//i.test(t),n=/^[a-z][a-z0-9+.-]*:/i.test(t);if(e||n&&!t.includes("@"))return!0;const i=(t.includes("@")?t.split("@").pop():t).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(i)||!/\./.test(i))}}},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=>!!qh(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=>!!qh(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",li(this.options.HTMLAttributes,t),0]:["a",li(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=>!!qh(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=>!!qh(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[sm({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=$re(t).filter(a=>a.isLink&&this.options.isAllowedUri(a.value,{defaultValidate:o=>!!qh(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(cqe({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!qh(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(uqe({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(dqe({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),hqe=Hre,fqe=Object.defineProperty,mqe=(t,e)=>{for(var n in e)fqe(t,n,{get:e[n],enumerable:!0})},pqe="listItem",BW="textStyle",$W=/^\s*([-+*])\s$/,Vre=As.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",li(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,`
  8297. `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(pqe,this.editor.getAttributes(BW)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=$g({find:$W,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=$g({find:$W,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(BW),editor:this.editor})),[t]}}),Gre=As.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",li(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)=>ZL(t,e,r=>{var i,a;return r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${(((a=(i=r.meta)==null?void 0:i.parentAttrs)==null?void 0:a.start)||1)+r.index}. `:"- "},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)}}}),gqe={};mqe(gqe,{findListItemPos:()=>Yy,getNextListDepth:()=>oI,handleBackspace:()=>cD,handleDelete:()=>uD,hasListBefore:()=>Wre,hasListItemAfter:()=>xqe,hasListItemBefore:()=>qre,listItemHasSubList:()=>Kre,nextListIsDeeper:()=>Xre,nextListIsHigher:()=>Yre});var Yy=(t,e)=>{const{$from:n}=e.selection,r=Ti(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}},oI=(t,e)=>{const n=Yy(t,e);if(!n)return!1;const[,r]=v7e(e,t,n.$pos.pos+4);return r},Wre=(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))},qre=(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)},Kre=(t,e,n)=>{if(!n)return!1;const r=Ti(t,e.schema);let i=!1;return n.descendants(a=>{a.type===r&&(i=!0)}),i},cD=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!sh(t.state,e)&&Wre(t.state,e,n)){const{$anchor:l}=t.state.selection,c=t.state.doc.resolve(l.before()-1),u=[];c.node().descendants((m,p)=>{m.type.name===e&&u.push({node:m,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(!sh(t.state,e)||!M7e(t.state))return!1;const r=Yy(e,t.state);if(!r)return!1;const a=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=Kre(e,t.state,a);return qre(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},Xre=(t,e)=>{const n=oI(t,e),r=Yy(t,e);return!r||!n?!1:n>r.depth},Yre=(t,e)=>{const n=oI(t,e),r=Yy(t,e);return!r||!n?!1:n<r.depth},uD=(t,e)=>{if(!sh(t.state,e)||!S7e(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:Xre(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():Yre(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},xqe=(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)},Zre=br.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&&uD(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&&uD(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&&cD(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&&cD(t,n,r)&&(e=!0)}),e}}}}),HW=/^(\s*)(\d+)\.\s+(.*)$/,bqe=/^\s/;function yqe(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n],a=i.match(HW);if(!a)break;const[,o,l,c]=a,u=o.length;let d=c,f=n+1;const m=[i];for(;f<t.length;){const p=t[f];if(p.match(HW))break;if(p.trim()==="")m.push(p),d+=`
  8298. `,f+=1;else if(p.match(bqe))m.push(p),d+=`
  8299. ${p.slice(u+2)}`,f+=1;else break}e.push({indent:u,number:parseInt(l,10),content:d.trim(),raw:m.join(`
  8300. `)}),r=f,n=f}return[e,r]}function Qre(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(`
  8301. `),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(`
  8302. `).trim();if(d){const p=n.blockTokens(d);u.push(...p)}let f=a+1;const m=[];for(;f<t.length&&t[f].indent>e;)m.push(t[f]),f+=1;if(m.length>0){const p=Math.min(...m.map(v=>v.indent)),b=Qre(m,p,n);u.push({type:"list",ordered:!0,start:m[0].number,items:b,raw:m.map(v=>v.raw).join(`
  8303. `)})}i.push({type:"list_item",raw:o.raw,tokens:u}),a=f}else a+=1}return i}function vqe(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 _qe="listItem",VW="textStyle",GW=/^(\d+)\.\s$/,Jre=As.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",li(this.options.HTMLAttributes,n),0]:["ol",li(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?vqe(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,`
  8304. `):"",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(`
  8305. `),[a,o]=yqe(i);if(a.length===0)return;const l=Qre(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(`
  8306. `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(_qe,this.editor.getAttributes(VW)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=$g({find:GW,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=$g({find:GW,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(VW)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),wqe=/^\s*(\[([( |x])?\])\s$/,Sqe=As.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",li(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 ZL(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=f=>{var m,p;l.ariaLabel=((p=(m=this.options.a11y)==null?void 0:m.checkboxLabel)==null?void 0:p.call(m,f,l.checked))||`Task item checkbox for ${f.textContent||"empty task item"}`};u(t),a.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",f=>f.preventDefault()),l.addEventListener("change",f=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:m}=f.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:p})=>{const b=n();if(typeof b!="number")return!1;const v=p.doc.nodeAt(b);return p.setNodeMarkup(b,void 0,{...v?.attrs,checked:m}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,m)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([f,m])=>{i.setAttribute(f,m)}),i.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,a.append(l,o),i.append(a,c),Object.entries(e).forEach(([f,m])=>{i.setAttribute(f,m)});let d=new Set(Object.keys(e));return{dom:i,contentDOM:c,update:f=>{if(f.type!==this.type)return!1;i.dataset.checked=f.attrs.checked,l.checked=f.attrs.checked,u(f);const m=r.extensionManager.attributes,p=cy(f,m),b=new Set(Object.keys(p)),v=this.options.HTMLAttributes;return d.forEach(x=>{b.has(x)||(x in v?i.setAttribute(x,v[x]):i.removeAttribute(x))}),Object.entries(p).forEach(([x,y])=>{y==null?x in v?i.setAttribute(x,v[x]):i.removeAttribute(x):i.setAttribute(x,y)}),d=b,!0}}}},addInputRules(){return[$g({find:wqe,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),Mqe=As.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",li(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,`
  8307. `):"",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=JR(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=JR(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()}}});br.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(Vre.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(Gre.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(Zre.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(Jre.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(Sqe.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(Mqe.configure(this.options.taskList)),t}});var WW="&nbsp;",Eqe=" ",Nqe=As.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",li(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];if(n.length===1&&n[0].type==="image")return e.parseChildren([n[0]]);const r=e.parseInline(n);return r.length===1&&r[0].type==="text"&&(r[0].text===WW||r[0].text===Eqe)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(t,e)=>{if(!t)return"";const n=Array.isArray(t.content)?t.content:[];return n.length===0?WW:e.renderChildren(n)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Aqe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Tqe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Cqe=xh.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",li(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[Bg({find:Aqe,type:this.type})]},addPasteRules(){return[sm({find:Tqe,type:this.type})]}}),kqe=As.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),eie=xh.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",li(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()}}}),jqe=eie;function Pqe(t={}){return new Yr({view(e){return new Rqe(e,t)}})}class Rqe{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,m=e.nodeAfter;if(f||m){let p=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(p){let b=p.getBoundingClientRect(),v=f?b.bottom:b.top;f&&m&&(v=(v+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let x=this.width/2*l;r={left:b.left,right:b.right,top:v-x,bottom:v+x}}}}if(!r){let f=this.editorView.coordsAtPos(this.cursorPos),m=this.width/2*o;r={left:f.left-m,right:f.left+m,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(),m=f.width/c.offsetWidth,p=f.height/c.offsetHeight;u=f.left-c.scrollLeft*m,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=Yte(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 ii extends En{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return ii.valid(r)?new ii(r):En.near(r)}content(){return $t.empty}eq(e){return e instanceof ii&&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 ii(e.resolve(n.pos))}getBookmark(){return new lI(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!Dqe(e)||!Oqe(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&&ii.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(ii.valid(c))return c}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!nn.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(ii.valid(l))return l}return null}}}ii.prototype.visible=!1;ii.findFrom=ii.findGapCursorFrom;En.jsonID("gapcursor",ii);class lI{constructor(e){this.pos=e}map(e){return new lI(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return ii.valid(n)?new ii(n):En.near(n)}}function tie(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function Dqe(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||tie(i.type))return!0;if(i.inlineContent)return!1}}return!0}function Oqe(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||tie(i.type))return!0;if(i.inlineContent)return!1}}return!0}function Lqe(){return new Yr({props:{decorations:zqe,createSelectionBetween(t,e,n){return e.pos==n.pos&&ii.valid(n)?new ii(n):null},handleClick:Fqe,handleKeyDown:Iqe,handleDOMEvents:{beforeinput:Uqe}}})}const Iqe=Zne({ArrowLeft:H1("horiz",-1),ArrowRight:H1("horiz",1),ArrowUp:H1("vert",-1),ArrowDown:H1("vert",1)});function H1(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 fn){if(!a.endOfTextblock(n)||l.depth==0)return!1;c=!1,l=r.doc.resolve(e>0?l.after():l.before())}let u=ii.findGapCursorFrom(l,e,c);return u?(i&&i(r.tr.setSelection(new ii(u))),!0):!1}}function Fqe(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!ii.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&nn.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new ii(r))),!0)}function Uqe(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof ii))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=At.empty;for(let o=r.length-1;o>=0;o--)i=At.from(r[o].createAndFill(null,i));let a=t.state.tr.replace(n.pos,n.pos,new $t(i,0,0));return a.setSelection(fn.near(a.doc.resolve(n.pos+1))),t.dispatch(a),!1}function zqe(t){if(!(t.selection instanceof ii))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Vr.create(t.doc,[Qa.widget(t.selection.head,e,{key:"gapcursor"})])}var $M=200,ia=function(){};ia.prototype.append=function(e){return e.length?(e=ia.from(e),!this.length&&e||e.length<$M&&this.leafAppend(e)||this.length<$M&&e.leafPrepend(this)||this.appendInner(e)):this};ia.prototype.prepend=function(e){return e.length?ia.from(e).append(this):this};ia.prototype.appendInner=function(e){return new Bqe(this,e)};ia.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?ia.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};ia.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};ia.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)};ia.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};ia.from=function(e){return e instanceof ia?e:e&&e.length?new nie(e):ia.empty};var nie=(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<=$M)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=$M)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})(ia);ia.empty=new nie([]);var Bqe=(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})(ia);const $qe=500;class Jo{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,m)=>{if(!f.step){i||(i=this.remapping(r,m+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)),b;p&&o.maybeStep(p).doc&&(b=o.mapping.maps[o.mapping.maps.length-1],u.push(new Dl(b,void 0,void 0,u.length+d.length))),a--,b&&i.appendMap(b,a)}else o.maybeStep(f.step);if(f.selection)return l=i?f.selection.map(i.slice(a)):f.selection,c=new Jo(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]),m=new Dl(e.mapping.maps[d],f,n),p;(p=c&&c.merge(m))&&(m=p,d?a.pop():l=l.slice(0,l.length-1)),a.push(m),n&&(o++,n=void 0),i||(c=m)}let u=o-r.depth;return u>Vqe&&(l=Hqe(l,u),o-=u),new Jo(l.append(a),o)}remapping(e,n){let r=new ry;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 Jo(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(m=>{m.selection&&l--},i);let c=n;this.items.forEach(m=>{let p=a.getMirror(--c);if(p==null)return;o=Math.min(o,p);let b=a.maps[p];if(m.step){let v=e.steps[p].invert(e.docs[p]),x=m.selection&&m.selection.map(a.slice(c+1,p));x&&l++,r.push(new Dl(b,v,x))}else r.push(new Dl(b))},i);let u=[];for(let m=n;m<o;m++)u.push(new Dl(a.maps[m]));let d=this.items.slice(0,i).append(u).append(r),f=new Jo(d,l);return f.emptyItemCount()>$qe&&(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),m,p=i.length-1;(m=i.length&&i[p].merge(f))?i[p]=m:i.push(f)}}else o.map&&r--},this.items.length,0),new Jo(ia.from(i.reverse()),a)}}Jo.empty=new Jo(ia.empty,0);function Hqe(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 _d{constructor(e,n,r,i,a){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=a}}const Vqe=20;function Gqe(t,e,n,r){let i=n.getMeta(Rf),a;if(i)return i.historyState;n.getMeta(Kqe)&&(t=new _d(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(Rf))return o.getMeta(Rf).redo?new _d(t.done.addTransform(n,void 0,r,_w(e)),t.undone,qW(n.mapping.maps),t.prevTime,t.prevComposition):new _d(t.done,t.undone.addTransform(n,void 0,r,_w(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||!Wqe(n,t.prevRanges)),u=o?Fj(t.prevRanges,n.mapping):qW(n.mapping.maps);return new _d(t.done.addTransform(n,c?e.selection.getBookmark():void 0,r,_w(e)),Jo.empty,u,n.time,l??t.prevComposition)}else return(a=n.getMeta("rebased"))?new _d(t.done.rebased(n,a),t.undone.rebased(n,a),Fj(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new _d(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Fj(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function Wqe(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 qW(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 Fj(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 qqe(t,e,n){let r=_w(e),i=Rf.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 _d(n?l:a.remaining,n?a.remaining:l,null,0,-1);return a.transform.setSelection(o).setMeta(Rf,{redo:n,historyState:c})}let Uj=!1,KW=null;function _w(t){let e=t.plugins;if(KW!=e){Uj=!1,KW=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){Uj=!0;break}}return Uj}const Rf=new Vi("history"),Kqe=new Vi("closeHistory");function Xqe(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Yr({key:Rf,state:{init(){return new _d(Jo.empty,Jo.empty,null,0,-1)},apply(e,n,r){return Gqe(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?iie:r=="historyRedo"?aie:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function rie(t,e){return(n,r)=>{let i=Rf.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let a=qqe(i,n,t);a&&r(e?a.scrollIntoView():a)}return!0}}const iie=rie(!1,!0),aie=rie(!0,!0);br.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 Yr({key:new Vi("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 Yqe=br.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Pqe(this.options)]}});br.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Yr({key:new Vi("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:i}=e,a=[];if(!n||!r)return Vr.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(Qa.node(u,u+c.nodeSize,{class:this.options.className}))}),Vr.create(t,a)}}})]}});var Zqe=br.create({name:"gapCursor",addProseMirrorPlugins(){return[Lqe()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=or(en(t,"allowGapCursor",n)))!=null?e:null}}});br.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new Yr({key:new Vi("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&&CN(o);if((c||!this.options.showOnlyCurrent)&&u){const d=[this.options.emptyNodeClass];a&&d.push(this.options.emptyEditorClass);const f=Qa.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}),Vr.create(t,i)}}})]}});br.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new Yr({key:new Vi("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||fre(n.selection)||t.view.dragging?null:Vr.create(n.doc,[Qa.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function XW({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var Qqe=br.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new Vi(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 Yr({key:e,appendTransaction:(i,a,o)=>{const{doc:l,tr:c,schema:u}=o,d=e.getState(o),f=l.content.size,m=u.nodes[n];if(d)return c.insert(f,m.create())},state:{init:(i,a)=>{const o=a.tr.doc.lastChild;return!XW({node:o,types:r})},apply:(i,a)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return a;const o=i.doc.lastChild;return!XW({node:o,types:r})}}})]}}),Jqe=br.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>iie(t,e),redo:()=>({state:t,dispatch:e})=>aie(t,e)}},addProseMirrorPlugins(){return[Xqe(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()}}}),eKe=br.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push(NWe.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(_We.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(Vre.configure(this.options.bulletList)),this.options.code!==!1&&i.push(CWe.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(PWe.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(RWe.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(Yqe.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(Zqe.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(DWe.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(OWe.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(Jqe.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(LWe.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(BWe.configure(this.options.italic)),this.options.listItem!==!1&&i.push(Gre.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(Zre.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(Hre.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(Jre.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(Nqe.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(Cqe.configure(this.options.strike)),this.options.text!==!1&&i.push(kqe.configure(this.options.text)),this.options.underline!==!1&&i.push(eie.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(Qqe.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),tKe=eKe,nKe=br.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")}}}),rKe=nKe,iKe=20,sie=(t,e=0)=>{const n=[];return!t.children.length||e>iKe||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...sie(r,e+1))}),n},aKe=t=>{if(!t.children.length)return;const e=sie(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}`)})},oie=xh.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&aKe(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",li(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}}}}),sKe=br.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()}}}),lie=br.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()}}}),oKe=br.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()}}}),lKe=br.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()}}}),cKe=br.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()}}});br.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(sKe.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(lie.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(oKe.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(lKe.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(cKe.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(oie.configure(this.options.textStyle)),t}});var uKe=lie,dKe=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,hKe=As.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",li(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")return null;const{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:i,getPos:a,HTMLAttributes:o,editor:l})=>{const c=document.createElement("img");Object.entries(o).forEach(([f,m])=>{if(m!=null)switch(f){case"width":case"height":break;default:c.setAttribute(f,m);break}}),c.src=o.src;const u=new u9e({element:c,editor:l,node:i,getPos:a,onResize:(f,m)=>{c.style.width=`${f}px`,c.style.height=`${m}px`},onCommit:(f,m)=>{const p=a();p!==void 0&&this.editor.chain().setNodeSelection(p).updateAttributes(this.name,{width:f,height:m}).run()},onUpdate:(f,m,p)=>f.type===i.type,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:r===!0}}),d=u.dom;return d.style.visibility="hidden",d.style.pointerEvents="none",c.onload=()=>{d.style.visibility="",d.style.pointerEvents=""},u}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[kre({find:dKe,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),fKe=hKe;function dD({content:t,onChange:e,placeholder:n}){const r=gWe({extensions:[tKe.configure({heading:!1,codeBlock:!1,code:!1}),jqe,hqe.configure({openOnClick:!1,HTMLAttributes:{target:"_blank",rel:"noopener noreferrer"}}),rKe.configure({types:["paragraph"]}),oie,uKe,fKe.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(Iue,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().toggleItalic().run(),isActive:r.isActive("italic"),title:"Italic",children:s.jsx(The,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().toggleUnderline().run(),isActive:r.isActive("underline"),title:"Underline",children:s.jsx(xme,{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(lE,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().toggleOrderedList().run(),isActive:r.isActive("orderedList"),title:"Numbered List",children:s.jsx(mK,{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(cme,{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(ame,{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(ome,{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(Xg,{className:"w-4 h-4"})}),r.isActive("link")&&s.jsx(i,{onClick:()=>r.chain().focus().unsetLink().run(),title:"Remove Link",children:s.jsx(BD,{className:"w-4 h-4"})})]}),s.jsx(cWe,{editor:r})]})}function cie({archiveId:t,archiveName:e,onClose:n}){const r=ln(),[i,a]=w.useState(!1),[o,l]=w.useState(null),[c,u]=w.useState({}),{data:d,isLoading:f,error:m}=ft({queryKey:["archive-project-page",t],queryFn:()=>me.getArchiveProjectPage(t)}),p=pt({mutationFn:A=>me.updateArchiveProjectPage(t,A),onSuccess:()=>{r.invalidateQueries({queryKey:["archive-project-page",t]}),a(!1),u({})}});w.useEffect(()=>{const A=k=>{k.key==="Escape"&&(o!==null?l(null):i?y():n())};return document.addEventListener("keydown",A),()=>document.removeEventListener("keydown",A)},[o,i,n]);const b=[...d?.model_pictures||[],...d?.profile_pictures||[]],v=()=>{u({title:d?.title||"",description:d?.description||"",designer:d?.designer||"",license:d?.license||"",profile_title:d?.profile_title||"",profile_description:d?.profile_description||""}),a(!0)},x=()=>{p.mutate(c)},y=()=>{a(!1),u({})},S=A=>{const k=["p","br","b","strong","i","em","u","a","ul","ol","li","figure","img"],C=new DOMParser().parseFromString(A,"text/html"),D=T=>{if(T.nodeType===Node.TEXT_NODE)return T.textContent||"";if(T.nodeType===Node.ELEMENT_NODE){const R=T,U=R.tagName.toLowerCase();if(!k.includes(U))return Array.from(R.childNodes).map(D).join("");let L="";if(U==="a"&&R.getAttribute("href")){const j=R.getAttribute("href");j?.toLowerCase().startsWith("http")&&(L=` href="${j}" target="_blank" rel="noopener noreferrer"`)}if(U==="img"){const j=R.getAttribute("src");if(!j?.toLowerCase().startsWith("http"))return"";L=` src="${j}" style="max-width: 100%; height: auto;"`}const q=Array.from(R.childNodes).map(D).join("");return["br","img"].includes(U)?`<${U}${L} />`:`<${U}${L}>${q}</${U}>`}return""};return Array.from(C.body.childNodes).map(D).join("")},M=d&&(d.title||d.description||d.designer||d.profile_title||b.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(Ya,{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&&M&&s.jsxs(Me,{variant:"ghost",size:"sm",onClick:v,children:[s.jsx(Uf,{className:"w-4 h-4 mr-1"}),"Edit"]}),i&&s.jsxs(s.Fragment,{children:[s.jsx(Me,{variant:"ghost",size:"sm",onClick:y,children:"Cancel"}),s.jsxs(Me,{variant:"primary",size:"sm",onClick:x,disabled:p.isPending,children:[s.jsx(bs,{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(Gt,{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"})}),m&&s.jsx("div",{className:"text-red-400 text-center py-12",children:"Failed to load project page data"}),d&&!M&&s.jsxs("div",{className:"text-bambu-gray text-center py-12",children:[s.jsx(Ya,{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&&M&&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(_P,{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(_P,{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(Gr,{className:"w-3 h-3"})})]}),d.creation_date&&s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[s.jsx(si,{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(Ya,{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(Ya,{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(dD,{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:S(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(dD,{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:S(d.profile_description)}}),d.profile_user_name&&s.jsxs("p",{className:"text-sm text-bambu-gray",children:["by ",d.profile_user_name]})]})]}),b.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(by,{className:"w-4 h-4"}),"Images (",b.length,")"]}),s.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 gap-2",children:b.map((A,k)=>s.jsx("button",{onClick:()=>l(k),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(Gr,{className:"w-4 h-4"}),"View on MakerWorld"]})})]})]})]}),o!==null&&b[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(If,{className:"w-6 h-6 text-white"})}),s.jsx("img",{src:b[o].url,alt:b[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(b.length-1,o+1))},disabled:o===b.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(Zs,{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(Gt,{className:"w-6 h-6 text-white"})}),s.jsxs("div",{className:"absolute bottom-4 text-white text-sm",children:[o+1," / ",b.length]})]})]})}const mKe=[.25,.5,.75,1,1.5,2,3,4];function Op(t){const e=Math.floor(t/60),n=Math.floor(t%60);return`${e}:${n.toString().padStart(2,"0")}`}function pKe({archiveId:t,timelapseSrc:e,onClose:n,onSave:r}){const{showToast:i}=Yn(),a=w.useRef(null),o=w.useRef(null),[l,c]=w.useState(!1),[u,d]=w.useState(0),[f,m]=w.useState(0),[p,b]=w.useState(0),[v,x]=w.useState(0),[y,S]=w.useState(1),[M,N]=w.useState(null),[A,k]=w.useState(null),[C,D]=w.useState(.8),[T,R]=w.useState(!1),{data:U,isLoading:L}=ft({queryKey:["timelapse-info",t],queryFn:()=>me.getTimelapseInfo(t)}),{data:q}=ft({queryKey:["timelapse-thumbnails",t],queryFn:()=>me.getTimelapseThumbnails(t,15)}),j=pt({mutationFn:()=>me.processTimelapse(t,{trimStart:p,trimEnd:v,speed:y,saveMode:"replace"},M||void 0),onSuccess:z=>{i(z.message,"success"),r?.(),n()},onError:z=>{i(z.message||"Processing failed","error")}});w.useEffect(()=>{U?.duration&&v===0&&x(U.duration)},[U?.duration,v]),w.useEffect(()=>{const z=H=>{H.key==="Escape"&&n()};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[n]),w.useEffect(()=>{const z=a.current;if(!z)return;const H=()=>{const fe=z.currentTime;d(fe),fe>=v&&(z.currentTime=p)},Z=()=>{m(z.duration),v===0&&x(z.duration)},ee=()=>c(!0),he=()=>c(!1);return z.addEventListener("timeupdate",H),z.addEventListener("durationchange",Z),z.addEventListener("play",ee),z.addEventListener("pause",he),()=>{z.removeEventListener("timeupdate",H),z.removeEventListener("durationchange",Z),z.removeEventListener("play",ee),z.removeEventListener("pause",he)}},[p,v]),w.useEffect(()=>{const z=o.current,H=a.current;!z||!H||!A||(z.currentTime=H.currentTime,z.playbackRate=H.playbackRate,l&&!T?z.play().catch(()=>{}):z.pause())},[l,A,T]),w.useEffect(()=>{o.current&&(o.current.volume=T?0:C)},[C,T]),w.useEffect(()=>{a.current&&(a.current.playbackRate=y),o.current&&(o.current.playbackRate=y)},[y]);const W=w.useCallback(()=>{const z=a.current;z&&(l?z.pause():(z.currentTime<p&&(z.currentTime=p),z.play()))},[l,p]),K=z=>{const H=a.current;H&&(H.currentTime=Math.max(p,Math.min(v,z)))},V=z=>{const H=z.target.files?.[0];H&&(A&&URL.revokeObjectURL(A),N(H),k(URL.createObjectURL(H)))},J=()=>{A&&URL.revokeObjectURL(A),N(null),k(null)};w.useEffect(()=>()=>{A&&URL.revokeObjectURL(A)},[A]);const ne=v-p,te=ne/y;return L?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(mt,{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(Id,{className:"w-5 h-5 text-bambu-green"}),"Edit Timelapse"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Me,{variant:"primary",size:"sm",onClick:()=>j.mutate(),disabled:j.isPending,children:j.isPending?s.jsxs(s.Fragment,{children:[s.jsx(mt,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):s.jsxs(s.Fragment,{children:[s.jsx(bs,{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(Gt,{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:W,muted:!!A}),!l&&s.jsx("button",{onClick:W,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(ol,{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(Rfe,{className:"w-4 h-4"}),s.jsx("span",{children:"Trim"}),s.jsxs("span",{className:"ml-auto",children:[Op(p)," - ",Op(v)," (",Op(ne),")"]})]}),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((z,H)=>s.jsx("div",{className:"flex-1 bg-cover bg-center",style:{backgroundImage:`url(data:image/jpeg;base64,${z})`}},H))}),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-v)/f*100}%`}}),s.jsx("div",{className:"absolute inset-y-0 border-2 border-bambu-green",style:{left:`${p/f*100}%`,right:`${(f-v)/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:z=>{const H=parseFloat(z.target.value);H<v-1&&(b(H),a.current&&a.current.currentTime<H&&(a.current.currentTime=H))},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:v,onChange:z=>{const H=parseFloat(z.target.value);H>p+1&&x(H)},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:z=>K(parseFloat(z.target.value)),className:`w-full h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
  8308. [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
  8309. [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full
  8310. [&::-webkit-slider-thumb]:cursor-pointer`}),s.jsx("div",{className:"flex items-center justify-center gap-2",children:s.jsx("button",{onClick:W,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:l?s.jsx(UD,{className:"w-5 h-5 text-white"}):s.jsx(ol,{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(iE,{className:"w-4 h-4"}),s.jsx("span",{children:"Speed"}),s.jsxs("span",{className:"ml-auto",children:[y,"x (output: ",Op(te),")"]})]}),s.jsx("div",{className:"flex gap-1",children:mKe.map(z=>s.jsxs("button",{onClick:()=>S(z),className:`flex-1 px-2 py-2 text-sm rounded transition-colors ${y===z?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[z,"x"]},z))})]}),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(yP,{className:"w-4 h-4"}),s.jsx("span",{children:"Music Overlay"})]}),M?s.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[s.jsx(yP,{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:M.name}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[(M.size/1024/1024).toFixed(1)," MB"]})]}),s.jsx("button",{onClick:()=>R(!T),className:"p-2 hover:bg-bambu-dark-tertiary rounded transition-colors",children:T?s.jsx(Nme,{className:"w-4 h-4 text-bambu-gray"}):s.jsx(Mme,{className:"w-4 h-4 text-bambu-green"})}),s.jsx("input",{type:"range",min:0,max:1,step:.1,value:C,onChange:z=>D(parseFloat(z.target.value)),className:`w-20 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
  8311. [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
  8312. [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full`}),s.jsx("button",{onClick:J,className:"p-2 hover:bg-red-500/20 rounded transition-colors",children:s.jsx(hn,{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(fi,{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:"})," ",Op(f)," @ ",U?.width,"x",U?.height]}),s.jsxs("p",{className:"text-bambu-gray",children:[s.jsx("span",{className:"text-white",children:"Output:"})," ",Op(te)," @ ",y,"x speed",M&&" + music overlay"]})]})]}),j.isPending&&s.jsxs("div",{className:"absolute inset-0 bg-black/80 flex flex-col items-center justify-center gap-4",children:[s.jsx(mt,{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 gKe=[.25,.5,.75,1,1.5,2,3,4];function uie({src:t,title:e,downloadFilename:n,archiveId:r,onClose:i,onEdit:a}){const o=w.useRef(null),[l,c]=w.useState(!0),[u,d]=w.useState(1),[f,m]=w.useState(0),[p,b]=w.useState(0),[v,x]=w.useState(!1);w.useEffect(()=>{const C=o.current;C&&(C.playbackRate=u)},[u]),w.useEffect(()=>{const C=D=>{D.key==="Escape"&&i()};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[i]),w.useEffect(()=>{const C=o.current;if(!C)return;const D=()=>m(C.currentTime),T=()=>b(C.duration),R=()=>c(!0),U=()=>c(!1);return C.addEventListener("timeupdate",D),C.addEventListener("durationchange",T),C.addEventListener("play",R),C.addEventListener("pause",U),()=>{C.removeEventListener("timeupdate",D),C.removeEventListener("durationchange",T),C.removeEventListener("play",R),C.removeEventListener("pause",U)}},[]);const y=()=>{const C=o.current;C&&(l?C.pause():C.play())},S=C=>{const D=o.current;D&&(D.currentTime=parseFloat(C.target.value))},M=()=>{const C=o.current;C&&(C.currentTime=Math.max(0,C.currentTime-5))},N=()=>{const C=o.current;C&&(C.currentTime=Math.min(p,C.currentTime+5))},A=C=>{const D=Math.floor(C/60),T=Math.floor(C%60);return`${D}:${T.toString().padStart(2,"0")}`},k=()=>{const C=document.createElement("a");C.href=t,C.download=n,C.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(Id,{className:"w-5 h-5 text-bambu-green"}),e]}),s.jsxs("div",{className:"flex items-center gap-2",children:[r&&s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>x(!0),children:[s.jsx(Na,{className:"w-4 h-4"}),"Edit"]}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:k,children:[s.jsx($r,{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(Gt,{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:y}),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:S,className:`flex-1 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
  8313. [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
  8314. [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full
  8315. [&::-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:M,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip back 5s",children:s.jsx(Vfe,{className:"w-5 h-5 text-bambu-gray"})}),s.jsx("button",{onClick:y,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:l?s.jsx(UD,{className:"w-5 h-5 text-white"}):s.jsx(ol,{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(Ow,{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:gKe.map(C=>s.jsxs("button",{onClick:()=>d(C),className:`px-2 py-1 text-xs rounded transition-colors ${u===C?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:bg-bambu-dark-tertiary/80"}`,children:[C,"x"]},C))})]})]})]})]})]}),v&&r&&s.jsx(pKe,{archiveId:r,timelapseSrc:t,onClose:()=>x(!1),onSave:a})]})}function xKe({archiveIds:t,onClose:e}){w.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:()=>me.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(Gt,{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(mt,{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(Tn,{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(bKe,{comparison:n}):null}),s.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:s.jsx(Me,{variant:"secondary",onClick:e,className:"w-full",children:"Close"})})]})})}function bKe({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-status-ok":e.status==="failed"?"text-status-error":"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(Tn,{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(Tn,{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(Es,{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 yKe(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function vKe(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 _Ke({upload:t,projects:e,onArchive:n,onDiscard:r,isArchiving:i,isDiscarding:a}){const[o,l]=w.useState(!1),[c,u]=w.useState(t.tags||""),[d,f]=w.useState(t.notes||""),[m,p]=w.useState(t.project_id),[b,v]=w.useState(!1);return s.jsx(Nt,{children:s.jsxs(Ct,{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(_f,{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:yKe(t.file_size)}),s.jsx("span",{children:"·"}),s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(Jn,{className:"w-3 h-3"}),vKe(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(du,{className:"w-5 h-5"}):s.jsx(Oi,{className:"w-5 h-5"})}),s.jsx(Me,{variant:"primary",size:"sm",onClick:()=>n(t.id,{tags:c,notes:d,project_id:m||void 0}),disabled:i,children:i?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx(Ja,{className:"w-4 h-4"}),"Archive"]})}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>v(!0),disabled:a,children:a?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(hn,{className:"w-4 h-4 text-red-400"})})]})]}),b&&s.jsx(zn,{title:"Discard Upload",message:`Are you sure you want to discard "${t.filename}"? This cannot be undone.`,confirmText:"Discard",variant:"danger",onConfirm:()=>{r(t.id),v(!1)},onCancel:()=>v(!1)}),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:x=>u(x.target.value),placeholder:"e.g., functional, prototype, gift",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white placeholder-bambu-gray text-sm"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes"}),s.jsx("textarea",{value:d,onChange:x=>f(x.target.value),placeholder:"Add notes about this print...",rows:2,className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white placeholder-bambu-gray text-sm resize-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Project"}),s.jsxs("select",{value:m||"",onChange:x=>p(x.target.value?Number(x.target.value):null),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white text-sm",children:[s.jsx("option",{value:"",children:"No project"}),e.map(x=>s.jsx("option",{value:x.id,children:x.name},x.id))]})]})]})]})})}function wKe(){const t=ln(),{showToast:e}=Yn(),[n,r]=w.useState(!1),[i,a]=w.useState(!1),[o,l]=w.useState(new Set),[c,u]=w.useState(new Set),{data:d,isLoading:f}=ft({queryKey:["pending-uploads"],queryFn:Fp.list,refetchInterval:1e4}),{data:m}=ft({queryKey:["projects"],queryFn:()=>me.getProjects()}),p=pt({mutationFn:({id:y,data:S})=>Fp.archive(y,S),onMutate:({id:y})=>{l(S=>new Set(S).add(y))},onSettled:(y,S,{id:M})=>{l(N=>{const A=new Set(N);return A.delete(M),A})},onSuccess:y=>{t.invalidateQueries({queryKey:["pending-uploads"]}),t.invalidateQueries({queryKey:["archives"]}),e(`Archived: ${y.print_name}`)},onError:y=>{e(y.message||"Failed to archive","error")}}),b=pt({mutationFn:y=>Fp.discard(y),onMutate:y=>{u(S=>new Set(S).add(y))},onSettled:(y,S,M)=>{u(N=>{const A=new Set(N);return A.delete(M),A})},onSuccess:()=>{t.invalidateQueries({queryKey:["pending-uploads"]}),e("Upload discarded")},onError:y=>{e(y.message||"Failed to discard","error")}}),v=pt({mutationFn:Fp.archiveAll,onSuccess:y=>{t.invalidateQueries({queryKey:["pending-uploads"]}),t.invalidateQueries({queryKey:["archives"]}),e(`Archived ${y.archived} files${y.failed>0?`, ${y.failed} failed`:""}`)},onError:y=>{e(y.message||"Failed to archive all","error")}}),x=pt({mutationFn:Fp.discardAll,onSuccess:y=>{t.invalidateQueries({queryKey:["pending-uploads"]}),e(`Discarded ${y.discarded} files`)},onError:y=>{e(y.message||"Failed to discard all","error")}});return f?s.jsx(Nt,{children:s.jsx(Ct,{className:"py-8 flex justify-center",children:s.jsx(mt,{className:"w-6 h-6 animate-spin text-bambu-green"})})}):!d||d.length===0?null:s.jsxs("div",{className:"mb-6",children:[s.jsxs(Nt,{className:"border-l-4 border-l-yellow-500",children:[s.jsx(Er,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(fi,{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(Me,{variant:"primary",size:"sm",onClick:()=>r(!0),disabled:v.isPending,children:v.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx(Ja,{className:"w-4 h-4"}),"Archive All"]})}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>a(!0),disabled:x.isPending,children:x.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx(hn,{className:"w-4 h-4"}),"Discard All"]})})]})]})}),s.jsxs(Ct,{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(y=>s.jsx(_Ke,{upload:y,projects:m||[],onArchive:(S,M)=>p.mutate({id:S,data:M}),onDiscard:S=>b.mutate(S),isArchiving:o.has(y.id),isDiscarding:c.has(y.id)},y.id))})]})]}),n&&s.jsx(zn,{title:"Archive All Uploads",message:`Are you sure you want to archive all ${d.length} pending uploads?`,confirmText:"Archive All",onConfirm:()=>{v.mutate(),r(!1)},onCancel:()=>r(!1)}),i&&s.jsx(zn,{title:"Discard All Uploads",message:`Are you sure you want to discard all ${d.length} pending uploads? This cannot be undone.`,confirmText:"Discard All",variant:"danger",onConfirm:()=>{x.mutate(),a(!1)},onCancel:()=>a(!1)})]})}function HM(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Db(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function sf(t){if(!t)return!1;const e=t.toLowerCase();return e.endsWith(".gcode")||e.includes(".gcode.")}function SKe({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=ln(),{showToast:u}=Yn(),d=TK(),[f,m]=w.useState(!1),[p,b]=w.useState(!1),[v,x]=w.useState(!1),[y,S]=w.useState(!1),[M,N]=w.useState(!1),[A,k]=w.useState(!1),[C,D]=w.useState([]),[T,R]=w.useState(!1),[U,L]=w.useState(!1),[q,j]=w.useState(!1),[W,K]=w.useState(!1),[V,J]=w.useState(!1),[ne,te]=w.useState(!1),[z,H]=w.useState(null),Z=w.useRef(null),ee=w.useRef(null),he=pt({mutationFn:I=>me.uploadSource3mf(t.id,I),onSuccess:I=>{c.invalidateQueries({queryKey:["archives"]}),u(`Source 3MF attached: ${I.filename}`)},onError:I=>{u(I.message||"Failed to upload source 3MF","error")}}),fe=pt({mutationFn:()=>me.deleteSource3mf(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u("Source 3MF removed")},onError:I=>{u(I.message||"Failed to remove source 3MF","error")}}),oe=pt({mutationFn:I=>me.uploadF3d(t.id,I),onSuccess:I=>{c.invalidateQueries({queryKey:["archives"]}),u(`F3D attached: ${I.filename}`)},onError:I=>{u(I.message||"Failed to upload F3D","error")}}),Ne=pt({mutationFn:()=>me.deleteF3d(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u("F3D removed")},onError:I=>{u(I.message||"Failed to remove F3D","error")}}),ge=pt({mutationFn:()=>me.scanArchiveTimelapse(t.id),onSuccess:I=>{I.status==="attached"?(c.invalidateQueries({queryKey:["archives"]}),u(`Timelapse attached: ${I.filename}`)):I.status==="exists"?u("Timelapse already attached"):I.status==="not_found"&&I.available_files&&I.available_files.length>0?(D(I.available_files),k(!0)):u(I.message||"No matching timelapse found","warning")},onError:I=>{u(I.message||"Failed to scan for timelapse","error")}}),Se=pt({mutationFn:I=>me.selectArchiveTimelapse(t.id,I),onSuccess:I=>{c.invalidateQueries({queryKey:["archives"]}),u(`Timelapse attached: ${I.filename}`),k(!1),D([])},onError:I=>{u(I.message||"Failed to attach timelapse","error")}}),Re=pt({mutationFn:()=>me.deleteArchive(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u("Archive deleted")},onError:()=>{u("Failed to delete archive","error")}}),de=pt({mutationFn:()=>me.toggleFavorite(t.id),onSuccess:I=>{c.invalidateQueries({queryKey:["archives"]}),u(I.is_favorite?"Added to favorites":"Removed from favorites")}}),{data:Qe}=ft({queryKey:["archive-folders",t.id],queryFn:()=>me.getLibraryFoldersByArchive(t.id)}),G=pt({mutationFn:I=>me.updateArchive(t.id,{project_id:I}),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),c.invalidateQueries({queryKey:["projects"]}),u("Project updated")},onError:()=>{u("Failed to update project","error")}}),ie=I=>{I.preventDefault(),H({x:I.clientX,y:I.clientY})},$=[...sf(t.filename)?[{label:"Print",icon:s.jsx(Wr,{className:"w-4 h-4"}),onClick:()=>b(!0)},{label:"Schedule",icon:s.jsx(si,{className:"w-4 h-4"}),onClick:()=>K(!0)},{label:"Open in Bambu Studio",icon:s.jsx(Gr,{className:"w-4 h-4"}),onClick:()=>{const I=t.print_name||t.filename||"model",ce=`${window.location.origin}${me.getArchiveForSlicer(t.id,I)}`;Kc(ce)}}]:[{label:"Slice",icon:s.jsx(Gr,{className:"w-4 h-4"}),onClick:()=>{const I=t.print_name||t.filename||"model",ce=`${window.location.origin}${me.getArchiveForSlicer(t.id,I)}`;Kc(ce)}}],{label:t.external_url?"External Link":"View on MakerWorld",icon:s.jsx(Fd,{className:"w-4 h-4"}),onClick:()=>{const I=t.external_url||t.makerworld_url;I&&window.open(I,"_blank")},disabled:!t.external_url&&!t.makerworld_url},{label:"",divider:!0,onClick:()=>{}},{label:"3D Preview",icon:s.jsx(Bs,{className:"w-4 h-4"}),onClick:()=>m(!0)},{label:"View Timelapse",icon:s.jsx(Id,{className:"w-4 h-4"}),onClick:()=>N(!0),disabled:!t.timelapse_path},{label:"Scan for Timelapse",icon:s.jsx(Dw,{className:"w-4 h-4"}),onClick:()=>ge.mutate(),disabled:!t.printer_id||!!t.timelapse_path||ge.isPending},{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?"Download Source 3MF":"Upload Source 3MF",icon:s.jsx(kw,{className:"w-4 h-4"}),onClick:()=>{if(t.source_3mf_path){const I=document.createElement("a");I.href=me.getSource3mfDownloadUrl(t.id),I.download=`${t.print_name||t.filename}_source.3mf`,I.click()}else Z.current?.click()}},...t.source_3mf_path?[{label:"Replace Source 3MF",icon:s.jsx(fi,{className:"w-4 h-4"}),onClick:()=>Z.current?.click()},{label:"Remove Source 3MF",icon:s.jsx(hn,{className:"w-4 h-4"}),onClick:()=>J(!0),danger:!0}]:[],{label:t.f3d_path?"Replace F3D":"Upload F3D",icon:s.jsx(Bs,{className:"w-4 h-4"}),onClick:()=>ee.current?.click()},...t.f3d_path?[{label:"Download F3D",icon:s.jsx($r,{className:"w-4 h-4"}),onClick:()=>{const I=document.createElement("a");I.href=me.getF3dDownloadUrl(t.id),I.download=`${t.print_name||t.filename}.f3d`,I.click()}},{label:"Remove F3D",icon:s.jsx(hn,{className:"w-4 h-4"}),onClick:()=>te(!0),danger:!0}]:[],{label:"",divider:!0,onClick:()=>{}},{label:"Download",icon:s.jsx($r,{className:"w-4 h-4"}),onClick:()=>{const I=document.createElement("a");I.href=me.getArchiveDownload(t.id),I.download=`${t.print_name||t.filename}.3mf`,I.click()}},{label:"Copy Download Link",icon:s.jsx(il,{className:"w-4 h-4"}),onClick:()=>{const I=`${window.location.origin}${me.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(I).then(()=>{u("Link copied to clipboard")}).catch(()=>{u("Failed to copy link","error")})}},{label:"QR Code",icon:s.jsx(bK,{className:"w-4 h-4"}),onClick:()=>R(!0)},{label:`View Photos${t.photos?.length?` (${t.photos.length})`:""}`,icon:s.jsx(fg,{className:"w-4 h-4"}),onClick:()=>L(!0),disabled:!t.photos?.length},{label:"Project Page",icon:s.jsx(Ya,{className:"w-4 h-4"}),onClick:()=>j(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?"Remove from Favorites":"Add to Favorites",icon:s.jsx(zf,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>de.mutate()},{label:"Edit",icon:s.jsx(Na,{className:"w-4 h-4"}),onClick:()=>S(!0)},...t.project_id&&t.project_name?[{label:`Go to Project: ${t.project_name}`,icon:s.jsx(Ea,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:"Add to Project",icon:s.jsx(Ea,{className:"w-4 h-4"}),onClick:()=>{},submenu:(()=>{const I=[];if(t.project_id&&I.push({label:"Remove from Project",icon:s.jsx(Gt,{className:"w-4 h-4"}),onClick:()=>G.mutate(null)}),!a)I.push({label:"Loading...",icon:s.jsx(mt,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const ce=a.filter(Ee=>Ee.status==="active");ce.length===0?I.push({label:"No projects available",icon:s.jsx(Ea,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):ce.forEach(Ee=>{I.push({label:Ee.name,icon:s.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:Ee.color||"#888"}}),onClick:()=>G.mutate(Ee.id),disabled:t.project_id===Ee.id})})}return I})()},{label:n?"Deselect":"Select",icon:n?s.jsx(ll,{className:"w-4 h-4"}):s.jsx(cl,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:"Delete",icon:s.jsx(hn,{className:"w-4 h-4"}),onClick:()=>x(!0),danger:!0}];return s.jsxs(Nt,{"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:ie,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:I=>{I.stopPropagation(),r(t.id)},children:n?s.jsx(ll,{className:"w-5 h-5 text-bambu-green"}):s.jsx(cl,{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:me.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(by,{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:I=>{I.stopPropagation();const ce=I.currentTarget.getBoundingClientRect();H({x:ce.left,y:ce.bottom+4})},title:"Right-click for more options",children:s.jsx(Ld,{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:I=>{I.stopPropagation(),de.mutate()},title:t.is_favorite?"Remove from favorites":"Add to favorites",children:s.jsx(zf,{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-status-error/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(il,{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:I=>{I.stopPropagation();const ce=(t.print_name||t.filename||"source").replace(/\.gcode\.3mf$/i,"")+"_source",Ee=`${window.location.origin}${me.getSource3mfForSlicer(t.id,ce)}`;Kc(Ee)},title:"Open source 3MF in Bambu Studio (right-click for more options)",children:s.jsx(kw,{className:"w-4 h-4 text-orange-400"})}),t.f3d_path&&s.jsx("button",{className:`absolute bottom-2 ${t.source_3mf_path?"left-12":"left-2"} p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors`,onClick:I=>{I.stopPropagation(),window.location.href=me.getF3dDownloadUrl(t.id)},title:"Download Fusion 360 design file",children:s.jsx(Bs,{className:"w-4 h-4 text-cyan-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:I=>{I.stopPropagation(),N(!0)},title:"View timelapse",children:s.jsx(Id,{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:I=>{I.stopPropagation(),L(!0)},title:`View ${t.photos.length} photo${t.photos.length>1?"s":""}`,children:[s.jsx(fg,{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})]}),Qe&&Qe.length>0&&s.jsx(ps,{to:`/files?folder=${Qe[0].id}`,className:"absolute bottom-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:I=>I.stopPropagation(),title:`Open folder: ${Qe[0].name}`,style:{left:t.source_3mf_path?t.f3d_path?"5.5rem":"3rem":t.f3d_path?"3rem":"0.5rem"},children:s.jsx(al,{className:"w-4 h-4 text-yellow-400"})})]}),s.jsxs(Ct,{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 ${sf(t.filename)?"bg-bambu-green/20 text-bambu-green":"bg-orange-500/20 text-orange-400"}`,title:sf(t.filename)?"Sliced file - ready to print":"Source file only - no AMS mapping available",children:sf(t.filename)?"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(I=>I.id===t.project_id)?.color||"#6b7280"}20`,color:a?.find(I=>I.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: ${Db(t.print_time_seconds||0)}
  8316. Actual: ${Db(t.actual_time_seconds||0)}
  8317. Accuracy: ${t.time_accuracy.toFixed(0)}%`:t.actual_time_seconds?`Actual: ${Db(t.actual_time_seconds)}`:`Estimated: ${Db(t.print_time_seconds||0)}`,children:[s.jsx(Jn,{className:"w-3 h-3"}),Db(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(Ql,{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(sl,{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(Bs,{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((I,ce)=>s.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:I},title:I},ce))})]})]}),(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(vK,{className:"w-3 h-3"})}),t.tags?.split(",").map((I,ce)=>s.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-dark-tertiary text-bambu-gray-light rounded text-xs",children:I.trim()},ce))]}),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:bg(t.created_at,l)}),s.jsx("span",{children:HM(t.file_size)})]}),s.jsxs("div",{className:"flex gap-1 mt-3",children:[sf(t.filename)?s.jsxs(s.Fragment,{children:[s.jsxs(Me,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>b(!0),children:[s.jsx(Wr,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{className:"hidden sm:inline",children:"Reprint"})]}),s.jsx(Me,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const I=t.print_name||t.filename||"model",ce=`${window.location.origin}${me.getArchiveForSlicer(t.id,I)}`;Kc(ce)},title:"Open in Bambu Studio",children:s.jsx(Gr,{className:"w-3 h-3 sm:w-4 sm:h-4"})})]}):s.jsxs(Me,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>{const I=t.print_name||t.filename||"model",ce=`${window.location.origin}${me.getArchiveForSlicer(t.id,I)}`;Kc(ce)},title:"Open in Bambu Studio to slice",children:[s.jsx(Gr,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{className:"hidden sm:inline",children:"Slice"})]}),s.jsx(Me,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const I=t.external_url||t.makerworld_url;I&&window.open(I,"_blank")},disabled:!t.external_url&&!t.makerworld_url,title:t.external_url?"External Link":t.makerworld_url?`MakerWorld: ${t.designer||"View project"}`:"No external link",children:s.jsx(Fd,{className:`w-3 h-3 sm:w-4 sm:h-4 ${!t.external_url&&!t.makerworld_url?"opacity-20":""}`})}),s.jsx(Me,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>m(!0),title:"3D Preview",children:s.jsx(Bs,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),s.jsx(Me,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const I=document.createElement("a");I.href=me.getArchiveDownload(t.id),I.download=`${t.print_name||t.filename}.3mf`,I.click()},title:"Download",children:s.jsx($r,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),s.jsx(Me,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>S(!0),title:"Edit",children:s.jsx(Na,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),s.jsx(Me,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>x(!0),title:"Delete",children:s.jsx(hn,{className:"w-3 h-3 sm:w-4 sm:h-4 text-red-400"})})]})]}),y&&s.jsx(vte,{archive:t,onClose:()=>S(!1)}),f&&s.jsx(gte,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>m(!1)}),p&&s.jsx(ih,{mode:"reprint",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>b(!1)}),v&&s.jsx(zn,{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:()=>{Re.mutate(),x(!1)},onCancel:()=>x(!1)}),V&&s.jsx(zn,{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:()=>{fe.mutate(),J(!1)},onCancel:()=>J(!1)}),ne&&s.jsx(zn,{title:"Remove F3D",message:`Are you sure you want to remove the Fusion 360 design file from "${t.print_name||t.filename}"?`,confirmText:"Remove",variant:"danger",onConfirm:()=>{Ne.mutate(),te(!1)},onCancel:()=>te(!1)}),z&&s.jsx(_te,{x:z.x,y:z.y,items:$,onClose:()=>H(null)}),M&&t.timelapse_path&&s.jsx(uie,{src:me.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&&C.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:()=>{k(!1),D([])},className:"text-gray-400 hover:text-white p-1",children:s.jsx(Gt,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:C.map(I=>s.jsxs("button",{onClick:()=>Se.mutate(I.name),disabled:Se.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(Id,{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:I.name}),s.jsxs("p",{className:"text-sm text-gray-400",children:[HM(I.size),I.mtime&&` • ${bg(I.mtime,l)}`]})]})]},I.name))}),s.jsx("div",{className:"p-4 border-t border-gray-700",children:s.jsx(Me,{variant:"secondary",onClick:()=>{k(!1),D([])},className:"w-full",children:"Cancel"})})]})}),T&&s.jsx(wte,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>R(!1)}),U&&t.photos&&t.photos.length>0&&s.jsx(Ste,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>L(!1),onDelete:async I=>{try{await me.deleteArchivePhoto(t.id,I),c.invalidateQueries({queryKey:["archives"]}),u("Photo deleted")}catch{u("Failed to delete photo","error")}}}),q&&s.jsx(cie,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>j(!1)}),W&&s.jsx(ih,{mode:"add-to-queue",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>K(!1)}),s.jsx("input",{ref:Z,type:"file",accept:".3mf",className:"hidden",onChange:I=>{const ce=I.target.files?.[0];ce&&he.mutate(ce),I.target.value=""}}),s.jsx("input",{ref:ee,type:"file",accept:".f3d",className:"hidden",onChange:I=>{const ce=I.target.files?.[0];ce&&oe.mutate(ce),I.target.value=""}})]})}function MKe({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i,projects:a,isHighlighted:o}){const l=ln(),{showToast:c}=Yn(),[u,d]=w.useState(!1),[f,m]=w.useState(!1),[p,b]=w.useState(!1),[v,x]=w.useState(!1),[y,S]=w.useState(!1),[M,N]=w.useState(!1),[A,k]=w.useState(!1),[C,D]=w.useState([]),[T,R]=w.useState(!1),[U,L]=w.useState(!1),[q,j]=w.useState(!1),[W,K]=w.useState(!1),[V,J]=w.useState(!1),[ne,te]=w.useState(null),z=w.useRef(null),H=w.useRef(null),Z=pt({mutationFn:X=>me.uploadSource3mf(t.id,X),onSuccess:X=>{l.invalidateQueries({queryKey:["archives"]}),c(`Source 3MF attached: ${X.filename}`)},onError:X=>{c(X.message||"Failed to upload source 3MF","error")}}),ee=pt({mutationFn:()=>me.deleteSource3mf(t.id),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),c("Source 3MF removed")},onError:X=>{c(X.message||"Failed to remove source 3MF","error")}}),he=pt({mutationFn:X=>me.uploadF3d(t.id,X),onSuccess:X=>{l.invalidateQueries({queryKey:["archives"]}),c(`F3D attached: ${X.filename}`)},onError:X=>{c(X.message||"Failed to upload F3D","error")}}),fe=pt({mutationFn:()=>me.deleteF3d(t.id),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),c("F3D removed")},onError:X=>{c(X.message||"Failed to remove F3D","error")}}),oe=pt({mutationFn:()=>me.scanArchiveTimelapse(t.id),onSuccess:X=>{X.status==="attached"?(l.invalidateQueries({queryKey:["archives"]}),c(`Timelapse attached: ${X.filename}`)):X.status==="exists"?c("Timelapse already attached"):X.status==="not_found"&&X.available_files&&X.available_files.length>0?(D(X.available_files),k(!0)):c(X.message||"No matching timelapse found","warning")},onError:X=>{c(X.message||"Failed to scan for timelapse","error")}}),Ne=pt({mutationFn:X=>me.selectArchiveTimelapse(t.id,X),onSuccess:X=>{l.invalidateQueries({queryKey:["archives"]}),c(`Timelapse attached: ${X.filename}`),k(!1),D([])},onError:X=>{c(X.message||"Failed to attach timelapse","error")}}),ge=pt({mutationFn:()=>me.deleteArchive(t.id),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),c("Archive deleted")},onError:()=>{c("Failed to delete archive","error")}}),Se=pt({mutationFn:()=>me.toggleFavorite(t.id),onSuccess:X=>{l.invalidateQueries({queryKey:["archives"]}),c(X.is_favorite?"Added to favorites":"Removed from favorites")}}),{data:Re}=ft({queryKey:["archive-folders",t.id],queryFn:()=>me.getLibraryFoldersByArchive(t.id)}),de=pt({mutationFn:X=>me.updateArchive(t.id,{project_id:X}),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),l.invalidateQueries({queryKey:["projects"]}),c("Project updated")},onError:()=>{c("Failed to update project","error")}}),Qe=X=>{X.preventDefault(),te({x:X.clientX,y:X.clientY})},ie=[...sf(t.filename)?[{label:"Print",icon:s.jsx(Wr,{className:"w-4 h-4"}),onClick:()=>b(!0)},{label:"Schedule",icon:s.jsx(si,{className:"w-4 h-4"}),onClick:()=>x(!0)},{label:"Open in Bambu Studio",icon:s.jsx(Gr,{className:"w-4 h-4"}),onClick:()=>{const X=t.print_name||t.filename||"model",$=`${window.location.origin}${me.getArchiveForSlicer(t.id,X)}`;Kc($)}}]:[{label:"Slice",icon:s.jsx(Gr,{className:"w-4 h-4"}),onClick:()=>{const X=t.print_name||t.filename||"model",$=`${window.location.origin}${me.getArchiveForSlicer(t.id,X)}`;Kc($)}}],{label:t.external_url?"External Link":"View on MakerWorld",icon:s.jsx(Fd,{className:"w-4 h-4"}),onClick:()=>{const X=t.external_url||t.makerworld_url;X&&window.open(X,"_blank")},disabled:!t.external_url&&!t.makerworld_url},{label:"",divider:!0,onClick:()=>{}},{label:"3D Preview",icon:s.jsx(Bs,{className:"w-4 h-4"}),onClick:()=>S(!0)},{label:"View Timelapse",icon:s.jsx(Id,{className:"w-4 h-4"}),onClick:()=>N(!0),disabled:!t.timelapse_path},{label:"Scan for Timelapse",icon:s.jsx(Dw,{className:"w-4 h-4"}),onClick:()=>oe.mutate(),disabled:!t.printer_id||!!t.timelapse_path||oe.isPending},{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?"Download Source 3MF":"Upload Source 3MF",icon:s.jsx(kw,{className:"w-4 h-4"}),onClick:()=>{if(t.source_3mf_path){const X=document.createElement("a");X.href=me.getSource3mfDownloadUrl(t.id),X.download=`${t.print_name||t.filename}_source.3mf`,X.click()}else z.current?.click()}},...t.source_3mf_path?[{label:"Replace Source 3MF",icon:s.jsx(fi,{className:"w-4 h-4"}),onClick:()=>z.current?.click()},{label:"Remove Source 3MF",icon:s.jsx(hn,{className:"w-4 h-4"}),onClick:()=>K(!0),danger:!0}]:[],{label:t.f3d_path?"Replace F3D":"Upload F3D",icon:s.jsx(Bs,{className:"w-4 h-4"}),onClick:()=>H.current?.click()},...t.f3d_path?[{label:"Download F3D",icon:s.jsx($r,{className:"w-4 h-4"}),onClick:()=>{const X=document.createElement("a");X.href=me.getF3dDownloadUrl(t.id),X.download=`${t.print_name||t.filename}.f3d`,X.click()}},{label:"Remove F3D",icon:s.jsx(hn,{className:"w-4 h-4"}),onClick:()=>J(!0),danger:!0}]:[],{label:"",divider:!0,onClick:()=>{}},{label:"Download",icon:s.jsx($r,{className:"w-4 h-4"}),onClick:()=>{const X=document.createElement("a");X.href=me.getArchiveDownload(t.id),X.download=`${t.print_name||t.filename}.3mf`,X.click()}},{label:"Copy Download Link",icon:s.jsx(il,{className:"w-4 h-4"}),onClick:()=>{const X=`${window.location.origin}${me.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(X).then(()=>{c("Link copied to clipboard")}).catch(()=>{c("Failed to copy link","error")})}},{label:"QR Code",icon:s.jsx(bK,{className:"w-4 h-4"}),onClick:()=>R(!0)},{label:`View Photos${t.photos?.length?` (${t.photos.length})`:""}`,icon:s.jsx(fg,{className:"w-4 h-4"}),onClick:()=>L(!0),disabled:!t.photos?.length},{label:"Project Page",icon:s.jsx(Ya,{className:"w-4 h-4"}),onClick:()=>j(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?"Remove from Favorites":"Add to Favorites",icon:s.jsx(zf,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>Se.mutate()},{label:"Edit",icon:s.jsx(Na,{className:"w-4 h-4"}),onClick:()=>d(!0)},...t.project_id&&t.project_name?[{label:`Go to Project: ${t.project_name}`,icon:s.jsx(Ea,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:"Add to Project",icon:s.jsx(Ea,{className:"w-4 h-4"}),onClick:()=>{},submenu:(()=>{const X=[];if(t.project_id&&X.push({label:"Remove from Project",icon:s.jsx(Gt,{className:"w-4 h-4"}),onClick:()=>de.mutate(null)}),!a)X.push({label:"Loading...",icon:s.jsx(mt,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const $=a.filter(I=>I.status==="active");$.length===0?X.push({label:"No projects available",icon:s.jsx(Ea,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):$.forEach(I=>{X.push({label:I.name,icon:s.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:I.color||"#888"}}),onClick:()=>de.mutate(I.id),disabled:t.project_id===I.id})})}return X})()},{label:n?"Deselect":"Select",icon:n?s.jsx(ll,{className:"w-4 h-4"}):s.jsx(cl,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:"Delete",icon:s.jsx(hn,{className:"w-4 h-4"}),onClick:()=>m(!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:Qe,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(ll,{className:"w-4 h-4 text-bambu-green"}):s.jsx(cl,{className:"w-4 h-4 text-bambu-gray"})}),t.thumbnail_path?s.jsx("img",{src:me.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(by,{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(Id,{className:"w-3.5 h-3.5 text-bambu-green flex-shrink-0"})}),Re&&Re.length>0&&s.jsx(ps,{to:`/files?folder=${Re[0].id}`,className:"flex-shrink-0",title:`Open folder: ${Re[0].name}`,onClick:X=>X.stopPropagation(),children:s.jsx(al,{className:"w-3.5 h-3.5 text-yellow-400"})})]}),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((X,$)=>s.jsx("div",{className:"w-2.5 h-2.5 rounded-full border border-white/20",style:{backgroundColor:X},title:X},$))})]})]}),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:xg(t.created_at)}),s.jsx("div",{className:"col-span-1 text-sm text-bambu-gray",children:HM(t.file_size)}),s.jsxs("div",{className:"col-span-2 flex justify-end gap-1",children:[s.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>{const X=t.print_name||t.filename||"model",$=`${window.location.origin}${me.getArchiveForSlicer(t.id,X)}`;Kc($)},title:"Open in Bambu Studio",children:s.jsx(Gr,{className:"w-4 h-4"})}),(t.external_url||t.makerworld_url)&&s.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>window.open(t.external_url||t.makerworld_url,"_blank"),title:t.external_url?"External Link":"MakerWorld",children:s.jsx(Fd,{className:"w-4 h-4"})}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>{const X=document.createElement("a");X.href=me.getArchiveDownload(t.id),X.download=`${t.print_name||t.filename}.3mf`,X.click()},title:"Download",children:s.jsx($r,{className:"w-4 h-4"})}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>d(!0),title:"Edit",children:s.jsx(Na,{className:"w-4 h-4"})}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>m(!0),title:"Delete",children:s.jsx(hn,{className:"w-4 h-4 text-red-400"})}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:X=>{const $=X.currentTarget.getBoundingClientRect();te({x:$.left,y:$.bottom+4})},title:"More options",children:s.jsx(Ld,{className:"w-4 h-4"})})]})]}),u&&s.jsx(vte,{archive:t,onClose:()=>d(!1)}),y&&s.jsx(gte,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>S(!1)}),p&&s.jsx(ih,{mode:"reprint",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>b(!1)}),f&&s.jsx(zn,{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:()=>{ge.mutate(),m(!1)},onCancel:()=>m(!1)}),W&&s.jsx(zn,{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:()=>{ee.mutate(),K(!1)},onCancel:()=>K(!1)}),V&&s.jsx(zn,{title:"Remove F3D",message:`Are you sure you want to remove the Fusion 360 design file from "${t.print_name||t.filename}"?`,confirmText:"Remove",variant:"danger",onConfirm:()=>{fe.mutate(),J(!1)},onCancel:()=>J(!1)}),ne&&s.jsx(_te,{x:ne.x,y:ne.y,items:ie,onClose:()=>te(null)}),M&&t.timelapse_path&&s.jsx(uie,{src:me.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&&C.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:()=>{k(!1),D([])},className:"text-gray-400 hover:text-white p-1",children:s.jsx(Gt,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:C.map(X=>s.jsxs("button",{onClick:()=>Ne.mutate(X.name),disabled:Ne.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:X.name}),s.jsxs("div",{className:"text-sm text-gray-400 flex gap-3",children:[s.jsx("span",{children:HM(X.size)}),X.mtime&&s.jsx("span",{children:xg(X.mtime)})]})]},X.name))})]})}),T&&s.jsx(wte,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>R(!1)}),U&&t.photos&&s.jsx(Ste,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>L(!1),onDelete:async X=>{try{await me.deleteArchivePhoto(t.id,X),l.invalidateQueries({queryKey:["archives"]}),c("Photo deleted")}catch{c("Failed to delete photo","error")}}}),q&&s.jsx(cie,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>j(!1)}),v&&s.jsx(ih,{mode:"add-to-queue",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>x(!1)}),s.jsx("input",{ref:z,type:"file",accept:".3mf",className:"hidden",onChange:X=>{const $=X.target.files?.[0];$&&Z.mutate($),X.target.value=""}}),s.jsx("input",{ref:H,type:"file",accept:".f3d",className:"hidden",onChange:X=>{const $=X.target.files?.[0];$&&he.mutate($),X.target.value=""}})]})}const EKe=[{id:"all",label:"All Archives",icon:s.jsx(al,{className:"w-4 h-4"})},{id:"recent",label:"Last 24 Hours",icon:s.jsx(Jn,{className:"w-4 h-4"})},{id:"this-week",label:"This Week",icon:s.jsx(si,{className:"w-4 h-4"})},{id:"this-month",label:"This Month",icon:s.jsx(si,{className:"w-4 h-4"})},{id:"favorites",label:"Favorites",icon:s.jsx(zf,{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(il,{className:"w-4 h-4"})}];function NKe(){const t=ln(),{showToast:e}=Yn(),n=w.useRef(null),[r,i]=w.useState(""),[a,o]=w.useState(()=>{const re=localStorage.getItem("archiveFilterPrinter");return re?Number(re):null}),[l,c]=w.useState(()=>localStorage.getItem("archiveFilterMaterial")),[u,d]=w.useState(()=>{const re=localStorage.getItem("archiveFilterColors");return re?new Set(JSON.parse(re)):new Set}),[f,m]=w.useState(()=>localStorage.getItem("archiveColorFilterMode")||"or"),[p,b]=w.useState(()=>localStorage.getItem("archiveFilterFavorites")==="true"),[v,x]=w.useState(()=>localStorage.getItem("archiveHideFailed")==="true"),[y,S]=w.useState(()=>localStorage.getItem("archiveFilterTag")),[M,N]=w.useState(()=>localStorage.getItem("archiveFilterFileType")||"all"),[A,k]=w.useState(!1),[C,D]=w.useState([]),[T,R]=w.useState(!1),[U,L]=w.useState(new Set),[q,j]=w.useState(!1),[W,K]=w.useState(!1),[V,J]=w.useState(!1),[ne,te]=w.useState(!1),[z,H]=w.useState(()=>localStorage.getItem("archiveViewMode")||"grid"),[Z,ee]=w.useState(()=>localStorage.getItem("archiveSortBy")||"date-desc"),[he,fe]=w.useState(()=>localStorage.getItem("archiveCollection")||"all"),[oe,Ne]=w.useState(!1),[ge,Se]=w.useState(!1),[Re,de]=w.useState(!1),[Qe,G]=w.useState(null);w.useEffect(()=>{if(Qe){const re=setTimeout(()=>{const ve=document.querySelector(`[data-archive-id="${Qe}"]`);ve&&ve.scrollIntoView({behavior:"smooth",block:"center"})},100),Fe=setTimeout(()=>G(null),5e3);return()=>{clearTimeout(re),clearTimeout(Fe)}}},[Qe]);const{data:ie,isLoading:X}=ft({queryKey:["archives",a],queryFn:()=>me.getArchives(a||void 0)}),{data:$}=ft({queryKey:["printers"],queryFn:me.getPrinters}),{data:I}=ft({queryKey:["projects"],queryFn:()=>me.getProjects()}),{data:ce}=ft({queryKey:["settings"],queryFn:me.getSettings}),Ee=ce?.time_format||"system",Ie=pt({mutationFn:async re=>(await Promise.all(re.map(Fe=>me.deleteArchive(Fe))),re.length),onSuccess:re=>{t.invalidateQueries({queryKey:["archives"]}),L(new Set),e(`${re} archive${re!==1?"s":""} deleted`)},onError:()=>{e("Failed to delete archives","error")}});w.useEffect(()=>{a!==null?localStorage.setItem("archiveFilterPrinter",a.toString()):localStorage.removeItem("archiveFilterPrinter")},[a]),w.useEffect(()=>{l?localStorage.setItem("archiveFilterMaterial",l):localStorage.removeItem("archiveFilterMaterial")},[l]),w.useEffect(()=>{localStorage.setItem("archiveFilterColors",JSON.stringify([...u]))},[u]),w.useEffect(()=>{localStorage.setItem("archiveColorFilterMode",f)},[f]),w.useEffect(()=>{localStorage.setItem("archiveFilterFavorites",p.toString())},[p]),w.useEffect(()=>{localStorage.setItem("archiveHideFailed",v.toString())},[v]),w.useEffect(()=>{y?localStorage.setItem("archiveFilterTag",y):localStorage.removeItem("archiveFilterTag")},[y]),w.useEffect(()=>{localStorage.setItem("archiveFilterFileType",M)},[M]),w.useEffect(()=>{localStorage.setItem("archiveViewMode",z)},[z]),w.useEffect(()=>{localStorage.setItem("archiveSortBy",Z)},[Z]),w.useEffect(()=>{localStorage.setItem("archiveCollection",he)},[he]);const le=new Map($?.map(re=>[re.id,re.name])||[]),B=[...new Set(ie?.flatMap(re=>re.filament_type?.split(", ")||[]).filter(Boolean)||[])].sort(),O=[...new Set(ie?.flatMap(re=>re.filament_color?.split(",")||[]).filter(Boolean)||[])],Y=[...new Set(ie?.flatMap(re=>re.tags?.split(",").map(Fe=>Fe.trim())||[]).filter(Boolean)||[])].sort(),pe=ie?.filter(re=>{const Fe=new Date,ve=Si(re.created_at)||new Date(0);let $e=!0;switch(he){case"recent":$e=Fe.getTime()-ve.getTime()<1440*60*1e3;break;case"this-week":$e=Fe.getTime()-ve.getTime()<10080*60*1e3;break;case"this-month":$e=ve.getMonth()===Fe.getMonth()&&ve.getFullYear()===Fe.getFullYear();break;case"favorites":$e=re.is_favorite===!0;break;case"failed":$e=re.status==="failed"||re.status==="aborted";break;case"duplicates":$e=re.duplicate_count>0;break}const Le=(re.print_name||re.filename).toLowerCase().includes(r.toLowerCase()),Ae=!l||re.filament_type?.split(", ").includes(l),Ge=re.filament_color?.split(",")||[],it=u.size===0||(f==="or"?Ge.some(Yt=>u.has(Yt)):[...u].every(Yt=>Ge.includes(Yt))),Ot=he==="favorites"||!p||re.is_favorite,kt=he==="failed"||!v||re.status!=="failed"&&re.status!=="aborted",on=re.tags?.split(",").map(Yt=>Yt.trim())||[],Ut=!y||on.includes(y),yn=sf(re.filename);return $e&&Le&&Ae&&it&&Ot&&kt&&Ut&&(M==="all"||M==="gcode"&&yn||M==="source"&&!yn)}).sort((re,Fe)=>{switch(Z){case"date-desc":return(Si(Fe.created_at)?.getTime()||0)-(Si(re.created_at)?.getTime()||0);case"date-asc":return(Si(re.created_at)?.getTime()||0)-(Si(Fe.created_at)?.getTime()||0);case"name-asc":return(re.print_name||re.filename).localeCompare(Fe.print_name||Fe.filename);case"name-desc":return(Fe.print_name||Fe.filename).localeCompare(re.print_name||re.filename);case"size-desc":return Fe.file_size-re.file_size;case"size-asc":return re.file_size-Fe.file_size;default:return 0}}),we=q||U.size>0,ae=re=>{L(Fe=>{const ve=new Set(Fe);return ve.has(re)?ve.delete(re):ve.add(re),ve})},ke=()=>{pe&&L(new Set(pe.map(re=>re.id)))},De=()=>{L(new Set),j(!1)},Ke=re=>{d(Fe=>{const ve=new Set(Fe);return ve.has(re)?ve.delete(re):ve.add(re),ve})},et=()=>{d(new Set)},Ye=()=>{i(""),o(null),c(null),b(!1),x(!1),S(null),N("all")},se=r||a||l||p||v||y||M!=="all",ye=w.useCallback(re=>{re.preventDefault(),re.dataTransfer.types.includes("Files")&&R(!0)},[]),Ce=w.useCallback(re=>{re.preventDefault(),re.currentTarget===re.target&&R(!1)},[]),Ue=w.useCallback(re=>{re.preventDefault(),R(!1);const Fe=Array.from(re.dataTransfer.files).filter(ve=>ve.name.endsWith(".3mf"));Fe.length>0?(D(Fe),k(!0)):re.dataTransfer.files.length>0&&e("Only .3mf files are supported","warning")},[e]),dt=w.useCallback(re=>{const Fe=re.target;if(Fe.tagName==="INPUT"||Fe.tagName==="TEXTAREA"||Fe.isContentEditable){re.key==="Escape"&&Fe.blur();return}switch(re.key){case"/":re.preventDefault(),n.current?.focus();break;case"u":case"U":!re.metaKey&&!re.ctrlKey&&(re.preventDefault(),k(!0));break;case"Escape":we&&De();break}},[we]);return w.useEffect(()=>(document.addEventListener("keydown",dt),()=>document.removeEventListener("keydown",dt)),[dt]),s.jsxs("div",{className:"p-4 md:p-8 relative min-h-full",onDragOver:ye,onDragLeave:Ce,onDrop:Ue,children:[T&&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(fi,{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(Me,{variant:"secondary",size:"sm",onClick:De,children:[s.jsx(Gt,{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(Me,{variant:"secondary",size:"sm",onClick:ke,children:"Select All"}),s.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>J(!0),children:[s.jsx(gg,{className:"w-4 h-4"}),"Tags"]}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>te(!0),children:[s.jsx(Ea,{className:"w-4 h-4"}),"Project"]}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>{const re=Array.from(U);Promise.all(re.map(Fe=>me.toggleFavorite(Fe))).then(()=>{t.invalidateQueries({queryKey:["archives"]}),e(`Toggled favorites for ${re.length} archive${re.length!==1?"s":""}`)}).catch(()=>{e("Failed to update favorites","error")})},children:[s.jsx(zf,{className:"w-4 h-4"}),"Favorite"]}),s.jsxs(Me,{size:"sm",className:"bg-red-500 hover:bg-red-600",onClick:()=>K(!0),children:[s.jsx(hn,{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:he,onChange:re=>fe(re.target.value),children:EKe.map(re=>s.jsx("option",{value:re.id,children:re.label},re.id))})]}),s.jsxs("p",{className:"text-bambu-gray",children:[pe?.length||0," of ",ie?.length||0," prints"]})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"relative",children:[s.jsxs(Me,{variant:"secondary",onClick:()=>Ne(!oe),disabled:ge,children:[ge?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(jw,{className:"w-4 h-4"}),"Export"]}),oe&&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()=>{Ne(!1),Se(!0);try{const{blob:re,filename:Fe}=await me.exportArchives({format:"csv",printerId:a||void 0,status:he==="failed"?"failed":void 0,search:r||void 0}),ve=URL.createObjectURL(re),$e=document.createElement("a");$e.href=ve,$e.download=Fe,$e.click(),URL.revokeObjectURL(ve),e("Export downloaded")}catch{e("Export failed","error")}finally{Se(!1)}},children:[s.jsx(Ya,{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()=>{Ne(!1),Se(!0);try{const{blob:re,filename:Fe}=await me.exportArchives({format:"xlsx",printerId:a||void 0,status:he==="failed"?"failed":void 0,search:r||void 0}),ve=URL.createObjectURL(re),$e=document.createElement("a");$e.href=ve,$e.download=Fe,$e.click(),URL.revokeObjectURL(ve),e("Export downloaded")}catch{e("Export failed","error")}finally{Se(!1)}},children:[s.jsx(jw,{className:"w-4 h-4"}),"Export as Excel"]})]})]}),U.size>=2&&U.size<=5&&s.jsxs(Me,{variant:"secondary",onClick:()=>de(!0),children:[s.jsx(Zp,{className:"w-4 h-4"}),"Compare (",U.size,")"]}),!we&&s.jsxs(Me,{variant:"secondary",onClick:()=>j(!0),children:[s.jsx(ll,{className:"w-4 h-4"}),"Select"]}),s.jsxs(Me,{onClick:()=>k(!0),children:[s.jsx(fi,{className:"w-4 h-4"}),"Upload 3MF"]})]})]}),s.jsx(Nt,{className:"mb-6",children:s.jsxs(Ct,{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(Sa,{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:re=>i(re.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(rE,{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:re=>o(re.target.value?Number(re.target.value):null),children:[s.jsx("option",{value:"",children:"All Printers"}),$?.map(re=>s.jsx("option",{value:re.id,children:re.name},re.id))]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(Ql,{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:re=>c(re.target.value||null),children:[s.jsx("option",{value:"",children:"All Materials"}),B.map(re=>s.jsx("option",{value:re,children:re},re))]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(kw,{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:M,onChange:re=>N(re.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:()=>b(!p),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${p?"bg-yellow-500/20 border-yellow-500 text-yellow-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:p?"Show all":"Show favorites only",children:[s.jsx(zf,{className:`w-4 h-4 ${p?"fill-yellow-400":""}`}),s.jsx("span",{className:"text-sm hidden md:inline",children:"Favorites"})]}),s.jsxs("button",{onClick:()=>x(!v),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${v?"bg-red-500/20 border-red-500 text-red-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:v?"Show failed prints":"Hide failed prints",children:[s.jsx(aa,{className:"w-4 h-4 "}),s.jsx("span",{className:"text-sm hidden md:inline",children:"Hide Failed"})]}),Y.length>0&&s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(gg,{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:y||"",onChange:re=>S(re.target.value||null),children:[s.jsx("option",{value:"",children:"All Tags"}),Y.map(re=>s.jsx("option",{value:re,children:re},re))]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(lK,{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:Z,onChange:re=>ee(re.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 ${z==="grid"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>H("grid"),title:"Grid view",children:s.jsx(oE,{className:"w-4 h-4"})}),s.jsx("button",{className:`p-2 ${z==="list"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>H("list"),title:"List view",children:s.jsx(lE,{className:"w-4 h-4"})}),s.jsx("button",{className:`p-2 ${z==="calendar"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>H("calendar"),title:"Calendar view",children:s.jsx(Yue,{className:"w-4 h-4"})})]})]}),se&&s.jsxs(Me,{variant:"ghost",size:"sm",onClick:Ye,className:"text-bambu-gray hover:text-white",children:[s.jsx(Gt,{className:"w-4 h-4"}),"Reset"]})]}),O.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:()=>m(re=>re==="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:O.map(re=>s.jsx("button",{onClick:()=>Ke(re),className:`w-6 h-6 rounded-full border-2 transition-all ${u.has(re)?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:re},title:re},re))}),u.size>0&&s.jsxs("button",{onClick:et,className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1",children:[s.jsx(Gt,{className:"w-3 h-3"}),"Clear"]})]})]})}),s.jsx(wKe,{}),X?s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading archives..."}):pe?.length===0?s.jsx(Nt,{children:s.jsxs(Ct,{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"})]})}):z==="calendar"?s.jsx(Nt,{className:"p-6",children:s.jsx(h$e,{archives:pe||[],onArchiveClick:re=>{i(""),H("grid"),G(re.id)},highlightedArchiveId:Qe})}):z==="grid"?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:pe?.map(re=>s.jsx(SKe,{archive:re,printerName:re.printer_id?le.get(re.printer_id)||"Unknown":"No Printer",isSelected:U.has(re.id),onSelect:ae,selectionMode:we,projects:I,isHighlighted:re.id===Qe,timeFormat:Ee},re.id))}):z==="list"?s.jsx(Nt,{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"})]}),pe?.map(re=>s.jsx(MKe,{archive:re,printerName:re.printer_id?le.get(re.printer_id)||"Unknown":"No Printer",isSelected:U.has(re.id),onSelect:ae,selectionMode:we,projects:I,isHighlighted:re.id===Qe},re.id))]})}):null,A&&s.jsx(r$e,{onClose:()=>{k(!1),D([])},initialFiles:C}),W&&s.jsx(zn,{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:()=>{Ie.mutate(Array.from(U)),K(!1)},onCancel:()=>K(!1)}),V&&s.jsx(s$e,{selectedIds:Array.from(U),existingTags:Y,onClose:()=>J(!1)}),ne&&s.jsx(o$e,{selectedIds:Array.from(U),onClose:()=>te(!1)}),Re&&U.size>=2&&U.size<=5&&s.jsx(xKe,{archiveIds:Array.from(U),onClose:()=>{de(!1),L(new Set),j(!1)}})]})}function AKe(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return w.useMemo(()=>r=>{e.forEach(i=>i(r))},e)}const RN=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function fx(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function cI(t){return"nodeType"in t}function Ts(t){var e,n;return t?fx(t)?t:cI(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function uI(t){const{Document:e}=Ts(t);return t instanceof e}function Zy(t){return fx(t)?!1:t instanceof Ts(t).HTMLElement}function die(t){return t instanceof Ts(t).SVGElement}function mx(t){return t?fx(t)?t.document:cI(t)?uI(t)?t:Zy(t)||die(t)?t.ownerDocument:document:document:document}const oc=RN?w.useLayoutEffect:w.useEffect;function dI(t){const e=w.useRef(t);return oc(()=>{e.current=t}),w.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 TKe(){const t=w.useRef(null),e=w.useCallback((r,i)=>{t.current=setInterval(r,i)},[]),n=w.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,n]}function hy(t,e){e===void 0&&(e=[t]);const n=w.useRef(t);return oc(()=>{n.current!==t&&(n.current=t)},e),n}function Qy(t,e){const n=w.useRef();return w.useMemo(()=>{const r=t(n.current);return n.current=r,r},[...e])}function VM(t){const e=dI(t),n=w.useRef(null),r=w.useCallback(i=>{i!==n.current&&e?.(i,n.current),n.current=i},[]);return[n,r]}function hD(t){const e=w.useRef();return w.useEffect(()=>{e.current=t},[t]),e.current}let zj={};function Jy(t,e){return w.useMemo(()=>{if(e)return e;const n=zj[t]==null?0:zj[t]+1;return zj[t]=n,t+"-"+n},[t,e])}function hie(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 dg=hie(1),fy=hie(-1);function CKe(t){return"clientX"in t&&"clientY"in t}function hI(t){if(!t)return!1;const{KeyboardEvent:e}=Ts(t.target);return e&&t instanceof e}function kKe(t){if(!t)return!1;const{TouchEvent:e}=Ts(t.target);return e&&t instanceof e}function fD(t){if(kKe(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 CKe(t)?{x:t.clientX,y:t.clientY}:null}const Hg=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[Hg.Translate.toString(t),Hg.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:r}=t;return e+" "+n+"ms "+r}}}),YW="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function jKe(t){return t.matches(YW)?t:t.querySelector(YW)}const PKe={display:"none"};function RKe(t){let{id:e,value:n}=t;return Ur.createElement("div",{id:e,style:PKe},n)}function DKe(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 Ur.createElement("div",{id:e,style:i,role:"status","aria-live":r,"aria-atomic":!0},n)}function OKe(){const[t,e]=w.useState("");return{announce:w.useCallback(r=>{r!=null&&e(r)},[]),announcement:t}}const fie=w.createContext(null);function LKe(t){const e=w.useContext(fie);w.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function IKe(){const[t]=w.useState(()=>new Set),e=w.useCallback(r=>(t.add(r),()=>t.delete(r)),[t]);return[w.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 FKe={draggable:`
  8318. To pick up a draggable item, press the space bar.
  8319. While dragging, use the arrow keys to move the item.
  8320. Press space again to drop the item in its new position, or press escape to cancel.
  8321. `},UKe={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 zKe(t){let{announcements:e=UKe,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=FKe}=t;const{announce:a,announcement:o}=OKe(),l=Jy("DndLiveRegion"),[c,u]=w.useState(!1);if(w.useEffect(()=>{u(!0)},[]),LKe(w.useMemo(()=>({onDragStart(f){let{active:m}=f;a(e.onDragStart({active:m}))},onDragMove(f){let{active:m,over:p}=f;e.onDragMove&&a(e.onDragMove({active:m,over:p}))},onDragOver(f){let{active:m,over:p}=f;a(e.onDragOver({active:m,over:p}))},onDragEnd(f){let{active:m,over:p}=f;a(e.onDragEnd({active:m,over:p}))},onDragCancel(f){let{active:m,over:p}=f;a(e.onDragCancel({active:m,over:p}))}}),[a,e])),!c)return null;const d=Ur.createElement(Ur.Fragment,null,Ur.createElement(RKe,{id:r,value:i.draggable}),Ur.createElement(DKe,{id:l,announcement:o}));return n?Yc.createPortal(d,n):d}var Di;(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"})(Di||(Di={}));function GM(){}function WM(t,e){return w.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function mie(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return w.useMemo(()=>[...e].filter(r=>r!=null),[...e])}const fl=Object.freeze({x:0,y:0});function pie(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function gie(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return n-r}function BKe(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return r-n}function ZW(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 xie(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function QW(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 bie=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=QW(e,e.left,e.top),a=[];for(const o of r){const{id:l}=o,c=n.get(l);if(c){const u=pie(QW(c),i);a.push({id:l,data:{droppableContainer:o,value:u}})}}return a.sort(gie)},$Ke=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=ZW(e),a=[];for(const o of r){const{id:l}=o,c=n.get(l);if(c){const u=ZW(c),d=i.reduce((m,p,b)=>m+pie(u[b],p),0),f=Number((d/4).toFixed(4));a.push({id:l,data:{droppableContainer:o,value:f}})}}return a.sort(gie)};function HKe(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 VKe=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=HKe(l,e);c>0&&i.push({id:o,data:{droppableContainer:a,value:c}})}}return i.sort(BKe)};function GKe(t,e,n){return{...t,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function yie(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:fl}function WKe(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 qKe=WKe(1);function KKe(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 XKe(t,e,n){const r=KKe(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 YKe={ignoreTransform:!1};function px(t,e){e===void 0&&(e=YKe);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:u,transformOrigin:d}=Ts(t).getComputedStyle(t);u&&(n=XKe(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 JW(t){return px(t,{ignoreTransform:!0})}function ZKe(t){const e=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function QKe(t,e){return e===void 0&&(e=Ts(t).getComputedStyle(t)),e.position==="fixed"}function JKe(t,e){e===void 0&&(e=Ts(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 DN(t,e){const n=[];function r(i){if(e!=null&&n.length>=e||!i)return n;if(uI(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!Zy(i)||die(i)||n.includes(i))return n;const a=Ts(t).getComputedStyle(i);return i!==t&&JKe(i,a)&&n.push(i),QKe(i,a)?n:r(i.parentNode)}return t?r(t):n}function vie(t){const[e]=DN(t,1);return e??null}function Bj(t){return!RN||!t?null:fx(t)?t:cI(t)?uI(t)||t===mx(t).scrollingElement?window:Zy(t)?t:null:null}function _ie(t){return fx(t)?t.scrollX:t.scrollLeft}function wie(t){return fx(t)?t.scrollY:t.scrollTop}function mD(t){return{x:_ie(t),y:wie(t)}}var Qi;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Qi||(Qi={}));function Sie(t){return!RN||!t?!1:t===document.scrollingElement}function Mie(t){const e={x:0,y:0},n=Sie(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 eXe={x:.2,y:.2};function tXe(t,e,n,r,i){let{top:a,left:o,right:l,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=eXe);const{isTop:u,isBottom:d,isLeft:f,isRight:m}=Mie(t),p={x:0,y:0},b={x:0,y:0},v={height:e.height*i.y,width:e.width*i.x};return!u&&a<=e.top+v.height?(p.y=Qi.Backward,b.y=r*Math.abs((e.top+v.height-a)/v.height)):!d&&c>=e.bottom-v.height&&(p.y=Qi.Forward,b.y=r*Math.abs((e.bottom-v.height-c)/v.height)),!m&&l>=e.right-v.width?(p.x=Qi.Forward,b.x=r*Math.abs((e.right-v.width-l)/v.width)):!f&&o<=e.left+v.width&&(p.x=Qi.Backward,b.x=r*Math.abs((e.left+v.width-o)/v.width)),{direction:p,speed:b}}function nXe(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 Eie(t){return t.reduce((e,n)=>dg(e,mD(n)),fl)}function rXe(t){return t.reduce((e,n)=>e+_ie(n),0)}function iXe(t){return t.reduce((e,n)=>e+wie(n),0)}function aXe(t,e){if(e===void 0&&(e=px),!t)return;const{top:n,left:r,bottom:i,right:a}=e(t);vie(t)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const sXe=[["x",["left","right"],rXe],["y",["top","bottom"],iXe]];class fI{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=DN(n),i=Eie(r);this.rect={...e},this.width=e.width,this.height=e.height;for(const[a,o,l]of sXe)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 y0{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 oXe(t){const{EventTarget:e}=Ts(t);return t instanceof e?t:mx(t)}function $j(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 wo;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(wo||(wo={}));function eq(t){t.preventDefault()}function lXe(t){t.stopPropagation()}var In;(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"})(In||(In={}));const Nie={start:[In.Space,In.Enter],cancel:[In.Esc],end:[In.Space,In.Enter,In.Tab]},cXe=(t,e)=>{let{currentCoordinates:n}=e;switch(t.code){case In.Right:return{...n,x:n.x+25};case In.Left:return{...n,x:n.x-25};case In.Down:return{...n,y:n.y+25};case In.Up:return{...n,y:n.y-25}}};class ON{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 y0(mx(n)),this.windowListeners=new y0(Ts(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(wo.Resize,this.handleCancel),this.windowListeners.add(wo.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(wo.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,r=e.node.current;r&&aXe(r),n(fl)}handleKeyDown(e){if(hI(e)){const{active:n,context:r,options:i}=this.props,{keyboardCodes:a=Nie,coordinateGetter:o=cXe,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}:fl;this.referenceCoordinates||(this.referenceCoordinates=d);const f=o(e,{active:n,context:r.current,currentCoordinates:d});if(f){const m=fy(f,d),p={x:0,y:0},{scrollableAncestors:b}=r.current;for(const v of b){const x=e.code,{isTop:y,isRight:S,isLeft:M,isBottom:N,maxScroll:A,minScroll:k}=Mie(v),C=nXe(v),D={x:Math.min(x===In.Right?C.right-C.width/2:C.right,Math.max(x===In.Right?C.left:C.left+C.width/2,f.x)),y:Math.min(x===In.Down?C.bottom-C.height/2:C.bottom,Math.max(x===In.Down?C.top:C.top+C.height/2,f.y))},T=x===In.Right&&!S||x===In.Left&&!M,R=x===In.Down&&!N||x===In.Up&&!y;if(T&&D.x!==f.x){const U=v.scrollLeft+m.x,L=x===In.Right&&U<=A.x||x===In.Left&&U>=k.x;if(L&&!m.y){v.scrollTo({left:U,behavior:l});return}L?p.x=v.scrollLeft-U:p.x=x===In.Right?v.scrollLeft-A.x:v.scrollLeft-k.x,p.x&&v.scrollBy({left:-p.x,behavior:l});break}else if(R&&D.y!==f.y){const U=v.scrollTop+m.y,L=x===In.Down&&U<=A.y||x===In.Up&&U>=k.y;if(L&&!m.x){v.scrollTo({top:U,behavior:l});return}L?p.y=v.scrollTop-U:p.y=x===In.Down?v.scrollTop-A.y:v.scrollTop-k.y,p.y&&v.scrollBy({top:-p.y,behavior:l});break}}this.handleMove(e,dg(fy(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()}}ON.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:r=Nie,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 tq(t){return!!(t&&"distance"in t)}function nq(t){return!!(t&&"delay"in t)}class mI{constructor(e,n,r){var i;r===void 0&&(r=oXe(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=mx(o),this.documentListeners=new y0(this.document),this.listeners=new y0(r),this.windowListeners=new y0(Ts(o)),this.initialCoordinates=(i=fD(a))!=null?i:fl,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(wo.Resize,this.handleCancel),this.windowListeners.add(wo.DragStart,eq),this.windowListeners.add(wo.VisibilityChange,this.handleCancel),this.windowListeners.add(wo.ContextMenu,eq),this.documentListeners.add(wo.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(nq(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(tq(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(wo.Click,lXe,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(wo.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=fD(e))!=null?n:fl,u=fy(i,c);if(!r&&l){if(tq(l)){if(l.tolerance!=null&&$j(u,l.tolerance))return this.handleCancel();if($j(u,l.distance))return this.handleStart()}if(nq(l)&&$j(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===In.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const uXe={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class LN extends mI{constructor(e){const{event:n}=e,r=mx(n.target);super(e,uXe,r)}}LN.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 dXe={move:{name:"mousemove"},end:{name:"mouseup"}};var pD;(function(t){t[t.RightClick=2]="RightClick"})(pD||(pD={}));class hXe extends mI{constructor(e){super(e,dXe,mx(e.event.target))}}hXe.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return n.button===pD.RightClick?!1:(r?.({event:n}),!0)}}];const Hj={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class fXe extends mI{constructor(e){super(e,Hj)}static setup(){return window.addEventListener(Hj.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Hj.move.name,e)};function e(){}}}fXe.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 v0;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(v0||(v0={}));var qM;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(qM||(qM={}));function mXe(t){let{acceleration:e,activator:n=v0.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:l=qM.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:d,delta:f,threshold:m}=t;const p=gXe({delta:f,disabled:!a}),[b,v]=TKe(),x=w.useRef({x:0,y:0}),y=w.useRef({x:0,y:0}),S=w.useMemo(()=>{switch(n){case v0.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case v0.DraggableRect:return i}},[n,i,c]),M=w.useRef(null),N=w.useCallback(()=>{const k=M.current;if(!k)return;const C=x.current.x*y.current.x,D=x.current.y*y.current.y;k.scrollBy(C,D)},[]),A=w.useMemo(()=>l===qM.TreeOrder?[...u].reverse():u,[l,u]);w.useEffect(()=>{if(!a||!u.length||!S){v();return}for(const k of A){if(r?.(k)===!1)continue;const C=u.indexOf(k),D=d[C];if(!D)continue;const{direction:T,speed:R}=tXe(k,D,S,e,m);for(const U of["x","y"])p[U][T[U]]||(R[U]=0,T[U]=0);if(R.x>0||R.y>0){v(),M.current=k,b(N,o),x.current=R,y.current=T;return}}x.current={x:0,y:0},y.current={x:0,y:0},v()},[e,N,r,v,a,o,JSON.stringify(S),JSON.stringify(p),b,u,A,d,JSON.stringify(m)])}const pXe={x:{[Qi.Backward]:!1,[Qi.Forward]:!1},y:{[Qi.Backward]:!1,[Qi.Forward]:!1}};function gXe(t){let{delta:e,disabled:n}=t;const r=hD(e);return Qy(i=>{if(n||!r||!i)return pXe;const a={x:Math.sign(e.x-r.x),y:Math.sign(e.y-r.y)};return{x:{[Qi.Backward]:i.x[Qi.Backward]||a.x===-1,[Qi.Forward]:i.x[Qi.Forward]||a.x===1},y:{[Qi.Backward]:i.y[Qi.Backward]||a.y===-1,[Qi.Forward]:i.y[Qi.Forward]||a.y===1}}},[n,e,r])}function xXe(t,e){const n=e!=null?t.get(e):void 0,r=n?n.node.current:null;return Qy(i=>{var a;return e==null?null:(a=r??i)!=null?a:null},[r,e])}function bXe(t,e){return w.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 my;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(my||(my={}));var gD;(function(t){t.Optimized="optimized"})(gD||(gD={}));const rq=new Map;function yXe(t,e){let{dragging:n,dependencies:r,config:i}=e;const[a,o]=w.useState(null),{frequency:l,measure:c,strategy:u}=i,d=w.useRef(t),f=x(),m=hy(f),p=w.useCallback(function(y){y===void 0&&(y=[]),!m.current&&o(S=>S===null?y:S.concat(y.filter(M=>!S.includes(M))))},[m]),b=w.useRef(null),v=Qy(y=>{if(f&&!n)return rq;if(!y||y===rq||d.current!==t||a!=null){const S=new Map;for(let M of t){if(!M)continue;if(a&&a.length>0&&!a.includes(M.id)&&M.rect.current){S.set(M.id,M.rect.current);continue}const N=M.node.current,A=N?new fI(c(N),N):null;M.rect.current=A,A&&S.set(M.id,A)}return S}return y},[t,a,n,f,c]);return w.useEffect(()=>{d.current=t},[t]),w.useEffect(()=>{f||p()},[n,f]),w.useEffect(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),w.useEffect(()=>{f||typeof l!="number"||b.current!==null||(b.current=setTimeout(()=>{p(),b.current=null},l))},[l,f,p,...r]),{droppableRects:v,measureDroppableContainers:p,measuringScheduled:a!=null};function x(){switch(u){case my.Always:return!1;case my.BeforeDragging:return n;default:return!n}}}function Aie(t,e){return Qy(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function vXe(t,e){return Aie(t,e)}function _Xe(t){let{callback:e,disabled:n}=t;const r=dI(e),i=w.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:a}=window;return new a(r)},[r,n]);return w.useEffect(()=>()=>i?.disconnect(),[i]),i}function IN(t){let{callback:e,disabled:n}=t;const r=dI(e),i=w.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:a}=window;return new a(r)},[n]);return w.useEffect(()=>()=>i?.disconnect(),[i]),i}function wXe(t){return new fI(px(t),t)}function iq(t,e,n){e===void 0&&(e=wXe);const[r,i]=w.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=_Xe({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=IN({callback:a});return oc(()=>{a(),t?(l?.observe(t),o?.observe(document.body,{childList:!0,subtree:!0})):(l?.disconnect(),o?.disconnect())},[t]),r}function SXe(t){const e=Aie(t);return yie(t,e)}const aq=[];function MXe(t){const e=w.useRef(t),n=Qy(r=>t?r&&r!==aq&&t&&e.current&&t.parentNode===e.current.parentNode?r:DN(t):aq,[t]);return w.useEffect(()=>{e.current=t},[t]),n}function EXe(t){const[e,n]=w.useState(null),r=w.useRef(t),i=w.useCallback(a=>{const o=Bj(a.target);o&&n(l=>l?(l.set(o,mD(o)),new Map(l)):null)},[]);return w.useEffect(()=>{const a=r.current;if(t!==a){o(a);const l=t.map(c=>{const u=Bj(c);return u?(u.addEventListener("scroll",i,{passive:!0}),[u,mD(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=Bj(c);u?.removeEventListener("scroll",i)})}},[i,t]),w.useMemo(()=>t.length?e?Array.from(e.values()).reduce((a,o)=>dg(a,o),fl):Eie(t):fl,[t,e])}function sq(t,e){e===void 0&&(e=[]);const n=w.useRef(null);return w.useEffect(()=>{n.current=null},e),w.useEffect(()=>{const r=t!==fl;r&&!n.current&&(n.current=t),!r&&n.current&&(n.current=null)},[t]),n.current?fy(t,n.current):fl}function NXe(t){w.useEffect(()=>{if(!RN)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 AXe(t,e){return w.useMemo(()=>t.reduce((n,r)=>{let{eventName:i,handler:a}=r;return n[i]=o=>{a(o,e)},n},{}),[t,e])}function Tie(t){return w.useMemo(()=>t?ZKe(t):null,[t])}const oq=[];function TXe(t,e){e===void 0&&(e=px);const[n]=t,r=Tie(n?Ts(n):null),[i,a]=w.useState(oq);function o(){a(()=>t.length?t.map(c=>Sie(c)?r:new fI(e(c),c)):oq)}const l=IN({callback:o});return oc(()=>{l?.disconnect(),o(),t.forEach(c=>l?.observe(c))},[t]),i}function CXe(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return Zy(e)?e:t}function kXe(t){let{measure:e}=t;const[n,r]=w.useState(null),i=w.useCallback(u=>{for(const{target:d}of u)if(Zy(d)){r(f=>{const m=e(d);return f?{...f,width:m.width,height:m.height}:m});break}},[e]),a=IN({callback:i}),o=w.useCallback(u=>{const d=CXe(u);a?.disconnect(),d&&a?.observe(d),r(d?e(d):null)},[e,a]),[l,c]=VM(o);return w.useMemo(()=>({nodeRef:l,rect:n,setRef:c}),[n,l,c])}const jXe=[{sensor:LN,options:{}},{sensor:ON,options:{}}],PXe={current:{}},ww={draggable:{measure:JW},droppable:{measure:JW,strategy:my.WhileDragging,frequency:gD.Optimized},dragOverlay:{measure:px}};class _0 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 RXe={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new _0,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:GM},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:ww,measureDroppableContainers:GM,windowRect:null,measuringScheduled:!1},DXe={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:GM,draggableNodes:new Map,over:null,measureDroppableContainers:GM},FN=w.createContext(DXe),Cie=w.createContext(RXe);function OXe(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new _0}}}function LXe(t,e){switch(e.type){case Di.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case Di.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 Di.DragEnd:case Di.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Di.RegisterDroppable:{const{element:n}=e,{id:r}=n,i=new _0(t.droppable.containers);return i.set(r,n),{...t,droppable:{...t.droppable,containers:i}}}case Di.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 _0(t.droppable.containers);return o.set(n,{...a,disabled:i}),{...t,droppable:{...t.droppable,containers:o}}}case Di.UnregisterDroppable:{const{id:n,key:r}=e,i=t.droppable.containers.get(n);if(!i||r!==i.key)return t;const a=new _0(t.droppable.containers);return a.delete(n),{...t,droppable:{...t.droppable,containers:a}}}default:return t}}function IXe(t){let{disabled:e}=t;const{active:n,activatorEvent:r,draggableNodes:i}=w.useContext(FN),a=hD(r),o=hD(n?.id);return w.useEffect(()=>{if(!e&&!r&&a&&o!=null){if(!hI(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=jKe(d);if(f){f.focus();break}}})}},[r,e,i,o,a]),null}function FXe(t,e){let{transform:n,...r}=e;return t!=null&&t.length?t.reduce((i,a)=>a({transform:i,...r}),n):n}function UXe(t){return w.useMemo(()=>({draggable:{...ww.draggable,...t?.draggable},droppable:{...ww.droppable,...t?.droppable},dragOverlay:{...ww.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function zXe(t){let{activeNode:e,measure:n,initialRect:r,config:i=!0}=t;const a=w.useRef(!1),{x:o,y:l}=typeof i=="boolean"?{x:i,y:i}:i;oc(()=>{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=yie(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 m=vie(u);m&&m.scrollBy({top:f.y,left:f.x})}},[e,o,l,r,n])}const kie=w.createContext({...fl,scaleX:1,scaleY:1});var wd;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(wd||(wd={}));const jie=w.memo(function(e){var n,r,i,a;let{id:o,accessibility:l,autoScroll:c=!0,children:u,sensors:d=jXe,collisionDetection:f=VKe,measuring:m,modifiers:p,...b}=e;const v=w.useReducer(LXe,void 0,OXe),[x,y]=v,[S,M]=IKe(),[N,A]=w.useState(wd.Uninitialized),k=N===wd.Initialized,{draggable:{active:C,nodes:D,translate:T},droppable:{containers:R}}=x,U=C!=null?D.get(C):null,L=w.useRef({initial:null,translated:null}),q=w.useMemo(()=>{var $e;return C!=null?{id:C,data:($e=U?.data)!=null?$e:PXe,rect:L}:null},[C,U]),j=w.useRef(null),[W,K]=w.useState(null),[V,J]=w.useState(null),ne=hy(b,Object.values(b)),te=Jy("DndDescribedBy",o),z=w.useMemo(()=>R.getEnabled(),[R]),H=UXe(m),{droppableRects:Z,measureDroppableContainers:ee,measuringScheduled:he}=yXe(z,{dragging:k,dependencies:[T.x,T.y],config:H.droppable}),fe=xXe(D,C),oe=w.useMemo(()=>V?fD(V):null,[V]),Ne=ve(),ge=vXe(fe,H.draggable.measure);zXe({activeNode:C!=null?D.get(C):null,config:Ne.layoutShiftCompensation,initialRect:ge,measure:H.draggable.measure});const Se=iq(fe,H.draggable.measure,ge),Re=iq(fe?fe.parentElement:null),de=w.useRef({activatorEvent:null,active:null,activeNode:fe,collisionRect:null,collisions:null,droppableRects:Z,draggableNodes:D,draggingNode:null,draggingNodeRect:null,droppableContainers:R,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Qe=R.getNodeFor((n=de.current.over)==null?void 0:n.id),G=kXe({measure:H.dragOverlay.measure}),ie=(r=G.nodeRef.current)!=null?r:fe,X=k?(i=G.rect)!=null?i:Se:null,$=!!(G.nodeRef.current&&G.rect),I=SXe($?null:Se),ce=Tie(ie?Ts(ie):null),Ee=MXe(k?Qe??fe:null),Ie=TXe(Ee),le=FXe(p,{transform:{x:T.x-I.x,y:T.y-I.y,scaleX:1,scaleY:1},activatorEvent:V,active:q,activeNodeRect:Se,containerNodeRect:Re,draggingNodeRect:X,over:de.current.over,overlayNodeRect:G.rect,scrollableAncestors:Ee,scrollableAncestorRects:Ie,windowRect:ce}),B=oe?dg(oe,T):null,O=EXe(Ee),Y=sq(O),pe=sq(O,[Se]),we=dg(le,Y),ae=X?qKe(X,le):null,ke=q&&ae?f({active:q,collisionRect:ae,droppableRects:Z,droppableContainers:z,pointerCoordinates:B}):null,De=xie(ke,"id"),[Ke,et]=w.useState(null),Ye=$?le:dg(le,pe),se=GKe(Ye,(a=Ke?.rect)!=null?a:null,Se),ye=w.useRef(null),Ce=w.useCallback(($e,Le)=>{let{sensor:Ae,options:Ge}=Le;if(j.current==null)return;const it=D.get(j.current);if(!it)return;const Ot=$e.nativeEvent,kt=new Ae({active:j.current,activeNode:it,event:Ot,options:Ge,context:de,onAbort(Ut){if(!D.get(Ut))return;const{onDragAbort:xt}=ne.current,Yt={id:Ut};xt?.(Yt),S({type:"onDragAbort",event:Yt})},onPending(Ut,yn,xt,Yt){if(!D.get(Ut))return;const{onDragPending:Tt}=ne.current,Cn={id:Ut,constraint:yn,initialCoordinates:xt,offset:Yt};Tt?.(Cn),S({type:"onDragPending",event:Cn})},onStart(Ut){const yn=j.current;if(yn==null)return;const xt=D.get(yn);if(!xt)return;const{onDragStart:Yt}=ne.current,sn={activatorEvent:Ot,active:{id:yn,data:xt.data,rect:L}};Yc.unstable_batchedUpdates(()=>{Yt?.(sn),A(wd.Initializing),y({type:Di.DragStart,initialCoordinates:Ut,active:yn}),S({type:"onDragStart",event:sn}),K(ye.current),J(Ot)})},onMove(Ut){y({type:Di.DragMove,coordinates:Ut})},onEnd:on(Di.DragEnd),onCancel:on(Di.DragCancel)});ye.current=kt;function on(Ut){return async function(){const{active:xt,collisions:Yt,over:sn,scrollAdjustedTranslate:Tt}=de.current;let Cn=null;if(xt&&Tt){const{cancelDrop:Cr}=ne.current;Cn={activatorEvent:Ot,active:xt,collisions:Yt,delta:Tt,over:sn},Ut===Di.DragEnd&&typeof Cr=="function"&&await Promise.resolve(Cr(Cn))&&(Ut=Di.DragCancel)}j.current=null,Yc.unstable_batchedUpdates(()=>{y({type:Ut}),A(wd.Uninitialized),et(null),K(null),J(null),ye.current=null;const Cr=Ut===Di.DragEnd?"onDragEnd":"onDragCancel";if(Cn){const er=ne.current[Cr];er?.(Cn),S({type:Cr,event:Cn})}})}}},[D]),Ue=w.useCallback(($e,Le)=>(Ae,Ge)=>{const it=Ae.nativeEvent,Ot=D.get(Ge);if(j.current!==null||!Ot||it.dndKit||it.defaultPrevented)return;const kt={active:Ot};$e(Ae,Le.options,kt)===!0&&(it.dndKit={capturedBy:Le.sensor},j.current=Ge,Ce(Ae,Le))},[D,Ce]),dt=bXe(d,Ue);NXe(d),oc(()=>{Se&&N===wd.Initializing&&A(wd.Initialized)},[Se,N]),w.useEffect(()=>{const{onDragMove:$e}=ne.current,{active:Le,activatorEvent:Ae,collisions:Ge,over:it}=de.current;if(!Le||!Ae)return;const Ot={active:Le,activatorEvent:Ae,collisions:Ge,delta:{x:we.x,y:we.y},over:it};Yc.unstable_batchedUpdates(()=>{$e?.(Ot),S({type:"onDragMove",event:Ot})})},[we.x,we.y]),w.useEffect(()=>{const{active:$e,activatorEvent:Le,collisions:Ae,droppableContainers:Ge,scrollAdjustedTranslate:it}=de.current;if(!$e||j.current==null||!Le||!it)return;const{onDragOver:Ot}=ne.current,kt=Ge.get(De),on=kt&&kt.rect.current?{id:kt.id,rect:kt.rect.current,data:kt.data,disabled:kt.disabled}:null,Ut={active:$e,activatorEvent:Le,collisions:Ae,delta:{x:it.x,y:it.y},over:on};Yc.unstable_batchedUpdates(()=>{et(on),Ot?.(Ut),S({type:"onDragOver",event:Ut})})},[De]),oc(()=>{de.current={activatorEvent:V,active:q,activeNode:fe,collisionRect:ae,collisions:ke,droppableRects:Z,draggableNodes:D,draggingNode:ie,draggingNodeRect:X,droppableContainers:R,over:Ke,scrollableAncestors:Ee,scrollAdjustedTranslate:we},L.current={initial:X,translated:ae}},[q,fe,ke,ae,D,ie,X,Z,R,Ke,Ee,we]),mXe({...Ne,delta:T,draggingRect:ae,pointerCoordinates:B,scrollableAncestors:Ee,scrollableAncestorRects:Ie});const re=w.useMemo(()=>({active:q,activeNode:fe,activeNodeRect:Se,activatorEvent:V,collisions:ke,containerNodeRect:Re,dragOverlay:G,draggableNodes:D,droppableContainers:R,droppableRects:Z,over:Ke,measureDroppableContainers:ee,scrollableAncestors:Ee,scrollableAncestorRects:Ie,measuringConfiguration:H,measuringScheduled:he,windowRect:ce}),[q,fe,Se,V,ke,Re,G,D,R,Z,Ke,ee,Ee,Ie,H,he,ce]),Fe=w.useMemo(()=>({activatorEvent:V,activators:dt,active:q,activeNodeRect:Se,ariaDescribedById:{draggable:te},dispatch:y,draggableNodes:D,over:Ke,measureDroppableContainers:ee}),[V,dt,q,Se,y,te,D,Ke,ee]);return Ur.createElement(fie.Provider,{value:M},Ur.createElement(FN.Provider,{value:Fe},Ur.createElement(Cie.Provider,{value:re},Ur.createElement(kie.Provider,{value:se},u)),Ur.createElement(IXe,{disabled:l?.restoreFocus===!1})),Ur.createElement(zKe,{...l,hiddenTextDescribedById:te}));function ve(){const $e=W?.autoScrollEnabled===!1,Le=typeof c=="object"?c.enabled===!1:c===!1,Ae=k&&!$e&&!Le;return typeof c=="object"?{...c,enabled:Ae}:{enabled:Ae}}}),BXe=w.createContext(null),lq="button",$Xe="Draggable";function HXe(t){let{id:e,data:n,disabled:r=!1,attributes:i}=t;const a=Jy($Xe),{activators:o,activatorEvent:l,active:c,activeNodeRect:u,ariaDescribedById:d,draggableNodes:f,over:m}=w.useContext(FN),{role:p=lq,roleDescription:b="draggable",tabIndex:v=0}=i??{},x=c?.id===e,y=w.useContext(x?kie:BXe),[S,M]=VM(),[N,A]=VM(),k=AXe(o,e),C=hy(n);oc(()=>(f.set(e,{id:e,key:a,node:S,activatorNode:N,data:C}),()=>{const T=f.get(e);T&&T.key===a&&f.delete(e)}),[f,e]);const D=w.useMemo(()=>({role:p,tabIndex:v,"aria-disabled":r,"aria-pressed":x&&p===lq?!0:void 0,"aria-roledescription":b,"aria-describedby":d.draggable}),[r,p,v,x,b,d.draggable]);return{active:c,activatorEvent:l,activeNodeRect:u,attributes:D,isDragging:x,listeners:r?void 0:k,node:S,over:m,setNodeRef:M,setActivatorNodeRef:A,transform:y}}function VXe(){return w.useContext(Cie)}const GXe="Droppable",WXe={timeout:25};function qXe(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:i}=t;const a=Jy(GXe),{active:o,dispatch:l,over:c,measureDroppableContainers:u}=w.useContext(FN),d=w.useRef({disabled:n}),f=w.useRef(!1),m=w.useRef(null),p=w.useRef(null),{disabled:b,updateMeasurementsFor:v,timeout:x}={...WXe,...i},y=hy(v??r),S=w.useCallback(()=>{if(!f.current){f.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{u(Array.isArray(y.current)?y.current:[y.current]),p.current=null},x)},[x]),M=IN({callback:S,disabled:b||!o}),N=w.useCallback((D,T)=>{M&&(T&&(M.unobserve(T),f.current=!1),D&&M.observe(D))},[M]),[A,k]=VM(N),C=hy(e);return w.useEffect(()=>{!M||!A.current||(M.disconnect(),f.current=!1,M.observe(A.current))},[A,M]),w.useEffect(()=>(l({type:Di.RegisterDroppable,element:{id:r,key:a,disabled:n,node:A,rect:m,data:C}}),()=>l({type:Di.UnregisterDroppable,key:a,id:r})),[r]),w.useEffect(()=>{n!==d.current.disabled&&(l({type:Di.SetDroppableDisabled,id:r,key:a,disabled:n}),d.current.disabled=n)},[r,a,n,l]),{active:o,rect:m,isOver:c?.id===r,node:A,over:c,setNodeRef:k}}function UN(t,e,n){const r=t.slice();return r.splice(n<0?r.length+n:n,0,r.splice(e,1)[0]),r}function KXe(t,e){return t.reduce((n,r,i)=>{const a=e.get(r);return a&&(n[i]=a),n},Array(t.length))}function V1(t){return t!==null&&t>=0}function XXe(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 YXe(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const pI=t=>{let{rects:e,activeIndex:n,overIndex:r,index:i}=t;const a=UN(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}},G1={scaleX:1,scaleY:1},ZXe=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,...G1}:null}const c=QXe(a,i,n);return i>n&&i<=o?{x:0,y:-l.height-c,...G1}:i<n&&i>=o?{x:0,y:l.height+c,...G1}:{x:0,y:0,...G1}};function QXe(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 Pie="Sortable",Rie=Ur.createContext({activeIndex:-1,containerId:Pie,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:pI,disabled:{draggable:!1,droppable:!1}});function Die(t){let{children:e,id:n,items:r,strategy:i=pI,disabled:a=!1}=t;const{active:o,dragOverlay:l,droppableRects:c,over:u,measureDroppableContainers:d}=VXe(),f=Jy(Pie,n),m=l.rect!==null,p=w.useMemo(()=>r.map(k=>typeof k=="object"&&"id"in k?k.id:k),[r]),b=o!=null,v=o?p.indexOf(o.id):-1,x=u?p.indexOf(u.id):-1,y=w.useRef(p),S=!XXe(p,y.current),M=x!==-1&&v===-1||S,N=YXe(a);oc(()=>{S&&b&&d(p)},[S,p,b,d]),w.useEffect(()=>{y.current=p},[p]);const A=w.useMemo(()=>({activeIndex:v,containerId:f,disabled:N,disableTransforms:M,items:p,overIndex:x,useDragOverlay:m,sortedRects:KXe(p,c),strategy:i}),[v,f,N.draggable,N.droppable,M,p,x,c,m,i]);return Ur.createElement(Rie.Provider,{value:A},e)}const JXe=t=>{let{id:e,items:n,activeIndex:r,overIndex:i}=t;return UN(n,r,i).indexOf(e)},eYe=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},tYe={duration:200,easing:"ease"},Oie="transform",nYe=Hg.Transition.toString({property:Oie,duration:0,easing:"linear"}),rYe={roleDescription:"sortable"};function iYe(t){let{disabled:e,index:n,node:r,rect:i}=t;const[a,o]=w.useState(null),l=w.useRef(n);return oc(()=>{if(!e&&n!==l.current&&r.current){const c=i.current;if(c){const u=px(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]),w.useEffect(()=>{a&&o(null)},[a]),a}function Lie(t){let{animateLayoutChanges:e=eYe,attributes:n,disabled:r,data:i,getNewIndex:a=JXe,id:o,strategy:l,resizeObserverConfig:c,transition:u=tYe}=t;const{items:d,containerId:f,activeIndex:m,disabled:p,disableTransforms:b,sortedRects:v,overIndex:x,useDragOverlay:y,strategy:S}=w.useContext(Rie),M=aYe(r,p),N=d.indexOf(o),A=w.useMemo(()=>({sortable:{containerId:f,index:N,items:d},...i}),[f,i,N,d]),k=w.useMemo(()=>d.slice(d.indexOf(o)),[d,o]),{rect:C,node:D,isOver:T,setNodeRef:R}=qXe({id:o,data:A,disabled:M.droppable,resizeObserverConfig:{updateMeasurementsFor:k,...c}}),{active:U,activatorEvent:L,activeNodeRect:q,attributes:j,setNodeRef:W,listeners:K,isDragging:V,over:J,setActivatorNodeRef:ne,transform:te}=HXe({id:o,data:A,attributes:{...rYe,...n},disabled:M.draggable}),z=AKe(R,W),H=!!U,Z=H&&!b&&V1(m)&&V1(x),ee=!y&&V,he=ee&&Z?te:null,oe=Z?he??(l??S)({rects:v,activeNodeRect:q,activeIndex:m,overIndex:x,index:N}):null,Ne=V1(m)&&V1(x)?a({id:o,items:d,activeIndex:m,overIndex:x}):N,ge=U?.id,Se=w.useRef({activeId:ge,items:d,newIndex:Ne,containerId:f}),Re=d!==Se.current.items,de=e({active:U,containerId:f,isDragging:V,isSorting:H,id:o,index:N,items:d,newIndex:Se.current.newIndex,previousItems:Se.current.items,previousContainerId:Se.current.containerId,transition:u,wasDragging:Se.current.activeId!=null}),Qe=iYe({disabled:!de,index:N,node:D,rect:C});return w.useEffect(()=>{H&&Se.current.newIndex!==Ne&&(Se.current.newIndex=Ne),f!==Se.current.containerId&&(Se.current.containerId=f),d!==Se.current.items&&(Se.current.items=d)},[H,Ne,f,d]),w.useEffect(()=>{if(ge===Se.current.activeId)return;if(ge!=null&&Se.current.activeId==null){Se.current.activeId=ge;return}const ie=setTimeout(()=>{Se.current.activeId=ge},50);return()=>clearTimeout(ie)},[ge]),{active:U,activeIndex:m,attributes:j,data:A,rect:C,index:N,newIndex:Ne,items:d,isOver:T,isSorting:H,isDragging:V,listeners:K,node:D,overIndex:x,over:J,setNodeRef:z,setActivatorNodeRef:ne,setDroppableNodeRef:R,setDraggableNodeRef:W,transform:Qe??oe,transition:G()};function G(){if(Qe||Re&&Se.current.newIndex===N)return nYe;if(!(ee&&!hI(L)||!u)&&(H||de))return Hg.Transition.toString({...u,property:Oie})}}function aYe(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 KM(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 sYe=[In.Down,In.Right,In.Up,In.Left],Iie=(t,e)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:a,over:o,scrollableAncestors:l}}=e;if(sYe.includes(t.code)){if(t.preventDefault(),!n||!r)return;const c=[];a.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const m=i.get(f.id);if(m)switch(t.code){case In.Down:r.top<m.top&&c.push(f);break;case In.Up:r.top>m.top&&c.push(f);break;case In.Left:r.left>m.left&&c.push(f);break;case In.Right:r.left<m.left&&c.push(f);break}});const u=$Ke({collisionRect:r,droppableRects:i,droppableContainers:c});let d=xie(u,"id");if(d===o?.id&&u.length>1&&(d=u[1].id),d!=null){const f=a.get(n.id),m=a.get(d),p=m?i.get(m.id):null,b=m?.node.current;if(b&&p&&f&&m){const x=DN(b).some((k,C)=>l[C]!==k),y=Fie(f,m),S=oYe(f,m),M=x||!y?{x:0,y:0}:{x:S?r.width-p.width:0,y:S?r.height-p.height:0},N={x:p.left,y:p.top};return M.x&&M.y?N:fy(N,M)}}}};function Fie(t,e){return!KM(t)||!KM(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function oYe(t,e){return!KM(t)||!KM(e)||!Fie(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}function Uie(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 lYe(t,e="system"){if(!t)return"ASAP";const n=Si(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`:bg(t,e)}function cYe({status:t}){const e={pending:{icon:Jn,color:"text-status-warning bg-status-warning/10 border-status-warning/20",label:"Pending"},printing:{icon:ol,color:"text-blue-400 bg-blue-400/10 border-blue-400/20",label:"Printing"},completed:{icon:Hn,color:"text-status-ok bg-status-ok/10 border-status-ok/20",label:"Completed"},failed:{icon:za,color:"text-status-error bg-status-error/10 border-status-error/20",label:"Failed"},skipped:{icon:Ow,color:"text-orange-400 bg-orange-400/10 border-orange-400/20",label:"Skipped"},cancelled:{icon:Gt,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 Vj({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:m,transition:p,isDragging:b}=Lie({id:t.id,disabled:t.status!=="pending"}),v={transform:Hg.Transform.toString(m),transition:p},x=t.status==="printing",y=t.status==="pending",S=["completed","failed","skipped","cancelled"].includes(t.status);return s.jsx("div",{ref:f,style:v,className:`
  8322. group relative bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary
  8323. transition-all duration-200 hover:border-bambu-dark-tertiary/80
  8324. ${b?"opacity-50 scale-[1.02] shadow-xl z-50":""}
  8325. ${x?"border-blue-500/30 bg-gradient-to-r from-blue-500/5 to-transparent":""}
  8326. `,children:s.jsxs("div",{className:"flex items-center gap-4 p-4",children:[y?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(pg,{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:me.getArchiveThumbnail(t.archive_id),alt:"",className:"w-full h-full object-cover"}):t.library_file_thumbnail?s.jsx("img",{src:me.getLibraryFileThumbnailUrl(t.library_file_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(sl,{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||t.library_file_name||`File #${t.archive_id||t.library_file_id}`}),t.archive_id?s.jsx(ps,{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(Gr,{className:"w-3.5 h-3.5"})}):t.library_file_id?s.jsx(ps,{to:`/library?highlight=${t.library_file_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:"View in File Manager",children:s.jsx(Gr,{className:"w-3.5 h-3.5"})}):null]}),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 ${t.printer_id===null?"text-orange-400":""}`,children:[s.jsx(Wr,{className:"w-3.5 h-3.5"}),t.printer_id===null?"Unassigned":t.printer_name||`Printer #${t.printer_id}`]}),t.print_time_seconds&&s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx(Ad,{className:"w-3.5 h-3.5"}),Uie(t.print_time_seconds)]}),y&&!t.manual_start&&s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx(Jn,{className:"w-3.5 h-3.5"}),lYe(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(fK,{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(wu,{className:"w-3 h-3"}),"Auto power off"]})]}),x&&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(cYe,{status:t.status}),s.jsxs("div",{className:"flex items-center gap-1",children:[x&&s.jsx(Me,{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(fde,{className:"w-4 h-4"})}),y&&s.jsxs(s.Fragment,{children:[t.manual_start&&s.jsx(Me,{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(ol,{className:"w-4 h-4"})}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:n,title:"Edit",children:s.jsx(Na,{className:"w-4 h-4"})}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:r,title:"Cancel",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:s.jsx(Gt,{className:"w-4 h-4"})})]}),S&&s.jsxs(s.Fragment,{children:[s.jsx(Me,{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(Ar,{className:"w-4 h-4"})}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:i,title:"Remove",children:s.jsx(hn,{className:"w-4 h-4"})})]})]})]})})}function uYe(){const t=ln(),{showToast:e}=Yn(),[n,r]=w.useState(null),[i,a]=w.useState(""),[o,l]=w.useState(!1),[c,u]=w.useState(null),[d,f]=w.useState(null),[m,p]=w.useState(null),[b,v]=w.useState(()=>localStorage.getItem("queue.historySortBy")||"date"),[x,y]=w.useState(()=>{const Z=localStorage.getItem("queue.historySortAsc");return Z!==null?Z==="true":!1}),[S,M]=w.useState(()=>localStorage.getItem("queue.pendingSortBy")||"position"),[N,A]=w.useState(()=>{const Z=localStorage.getItem("queue.pendingSortAsc");return Z!==null?Z==="true":!0});w.useEffect(()=>{localStorage.setItem("queue.historySortBy",b)},[b]),w.useEffect(()=>{localStorage.setItem("queue.historySortAsc",String(x))},[x]),w.useEffect(()=>{localStorage.setItem("queue.pendingSortBy",S)},[S]),w.useEffect(()=>{localStorage.setItem("queue.pendingSortAsc",String(N))},[N]);const k=mie(WM(LN,{activationConstraint:{distance:8}}),WM(ON,{coordinateGetter:Iie})),{data:C}=ft({queryKey:["settings"],queryFn:me.getSettings}),D=C?.time_format||"system",{data:T,isLoading:R}=ft({queryKey:["queue",n,i],queryFn:()=>me.getQueue(n||void 0,i||void 0),refetchInterval:5e3}),{data:U}=ft({queryKey:["printers"],queryFn:()=>me.getPrinters()}),L=pt({mutationFn:Z=>me.cancelQueueItem(Z),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item cancelled")},onError:()=>e("Failed to cancel item","error")}),q=pt({mutationFn:Z=>me.removeFromQueue(Z),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item removed")},onError:()=>e("Failed to remove item","error")}),j=pt({mutationFn:Z=>me.stopQueueItem(Z),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Print stopped")},onError:()=>e("Failed to stop print","error")}),W=pt({mutationFn:Z=>me.startQueueItem(Z),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Print released to queue")},onError:()=>e("Failed to start print","error")}),K=pt({mutationFn:Z=>me.reorderQueue(Z),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]})},onError:()=>e("Failed to reorder queue","error")}),V=pt({mutationFn:async()=>{const Z=T?.filter(ee=>["completed","failed","skipped","cancelled"].includes(ee.status))||[];for(const ee of Z)await me.removeFromQueue(ee.id);return Z.length},onSuccess:Z=>{t.invalidateQueries({queryKey:["queue"]}),e(`Cleared ${Z} history item${Z!==1?"s":""}`)},onError:()=>e("Failed to clear history","error")}),J=w.useMemo(()=>{const Z=T?.filter(he=>he.status==="pending")||[],ee=he=>{if(!he.scheduled_time)return 0;const fe=new Date(he.scheduled_time).getTime(),oe=Date.now()+4320*60*60*1e3;return fe>oe?0:fe};return[...Z].sort((he,fe)=>{let oe;if(S==="name"){const Ne=he.archive_name||he.library_file_name||"",ge=fe.archive_name||fe.library_file_name||"";oe=Ne.localeCompare(ge)}else S==="printer"?oe=(he.printer_name||"").localeCompare(fe.printer_name||""):S==="time"?oe=ee(he)-ee(fe):oe=he.position-fe.position;return N?oe:-oe})},[T,S,N]),ne=T?.filter(Z=>Z.status==="printing")||[],te=w.useMemo(()=>[...T?.filter(ee=>["completed","failed","skipped","cancelled"].includes(ee.status))||[]].sort((ee,he)=>{let fe;if(b==="name"){const oe=ee.archive_name||ee.library_file_name||"",Ne=he.archive_name||he.library_file_name||"";fe=oe.localeCompare(Ne)}else b==="printer"?fe=(ee.printer_name||"").localeCompare(he.printer_name||""):fe=new Date(he.completed_at||he.created_at).getTime()-new Date(ee.completed_at||ee.created_at).getTime();return x?-fe:fe}),[T,b,x]),z=w.useMemo(()=>J.reduce((Z,ee)=>Z+(ee.print_time_seconds||0),0),[J]),H=Z=>{const{active:ee,over:he}=Z;if(!he||ee.id===he.id)return;const fe=J.findIndex(Ne=>Ne.id===ee.id),oe=J.findIndex(Ne=>Ne.id===he.id);if(fe!==-1&&oe!==-1){const ge=UN(J,fe,oe).map((Se,Re)=>({id:Se.id,position:Re+1}));K.mutate(ge)}};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(mK,{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(Nt,{className:"bg-gradient-to-br from-blue-500/10 to-transparent border-blue-500/20",children:s.jsx(Ct,{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(ol,{className:"w-5 h-5 text-blue-400"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:ne.length}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Printing"})]})]})})}),s.jsx(Nt,{className:"bg-gradient-to-br from-yellow-500/10 to-transparent border-yellow-500/20",children:s.jsx(Ct,{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(Jn,{className:"w-5 h-5 text-yellow-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:"Queued"})]})]})})}),s.jsx(Nt,{className:"bg-gradient-to-br from-bambu-green/10 to-transparent border-bambu-green/20",children:s.jsx(Ct,{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(Ad,{className:"w-5 h-5 text-bambu-green"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:Uie(z)}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Total Queue Time"})]})]})})}),s.jsx(Nt,{className:"bg-gradient-to-br from-gray-500/10 to-transparent border-gray-500/20",children:s.jsx(Ct,{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(Hn,{className:"w-5 h-5 text-gray-400"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:te.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===-1?"unassigned":n||"",onChange:Z=>{const ee=Z.target.value;r(ee==="unassigned"?-1:ee===""?null:Number(ee))},children:[s.jsx("option",{value:"",children:"All Printers"}),s.jsx("option",{value:"unassigned",children:"Unassigned"}),U?.map(Z=>s.jsx("option",{value:Z.id,children:Z.name},Z.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:Z=>a(Z.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"}),te.length>0&&s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>l(!0),children:[s.jsx(hn,{className:"w-4 h-4"}),"Clear History"]})]}),R?s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading..."}):T?.length===0?s.jsxs(Nt,{className:"p-12 text-center border-dashed",children:[s.jsx(si,{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:[ne.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:ne.map(Z=>s.jsx(Vj,{item:Z,onEdit:()=>{},onCancel:()=>{},onRemove:()=>{},onStop:()=>p({type:"stop",item:Z}),onRequeue:()=>{},onStart:()=>{},timeFormat:D},Z.id))})]}),J.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(Jn,{className:"w-5 h-5 text-yellow-400"}),"Queued",s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",J.length," item",J.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:S,onChange:Z=>M(Z.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(Me,{variant:"ghost",size:"sm",onClick:()=>A(!N),title:N?"Ascending":"Descending",className:"px-2",children:N?s.jsx(hg,{className:"w-4 h-4"}):s.jsx(A0,{className:"w-4 h-4"})})]})]}),s.jsx(jie,{sensors:k,collisionDetection:bie,onDragEnd:H,children:s.jsx(Die,{items:J.map(Z=>Z.id),strategy:ZXe,children:s.jsx("div",{className:"space-y-3",children:J.map((Z,ee)=>s.jsx(Vj,{item:Z,position:ee+1,onEdit:()=>u(Z),onCancel:()=>p({type:"cancel",item:Z}),onRemove:()=>{},onStop:()=>{},onRequeue:()=>{},onStart:()=>W.mutate(Z.id),timeFormat:D},Z.id))})})})]}),te.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(Hn,{className:"w-5 h-5 text-bambu-gray"}),"History",s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",te.length," item",te.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:b,onChange:Z=>v(Z.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(Me,{variant:"ghost",size:"sm",onClick:()=>y(!x),title:x?"Ascending (oldest first)":"Descending (newest first)",className:"px-2",children:x?s.jsx(hg,{className:"w-4 h-4"}):s.jsx(A0,{className:"w-4 h-4"})})]})]}),s.jsx("div",{className:"space-y-3",children:te.slice(0,20).map((Z,ee)=>s.jsx(Vj,{item:Z,position:ee+1,onEdit:()=>{},onCancel:()=>{},onRemove:()=>p({type:"remove",item:Z}),onStop:()=>{},onRequeue:()=>f(Z),onStart:()=>{},timeFormat:D},Z.id))})]})]}),c&&s.jsx(ih,{mode:"edit-queue-item",archiveId:c.archive_id??void 0,libraryFileId:c.library_file_id??void 0,archiveName:c.archive_name||c.library_file_name||`File #${c.archive_id||c.library_file_id}`,queueItem:c,onClose:()=>u(null)}),d&&s.jsx(ih,{mode:"add-to-queue",archiveId:d.archive_id??void 0,libraryFileId:d.library_file_id??void 0,archiveName:d.archive_name||d.library_file_name||`File #${d.archive_id||d.library_file_id}`,onClose:()=>f(null)}),m&&s.jsx(zn,{title:m.type==="cancel"?"Cancel Scheduled Print":m.type==="stop"?"Stop Print":"Remove from History",message:m.type==="cancel"?`Are you sure you want to cancel "${m.item.archive_name||m.item.library_file_name||"this print"}"?`:m.type==="stop"?`Are you sure you want to stop the current print "${m.item.archive_name||m.item.library_file_name||"this print"}"? This will cancel the print job on the printer.`:`Are you sure you want to remove "${m.item.archive_name||m.item.library_file_name||"this item"}" from the queue history?`,confirmText:m.type==="cancel"?"Cancel Print":m.type==="stop"?"Stop Print":"Remove",variant:"danger",onConfirm:()=>{m.type==="cancel"?L.mutate(m.item.id):m.type==="stop"?j.mutate(m.item.id):q.mutate(m.item.id),p(null)},onCancel:()=>p(null)}),o&&s.jsx(zn,{title:"Clear History",message:`Are you sure you want to remove all ${te.length} item${te.length!==1?"s":""} from the history?`,confirmText:"Clear History",variant:"danger",onConfirm:()=>{V.mutate(),l(!1)},onCancel:()=>l(!1)})]})}function dYe({printDates:t,months:e=3}){const n=w.useRef(null),[r,i]=w.useState(0);w.useEffect(()=>{const S=n.current;if(!S)return;const M=new ResizeObserver(N=>{const A=N[0]?.contentRect.width||0;i(A)});return M.observe(S),()=>M.disconnect()},[]);const{weeks:a,monthLabels:o,printCounts:l}=w.useMemo(()=>{const S={};t.forEach(U=>{const L=U.split("T")[0];S[L]=(S[L]||0)+1});const M=new Date,N=new Date(M);N.setMonth(N.getMonth()-e),N.setDate(N.getDate()-N.getDay());const A=[],k=[];let C=[],D=-1;const T=new Date(N);let R=0;for(;T<=M;)T.getDay()===0&&C.length>0&&(A.push(C),C=[],R++),T.getMonth()!==D&&(k.push({month:T.toLocaleDateString("en-US",{month:"short"}),weekIndex:R}),D=T.getMonth()),C.push(new Date(T)),T.setDate(T.getDate()+1);return C.length>0&&A.push(C),{weeks:A,monthLabels:k,printCounts:S}},[t,e]),c=Math.max(1,...Object.values(l)),u=S=>{if(S===0)return"bg-bambu-dark";const M=S/c;return M<=.25?"bg-bambu-green/30":M<=.5?"bg-bambu-green/50":M<=.75?"bg-bambu-green/75":"bg-bambu-green"},d=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],f=a.length,m=32,p=2,b=r-m-16,v=f>0?Math.floor((b-(f-1)*p)/f):12,x=Math.max(8,Math.min(20,v)),y=x<=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:m+4},children:o.map(({month:S,weekIndex:M},N)=>s.jsx("div",{className:"text-bambu-gray",style:{fontSize:y,marginLeft:N===0?0:`${(M-(o[N-1]?.weekIndex||0))*(x+p)-24}px`},children:S},N))}),s.jsxs("div",{className:"flex",style:{gap:p},children:[s.jsx("div",{className:"flex flex-col",style:{gap:p,marginRight:4,width:m},children:d.map((S,M)=>s.jsx("div",{className:"text-bambu-gray flex items-center",style:{width:m,height:x,fontSize:y,visibility:M%2===1?"visible":"hidden"},children:S},S))}),a.map((S,M)=>s.jsx("div",{className:"flex flex-col",style:{gap:p},children:[0,1,2,3,4,5,6].map(N=>{const A=S.find(T=>T.getDay()===N);if(!A)return s.jsx("div",{style:{width:x,height:x}},N);const k=A.toISOString().split("T")[0],C=l[k]||0,D=k===new Date().toISOString().split("T")[0];return s.jsx("div",{className:`rounded-sm ${u(C)} ${D?"ring-1 ring-white":""}`,style:{width:x,height:x},title:`${A.toLocaleDateString()}: ${C} print${C!==1?"s":""}`},N)})},M))]}),s.jsxs("div",{className:"flex items-center gap-2 mt-3 text-bambu-gray",style:{fontSize:y},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:x,height:x}}),s.jsx("div",{className:"rounded-sm bg-bambu-green/30",style:{width:x,height:x}}),s.jsx("div",{className:"rounded-sm bg-bambu-green/50",style:{width:x,height:x}}),s.jsx("div",{className:"rounded-sm bg-bambu-green/75",style:{width:x,height:x}}),s.jsx("div",{className:"rounded-sm bg-bambu-green",style:{width:x,height:x}})]}),s.jsx("span",{children:"More"})]})]})})}const W1=["#00ae42","#3b82f6","#f59e0b","#ef4444","#8b5cf6","#ec4899","#14b8a6","#f97316"];function hYe(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 fYe({archives:t,currency:e="$"}){const[n,r]=w.useState("30d"),i=w.useMemo(()=>{const m=hYe(n);return t.filter(p=>(Si(p.completed_at||p.created_at)||new Date(0))>=m)},[t,n]),a=w.useMemo(()=>{const m=new Map;return i.forEach(p=>{const b=Si(p.completed_at||p.created_at)||new Date,v=`${b.getFullYear()}-${String(b.getMonth()+1).padStart(2,"0")}-${String(b.getDate()).padStart(2,"0")}`,x=m.get(v)||{date:v,filament:0,cost:0,prints:0};x.filament+=p.filament_used_grams||0,x.cost+=p.cost||0,x.prints+=1,m.set(v,x)}),Array.from(m.values()).sort((p,b)=>p.date.localeCompare(b.date)).map(p=>({...p,dateLabel:new Date(p.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})}))},[i]),o=w.useMemo(()=>{if(n==="7d"||n==="30d")return a;const m=new Map;return i.forEach(p=>{const b=Si(p.completed_at||p.created_at)||new Date,v=new Date(b);v.setDate(b.getDate()-b.getDay());const x=`${v.getFullYear()}-${String(v.getMonth()+1).padStart(2,"0")}-${String(v.getDate()).padStart(2,"0")}`,y=m.get(x)||{week:x,filament:0,cost:0,prints:0};y.filament+=p.filament_used_grams||0,y.cost+=p.cost||0,y.prints+=1,m.set(x,y)}),Array.from(m.values()).sort((p,b)=>p.week.localeCompare(b.week)).map(p=>({date:p.week,dateLabel:`Week of ${new Date(p.week).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`,...p}))},[i,a,n]),l=w.useMemo(()=>{const m=new Map;return i.forEach(p=>{const v=(p.filament_type||"Unknown").split(", ");v.forEach(x=>{const y=(p.filament_used_grams||0)/v.length;m.set(x,(m.get(x)||0)+y)})}),Array.from(m.entries()).map(([p,b])=>({name:p,value:Math.round(b)})).sort((p,b)=>b.value-p.value)},[i]),c=w.useMemo(()=>{const m=new Date,p=[];for(let b=5;b>=0;b--){const v=new Date(m.getFullYear(),m.getMonth()-b,1),x=new Date(m.getFullYear(),m.getMonth()-b+1,0),y=v.toLocaleDateString("en-US",{month:"short",year:"2-digit"}),S=t.filter(M=>{const N=Si(M.completed_at||M.created_at)||new Date(0);return N>=v&&N<=x});p.push({month:y,filament:Math.round(S.reduce((M,N)=>M+(N.filament_used_grams||0),0)),cost:S.reduce((M,N)=>M+(N.cost||0),0),prints:S.length})}return p},[t]),u=n==="7d"||n==="30d"?a:o,d=i.reduce((m,p)=>m+(p.filament_used_grams||0),0),f=i.reduce((m,p)=>m+(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(m=>s.jsx("button",{onClick:()=>r(m),className:`px-3 py-1 text-sm rounded-md transition-colors ${n===m?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:m==="all"?"All":m.replace("d","D")},m))})]}),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(nw,{width:"100%",height:250,children:s.jsxs(wPe,{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(jS,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),s.jsx(OS,{dataKey:"dateLabel",stroke:"#9ca3af",tick:{fontSize:12},interval:"preserveStartEnd"}),s.jsx(LS,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:m=>`${m}g`}),s.jsx(iw,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},labelStyle:{color:"#fff"},formatter:m=>[`${Number(m??0).toFixed(0)}g`,"Filament"]}),s.jsx(MJ,{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(nw,{width:160,height:160,children:s.jsxs(vPe,{children:[s.jsx(YQ,{data:l,cx:"50%",cy:"50%",innerRadius:40,outerRadius:70,paddingAngle:2,dataKey:"value",children:l.map((m,p)=>s.jsx(zy,{fill:W1[p%W1.length]},`cell-${p}`))}),s.jsx(iw,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:m=>[`${m??0}g`,"Usage"]})]})}),s.jsx("div",{className:"flex-1 space-y-2 overflow-hidden",children:l.map((m,p)=>{const b=l.reduce((x,y)=>x+y.value,0),v=b>0?(m.value/b*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:W1[p%W1.length]}}),s.jsx("span",{className:"text-white truncate flex-1",children:m.name}),s.jsxs("span",{className:"text-bambu-gray flex-shrink-0",children:[v,"%"]})]},m.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(nw,{width:"100%",height:200,children:s.jsxs(lPe,{data:c,children:[s.jsx(jS,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),s.jsx(OS,{dataKey:"month",stroke:"#9ca3af",tick:{fontSize:12}}),s.jsx(LS,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:m=>`${m}g`}),s.jsx(iw,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:(m,p)=>[p==="filament"?`${m??0}g`:p==="cost"?`${e}${Number(m??0).toFixed(2)}`:m??0,p==="filament"?"Filament":p==="cost"?"Cost":"Prints"]}),s.jsx(bO,{}),s.jsx(CJ,{dataKey:"filament",name:"Filament (g)",fill:"#00ae42",radius:[4,4,0,0]})]})})]})]})]})}function mYe({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:m}=Lie({id:t}),p={transform:Hg.Transform.toString(d),transition:f,opacity:m?.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 ${m?"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(pg,{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(gK,{className:"w-4 h-4 text-bambu-gray hover:text-white"}):s.jsx(pK,{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(tE,{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 pYe({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]=w.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]=w.useState(!1);w.useEffect(()=>{const N=()=>d(A=>!A);return window.addEventListener("toggle-hidden-panel",N),()=>window.removeEventListener("toggle-hidden-panel",N)},[]),w.useEffect(()=>{localStorage.setItem(e,JSON.stringify(l))},[l,e]),w.useEffect(()=>{const A=t.map(k=>k.id).filter(k=>!l.order.includes(k));A.length>0&&c(k=>({...k,order:[...k.order,...A]}))},[t,l.order]);const f=mie(WM(LN,{activationConstraint:{distance:8}}),WM(ON,{coordinateGetter:Iie})),m=N=>{const{active:A,over:k}=N;k&&A.id!==k.id&&c(C=>{const D=C.order.indexOf(A.id),T=C.order.indexOf(k.id);return{...C,order:UN(C.order,D,T)}})},p=N=>{c(A=>({...A,hidden:A.hidden.includes(N)?A.hidden.filter(k=>k!==N):[...A.hidden,N]}))},b=N=>{c(A=>{const k=A.sizes[N]||4,C=k===1?2:k===2?4:1;return{...A,sizes:{...A.sizes,[N]:C}}})},v=()=>{const N={order:t.map(A=>A.id),hidden:t.filter(A=>A.defaultVisible===!1).map(A=>A.id),sizes:o()};c(N),i?.()},x=l.order.map(N=>t.find(A=>A.id===N)).filter(Boolean),y=x.filter(N=>!l.hidden.includes(N.id)),S=x.filter(N=>l.hidden.includes(N.id)),M=a?.({hiddenCount:S.length,showHiddenPanel:u,setShowHiddenPanel:d,resetLayout:v});return s.jsxs("div",{className:"space-y-4",children:[M,!r&&!a&&s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsxs(Me,{variant:"secondary",size:"sm",onClick:v,children:[s.jsx(lm,{className:"w-4 h-4"}),"Reset Layout"]}),S.length>0&&s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>d(!u),children:[s.jsx(Ff,{className:"w-4 h-4"}),S.length," Hidden"]})]}),u&&S.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:S.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(Ff,{className:"w-3 h-3"}),N.title]},N.id))})]}),s.jsx(jie,{sensors:f,collisionDetection:bie,onDragEnd:m,children:s.jsx(Die,{items:y.map(N=>N.id),strategy:pI,children:s.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:y.map(N=>s.jsx(mYe,{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:()=>b(N.id)},N.id))})})}),y.length===0&&s.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[s.jsx("p",{children:"All widgets are hidden."}),s.jsx(Me,{className:"mt-4",onClick:v,children:"Reset Layout"})]})]})}function gYe({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(Ql,{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(Jn,{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(Ql,{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(mP,{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(Bf,{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(mP,{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 xYe({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(Hn,{className:"w-4 h-4 text-status-ok 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(za,{className:"w-4 h-4 text-status-error 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 bYe({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=(b=>b>=95&&b<=105?"#00ae42":b>105?"#3b82f6":"#f97316")(r),c=r-100,u=n===1?112:n===2?128:144,d=u/2-8,f=d*2*Math.PI,m=n===1?3:n===2?6:999,p=t?.time_accuracy_by_printer?Object.entries(t.time_accuracy_by_printer).slice(0,m):[];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(_K,{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(([b,v])=>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(b)||`Printer ${b}`}),s.jsxs("span",{className:`font-medium ${v>=95&&v<=105?"text-status-ok":v>105?"text-blue-400":"text-status-warning"}`,children:[v.toFixed(0),"%"]})]},b))})]})]})}function yYe({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 vYe({printDates:t,size:e=2}){const n=e===1?3:e===2?6:12;return s.jsx(dYe,{printDates:t,months:n})}function _Ye({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(Wr,{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 wYe({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(fYe,{archives:t,currency:e})}function SYe({size:t=1}){const{data:e,isLoading:n}=ft({queryKey:["failureAnalysis"],queryFn:()=>me.getFailureAnalysis({days:30})});if(n)return s.jsx("div",{className:"flex justify-center py-4",children:s.jsx(mt,{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(Tn,{className:`w-5 h-5 ${e.failure_rate>20?"text-status-error":e.failure_rate>10?"text-status-warning":"text-status-ok"}`}),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(SK,{className:`w-4 h-4 ${e.trend[e.trend.length-1].failure_rate<e.trend[e.trend.length-2].failure_rate?"text-status-ok":"text-status-error"}`}),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 MYe(){const{showToast:t}=Yn(),[e,n]=w.useState(!1),[r,i]=w.useState(!1),[a,o]=w.useState(0),[l,c]=w.useState(0),[u,d]=w.useState(!1);w.useEffect(()=>{const C=()=>{try{const T=localStorage.getItem("bambusy-dashboard-layout");if(T){const R=JSON.parse(T);c(R.hidden?.length||0)}}catch{c(0)}};C(),window.addEventListener("storage",C);const D=setInterval(C,500);return()=>{window.removeEventListener("storage",C),clearInterval(D)}},[a]);const{data:f,isLoading:m,refetch:p}=ft({queryKey:["archiveStats"],queryFn:me.getArchiveStats}),{data:b}=ft({queryKey:["printers"],queryFn:me.getPrinters}),{data:v}=ft({queryKey:["archives"],queryFn:()=>me.getArchives(void 0,void 0,1e3,0)}),{data:x}=ft({queryKey:["settings"],queryFn:me.getSettings}),y=async C=>{i(!1),n(!0);try{const{blob:D,filename:T}=await me.exportStats({format:C,days:90}),R=URL.createObjectURL(D),U=document.createElement("a");U.href=R,U.download=T,U.click(),URL.revokeObjectURL(R),t("Export downloaded")}catch{t("Export failed","error")}finally{n(!1)}},S=async()=>{d(!0);try{const C=await me.recalculateCosts();await p(),t(`Recalculated costs for ${C.updated} archives`)}catch{t("Failed to recalculate costs","error")}finally{d(!1)}},M=x?.currency||"$",N=new Map(b?.map(C=>[String(C.id),C.name])||[]),A=v?.map(C=>C.created_at)||[];if(m)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 k=[{id:"quick-stats",title:"Quick Stats",component:s.jsx(gYe,{stats:f,currency:M}),defaultSize:2},{id:"success-rate",title:"Success Rate",component:C=>s.jsx(xYe,{stats:f,printerMap:N,size:C}),defaultSize:1},{id:"time-accuracy",title:"Time Accuracy",component:C=>s.jsx(bYe,{stats:f,printerMap:N,size:C}),defaultSize:1},{id:"filament-types",title:"Filament Types",component:C=>s.jsx(yYe,{stats:f,size:C}),defaultSize:1},{id:"failure-analysis",title:"Failure Analysis (30 days)",component:C=>s.jsx(SYe,{size:C}),defaultSize:1},{id:"print-activity",title:"Print Activity",component:C=>s.jsx(vYe,{printDates:A,size:C}),defaultSize:2},{id:"prints-by-printer",title:"Prints by Printer",component:s.jsx(_Ye,{stats:f,printerMap:N}),defaultSize:2},{id:"filament-trends",title:"Filament Usage Trends",component:s.jsx(wYe,{archives:v||[],currency:M}),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(Me,{variant:"secondary",onClick:()=>{window.dispatchEvent(new CustomEvent("toggle-hidden-panel"))},children:[s.jsx(Ff,{className:"w-4 h-4"}),l," Hidden"]}),s.jsxs(Me,{variant:"secondary",onClick:()=>{localStorage.removeItem("bambusy-dashboard-layout"),o(C=>C+1),t("Layout reset")},children:[s.jsx(lm,{className:"w-4 h-4"}),"Reset Layout"]}),s.jsxs(Me,{variant:"secondary",onClick:S,disabled:u,title:"Recalculate all archive costs using current filament prices",children:[u?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(Kue,{className:"w-4 h-4"}),"Recalculate Costs"]}),s.jsxs("div",{className:"relative",children:[s.jsxs(Me,{variant:"secondary",onClick:()=>i(!r),disabled:e,children:[e?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(jw,{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:()=>y("csv"),children:[s.jsx(Ya,{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:()=>y("xlsx"),children:[s.jsx(jw,{className:"w-4 h-4"}),"Export as Excel"]})]})]})]})]}),s.jsx(pYe,{widgets:k,storageKey:"bambusy-dashboard-layout",hideControls:!0},a)]})}function EYe({plug:t,onEdit:e}){const n=ln(),{showToast:r}=Yn(),[i,a]=w.useState(!1),[o,l]=w.useState(!1),[c,u]=w.useState(!1),[d,f]=w.useState(!1),{data:m,isLoading:p}=ft({queryKey:["smart-plug-status",t.id],queryFn:()=>me.getSmartPlugStatus(t.id),refetchInterval:3e4}),{data:b}=ft({queryKey:["printers"],queryFn:me.getPrinters}),v=b?.find(D=>D.id===t.printer_id),x=pt({mutationFn:D=>me.controlSmartPlug(t.id,D),onMutate:async D=>{await n.cancelQueries({queryKey:["smart-plug-status",t.id]});const T=n.getQueryData(["smart-plug-status",t.id]),R=D==="on"?"ON":D==="off"||m?.state==="ON"?"OFF":"ON";return n.setQueryData(["smart-plug-status",t.id],U=>({...U,state:R})),{previousStatus:T}},onError:(D,T,R)=>{R?.previousStatus&&n.setQueryData(["smart-plug-status",t.id],R.previousStatus),r(`Failed to turn ${T} "${t.name}"`,"error")},onSettled:()=>{setTimeout(()=>{n.invalidateQueries({queryKey:["smart-plug-status",t.id]}),n.invalidateQueries({queryKey:["smart-plugs"]})},1e3)}}),y=pt({mutationFn:D=>me.updateSmartPlug(t.id,D),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&n.invalidateQueries({queryKey:["smartPlugByPrinter",t.printer_id]})}}),S=pt({mutationFn:()=>me.deleteSmartPlug(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]})}}),M=m?.state==="ON",N=m?.reachable??!1,A=x.isPending,C=(()=>{if(t.plug_type!=="tasmota"||!t.ip_address)return null;const D=t.ip_address;return t.username&&t.password?`http://${encodeURIComponent(t.username)}:${encodeURIComponent(t.password)}@${D}/`:`http://${D}/`})();return s.jsxs(s.Fragment,{children:[s.jsx(Nt,{className:"relative",children:s.jsxs(Ct,{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?M?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:t.plug_type==="homeassistant"?s.jsx(sE,{className:`w-5 h-5 ${N?M?"text-bambu-green":"text-bambu-gray":"text-red-400"}`}):s.jsx(Ws,{className:`w-5 h-5 ${N?M?"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.plug_type==="homeassistant"?t.ha_entity_id:t.ip_address})]})]}),s.jsxs("div",{className:"flex flex-col items-end gap-1",children:[p?s.jsx(mt,{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(Qp,{className:"w-4 h-4 text-status-ok"}),s.jsx("span",{className:M?"text-status-ok":"text-bambu-gray",children:m?.state||"Unknown"})]}):s.jsxs("div",{className:"flex items-center gap-1 text-sm text-status-error",children:[s.jsx(Yg,{className:"w-4 h-4"}),s.jsx("span",{children:"Offline"})]}),C&&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(Gr,{className:"w-3 h-3"}),"Admin"]})]})]}),v&&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:v.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(vf,{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(si,{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(Me,{size:"sm",variant:M?"primary":"secondary",disabled:!N||A,onClick:()=>l(!0),className:"flex-1",children:[A?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(wu,{className:"w-4 h-4"}),"On"]}),s.jsxs(Me,{size:"sm",variant:M?"secondary":"primary",disabled:!N||A,onClick:()=>u(!0),className:"flex-1",children:[A?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(uE,{className:"w-4 h-4"}),"Off"]})]}),s.jsxs("button",{onClick:()=>f(!d),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(Kd,{className:"w-4 h-4"}),"Automation Settings"]}),s.jsx("span",{children:d?"-":"+"})]}),d&&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(oE,{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:D=>y.mutate({show_in_switchbar:D.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:D=>y.mutate({enabled:D.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:D=>y.mutate({auto_on:D.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:D=>y.mutate({auto_off:D.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:()=>y.mutate({off_delay_mode:"time"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="time"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[s.jsx(Jn,{className:"w-4 h-4"}),"Time"]}),s.jsxs("button",{onClick:()=>y.mutate({off_delay_mode:"temperature"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="temperature"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[s.jsx(hE,{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:D=>y.mutate({off_delay_minutes:parseInt(D.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:D=>y.mutate({off_temp_threshold:parseInt(D.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(Me,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[s.jsx(cE,{className:"w-4 h-4"}),"Edit"]}),s.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>a(!0),className:"text-red-400 hover:text-red-300",children:s.jsx(hn,{className:"w-4 h-4"})})]})]})]})}),i&&s.jsx(zn,{title:"Delete Smart Plug",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{S.mutate(),a(!1)},onCancel:()=>a(!1)}),o&&s.jsx(zn,{title:"Turn On Smart Plug",message:`Are you sure you want to turn on "${t.name}"?`,confirmText:"Turn On",variant:"default",onConfirm:()=>{x.mutate("on"),l(!1)},onCancel:()=>l(!1)}),c&&s.jsx(zn,{title:"Turn Off Smart Plug",message:`Are you sure you want to turn off "${t.name}"? This will cut power to the connected device.`,confirmText:"Turn Off",variant:"danger",onConfirm:()=>{x.mutate("off"),u(!1)},onCancel:()=>u(!1)})]})}function NYe({plug:t,onClose:e}){const n=ln(),r=!!t,[i,a]=w.useState(t?.plug_type||"tasmota"),[o,l]=w.useState(t?.name||""),[c,u]=w.useState(t?.ip_address||""),[d,f]=w.useState(t?.username||""),[m,p]=w.useState(t?.password||""),[b,v]=w.useState(t?.ha_entity_id||""),[x,y]=w.useState(t?.ha_power_entity||""),[S,M]=w.useState(t?.ha_energy_today_entity||""),[N,A]=w.useState(t?.ha_energy_total_entity||""),[k,C]=w.useState(""),[D,T]=w.useState(""),[R,U]=w.useState(!1),L=w.useRef(null),[q,j]=w.useState(""),[W,K]=w.useState(!1),V=w.useRef(null),[J,ne]=w.useState(""),[te,z]=w.useState(!1),H=w.useRef(null),[Z,ee]=w.useState(""),[he,fe]=w.useState(!1),oe=w.useRef(null),[Ne,ge]=w.useState(t?.printer_id||null),[Se,Re]=w.useState(null),[de,Qe]=w.useState(null),[G,ie]=w.useState(t?.power_alert_enabled||!1),[X,$]=w.useState(t?.power_alert_high?.toString()||""),[I,ce]=w.useState(t?.power_alert_low?.toString()||""),[Ee,Ie]=w.useState(t?.schedule_enabled||!1),[le,B]=w.useState(t?.schedule_on_time||""),[O,Y]=w.useState(t?.schedule_off_time||""),[pe,we]=w.useState(t?.show_in_switchbar||!1),[ae,ke]=w.useState(!1),[De,Ke]=w.useState({scanned:0,total:0}),[et,Ye]=w.useState([]),se=w.useRef(null),{data:ye}=ft({queryKey:["printers"],queryFn:me.getPrinters}),{data:Ce}=ft({queryKey:["smart-plugs"],queryFn:me.getSmartPlugs}),{data:Ue}=ft({queryKey:["settings"],queryFn:me.getSettings}),dt=!!(Ue?.ha_enabled&&Ue?.ha_url&&Ue?.ha_token);w.useEffect(()=>{const xt=setTimeout(()=>{T(k)},300);return()=>clearTimeout(xt)},[k]),w.useEffect(()=>{const xt=Yt=>{L.current&&!L.current.contains(Yt.target)&&U(!1),V.current&&!V.current.contains(Yt.target)&&K(!1),H.current&&!H.current.contains(Yt.target)&&z(!1),oe.current&&!oe.current.contains(Yt.target)&&fe(!1)};return document.addEventListener("mousedown",xt),()=>document.removeEventListener("mousedown",xt)},[]);const{data:re,isLoading:Fe,error:ve}=ft({queryKey:["ha-entities",D],queryFn:()=>me.getHAEntities(D||void 0),enabled:i==="homeassistant"&&dt,retry:!1,staleTime:0}),{data:$e}=ft({queryKey:["ha-sensor-entities"],queryFn:me.getHASensorEntities,enabled:i==="homeassistant"&&dt,retry:!1,staleTime:0});w.useEffect(()=>{const xt=Yt=>{Yt.key==="Escape"&&e()};return window.addEventListener("keydown",xt),()=>{window.removeEventListener("keydown",xt),se.current&&clearInterval(se.current)}},[e]);const Le=async()=>{ke(!0),Ye([]),Ke({scanned:0,total:0}),Qe(null);try{await me.startTasmotaScan();const xt=async()=>{try{const Yt=await me.getTasmotaScanStatus();Ke({scanned:Yt.scanned,total:Yt.total});const sn=await me.getDiscoveredTasmotaDevices();Ye(sn),Yt.running||(ke(!1),se.current&&(clearInterval(se.current),se.current=null))}catch(Yt){console.error("Polling error:",Yt)}};await xt(),se.current=setInterval(xt,500)}catch(xt){ke(!1);const Yt=xt instanceof Error?xt.message:typeof xt=="string"?xt:JSON.stringify(xt);Qe(Yt||"Failed to start scan")}},Ae=async()=>{try{await me.stopTasmotaScan()}catch{}ke(!1),se.current&&(clearInterval(se.current),se.current=null)},Ge=xt=>{u(xt.ip_address),l(xt.name),Re(null)},it=pt({mutationFn:()=>me.testSmartPlugConnection(c,d||null,m||null),onSuccess:xt=>{Re(xt),Qe(null),!o&&xt.device_name&&l(xt.device_name)},onError:xt=>{Re(null),Qe(xt.message)}}),Ot=pt({mutationFn:xt=>me.createSmartPlug(xt),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:xt=>{Qe(xt.message)}}),kt=pt({mutationFn:xt=>me.updateSmartPlug(t.id,xt),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:xt=>{Qe(xt.message)}}),on=ye?.filter(xt=>!Ce?.some(sn=>sn.printer_id===xt.id&&sn.id!==t?.id)),Ut=xt=>{if(xt.preventDefault(),Qe(null),!o.trim()){Qe("Name is required");return}if(i==="tasmota"&&!c.trim()){Qe("IP address is required for Tasmota plugs");return}if(i==="homeassistant"&&!b){Qe("Entity is required for Home Assistant plugs");return}const Yt={name:o.trim(),plug_type:i,ip_address:i==="tasmota"?c.trim():null,ha_entity_id:i==="homeassistant"?b:null,ha_power_entity:i==="homeassistant"&&x||null,ha_energy_today_entity:i==="homeassistant"&&S||null,ha_energy_total_entity:i==="homeassistant"&&N||null,username:i==="tasmota"&&d.trim()||null,password:i==="tasmota"&&m.trim()||null,printer_id:Ne,power_alert_enabled:G,power_alert_high:X?parseFloat(X):null,power_alert_low:I?parseFloat(I):null,schedule_enabled:Ee,schedule_on_time:le||null,schedule_off_time:O||null,show_in_switchbar:pe};r?kt.mutate(Yt):Ot.mutate(Yt)},yn=Ot.isPending||kt.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:xt=>xt.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(Gt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:Ut,className:"p-6 space-y-4 overflow-y-auto",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}),!r&&s.jsxs("div",{className:"flex gap-2 mb-2",children:[s.jsxs("button",{type:"button",onClick:()=>{a("tasmota"),Re(null),Qe(null)},className:`flex-1 flex items-center justify-center gap-2 px-4 py-2.5 rounded-lg font-medium transition-colors ${i==="tasmota"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white border border-bambu-dark-tertiary"}`,children:[s.jsx(Ws,{className:"w-4 h-4"}),"Tasmota"]}),s.jsxs("button",{type:"button",onClick:()=>{a("homeassistant"),Re(null),Qe(null)},className:`flex-1 flex items-center justify-center gap-2 px-4 py-2.5 rounded-lg font-medium transition-colors ${i==="homeassistant"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white border border-bambu-dark-tertiary"}`,children:[s.jsx(sE,{className:"w-4 h-4"}),"Home Assistant"]})]}),!r&&i==="tasmota"&&s.jsxs("div",{className:"space-y-3",children:[ae?s.jsxs(Me,{type:"button",variant:"secondary",onClick:Ae,className:"w-full",children:[s.jsx(Gt,{className:"w-4 h-4"}),"Stop Scanning"]}):s.jsxs(Me,{type:"button",variant:"primary",onClick:Le,className:"w-full",children:[s.jsx(Sa,{className:"w-4 h-4"}),"Discover Tasmota Devices"]}),ae&&De.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:[De.scanned," / ",De.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:`${De.scanned/De.total*100}%`}})})]}),et.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("p",{className:"text-xs text-bambu-gray",children:["Found ",et.length," device(s) - click to select:"]}),s.jsx("div",{className:"max-h-40 overflow-y-auto space-y-1",children:et.map(xt=>s.jsxs("button",{type:"button",onClick:()=>Ge(xt),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(Ws,{className:"w-4 h-4 text-bambu-green"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:xt.name}),s.jsx("p",{className:"text-xs text-bambu-gray",children:xt.ip_address})]})]}),xt.state&&s.jsxs("span",{className:`flex items-center gap-1 text-xs ${xt.state==="ON"?"text-bambu-green":"text-bambu-gray"}`,children:[s.jsx(wu,{className:"w-3 h-3"}),xt.state]})]},xt.ip_address))})]}),!ae&&et.length===0&&De.total>0&&s.jsx("p",{className:"text-xs text-bambu-gray text-center py-2",children:"No Tasmota devices found on your network"})]}),i==="homeassistant"&&s.jsxs("div",{className:"space-y-3",children:[!dt&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"p-3 bg-yellow-500/20 border border-yellow-500/50 rounded-lg text-sm text-yellow-400",children:["Home Assistant is not configured. Set it up in"," ",s.jsx("span",{className:"font-medium",children:"Settings → Network → Home Assistant"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1 opacity-50",children:"Select Entity *"}),s.jsx("select",{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 opacity-50",children:s.jsx("option",{children:"Choose an entity..."})})]})]}),dt&&s.jsxs(s.Fragment,{children:[Fe&&s.jsxs("div",{className:"flex items-center justify-center py-4 text-bambu-gray",children:[s.jsx(mt,{className:"w-5 h-5 animate-spin mr-2"}),"Loading entities..."]}),ve&&s.jsxs("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:["Failed to load entities: ",ve.message]}),(()=>{const xt=Ce?.filter(Tt=>Tt.ha_entity_id&&Tt.id!==t?.id).map(Tt=>Tt.ha_entity_id)||[],Yt=(re||[]).filter(Tt=>!xt.includes(Tt.entity_id)),sn=re?.find(Tt=>Tt.entity_id===b);return s.jsxs("div",{ref:L,className:"relative",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Select Entity *"}),s.jsxs("div",{className:"relative",children:[s.jsx(Sa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),s.jsx("input",{type:"text",value:R?k:sn?`${sn.friendly_name} (${sn.entity_id})`:"",onChange:Tt=>{C(Tt.target.value),R||U(!0)},onFocus:()=>{U(!0),C("")},placeholder:"Search entities...",className:"w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),b&&!R&&s.jsx("button",{type:"button",onClick:()=>{v(""),C("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Gt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),Fe&&s.jsx(mt,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray animate-spin"})]}),R&&s.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-60 overflow-y-auto",children:[Fe&&s.jsxs("div",{className:"px-3 py-2 text-sm text-bambu-gray flex items-center gap-2",children:[s.jsx(mt,{className:"w-4 h-4 animate-spin"}),"Loading..."]}),!Fe&&Yt.length===0&&s.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:D?`No entities found matching "${D}"`:"No entities available"}),!Fe&&Yt.map(Tt=>s.jsxs("button",{type:"button",onClick:()=>{v(Tt.entity_id),U(!1),C(""),o||l(Tt.friendly_name)},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary transition-colors ${Tt.entity_id===b?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[s.jsx("div",{className:"font-medium",children:Tt.friendly_name}),s.jsxs("div",{className:"text-xs text-bambu-gray flex items-center justify-between",children:[s.jsx("span",{children:Tt.entity_id}),s.jsx("span",{className:Tt.state==="on"?"text-bambu-green":"",children:Tt.state})]})]},Tt.entity_id))]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:D?`Searching all entities (${Yt.length} found)`:`Showing switch, light, input_boolean (${Yt.length} available)`})]})})(),b&&$e&&$e.length>0&&s.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4 mt-4 space-y-3",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-medium mb-1",children:"Energy Monitoring (Optional)"}),s.jsx("p",{className:"text-xs text-bambu-gray mb-3",children:"Search and select sensors that provide power/energy data."})]}),(()=>{const xt=$e.filter(Tt=>Tt.unit_of_measurement==="W"||Tt.unit_of_measurement==="kW"||Tt.unit_of_measurement==="mW"),Yt=q?xt.filter(Tt=>Tt.entity_id.toLowerCase().includes(q.toLowerCase())||Tt.friendly_name.toLowerCase().includes(q.toLowerCase())):xt,sn=$e.find(Tt=>Tt.entity_id===x);return s.jsxs("div",{ref:V,className:"relative",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Power Sensor (W)"}),s.jsxs("div",{className:"relative",children:[s.jsx(Sa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),s.jsx("input",{type:"text",value:W?q:sn?`${sn.friendly_name} (${sn.state} ${sn.unit_of_measurement})`:"",onChange:Tt=>{j(Tt.target.value),W||K(!0)},onFocus:()=>{K(!0),j("")},placeholder:"Search power sensors...",className:"w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),x&&!W&&s.jsx("button",{type:"button",onClick:()=>{y(""),j("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Gt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),W&&s.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[s.jsx("button",{type:"button",onClick:()=>{y(""),K(!1),j("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),Yt.map(Tt=>s.jsxs("button",{type:"button",onClick:()=>{y(Tt.entity_id),K(!1),j("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${Tt.entity_id===x?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[s.jsx("div",{className:"font-medium",children:Tt.friendly_name}),s.jsxs("div",{className:"text-xs text-bambu-gray",children:[Tt.entity_id," • ",Tt.state," ",Tt.unit_of_measurement]})]},Tt.entity_id)),Yt.length===0&&s.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})(),(()=>{const xt=$e.filter(Tt=>Tt.unit_of_measurement==="kWh"||Tt.unit_of_measurement==="Wh"||Tt.unit_of_measurement==="MWh"),Yt=J?xt.filter(Tt=>Tt.entity_id.toLowerCase().includes(J.toLowerCase())||Tt.friendly_name.toLowerCase().includes(J.toLowerCase())):xt,sn=$e.find(Tt=>Tt.entity_id===S);return s.jsxs("div",{ref:H,className:"relative",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Energy Today (kWh)"}),s.jsxs("div",{className:"relative",children:[s.jsx(Sa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),s.jsx("input",{type:"text",value:te?J:sn?`${sn.friendly_name} (${sn.state} ${sn.unit_of_measurement})`:"",onChange:Tt=>{ne(Tt.target.value),te||z(!0)},onFocus:()=>{z(!0),ne("")},placeholder:"Search energy sensors...",className:"w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),S&&!te&&s.jsx("button",{type:"button",onClick:()=>{M(""),ne("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Gt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),te&&s.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[s.jsx("button",{type:"button",onClick:()=>{M(""),z(!1),ne("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),Yt.map(Tt=>s.jsxs("button",{type:"button",onClick:()=>{M(Tt.entity_id),z(!1),ne("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${Tt.entity_id===S?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[s.jsx("div",{className:"font-medium",children:Tt.friendly_name}),s.jsxs("div",{className:"text-xs text-bambu-gray",children:[Tt.entity_id," • ",Tt.state," ",Tt.unit_of_measurement]})]},Tt.entity_id)),Yt.length===0&&s.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})(),(()=>{const xt=$e.filter(Tt=>Tt.unit_of_measurement==="kWh"||Tt.unit_of_measurement==="Wh"||Tt.unit_of_measurement==="MWh"),Yt=Z?xt.filter(Tt=>Tt.entity_id.toLowerCase().includes(Z.toLowerCase())||Tt.friendly_name.toLowerCase().includes(Z.toLowerCase())):xt,sn=$e.find(Tt=>Tt.entity_id===N);return s.jsxs("div",{ref:oe,className:"relative",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Total Energy (kWh)"}),s.jsxs("div",{className:"relative",children:[s.jsx(Sa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),s.jsx("input",{type:"text",value:he?Z:sn?`${sn.friendly_name} (${sn.state} ${sn.unit_of_measurement})`:"",onChange:Tt=>{ee(Tt.target.value),he||fe(!0)},onFocus:()=>{fe(!0),ee("")},placeholder:"Search energy sensors...",className:"w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),N&&!he&&s.jsx("button",{type:"button",onClick:()=>{A(""),ee("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Gt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),he&&s.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[s.jsx("button",{type:"button",onClick:()=>{A(""),fe(!1),ee("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),Yt.map(Tt=>s.jsxs("button",{type:"button",onClick:()=>{A(Tt.entity_id),fe(!1),ee("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${Tt.entity_id===N?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[s.jsx("div",{className:"font-medium",children:Tt.friendly_name}),s.jsxs("div",{className:"text-xs text-bambu-gray",children:[Tt.entity_id," • ",Tt.state," ",Tt.unit_of_measurement]})]},Tt.entity_id)),Yt.length===0&&s.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})()]})]})]}),i==="tasmota"&&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:c,onChange:xt=>{u(xt.target.value),Re(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(Me,{type:"button",variant:"secondary",onClick:()=>it.mutate(),disabled:!c.trim()||it.isPending,children:[it.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(Qp,{className:"w-4 h-4"}),"Test"]})]})]}),i==="tasmota"&&Se&&s.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${Se.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:Se.success?s.jsxs(s.Fragment,{children:[s.jsx(Hn,{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:[Se.device_name&&`Device: ${Se.device_name} - `,"State: ",Se.state]})]})]}):s.jsxs(s.Fragment,{children:[s.jsx(Yg,{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:o,onChange:xt=>l(xt.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"})]}),i==="tasmota"&&s.jsxs(s.Fragment,{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:"Username"}),s.jsx("input",{type:"text",value:d,onChange:xt=>f(xt.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:m,onChange:xt=>p(xt.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:Ne??"",onChange:xt=>ge(xt.target.value?Number(xt.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)"}),on?.map(xt=>s.jsx("option",{value:xt.id,children:xt.name},xt.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(vf,{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:G,onChange:xt=>ie(xt.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"})]})]}),G&&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:X,onChange:xt=>$(xt.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:I,onChange:xt=>ce(xt.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(Jn,{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:Ee,onChange:xt=>Ie(xt.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"})]})]}),Ee&&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:le,onChange:xt=>B(xt.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:xt=>Y(xt.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(oE,{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:pe,onChange:xt=>we(xt.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(Me,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(Me,{type:"submit",disabled:yn,className:"flex-1",children:[yn?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(bs,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function qn({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 AYe={callmebot:"CallMeBot/WhatsApp",ntfy:"ntfy",pushover:"Pushover",telegram:"Telegram",email:"Email",discord:"Discord",webhook:"Webhook"};function TYe({provider:t,onEdit:e}){const n=ln(),[r,i]=w.useState(!1),[a,o]=w.useState(!1),[l,c]=w.useState(null),{data:u}=ft({queryKey:["printers"],queryFn:me.getPrinters}),d=u?.find(v=>v.id===t.printer_id),f=pt({mutationFn:v=>me.updateNotificationProvider(t.id,v),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),m=pt({mutationFn:()=>me.deleteNotificationProvider(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),p=pt({mutationFn:()=>me.testNotificationProvider(t.id),onSuccess:v=>{c(v),n.invalidateQueries({queryKey:["notification-providers"]})},onError:v=>{c({success:!1,message:v.message})}}),b=v=>v||"";return s.jsxs(s.Fragment,{children:[s.jsx(Nt,{className:"relative",children:s.jsxs(Ct,{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(vf,{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:AYe[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-status-ok hidden sm:inline",children:["Last: ",xg(t.last_success)]}),t.last_error&&t.last_error_at&&(!t.last_success||(Si(t.last_error_at)?.getTime()||0)>(Si(t.last_success)?.getTime()||0))&&s.jsx("span",{className:"text-xs text-status-error",title:t.last_error,children:"Error"}),s.jsx(qn,{checked:t.enabled,onChange:v=>f.mutate({enabled:v})})]})]}),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_plate_not_empty&&s.jsx("span",{className:"px-2 py-0.5 bg-rose-600/20 text-rose-300 text-xs rounded",children:"Plate Check"}),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(Rw,{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(si,{className:"w-3 h-3"}),"Digest ",t.daily_digest_time]})]}),s.jsx("div",{className:"mb-3",children:s.jsxs(Me,{size:"sm",variant:"secondary",disabled:p.isPending,onClick:()=>{c(null),p.mutate()},className:"w-full",children:[p.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(zD,{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(Hn,{className:"w-4 h-4"}):s.jsx(za,{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(Kd,{className:"w-4 h-4"}),"Event Settings"]}),a?s.jsx(du,{className:"w-4 h-4"}):s.jsx(Oi,{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(qn,{checked:t.enabled,onChange:v=>f.mutate({enabled:v})})]}),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(qn,{checked:t.on_print_start,onChange:v=>f.mutate({on_print_start:v})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Plate Not Empty"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Objects detected before print"})]}),s.jsx(qn,{checked:t.on_plate_not_empty??!0,onChange:v=>f.mutate({on_plate_not_empty:v})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Print Completed"}),s.jsx(qn,{checked:t.on_print_complete,onChange:v=>f.mutate({on_print_complete:v})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Print Failed"}),s.jsx(qn,{checked:t.on_print_failed,onChange:v=>f.mutate({on_print_failed:v})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Print Stopped"}),s.jsx(qn,{checked:t.on_print_stopped,onChange:v=>f.mutate({on_print_stopped:v})})]}),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(qn,{checked:t.on_print_progress,onChange:v=>f.mutate({on_print_progress:v})})]})]}),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(qn,{checked:t.on_printer_offline,onChange:v=>f.mutate({on_printer_offline:v})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Printer Error"}),s.jsx(qn,{checked:t.on_printer_error,onChange:v=>f.mutate({on_printer_error:v})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Low Filament"}),s.jsx(qn,{checked:t.on_filament_low,onChange:v=>f.mutate({on_filament_low:v})})]}),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(qn,{checked:t.on_maintenance_due??!1,onChange:v=>f.mutate({on_maintenance_due:v})})]})]}),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(qn,{checked:t.on_ams_humidity_high??!1,onChange:v=>f.mutate({on_ams_humidity_high:v})})]}),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(qn,{checked:t.on_ams_temperature_high??!1,onChange:v=>f.mutate({on_ams_temperature_high:v})})]})]}),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(qn,{checked:t.on_ams_ht_humidity_high??!1,onChange:v=>f.mutate({on_ams_ht_humidity_high:v})})]}),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(qn,{checked:t.on_ams_ht_temperature_high??!1,onChange:v=>f.mutate({on_ams_ht_temperature_high:v})})]})]}),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(Rw,{className:"w-4 h-4 text-purple-400"}),s.jsx("p",{className:"text-sm text-white",children:"Quiet Hours"})]}),s.jsx(qn,{checked:t.quiet_hours_enabled,onChange:v=>f.mutate({quiet_hours_enabled:v})})]}),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(Jn,{className:"w-4 h-4 text-bambu-gray"}),s.jsxs("span",{className:"text-sm text-white",children:[b(t.quiet_hours_start)||"22:00"," - ",b(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(si,{className:"w-4 h-4 text-emerald-400"}),s.jsx("p",{className:"text-sm text-white",children:"Daily Digest"})]}),s.jsx(qn,{checked:t.daily_digest_enabled,onChange:v=>f.mutate({daily_digest_enabled:v})})]}),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(Jn,{className:"w-4 h-4 text-bambu-gray"}),s.jsxs("span",{className:"text-sm text-white",children:["Send at ",b(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(Me,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[s.jsx(cE,{className:"w-4 h-4"}),"Edit"]}),s.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:s.jsx(hn,{className:"w-4 h-4"})})]})]})]})}),r&&s.jsx(zn,{title:"Delete Notification Provider",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{m.mutate(),i(!1)},onCancel:()=>i(!1)})]})}const cq=[{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 CYe({provider:t,onClose:e}){const n=ln(),r=!!t,[i,a]=w.useState(t?.name||""),[o,l]=w.useState(t?.provider_type||"email"),[c,u]=w.useState(t?.printer_id||null),[d,f]=w.useState(t?.quiet_hours_enabled||!1),[m,p]=w.useState(t?.quiet_hours_start||"22:00"),[b,v]=w.useState(t?.quiet_hours_end||"07:00"),[x,y]=w.useState(t?.daily_digest_enabled||!1),[S,M]=w.useState(t?.daily_digest_time||"08:00"),[N,A]=w.useState(t?.on_print_start??!1),[k,C]=w.useState(t?.on_print_complete??!0),[D,T]=w.useState(t?.on_print_failed??!0),[R,U]=w.useState(t?.on_print_stopped??!0),[L,q]=w.useState(t?.on_print_progress??!1),[j,W]=w.useState(t?.on_printer_offline??!1),[K,V]=w.useState(t?.on_printer_error??!1),[J,ne]=w.useState(t?.on_filament_low??!1),[te,z]=w.useState(t?.on_maintenance_due??!1),[H,Z]=w.useState(t?.config?Object.fromEntries(Object.entries(t.config).map(([$,I])=>[$,String(I)])):{}),[ee,he]=w.useState(null),[fe,oe]=w.useState(null),{data:Ne}=ft({queryKey:["printers"],queryFn:me.getPrinters});w.useEffect(()=>{const $=I=>{I.key==="Escape"&&e()};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[e]);const ge=pt({mutationFn:()=>me.testNotificationConfig({provider_type:o,config:H}),onSuccess:$=>{he($),oe(null)},onError:$=>{he({success:!1,message:$.message})}}),Se=pt({mutationFn:$=>me.createNotificationProvider($),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:$=>{oe($.message)}}),Re=pt({mutationFn:$=>me.updateNotificationProvider(t.id,$),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:$=>{oe($.message)}}),de=$=>{if($.preventDefault(),oe(null),!i.trim()){oe("Name is required");return}const I=ie(o);for(const Ee of I)if(!H[Ee.key]?.trim()){oe(`${Ee.label} is required`);return}const ce={name:i.trim(),provider_type:o,config:H,printer_id:c,quiet_hours_enabled:d,quiet_hours_start:d?m:null,quiet_hours_end:d?b:null,daily_digest_enabled:x,daily_digest_time:x?S:null,on_print_start:N,on_print_complete:k,on_print_failed:D,on_print_stopped:R,on_print_progress:L,on_printer_offline:j,on_printer_error:K,on_filament_low:J,on_maintenance_due:te};r?Re.mutate(ce):Se.mutate(ce)},Qe=Se.isPending||Re.isPending,G=$=>{switch($){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:"payload_format",label:"Payload Format",type:"select",required:!1,options:[{value:"generic",label:"Generic JSON"},{value:"slack",label:"Slack / Mattermost"}]},{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,showIf:I=>I.payload_format!=="slack"},{key:"field_message",label:"Message Field Name",placeholder:"message",type:"text",required:!1,showIf:I=>I.payload_format!=="slack"}];default:return[]}},ie=$=>G($).filter(I=>I.required),X=G(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:$=>$.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(Gt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:de,className:"p-6 space-y-4",children:[fe&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:fe}),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:$=>a($.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:$=>{l($.target.value),Z({}),he(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:cq.map($=>s.jsx("option",{value:$.value,children:$.label},$.value))}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:cq.find($=>$.value===o)?.description})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Configuration"}),X.filter($=>!("showIf"in $)||$.showIf?.(H)!==!1).map($=>s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[$.label," ",$.required&&"*"]}),$.type==="select"&&"options"in $&&$.options?s.jsx("select",{value:H[$.key]||$.options[0]?.value||"",onChange:I=>{Z({...H,[$.key]:I.target.value}),he(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:$.options.map(I=>s.jsx("option",{value:I.value,children:I.label},I.value))}):s.jsx("input",{type:$.type,value:H[$.key]||"",onChange:I=>{Z({...H,[$.key]:I.target.value}),he(null)},placeholder:$.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"})]},$.key))]}),s.jsx("div",{className:"flex gap-2",children:s.jsxs(Me,{type:"button",variant:"secondary",onClick:()=>{he(null),ge.mutate()},disabled:ge.isPending||!H[ie(o)[0]?.key],className:"flex-1",children:[ge.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(zD,{className:"w-4 h-4"}),"Test Configuration"]})}),ee&&s.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${ee.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:ee.success?s.jsxs(s.Fragment,{children:[s.jsx(Hn,{className:"w-5 h-5"}),s.jsx("span",{children:ee.message})]}):s.jsxs(s.Fragment,{children:[s.jsx(za,{className:"w-5 h-5"}),s.jsx("span",{children:ee.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:$=>u($.target.value?Number($.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"}),Ne?.map($=>s.jsx("option",{value:$.id,children:$.name},$.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(qn,{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:m,onChange:$=>p($.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:b,onChange:$=>v($.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(qn,{checked:x,onChange:y})]}),x&&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:S,onChange:$=>M($.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(qn,{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(qn,{checked:k,onChange:C})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Failed"}),s.jsx(qn,{checked:D,onChange:T})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Stopped"}),s.jsx(qn,{checked:R,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(qn,{checked:L,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(qn,{checked:j,onChange:W})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Error"}),s.jsx(qn,{checked:K,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(qn,{checked:J,onChange:ne})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Maintenance"}),s.jsx(qn,{checked:te,onChange:z})]})]})]})]}),s.jsxs("div",{className:"flex gap-3 pt-2",children:[s.jsx(Me,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(Me,{type:"submit",disabled:Qe,className:"flex-1",children:[Qe?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(bs,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function kYe({template:t,onClose:e}){const n=ln(),r=w.useRef(null),[i,a]=w.useState(t.title_template),[o,l]=w.useState(t.body_template),[c,u]=w.useState(null),[d,f]=w.useState(!0),{data:m}=ft({queryKey:["template-variables"],queryFn:me.getTemplateVariables}),p=m?.find(A=>A.event_type===t.event_type),{data:b,isLoading:v}=ft({queryKey:["template-preview",t.event_type,i,o],queryFn:()=>me.previewTemplate({event_type:t.event_type,title_template:i,body_template:o}),enabled:d&&i.length>0&&o.length>0});w.useEffect(()=>{const A=k=>{k.key==="Escape"&&e()};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[e]);const x=pt({mutationFn:A=>me.updateNotificationTemplate(t.id,A),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-templates"]}),e()},onError:A=>{u(A.message)}}),y=pt({mutationFn:()=>me.resetNotificationTemplate(t.id),onSuccess:A=>{a(A.title_template),l(A.body_template),n.invalidateQueries({queryKey:["notification-templates"]})},onError:A=>{u(A.message)}}),S=A=>{if(A.preventDefault(),u(null),!i.trim()){u("Title is required");return}if(!o.trim()){u("Body is required");return}x.mutate({title_template:i,body_template:o})},M=A=>{const k=r.current;if(!k)return;const C=k.selectionStart,D=k.selectionEnd,T=o,R=T.substring(0,C),U=T.substring(D),L=R+`{${A}}`+U;l(L),setTimeout(()=>{k.focus();const q=C+A.length+2;k.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(Gt,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsxs("form",{onSubmit:S,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:()=>M(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(rr,{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(Ff,{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:v?s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-sm",children:[s.jsx(mt,{className:"w-4 h-4 animate-spin"}),"Loading preview..."]}):b?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:b.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:b.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(Me,{type:"button",variant:"ghost",onClick:()=>y.mutate(),disabled:y.isPending,className:"text-orange-400 hover:text-orange-300",children:[y.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin mr-2"}):s.jsx(lm,{className:"w-4 h-4 mr-2"}),"Reset to Default"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Me,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),s.jsxs(Me,{onClick:S,disabled:x.isPending||!N,children:[x.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin mr-2"}):s.jsx(bs,{className:"w-4 h-4 mr-2"}),"Save"]})]})]})]})})}const jYe={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"},PYe={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 RYe({onClose:t}){const e=ln(),{showToast:n}=Yn(),[r,i]=w.useState(7),[a,o]=w.useState(null),[l,c]=w.useState(!1),{data:u}=ft({queryKey:["settings"],queryFn:me.getSettings}),d=u?.time_format||"system",{data:f,isLoading:m,refetch:p,isRefetching:b}=ft({queryKey:["notification-logs",r,l],queryFn:()=>me.getNotificationLogs({days:r,limit:100,success:l?!1:void 0})}),{data:v}=ft({queryKey:["notification-log-stats",r],queryFn:()=>me.getNotificationLogStats(r)}),x=pt({mutationFn:()=>me.clearNotificationLogs(30),onSuccess:S=>{n(S.message,"success"),e.invalidateQueries({queryKey:["notification-logs"]}),e.invalidateQueries({queryKey:["notification-log-stats"]})},onError:S=>{n(`Failed to clear logs: ${S.message}`,"error")}}),y=S=>{const M=Si(S);if(!M)return"";const A=new Date().getTime()-M.getTime();return A<6e4?"Just now":A<36e5?`${Math.floor(A/6e4)}m ago`:A<864e5?`${Math.floor(A/36e5)}h ago`:M.toLocaleDateString()+" "+qme(M,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(Pw,{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:"×"})]}),v&&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:v.total})," notifications"]}),s.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[s.jsx(Hn,{className:"w-4 h-4"}),v.success_count," sent"]}),v.failure_count>0&&s.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[s.jsx(za,{className:"w-4 h-4"}),v.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:S=>i(Number(S.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:S=>c(S.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(Me,{size:"sm",variant:"secondary",onClick:()=>p(),disabled:b,children:[b?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(Ar,{className:"w-4 h-4"}),"Refresh"]}),s.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>x.mutate(),disabled:x.isPending,className:"text-red-400 hover:text-red-300",children:[x.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(hn,{className:"w-4 h-4"}),"Clear Old"]})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:m?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(mt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):f&&f.length>0?s.jsx("div",{className:"space-y-2",children:f.map(S=>s.jsx(DYe,{log:S,isExpanded:a===S.id,onToggle:()=>o(a===S.id?null:S.id),formatDate:y,formatFullDate:M=>bg(M,d)},S.id))}):s.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[s.jsx(Pw,{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 DYe({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(Hn,{className:"w-4 h-4 text-bambu-green shrink-0"}):s.jsx(za,{className:"w-4 h-4 text-red-400 shrink-0"}),s.jsx("span",{className:`text-xs font-medium ${PYe[t.event_type]||"text-bambu-gray"}`,children:jYe[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(du,{className:"w-4 h-4 text-bambu-gray shrink-0"}):s.jsx(Oi,{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 q1=[{id:"settings",labelKey:"backup.categories.settings",defaultLabel:"App Settings",icon:s.jsx(dE,{className:"w-4 h-4"}),default:!0,description:"Language, theme, update preferences"},{id:"notifications",labelKey:"backup.categories.notifications",defaultLabel:"Notification Providers",icon:s.jsx(vf,{className:"w-4 h-4"}),default:!0,description:"ntfy, Pushover, Discord, etc."},{id:"templates",labelKey:"backup.categories.templates",defaultLabel:"Notification Templates",icon:s.jsx(Ya,{className:"w-4 h-4"}),default:!0,description:"Custom message templates"},{id:"smart_plugs",labelKey:"backup.categories.smartPlugs",defaultLabel:"Smart Plugs",icon:s.jsx(Ws,{className:"w-4 h-4"}),default:!0,description:"Tasmota plug configurations"},{id:"external_links",labelKey:"backup.categories.externalLinks",defaultLabel:"External Links",icon:s.jsx(Xg,{className:"w-4 h-4"}),default:!0,description:"Sidebar links to external services"},{id:"printers",labelKey:"backup.categories.printers",defaultLabel:"Printers",icon:s.jsx(Wr,{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(FD,{className:"w-4 h-4"}),default:!1,description:"Filament types and costs"},{id:"maintenance",labelKey:"backup.categories.maintenance",defaultLabel:"Maintenance Types",icon:s.jsx(Xd,{className:"w-4 h-4"}),default:!1,description:"Custom maintenance schedules"},{id:"archives",labelKey:"backup.categories.archives",defaultLabel:"Print Archives",icon:s.jsx(Ja,{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(Ea,{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(fi,{className:"w-4 h-4"}),default:!1,description:"Virtual printer uploads awaiting review"},{id:"api_keys",labelKey:"backup.categories.apiKeys",defaultLabel:"API Keys",icon:s.jsx(lf,{className:"w-4 h-4"}),default:!1,description:"Webhook API keys (new keys generated on import)"}];function OYe({onClose:t,onExport:e}){const{t:n}=Gg(),[r,i]=w.useState(()=>{const b={};return q1.forEach(v=>{b[v.id]=v.default}),b}),[a,o]=w.useState(!1),[l,c]=w.useState(!1);w.useEffect(()=>{const b=v=>{v.key==="Escape"&&t()};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[t]);const u=b=>{i(v=>({...v,[b]:!v[b]}))},d=()=>{const b={};q1.forEach(v=>{b[v.id]=!0}),i(b)},f=()=>{const b={};q1.forEach(v=>{b[v.id]=!1}),i(b)},m=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(Nt,{className:"w-full max-w-lg",onClick:b=>b.stopPropagation(),children:s.jsxs(Ct,{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($r,{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(Gt,{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:q1.map(b=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg cursor-pointer transition-colors ${r[b.id]?"bg-bambu-green/10 border border-bambu-green/30":"bg-bambu-dark hover:bg-bambu-dark-tertiary border border-transparent"}`,children:[s.jsx("input",{type:"checkbox",checked:r[b.id],onChange:()=>u(b.id),disabled:l,className:"w-4 h-4 rounded border-bambu-gray bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0"}),s.jsx("div",{className:`${r[b.id]?"text-bambu-green":"text-bambu-gray"}`,children:b.icon}),s.jsxs("div",{className:"flex-1",children:[s.jsx("div",{className:"text-white text-sm font-medium",children:n(b.labelKey,{defaultValue:b.defaultLabel})}),s.jsx("div",{className:"text-xs text-bambu-gray",children:b.description})]})]},b.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(Ja,{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(lf,{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(qn,{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(Tn,{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:m,defaultValue:`${m} categories selected`})}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx(Me,{variant:"secondary",onClick:t,disabled:l,children:n("common.cancel",{defaultValue:"Cancel"})}),s.jsx(Me,{onClick:p,disabled:m===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(mt,{className:"w-4 h-4 mr-2 animate-spin"}),n("backup.exporting",{defaultValue:"Exporting..."})]}):s.jsxs(s.Fragment,{children:[s.jsx($r,{className:"w-4 h-4 mr-2"}),n("backup.export",{defaultValue:"Export"})]})})]})]})]})})})}const uq={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",api_keys:"API Keys"};function LYe({onClose:t,onRestore:e,onSuccess:n}){const[r,i]=w.useState("options"),[a,o]=w.useState(!1),[l,c]=w.useState(null),[u,d]=w.useState(null),[f,m]=w.useState(new Set),p=w.useRef(null);w.useEffect(()=>{const N=A=>{A.key==="Escape"&&r!=="restoring"&&(r==="result"&&u?.success&&n(),t())};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[t,n,r,u]);const b=N=>{const A=N.target.files?.[0];A&&c(A)},v=async()=>{if(l){i("restoring");try{const N=await e(l,a);d(N),i("result")}catch{d({success:!1,message:"Failed to restore backup. Please check the file format."}),i("result")}}},x=()=>{u?.success&&n(),t()},y=N=>{m(A=>{const k=new Set(A);return k.has(N)?k.delete(N):k.add(N),k})},S=u?.restored?Object.values(u.restored).reduce((N,A)=>N+A,0)+(u.files_restored||0):0,M=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:N=>{N.target===N.currentTarget&&r!=="restoring"&&t()},children:s.jsx(Nt,{className:"w-full max-w-lg",children:s.jsxs(Ct,{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(Hn,{className:"w-5 h-5"}):r==="result"&&!u?.success?s.jsx(Tn,{className:"w-5 h-5"}):s.jsx(fi,{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:x,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(Gt,{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:b}),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(Hn,{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(fi,{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(Tn,{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(Ar,{className:"w-4 h-4 text-orange-400"}):s.jsx(Ow,{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(qn,{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(Tn,{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(Me,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),s.jsxs(Me,{type:"button",onClick:v,disabled:!l,className:"bg-bambu-green hover:bg-bambu-green-dark disabled:opacity-50",children:[s.jsx(fi,{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(mt,{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:S}),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:M}),s.jsx("div",{className:"text-sm text-bambu-gray",children:"Items Skipped"})]})]}),u.restored&&Object.entries(u.restored).some(([,N])=>N>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(Hn,{className:"w-4 h-4 text-bambu-green"}),"Restored"]}),s.jsxs("div",{className:"space-y-1",children:[Object.entries(u.restored).filter(([,N])=>N>0).map(([N,A])=>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:uq[N]||N}),s.jsx("span",{className:"text-bambu-green font-medium",children:A})]},N)),(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(([,N])=>N>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(Ow,{className:"w-4 h-4 text-yellow-500"}),"Skipped (already exist)"]}),s.jsx("div",{className:"space-y-1",children:Object.entries(u.skipped).filter(([,N])=>N>0).map(([N,A])=>{const k=u.skipped_details?.[N]||[],C=f.has(N);return s.jsxs("div",{children:[s.jsxs("button",{onClick:()=>k.length>0&&y(N),className:`w-full flex items-center justify-between text-sm p-2 rounded bg-bambu-dark ${k.length>0?"hover:bg-bambu-dark-tertiary cursor-pointer":""}`,children:[s.jsxs("span",{className:"text-white flex items-center gap-2",children:[uq[N]||N,k.length>0&&(C?s.jsx(du,{className:"w-3 h-3"}):s.jsx(Oi,{className:"w-3 h-3"}))]}),s.jsx("span",{className:"text-yellow-500 font-medium",children:A})]}),C&&k.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:[k.slice(0,10).map((D,T)=>s.jsx("div",{children:D},T)),k.length>10&&s.jsxs("div",{className:"text-bambu-gray/60",children:["...and ",k.length-10," more"]})]})]},N)})})]}),u.new_api_keys&&u.new_api_keys.length>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(Tn,{className:"w-4 h-4 text-orange-500"}),"New API Keys Generated"]}),s.jsxs("div",{className:"p-3 rounded bg-orange-500/10 border border-orange-500/30",children:[s.jsx("p",{className:"text-xs text-orange-200 mb-2",children:"These keys are only shown once. Copy them now!"}),s.jsx("div",{className:"space-y-2",children:u.new_api_keys.map((N,A)=>s.jsxs("div",{className:"p-2 rounded bg-bambu-dark",children:[s.jsx("div",{className:"text-sm text-white font-medium mb-1",children:N.name}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("code",{className:"text-xs text-bambu-green bg-bambu-dark-tertiary px-2 py-1 rounded font-mono flex-1 break-all",children:N.key}),s.jsx("button",{onClick:()=>navigator.clipboard.writeText(N.key),className:"text-xs text-bambu-gray hover:text-white px-2 py-1 rounded bg-bambu-dark-tertiary",children:"Copy"})]})]},A))})]})]}),S===0&&M===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(Me,{onClick:x,children:"Close"})})]})]})})})}async function IYe(){const t=await fetch("/api/v1/settings/spoolman");if(!t.ok)throw new Error("Failed to load Spoolman settings");return t.json()}async function FYe(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 UYe(){const t=ln(),[e,n]=w.useState(!1),[r,i]=w.useState(""),[a,o]=w.useState("auto"),[l,c]=w.useState(!1),[u,d]=w.useState("all"),[f,m]=w.useState(!1),[p,b]=w.useState(!1),{data:v,isLoading:x}=ft({queryKey:["spoolman-settings"],queryFn:IYe}),{data:y,isLoading:S,refetch:M}=ft({queryKey:["spoolman-status"],queryFn:me.getSpoolmanStatus,refetchInterval:3e4}),{data:N}=ft({queryKey:["printers"],queryFn:me.getPrinters});w.useEffect(()=>{v&&(n(v.spoolman_enabled==="true"),i(v.spoolman_url||""),o(v.spoolman_sync_mode||"auto"),m(!0))},[v]),w.useEffect(()=>{if(!f||!v)return;if(v.spoolman_enabled==="true"!==e||(v.spoolman_url||"")!==r||(v.spoolman_sync_mode||"auto")!==a){const W=setTimeout(()=>{A.mutate()},500);return()=>clearTimeout(W)}},[e,r,a,f]);const A=pt({mutationFn:()=>FYe({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)}}),k=pt({mutationFn:me.connectSpoolman,onSuccess:()=>{M()}}),C=pt({mutationFn:me.disconnectSpoolman,onSuccess:()=>{M()}}),D=pt({mutationFn:me.syncAllPrintersAms,onSuccess:j=>{j.success}}),T=pt({mutationFn:j=>me.syncPrinterAms(j),onSuccess:j=>{j.success}}),R=()=>{u==="all"?D.mutate():T.mutate(u)},U=D.isPending||T.isPending,L=u==="all"?D.data:T.data,q=u==="all"?D.isSuccess:T.isSuccess;return x?s.jsxs(Nt,{children:[s.jsx(Er,{children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(mg,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]})}),s.jsx(Ct,{children:s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(mt,{className:"w-6 h-6 text-bambu-green animate-spin"})})})]}):s.jsxs(Nt,{children:[s.jsx(Er,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(mg,{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(mt,{className:"w-4 h-4 text-bambu-green animate-spin"}),l&&s.jsx(Es,{className:"w-4 h-4 text-bambu-green"})]})}),s.jsxs(Ct,{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(Zl,{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:j=>n(j.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:j=>i(j.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:j=>o(j.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:"}),S?s.jsx(mt,{className:"w-4 h-4 text-bambu-gray animate-spin"}):y?.connected?s.jsxs("span",{className:"flex items-center gap-1 text-sm text-green-500",children:[s.jsx(Es,{className:"w-4 h-4"}),"Connected"]}):s.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-500",children:[s.jsx(Gt,{className:"w-4 h-4"}),"Disconnected"]})]}),s.jsx("div",{className:"flex gap-2",children:y?.connected?s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>C.mutate(),disabled:C.isPending,children:[C.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(Dhe,{className:"w-4 h-4"}),"Disconnect"]}):s.jsxs(Me,{size:"sm",onClick:()=>k.mutate(),disabled:k.isPending||!r,children:[k.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(Gl,{className:"w-4 h-4"}),"Connect"]})})]}),k.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:k.error.message}),y?.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:j=>d(j.target.value==="all"?"all":Number(j.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(j=>s.jsx("option",{value:j.id,children:j.name},j.id))]}),s.jsx(Oi,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:R,disabled:U,children:[U?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(Ar,{className:"w-4 h-4"}),"Sync"]})]})]}),q&&L&&s.jsxs("div",{className:"mt-3 space-y-2",children:[s.jsx("div",{className:`p-2 rounded text-sm ${L.success?"bg-green-500/20 border border-green-500/50 text-green-400":"bg-yellow-500/20 border border-yellow-500/50 text-yellow-400"}`,children:L.success?`Synced ${L.synced_count} spool${L.synced_count!==1?"s":""} successfully`:`Synced ${L.synced_count} spool${L.synced_count!==1?"s":""} with ${L.errors.length} error${L.errors.length!==1?"s":""}`}),L.skipped_count>0&&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(Tn,{className:"w-3.5 h-3.5"}),s.jsxs("span",{className:"font-medium",children:[L.skipped_count," spool",L.skipped_count!==1?"s":""," skipped"]})]}),L.skipped_count>5&&s.jsx("button",{onClick:()=>b(!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?L.skipped:L.skipped.slice(0,5)).map((j,W)=>s.jsxs("li",{className:"flex items-center gap-2",children:[j.color&&s.jsx("span",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:`#${j.color}`}}),s.jsx("span",{children:j.location}),s.jsxs("span",{className:"text-amber-300/60",children:["- ",j.reason]})]},W)),!p&&L.skipped_count>5&&s.jsxs("li",{className:"text-amber-300/60 italic",children:["...and ",L.skipped_count-5," more"]})]})]}),L.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:L.errors.map((j,W)=>s.jsx("li",{children:j},W))})]})]})]})]})]})}function zYe({link:t,onClose:e}){const n=ln(),{mode:r}=oh(),i=!!t,a=w.useRef(null),[o,l]=w.useState(t?.name||""),[c,u]=w.useState(t?.url||""),[d,f]=w.useState(t?.icon||"link"),[m,p]=w.useState(!!t?.custom_icon),[b,v]=w.useState(t?.custom_icon?me.getExternalLinkIconUrl(t.id):null),[x,y]=w.useState(null),[S,M]=w.useState(null);w.useEffect(()=>{const U=L=>{L.key==="Escape"&&e()};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[e]);const N=pt({mutationFn:async U=>{const L=await me.createExternalLink(U);return x?await me.uploadExternalLinkIcon(L.id,x):L},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:U=>{M(U.message)}}),A=pt({mutationFn:async U=>{let L=await me.updateExternalLink(t.id,U);return x?L=await me.uploadExternalLinkIcon(t.id,x):!m&&t?.custom_icon&&(L=await me.deleteExternalLinkIcon(t.id)),L},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:U=>{M(U.message)}}),k=U=>{const L=U.target.files?.[0];if(L){if(!["image/png","image/jpeg","image/gif","image/svg+xml","image/webp","image/x-icon"].includes(L.type)){M("Please select a valid image file (PNG, JPG, GIF, SVG, WebP, or ICO)");return}if(L.size>1024*1024){M("Image file must be less than 1MB");return}y(L),p(!0);const j=new FileReader;j.onload=W=>{v(W.target?.result)},j.readAsDataURL(L)}},C=()=>{y(null),v(null),p(!1),a.current&&(a.current.value="")},D=U=>{if(U.preventDefault(),M(null),!o.trim()){M("Name is required");return}if(!c.trim()){M("URL is required");return}if(!c.startsWith("http://")&&!c.startsWith("https://")){M("URL must start with http:// or https://");return}const L={name:o.trim(),url:c.trim(),icon:d};i?A.mutate(L):N.mutate(L)},T=N.isPending||A.isPending,R=fE(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:m&&b?s.jsx("img",{src:b,alt:"",className:`w-5 h-5 rounded ${r==="dark"?"invert opacity-[0.65]":"opacity-60"}`}):s.jsx(R,{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(Gt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:D,className:"p-6 space-y-4",children:[S&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:S}),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:k}),m&&b?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("img",{src:b,alt:"Custom icon",className:`w-8 h-8 rounded border border-bambu-dark-tertiary ${r==="dark"?"invert opacity-[0.65]":"opacity-60"}`}),s.jsx("button",{type:"button",onClick:C,className:"p-1 text-red-400 hover:text-red-300 transition-colors",title:"Remove custom icon",children:s.jsx(hn,{className:"w-4 h-4"})})]}):s.jsxs(Me,{type:"button",variant:"secondary",size:"sm",onClick:()=>a.current?.click(),children:[s.jsx(fi,{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."})]}),!m&&s.jsxs("div",{children:[s.jsx("span",{className:"text-sm text-bambu-gray block mb-2",children:"Or choose a preset icon"}),s.jsx(Bme,{value:d,onChange:f})]})]}),s.jsxs("div",{className:"flex gap-3 pt-2",children:[s.jsx(Me,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(Me,{type:"submit",disabled:T,className:"flex-1",children:[T?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(bs,{className:"w-4 h-4"}),i?"Save":"Add"]})]})]})]})})}function BYe(){const t=ln(),[e,n]=w.useState(!1),[r,i]=w.useState(null),[a,o]=w.useState(null),[l,c]=w.useState(null),{data:u,isLoading:d}=ft({queryKey:["external-links"],queryFn:me.getExternalLinks}),f=pt({mutationFn:S=>me.deleteExternalLink(S),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),m=pt({mutationFn:S=>me.reorderExternalLinks(S),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),p=(S,M)=>{c(M),S.dataTransfer.effectAllowed="move"},b=S=>{S.preventDefault(),S.dataTransfer.dropEffect="move"},v=(S,M)=>{if(S.preventDefault(),l===null||l===M||!u)return;const N=u.map(D=>D.id),A=N.indexOf(l),k=N.indexOf(M);if(A===-1||k===-1)return;const C=[...N];C.splice(A,1),C.splice(k,0,l),m.mutate(C),c(null)},x=S=>{o(S)},y=()=>{a&&(f.mutate(a.id),o(null))};return s.jsxs(s.Fragment,{children:[s.jsxs(Nt,{children:[s.jsx(Er,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Gl,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Sidebar Links"})]}),s.jsxs(Me,{size:"sm",onClick:()=>n(!0),children:[s.jsx(rr,{className:"w-4 h-4"}),"Add Link"]})]})}),s.jsxs(Ct,{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(mt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):u&&u.length>0?s.jsx("div",{className:"space-y-2",children:u.map(S=>{const M=fE(S.icon);return s.jsxs("div",{draggable:!0,onDragStart:N=>p(N,S.id),onDragOver:b,onDrop:N=>v(N,S.id),className:`flex items-center gap-3 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary transition-colors ${l===S.id?"opacity-50":""}`,children:[s.jsx(pg,{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(M,{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:S.name}),s.jsx(Gr,{className:"w-3 h-3 text-bambu-gray flex-shrink-0"})]}),s.jsx("span",{className:"text-sm text-bambu-gray truncate block",children:S.url})]}),s.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[s.jsx("button",{onClick:()=>i(S),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors",title:"Edit",children:s.jsx(Na,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>x(S),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(hn,{className:"w-4 h-4"})})]})]},S.id)})}):s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx(Gl,{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(zYe,{link:r,onClose:()=>{n(!1),i(null)}}),a&&s.jsx(zn,{title:"Delete Link",message:`Are you sure you want to delete "${a.name}"? This action cannot be undone.`,confirmText:"Delete",cancelText:"Cancel",variant:"danger",onConfirm:y,onCancel:()=>o(null)})]})}function $Ye(){const t=ln(),{showToast:e}=Yn(),[n,r]=w.useState(!1),[i,a]=w.useState(""),[o,l]=w.useState("immediate"),[c,u]=w.useState("3DPrinter-X1-Carbon"),[d,f]=w.useState(!1),[m,p]=w.useState(null),{data:b,isLoading:v}=ft({queryKey:["virtual-printer-settings"],queryFn:Z1.getSettings,refetchInterval:1e4}),{data:x}=ft({queryKey:["virtual-printer-models"],queryFn:Z1.getModels});w.useEffect(()=>{if(b){r(b.enabled);let D=b.mode==="queue"?"review":b.mode;D!=="immediate"&&D!=="review"&&D!=="print_queue"&&(D="immediate"),l(D),u(b.model)}},[b]);const y=pt({mutationFn:D=>Z1.updateSettings(D),onSuccess:()=>{t.invalidateQueries({queryKey:["virtual-printer-settings"]}),e("Virtual printer settings updated"),p(null)},onError:D=>{if(e(D.message||"Failed to update settings","error"),b){r(b.enabled);const T=b.mode==="queue"?"review":b.mode;l(T==="print_queue"||T==="review"?T:"immediate"),u(b.model)}p(null)}}),S=()=>{const D=!n;if(D&&!i&&!b?.access_code_set){e("Please set an access code first","error");return}r(D),p("toggle"),y.mutate({enabled:D,access_code:i||void 0,mode:o})},M=()=>{if(!i){e("Access code cannot be empty","error");return}if(i.length!==8){e("Access code must be exactly 8 characters","error");return}p("accessCode"),y.mutate({access_code:i}),a("")},N=D=>{l(D),p("mode"),y.mutate({mode:D})},A=D=>{u(D),p("model"),y.mutate({model:D})};if(v)return s.jsx(Nt,{children:s.jsx(Ct,{className:"py-8 flex justify-center",children:s.jsx(mt,{className:"w-6 h-6 animate-spin text-bambu-green"})})});const k=b?.status,C=k?.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(Nt,{children:[s.jsx(Er,{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-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Virtual Printer"})]}),k&&s.jsxs("div",{className:`flex items-center gap-2 text-sm ${C?"text-green-400":"text-bambu-gray"}`,children:[s.jsx("span",{className:`w-2 h-2 rounded-full ${C?"bg-green-400 animate-pulse":"bg-gray-500"}`}),C?"Running":"Stopped"]})]})}),s.jsxs(Ct,{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:C?'Visible as "Bambuddy" in slicer discovery':"Not visible to slicers"})]}),s.jsx("button",{onClick:S,disabled:m==="toggle",className:`relative w-12 h-6 rounded-full transition-colors ${n?"bg-bambu-green":"bg-bambu-dark-tertiary"} ${m==="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:D=>A(D.target.value),disabled:m==="model",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white appearance-none cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed pr-10",children:x?.models&&Object.entries(x.models).sort(([,D],[,T])=>D.localeCompare(T)).map(([D,T])=>s.jsx("option",{value:D,children:T},D))}),s.jsx(Oi,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),n&&C&&s.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:[s.jsx(Zl,{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:b?.access_code_set?s.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[s.jsx(Es,{className:"w-4 h-4"}),"Access code is set"]}):s.jsxs("span",{className:"flex items-center gap-1 text-yellow-400",children:[s.jsx(Tn,{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:D=>a(D.target.value),placeholder:b?.access_code_set?"Enter new code to change":"Enter 8-char code",maxLength:8,className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white placeholder-bambu-gray pr-10 font-mono"}),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(tE,{className:"w-4 h-4"}):s.jsx(Ff,{className:"w-4 h-4"})})]}),s.jsx(Me,{onClick:M,disabled:!i||m==="accessCode",variant:"primary",children:m==="accessCode"?s.jsx(mt,{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:"Mode"}),s.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[s.jsxs("button",{onClick:()=>N("immediate"),disabled:m==="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:"Archive"}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Archive files immediately"})]}),s.jsxs("button",{onClick:()=>N("review"),disabled:m==="mode",className:`p-3 rounded-lg border text-left transition-colors ${o==="review"?"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:"Review"}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Review and tag before archiving"})]}),s.jsxs("button",{onClick:()=>N("print_queue"),disabled:m==="mode",className:`p-3 rounded-lg border text-left transition-colors ${o==="print_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"}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Archive and add to print queue"})]})]})]})]})]})}),s.jsxs("div",{className:"space-y-6 lg:w-[480px] lg:flex-shrink-0",children:[s.jsx(Nt,{className:"border-l-4 border-l-yellow-500",children:s.jsx(Ct,{className:"py-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Tn,{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(Gr,{className:"w-4 h-4"}),"Read the setup guide before enabling"]})]})]})})}),s.jsx(Nt,{children:s.jsx(Ct,{className:"py-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Zl,{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'})]})]})]})})}),k&&C&&s.jsxs(Nt,{children:[s.jsx(Er,{children:s.jsx("h3",{className:"text-md font-semibold text-white",children:"Status Details"})}),s.jsx(Ct,{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:k.name})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:"Model"}),s.jsx("div",{className:"text-white",children:k.model_name||k.model})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:"Serial Number"}),s.jsx("div",{className:"text-white font-mono",children:k.serial})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:"Mode"}),s.jsx("div",{className:"text-white capitalize",children:k.mode})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:"Pending Files"}),s.jsx("div",{className:"text-white",children:k.pending_files})]})]})})]})]})]})}const HYe={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 VYe(t,e){const n=e.replace("#/","").split("/");let r=t;for(const i of n)r=r[i];return r}function Zb(t,e,n=0){if(n>5)return"...";if(e.$ref)return Zb(t,VYe(t,e.$ref),n+1);if(e.allOf){const r={};for(const i of e.allOf){const a=Zb(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?[Zb(t,e.items,n+1)]:[];case"object":if(e.properties){const r={};for(const[i,a]of Object.entries(e.properties))r[i]=Zb(t,a,n+1);return r}return{};default:return null}}function GYe({path:t,method:e,spec:n,schema:r,apiKey:i}){const[a,o]=w.useState(!1),[l,c]=w.useState({}),[u,d]=w.useState(""),[f,m]=w.useState(null),[p,b]=w.useState(!1),[v,x]=w.useState(!1);w.useEffect(()=>{if(a&&n.parameters){const D={};for(const T of n.parameters)T.schema?.default!==void 0&&(D[T.name]=String(T.schema.default));c(T=>({...D,...T}))}},[a,n.parameters]),w.useEffect(()=>{if(a&&n.requestBody?.content?.["application/json"]?.schema&&!u){const D=n.requestBody.content["application/json"].schema,T=Zb(r,D);d(JSON.stringify(T,null,2))}},[a,n.requestBody,r,u]);const S=(()=>{const D=[];for(const T of n.parameters||[])if(T.in==="path"||T.required){const R=l[T.name];(R===void 0||R==="")&&D.push(T.name)}return D})(),M=async()=>{if(S.length>0){m({status:0,statusText:"Validation Error",headers:{},body:`Missing required parameters: ${S.join(", ")}`,duration:0});return}b(!0),m(null);try{let D=t;const T=new URLSearchParams;for(const te of n.parameters||[]){const z=l[te.name];z!==void 0&&z!==""&&(te.in==="path"?D=D.replace(`{${te.name}}`,encodeURIComponent(z)):te.in==="query"&&T.append(te.name,z))}const R=T.toString(),U=`${D}${R?`?${R}`:""}`,L={"Content-Type":"application/json"};i&&(L["X-API-Key"]=i);const q={method:e.toUpperCase(),headers:L};["post","put","patch"].includes(e)&&u&&(q.body=u);const j=performance.now(),W=await fetch(U,q),K=Math.round(performance.now()-j),V={};W.headers.forEach((te,z)=>{V[z]=te});let J;W.headers.get("content-type")?.includes("application/json")?J=await W.json():J=await W.text(),m({status:W.status,statusText:W.statusText,headers:V,body:J,duration:K})}catch(D){m({status:0,statusText:"Network Error",headers:{},body:D instanceof Error?D.message:"Unknown error",duration:0})}finally{b(!1)}},N=async()=>{if(f){const D=typeof f.body=="string"?f.body:JSON.stringify(f.body,null,2);try{await navigator.clipboard.writeText(D),x(!0),setTimeout(()=>x(!1),2e3)}catch{const T=document.createElement("textarea");T.value=D,T.style.position="fixed",T.style.left="-999999px",document.body.appendChild(T),T.select(),document.execCommand("copy"),document.body.removeChild(T),x(!0),setTimeout(()=>x(!1),2e3)}}},A=(n.parameters||[]).filter(D=>D.in==="path"),k=(n.parameters||[]).filter(D=>D.in==="query"),C=["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(Oi,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}):s.jsx(Zs,{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 ${HYe[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(D=>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:[D.name,D.required&&s.jsx("span",{className:"text-red-400 ml-1",children:"*"})]}),s.jsx("input",{type:"text",value:l[D.name]||"",onChange:T=>c(R=>({...R,[D.name]:T.target.value})),placeholder:D.description||D.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"})]},D.name))})]}),k.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:k.map(D=>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:[D.name,D.required&&s.jsx("span",{className:"text-red-400 ml-1",children:"*"})]}),D.schema?.enum?s.jsxs("select",{value:l[D.name]||"",onChange:T=>c(R=>({...R,[D.name]:T.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 --"}),D.schema.enum.map(T=>s.jsx("option",{value:T,children:T},T))]}):s.jsx("input",{type:"text",value:l[D.name]||"",onChange:T=>c(R=>({...R,[D.name]:T.target.value})),placeholder:D.description||D.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"})]},D.name))})]}),C&&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:D=>d(D.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(Me,{onClick:M,disabled:p,children:[p?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(ol,{className:"w-4 h-4"}),"Execute"]}),S.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: ",S.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(Me,{variant:"secondary",size:"sm",onClick:N,children:v?s.jsx(Hn,{className:"w-3 h-3 text-green-400"}):s.jsx(il,{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 WYe({apiKey:t=""}){const[e,n]=w.useState(null),[r,i]=w.useState(!0),[a,o]=w.useState(null),[l,c]=w.useState(new Set),[u,d]=w.useState("");if(w.useEffect(()=>{async function x(){try{const y=await fetch("/openapi.json");if(!y.ok)throw new Error("Failed to fetch OpenAPI schema");const S=await y.json();n(S)}catch(y){o(y instanceof Error?y.message:"Unknown error")}finally{i(!1)}}x()},[]),r)return s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(mt,{className:"w-8 h-8 text-bambu-green animate-spin"})});if(a||!e)return s.jsx(Nt,{children:s.jsx(Ct,{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[x,y]of Object.entries(e.paths))for(const[S,M]of Object.entries(y)){if(S==="parameters")continue;const N=M.tags||["Other"];for(const A of N)f[A]||(f[A]=[]),f[A].push({path:x,method:S,spec:M})}const m=Object.entries(f).map(([x,y])=>{if(!u)return{tag:x,endpoints:y};const S=y.filter(({path:M,method:N,spec:A})=>{const k=u.toLowerCase();return M.toLowerCase().includes(k)||N.toLowerCase().includes(k)||(A.summary?.toLowerCase()||"").includes(k)||(A.description?.toLowerCase()||"").includes(k)});return{tag:x,endpoints:S}}).filter(({endpoints:x})=>x.length>0).sort((x,y)=>x.tag.localeCompare(y.tag)),p=x=>{c(y=>{const S=new Set(y);return S.has(x)?S.delete(x):S.add(x),S})},b=()=>{c(new Set(m.map(x=>x.tag)))},v=()=>{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:x=>d(x.target.value),placeholder:"Search endpoints...",className:"w-full max-w-md px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Me,{variant:"secondary",size:"sm",onClick:b,children:"Expand All"}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:v,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(Gr,{className:"w-4 h-4"}),"Swagger UI"]})]})]}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:[m.reduce((x,y)=>x+y.endpoints.length,0)," endpoints in ",m.length," categories"]}),s.jsx("div",{className:"space-y-3",children:m.map(({tag:x,endpoints:y})=>s.jsxs(Nt,{children:[s.jsx("button",{onClick:()=>p(x),className:"w-full flex items-center justify-between p-4 hover:bg-bambu-dark-tertiary/30 transition-colors text-left",children:s.jsxs("div",{className:"flex items-center gap-2",children:[l.has(x)?s.jsx(Oi,{className:"w-5 h-5 text-bambu-gray"}):s.jsx(Zs,{className:"w-5 h-5 text-bambu-gray"}),s.jsx("h3",{className:"text-base font-semibold text-white capitalize",children:x.replace(/-/g," ")}),s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-2 py-0.5 rounded-full text-bambu-gray",children:y.length})]})}),l.has(x)&&s.jsx(Ct,{className:"pt-0 space-y-2",children:y.map(({path:S,method:M,spec:N})=>s.jsx(GYe,{path:S,method:M,spec:N,schema:e,apiKey:t},`${M}-${S}`))})]},x))})]})}const qYe=["general","network","plugs","notifications","filament","apikeys","virtual-printer","users"];function KYe(){const t=ln(),e=pl(),[n,r]=Hq(),{t:i,i18n:a}=Gg(),{showToast:o,showPersistentToast:l,dismissToast:c}=Yn(),{authEnabled:u,user:d,refreshAuth:f}=lh(),{mode:m,darkStyle:p,darkBackground:b,darkAccent:v,lightStyle:x,lightBackground:y,lightAccent:S,setDarkStyle:M,setDarkBackground:N,setDarkAccent:A,setLightStyle:k,setLightBackground:C,setLightAccent:D}=oh(),[T,R]=w.useState(null),[U,L]=w.useState(!1),[q,j]=w.useState(null),[W,K]=w.useState(!1),[V,J]=w.useState(null),[ne,te]=w.useState(null),[z,H]=w.useState(!1),[Z,ee]=w.useState(kK()),he=n.get("tab"),fe=he&&qYe.includes(he)?he:"general",[oe,Ne]=w.useState(fe),ge=be=>{Ne(be),be==="general"?n.delete("tab"):n.set("tab",be),r(n,{replace:!0})},[Se,Re]=w.useState(!1),[de,Qe]=w.useState(""),[G,ie]=w.useState({can_queue:!0,can_control_printer:!1,can_read_status:!0}),[X,$]=w.useState(null),[I,ce]=w.useState(null),[Ee,Ie]=w.useState(""),[le,B]=w.useState(!1),[O,Y]=w.useState(!1),[pe,we]=w.useState(null),[ae,ke]=w.useState(!1),[De,Ke]=w.useState(!1),[et,Ye]=w.useState(!1),[se,ye]=w.useState(!1),[Ce,Ue]=w.useState(null),[dt,re]=w.useState(!1),[Fe,ve]=w.useState({}),[$e,Le]=w.useState({}),Ae=be=>{ee(be),Gme(be)},Ge=()=>{localStorage.removeItem("sidebarOrder"),window.location.reload()},{data:it,isLoading:Ot}=ft({queryKey:["settings"],queryFn:me.getSettings}),{data:kt,isLoading:on}=ft({queryKey:["smart-plugs"],queryFn:me.getSmartPlugs}),{data:Ut,isLoading:yn}=ft({queryKey:["smart-plugs-energy",kt?.map(be=>be.id)],queryFn:async()=>{if(!kt||kt.length===0)return null;const be=await Promise.all(kt.filter(cn=>cn.enabled).map(async cn=>{try{const ki=await me.getSmartPlugStatus(cn.id);return{plug:cn,status:ki}}catch{return{plug:cn,status:null}}}));let ut=0,It=0,yt=0,Xt=0,tr=0;for(const{status:cn}of be)cn?.reachable&&cn.energy&&(tr++,cn.energy.power!=null&&(ut+=cn.energy.power),cn.energy.today!=null&&(It+=cn.energy.today),cn.energy.yesterday!=null&&(yt+=cn.energy.yesterday),cn.energy.total!=null&&(Xt+=cn.energy.total));return{totalPower:ut,totalToday:It,totalYesterday:yt,totalLifetime:Xt,reachableCount:tr,totalPlugs:kt.filter(cn=>cn.enabled).length}},enabled:oe==="plugs"&&!!kt&&kt.length>0,refetchInterval:oe==="plugs"?1e4:!1}),{data:xt,isLoading:Yt}=ft({queryKey:["notification-providers"],queryFn:me.getNotificationProviders}),{data:sn,isLoading:Tt}=ft({queryKey:["api-keys"],queryFn:me.getAPIKeys}),Cn=pt({mutationFn:be=>me.createAPIKey(be),onSuccess:be=>{$(be.key||null),Re(!1),Qe(""),t.invalidateQueries({queryKey:["api-keys"]}),o("API key created")},onError:be=>{o(`Failed to create API key: ${be.message}`,"error")}}),Cr=pt({mutationFn:be=>me.deleteAPIKey(be),onSuccess:()=>{t.invalidateQueries({queryKey:["api-keys"]}),o("API key deleted")},onError:be=>{o(`Failed to delete API key: ${be.message}`,"error")}}),{data:er}=ft({queryKey:["printers"],queryFn:me.getPrinters}),{data:Un,isLoading:yr}=ft({queryKey:["notification-templates"],queryFn:me.getNotificationTemplates}),{data:Ci}=ft({queryKey:["virtual-printer-settings"],queryFn:Z1.getSettings,refetchInterval:1e4}),gi=Ci?.status?.running??!1,{data:_e}=ft({queryKey:["ffmpeg-status"],queryFn:me.checkFfmpeg}),{data:Je}=ft({queryKey:["version"],queryFn:me.getVersion}),{data:Ze,refetch:lt,isRefetching:st}=ft({queryKey:["updateCheck"],queryFn:me.checkForUpdates,staleTime:300*1e3}),{data:Pt,refetch:Bt}=ft({queryKey:["updateStatus"],queryFn:me.getUpdateStatus,refetchInterval:be=>{const ut=be.state.data;return ut?.status==="downloading"||ut?.status==="installing"?1e3:!1}}),{data:Ht}=ft({queryKey:["mqtt-status"],queryFn:me.getMQTTStatus,refetchInterval:oe==="network"?5e3:!1}),Jt=pt({mutationFn:me.applyUpdate,onSuccess:be=>{be.is_docker?o(be.message,"error"):Bt()}}),[ue,je]=w.useState(null),Ve=pt({mutationFn:me.testAllNotificationProviders,onSuccess:be=>{je(be),t.invalidateQueries({queryKey:["notification-providers"]}),be.failed===0?o(`All ${be.tested} providers tested successfully!`,"success"):o(`${be.success}/${be.tested} providers succeeded`,be.failed>0?"error":"success")},onError:be=>{o(`Failed to test providers: ${be.message}`,"error")}}),We=pt({mutationFn:async be=>{if(!kt)return{success:0,failed:0};const ut=kt.filter(yt=>yt.enabled),It=await Promise.all(ut.map(async yt=>{try{return await me.controlSmartPlug(yt.id,be),{success:!0}}catch{return{success:!1}}}));return{success:It.filter(yt=>yt.success).length,failed:It.filter(yt=>!yt.success).length}},onSuccess:(be,ut)=>{t.invalidateQueries({queryKey:["smart-plugs"]}),t.invalidateQueries({queryKey:["smart-plugs-energy"]}),be.failed===0?o(`All ${be.success} plugs turned ${ut}`,"success"):o(`${be.success} plugs turned ${ut}, ${be.failed} failed`,"error")},onError:be=>{o(`Failed: ${be.message}`,"error")}}),He=w.useRef(null),wt=w.useRef(!1),Dt=w.useRef(!0);w.useEffect(()=>{if(it&&!T){const be={...it,external_url:it.external_url||window.location.origin};R(be),setTimeout(()=>{Dt.current=!1},100)}},[it,T]);const Et=pt({mutationFn:me.updateSettings,onSuccess:be=>{t.setQueryData(["settings"],be),R(be),t.invalidateQueries({queryKey:["archiveStats"]}),o("Settings saved","success")},onError:be=>{o(`Failed to save: ${be.message}`,"error")},onSettled:()=>{wt.current=!1}}),St=pt({mutationFn:({id:be,data:ut})=>me.updatePrinter(be,ut),onSuccess:()=>{t.invalidateQueries({queryKey:["printers"]}),o("Camera settings saved","success")},onError:be=>{o(`Failed to update printer: ${be.message}`,"error")}});w.useEffect(()=>{if(!(Dt.current||!T||!it||!(it.auto_archive!==T.auto_archive||it.save_thumbnails!==T.save_thumbnails||it.capture_finish_photo!==T.capture_finish_photo||it.default_filament_cost!==T.default_filament_cost||it.currency!==T.currency||it.energy_cost_per_kwh!==T.energy_cost_per_kwh||it.energy_tracking_mode!==T.energy_tracking_mode||it.check_updates!==T.check_updates||it.notification_language!==T.notification_language||it.ams_humidity_good!==T.ams_humidity_good||it.ams_humidity_fair!==T.ams_humidity_fair||it.ams_temp_good!==T.ams_temp_good||it.ams_temp_fair!==T.ams_temp_fair||it.ams_history_retention_days!==T.ams_history_retention_days||it.per_printer_mapping_expanded!==T.per_printer_mapping_expanded||it.date_format!==T.date_format||it.time_format!==T.time_format||it.default_printer_id!==T.default_printer_id||it.ftp_retry_enabled!==T.ftp_retry_enabled||it.ftp_retry_count!==T.ftp_retry_count||it.ftp_retry_delay!==T.ftp_retry_delay||it.ftp_timeout!==T.ftp_timeout||it.mqtt_enabled!==T.mqtt_enabled||it.mqtt_broker!==T.mqtt_broker||it.mqtt_port!==T.mqtt_port||it.mqtt_username!==T.mqtt_username||it.mqtt_password!==T.mqtt_password||it.mqtt_topic_prefix!==T.mqtt_topic_prefix||it.mqtt_use_tls!==T.mqtt_use_tls||it.external_url!==T.external_url||it.ha_enabled!==T.ha_enabled||it.ha_url!==T.ha_url||it.ha_token!==T.ha_token||(it.library_archive_mode??"ask")!==(T.library_archive_mode??"ask")||Number(it.library_disk_warning_gb??5)!==Number(T.library_disk_warning_gb??5)||(it.camera_view_mode??"window")!==(T.camera_view_mode??"window")))&&!wt.current)return He.current&&clearTimeout(He.current),He.current=setTimeout(()=>{if(wt.current)return;wt.current=!0;const ut={auto_archive:T.auto_archive,save_thumbnails:T.save_thumbnails,capture_finish_photo:T.capture_finish_photo,default_filament_cost:T.default_filament_cost,currency:T.currency,energy_cost_per_kwh:T.energy_cost_per_kwh,energy_tracking_mode:T.energy_tracking_mode,check_updates:T.check_updates,notification_language:T.notification_language,ams_humidity_good:T.ams_humidity_good,ams_humidity_fair:T.ams_humidity_fair,ams_temp_good:T.ams_temp_good,ams_temp_fair:T.ams_temp_fair,ams_history_retention_days:T.ams_history_retention_days,per_printer_mapping_expanded:T.per_printer_mapping_expanded,date_format:T.date_format,time_format:T.time_format,default_printer_id:T.default_printer_id,ftp_retry_enabled:T.ftp_retry_enabled,ftp_retry_count:T.ftp_retry_count,ftp_retry_delay:T.ftp_retry_delay,ftp_timeout:T.ftp_timeout,mqtt_enabled:T.mqtt_enabled,mqtt_broker:T.mqtt_broker,mqtt_port:T.mqtt_port,mqtt_username:T.mqtt_username,mqtt_password:T.mqtt_password,mqtt_topic_prefix:T.mqtt_topic_prefix,mqtt_use_tls:T.mqtt_use_tls,external_url:T.external_url,ha_enabled:T.ha_enabled,ha_url:T.ha_url,ha_token:T.ha_token,library_archive_mode:T.library_archive_mode,library_disk_warning_gb:T.library_disk_warning_gb,camera_view_mode:T.camera_view_mode};Et.mutate(ut)},500),()=>{He.current&&clearTimeout(He.current)}},[T,it,Et]);const Mt=w.useCallback((be,ut)=>{R(It=>It?{...It,[be]:ut}:null)},[]),Oe=async(be,ut,It)=>{if(!ut){o("Please enter a camera URL","error");return}Le(yt=>({...yt,[be]:!0})),ve(yt=>({...yt,[be]:null}));try{const yt=await me.testExternalCamera(be,ut,It);ve(Xt=>({...Xt,[be]:yt})),yt.success?o(`Camera connected${yt.resolution?` (${yt.resolution})`:""}`,"success"):o(yt.error||"Connection failed","error")}catch(yt){const Xt=yt instanceof Error?yt.message:"Test failed";ve(tr=>({...tr,[be]:{success:!1,error:Xt}})),o(Xt,"error")}finally{Le(yt=>({...yt,[be]:!1}))}},[gt,Rt]=w.useState({}),ct=w.useRef({});w.useEffect(()=>{if(er){const be={};er.forEach(ut=>{ut.external_camera_url&&gt[ut.id]===void 0&&(be[ut.id]=ut.external_camera_url)}),Object.keys(be).length>0&&Rt(ut=>({...ut,...be}))}},[er]);const Zt=(be,ut)=>{Rt(It=>({...It,[be]:ut})),ct.current[be]&&clearTimeout(ct.current[be]),ct.current[be]=setTimeout(()=>{St.mutate({id:be,data:{external_camera_url:ut||null}})},800)},Kt=(be,ut)=>{const It={};ut.type!==void 0&&(It.external_camera_type=ut.type||null),ut.enabled!==void 0&&(It.external_camera_enabled=ut.enabled),St.mutate({id:be,data:It})};return Ot||!T?s.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:s.jsx(mt,{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 overflow-x-auto",children:[s.jsx("button",{onClick:()=>ge("general"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${oe==="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:()=>ge("plugs"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${oe==="plugs"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Ws,{className:"w-4 h-4"}),"Smart Plugs",kt&&kt.length>0&&s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:kt.length})]}),s.jsxs("button",{onClick:()=>ge("notifications"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${oe==="notifications"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(vf,{className:"w-4 h-4"}),"Notifications",xt&&xt.length>0&&s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:xt.length})]}),s.jsxs("button",{onClick:()=>ge("filament"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${oe==="filament"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(kde,{className:"w-4 h-4"}),"Filament"]}),s.jsxs("button",{onClick:()=>ge("network"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${oe==="network"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Qp,{className:"w-4 h-4"}),"Network",s.jsx("span",{className:`w-2 h-2 rounded-full ${Ht?.enabled?"bg-green-400":"bg-gray-500"}`})]}),s.jsxs("button",{onClick:()=>ge("apikeys"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${oe==="apikeys"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(lf,{className:"w-4 h-4"}),"API Keys",sn&&sn.length>0&&s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:sn.length})]}),s.jsxs("button",{onClick:()=>ge("virtual-printer"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${oe==="virtual-printer"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Wr,{className:"w-4 h-4"}),"Virtual Printer",s.jsx("span",{className:`w-2 h-2 rounded-full ${gi?"bg-green-400":"bg-gray-500"}`})]}),s.jsxs("button",{onClick:()=>ge("users"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${oe==="users"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(cf,{className:"w-4 h-4"}),"Users",u&&s.jsx("span",{className:`w-2 h-2 rounded-full ${u?"bg-green-400":"bg-gray-500"}`})]})]}),oe==="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(Nt,{children:[s.jsx(Er,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.general")})}),s.jsxs(Ct,{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(Fd,{className:"w-4 h-4 inline mr-1"}),i("settings.language")]}),s.jsx("select",{value:a.language,onChange:be=>a.changeLanguage(be.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:Nz.map(be=>s.jsxs("option",{value:be.code,children:[be.nativeName," (",be.name,")"]},be.code))}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("settings.languageDescription")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:i("settings.defaultView")}),s.jsx("select",{value:Z,onChange:be=>Ae(be.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:C0.map(be=>s.jsx("option",{value:be.to,children:i(be.labelKey)},be.id))}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("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:T.date_format||"system",onChange:be=>Mt("date_format",be.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:T.time_format||"system",onChange:be=>Mt("time_format",be.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:T.default_printer_id??"",onChange:be=>Mt("default_printer_id",be.target.value?Number(be.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)"}),er?.map(be=>s.jsx("option",{value:be.id,children:be.name},be.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(Me,{variant:"secondary",size:"sm",onClick:Ge,children:[s.jsx(lm,{className:"w-4 h-4"}),"Reset"]})]})]})]}),s.jsxs(Nt,{children:[s.jsx(Er,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(FD,{className:"w-5 h-5"}),"Appearance"]})}),s.jsxs(Ct,{className:"space-y-6",children:[s.jsxs("div",{className:`space-y-3 p-4 rounded-lg border ${m==="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",m==="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:b,onChange:be=>{N(be.target.value),o("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:v,onChange:be=>{A(be.target.value),o("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:p,onChange:be=>{M(be.target.value),o("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 ${m==="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",m==="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:y,onChange:be=>{C(be.target.value),o("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:S,onChange:be=>{D(be.target.value),o("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:x,onChange:be=>{k(be.target.value),o("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(Nt,{children:[s.jsx(Er,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Archive Settings"})}),s.jsxs(Ct,{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:T.auto_archive,onChange:be=>Mt("auto_archive",be.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:T.save_thumbnails,onChange:be=>Mt("save_thumbnails",be.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:T.capture_finish_photo,onChange:be=>Mt("capture_finish_photo",be.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"})]})]}),T.capture_finish_photo&&_e&&!_e.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(Tn,{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(Nt,{children:[s.jsx(Er,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx($D,{className:"w-5 h-5 text-bambu-green"}),"Camera"]})}),s.jsxs(Ct,{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Camera View Mode"}),s.jsxs("select",{value:T.camera_view_mode??"window",onChange:be=>Mt("camera_view_mode",be.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:"window",children:"New Window"}),s.jsx("option",{value:"embedded",children:"Embedded Overlay"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:T.camera_view_mode==="embedded"?"Camera opens in a resizable overlay on the main screen":"Camera opens in a separate browser window"})]}),s.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4 mt-4",children:[s.jsx("h3",{className:"text-sm font-medium text-white mb-2",children:"External Cameras"}),s.jsx("p",{className:"text-xs text-bambu-gray mb-3",children:"Configure external cameras to replace the built-in printer camera. Supports MJPEG streams, RTSP, HTTP snapshots, and USB cameras (V4L2). When enabled, the external camera is used for live view and finish photos."}),er&&er.length>0?s.jsx("div",{className:"space-y-3",children:er.map(be=>s.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-white font-medium text-sm",children:be.name}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:be.external_camera_enabled,onChange:ut=>Kt(be.id,{enabled:ut.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 peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),be.external_camera_enabled&&s.jsxs("div",{className:"space-y-2 mt-2",children:[s.jsx("input",{type:"text",placeholder:be.external_camera_type==="usb"?"Device path (/dev/video0)":"Camera URL (rtsp://... or http://...)",value:gt[be.id]??be.external_camera_url??"",onChange:ut=>Zt(be.id,ut.target.value),className:"w-full 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:"flex gap-2",children:[s.jsxs("select",{value:be.external_camera_type||"mjpeg",onChange:ut=>Kt(be.id,{type:ut.target.value}),className:"flex-1 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",children:[s.jsx("option",{value:"mjpeg",children:"MJPEG Stream"}),s.jsx("option",{value:"rtsp",children:"RTSP Stream"}),s.jsx("option",{value:"snapshot",children:"HTTP Snapshot"}),s.jsx("option",{value:"usb",children:"USB Camera (V4L2)"})]}),s.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>Oe(be.id,gt[be.id]??be.external_camera_url??"",be.external_camera_type||"mjpeg"),disabled:$e[be.id]||!(gt[be.id]??be.external_camera_url),children:$e[be.id]?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):"Test"})]}),Fe[be.id]&&s.jsx("div",{className:`text-xs flex items-center gap-1 ${Fe[be.id]?.success?"text-green-500":"text-red-500"}`,children:Fe[be.id]?.success?s.jsxs(s.Fragment,{children:[s.jsx(Hn,{className:"w-3 h-3"}),"Connected",Fe[be.id]?.resolution&&` (${Fe[be.id]?.resolution})`]}):s.jsxs(s.Fragment,{children:[s.jsx(za,{className:"w-3 h-3"}),Fe[be.id]?.error||"Connection failed"]})})]})]},be.id))}):s.jsx("p",{className:"text-xs text-bambu-gray italic",children:"No printers configured"})]})]})]}),s.jsxs(Nt,{children:[s.jsx(Er,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Cost Tracking"})}),s.jsxs(Ct,{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:T.default_filament_cost,onChange:be=>Mt("default_filament_cost",parseFloat(be.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:T.currency,onChange:be=>Mt("currency",be.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:T.energy_cost_per_kwh,onChange:be=>Mt("energy_cost_per_kwh",parseFloat(be.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:T.energy_tracking_mode||"total",onChange:be=>Mt("energy_tracking_mode",be.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:T.energy_tracking_mode==="print"?"Dashboard shows sum of energy used during prints":"Dashboard shows lifetime energy from smart plugs"})]})]})]}),s.jsxs(Nt,{children:[s.jsx(Er,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Ya,{className:"w-5 h-5 text-bambu-green"}),"File Manager"]})}),s.jsxs(Ct,{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Create Archive Entry When Printing"}),s.jsxs("select",{value:T.library_archive_mode??"ask",onChange:be=>Mt("library_archive_mode",be.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:"always",children:"Always create archive entry"}),s.jsx("option",{value:"never",children:"Never create archive entry"}),s.jsx("option",{value:"ask",children:"Ask each time"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"When printing from File Manager, optionally create an archive entry"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Low Disk Space Warning"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"0.5",max:"100",step:"0.5",value:T.library_disk_warning_gb??5,onChange:be=>Mt("library_disk_warning_gb",parseFloat(be.target.value)||5),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:"GB"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Show warning when free disk space falls below this threshold"})]})]})]})]}),s.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-sm",children:[s.jsx(BYe,{}),s.jsxs(Nt,{children:[s.jsx(Er,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Updates"})}),s.jsxs(Ct,{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:T.check_updates,onChange:be=>Mt("check_updates",be.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",Je?.version||"..."]})]}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>lt(),disabled:st,children:[st?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(Ar,{className:"w-4 h-4"}),"Check now"]})]}),Ze?.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",Ze.latest_version]}),Ze.release_name&&Ze.release_name!==Ze.latest_version&&s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:Ze.release_name})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[Ze.release_notes&&s.jsx("button",{onClick:()=>Ye(!0),className:"text-bambu-gray hover:text-white transition-colors text-sm underline",children:"Release Notes"}),Ze.release_url&&s.jsx("a",{href:Ze.release_url,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-white transition-colors",title:"View release on GitHub",children:s.jsx(Gr,{className:"w-4 h-4"})})]})]}),Pt?.status==="downloading"||Pt?.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(mt,{className:"w-4 h-4 animate-spin"}),s.jsx("span",{children:Pt.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:`${Pt.progress}%`}})})]}):Pt?.status==="complete"?s.jsx("div",{className:"mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green",children:Pt.message}):Pt?.status==="error"?s.jsx("div",{className:"mt-3 p-2 bg-red-500/20 rounded text-sm text-red-400",children:Pt.error||Pt.message}):Ze?.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(Me,{className:"mt-3",onClick:()=>Jt.mutate(),disabled:Jt.isPending,children:[Jt.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx($r,{className:"w-4 h-4"}),"Install Update"]})]}):Ze?.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: ",Ze.error]}):Ze&&!Ze.update_available?s.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"You're running the latest version"}):null]})]})]}),s.jsxs(Nt,{children:[s.jsx(Er,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Data Management"})}),s.jsxs(Ct,{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(Me,{variant:"secondary",size:"sm",onClick:()=>ke(!0),children:[s.jsx($r,{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(Me,{variant:"secondary",size:"sm",onClick:()=>Ke(!0),children:[s.jsx(fi,{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(Me,{variant:"secondary",size:"sm",onClick:()=>B(!0),children:[s.jsx(hn,{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(Me,{variant:"secondary",size:"sm",onClick:()=>Y(!0),children:[s.jsx(hn,{className:"w-4 h-4"}),"Reset"]})]})]})]})]})]}),oe==="network"&&T&&s.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[s.jsxs("div",{className:"flex-1 lg:max-w-xl space-y-4",children:[s.jsxs(Nt,{children:[s.jsx(Er,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Fd,{className:"w-5 h-5 text-blue-400"}),"External URL"]})}),s.jsxs(Ct,{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"The external URL where Bambuddy is accessible. Used for notification images and external integrations."}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Bambuddy URL"}),s.jsx("input",{type:"text",value:T.external_url??"",onChange:be=>Mt("external_url",be.target.value),placeholder:"http://192.168.1.100:8000",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:"Include protocol and port (e.g., http://192.168.1.100:8000)"})]})]})]}),s.jsxs(Nt,{children:[s.jsx(Er,{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-blue-400"}),"FTP Retry"]})}),s.jsxs(Ct,{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:T.ftp_retry_enabled??!0,onChange:be=>Mt("ftp_retry_enabled",be.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"})]})]}),T.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:T.ftp_retry_count??3,onChange:be=>Mt("ftp_retry_count",Math.min(10,Math.max(1,parseInt(be.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:T.ftp_retry_delay??2,onChange:be=>Mt("ftp_retry_delay",Math.min(30,Math.max(1,parseInt(be.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:T.ftp_timeout??30,onChange:be=>Mt("ftp_timeout",Math.min(120,Math.max(10,parseInt(be.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:"flex-1 lg:max-w-xl space-y-4",children:[s.jsxs(Nt,{children:[s.jsx(Er,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(sE,{className:"w-5 h-5 text-bambu-green"}),"Home Assistant"]}),T.ha_enabled&&Ce&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${Ce.success?"bg-green-400":"bg-red-400"}`}),s.jsx("span",{className:`text-sm ${Ce.success?"text-green-400":"text-red-400"}`,children:Ce.success?"Connected":"Disconnected"})]})]})}),s.jsxs(Ct,{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Connect to Home Assistant to control smart plugs via HA's REST API. Supports switch, light, and input_boolean entities."}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Enable Home Assistant"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Control smart plugs via Home Assistant"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:T.ha_enabled??!1,onChange:be=>Mt("ha_enabled",be.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"})]})]}),T.ha_enabled&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Home Assistant URL"}),s.jsx("input",{type:"text",value:T.ha_url??"",onChange:be=>Mt("ha_url",be.target.value),placeholder:"http://192.168.1.100:8123",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:"Long-Lived Access Token"}),s.jsx("input",{type:"password",value:T.ha_token??"",onChange:be=>Mt("ha_token",be.target.value),placeholder:"eyJ0eXAiOiJKV1QiLC...",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:"Create a token in HA: Profile → Long-Lived Access Tokens → Create Token"})]}),T.ha_url&&T.ha_token&&s.jsx("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:s.jsxs(Me,{variant:"secondary",size:"sm",disabled:dt,onClick:async()=>{re(!0),Ue(null);try{const be=await me.testHAConnection(T.ha_url,T.ha_token);Ue(be)}catch(be){Ue({success:!1,message:null,error:be instanceof Error?be.message:"Unknown error"})}finally{re(!1)}},children:[dt?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(Qp,{className:"w-4 h-4"}),"Test Connection"]})})]})]})]}),s.jsxs(Nt,{children:[s.jsx(Er,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Qp,{className:"w-5 h-5 text-blue-400"}),"MQTT Publishing"]}),Ht?.enabled&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${Ht.connected?"bg-green-400":"bg-red-400"}`}),s.jsx("span",{className:`text-sm ${Ht.connected?"text-green-400":"text-red-400"}`,children:Ht.connected?"Connected":"Disconnected"})]})]})}),s.jsxs(Ct,{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Publish BamBuddy events to an external MQTT broker for integration with Node-RED, Home Assistant, and other automation systems."}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Enable MQTT"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Publish events to external MQTT broker"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:T.mqtt_enabled??!1,onChange:be=>Mt("mqtt_enabled",be.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"})]})]}),T.mqtt_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:"Broker hostname"}),s.jsx("input",{type:"text",value:T.mqtt_broker??"",onChange:be=>Mt("mqtt_broker",be.target.value),placeholder:"mqtt.example.com or 192.168.1.100",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:"flex items-end gap-4",children:[s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Port"}),s.jsx("input",{type:"number",min:"1",max:"65535",value:T.mqtt_port??1883,onChange:be=>Mt("mqtt_port",Math.min(65535,Math.max(1,parseInt(be.target.value)||1883))),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.jsxs("div",{className:"flex items-center gap-3 pb-2",children:[s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:T.mqtt_use_tls??!1,onChange:be=>{const ut=be.target.checked;Mt("mqtt_use_tls",ut);const It=T.mqtt_port??1883;ut&&It===1883?Mt("mqtt_port",8883):!ut&&It===8883&&Mt("mqtt_port",1883)},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.jsx("span",{className:"text-white text-sm",children:"Use TLS"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Username (optional)"}),s.jsx("input",{type:"text",value:T.mqtt_username??"",onChange:be=>Mt("mqtt_username",be.target.value),placeholder:"Leave empty for anonymous",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 (optional)"}),s.jsx("input",{type:"password",value:T.mqtt_password??"",onChange:be=>Mt("mqtt_password",be.target.value),placeholder:"Leave empty for anonymous",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:"Topic prefix"}),s.jsx("input",{type:"text",value:T.mqtt_topic_prefix??"bambuddy",onChange:be=>Mt("mqtt_topic_prefix",be.target.value),placeholder:"bambuddy",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("p",{className:"text-xs text-bambu-gray mt-1",children:["Topics will be: ",T.mqtt_topic_prefix||"bambuddy","/printers/<serial>/status, etc."]})]}),Ht&&s.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary",children:s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("span",{className:`w-2 h-2 rounded-full ${Ht.connected?"bg-green-400":"bg-red-400"}`}),s.jsx("span",{className:"text-bambu-gray",children:Ht.connected?s.jsxs(s.Fragment,{children:["Connected to ",s.jsxs("span",{className:"text-white",children:[Ht.broker,":",Ht.port]})]}):"Not connected"})]})})]})]})]})]})]}),Ce&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-6 max-w-md w-full mx-4",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[Ce.success?s.jsx(Hn,{className:"w-8 h-8 text-green-400"}):s.jsx(za,{className:"w-8 h-8 text-red-400"}),s.jsx("h3",{className:"text-lg font-medium text-white",children:Ce.success?"Connection Successful":"Connection Failed"})]}),s.jsx("p",{className:"text-bambu-gray mb-6",children:Ce.success?Ce.message||"Successfully connected to Home Assistant.":Ce.error||"Failed to connect to Home Assistant."}),s.jsx("div",{className:"flex justify-end",children:s.jsx(Me,{variant:"primary",onClick:()=>Ue(null),children:"OK"})})]})}),oe==="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(Ws,{className:"w-5 h-5 text-bambu-green"}),"Smart Plugs"]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Connect smart plugs (Tasmota or Home Assistant) 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:[kt&&kt.filter(be=>be.enabled).length>1&&s.jsxs(s.Fragment,{children:[s.jsxs(Me,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>we("on"),disabled:We.isPending,title:"Turn all plugs on",children:[We.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(wu,{className:"w-4 h-4 text-bambu-green"}),"All On"]}),s.jsxs(Me,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>we("off"),disabled:We.isPending,title:"Turn all plugs off",children:[We.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(uE,{className:"w-4 h-4 text-red-400"}),"All Off"]})]}),s.jsxs(Me,{className:"whitespace-nowrap",onClick:()=>{j(null),L(!0)},children:[s.jsx(rr,{className:"w-4 h-4"}),"Add Smart Plug"]})]})]}),kt&&kt.length>0&&s.jsxs(Nt,{className:"mb-6",children:[s.jsx(Er,{children:s.jsxs("h3",{className:"text-base font-semibold text-white flex items-center gap-2",children:[s.jsx(Bf,{className:"w-4 h-4 text-yellow-400"}),"Energy Summary",yn&&s.jsx(mt,{className:"w-4 h-4 animate-spin text-bambu-gray ml-2"})]})}),s.jsx(Ct,{children:Ut?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(Bf,{className:"w-3 h-3"}),"Current Power"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[Ut.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:[Ut.reachableCount,"/",Ut.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(si,{className:"w-3 h-3"}),"Today"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[Ut.totalToday.toFixed(2),s.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),T&&T.energy_cost_per_kwh>0&&s.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(Ut.totalToday*T.energy_cost_per_kwh).toFixed(2)," ",T.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(MK,{className:"w-3 h-3"}),"Yesterday"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[Ut.totalYesterday.toFixed(2),s.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),T&&T.energy_cost_per_kwh>0&&s.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(Ut.totalYesterday*T.energy_cost_per_kwh).toFixed(2)," ",T.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(mP,{className:"w-3 h-3"}),"Total"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[Ut.totalLifetime.toFixed(1),s.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),T&&T.energy_cost_per_kwh>0&&s.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(Ut.totalLifetime*T.energy_cost_per_kwh).toFixed(2)," ",T.currency]})]})]}):yn?null:s.jsx("p",{className:"text-sm text-bambu-gray",children:"Enable plugs to see energy summary"})})]}),on?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(mt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):kt&&kt.length>0?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:kt.map(be=>s.jsx(EYe,{plug:be,onEdit:ut=>{j(ut),L(!0)}},be.id))}):s.jsx(Nt,{children:s.jsx(Ct,{className:"py-12",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(Ws,{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(Me,{onClick:()=>{j(null),L(!0)},children:[s.jsx(rr,{className:"w-4 h-4"}),"Add Your First Smart Plug"]})]})})})]}),oe==="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(vf,{className:"w-5 h-5 text-bambu-green"}),"Providers"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>H(!0),children:[s.jsx(Pw,{className:"w-4 h-4"}),"Log"]}),xt&&xt.length>0&&s.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>{je(null),Ve.mutate()},disabled:Ve.isPending,children:[Ve.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(zD,{className:"w-4 h-4"}),"Test All"]}),s.jsxs(Me,{size:"sm",onClick:()=>{J(null),K(!0)},children:[s.jsx(rr,{className:"w-4 h-4"}),"Add"]})]})]}),s.jsx(Nt,{className:"mb-4",children:s.jsx(Ct,{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:i("settings.notificationLanguage")}),s.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.notificationLanguageDescription")})]}),s.jsx("select",{value:T.notification_language||"en",onChange:be=>Mt("notification_language",be.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:Nz.map(be=>s.jsx("option",{value:be.code,children:be.nativeName},be.code))})]})})}),ue&&s.jsx(Nt,{className:"mb-4",children:s.jsxs(Ct,{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:()=>je(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(Hn,{className:"w-4 h-4"}),ue.success," passed"]}),ue.failed>0&&s.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[s.jsx(za,{className:"w-4 h-4"}),ue.failed," failed"]})]}),ue.results.filter(be=>!be.success).length>0&&s.jsx("div",{className:"space-y-1 mt-2 pt-2 border-t border-bambu-dark-tertiary",children:ue.results.filter(be=>!be.success).map(be=>s.jsxs("div",{className:"text-xs text-red-400",children:[s.jsxs("span",{className:"font-medium",children:[be.provider_name,":"]})," ",be.message]},be.provider_id))})]})}),Yt?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(mt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):xt&&xt.length>0?s.jsx("div",{className:"space-y-3",children:xt.map(be=>s.jsx(TYe,{provider:be,onEdit:ut=>{J(ut),K(!0)}},be.id))}):s.jsx(Nt,{children:s.jsx(Ct,{className:"py-8",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(vf,{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(Me,{size:"sm",onClick:()=>{J(null),K(!0)},children:[s.jsx(rr,{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(Ya,{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."}),yr?s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(mt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):Un&&Un.length>0?s.jsx("div",{className:"space-y-2",children:Un.map(be=>s.jsx(Nt,{className:"cursor-pointer hover:border-bambu-green/50 transition-colors",onClick:()=>te(be),children:s.jsx(Ct,{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:be.name}),s.jsx("p",{className:"text-bambu-gray text-xs truncate mt-0.5",children:be.title_template})]}),s.jsx("button",{className:"p-1.5 hover:bg-bambu-dark-tertiary rounded transition-colors shrink-0 ml-2",onClick:ut=>{ut.stopPropagation(),te(be)},children:s.jsx(cE,{className:"w-4 h-4 text-bambu-gray"})})]})})},be.id))}):s.jsx(Nt,{children:s.jsx(Ct,{className:"py-8",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(Ya,{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."})]})})})]})]}),oe==="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(lf,{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(Me,{size:"sm",onClick:()=>Re(!0),className:"flex-shrink-0",children:[s.jsx(rr,{className:"w-4 h-4"}),"Create Key"]})]}),X&&s.jsx(Nt,{className:"mb-6 border-bambu-green",children:s.jsx(Ct,{className:"py-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Hn,{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:X}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(X);else{const be=document.createElement("textarea");be.value=X,be.style.position="fixed",be.style.left="-999999px",document.body.appendChild(be),be.select(),document.execCommand("copy"),document.body.removeChild(be)}o("Key copied to clipboard")}catch{o("Failed to copy key","error")}},children:s.jsx(il,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"flex gap-2 mt-3",children:[s.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>{Ie(X),o("Key added to API Browser")},children:"Use in API Browser"}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>$(null),children:"Dismiss"})]})]})]})})}),Se&&s.jsxs(Nt,{className:"mb-6",children:[s.jsx(Er,{children:s.jsx("h3",{className:"text-base font-semibold text-white",children:"Create New API Key"})}),s.jsxs(Ct,{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:de,onChange:be=>Qe(be.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:G.can_read_status,onChange:be=>ie(ut=>({...ut,can_read_status:be.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:G.can_queue,onChange:be=>ie(ut=>({...ut,can_queue:be.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:G.can_control_printer,onChange:be=>ie(ut=>({...ut,can_control_printer:be.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(Me,{onClick:()=>Cn.mutate({name:de||"Unnamed Key",...G}),disabled:Cn.isPending,children:[Cn.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(rr,{className:"w-4 h-4"}),"Create Key"]}),s.jsx(Me,{variant:"secondary",onClick:()=>Re(!1),children:"Cancel"})]})]})]}),Tt?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(mt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):sn&&sn.length>0?s.jsx("div",{className:"space-y-3",children:sn.map(be=>s.jsx(Nt,{children:s.jsx(Ct,{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(lf,{className:`w-5 h-5 ${be.enabled?"text-bambu-green":"text-bambu-gray"}`}),s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-medium",children:be.name}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[be.key_prefix,"••••••••",be.last_used&&` · Last used: ${xg(be.last_used)}`]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"flex gap-1 text-xs",children:[be.can_read_status&&s.jsx("span",{className:"px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded",children:"Read"}),be.can_queue&&s.jsx("span",{className:"px-1.5 py-0.5 bg-green-500/20 text-green-400 rounded",children:"Queue"}),be.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(Me,{variant:"secondary",size:"sm",onClick:()=>ce(be.id),children:s.jsx(hn,{className:"w-4 h-4 text-red-400"})})]})]})})},be.id))}):s.jsx(Nt,{children:s.jsx(Ct,{className:"py-12",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(lf,{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(Me,{onClick:()=>Re(!0),children:[s.jsx(rr,{className:"w-4 h-4"}),"Create Your First Key"]})]})})}),s.jsxs(Nt,{className:"mt-6",children:[s.jsx(Er,{children:s.jsx("h3",{className:"text-base font-semibold text-white",children:"Webhook Endpoints"})}),s.jsxs(Ct,{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(Fd,{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(Nt,{className:"mb-4",children:s.jsxs(Ct,{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:Ee,onChange:be=>Ie(be.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(WYe,{apiKey:Ee})]})]}),oe==="virtual-printer"&&s.jsx($Ye,{}),oe==="filament"&&T&&s.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[s.jsx("div",{className:"flex-1 lg:max-w-xl",children:s.jsxs(Nt,{children:[s.jsx(Er,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:"AMS Display Thresholds"})}),s.jsxs(Ct,{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(ID,{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:T.ams_humidity_good??40,onChange:be=>Mt("ams_humidity_good",parseInt(be.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:T.ams_humidity_fair??60,onChange:be=>Mt("ams_humidity_fair",parseInt(be.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(hE,{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:T.ams_temp_good??28,onChange:be=>Mt("ams_temp_good",parseFloat(be.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:T.ams_temp_fair??35,onChange:be=>Mt("ams_temp_fair",parseFloat(be.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(mg,{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:T.ams_history_retention_days??30,onChange:be=>Mt("ams_history_retention_days",parseInt(be.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("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(Wr,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{className:"font-medium",children:"Print Modal"})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-white",children:"Expand custom mapping by default"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:"When printing to multiple printers, show per-printer AMS mapping expanded"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:T.per_printer_mapping_expanded??!1,onChange:be=>Mt("per_printer_mapping_expanded",be.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.jsx("div",{className:"flex-1 lg:max-w-xl",children:s.jsx(UYe,{})})]}),I!==null&&s.jsx(zn,{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:()=>{Cr.mutate(I),ce(null)},onCancel:()=>ce(null)}),U&&s.jsx(NYe,{plug:q,onClose:()=>{L(!1),j(null)}}),W&&s.jsx(CYe,{provider:V,onClose:()=>{K(!1),J(null)}}),ne&&s.jsx(kYe,{template:ne,onClose:()=>te(null)}),z&&s.jsx(RYe,{onClose:()=>H(!1)}),le&&s.jsx(zn,{title:"Clear Notification Logs",message:"This will permanently delete all notification logs older than 30 days. This action cannot be undone.",confirmText:"Clear Logs",variant:"warning",onConfirm:async()=>{B(!1);try{const be=await me.clearNotificationLogs(30);o(be.message,"success")}catch{o("Failed to clear logs","error")}},onCancel:()=>B(!1)}),O&&s.jsx(zn,{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:()=>{Y(!1),localStorage.clear(),o("UI preferences reset. Refreshing...","success"),setTimeout(()=>window.location.reload(),1e3)},onCancel:()=>Y(!1)}),pe&&s.jsx(zn,{title:`Turn All Plugs ${pe==="on"?"On":"Off"}`,message:`This will turn ${pe==="on"?"ON":"OFF"} all ${kt?.filter(be=>be.enabled).length||0} enabled smart plugs. ${pe==="off"?"Any running printers may be affected!":""}`,confirmText:`Turn All ${pe==="on"?"On":"Off"}`,variant:pe==="off"?"danger":"warning",onConfirm:()=>{const be=pe;we(null),We.mutate(be)},onCancel:()=>we(null)}),ae&&s.jsx(OYe,{onClose:()=>ke(!1),onExport:async be=>{ke(!1);const ut="backup-progress",It=be.archives;It&&l(ut,i("backup.preparing",{defaultValue:"Preparing backup..."}),"loading");try{const{blob:yt,filename:Xt}=await me.exportBackup(be);It&&c(ut);const tr=URL.createObjectURL(yt),cn=document.createElement("a");cn.href=tr,cn.download=Xt,cn.click(),URL.revokeObjectURL(tr),o(i("backup.downloaded",{defaultValue:"Backup downloaded"}),"success")}catch{It&&c(ut),o(i("backup.failed",{defaultValue:"Failed to create backup"}),"error")}}}),De&&s.jsx(LYe,{onClose:()=>Ke(!1),onRestore:async(be,ut)=>await me.importBackup(be,ut),onSuccess:()=>{R(null),Dt.current=!0,t.resetQueries({queryKey:["settings"]}),t.invalidateQueries({queryKey:["notification-providers"]}),t.invalidateQueries({queryKey:["notification-templates"]}),t.invalidateQueries({queryKey:["smart-plugs"]}),t.invalidateQueries({queryKey:["external-links"]}),t.invalidateQueries({queryKey:["printers"]}),t.invalidateQueries({queryKey:["filaments"]}),t.invalidateQueries({queryKey:["maintenance-types"]}),t.invalidateQueries({queryKey:["api-keys"]})}}),et&&Ze?.release_notes&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>Ye(!1),children:s.jsxs(Nt,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",onClick:be=>be.stopPropagation(),children:[s.jsxs(Er,{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",Ze.latest_version]}),Ze.release_name&&Ze.release_name!==Ze.latest_version&&s.jsx("p",{className:"text-sm text-bambu-gray",children:Ze.release_name})]}),s.jsx("button",{onClick:()=>Ye(!1),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:s.jsx(Gt,{className:"w-5 h-5"})})]}),s.jsx(Ct,{className:"overflow-y-auto flex-1",children:s.jsx("pre",{className:"text-sm text-bambu-gray whitespace-pre-wrap font-sans",children:Ze.release_notes})}),s.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary shrink-0 flex gap-2",children:[Ze.release_url&&s.jsx("a",{href:Ze.release_url,target:"_blank",rel:"noopener noreferrer",className:"flex-1",children:s.jsxs(Me,{variant:"secondary",className:"w-full",children:[s.jsx(Gr,{className:"w-4 h-4"}),"View on GitHub"]})}),s.jsx(Me,{onClick:()=>Ye(!1),className:"flex-1",children:"Close"})]})]})}),oe==="users"&&s.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-8",children:[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(cf,{className:"w-5 h-5 text-bambu-green"}),"User Authentication"]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Enable authentication to secure your Bambuddy instance and manage user access."})]}),s.jsx(Nt,{children:s.jsx(Ct,{className:"py-6",children:u?s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-12 h-12 rounded-full flex items-center justify-center bg-green-500/20",children:s.jsx(aT,{className:"w-6 h-6 text-green-400"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("h3",{className:"text-white font-medium",children:"Authentication Enabled"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Your Bambuddy instance is secured with authentication."})]})]}),d&&s.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Current User"}),s.jsx("p",{className:"text-white font-medium",children:d.username}),s.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:["Role: ",s.jsx("span",{className:"capitalize",children:d.role})]})]}),s.jsx("div",{className:`px-3 py-1 rounded-full text-xs font-medium ${d.role==="admin"?"bg-purple-500/20 text-purple-300":"bg-blue-500/20 text-blue-300"}`,children:d.role==="admin"?"Admin":"User"})]})}),s.jsxs("div",{className:"pt-4 border-t border-bambu-dark-tertiary space-y-3",children:[s.jsxs(Me,{onClick:()=>e("/users"),className:"w-full",variant:"secondary",children:[s.jsx(cf,{className:"w-4 h-4"}),"Manage Users"]}),d?.role==="admin"&&s.jsxs(Me,{onClick:()=>ye(!0),className:"w-full",variant:"secondary",children:[s.jsx(Wz,{className:"w-4 h-4"}),"Disable Authentication"]})]})]}):s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`w-12 h-12 rounded-full flex items-center justify-center ${u?"bg-green-500/20":"bg-gray-500/20"}`,children:u?s.jsx(aT,{className:"w-6 h-6 text-green-400"}):s.jsx(Wz,{className:"w-6 h-6 text-gray-400"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("h3",{className:"text-white font-medium",children:"Authentication Disabled"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Your Bambuddy instance is currently accessible without authentication."})]})]}),s.jsxs("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Enable authentication to:"}),s.jsxs("ul",{className:"space-y-2 text-sm text-bambu-gray mb-4",children:[s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(Hn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:"Require login to access the system"})]}),s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(Hn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:"Manage multiple users with different roles"})]}),s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(Hn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:"Control access to printer settings and user management"})]})]}),s.jsxs(Me,{type:"button",onClick:be=>{be.preventDefault(),e("/setup")},className:"w-full",children:[s.jsx(aT,{className:"w-4 h-4"}),"Activate Authentication"]})]})]})})})]}),u&&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(vP,{className:"w-5 h-5 text-bambu-green"}),"Role Permissions"]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Overview of what each role can do."})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs(Nt,{children:[s.jsx(Er,{children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-purple-500/20 flex items-center justify-center",children:s.jsx(vP,{className:"w-4 h-4 text-purple-300"})}),s.jsx("h3",{className:"text-white font-medium",children:"Admin"})]})}),s.jsx(Ct,{children:s.jsxs("ul",{className:"space-y-2 text-sm text-bambu-gray",children:[s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(Hn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:"Manage printer settings"})]}),s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(Hn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:"Create, edit, and delete users"})]}),s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(Hn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:"Access all system features"})]})]})})]}),s.jsxs(Nt,{children:[s.jsx(Er,{children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-blue-500/20 flex items-center justify-center",children:s.jsx(cf,{className:"w-4 h-4 text-blue-300"})}),s.jsx("h3",{className:"text-white font-medium",children:"User"})]})}),s.jsx(Ct,{children:s.jsxs("ul",{className:"space-y-2 text-sm text-bambu-gray",children:[s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(Hn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:"Send print jobs"})]}),s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(Hn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:"Manage files and archives"})]}),s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(Hn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:"Manage filament"})]})]})})]})]})]})]}),se&&s.jsx(zn,{title:"Disable Authentication",message:"Are you sure you want to disable authentication? This will make your Bambuddy instance accessible without login. All users will remain in the database but authentication will be disabled.",confirmText:"Disable Authentication",variant:"danger",onConfirm:async()=>{try{await me.disableAuth(),o("Authentication disabled successfully","success"),await f(),ye(!1),window.location.href="/"}catch(be){const ut=be instanceof Error?be.message:"Failed to disable authentication";o(ut,"error")}},onCancel:()=>ye(!1)})]})}const zie=t=>{const e=parseFloat(t);return(Math.trunc(e*1e3)/1e3).toFixed(3)},XYe=t=>t.startsWith("HH")?"HF":"S",YYe=t=>{const e=t.match(/^([A-Z]{2}\d{2})/);return e?e[1]:"HH00"},xD=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 Gj({profile:t,onEdit:e,onCopy:n,selectionMode:r,isSelected:i,onToggleSelect:a,note:o}){const l=XYe(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(ll,{className:"w-4 h-4 text-bambu-green"}):s.jsx(cl,{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:zie(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(vK,{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(il,{className:"w-4 h-4"})})]})}function Wj({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}=Yn(),[f,m]=w.useState(t?.name||""),[p,b]=w.useState(t?.k_value?zie(t.k_value):"0.020"),[v,x]=w.useState(t?.filament_id||""),[y,S]=w.useState(t?.nozzle_id?YYe(t.nozzle_id):"HH00"),[M,N]=w.useState(t?.nozzle_diameter||n),[A,k]=w.useState(t?[t.extruder_id]:i?[0,1]:[0]),[C,D]=w.useState(!1),[T,R]=w.useState({current:0,total:0}),[U,L]=w.useState(a),q=Ur.useMemo(()=>{const te=new Map;for(const z of r)if(z.filament_id&&!te.has(z.filament_id)){const H=xD(z.name||"");te.set(z.filament_id,{id:z.filament_id,name:H||z.filament_id})}return Array.from(te.values()).sort((z,H)=>z.name.localeCompare(H.name))},[r]),j=pt({mutationFn:te=>(console.log("[KProfile] Calling API..."),me.setKProfile(e,te)),onSuccess:te=>{if(console.log("[KProfile] Save success:",te),d("K-profile saved"),u&&U!==a){let z;U===""&&o?z=o:t&&t.slot_id>0?z=t.setting_id||`slot_${t.slot_id}_${t.filament_id}_${t.extruder_id}`:z=`name_${f}_${v}`,u(z,U)}D(!0),setTimeout(()=>{D(!1),c()},2500)},onError:te=>{console.error("[KProfile] Save error:",te),d(te.message,"error"),D(!1)}}),W=pt({mutationFn:te=>(console.log("[KProfile] Deleting profile..."),me.deleteKProfile(e,te)),onSuccess:te=>{console.log("[KProfile] Delete success:",te),d("K-profile deleted"),D(!0),setTimeout(()=>{D(!1),l()},4e3)},onError:te=>{console.error("[KProfile] Delete error:",te),d(te.message,"error"),D(!1)}}),[K,V]=w.useState(!1),J=()=>{t&&W.mutate({slot_id:t.slot_id,extruder_id:t.extruder_id,nozzle_id:t.nozzle_id,nozzle_diameter:t.nozzle_diameter,filament_id:t.filament_id,setting_id:t.setting_id})},ne=async te=>{if(te.preventDefault(),i&&!t&&A.length===0){d("Please select at least one extruder","error");return}const z=parseFloat(p).toFixed(6),H=`${y}-${M}`;if(t||A.length===1){const ee={name:f,k_value:z,filament_id:v,nozzle_id:H,nozzle_diameter:M,extruder_id:t?t.extruder_id:A[0],setting_id:t?.setting_id,slot_id:t?.slot_id??0};console.log("[KProfile] Saving profile:",ee),j.mutate(ee);return}D(!0),R({current:1,total:A.length});const Z=A.map(ee=>({name:f,k_value:z,filament_id:v,nozzle_id:H,nozzle_diameter:M,extruder_id:ee,setting_id:void 0,slot_id:0}));console.log(`[KProfile] Saving ${Z.length} profiles in batch:`,Z);try{if(await me.setKProfilesBatch(e,Z),d(`K-profile saved to ${A.length} extruders`),u&&U){const ee=`name_${f}_${v}`;u(ee,U)}}catch(ee){console.error("[KProfile] Failed to save batch:",ee),d("Failed to save K-profiles","error"),D(!1),R({current:0,total:0});return}R({current:A.length,total:A.length}),setTimeout(()=>{D(!1),R({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(Nt,{className:"w-full max-w-md relative",children:[C&&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(mt,{className:"w-8 h-8 text-bambu-green animate-spin mb-3"}),s.jsx("p",{className:"text-white font-medium",children:T.total>1?`Saving to extruder ${T.current}/${T.total}...`:"Syncing with printer..."}),s.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:"Please wait"})]}),s.jsxs(Ct,{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:C,children:s.jsx(Gt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:ne,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:te=>m(te.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:te=>{const z=te.target.value;(z===""||/^\d*\.?\d*$/.test(z))&&b(z)},onBlur:te=>{const z=parseFloat(te.target.value);isNaN(z)||b((Math.trunc(z*1e3)/1e3).toFixed(3))},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none font-mono",placeholder:"0.020",required:!0}),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:v,onChange:te=>{const z=te.target.value;if(x(z),!t&&z&&!f){const H=q.find(Z=>Z.id===z);H&&m(`${y==="HH00"?"HF":"S"} ${H.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(te=>te.id===t.filament_id)?.name||t.filament_id},t.filament_id),!t&&q.map(te=>s.jsx("option",{value:te.id,children:te.name},te.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:y,onChange:te=>{const z=te.target.value;if(S(z),!t&&v&&!f){const H=q.find(Z=>Z.id===v);H&&m(`${z==="HS00"?"HF":"S"} ${H.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:M,onChange:te=>N(te.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:te=>{te.target.checked?k([...A,1]):k(A.filter(z=>z!==1))},className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green"}),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:te=>{te.target.checked?k([...A,0]):k(A.filter(z=>z!==0))},className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green"}),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:te=>L(te.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(Me,{type:"button",variant:"secondary",onClick:()=>V(!0),disabled:W.isPending||C,className:"text-red-500 hover:bg-red-500/10",children:W.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(hn,{className:"w-4 h-4"})}),s.jsx(Me,{type:"button",variant:"secondary",onClick:l,disabled:C,className:"flex-1",children:"Cancel"}),s.jsxs(Me,{type:"submit",disabled:j.isPending||C,className:"flex-1",children:[j.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(iE,{className:"w-4 h-4"}),"Save"]})]})]})]})]}),K&&s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[60]",children:s.jsx(Nt,{className:"w-full max-w-sm",children:s.jsxs(Ct,{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(hn,{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(Me,{variant:"secondary",onClick:()=>V(!1),className:"flex-1",children:"Cancel"}),s.jsxs(Me,{onClick:()=>{V(!1),J()},disabled:W.isPending,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[W.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(hn,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}const K1={NOZZLE_DIAMETER:"bambusy_kprofiles_nozzle",SORT_OPTION:"bambusy_kprofiles_sort"};function ZYe(){const{showToast:t}=Yn(),[e,n]=w.useState(null),[r,i]=w.useState(()=>localStorage.getItem(K1.NOZZLE_DIAMETER)||"0.4"),[a,o]=w.useState(null),[l,c]=w.useState(!1),[u,d]=w.useState(null),[f,m]=w.useState(""),[p,b]=w.useState("all"),[v,x]=w.useState("all"),[y,S]=w.useState(()=>localStorage.getItem(K1.SORT_OPTION)||"name"),[M,N]=w.useState(!1),[A,k]=w.useState(new Set),[C,D]=w.useState(!1),[T,R]=w.useState(!1),U=w.useCallback($=>`${$.slot_id}_${$.extruder_id}`,[]);w.useEffect(()=>{localStorage.setItem(K1.NOZZLE_DIAMETER,r)},[r]),w.useEffect(()=>{localStorage.setItem(K1.SORT_OPTION,y)},[y]);const{data:L,isLoading:q}=ft({queryKey:["printers"],queryFn:me.getPrinters}),{data:j,isLoading:W,isFetching:K,error:V,refetch:J}=ft({queryKey:["kprofiles",e,r],queryFn:async()=>{console.log("[KProfiles] Fetching profiles for printer",e,"nozzle",r);const $=await me.getKProfiles(e,r);return console.log("[KProfiles] Received profiles:",$?.profiles?.length||0,"profiles"),$},enabled:!!e,retry:!1,staleTime:0,gcTime:0,refetchOnMount:"always"}),{data:ne}=ft({queryKey:["kprofiles",e,"0.4"],queryFn:()=>me.getKProfiles(e,"0.4"),enabled:!!e,staleTime:6e4}),{data:te,refetch:z}=ft({queryKey:["kprofile-notes",e],queryFn:()=>me.getKProfileNotes(e),enabled:!!e,staleTime:3e4}),H=V?.message?.includes("not connected");w.useEffect(()=>{if(!e&&L&&L.length>0){const $=L.find(I=>I.is_active);$&&n($.id)}},[e,L]),w.useEffect(()=>{if(e){const $=setTimeout(()=>{J()},150);return()=>clearTimeout($)}},[e,r]);const Z=L?.filter($=>$.is_active)||[],ee=Ur.useMemo(()=>j?.profiles?j.profiles.filter(I=>{const ce=f.toLowerCase(),Ee=!ce||I.name.toLowerCase().includes(ce)||I.filament_id.toLowerCase().includes(ce),Ie=p==="all"||p==="left"&&I.extruder_id===1||p==="right"&&I.extruder_id===0,le=v==="all"||v==="hf"&&I.nozzle_id.startsWith("HH")||v==="s"&&I.nozzle_id.startsWith("HS");return Ee&&Ie&&le}).sort((I,ce)=>{switch(y){case"k_value":return parseFloat(I.k_value)-parseFloat(ce.k_value);case"filament":return xD(I.name).localeCompare(xD(ce.name));default:return I.name.localeCompare(ce.name)}}):[],[j?.profiles,f,p,v,y]),he=L?.find($=>$.id===e),fe=he?.nozzle_count===2;w.useEffect(()=>{const $=I=>{I.target instanceof HTMLInputElement||I.target instanceof HTMLTextAreaElement||I.target instanceof HTMLSelectElement||a||l||u||(I.key==="r"||I.key==="R"?(I.preventDefault(),J()):I.key==="n"||I.key==="N"?(I.preventDefault(),c(!0)):I.key==="Escape"&&M&&(I.preventDefault(),N(!1),k(new Set)))};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[a,l,u,M,J]);const oe=w.useCallback(()=>{if(!j?.profiles||j.profiles.length===0){t("No profiles to export","error");return}const $={version:1,exported_at:new Date().toISOString(),printer:he?.name||"Unknown",nozzle_diameter:r,profiles:j.profiles.map(Ie=>({name:Ie.name,k_value:Ie.k_value,filament_id:Ie.filament_id,nozzle_id:Ie.nozzle_id,nozzle_diameter:Ie.nozzle_diameter,extruder_id:Ie.extruder_id}))},I=new Blob([JSON.stringify($,null,2)],{type:"application/json"}),ce=URL.createObjectURL(I),Ee=document.createElement("a");Ee.href=ce,Ee.download=`kprofiles_${he?.name||"printer"}_${r}mm_${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(Ee),Ee.click(),document.body.removeChild(Ee),URL.revokeObjectURL(ce),t(`Exported ${j.profiles.length} profiles`)},[j?.profiles,he,r,t]),Ne=w.useCallback(()=>{const $=document.createElement("input");$.type="file",$.accept=".json",$.onchange=async I=>{const ce=I.target.files?.[0];if(ce)try{const Ee=await ce.text(),Ie=JSON.parse(Ee);if(!Ie.profiles||!Array.isArray(Ie.profiles)){t("Invalid file format","error");return}let le=0;for(const B of Ie.profiles)if(!(!B.name||!B.k_value||!B.filament_id))try{await me.setKProfile(e,{name:B.name,k_value:parseFloat(B.k_value).toFixed(6),filament_id:B.filament_id,nozzle_id:B.nozzle_id||`HH00-${r}`,nozzle_diameter:B.nozzle_diameter||r,extruder_id:B.extruder_id??0,slot_id:0}),le++,await new Promise(O=>setTimeout(O,500))}catch(O){console.error("Failed to import profile:",B.name,O)}t(`Imported ${le} of ${Ie.profiles.length} profiles`),J()}catch(Ee){console.error("Import error:",Ee),t("Failed to parse import file","error")}},$.click()},[e,r,t,J]),ge=w.useCallback($=>{k(I=>{const ce=new Set(I);return ce.has($)?ce.delete($):ce.add($),ce})},[]),Se=w.useCallback(()=>{k(new Set(ee.map($=>U($))))},[ee,U]),Re=w.useCallback(()=>{A.size!==0&&D(!0)},[A.size]),de=w.useCallback(async()=>{const $=ee.filter(ce=>A.has(U(ce)));R(!0);let I=0;for(const ce of $)try{await me.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}),I++,await new Promise(Ee=>setTimeout(Ee,300))}catch(Ee){console.error("Failed to delete profile:",ce.name,Ee)}t(`Deleted ${I} profiles`),R(!1),D(!1),N(!1),k(new Set),J()},[e,A,ee,t,J,U]),Qe=w.useCallback($=>{const I=[];return $.setting_id&&I.push($.setting_id),I.push(`slot_${$.slot_id}_${$.filament_id}_${$.extruder_id}`),I.push(`name_${$.name}_${$.filament_id}`),I},[]),G=w.useCallback(async($,I)=>{if(e)try{await me.setKProfileNote(e,$,I),z()}catch(ce){console.error("Failed to save note:",ce),t("Failed to save note","error")}},[e,z,t]),ie=w.useCallback($=>{if(!te?.notes)return{note:"",key:null};const I=Qe($);for(const ce of I)if(te.notes[ce])return{note:te.notes[ce],key:ce};return{note:"",key:null}},[te,Qe]),X=w.useCallback($=>ie($).note,[ie]);return q?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(mt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):!L||L.length===0?s.jsx(Nt,{children:s.jsxs(Ct,{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"})]})}):Z.length===0?s.jsx(Nt,{children:s.jsxs(Ct,{className:"py-12 text-center",children:[s.jsx(Wr,{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:[K&&!W&&s.jsxs("div",{className:"fixed inset-0 bg-black/50 flex flex-col items-center justify-center z-40",children:[s.jsx(mt,{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:$=>n(parseInt($.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:Z.map($=>s.jsx("option",{value:$.id,children:$.name},$.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:$=>i($.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(Me,{variant:"secondary",onClick:()=>J(),disabled:K,children:[s.jsx(Ar,{className:`w-4 h-4 ${K?"animate-spin":""}`}),"Refresh"]}),s.jsxs(Me,{onClick:()=>c(!0),children:[s.jsx(rr,{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(Sa,{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:$=>m($.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"})]}),fe&&s.jsx("div",{className:"w-36",children:s.jsxs("select",{value:p,onChange:$=>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:v,onChange:$=>x($.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:y,onChange:$=>S($.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(Me,{variant:"secondary",onClick:oe,disabled:!j?.profiles?.length,title:"Export profiles to JSON",children:[s.jsx($r,{className:"w-4 h-4"}),"Export"]}),s.jsxs(Me,{variant:"secondary",onClick:Ne,title:"Import profiles from JSON",children:[s.jsx(fi,{className:"w-4 h-4"}),"Import"]}),s.jsx("div",{className:"flex-1"}),M?s.jsxs(s.Fragment,{children:[s.jsxs(Me,{variant:"secondary",onClick:Se,title:"Select all visible profiles",children:[s.jsx(ll,{className:"w-4 h-4"}),"Select All"]}),s.jsxs(Me,{variant:"secondary",onClick:Re,disabled:A.size===0,className:"text-red-500 hover:bg-red-500/10",title:`Delete ${A.size} selected profiles`,children:[s.jsx(hn,{className:"w-4 h-4"}),"Delete (",A.size,")"]}),s.jsxs(Me,{variant:"secondary",onClick:()=>{N(!1),k(new Set)},children:[s.jsx(Gt,{className:"w-4 h-4"}),"Cancel"]})]}):s.jsxs(Me,{variant:"secondary",onClick:()=>N(!0),disabled:!ee.length,title:"Enter selection mode for bulk delete",children:[s.jsx(ll,{className:"w-4 h-4"}),"Select"]})]}),W?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(mt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):H?s.jsx(Nt,{children:s.jsxs(Ct,{className:"py-12 text-center",children:[s.jsx(Yg,{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(Me,{variant:"secondary",onClick:()=>J(),children:[s.jsx(Ar,{className:"w-4 h-4"}),"Retry"]})]})}):ee.length>0?fe?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:ee.filter($=>$.extruder_id===1).map($=>s.jsx(Gj,{profile:$,onEdit:()=>o($),onCopy:()=>d($),selectionMode:M,isSelected:A.has(U($)),onToggleSelect:()=>ge(U($)),note:X($)},U($)))})]}),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:ee.filter($=>$.extruder_id===0).map($=>s.jsx(Gj,{profile:$,onEdit:()=>o($),onCopy:()=>d($),selectionMode:M,isSelected:A.has(U($)),onToggleSelect:()=>ge(U($)),note:X($)},U($)))})]})]}):s.jsx("div",{className:"space-y-1",children:ee.map($=>s.jsx(Gj,{profile:$,onEdit:()=>o($),onCopy:()=>d($),selectionMode:M,isSelected:A.has(U($)),onToggleSelect:()=>ge(U($)),note:X($)},U($)))}):f||p!=="all"||v!=="all"?s.jsx(Nt,{children:s.jsxs(Ct,{className:"py-12 text-center",children:[s.jsx(Sa,{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(Nt,{children:s.jsxs(Ct,{className:"py-12 text-center",children:[s.jsx(iE,{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(Me,{onClick:()=>c(!0),children:[s.jsx(rr,{className:"w-4 h-4"}),"Create First Profile"]})]})}),a&&e&&(()=>{const{note:$,key:I}=ie(a);return s.jsx(Wj,{profile:a,printerId:e,nozzleDiameter:r,existingProfiles:ne?.profiles||j?.profiles,isDualNozzle:fe,initialNote:$,initialNoteKey:I,onSaveNote:G,onClose:()=>{console.log("[KProfiles] Edit modal onClose - refetching profiles..."),o(null),J()},onSave:()=>{o(null),J()}})})(),l&&e&&s.jsx(Wj,{printerId:e,nozzleDiameter:r,existingProfiles:ne?.profiles||j?.profiles,isDualNozzle:fe,onSaveNote:G,onClose:()=>{c(!1),J()},onSave:()=>{c(!1),J()}}),u&&e&&s.jsx(Wj,{printerId:e,nozzleDiameter:r,existingProfiles:ne?.profiles||j?.profiles,isDualNozzle:fe,onSaveNote:G,profile:{...u,slot_id:0,name:`${u.name} (Copy)`},onClose:()=>{d(null),J()},onSave:()=>{d(null),J()}}),C&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(Nt,{className:"w-full max-w-sm",children:s.jsxs(Ct,{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(hn,{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(Me,{variant:"secondary",onClick:()=>D(!1),disabled:T,className:"flex-1",children:"Cancel"}),s.jsxs(Me,{onClick:de,disabled:T,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[T?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(hn,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}function gI(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 py(t){return/^(P[FPM]US|PF\d|PP\d)/.test(t)}function QYe(t){const e=Si(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 JYe({onSuccess:t}){const{showToast:e}=Yn(),[n,r]=w.useState("email"),[i,a]=w.useState(""),[o,l]=w.useState(""),[c,u]=w.useState(""),[d,f]=w.useState(""),[m,p]=w.useState("global"),b=pt({mutationFn:()=>me.cloudLogin(i,o,m),onSuccess:M=>{M.success?(e("Logged in successfully"),t()):M.needs_verification?(e("Verification code sent to your email"),r("code")):e(M.message,"error")},onError:M=>e(M.message,"error")}),v=pt({mutationFn:()=>me.cloudVerify(i,c),onSuccess:M=>{M.success?(e("Logged in successfully"),t()):e(M.message,"error")},onError:M=>e(M.message,"error")}),x=pt({mutationFn:()=>me.cloudSetToken(d),onSuccess:()=>{e("Token set successfully"),t()},onError:M=>e(M.message,"error")}),y=M=>{M.preventDefault(),n==="email"?b.mutate():n==="code"?v.mutate():n==="token"&&x.mutate()},S=b.isPending||v.isPending||x.isPending;return s.jsx(Nt,{className:"max-w-md mx-auto",children:s.jsxs(Ct,{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(eE,{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:y,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:M=>a(M.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:M=>l(M.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:m,onChange:M=>p(M.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:M=>u(M.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:M=>f(M.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(Me,{type:"button",variant:"secondary",onClick:()=>r("email"),className:"flex-1",children:"Back"}),s.jsxs(Me,{type:"submit",disabled:S,className:"flex-1",children:[S?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(qz,{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(lf,{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(qz,{className:"w-4 h-4"}),"Login with email instead"]})})]})]})})}function Lp({label:t,value:e,options:n,onChange:r}){const[i,a]=w.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(Oi,{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 eZe(){const[t,e]=w.useState(!1);w.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(hg,{className:"w-5 h-5"})}):null}function qj({setting:t,onClick:e,onDuplicate:n,compareMode:r,isCompareSelected:i,compareIndex:a,compareDisabled:o}){const l=gI(t.name),c=py(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(il,{className:"w-4 h-4"})})]})}function bD(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(`
  8327. `)){const i=t.replace(/\\n/g,`
  8328. `).replace(/\\"/g,'"').replace(/\\t/g," ").split(`
  8329. `);if(i.length>1)return`"""
  8330. `+i.map(a=>n+" "+a).join(`
  8331. `)+`
  8332. `+n+'"""'}return JSON.stringify(t)}if(typeof t=="number"||typeof t=="boolean")return String(t);if(Array.isArray(t))return t.length===0?"[]":`[
  8333. `+t.map(i=>n+" "+bD(i,e+1)).join(`,
  8334. `)+`
  8335. `+n+"]";if(typeof t=="object"){const r=Object.entries(t);return r.length===0?"{}":`{
  8336. `+r.map(([a,o])=>n+" "+JSON.stringify(a)+": "+bD(o,e+1)).join(`,
  8337. `)+`
  8338. `+n+"}"}return String(t)}function tZe({setting:t,onClose:e,onDeleted:n,onDuplicate:r,onEdit:i}){const{showToast:a}=Yn(),o=ln(),[l,c]=w.useState(!1),{data:u,isLoading:d}=ft({queryKey:["cloudSettingDetail",t.setting_id],queryFn:()=>me.getCloudSettingDetail(t.setting_id)}),f=pt({mutationFn:()=>me.deleteCloudSetting(t.setting_id),onSuccess:()=>{a("Preset deleted"),o.invalidateQueries({queryKey:["cloudSettings"]}),n()},onError:b=>a(b.message,"error")}),m=py(t.setting_id),p=gI(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(Nt,{className:"w-full max-w-3xl max-h-[90vh] flex flex-col overflow-hidden",children:s.jsxs(Ct,{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}),m&&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(Gt,{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(mt,{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:bD(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(Tn,{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(Me,{variant:"secondary",onClick:()=>c(!1),disabled:f.isPending,className:"flex-1",children:"Cancel"}),s.jsxs(Me,{variant:"danger",onClick:()=>f.mutate(),disabled:f.isPending,className:"flex-1",children:[f.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(hn,{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(Me,{variant:"secondary",onClick:e,className:"flex-1",children:"Close"}),s.jsxs(Me,{variant:"secondary",onClick:r,children:[s.jsx(il,{className:"w-4 h-4"}),"Duplicate"]}),m&&s.jsxs(s.Fragment,{children:[s.jsxs(Me,{variant:"secondary",onClick:i,disabled:d||!u,children:[s.jsx(Na,{className:"w-4 h-4"}),"Edit"]}),s.jsx(Me,{variant:"danger",onClick:()=>c(!0),children:s.jsx(hn,{className:"w-4 h-4"})})]})]})})]})})})}function Bie(){try{const t=localStorage.getItem("bambusy_preset_templates");return t?JSON.parse(t):[]}catch{return[]}}function $ie(t){localStorage.setItem("bambusy_preset_templates",JSON.stringify(t))}function nZe({onClose:t,onApply:e}){const{showToast:n}=Yn(),[r,i]=w.useState(Bie),[a,o]=w.useState("all"),[l,c]=w.useState(null),[u,d]=w.useState(""),[f,m]=w.useState(""),[p,b]=w.useState("{}"),[v,x]=w.useState(null),[y,S]=w.useState(null),M=a==="all"?r:r.filter(L=>L.type===a),N=L=>{i(L),$ie(L)},A=L=>{const q=r.filter(j=>j.id!==L);N(q),S(null),n("Template deleted")},k=L=>{c(L.id),d(L.name),m(L.description),b(JSON.stringify(L.settings,null,2)),x(null)},C=()=>{if(!(!l||!u.trim()))try{const L=JSON.parse(p),q=r.map(j=>j.id===l?{...j,name:u.trim(),description:f.trim(),settings:L}:j);N(q),c(null),n("Template updated")}catch(L){x(L.message)}},D=()=>{c(null),d(""),m(""),b("{}"),x(null)},T=L=>{const q=r.map(j=>j.id===L?{...j,showInModal:!j.showInModal}:j);N(q)},R={filament:{label:"Filament",icon:LD,color:"text-amber-400"},print:{label:"Process",icon:Kd,color:"text-blue-400"},printer:{label:"Printer",icon:Wr,color:"text-purple-400"}},U=y?r.find(L=>L.id===y):null;return w.useEffect(()=>{const L=q=>{q.key==="Escape"&&(y?S(null):l?D():t())};return window.addEventListener("keydown",L),()=>window.removeEventListener("keydown",L)},[y,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(Nt,{className:"w-full max-w-md",children:s.jsxs(Ct,{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(Tn,{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(Me,{variant:"secondary",onClick:()=>S(null),className:"flex-1",children:"Cancel"}),s.jsxs(Me,{onClick:()=>A(y),className:"flex-1 bg-red-500 hover:bg-red-600",children:[s.jsx(hn,{className:"w-4 h-4"}),"Delete"]})]})]})})}),s.jsx(Nt,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",children:s.jsxs(Ct,{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(T0,{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(Gt,{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(L=>s.jsx("button",{onClick:()=>o(L),className:`px-3 py-1 text-sm rounded-lg transition-colors ${a===L?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:L==="all"?"All":R[L].label},L))]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:M.length===0?s.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[s.jsx(T0,{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:M.map(L=>{const q=R[L.type],j=q.icon;return l===L.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:W=>d(W.target.value),placeholder:"Template name",className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",autoFocus:!0}),s.jsx("input",{type:"text",value:f,onChange:W=>m(W.target.value),placeholder:"Description",className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]}),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:W=>{b(W.target.value),x(null)},rows:6,className:`w-full px-3 py-2 bg-bambu-dark-secondary border rounded text-white text-sm font-mono focus:outline-none ${v?"border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`}),v&&s.jsx("p",{className:"text-xs text-red-400 mt-1",children:v})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Me,{size:"sm",onClick:C,disabled:!u.trim(),children:[s.jsx(bs,{className:"w-4 h-4"}),"Save"]}),s.jsx(Me,{size:"sm",variant:"secondary",onClick:D,children:"Cancel"})]})]},L.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(j,{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:L.name}),s.jsx("p",{className:"text-xs text-bambu-gray truncate",children:L.description})]}),s.jsxs("span",{className:"text-xs text-bambu-gray-dark px-2 py-1 bg-bambu-dark-secondary rounded",children:[Object.keys(L.settings).length," fields"]}),s.jsx("button",{onClick:()=>T(L.id),className:`p-1 transition-colors ${L.showInModal?"text-bambu-green hover:text-bambu-green/70":"text-bambu-gray hover:text-white"}`,title:L.showInModal?"Shown in modals":"Hidden in modals",children:L.showInModal?s.jsx(Ff,{className:"w-4 h-4"}):s.jsx(tE,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>e(L),className:"px-3 py-1 text-xs bg-bambu-green/20 text-bambu-green rounded hover:bg-bambu-green/30 transition-colors",children:"Apply"}),s.jsx("button",{onClick:()=>k(L),className:"p-1 text-bambu-gray hover:text-white",title:"Edit",children:s.jsx(Na,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>S(L.id),className:"p-1 text-bambu-gray hover:text-red-400",title:"Delete",children:s.jsx(hn,{className:"w-4 h-4"})})]},L.id)})})})]})})]})}function Hie({onClose:t,leftPreset:e,rightPreset:n,leftLabel:r,rightLabel:i}){const[a,o]=w.useState("changes"),[l,c]=w.useState(""),u=w.useMemo(()=>{const p=new Set([...Object.keys(e),...Object.keys(n)]),b=[];for(const v of p){if(v==="inherits"||v==="version")continue;const x=e[v],y=n[v],S=v in e,M=v in n;let N;!S&&M?N="added":S&&!M?N="removed":JSON.stringify(x)!==JSON.stringify(y)?N="changed":N="same",b.push({key:v,left:x,right:y,status:N})}return b.sort((v,x)=>{const y={changed:0,added:1,removed:2,same:3};return y[v.status]!==y[x.status]?y[v.status]-y[x.status]:v.key.localeCompare(x.key)})},[e,n]),d=w.useMemo(()=>{let p=[...u];if(a==="changes"&&(p=p.filter(b=>b.status!=="same")),l){const b=l.toLowerCase();p=p.filter(v=>v.key.toLowerCase().includes(b)||String(v.left).toLowerCase().includes(b)||String(v.right).toLowerCase().includes(b))}return p},[u,a,l]),f=w.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]),m=p=>{if(p===void 0)return"—";if(p===null)return"null";if(Array.isArray(p))return p.length===0?"[]":p.length===1?String(p[0]):p.join(", ");if(typeof p=="object")return JSON.stringify(p);const b=String(p);if(b.includes("\\n")||b.length>100){const v=b.split("\\n").length;if(v>1)return`[${v} lines of G-code/script]`;if(b.length>100)return b.substring(0,100)+"…"}return b};return w.useEffect(()=>{const p=b=>{b.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(Nt,{className:"w-full max-w-4xl max-h-[85vh] flex flex-col overflow-hidden",children:s.jsxs(Ct,{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(Zp,{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(Gt,{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(rr,{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(bP,{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(hP,{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(iT,{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(Sa,{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(iT,{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 b={added:"bg-green-500/10",removed:"bg-red-500/10",changed:"bg-amber-500/10",same:""}[p.status],v={added:s.jsx(rr,{className:"w-3.5 h-3.5 text-green-400"}),removed:s.jsx(bP,{className:"w-3.5 h-3.5 text-red-400"}),changed:s.jsx(hP,{className:"w-3.5 h-3.5 text-amber-400"}),same:s.jsx(iT,{className:"w-3.5 h-3.5 text-bambu-gray-dark"})}[p.status];return s.jsxs("tr",{className:`border-b border-bambu-dark-tertiary ${b}`,children:[s.jsx("td",{className:"p-3",children:s.jsxs("div",{className:"flex items-center gap-2",children:[v,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:m(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:m(p.right)})})]},p.key)})})]})})]})})})}function rZe({onClose:t,initialData:e,allPresets:n}){const{showToast:r}=Yn(),i=ln(),a=!!e?.setting_id,[o,l]=w.useState("common"),[c,u]=w.useState(e?.type||"filament"),[d,f]=w.useState(e?.name?a?e.name:`${e.name} (Copy)`:""),[m,p]=w.useState(e?.base_id||""),[b,v]=w.useState(""),[x,y]=w.useState(e?.setting||{inherits:""}),[S,M]=w.useState(JSON.stringify(e?.setting||{inherits:""},null,2)),[N,A]=w.useState(null),[k,C]=w.useState(""),[D,T]=w.useState(!1),[R,U]=w.useState(""),[L,q]=w.useState(!1),[j,W]=w.useState(Bie),[K,V]=w.useState(!1),[J,ne]=w.useState(""),[te,z]=w.useState(""),[H,Z]=w.useState(!0),[ee,he]=w.useState(null),[fe,oe]=w.useState(!1),Ne=w.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer})[c]||[],[n,c]),ge=w.useMemo(()=>Ne.filter(se=>py(se.setting_id)),[Ne]),{data:Se}=ft({queryKey:["cloudFields",c],queryFn:()=>me.getCloudFields(c==="print"?"process":c),staleTime:1e3*60*60}),{data:Re}=ft({queryKey:["allPresetDetails",c,ge.map(se=>se.setting_id).join(",")],queryFn:async()=>{const se={};for(let Ce=0;Ce<ge.length;Ce+=5){const Ue=ge.slice(Ce,Ce+5);(await Promise.all(Ue.map(async re=>{try{const Fe=await me.getCloudSettingDetail(re.setting_id);return{id:re.setting_id,detail:Fe}}catch{return null}}))).forEach(re=>{re&&(se[re.id]=re.detail)})}return se},enabled:ge.length>0,staleTime:1e3*60*10}),{data:de,isLoading:Qe}=ft({queryKey:["cloudSettingDetail",m],queryFn:()=>me.getCloudSettingDetail(m),enabled:!!m});w.useEffect(()=>{o!=="json"&&M(JSON.stringify(x,null,2))},[x,o]);const G=w.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer}[c]||[]).filter(ye=>!py(ye.setting_id)).sort((ye,Ce)=>ye.name.localeCompare(Ce.name)),[n,c]);w.useEffect(()=>{if(!m)return;const se=G.find(ye=>ye.setting_id===m);se&&(v(se.name),a||(y({inherits:se.name}),M(JSON.stringify({inherits:se.name},null,2))))},[m,G,a]);const ie=w.useMemo(()=>{const se=Se?.fields||[],ye=new Set(se.map(re=>re.key)),Ce=new Set,Ue=new Set(["inherits","updated_time","compatible_printers","compatible_prints"]);Re&&Object.values(Re).forEach(re=>{re?.setting&&Object.keys(re.setting).forEach(Fe=>{!ye.has(Fe)&&!Ue.has(Fe)&&Ce.add(Fe)})}),Object.keys(x).forEach(re=>{!ye.has(re)&&!Ue.has(re)&&Ce.add(re)});const dt=Array.from(Ce).sort().map(re=>({key:re,label:re.replace(/_/g," ").replace(/\b\w/g,Fe=>Fe.toUpperCase()),type:"text",category:"discovered",description:"Discovered from presets"}));return[...se,...dt]},[Se,Re,x]),X=ie.filter(se=>se.label.toLowerCase().includes(k.toLowerCase())||se.key.toLowerCase().includes(k.toLowerCase())),$=()=>{if(R.trim()){const se=R.trim().toLowerCase().replace(/\s+/g,"_");I(se,""),U(""),q(!1),r(`Field "${se}" added`)}},I=(se,ye)=>{y(Ce=>{const Ue={...Ce};return ye===""||ye===void 0?delete Ue[se]:Ue[se]=ye,Ue})},ce=se=>{y(ye=>({...ye,...se.settings})),he(se.name),r("Template applied")},Ee=()=>{if(!J.trim())return;const se={...x};if(delete se.inherits,Object.keys(se).length===0){r("No overrides to save","error");return}const ye={id:Date.now().toString(),name:J.trim(),description:te.trim()||"Custom template",type:c,settings:se,showInModal:H},Ce=[...j,ye];W(Ce),$ie(Ce),V(!1),ne(""),z(""),Z(!0),r("Template saved")},Ie=w.useMemo(()=>j.filter(se=>se.type===c&&se.showInModal),[c,j]),le=se=>{M(se);try{const ye=JSON.parse(se);y(ye),A(null)}catch(ye){A(ye.message)}},B=se=>{se.preventDefault(),T(!1);const ye=se.dataTransfer.files[0];if(ye&&ye.name.endsWith(".json")){const Ce=new FileReader;Ce.onload=Ue=>{try{const dt=Ue.target?.result,re=JSON.parse(dt),Fe=re.setting||re;y(ve=>({...ve,...Fe})),M(JSON.stringify({...x,...Fe},null,2)),r("File imported successfully")}catch{r("Invalid JSON file","error")}},Ce.readAsText(ye)}},O=pt({mutationFn:()=>{const se={...x},ye=c==="filament"?"filament_settings_id":c==="print"?"print_settings_id":"printer_settings_id";se[ye]=`"${d}"`;const Ce={type:c,name:d,base_id:m,setting:se};return me.createCloudSetting(Ce)},onSuccess:async()=>{r("Preset created successfully"),await i.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:se=>r(se.message,"error")}),Y=pt({mutationFn:()=>{if(!e?.setting_id)throw new Error("No setting ID for update");return me.updateCloudSetting(e.setting_id,{name:d,setting:x})},onSuccess:async()=>{r("Preset updated successfully"),i.removeQueries({queryKey:["cloudSettingDetail"]}),await i.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:se=>r(se.message,"error")}),pe=a?Y:O,we=de?.setting?.inherits,ae=we?G.find(se=>se.name===we):void 0,{data:ke}=ft({queryKey:["cloudSettingDetail",ae?.setting_id],queryFn:()=>me.getCloudSettingDetail(ae.setting_id),enabled:!!ae?.setting_id}),De=w.useMemo(()=>{const se=ke?.setting||{},ye=de?.setting||{},Ce=m&&Re?.[m]?.setting?Re[m].setting:{};return{...se,...ye,...Ce}},[m,de,ke,Re]),Ke=se=>{if(se==null)return"";if(Array.isArray(se)){const ye=[...new Set(se.map(Ce=>String(Ce)))];return ye.length===1?ye[0]:se.join(", ")}return String(se)},et=se=>{const ye=x[se.key],Ce=De[se.key],Ue=Ke(Ce),dt=Qe?"Loading...":Ue||"",re="w-full px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none";if(se.type==="boolean"){const Fe=ye==="1"||ye===void 0&&Ce==="1";return s.jsx("button",{type:"button",onClick:()=>I(se.key,ye==="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 se.type==="select"?s.jsxs("select",{value:ye||"",onChange:Fe=>I(se.key,Fe.target.value),className:re,children:[s.jsx("option",{value:"",children:dt}),se.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:se.type==="number"?"number":"text",value:ye!==void 0?String(ye):"",onChange:Fe=>I(se.key,Fe.target.value),step:se.step,min:se.min,max:se.max,placeholder:dt,className:re}),se.unit&&s.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:se.unit})]})},Ye=w.useMemo(()=>de?.setting?de.setting:{},[de]);return s.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onDragOver:se=>{se.preventDefault(),T(!0)},onDragLeave:()=>T(!1),onDrop:B,children:[fe&&m&&s.jsx(Hie,{onClose:()=>oe(!1),leftPreset:Ye,rightPreset:x,leftLabel:`Base: ${b||m}`,rightLabel:`Current: ${d||"New Preset"}`}),s.jsx(Nt,{className:"w-full max-w-6xl max-h-[90vh] flex flex-col",children:s.jsxs(Ct,{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:[m&&s.jsxs("button",{onClick:()=>oe(!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(Zp,{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(Gt,{className:"w-5 h-5"})})]})]}),D&&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(fi,{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:se=>{u(se.target.value),p("")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[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:m,onChange:se=>p(se.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"",children:"Select base preset..."}),G.map(se=>s.jsx("option",{value:se.setting_id,children:se.name},se.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:se=>f(se.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"My Custom Preset"})]})]}),b&&s.jsx("div",{className:"text-xs text-bambu-gray",children:s.jsxs("p",{className:"flex items-center gap-1",children:[s.jsx(Es,{className:"w-3 h-3 text-bambu-green"}),"Inherits from: ",s.jsx("span",{className:"text-white",children:b}),Qe&&s.jsx(mt,{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(Kz,{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(lE,{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(uK,{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 se={name:d,type:c,base_id:m,setting:x},ye=new Blob([JSON.stringify(se,null,2)],{type:"application/json"}),Ce=URL.createObjectURL(ye),Ue=document.createElement("a");Ue.href=Ce,Ue.download=`${d||"preset"}.json`,document.body.appendChild(Ue),Ue.click(),document.body.removeChild(Ue),URL.revokeObjectURL(Ce),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($r,{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(fi,{className:"w-4 h-4"}),"Import"]}),s.jsx("input",{id:"file-import",type:"file",accept:".json",className:"hidden",onChange:se=>{const ye=se.target.files?.[0];if(ye){const Ce=new FileReader;Ce.onload=Ue=>{try{const dt=JSON.parse(Ue.target?.result),re=dt.setting||dt;y(Fe=>({...Fe,...re})),r("File imported")}catch{r("Invalid JSON","error")}},Ce.readAsText(ye)}}})]}),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(T0,{className:"w-4 h-4 text-amber-400"}),"Quick Templates"]}),Object.keys(x).filter(se=>se!=="inherits").length>0&&s.jsxs("button",{onClick:()=>V(!K),className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1 transition-colors",children:[s.jsx(bs,{className:"w-3 h-3"}),"Save as template"]})]}),K&&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:J,onChange:se=>ne(se.target.value),placeholder:"Template name",className:"px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",autoFocus:!0}),s.jsx("input",{type:"text",value:te,onChange:se=>z(se.target.value),placeholder:"Description (optional)",className:"px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Me,{size:"sm",onClick:Ee,disabled:!J.trim(),children:[s.jsx(bs,{className:"w-3 h-3"}),"Save"]}),s.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>V(!1),children:"Cancel"})]}),s.jsxs("button",{onClick:()=>Z(!H),className:`flex items-center gap-1.5 text-xs transition-colors ${H?"text-bambu-green":"text-bambu-gray hover:text-white"}`,children:[H?s.jsx(Ff,{className:"w-3.5 h-3.5"}):s.jsx(tE,{className:"w-3.5 h-3.5"}),H?"Show in modals":"Hidden in modals"]})]})]}),ee&&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(Es,{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:ee})]}),s.jsx("button",{onClick:()=>he(null),className:"ml-auto text-bambu-green/70 hover:text-bambu-green",children:s.jsx(Gt,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[Ie.map(se=>s.jsxs("button",{onClick:()=>ce(se),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:se.name}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:se.description})]},se.id)),Ie.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:ie.slice(0,10).map(se=>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:se.label}),s.jsx("div",{className:"w-48",children:et(se)})]},se.key))})]}),Object.keys(x).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(x).filter(([se])=>se!=="inherits").map(([se,ye])=>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:[se,": ",String(ye).slice(0,20),s.jsx("button",{onClick:()=>I(se,void 0),className:"hover:text-white",children:s.jsx(Gt,{className:"w-3 h-3"})})]},se))})]})]}),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:Re?`${ie.length} fields`:"Loading..."})]}),s.jsxs("div",{className:"relative mb-3 flex-shrink-0",children:[s.jsx(Sa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:k,onChange:se=>C(se.target.value),placeholder:"Search fields...",className:"w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto space-y-1 pr-2 min-h-0",children:[X.filter(se=>!(se.key in x)).map(se=>{const ye=De[se.key],Ce=Ke(ye);return s.jsxs("div",{onClick:()=>{y(Ue=>({...Ue,[se.key]:Ce||""}))},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:se.label}),s.jsx("p",{className:"text-xs text-bambu-gray-dark truncate",children:se.key})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[Ce&&s.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark px-2 py-0.5 rounded max-w-32 truncate",title:Ce,children:[Ce.slice(0,20),Ce.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(rr,{className:"w-4 h-4 text-bambu-gray group-hover:text-bambu-green transition-colors"})})]})]},se.key)}),X.filter(se=>!(se.key in x)).length===0&&s.jsx("p",{className:"text-center text-bambu-gray py-4 text-sm",children:k?"No matching fields":"All fields added"})]}),s.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:L?s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",value:R,onChange:se=>U(se.target.value),onKeyDown:se=>se.key==="Enter"&&$(),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(Me,{size:"sm",onClick:$,disabled:!R.trim(),children:s.jsx(rr,{className:"w-4 h-4"})}),s.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>{q(!1),U("")},children:s.jsx(Gt,{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(rr,{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(x).filter(se=>se!=="inherits").length," fields"]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto space-y-2 pr-2 min-h-0",children:[Object.entries(x).filter(([se])=>se!=="inherits").map(([se,ye])=>{const Ce=ie.find(Ue=>Ue.key===se);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:Ce?.label||se}),s.jsx("p",{className:"text-xs text-bambu-gray-dark",children:se})]}),s.jsx("button",{onClick:()=>I(se,void 0),className:"p-1 text-bambu-gray hover:text-red-400 transition-colors",children:s.jsx(Gt,{className:"w-4 h-4"})})]}),Ce?et(Ce):s.jsx("input",{type:"text",value:String(ye),onChange:Ue=>I(se,Ue.target.value),className:"w-full px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]},se)}),Object.keys(x).filter(se=>se!=="inherits").length===0&&s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx(Kz,{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(x).filter(se=>se!=="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(bs,{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:S,onChange:se=>le(se.target.value),className:`w-full h-80 px-3 py-2 bg-bambu-dark border rounded-lg text-white text-xs font-mono focus:outline-none resize-none ${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(Me,{variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),s.jsxs(Me,{onClick:()=>pe.mutate(),disabled:pe.isPending||!d.trim()||!a&&!m||!!N,className:"flex-1",children:[pe.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):a?s.jsx(bs,{className:"w-4 h-4"}):s.jsx(rr,{className:"w-4 h-4"}),a?"Save":e?"Duplicate":"Create"]})]})]})})]})}function iZe({settings:t,lastSyncTime:e,onRefresh:n,isRefreshing:r,printers:i}){const[a,o]=w.useState(""),[l,c]=w.useState("all"),[u,d]=w.useState("all"),[f,m]=w.useState("all"),[p,b]=w.useState("all"),[v,x]=w.useState("all"),[y,S]=w.useState("all"),[M,N]=w.useState(null),[A,k]=w.useState(!1),[C,D]=w.useState(!1),[T,R]=w.useState(null),[U,L]=w.useState(null),[q,j]=w.useState(null),[W,K]=w.useState(!1),[V,J]=w.useState([null,null]),[ne,te]=w.useState(!1),[z,H]=w.useState(null),Z=ln(),ee=w.useMemo(()=>[...t.filament.map(X=>({...X,type:"filament"})),...t.printer.map(X=>({...X,type:"printer"})),...t.process.map(X=>({...X,type:"process"}))].map(X=>({...X,meta:gI(X.name)})),[t]),he=w.useMemo(()=>{const ie=new Set,X=new Set,$=new Set;return ee.forEach(I=>{I.meta.nozzle&&ie.add(I.meta.nozzle),I.meta.filamentType&&X.add(I.meta.filamentType),I.meta.layerHeight&&$.add(I.meta.layerHeight)}),{printers:i.map(I=>({id:I.id.toString(),name:I.name})),nozzles:Array.from(ie).sort((I,ce)=>parseFloat(I)-parseFloat(ce)),filaments:Array.from(X).sort(),layerHeights:Array.from($).sort((I,ce)=>parseFloat(I)-parseFloat(ce))}},[ee,i]),fe=w.useMemo(()=>f==="all"?null:i.find(X=>X.id.toString()===f)?.model||null,[f,i]),oe=w.useMemo(()=>ee.filter(ie=>l==="all"||ie.type===l).filter(ie=>{if(u==="all")return!0;const X=py(ie.setting_id);return u==="custom"?X:!X}).filter(ie=>{if(f==="all"||!fe)return!0;const X=ie.meta.printer?.toLowerCase()||"",$=fe.toLowerCase();return X.includes($)||$.includes(X)}).filter(ie=>p==="all"||ie.meta.nozzle===p).filter(ie=>v==="all"||ie.meta.filamentType===v).filter(ie=>y==="all"||ie.meta.layerHeight===y).filter(ie=>a===""||ie.name.toLowerCase().includes(a.toLowerCase())).sort((ie,X)=>ie.name.localeCompare(X.name)),[ee,l,u,f,fe,p,v,y,a]),Ne=ie=>{if(W){const X=V[0]?.setting_id===ie.setting_id,$=V[1]?.setting_id===ie.setting_id;if(X)J([V[1],null]);else if($)J([V[0],null]);else if(!V[0])J([ie,null]);else if(V[1]){if(V[0].type!==ie.type)return;J([V[0],ie])}else{if(V[0].type!==ie.type)return;J([V[0],ie])}}else N(ie)},ge=ie=>{if(V[0]?.setting_id===ie.setting_id)return 0;if(V[1]?.setting_id===ie.setting_id)return 1},Se=async ie=>{try{const X=await me.getCloudSettingDetail(ie.setting_id),$=ie.type==="process"?"print":ie.type;R({type:$,name:ie.name,base_id:X.base_id||"GFSA00",setting:X.setting||{}}),N(null)}catch(X){console.error("Failed to fetch preset details for duplication:",X)}},Re=async ie=>{try{Z.removeQueries({queryKey:["cloudSettingDetail",ie.setting_id]});const X=await me.getCloudSettingDetail(ie.setting_id),$=ie.type==="process"?"print":ie.type;L({type:$,name:ie.name,base_id:X.base_id||"GFSA00",setting:X.setting||{},setting_id:ie.setting_id}),N(null)}catch(X){console.error("Failed to fetch preset details for editing:",X)}},de=()=>{c("all"),d("all"),m("all"),b("all"),x("all"),S("all"),o("")},Qe=l!=="all"||u!=="all"||f!=="all"||p!=="all"||v!=="all"||y!=="all"||a!=="",G=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(Sa,{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:ie=>o(ie.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(Me,{variant:W?"primary":"secondary",onClick:()=>{W?(K(!1),J([null,null])):K(!0)},children:[s.jsx(Zp,{className:"w-4 h-4"}),W?"Cancel":"Compare"]}),s.jsxs(Me,{variant:"secondary",onClick:()=>D(!0),children:[s.jsx(T0,{className:"w-4 h-4"}),"Templates"]}),s.jsxs(Me,{variant:"secondary",onClick:n,disabled:r,children:[s.jsx(Ar,{className:`w-4 h-4 ${r?"animate-spin":""}`}),"Refresh"]}),s.jsxs(Me,{onClick:()=>k(!0),children:[s.jsx(rr,{className:"w-4 h-4"}),"New Preset"]})]})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(rE,{className:"w-4 h-4 text-bambu-gray"}),s.jsx(Lp,{label:"Type",value:l,options:[{value:"all",label:"All",count:G},{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:ie=>c(ie)}),s.jsx(Lp,{label:"Owner",value:u,options:[{value:"all",label:"All"},{value:"custom",label:"My Presets"},{value:"builtin",label:"Built-in"}],onChange:ie=>d(ie)}),he.printers.length>0&&s.jsx(Lp,{label:"Printer",value:f,options:[{value:"all",label:"All"},...he.printers.map(ie=>({value:ie.id,label:ie.name}))],onChange:m}),he.nozzles.length>0&&s.jsx(Lp,{label:"Nozzle",value:p,options:[{value:"all",label:"All"},...he.nozzles.map(ie=>({value:ie,label:ie}))],onChange:b}),he.filaments.length>0&&(l==="all"||l==="filament")&&s.jsx(Lp,{label:"Filament",value:v,options:[{value:"all",label:"All"},...he.filaments.map(ie=>({value:ie,label:ie}))],onChange:x}),he.layerHeights.length>0&&(l==="all"||l==="process")&&s.jsx(Lp,{label:"Layer",value:y,options:[{value:"all",label:"All"},...he.layerHeights.map(ie=>({value:ie,label:ie}))],onChange:S}),Qe&&s.jsx("button",{onClick:de,className:"px-3 py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:"Clear filters"})]})]}),W&&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(Zp,{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(hP,{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(Me,{size:"sm",onClick:async()=>{try{const[ie,X]=await Promise.all([me.getCloudSettingDetail(V[0].setting_id),me.getCloudSettingDetail(V[1].setting_id)]);H([ie.setting||{},X.setting||{}]),te(!0)}catch{}},children:[s.jsx(Zp,{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(Jn,{className:"w-3 h-3"}),"Last synced: ",QYe(e.toISOString())]}),s.jsxs("span",{children:["Showing ",oe.length," of ",G," 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)"})]})]}),oe.length===0?s.jsxs("div",{className:"text-center py-16",children:[s.jsx(sl,{className:"w-12 h-12 text-bambu-gray-dark mx-auto mb-4"}),s.jsx("p",{className:"text-bambu-gray",children:"No presets found"}),Qe&&s.jsx("button",{onClick:de,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(LD,{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:["(",oe.filter(ie=>ie.type==="filament").length,")"]})]}),s.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[oe.filter(ie=>ie.type==="filament").map(ie=>s.jsx(qj,{setting:ie,onClick:()=>Ne(ie),onDuplicate:()=>Se(ie),compareMode:W,isCompareSelected:ge(ie)!==void 0,compareIndex:ge(ie),compareDisabled:W&&!!V[0]&&V[0].type!==ie.type},ie.setting_id)),oe.filter(ie=>ie.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(Kd,{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:["(",oe.filter(ie=>ie.type==="process").length,")"]})]}),s.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[oe.filter(ie=>ie.type==="process").map(ie=>s.jsx(qj,{setting:ie,onClick:()=>Ne(ie),onDuplicate:()=>Se(ie),compareMode:W,isCompareSelected:ge(ie)!==void 0,compareIndex:ge(ie),compareDisabled:W&&!!V[0]&&V[0].type!==ie.type},ie.setting_id)),oe.filter(ie=>ie.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(Wr,{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:["(",oe.filter(ie=>ie.type==="printer").length,")"]})]}),s.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[oe.filter(ie=>ie.type==="printer").map(ie=>s.jsx(qj,{setting:ie,onClick:()=>Ne(ie),onDuplicate:()=>Se(ie),compareMode:W,isCompareSelected:ge(ie)!==void 0,compareIndex:ge(ie),compareDisabled:W&&!!V[0]&&V[0].type!==ie.type},ie.setting_id)),oe.filter(ie=>ie.type==="printer").length===0&&s.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No printer presets"})]})]})]}),M&&s.jsx(tZe,{setting:M,onClose:()=>N(null),onDeleted:()=>N(null),onDuplicate:()=>Se(M),onEdit:()=>Re(M)}),(A||T||U||q)&&s.jsx(rZe,{onClose:()=>{k(!1),R(null),L(null),j(null)},initialData:U||T||(q?{type:q.type,name:"",base_id:"",setting:q.setting}:void 0),allPresets:t}),C&&s.jsx(nZe,{onClose:()=>D(!1),onApply:ie=>{j({type:ie.type,setting:ie.settings}),D(!1)}}),ne&&z&&V[0]&&V[1]&&s.jsx(Hie,{onClose:()=>{te(!1),H(null)},leftPreset:z[0],rightPreset:z[1],leftLabel:V[0].name,rightLabel:V[1].name})]})}function aZe(){const t=ln(),{showToast:e}=Yn(),[n,r]=w.useState("cloud"),[i,a]=w.useState(),{data:o,isLoading:l}=ft({queryKey:["cloudStatus"],queryFn:me.getCloudStatus}),{data:c=[]}=ft({queryKey:["printers"],queryFn:me.getPrinters}),{data:u,isLoading:d,refetch:f,dataUpdatedAt:m}=ft({queryKey:["cloudSettings"],queryFn:()=>me.getCloudSettings(),enabled:!!o?.is_authenticated,retry:!1,staleTime:1e3*60*5});w.useEffect(()=>{m&&a(new Date(m))},[m]);const p=pt({mutationFn:me.cloudLogout,onSuccess:()=>{t.invalidateQueries({queryKey:["cloudStatus"]}),t.removeQueries({queryKey:["cloudSettings"]}),e("Logged out")}}),b=()=>{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(mt,{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(eE,{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(iE,{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(Me,{variant:"secondary",size:"sm",onClick:()=>p.mutate(),disabled:p.isPending,children:[s.jsx(xP,{className:"w-4 h-4"}),"Logout"]})]}),o?.is_authenticated?d?s.jsx("div",{className:"flex items-center justify-center py-16",children:s.jsx(mt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):u?s.jsx(iZe,{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(Me,{onClick:()=>f(),children:"Retry"})]}):s.jsx(JYe,{onSuccess:b})]}),n==="kprofiles"&&s.jsx(ZYe,{}),s.jsx(eZe,{})]})}const Qb={Droplet:LD,Flame:Zde,Ruler:Cfe,Sparkles:T0,Square:cl,Cable:Wue,Wrench:Xd,Calendar:si,Timer:Ad,Cog:Mde,Fan:dK,Zap:Bf,Wind:EK,Thermometer:hE,Layers:sl,Box:Bs,Target:_K,RefreshCw:Ar,Settings:dE,Filter:rE,CircleDot:dde};function w0(t){return t&&Qb[t]||Xd}function Ip(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 Kj(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 sZe(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 oZe({item:t,onPerform:e,onToggle:n}){const r=w0(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 ${Ip(Math.abs(f),"days")}`:t.is_warning?`Due in ${Ip(f,"days")}`:`${Ip(f,"days")} left`}else return t.is_due?`Overdue by ${Ip(Math.abs(t.hours_until_due),"hours")}`:t.is_warning?`Due in ${Ip(t.hours_until_due,"hours")}`:`${Ip(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(si,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"})}),(()=>{const f=t.maintenance_type_wiki_url||sZe(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:m=>m.stopPropagation(),children:s.jsx(Gr,{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(Tn,{className:"w-3 h-3"}),t.is_warning&&!t.is_due&&s.jsx(Jn,{className:"w-3 h-3"}),!t.is_due&&!t.is_warning&&t.enabled&&s.jsx(Es,{className:"w-3 h-3"}),d()]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx(qn,{checked:t.enabled,onChange:f=>n(t.id,f)}),s.jsxs(Me,{size:"sm",variant:t.is_due?"primary":"secondary",onClick:()=>e(t.id),disabled:!t.enabled,className:"!px-3",children:[s.jsx(lm,{className:"w-3.5 h-3.5"}),"Reset"]})]})]})})}function lZe({overview:t,onPerform:e,onToggle:n,onSetHours:r}){const[i,a]=w.useState(!0),[o,l]=w.useState(!1),[c,u]=w.useState(t.total_print_hours.toFixed(1)),d=[...t.maintenance_items].sort((p,b)=>p.is_due&&!b.is_due?-1:!p.is_due&&b.is_due?1:p.is_warning&&!b.is_warning?-1:!p.is_warning&&b.is_warning?1:p.maintenance_type_id-b.maintenance_type_id),f=d.find(p=>p.enabled&&(p.is_due||p.is_warning)),m=()=>{const p=parseFloat(c);!isNaN(p)&&p>=0&&(r(t.printer_id,p),l(!1))};return s.jsxs(Nt,{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(Tn,{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(Jn,{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(Es,{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(du,{className:"w-4 h-4"}):s.jsx(Oi,{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(Ad,{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"&&m(),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(Me,{size:"sm",onClick:m,children:"Save"}),s.jsx(Me,{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(Uf,{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=w0(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(Ct,{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(oZe,{item:p,onPerform:e,onToggle:n},p.id))})})]})}function cZe({overview:t,types:e,onUpdateInterval:n,onAddType:r,onUpdateType:i,onDeleteType:a,onAssignType:o,onRemoveItem:l}){const[c,u]=w.useState(null),[d,f]=w.useState(""),[m,p]=w.useState("hours"),[b,v]=w.useState(!1),[x,y]=w.useState(""),[S,M]=w.useState("100"),[N,A]=w.useState("hours"),[k,C]=w.useState("Wrench"),[D,T]=w.useState(""),[R,U]=w.useState(new Set),[L,q]=w.useState(null),j=w.useMemo(()=>t?t.map($=>({id:$.printer_id,name:$.printer_name})):[],[t]),W=$=>t?t.filter(I=>I.maintenance_items.some(ce=>ce.maintenance_type_id===$)).map(I=>({printerId:I.printer_id,printerName:I.printer_name,itemId:I.maintenance_items.find(ce=>ce.maintenance_type_id===$)?.id})):[],K=$=>{if(!t)return[];const I=new Set(W($).map(ce=>ce.printerId));return j.filter(ce=>!I.has(ce.id))},[V,J]=w.useState(null),[ne,te]=w.useState(""),[z,H]=w.useState(""),[Z,ee]=w.useState("hours"),[he,fe]=w.useState("Wrench"),[oe,Ne]=w.useState(""),ge=$=>{J($),te($.name),H($.default_interval_hours.toString()),ee($.interval_type||"hours"),fe($.icon||"Wrench"),Ne($.wiki_url||"")},Se=()=>{V&&ne.trim()&&parseFloat(z)>0&&(i(V.id,{name:ne.trim(),default_interval_hours:parseFloat(z),interval_type:Z,icon:he,wiki_url:oe.trim()||null}),J(null))},Re=($,I,ce)=>{const Ee=parseFloat(d);if(!isNaN(Ee)&&Ee>0){const Ie=Math.abs(Ee-I)<.01?null:Ee;n($,{custom_interval_hours:Ie,custom_interval_type:m!==ce?m:null})}u(null)},de=$=>{$.preventDefault(),x.trim()&&parseFloat(S)>0&&R.size>0&&(r({name:x.trim(),default_interval_hours:parseFloat(S),interval_type:N,icon:k,wiki_url:D.trim()||null},Array.from(R)),y(""),M("100"),A("hours"),T(""),U(new Set),v(!1))},Qe=$=>{U(I=>{const ce=new Set(I);return ce.has($)?ce.delete($):ce.add($),ce})},G=t?.map($=>({printerId:$.printer_id,printerName:$.printer_name,items:$.maintenance_items.sort((I,ce)=>I.maintenance_type_id-ce.maintenance_type_id)})).sort(($,I)=>$.printerName.localeCompare(I.printerName))||[],ie=e.filter($=>$.is_system),X=e.filter($=>!$.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(Me,{onClick:()=>v(!b),children:[s.jsx(rr,{className:"w-4 h-4"}),"Add Custom Type"]})]}),b&&s.jsx(Nt,{className:"mb-6",children:s.jsx(Ct,{className:"py-4",children:s.jsxs("form",{onSubmit:de,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:x,onChange:$=>y($.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:$=>{A($.target.value),$.target.value==="days"?M("30"):M("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:S,onChange:$=>M($.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(Qb).map($=>{const I=Qb[$];return s.jsx("button",{type:"button",onClick:()=>C($),className:`p-2 rounded-lg transition-colors ${k===$?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:s.jsx(I,{className:"w-4 h-4"})},$)})})]})}),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:D,onChange:$=>T($.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:j.map($=>s.jsx("button",{type:"button",onClick:()=>Qe($.id),className:`px-3 py-1.5 rounded-lg text-sm transition-colors ${R.has($.id)?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:$.name},$.id))}),R.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(Me,{type:"button",variant:"secondary",onClick:()=>{v(!1),U(new Set)},children:"Cancel"}),s.jsx(Me,{type:"submit",disabled:!x.trim()||R.size===0,children:"Add Type"})]})]})})}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[ie.map($=>{const I=w0($.icon),ce=$.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(I,{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:$.name}),s.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[ce==="days"?s.jsx(si,{className:"w-3 h-3"}):s.jsx(Ad,{className:"w-3 h-3"}),Kj($.default_interval_hours,ce)]})]})]})},$.id)}),X.map($=>{const I=w0($.icon),ce=$.interval_type||"hours";if(V?.id===$.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:ne,onChange:O=>te(O.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:Z,onChange:O=>ee(O.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:z,onChange:O=>H(O.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(Qb).map(O=>{const Y=Qb[O];return s.jsx("button",{type:"button",onClick:()=>fe(O),className:`p-1.5 rounded transition-colors ${he===O?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:s.jsx(Y,{className:"w-3.5 h-3.5"})},O)})}),s.jsx("input",{type:"url",value:oe,onChange:O=>Ne(O.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(Me,{size:"sm",onClick:Se,disabled:!ne.trim(),children:"Save"}),s.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>J(null),children:"Cancel"})]})]})},$.id);const Ie=W($.id),le=K($.id),B=L===$.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(I,{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:$.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(si,{className:"w-3 h-3"}):s.jsx(Ad,{className:"w-3 h-3"}),Kj($.default_interval_hours,ce)]})]}),s.jsxs("button",{onClick:()=>q(B?null:$.id),className:`px-2 py-1 rounded-lg border transition-colors flex items-center gap-1 ${Ie.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:`${Ie.length} printer(s) assigned - click to manage`,children:[s.jsx(Wr,{className:"w-3 h-3"}),s.jsx("span",{className:"text-xs font-medium",children:Ie.length}),s.jsx(Oi,{className:`w-3 h-3 transition-transform ${B?"rotate-180":""}`})]}),s.jsx("button",{onClick:()=>ge($),className:"p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",children:s.jsx(Uf,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>{confirm(`Delete "${$.name}"?`)&&a($.id)},className:"p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors",children:s.jsx(hn,{className:"w-4 h-4"})})]}),B&&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:"}),Ie.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:Ie.map(O=>s.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark rounded text-xs text-white",children:[O.printerName,s.jsx("button",{onClick:()=>O.itemId&&l(O.itemId),className:"hover:text-red-400 ml-1",title:"Remove from this printer",children:"×"})]},O.printerId))}),le.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:"}),le.map(O=>s.jsxs("button",{onClick:()=>o(O.id,$.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:["+ ",O.name]},O.id))]})]})]},$.id)})]})]}),G.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:G.map($=>s.jsx(Nt,{children:s.jsxs(Ct,{className:"py-4",children:[s.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:$.printerName}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:$.items.map(I=>{const ce=w0(I.maintenance_type_icon),Ee=e.find(Y=>Y.id===I.maintenance_type_id),Ie=Ee?.default_interval_hours||I.interval_hours,le=Ee?.interval_type||"hours",B=I.interval_type||"hours",O=c===I.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:I.maintenance_type_name}),O?s.jsxs("div",{className:"flex items-center gap-1",children:[m==="days"?s.jsx(si,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}):s.jsx(Ad,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}),s.jsxs("select",{value:m,onChange:Y=>p(Y.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:Y=>f(Y.target.value),onKeyDown:Y=>{Y.key==="Enter"&&Re(I.id,Ie,le),Y.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(Me,{size:"sm",onClick:()=>Re(I.id,Ie,le),children:"OK"})]}):s.jsxs("button",{onClick:()=>{u(I.id),f(I.interval_hours.toString()),p(B)},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:[B==="days"?s.jsx(si,{className:"w-3 h-3"}):s.jsx(Ad,{className:"w-3 h-3"}),Kj(I.interval_hours,B),s.jsx(Uf,{className:"w-3 h-3 text-bambu-gray"})]})]},I.id)})})]})},$.printerId))})]}),G.length===0&&s.jsx(Nt,{children:s.jsxs(Ct,{className:"text-center py-12",children:[s.jsx(Jn,{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 uZe(){const t=ln(),{showToast:e}=Yn(),[n,r]=w.useState("status"),{data:i,isLoading:a}=ft({queryKey:["maintenanceOverview"],queryFn:me.getMaintenanceOverview}),{data:o}=ft({queryKey:["maintenanceTypes"],queryFn:me.getMaintenanceTypes}),l=pt({mutationFn:({id:M,notes:N})=>me.performMaintenance(M,N),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Maintenance marked as complete")},onError:M=>{e(M.message,"error")}}),c=pt({mutationFn:({id:M,data:N})=>me.updateMaintenanceItem(M,N),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:M=>{e(M.message,"error")}}),u=pt({mutationFn:({id:M,data:N})=>me.updateMaintenanceType(M,N),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type updated")},onError:M=>{e(M.message,"error")}}),d=pt({mutationFn:me.deleteMaintenanceType,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type deleted")},onError:M=>{e(M.message,"error")}}),f=pt({mutationFn:({printerId:M,hours:N})=>me.setPrinterHours(M,N),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Print hours updated")},onError:M=>{e(M.message,"error")}}),m=pt({mutationFn:({printerId:M,typeId:N})=>me.assignMaintenanceType(M,N),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Printer assigned")},onError:M=>{e(M.message,"error")}}),p=pt({mutationFn:me.removeMaintenanceItem,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Printer removed")},onError:M=>{e(M.message,"error")}}),b=M=>{l.mutate({id:M})},v=(M,N)=>{c.mutate({id:M,data:{enabled:N}})},x=(M,N)=>{f.mutate({printerId:M,hours:N})};if(a)return s.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:s.jsx(mt,{className:"w-8 h-8 text-bambu-green animate-spin"})});const y=i?.reduce((M,N)=>M+N.due_count,0)||0,S=i?.reduce((M,N)=>M+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:[y>0&&s.jsxs("span",{className:"text-red-400",children:[y," task",y!==1?"s":""," overdue"]}),y>0&&S>0&&" · ",S>0&&s.jsxs("span",{className:"text-amber-400",children:[S," due soon"]}),y===0&&S===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((M,N)=>{const A=M.due_count*10+M.warning_count,k=N.due_count*10+N.warning_count;return A!==k?k-A:M.printer_name.localeCompare(N.printer_name)}).map(M=>s.jsx(lZe,{overview:M,onPerform:b,onToggle:v,onSetHours:x},M.printer_id)):s.jsx(Nt,{children:s.jsxs(Ct,{className:"text-center py-16",children:[s.jsx(Xd,{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(cZe,{overview:i,types:o||[],onUpdateInterval:(M,N)=>c.mutate({id:M,data:N}),onAddType:async(M,N)=>{const A=await me.createMaintenanceType(M);for(const k of N)await me.assignMaintenanceType(k,A.id);t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type added")},onUpdateType:(M,N)=>u.mutate({id:M,data:N}),onDeleteType:M=>d.mutate(M),onAssignType:(M,N)=>m.mutate({printerId:M,typeId:N}),onRemoveItem:M=>p.mutate(M)})]})}const dq=["#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#6b7280"];function Vie({project:t,onClose:e,onSave:n,isLoading:r}){const[i,a]=w.useState(t?.name||""),[o,l]=w.useState(t?.description||""),[c,u]=w.useState(t?.color||dq[0]),[d,f]=w.useState(t?.target_count?.toString()||""),[m,p]=w.useState(t?.target_parts_count?.toString()||""),[b,v]=w.useState(t?.status||"active"),[x,y]=w.useState(t?.tags||""),[S,M]=w.useState(t?.due_date?.split("T")[0]||""),[N,A]=w.useState(t?.priority||"normal"),k=C=>{C.preventDefault(),n({name:i.trim(),description:o.trim()||void 0,color:c,target_count:d?parseInt(d,10):void 0,target_parts_count:m?parseInt(m,10):void 0,tags:x.trim()||void 0,due_date:S||void 0,priority:N,...t&&{status:b}})};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:k,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:C=>a(C.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:C=>l(C.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:dq.map(C=>s.jsx("button",{type:"button",onClick:()=>u(C),className:`w-8 h-8 rounded-full transition-transform ${c===C?"ring-2 ring-white ring-offset-2 ring-offset-bambu-dark-secondary scale-110":""}`,style:{backgroundColor:C}},C))})]}),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:"Target Plates"}),s.jsx("input",{type:"number",value:d,onChange:C=>f(C.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., 25",min:"1"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Number of print jobs"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Target Parts"}),s.jsx("input",{type:"number",value:m,onChange:C=>p(C.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., 150",min:"1"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Total objects needed"})]})]}),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:C=>y(C.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:S,onChange:C=>M(C.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:N,onChange:C=>A(C.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:b,onChange:C=>v(C.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(Me,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(Me,{type:"submit",disabled:!i.trim()||r,children:r?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):t?"Save":"Create"})]})]})]})})}function dZe({project:t,onClick:e,onEdit:n,onDelete:r}){const i=t.target_count?Math.round(t.archive_count/t.target_count*100):0,a=t.target_parts_count?Math.round(t.completed_count/t.target_parts_count*100):0,o=t.status==="completed",l=t.status==="archived",[c,u]=w.useState(!1),f=o?{icon:JM,color:"text-bambu-green",bg:"bg-bambu-green/10"}:l?{icon:Ja,color:"text-bambu-gray",bg:"bg-bambu-gray/10"}:t.queue_count>0?{icon:Jn,color:"text-blue-400",bg:"bg-blue-400/10"}:{icon:Ea,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 ${f.bg} flex-shrink-0`,children:s.jsx(f.icon,{className:`w-5 h-5 ${f.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_parts_count?s.jsxs("span",{className:`text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium ${a>=100?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray"}`,children:[t.completed_count,"/",t.target_parts_count," parts"]}):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.archive_count,"/",t.target_count," plates"]}):t.completed_count>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.completed_count," parts"]}):null,o&&s.jsx("span",{className:"text-xs bg-bambu-green/20 text-bambu-green px-2 py-0.5 rounded-full whitespace-nowrap",children:"Done"}),l&&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 m=t.archives.map(x=>x.filament_type).filter(Boolean).flatMap(x=>x.split(",").map(y=>y.trim())).filter(Boolean),p=[...new Set(m)],b=t.archives.map(x=>x.filament_color).filter(Boolean).flatMap(x=>x.split(",").map(y=>y.trim())).filter(x=>x.startsWith("#")||/^[0-9A-Fa-f]{6}$/.test(x)),v=[...new Set(b)];return p.length===0&&v.length===0?null:s.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[p.slice(0,3).map(x=>s.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-bambu-dark text-bambu-gray rounded",children:x},x)),v.length>0&&s.jsxs("div",{className:"flex items-center gap-0.5",children:[v.slice(0,5).map(x=>s.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:x.startsWith("#")?x:`#${x}`},title:x},x)),v.length>5&&s.jsxs("span",{className:"text-[10px] text-bambu-gray ml-0.5",children:["+",v.length-5]})]})]})})()]})]}),s.jsxs("div",{className:"relative",onClick:m=>m.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:()=>u(!c),children:s.jsx(Ld,{className:"w-4 h-4"})}),c&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>u(!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(),u(!1)},children:[s.jsx(Uf,{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(),u(!1)},children:[s.jsx(hn,{className:"w-4 h-4"}),"Delete"]})]})]})]})]}),s.jsx("div",{className:"mb-4",children:t.target_count||t.target_parts_count?s.jsxs("div",{className:"space-y-3",children:[t.target_count&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between text-xs mb-1",children:[s.jsx("span",{className:"text-bambu-gray",children:"Plates"}),s.jsxs("span",{className:i>=100?"text-bambu-green font-medium":"text-white",children:[t.archive_count," / ",t.target_count]})]}),s.jsx("div",{className:"h-2 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`}})})]}),t.target_parts_count&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between text-xs mb-1",children:[s.jsx("span",{className:"text-bambu-gray",children:"Parts"}),s.jsxs("span",{className:a>=100?"text-bambu-green font-medium":"text-white",children:[t.completed_count," / ",t.target_parts_count]})]}),s.jsx("div",{className:"h-2 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(a,100)}%`,background:a>=100?"linear-gradient(90deg, #22c55e, #4ade80)":`linear-gradient(90deg, ${t.color||"#6b7280"}, ${t.color||"#6b7280"}cc)`,boxShadow:`0 0 8px ${a>=100?"#22c55e":t.color||"#6b7280"}60`}})})]}),t.failed_count>0&&s.jsxs("div",{className:"text-xs text-red-400",children:[t.failed_count," failed"]})]}):t.completed_count>0||t.failed_count>0?s.jsxs("div",{className:"flex items-center gap-4 text-xs",children:[t.completed_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[s.jsx(Ja,{className:"w-3.5 h-3.5"}),s.jsxs("span",{children:[t.completed_count," completed"]})]}),t.failed_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-red-400",children:[s.jsx(Tn,{className:"w-3.5 h-3.5"}),s.jsxs("span",{children:[t.failed_count," failed"]})]}),t.queue_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-blue-400",children:[s.jsx(Jn,{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(m=>s.jsxs("div",{className:"relative aspect-square rounded-lg bg-bambu-dark overflow-hidden border border-bambu-dark-tertiary",title:m.print_name||"Unknown",children:[m.thumbnail_path?s.jsx("img",{src:me.getArchiveThumbnail(m.id),alt:m.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(Ql,{className:"w-6 h-6"})}),m.status==="failed"&&s.jsx("div",{className:"absolute inset-0 bg-red-500/40 flex items-center justify-center",children:s.jsx(Tn,{className:"w-4 h-4 text-white"})})]},m.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:"Print jobs (plates)",children:[s.jsx(sl,{className:"w-3.5 h-3.5 text-blue-400"}),s.jsxs("span",{children:[t.archive_count," plates"]})]}),s.jsxs("div",{className:"flex items-center gap-1.5",title:"Parts printed",children:[s.jsx(Ql,{className:"w-3.5 h-3.5 text-bambu-green"}),s.jsxs("span",{children:[t.completed_count," parts"]})]}),t.failed_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-red-400",title:"Failed parts",children:[s.jsx(Tn,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:t.failed_count})]}),t.queue_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-yellow-400",title:"In queue",children:[s.jsx(gP,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:t.queue_count})]})]}),s.jsx(Zs,{className:"w-4 h-4 text-bambu-gray/50 group-hover:text-bambu-gray transition-colors"})]})]})]})}function hZe(){const t=pl(),e=ln(),{showToast:n}=Yn(),[r,i]=w.useState(!1),[a,o]=w.useState(),[l,c]=w.useState("active"),[u,d]=w.useState(null),{data:f,isLoading:m}=ft({queryKey:["projects",l==="all"?void 0:l],queryFn:()=>me.getProjects(l==="all"?void 0:l)}),p=pt({mutationFn:U=>me.createProject(U),onSuccess:()=>{e.invalidateQueries({queryKey:["projects"]}),i(!1),n("Project created","success")},onError:U=>{n(U.message,"error")}}),b=pt({mutationFn:({id:U,data:L})=>me.updateProject(U,L),onSuccess:()=>{e.invalidateQueries({queryKey:["projects"]}),i(!1),o(void 0),n("Project updated","success")},onError:U=>{n(U.message,"error")}}),v=pt({mutationFn:U=>me.deleteProject(U),onSuccess:()=>{d(null),n("Project deleted","success"),setTimeout(()=>window.location.reload(),100)},onError:U=>{d(null),n(U.message,"error")}}),x=pt({mutationFn:U=>me.importProject(U),onSuccess:()=>{e.invalidateQueries({queryKey:["projects"]}),n("Project imported","success")},onError:U=>{n(U.message,"error")}}),y=w.useRef(null),S=async()=>{try{const U=await me.getProjects(),L=await Promise.all(U.map(async K=>await me.exportProjectJson(K.id))),q=new Blob([JSON.stringify(L,null,2)],{type:"application/json"}),j=URL.createObjectURL(q),W=document.createElement("a");W.href=j,W.download=`bambuddy_projects_${new Date().toISOString().split("T")[0]}.json`,W.click(),URL.revokeObjectURL(j),n("Projects exported (metadata only)","success")}catch(U){n(U.message,"error")}},M=()=>{y.current?.click()},N=async U=>{const L=U.target.files?.[0];if(L){try{if(L.name.toLowerCase().endsWith(".zip")){const j=new FormData;j.append("file",L);const W=await fetch("/api/v1/projects/import/file",{method:"POST",body:j});if(!W.ok){const K=await W.json();throw new Error(K.detail||"Import failed")}e.invalidateQueries({queryKey:["projects"]}),n("Project imported","success")}else{const j=await L.text(),W=JSON.parse(j),K=Array.isArray(W)?W:[W];for(const V of K)await x.mutateAsync(V);K.length>1&&n(`${K.length} projects imported`,"success")}}catch(q){n(`Import failed: ${q.message}`,"error")}U.target.value=""}},A=U=>{a?b.mutate({id:a.id,data:U}):p.mutate(U)},k=U=>{o(U),i(!0)},C=U=>{t(`/projects/${U.id}`)},D=U=>{d(U)},T=()=>{u!==null&&v.mutate(u)},R=f?.reduce((U,L)=>(U[L.status]=(U[L.status]||0)+1,U.all=(U.all||0)+1,U),{})||{};return s.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[s.jsx("input",{ref:y,type:"file",accept:".json,.zip",onChange:N,className:"hidden"}),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(Ea,{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("div",{className:"flex gap-2",children:[s.jsxs(Me,{variant:"secondary",onClick:M,title:"Import project",children:[s.jsx(fi,{className:"w-4 h-4 mr-2"}),"Import"]}),s.jsxs(Me,{variant:"secondary",onClick:S,title:"Export all projects",children:[s.jsx($r,{className:"w-4 h-4 mr-2"}),"Export"]}),s.jsxs(Me,{onClick:()=>i(!0),className:"sm:w-auto w-full",children:[s.jsx(rr,{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:Jn},{key:"completed",label:"Completed",icon:JM},{key:"archived",label:"Archived",icon:Ja},{key:"all",label:"All",icon:Ea}].map(({key:U,label:L,icon:q})=>s.jsxs("button",{onClick:()=>c(U),className:`flex items-center gap-2 px-4 py-2 text-sm rounded-lg transition-all ${l===U?"bg-bambu-card text-white shadow-sm":"text-bambu-gray hover:text-white"}`,children:[s.jsx(q,{className:"w-4 h-4"}),s.jsx("span",{children:L}),R[U]>0&&s.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${l===U?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark-tertiary"}`,children:R[U]})]},U))}),m?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(mt,{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(Ea,{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(Me,{onClick:()=>i(!0),children:[s.jsx(rr,{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(U=>s.jsx(dZe,{project:U,onClick:()=>C(U),onEdit:()=>k(U),onDelete:()=>D(U.id)},U.id))}),u!==null&&s.jsx(zn,{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:T,onCancel:()=>d(null)}),r&&s.jsx(Vie,{project:a,onClose:()=>{i(!1),o(void 0)},onSave:A,isLoading:p.isPending||b.isPending})]})}function fZe(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 mZe(t){return t>=1e3?`${(t/1e3).toFixed(2)}kg`:`${Math.round(t)}g`}function pZe({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 hq({icon:t,label:e,value:n,subValue:r,hint:i,color:a="text-bambu-gray"}){return s.jsx(Nt,{children:s.jsx(Ct,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",title:i,children:[s.jsx("div",{className:`p-2 rounded-lg bg-bambu-dark ${a}`,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 gZe({archives:t}){return t.length===0?s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx(Ql,{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(ps,{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:me.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(Ql,{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(za,{className:"w-8 h-8 text-white"})}),e.status==="completed"&&s.jsx("div",{className:"absolute top-1 right-1",children:s.jsx(Hn,{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 xZe({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(Tn,{className:"w-3 h-3"}),r]})}function bZe(t){return t?xg(t,{year:"numeric",month:"short",day:"numeric"}):""}function Xj(t){if(!t)return null;const e=Si(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 yZe(){const{id:t}=MD(),e=pl(),n=ln(),{showToast:r}=Yn(),[i,a]=w.useState(!1),[o,l]=w.useState(!1),[c,u]=w.useState(""),d=parseInt(t||"0",10),{data:f,isLoading:m,error:p}=ft({queryKey:["project",d],queryFn:()=>me.getProject(d),enabled:d>0}),{data:b,isLoading:v}=ft({queryKey:["project-archives",d],queryFn:()=>me.getProjectArchives(d),enabled:d>0}),{data:x,isLoading:y}=ft({queryKey:["project-bom",d],queryFn:()=>me.getProjectBOM(d),enabled:d>0}),{data:S,isLoading:M}=ft({queryKey:["project-timeline",d],queryFn:()=>me.getProjectTimeline(d,20),enabled:d>0}),{data:N}=ft({queryKey:["settings"],queryFn:me.getSettings}),{data:A}=ft({queryKey:["project-folders",d],queryFn:()=>me.getLibraryFoldersByProject(d),enabled:d>0}),k=N?.currency||"$",C=N?.time_format||"system",D=pt({mutationFn:ye=>me.updateProject(d,ye),onSuccess:()=>{n.invalidateQueries({queryKey:["project",d]}),n.invalidateQueries({queryKey:["projects"]}),a(!1),l(!1),r("Project updated","success")},onError:ye=>{r(ye.message,"error")}}),T=()=>{u(f?.notes||""),l(!0)},R=()=>{D.mutate({notes:c})},U=()=>{l(!1),u("")},[L,q]=w.useState(""),[j,W]=w.useState(1),[K,V]=w.useState(""),[J,ne]=w.useState(""),[te,z]=w.useState(""),[H,Z]=w.useState(!1),[ee,he]=w.useState(!1),[fe,oe]=w.useState(null),[Ne,ge]=w.useState(""),[Se,Re]=w.useState(1),[de,Qe]=w.useState(""),[G,ie]=w.useState(""),[X,$]=w.useState(""),[I,ce]=w.useState({isOpen:!1,title:"",message:"",onConfirm:()=>{}}),Ee=pt({mutationFn:ye=>me.createBOMItem(d,ye),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",d]}),n.invalidateQueries({queryKey:["project",d]}),q(""),W(1),V(""),ne(""),z(""),Z(!1),r("Part added","success")},onError:ye=>r(ye.message,"error")}),Ie=pt({mutationFn:({itemId:ye,data:Ce})=>me.updateBOMItem(d,ye,Ce),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",d]}),n.invalidateQueries({queryKey:["project",d]}),oe(null)},onError:ye=>r(ye.message,"error")}),le=pt({mutationFn:ye=>me.deleteBOMItem(d,ye),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",d]}),n.invalidateQueries({queryKey:["project",d]}),r("Part removed","success")},onError:ye=>r(ye.message,"error")}),B=ye=>{ye.preventDefault(),L.trim()&&Ee.mutate({name:L.trim(),quantity_needed:j,unit_price:K?parseFloat(K):void 0,sourcing_url:J.trim()||void 0,remarks:te.trim()||void 0})},O=ye=>{const Ce=ye.is_complete?0:ye.quantity_needed;Ie.mutate({itemId:ye.id,data:{quantity_acquired:Ce}})},Y=(ye,Ce)=>{ce({isOpen:!0,title:"Delete Part",message:`Are you sure you want to delete "${Ce}"?`,onConfirm:()=>{ce(Ue=>({...Ue,isOpen:!1})),le.mutate(ye)}})},pe=ye=>{oe(ye),ge(ye.name),Re(ye.quantity_needed),Qe(ye.unit_price?.toString()||""),ie(ye.sourcing_url||""),$(ye.remarks||"")},we=ye=>{ye.preventDefault(),!(!fe||!Ne.trim())&&Ie.mutate({itemId:fe.id,data:{name:Ne.trim(),quantity_needed:Se,unit_price:de?parseFloat(de):void 0,sourcing_url:G.trim()||void 0,remarks:X.trim()||void 0}})},ae=()=>{oe(null)},ke=async()=>{try{const ye=await fetch(`/api/v1/projects/${d}/export`);if(!ye.ok)throw new Error("Export failed");const Ce=await ye.blob(),Ue=URL.createObjectURL(Ce),dt=document.createElement("a");dt.href=Ue;const Fe=ye.headers.get("Content-Disposition")?.match(/filename="(.+)"/);dt.download=Fe?.[1]||`${f?.name||"project"}_${new Date().toISOString().split("T")[0]}.zip`,dt.click(),URL.revokeObjectURL(Ue),r("Project exported","success")}catch(ye){r(ye.message,"error")}},De=pt({mutationFn:()=>me.createTemplateFromProject(d),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),r("Template created","success")},onError:ye=>r(ye.message,"error")}),Ke=ye=>bg(ye,C,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});if(m)return s.jsx("div",{className:"flex items-center justify-center py-24",children:s.jsx(mt,{className:"w-8 h-8 animate-spin text-bambu-green"})});if(p||!f)return s.jsxs("div",{className:"text-center py-24",children:[s.jsx("p",{className:"text-bambu-gray",children:p?`Error: ${p.message}`:"Project not found"}),s.jsx(Me,{variant:"secondary",className:"mt-4",onClick:()=>e("/projects"),children:"Back to Projects"})]});const et=f.stats,Ye=et?.progress_percent??0,se=et?.parts_progress_percent??0;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(ps,{to:"/projects",className:"hover:text-white transition-colors",children:"Projects"}),s.jsx(Zs,{className:"w-4 h-4"}),s.jsx("span",{className:"text-white",children:f.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(oK,{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:f.color||"#6b7280"}}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:f.name}),f.description&&s.jsx("p",{className:"text-bambu-gray mt-1",children:f.description})]})]}),s.jsx(pZe,{status:f.status})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Me,{variant:"secondary",onClick:ke,title:"Export project",children:[s.jsx($r,{className:"w-4 h-4 mr-2"}),"Export"]}),s.jsxs(Me,{onClick:()=>a(!0),children:[s.jsx(Uf,{className:"w-4 h-4 mr-2"}),"Edit"]})]})]}),(f.target_count||f.target_parts_count)&&s.jsx(Nt,{children:s.jsxs(Ct,{className:"p-4 space-y-4",children:[f.target_count&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:"Plates Progress"}),s.jsxs("span",{className:"text-sm font-medium text-white",children:[et?.total_archives||0," / ",f.target_count," print jobs"]})]}),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(Ye,100)}%`,backgroundColor:Ye>=100?"#22c55e":f.color||"#6b7280"}})}),s.jsxs("div",{className:"flex justify-between mt-1",children:[s.jsxs("span",{className:"text-xs text-bambu-gray/70",children:[Ye.toFixed(0),"% complete"]}),et?.remaining_prints!=null&&et.remaining_prints>0&&s.jsxs("span",{className:"text-xs text-bambu-gray/70",children:[et.remaining_prints," remaining"]})]})]}),f.target_parts_count&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:"Parts Progress"}),s.jsxs("span",{className:"text-sm font-medium text-white",children:[et?.completed_prints||0," / ",f.target_parts_count," parts"]})]}),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(se,100)}%`,backgroundColor:se>=100?"#22c55e":f.color||"#6b7280"}})}),s.jsxs("div",{className:"flex justify-between mt-1",children:[s.jsxs("span",{className:"text-xs text-bambu-gray/70",children:[se.toFixed(0),"% complete"]}),et?.remaining_parts!=null&&et.remaining_parts>0&&s.jsxs("span",{className:"text-xs text-bambu-gray/70",children:[et.remaining_parts," remaining"]})]})]})]})}),et&&s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsx(Nt,{children:s.jsx(Ct,{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 text-bambu-green",children:s.jsx(Ql,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Print Jobs"}),s.jsxs("p",{className:"text-xl font-semibold text-white",children:[et.total_archives," ",s.jsx("span",{className:"text-sm font-normal text-bambu-gray",children:"total"})]}),et.failed_prints>0&&s.jsxs("p",{className:"text-sm text-status-error",children:[et.failed_prints," failed"]}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:[et.completed_prints," parts printed"]})]})]})})}),s.jsx(hq,{icon:Jn,label:"Print Time",value:fZe(et.total_print_time_hours),color:"text-yellow-400"}),s.jsx(hq,{icon:Wr,label:"Filament Used",value:mZe(et.total_filament_grams),color:"text-purple-400"})]}),et&&(et.estimated_cost>0||f.budget)&&s.jsx(Nt,{children:s.jsxs(Ct,{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:[k,et.estimated_cost.toFixed(2)]})]}),et.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:[et.total_energy_kwh.toFixed(2)," kWh",et.total_energy_cost>0&&s.jsxs("span",{className:"text-sm text-bambu-gray ml-1",children:["(",k,et.total_energy_cost.toFixed(2),")"]})]})]}),f.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:[k,f.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 ${f.budget-et.estimated_cost>=0?"text-bambu-green":"text-red-400"}`,children:[k,(f.budget-et.estimated_cost).toFixed(2)]})]})]})]})]})}),f.children&&f.children.length>0&&s.jsx(Nt,{children:s.jsxs(Ct,{className:"p-4",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-3",children:[s.jsx(rhe,{className:"w-5 h-5"}),"Sub-projects (",f.children.length,")"]}),s.jsx("div",{className:"space-y-2",children:f.children.map(ye=>s.jsxs(ps,{to:`/projects/${ye.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:ye.color||"#6b7280"}}),s.jsx("span",{className:"text-white",children:ye.name}),s.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${ye.status==="completed"?"bg-status-ok/20 text-status-ok":ye.status==="archived"?"bg-bambu-gray/20 text-bambu-gray":"bg-blue-500/20 text-blue-400"}`,children:ye.status})]}),ye.progress_percent!==null&&s.jsxs("span",{className:"text-sm text-bambu-gray",children:[ye.progress_percent.toFixed(0),"%"]})]},ye.id))})]})}),f.parent_id&&f.parent_name&&s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(sl,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("span",{className:"text-bambu-gray",children:"Part of:"}),s.jsx(ps,{to:`/projects/${f.parent_id}`,className:"text-bambu-green hover:underline",children:f.parent_name})]}),(f.tags||f.due_date||f.priority!=="normal")&&s.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[f.priority&&f.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(xZe,{priority:f.priority})]}),f.due_date&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(si,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("span",{className:"text-sm text-white",children:bZe(f.due_date)}),Xj(f.due_date)&&s.jsxs("span",{className:`text-xs ${Xj(f.due_date).color}`,children:["(",Xj(f.due_date).label,")"]})]}),f.tags&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(gg,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("div",{className:"flex flex-wrap gap-1",children:f.tags.split(",").map((ye,Ce)=>s.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark-tertiary text-bambu-gray text-xs rounded",children:ye.trim()},Ce))})]})]}),s.jsx(Nt,{children:s.jsxs(Ct,{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(Ya,{className:"w-5 h-5"}),"Notes"]}),o?s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Me,{variant:"secondary",size:"sm",onClick:U,disabled:D.isPending,children:[s.jsx(Gt,{className:"w-4 h-4 mr-1"}),"Cancel"]}),s.jsxs(Me,{size:"sm",onClick:R,disabled:D.isPending,children:[D.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin mr-1"}):s.jsx(bs,{className:"w-4 h-4 mr-1"}),"Save"]})]}):s.jsxs(Me,{variant:"secondary",size:"sm",onClick:T,children:[s.jsx(Uf,{className:"w-4 h-4 mr-1"}),"Edit"]})]}),o?s.jsx(dD,{content:c,onChange:u,placeholder:"Add notes about this project..."}):f.notes?s.jsx("div",{className:"prose prose-invert prose-sm max-w-none",dangerouslySetInnerHTML:{__html:f.notes}}):s.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No notes yet. Click Edit to add notes."})]})}),s.jsx(Nt,{children:s.jsxs(Ct,{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(al,{className:"w-5 h-5"}),"Files"]})}),s.jsxs("p",{className:"text-xs text-bambu-gray mb-3",children:[s.jsx(ps,{to:"/files",className:"text-bambu-green hover:underline",children:"Link folders from the File Manager"})," ","to this project for quick access."]}),A&&A.length>0?s.jsx("div",{className:"space-y-2",children:A.map(ye=>s.jsxs(ps,{to:`/files?folder=${ye.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 min-w-0",children:[s.jsx(al,{className:"w-5 h-5 text-bambu-green flex-shrink-0"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-sm text-white truncate",children:ye.name}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[ye.file_count," file",ye.file_count!==1?"s":""]})]})]}),s.jsx(Zs,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"})]},ye.id))}):s.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No folders linked. Go to File Manager and link a folder to this project."})]})}),s.jsx(Nt,{children:s.jsxs(Ct,{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(yK,{className:"w-5 h-5"}),"Bill of Materials",et&&et.bom_total_items>0&&s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",et.bom_completed_items,"/",et.bom_total_items," acquired)"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[x&&x.some(ye=>ye.is_complete)&&s.jsx("button",{onClick:()=>he(!ee),className:`text-xs px-2 py-1 rounded transition-colors ${ee?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:ee?"Show all":"Hide done"}),!H&&s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>Z(!0),children:[s.jsx(rr,{className:"w-4 h-4 mr-1"}),"Add Part"]})]})]}),H&&s.jsxs("form",{onSubmit:B,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:L,onChange:ye=>q(ye.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:ye=>W(parseInt(ye.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:K,onChange:ye=>V(ye.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 (${k})`})]})]}),s.jsx("input",{type:"url",value:J,onChange:ye=>ne(ye.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:te,onChange:ye=>z(ye.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(Me,{type:"button",variant:"secondary",size:"sm",onClick:()=>Z(!1),children:"Cancel"}),s.jsx(Me,{type:"submit",size:"sm",disabled:!L.trim()||Ee.isPending,children:Ee.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):"Add Part"})]})]}),y?s.jsx("div",{className:"flex items-center justify-center py-4",children:s.jsx(mt,{className:"w-6 h-6 animate-spin text-bambu-green"})}):x&&x.length>0?s.jsxs("div",{className:"space-y-2",children:[x.filter(ye=>!ee||!ye.is_complete).map(ye=>s.jsx("div",{className:`p-3 rounded-lg transition-colors ${ye.is_complete?"bg-status-ok/10":"bg-bambu-dark"}`,children:fe?.id===ye.id?s.jsxs("form",{onSubmit:we,className:"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:Ne,onChange:Ce=>ge(Ce.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",autoFocus:!0}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"number",value:Se,onChange:Ce=>Re(parseInt(Ce.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:de,onChange:Ce=>Qe(Ce.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 (${k})`})]})]}),s.jsx("input",{type:"url",value:G,onChange:Ce=>ie(Ce.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:X,onChange:Ce=>$(Ce.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(Me,{type:"button",variant:"secondary",size:"sm",onClick:ae,children:"Cancel"}),s.jsx(Me,{type:"submit",size:"sm",disabled:!Ne.trim()||Ie.isPending,children:Ie.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):"Save"})]})]}):s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("button",{onClick:()=>O(ye),disabled:Ie.isPending,className:`w-5 h-5 mt-0.5 rounded border-2 flex items-center justify-center transition-colors flex-shrink-0 ${ye.is_complete?"bg-status-ok border-status-ok text-white":"border-bambu-gray hover:border-bambu-green"}`,children:ye.is_complete&&s.jsx(Hn,{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 ${ye.is_complete?"text-bambu-gray line-through":"text-white"}`,children:[ye.name,s.jsxs("span",{className:"text-bambu-gray font-normal ml-2",children:["x",ye.quantity_needed]})]}),ye.unit_price!==null&&s.jsxs("span",{className:"text-xs text-bambu-green whitespace-nowrap",children:[k,(ye.unit_price*ye.quantity_needed).toFixed(2)]})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:()=>pe(ye),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors flex-shrink-0",title:"Edit",children:s.jsx(Na,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>Y(ye.id,ye.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(hn,{className:"w-4 h-4"})})]})]}),ye.sourcing_url&&s.jsxs("a",{href:ye.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:Ce=>Ce.stopPropagation(),children:[s.jsx(Gr,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:(()=>{try{return new URL(ye.sourcing_url).hostname.replace("www.","")}catch{return ye.sourcing_url}})()})]}),ye.remarks&&s.jsx("p",{className:"mt-1 text-xs text-bambu-gray/80 italic",children:ye.remarks})]})]})},ye.id)),x.some(ye=>ye.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:[k,x.reduce((ye,Ce)=>ye+(Ce.unit_price||0)*Ce.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(Nt,{children:s.jsxs(Ct,{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(Pw,{className:"w-5 h-5"}),"Activity Timeline"]})}),M?s.jsx("div",{className:"flex items-center justify-center py-4",children:s.jsx(mt,{className:"w-6 h-6 animate-spin text-bambu-green"})}):S&&S.length>0?s.jsx("div",{className:"space-y-3",children:S.slice(0,10).map((ye,Ce)=>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 ${ye.event_type==="print_completed"?"bg-status-ok/20 text-status-ok":ye.event_type==="print_failed"?"bg-status-error/20 text-status-error":ye.event_type==="print_started"?"bg-yellow-500/20 text-yellow-400":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:[ye.event_type==="print_completed"&&s.jsx(Hn,{className:"w-4 h-4"}),ye.event_type==="print_failed"&&s.jsx(za,{className:"w-4 h-4"}),ye.event_type==="print_started"&&s.jsx(Wr,{className:"w-4 h-4"}),ye.event_type==="queued"&&s.jsx(gP,{className:"w-4 h-4"}),ye.event_type==="project_created"&&s.jsx(rr,{className:"w-4 h-4"})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm text-white",children:ye.title}),ye.description&&s.jsx("p",{className:"text-xs text-bambu-gray truncate",children:ye.description}),s.jsx("p",{className:"text-xs text-bambu-gray/70",children:Ke(ye.timestamp)})]})]},Ce))}):s.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No activity yet."})]})}),!f.is_template&&s.jsx("div",{className:"flex justify-end",children:s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>De.mutate(),disabled:De.isPending,children:[De.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin mr-2"}):s.jsx(il,{className:"w-4 h-4 mr-2"}),"Save as Template"]})}),et&&(et.queued_prints>0||et.in_progress_prints>0)&&s.jsx(Nt,{children:s.jsxs(Ct,{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(gP,{className:"w-5 h-5"}),"Queue"]}),s.jsx(ps,{to:`/queue?project=${d}`,className:"text-sm text-bambu-green hover:underline",children:"View all"})]}),s.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[et.in_progress_prints>0&&s.jsxs("span",{className:"text-yellow-400",children:[et.in_progress_prints," printing"]}),et.queued_prints>0&&s.jsxs("span",{className:"text-bambu-gray",children:[et.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(Ql,{className:"w-5 h-5"}),"Prints (",b?.length||0,")"]})}),v?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(mt,{className:"w-6 h-6 animate-spin text-bambu-green"})}):s.jsx(gZe,{archives:b||[]})]}),i&&s.jsx(Vie,{project:{...f,archive_count:et?.total_archives||0,total_items:et?.total_items||0,completed_count:et?.completed_prints||0,failed_count:et?.failed_prints||0,queue_count:et?.queued_prints||0,progress_percent:et?.progress_percent||null,archives:[]},onClose:()=>a(!1),onSave:ye=>D.mutate(ye),isLoading:D.isPending}),I.isOpen&&s.jsx(zn,{title:I.title,message:I.message,confirmText:"Delete",variant:"danger",onConfirm:I.onConfirm,onCancel:()=>ce(ye=>({...ye,isOpen:!1}))})]})}function Vp(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(2)} GB`}function vZe(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 _Ze({parentId:t,onClose:e,onSave:n,isLoading:r}){const[i,a]=w.useState(""),o=l=>{l.preventDefault(),n({name:i.trim(),parent_id:t})};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-sm 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:"New Folder"})}),s.jsxs("form",{onSubmit:o,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:"Folder Name"}),s.jsx("input",{type:"text",value:i,onChange:l=>a(l.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., Functional Parts",autoFocus:!0,required:!0})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx(Me,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(Me,{type:"submit",disabled:!i.trim()||r,children:r?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):"Create"})]})]})]})})}function wZe({type:t,currentName:e,onClose:n,onSave:r,isLoading:i}){const[a,o]=w.useState(e),l=c=>{c.preventDefault(),a.trim()&&a.trim()!==e&&r(a.trim())};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-sm border border-bambu-dark-tertiary",children:[s.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:s.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Rename ",t==="file"?"File":"Folder"]})}),s.jsxs("form",{onSubmit:l,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:a,onChange:c=>o(c.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",autoFocus:!0,required:!0})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx(Me,{type:"button",variant:"secondary",onClick:n,children:"Cancel"}),s.jsx(Me,{type:"submit",disabled:!a.trim()||a.trim()===e||i,children:i?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):"Rename"})]})]})]})})}function SZe({folders:t,selectedFiles:e,currentFolderId:n,onClose:r,onMove:i,isLoading:a}){const[o,l]=w.useState(null),c=(d,f=0)=>{const m=[];for(const p of d)m.push({id:p.id,name:p.name,depth:f}),p.children.length>0&&m.push(...c(p.children,f+1));return m},u=[{id:null,name:"Root (No Folder)",depth:0},...c(t)];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-sm border border-bambu-dark-tertiary",children:[s.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:s.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Move ",e.length," File(s)"]})}),s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsx("div",{className:"max-h-64 overflow-y-auto space-y-1",children:u.map(d=>s.jsxs("button",{onClick:()=>l(d.id),disabled:d.id===n,className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${o===d.id?"bg-bambu-green/20 text-bambu-green":d.id===n?"opacity-50 cursor-not-allowed text-bambu-gray":"hover:bg-bambu-dark text-white"}`,style:{paddingLeft:`${12+d.depth*16}px`},children:[s.jsx(al,{className:"w-4 h-4"}),d.name,d.id===n&&s.jsx("span",{className:"text-xs text-bambu-gray ml-auto",children:"(current)"})]},d.id??"root"))}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx(Me,{type:"button",variant:"secondary",onClick:r,children:"Cancel"}),s.jsx(Me,{onClick:()=>i(o),disabled:a,children:a?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):"Move"})]})]})]})})}function MZe({folder:t,onClose:e,onLink:n,isLoading:r}){const[i,a]=w.useState("project"),[o,l]=w.useState(t.project_id||t.archive_id||null);w.useState(()=>{t.archive_id&&a("archive")});const{data:c}=ft({queryKey:["projects"],queryFn:()=>me.getProjects()}),{data:u}=ft({queryKey:["archives-for-link"],queryFn:()=>me.getArchives(void 0,void 0,100)}),d=()=>{n(i==="project"?{project_id:o,archive_id:0}:{project_id:0,archive_id:o})},f=()=>{n({project_id:0,archive_id:0})},m=t.project_id||t.archive_id;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.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Gl,{className:"w-5 h-5 text-bambu-green"}),"Link Folder"]}),s.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark rounded",children:s.jsx(Gt,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsxs("p",{className:"text-sm text-bambu-gray",children:['Link "',s.jsx("span",{className:"text-white",children:t.name}),'" to a project or archive for quick access.']}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("button",{onClick:()=>{a("project"),l(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${i==="project"?"border-bambu-green bg-bambu-green/10 text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:[s.jsx(cK,{className:"w-4 h-4"}),"Project"]}),s.jsxs("button",{onClick:()=>{a("archive"),l(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${i==="archive"?"border-bambu-green bg-bambu-green/10 text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:[s.jsx(Ja,{className:"w-4 h-4"}),"Archive"]})]}),s.jsx("div",{className:"max-h-64 overflow-y-auto space-y-1 bg-bambu-dark rounded-lg p-2",children:i==="project"?c&&c.length>0?c.map(p=>s.jsxs("button",{onClick:()=>l(p.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${o===p.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark-tertiary text-white"}`,children:[s.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:p.color||"#00ae42"}}),s.jsx("span",{className:"truncate",children:p.name})]},p.id)):s.jsx("p",{className:"text-sm text-bambu-gray text-center py-4",children:"No projects found"}):u&&u.length>0?u.map(p=>s.jsxs("button",{onClick:()=>l(p.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${o===p.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark-tertiary text-white"}`,children:[s.jsx(_f,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"truncate",children:p.print_name||p.filename})]},p.id)):s.jsx("p",{className:"text-sm text-bambu-gray text-center py-4",children:"No archives found"})})]}),s.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex justify-between",children:[m&&s.jsxs(Me,{variant:"danger",onClick:f,disabled:r,children:[s.jsx(BD,{className:"w-4 h-4 mr-2"}),"Unlink"]}),s.jsxs("div",{className:`flex gap-2 ${m?"":"ml-auto"}`,children:[s.jsx(Me,{variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(Me,{onClick:d,disabled:!o||r,children:r?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):"Link"})]})]})]})})}function EZe({folderId:t,onClose:e,onUploadComplete:n}){const[r,i]=w.useState([]),[a,o]=w.useState(!1),[l,c]=w.useState(!1),[u,d]=w.useState(!0),[f,m]=w.useState(!1),p=w.useRef(null),b=R=>{R.preventDefault(),o(!0)},v=R=>{R.preventDefault(),o(!1)},x=R=>{R.preventDefault(),o(!1);const U=Array.from(R.dataTransfer.files);S(U)},y=R=>{R.target.files&&S(Array.from(R.target.files))},S=R=>{const U=R.map(L=>({file:L,status:"pending",isZip:L.name.toLowerCase().endsWith(".zip")}));i(L=>[...L,...U])},M=R=>{i(U=>U.filter((L,q)=>q!==R))},N=r.some(R=>R.isZip&&R.status==="pending"),A=async()=>{if(r.length!==0){c(!0);for(let R=0;R<r.length;R++)if(r[R].status==="pending"){i(U=>U.map((L,q)=>q===R?{...L,status:"uploading"}:L));try{if(r[R].isZip){const U=await me.extractZipFile(r[R].file,t,u,f);i(L=>L.map((q,j)=>j===R?{...q,status:U.errors.length>0&&U.extracted===0?"error":"success",extractedCount:U.extracted,error:U.errors.length>0?`${U.errors.length} files failed`:void 0}:q))}else await me.uploadLibraryFile(r[R].file,t),i(U=>U.map((L,q)=>q===R?{...L,status:"success"}:L))}catch(U){i(L=>L.map((q,j)=>j===R?{...q,status:"error",error:U instanceof Error?U.message:"Upload failed"}:q))}}c(!1),n(),e()}},k=r.filter(R=>R.status==="pending").length,C=r.filter(R=>R.status==="success").length,D=r.filter(R=>R.status==="error").length,T=r.length>0&&k===0&&!l;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-lg border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Upload Files"}),s.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark rounded",children:s.jsx(Gt,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsxs("div",{onDragOver:b,onDragLeave:v,onDrop:x,onClick:()=>p.current?.click(),className:`border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-colors ${a?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-green/50"}`,children:[s.jsx(fi,{className:`w-10 h-10 mx-auto mb-3 ${a?"text-bambu-green":"text-bambu-gray"}`}),s.jsx("p",{className:"text-white font-medium",children:a?"Drop files here":"Drag & drop files here"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"or click to browse"}),s.jsx("p",{className:"text-xs text-bambu-gray/70 mt-2",children:"All file types supported. ZIP files will be extracted."})]}),s.jsx("input",{ref:p,type:"file",multiple:!0,className:"hidden",onChange:y}),N&&s.jsx("div",{className:"p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Ja,{className:"w-5 h-5 text-blue-400 mt-0.5 flex-shrink-0"}),s.jsxs("div",{className:"flex-1",children:[s.jsx("p",{className:"text-sm text-blue-300 font-medium",children:"ZIP files detected"}),s.jsx("p",{className:"text-xs text-blue-300/70 mt-1",children:"ZIP files will be extracted. Choose how to handle folder structure:"}),s.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:u,onChange:R=>d(R.target.checked),className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsx("span",{className:"text-sm text-white",children:"Preserve folder structure from ZIP"})]}),s.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:f,onChange:R=>m(R.target.checked),className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsx("span",{className:"text-sm text-white",children:"Create folder from ZIP filename"})]})]})]})}),r.length>0&&s.jsx("div",{className:"max-h-48 overflow-y-auto space-y-2",children:r.map((R,U)=>s.jsxs("div",{className:"flex items-center gap-3 p-2 bg-bambu-dark rounded-lg",children:[R.isZip?s.jsx(Ja,{className:"w-4 h-4 text-blue-400 flex-shrink-0"}):s.jsx(nE,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm text-white truncate",children:R.file.name}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[(R.file.size/1024/1024).toFixed(2)," MB",R.isZip&&R.status==="pending"&&s.jsx("span",{className:"text-blue-400 ml-2",children:"• Will be extracted"}),R.extractedCount!==void 0&&s.jsxs("span",{className:"text-green-400 ml-2",children:["• ",R.extractedCount," files extracted"]})]})]}),R.status==="pending"&&s.jsx("button",{onClick:()=>M(U),className:"p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Gt,{className:"w-4 h-4 text-bambu-gray"})}),R.status==="uploading"&&s.jsx(mt,{className:"w-4 h-4 text-bambu-green animate-spin"}),R.status==="success"&&s.jsx(Hn,{className:"w-4 h-4 text-green-500"}),R.status==="error"&&s.jsx("span",{title:R.error,children:s.jsx(za,{className:"w-4 h-4 text-red-500"})})]},U))}),T&&s.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:s.jsxs("p",{className:"text-sm text-white",children:["Upload complete: ",C," succeeded",D>0&&s.jsxs("span",{className:"text-red-400",children:[", ",D," failed"]})]})})]}),s.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex justify-end gap-2",children:[s.jsx(Me,{variant:"secondary",onClick:e,children:T?"Close":"Cancel"}),!T&&s.jsx(Me,{onClick:A,disabled:k===0||l,children:l?s.jsxs(s.Fragment,{children:[s.jsx(mt,{className:"w-4 h-4 mr-2 animate-spin"}),"Uploading..."]}):s.jsxs(s.Fragment,{children:[s.jsx(fi,{className:"w-4 h-4 mr-2"}),"Upload ",k>0?`(${k})`:""]})})]})]})})}function Gie({folder:t,selectedFolderId:e,onSelect:n,onDelete:r,onLink:i,onRename:a,depth:o=0}){const[l,c]=w.useState(!0),[u,d]=w.useState(!1),f=t.children.length>0,m=t.project_id||t.archive_id;return s.jsxs("div",{children:[s.jsxs("div",{className:`group flex items-start gap-1 px-2 py-1.5 rounded cursor-pointer transition-colors ${e===t.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark text-white"}`,style:{paddingLeft:`${8+o*12}px`},onClick:()=>n(t.id),children:[f?s.jsx("button",{onClick:p=>{p.stopPropagation(),c(!l)},className:"p-0.5 hover:bg-bambu-dark-tertiary rounded flex-shrink-0",children:s.jsx(Zs,{className:`w-3.5 h-3.5 transition-transform ${l?"rotate-90":""}`})}):s.jsx("div",{className:"w-4.5 flex-shrink-0"}),s.jsx(al,{className:"w-4 h-4 text-bambu-green flex-shrink-0"}),s.jsx("span",{className:"text-sm flex-1 break-words",title:t.name,children:t.name}),m&&s.jsxs("button",{onClick:p=>{p.stopPropagation(),i(t)},className:"flex items-center gap-1 text-xs px-1.5 py-0.5 rounded bg-blue-500/20 text-blue-400 hover:bg-blue-500/30 transition-colors",title:`${t.project_name?`Project: ${t.project_name}`:`Archive: ${t.archive_name}`} (click to change)`,children:[s.jsx(Gl,{className:"w-3 h-3"}),t.project_name?s.jsx(cK,{className:"w-3 h-3"}):s.jsx(Ja,{className:"w-3 h-3"})]}),t.file_count>0&&s.jsx("span",{className:"text-xs text-bambu-gray",children:t.file_count}),!m&&s.jsx("button",{onClick:p=>{p.stopPropagation(),i(t)},className:"p-1 rounded hover:bg-bambu-dark-tertiary",title:"Link to project or archive",children:s.jsx(Gl,{className:"w-3.5 h-3.5 text-bambu-gray hover:text-bambu-green"})}),s.jsx("div",{className:"flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",onClick:p=>p.stopPropagation(),children:s.jsxs("div",{className:"relative",children:[s.jsx("button",{onClick:()=>d(!u),className:"p-1 rounded hover:bg-bambu-dark-tertiary",children:s.jsx(Ld,{className:"w-3.5 h-3.5 text-bambu-gray"})}),u&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>d(!1)}),s.jsxs("div",{className:"absolute right-0 top-full mt-1 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-1.5 text-left text-sm text-white hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{a(t),d(!1)},children:[s.jsx(Na,{className:"w-3.5 h-3.5"}),"Rename"]}),s.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-sm text-white hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{i(t),d(!1)},children:[s.jsx(Gl,{className:"w-3.5 h-3.5"}),m?"Change Link...":"Link to..."]}),s.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-sm text-red-400 hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{r(t.id),d(!1)},children:[s.jsx(hn,{className:"w-3.5 h-3.5"}),"Delete"]})]})]})]})})]}),f&&l&&s.jsx("div",{children:t.children.map(p=>s.jsx(Gie,{folder:p,selectedFolderId:e,onSelect:n,onDelete:r,onLink:i,onRename:a,depth:o+1},p.id))})]})}function yD(t){const e=t.toLowerCase();return e.endsWith(".gcode")||e.includes(".gcode.")}function NZe({file:t,isSelected:e,onSelect:n,onDelete:r,onDownload:i,onAddToQueue:a,onPrint:o,onRename:l}){const[c,u]=w.useState(!1);return s.jsxs("div",{className:`group relative bg-bambu-card rounded-lg border transition-all cursor-pointer overflow-hidden ${e?"border-bambu-green ring-1 ring-bambu-green":"border-bambu-dark-tertiary hover:border-bambu-green/50"}`,onClick:()=>n(t.id),children:[s.jsxs("div",{className:"aspect-square bg-bambu-dark flex items-center justify-center overflow-hidden",children:[t.thumbnail_path?s.jsx("img",{src:me.getLibraryFileThumbnailUrl(t.id),alt:t.filename,className:"w-full h-full object-cover"}):s.jsx(_f,{className:"w-12 h-12 text-bambu-gray/30"}),s.jsx("div",{className:`absolute top-2 right-2 text-xs px-1.5 py-0.5 rounded font-medium ${t.file_type==="3mf"?"bg-bambu-green/90 text-white":t.file_type==="gcode"?"bg-blue-500/90 text-white":t.file_type==="stl"?"bg-purple-500/90 text-white":"bg-bambu-gray/90 text-white"}`,children:t.file_type.toUpperCase()})]}),s.jsxs("div",{className:"p-3",children:[s.jsx("h3",{className:"text-sm font-medium text-white truncate",title:t.print_name||t.filename,children:t.print_name||t.filename}),s.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-bambu-gray",children:[s.jsx("span",{children:Vp(t.file_size)}),t.print_time_seconds&&s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(Jn,{className:"w-3 h-3"}),vZe(t.print_time_seconds)]})]}),t.print_count>0&&s.jsxs("div",{className:"mt-1 text-xs text-bambu-green",children:["Printed ",t.print_count,"x"]})]}),s.jsxs("div",{className:"absolute bottom-2 right-2 opacity-100 md:opacity-0 md:group-hover:opacity-100 transition-opacity",onClick:d=>d.stopPropagation(),children:[s.jsx("button",{onClick:()=>u(!c),className:"p-1.5 rounded bg-bambu-dark-secondary/90 hover:bg-bambu-dark-tertiary",children:s.jsx(Ld,{className:"w-4 h-4 text-bambu-gray"})}),c&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>u(!1)}),s.jsxs("div",{className:"absolute right-0 bottom-8 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[140px]",children:[o&&yD(t.filename)&&s.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-sm text-bambu-green hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{o(t),u(!1)},children:[s.jsx(Wr,{className:"w-3.5 h-3.5"}),"Print"]}),a&&yD(t.filename)&&s.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-sm text-white hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{a(t.id),u(!1)},children:[s.jsx(Jn,{className:"w-3.5 h-3.5"}),"Add to Queue"]}),s.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-sm text-white hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{i(t.id),u(!1)},children:[s.jsx($r,{className:"w-3.5 h-3.5"}),"Download"]}),l&&s.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-sm text-white hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{l(t),u(!1)},children:[s.jsx(Na,{className:"w-3.5 h-3.5"}),"Rename"]}),s.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-sm text-red-400 hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{r(t.id),u(!1)},children:[s.jsx(hn,{className:"w-3.5 h-3.5"}),"Delete"]})]})]})]}),s.jsx("div",{className:`absolute top-2 left-2 w-5 h-5 rounded border-2 flex items-center justify-center transition-all ${e?"bg-bambu-green border-bambu-green":"border-white/30 bg-black/30 opacity-100 md:opacity-0 md:group-hover:opacity-100"}`,children:e&&s.jsx("div",{className:"w-2 h-2 bg-white rounded-sm"})})]})}function AZe(){const t=ln(),{showToast:e}=Yn(),[n]=Hq(),r=n.get("folder"),i=r?parseInt(r,10):null,[a,o]=w.useState(i),[l,c]=w.useState([]),[u,d]=w.useState(!1),[f,m]=w.useState(!1),[p,b]=w.useState(!1),[v,x]=w.useState(null),[y,S]=w.useState(null),[M,N]=w.useState(null),[A,k]=w.useState(null),[C,D]=w.useState(null),[T,R]=w.useState(()=>localStorage.getItem("library-view-mode")||"grid"),[U,L]=w.useState(""),[q,j]=w.useState("all"),[W,K]=w.useState("date"),[V,J]=w.useState("desc");w.useEffect(()=>{const ae=n.get("folder");if(ae){const ke=parseInt(ae,10);o(ke)}},[n]);const{data:ne}=ft({queryKey:["settings"],queryFn:()=>me.getSettings()}),{data:te,isLoading:z}=ft({queryKey:["library-folders"],queryFn:()=>me.getLibraryFolders()}),{data:H,isLoading:Z}=ft({queryKey:["library-files",a],queryFn:()=>me.getLibraryFiles(a,a===null)}),{data:ee}=ft({queryKey:["library-stats"],queryFn:()=>me.getLibraryStats()}),he=w.useMemo(()=>{if(!H)return[];const ae=new Set(H.map(ke=>ke.file_type));return Array.from(ae).sort()},[H]),fe=w.useMemo(()=>{if(!H)return[];let ae=[...H];if(U.trim()){const ke=U.toLowerCase();ae=ae.filter(De=>De.filename.toLowerCase().includes(ke)||De.print_name&&De.print_name.toLowerCase().includes(ke))}return q!=="all"&&(ae=ae.filter(ke=>ke.file_type===q)),ae.sort((ke,De)=>{let Ke=0;switch(W){case"name":Ke=(ke.print_name||ke.filename).localeCompare(De.print_name||De.filename);break;case"date":Ke=new Date(ke.created_at).getTime()-new Date(De.created_at).getTime();break;case"size":Ke=ke.file_size-De.file_size;break;case"type":Ke=ke.file_type.localeCompare(De.file_type);break;case"prints":Ke=ke.print_count-De.print_count;break}return V==="asc"?Ke:-Ke}),ae},[H,U,q,W,V]),oe=w.useMemo(()=>{if(!ee||!ne)return!1;const ae=(ne.library_disk_warning_gb||5)*1024*1024*1024;return ee.disk_free_bytes<ae},[ee,ne]),Ne=pt({mutationFn:ae=>me.createLibraryFolder(ae),onSuccess:()=>{t.invalidateQueries({queryKey:["library-folders"]}),d(!1),e("Folder created","success")},onError:ae=>e(ae.message,"error")}),ge=pt({mutationFn:ae=>me.deleteLibraryFolder(ae),onSuccess:()=>{t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-stats"]}),a===y?.id&&o(null),S(null),e("Folder deleted","success")},onError:ae=>{S(null),e(ae.message,"error")}}),Se=pt({mutationFn:ae=>me.deleteLibraryFile(ae),onSuccess:()=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-stats"]}),c(ae=>ae.filter(ke=>ke!==y?.id)),S(null),e("File deleted","success")},onError:ae=>{S(null),e(ae.message,"error")}}),Re=pt({mutationFn:ae=>me.bulkDeleteLibrary(ae,[]),onSuccess:(ae,ke)=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-stats"]}),e(`Deleted ${ke.length} files`,"success"),c([]),S(null)},onError:ae=>{S(null),e(ae.message,"error")}}),de=pt({mutationFn:({fileIds:ae,folderId:ke})=>me.moveLibraryFiles(ae,ke),onSuccess:()=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-folders"]}),c([]),m(!1),e("Files moved","success")},onError:ae=>e(ae.message,"error")}),Qe=pt({mutationFn:({id:ae,data:ke})=>me.updateLibraryFolder(ae,ke),onSuccess:(ae,ke)=>{t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["project-folders"]}),t.invalidateQueries({queryKey:["archive-folders"]}),x(null);const De=ke.data.project_id===0&&ke.data.archive_id===0;e(De?"Folder unlinked":"Folder linked","success")},onError:ae=>e(ae.message,"error")}),G=pt({mutationFn:ae=>me.addLibraryFilesToQueue(ae),onSuccess:ae=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["queue"]}),t.invalidateQueries({queryKey:["archives"]}),c([]),ae.added.length>0&&ae.errors.length===0?e(`Added ${ae.added.length} file${ae.added.length>1?"s":""} to queue`,"success"):ae.added.length>0&&ae.errors.length>0?e(`Added ${ae.added.length} file${ae.added.length>1?"s":""}, ${ae.errors.length} failed`,"success"):e(`Failed to add files: ${ae.errors[0]?.error||"Unknown error"}`,"error")},onError:ae=>e(ae.message,"error")}),ie=pt({mutationFn:({id:ae,filename:ke})=>me.updateLibraryFile(ae,{filename:ke}),onSuccess:()=>{t.invalidateQueries({queryKey:["library-files"]}),D(null),e("File renamed","success")},onError:ae=>{D(null),e(ae.message,"error")}}),X=pt({mutationFn:({id:ae,name:ke})=>me.updateLibraryFolder(ae,{name:ke}),onSuccess:()=>{t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-files"]}),D(null),e("Folder renamed","success")},onError:ae=>{D(null),e(ae.message,"error")}}),$=w.useCallback(ae=>{const ke=ae.toLowerCase();return ke.endsWith(".gcode")||ke.includes(".gcode.")},[]),I=w.useMemo(()=>H?H.filter(ae=>l.includes(ae.id)&&$(ae.filename)):[],[H,l,$]),ce=w.useCallback(ae=>{c(ke=>ke.includes(ae)?ke.filter(De=>De!==ae):[...ke,ae])},[]),Ee=w.useCallback(()=>{fe.length>0&&c(fe.map(ae=>ae.id))},[fe]),Ie=w.useCallback(()=>{c([])},[]),le=()=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-stats"]})},B=ae=>{window.open(me.getLibraryFileDownloadUrl(ae),"_blank")},O=()=>{y&&(y.type==="file"?Se.mutate(y.id):y.type==="folder"?ge.mutate(y.id):y.type==="bulk"&&Re.mutate(l))},Y=ge.isPending||Se.isPending||Re.isPending,pe=ae=>{R(ae),localStorage.setItem("library-view-mode",ae)},we=z||Z;return s.jsxs("div",{className:"p-4 md:p-8 h-[calc(100vh-64px)] flex flex-col",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-6",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(al,{className:"w-6 h-6 text-bambu-green"})}),"File Manager"]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-2 ml-14",children:"Organize and manage your print files"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"flex items-center bg-bambu-dark rounded-lg p-1",children:[s.jsx("button",{onClick:()=>pe("grid"),className:`p-1.5 rounded transition-colors ${T==="grid"?"bg-bambu-card text-white":"text-bambu-gray hover:text-white"}`,title:"Grid view",children:s.jsx(oE,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>pe("list"),className:`p-1.5 rounded transition-colors ${T==="list"?"bg-bambu-card text-white":"text-bambu-gray hover:text-white"}`,title:"List view",children:s.jsx(lE,{className:"w-4 h-4"})})]}),s.jsxs(Me,{variant:"secondary",onClick:()=>d(!0),children:[s.jsx(the,{className:"w-4 h-4 mr-2"}),"New Folder"]}),s.jsxs(Me,{onClick:()=>b(!0),children:[s.jsx(fi,{className:"w-4 h-4 mr-2"}),"Upload"]})]})]}),oe&&ee&&ne&&s.jsxs("div",{className:"flex items-center gap-3 mb-4 p-3 bg-amber-500/10 border border-amber-500/30 rounded-lg",children:[s.jsx(Tn,{className:"w-5 h-5 text-amber-500 flex-shrink-0"}),s.jsxs("div",{className:"flex-1",children:[s.jsx("p",{className:"text-sm text-amber-500 font-medium",children:"Low disk space warning"}),s.jsxs("p",{className:"text-xs text-amber-500/80",children:["Only ",Vp(ee.disk_free_bytes)," free of ",Vp(ee.disk_total_bytes)," total. Threshold is set to ",ne.library_disk_warning_gb," GB in settings."]})]})]}),ee&&s.jsxs("div",{className:"flex items-center gap-6 mb-6 p-3 bg-bambu-card rounded-lg border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(nE,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{className:"text-bambu-gray",children:"Files:"}),s.jsx("span",{className:"text-white font-medium",children:ee.total_files})]}),s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(al,{className:"w-4 h-4 text-blue-400"}),s.jsx("span",{className:"text-bambu-gray",children:"Folders:"}),s.jsx("span",{className:"text-white font-medium",children:ee.total_folders})]}),s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(aE,{className:"w-4 h-4 text-amber-400"}),s.jsx("span",{className:"text-bambu-gray",children:"Size:"}),s.jsx("span",{className:"text-white font-medium",children:Vp(ee.total_size_bytes)})]}),s.jsxs("div",{className:"flex items-center gap-2 text-sm ml-auto",children:[s.jsx("span",{className:"text-bambu-gray",children:"Free:"}),s.jsx("span",{className:`font-medium ${oe?"text-amber-500":"text-white"}`,children:Vp(ee.disk_free_bytes)})]})]}),s.jsxs("div",{className:"flex-1 flex gap-6 min-h-0",children:[s.jsxs("div",{className:"w-64 flex-shrink-0 bg-bambu-card rounded-lg border border-bambu-dark-tertiary overflow-hidden flex flex-col",children:[s.jsx("div",{className:"p-3 border-b border-bambu-dark-tertiary",children:s.jsx("h2",{className:"text-sm font-medium text-white",children:"Folders"})}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-2",children:[s.jsxs("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded cursor-pointer transition-colors ${a===null?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark text-white"}`,onClick:()=>o(null),children:[s.jsx(_f,{className:"w-4 h-4"}),s.jsx("span",{className:"text-sm",children:"All Files"})]}),te?.map(ae=>s.jsx(Gie,{folder:ae,selectedFolderId:a,onSelect:o,onDelete:ke=>S({type:"folder",id:ke}),onLink:x,onRename:ke=>D({type:"folder",id:ke.id,name:ke.name})},ae.id))]})]}),s.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[H&&H.length>0&&s.jsxs("div",{className:"flex items-center gap-3 mb-4 p-3 bg-bambu-card rounded-lg border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"relative flex-1 max-w-xs",children:[s.jsx(Sa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",placeholder:"Search files...",value:U,onChange:ae=>L(ae.target.value),className:"w-full pl-9 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(rE,{className:"w-4 h-4 text-bambu-gray"}),s.jsxs("select",{value:q,onChange:ae=>j(ae.target.value),className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1.5 text-sm text-white focus:outline-none focus:border-bambu-green",children:[s.jsx("option",{value:"all",children:"All types"}),he.map(ae=>s.jsx("option",{value:ae,children:ae.toUpperCase()},ae))]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("select",{value:W,onChange:ae=>K(ae.target.value),className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1.5 text-sm text-white focus:outline-none focus:border-bambu-green",children:[s.jsx("option",{value:"date",children:"Date"}),s.jsx("option",{value:"name",children:"Name"}),s.jsx("option",{value:"size",children:"Size"}),s.jsx("option",{value:"type",children:"Type"}),s.jsx("option",{value:"prints",children:"Prints"})]}),s.jsx("button",{onClick:()=>J(ae=>ae==="asc"?"desc":"asc"),className:"p-1.5 rounded bg-bambu-dark border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",title:V==="asc"?"Ascending":"Descending",children:V==="asc"?s.jsx(Rue,{className:"w-4 h-4 text-white"}):s.jsx(Aue,{className:"w-4 h-4 text-white"})})]}),(U||q!=="all")&&s.jsxs("span",{className:"text-sm text-bambu-gray",children:[fe.length," of ",H.length," files"]})]}),fe.length>0&&s.jsxs("div",{className:"flex items-center gap-2 mb-4 p-2 bg-bambu-card rounded-lg border border-bambu-dark-tertiary",children:[l.length===fe.length&&l.length>0?s.jsxs(Me,{variant:"secondary",size:"sm",onClick:Ie,children:[s.jsx(cl,{className:"w-4 h-4 mr-1"}),"Deselect All"]}):s.jsxs(Me,{variant:"secondary",size:"sm",onClick:Ee,children:[s.jsx(ll,{className:"w-4 h-4 mr-1"}),"Select All"]}),l.length>0&&s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"text-sm text-bambu-gray ml-2",children:[l.length," selected"]}),s.jsx("div",{className:"flex-1"}),I.length===1&&s.jsxs(Me,{variant:"primary",size:"sm",onClick:()=>k(I[0]),children:[s.jsx(ol,{className:"w-4 h-4 mr-1"}),"Print"]}),I.length>0&&s.jsxs(Me,{variant:I.length===1?"secondary":"primary",size:"sm",onClick:()=>G.mutate(I.map(ae=>ae.id)),disabled:G.isPending,children:[s.jsx(Jn,{className:"w-4 h-4 mr-1"}),G.isPending?"Adding...":`Add to Queue${I.length<l.length?` (${I.length})`:""}`]}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>m(!0),children:[s.jsx(cfe,{className:"w-4 h-4 mr-1"}),"Move"]}),s.jsxs(Me,{variant:"danger",size:"sm",onClick:()=>{l.length===1?S({type:"file",id:l[0]}):S({type:"bulk",id:0,count:l.length})},children:[s.jsx(hn,{className:"w-4 h-4 mr-1"}),"Delete"]}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:Ie,children:"Clear"})]})]}),we?s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsxs("div",{className:"flex flex-col items-center gap-3",children:[s.jsx(mt,{className:"w-8 h-8 animate-spin text-bambu-green"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Loading files..."})]})}):H?.length===0?s.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center",children:[s.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:s.jsx(_f,{className:"w-12 h-12 text-bambu-gray/50"})}),s.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:a!==null?"Folder is empty":"No files yet"}),s.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:a!==null?"Upload files or move files into this folder to get started.":"Upload files to start organizing your print-related files."}),s.jsxs(Me,{onClick:()=>b(!0),children:[s.jsx(rr,{className:"w-4 h-4 mr-2"}),"Upload Files"]})]}):fe.length===0?s.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center",children:[s.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:s.jsx(Sa,{className:"w-12 h-12 text-bambu-gray/50"})}),s.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:"No matching files"}),s.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:"No files match your current search or filter criteria."}),s.jsx(Me,{variant:"secondary",onClick:()=>{L(""),j("all")},children:"Clear filters"})]}):T==="grid"?s.jsx("div",{className:"flex-1 overflow-y-auto",children:s.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-6 gap-4",children:fe.map(ae=>s.jsx(NZe,{file:ae,isSelected:l.includes(ae.id),onSelect:ce,onDelete:ke=>S({type:"file",id:ke}),onDownload:B,onAddToQueue:ke=>G.mutate([ke]),onPrint:N,onRename:ke=>D({type:"file",id:ke.id,name:ke.filename})},ae.id))})}):s.jsx("div",{className:"flex-1 overflow-y-auto",children:s.jsxs("div",{className:"bg-bambu-card rounded-lg border border-bambu-dark-tertiary overflow-hidden",children:[s.jsxs("div",{className:"grid grid-cols-[auto_1fr_100px_100px_100px_80px] gap-4 px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary text-xs text-bambu-gray font-medium",children:[s.jsx("div",{className:"w-6"}),s.jsx("div",{children:"Name"}),s.jsx("div",{children:"Type"}),s.jsx("div",{children:"Size"}),s.jsx("div",{children:"Prints"}),s.jsx("div",{})]}),fe.map(ae=>s.jsxs("div",{className:`grid grid-cols-[auto_1fr_100px_100px_100px_80px] gap-4 px-4 py-3 items-center border-b border-bambu-dark-tertiary last:border-b-0 cursor-pointer hover:bg-bambu-dark/50 transition-colors ${l.includes(ae.id)?"bg-bambu-green/10":""}`,onClick:()=>ce(ae.id),children:[s.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center ${l.includes(ae.id)?"bg-bambu-green border-bambu-green":"border-bambu-gray/50"}`,children:l.includes(ae.id)&&s.jsx("div",{className:"w-2 h-2 bg-white rounded-sm"})}),s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsxs("div",{className:"relative group/thumb",children:[s.jsx("div",{className:"w-10 h-10 rounded bg-bambu-dark flex-shrink-0 overflow-hidden",children:ae.thumbnail_path?s.jsx("img",{src:me.getLibraryFileThumbnailUrl(ae.id),alt:"",className:"w-full h-full object-cover"}):s.jsx("div",{className:"w-full h-full flex items-center justify-center",children:s.jsx(_f,{className:"w-5 h-5 text-bambu-gray/50"})})}),ae.thumbnail_path&&s.jsx("div",{className:"absolute left-0 top-full mt-2 z-50 hidden group-hover/thumb:block",children:s.jsx("div",{className:"w-48 h-48 rounded-lg bg-bambu-dark-secondary border border-bambu-dark-tertiary shadow-xl overflow-hidden",children:s.jsx("img",{src:me.getLibraryFileThumbnailUrl(ae.id),alt:ae.filename,className:"w-full h-full object-contain"})})})]}),s.jsx("div",{className:"min-w-0",children:s.jsx("div",{className:"text-sm text-white truncate",children:ae.print_name||ae.filename})})]}),s.jsx("div",{children:s.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${ae.file_type==="3mf"?"bg-bambu-green/20 text-bambu-green":ae.file_type==="gcode"?"bg-blue-500/20 text-blue-400":ae.file_type==="stl"?"bg-purple-500/20 text-purple-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:ae.file_type.toUpperCase()})}),s.jsx("div",{className:"text-sm text-bambu-gray",children:Vp(ae.file_size)}),s.jsx("div",{className:"text-sm text-bambu-gray",children:ae.print_count>0?`${ae.print_count}x`:"-"}),s.jsxs("div",{className:"flex items-center gap-1",onClick:ke=>ke.stopPropagation(),children:[yD(ae.filename)&&s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>N(ae),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green transition-colors",title:"Print",children:s.jsx(Wr,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>G.mutate([ae.id]),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",title:"Add to Queue",disabled:G.isPending,children:s.jsx(Jn,{className:"w-4 h-4"})})]}),s.jsx("button",{onClick:()=>B(ae.id),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",title:"Download",children:s.jsx($r,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>D({type:"file",id:ae.id,name:ae.filename}),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",title:"Rename",children:s.jsx(Na,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>S({type:"file",id:ae.id}),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors",title:"Delete",children:s.jsx(hn,{className:"w-4 h-4"})})]})]},ae.id))]})})]})]}),u&&s.jsx(_Ze,{parentId:a,onClose:()=>d(!1),onSave:ae=>Ne.mutate(ae),isLoading:Ne.isPending}),f&&te&&s.jsx(SZe,{folders:te,selectedFiles:l,currentFolderId:a,onClose:()=>m(!1),onMove:ae=>de.mutate({fileIds:l,folderId:ae}),isLoading:de.isPending}),p&&s.jsx(EZe,{folderId:a,onClose:()=>b(!1),onUploadComplete:le}),v&&s.jsx(MZe,{folder:v,onClose:()=>x(null),onLink:ae=>Qe.mutate({id:v.id,data:ae}),isLoading:Qe.isPending}),y&&s.jsx(zn,{title:y.type==="folder"?"Delete Folder":y.type==="bulk"?`Delete ${y.count} Files`:"Delete File",message:y.type==="folder"?"Are you sure you want to delete this folder? All files inside will also be deleted.":y.type==="bulk"?`Are you sure you want to delete ${y.count} selected files? This action cannot be undone.`:"Are you sure you want to delete this file?",confirmText:"Delete",variant:"danger",isLoading:Y,loadingText:"Deleting...",onConfirm:O,onCancel:()=>S(null)}),M&&s.jsx(ih,{mode:"reprint",libraryFileId:M.id,archiveName:M.print_name||M.filename,onClose:()=>N(null),onSuccess:()=>{N(null),t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["archives"]})}}),A&&s.jsx(ih,{mode:"reprint",libraryFileId:A.id,archiveName:A.print_name||A.filename,onClose:()=>k(null),onSuccess:()=>{k(null),c([]),t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["archives"]})}}),C&&s.jsx(wZe,{type:C.type,currentName:C.name,onClose:()=>D(null),onSave:ae=>{C.type==="file"?ie.mutate({id:C.id,filename:ae}):X.mutate({id:C.id,name:ae})},isLoading:ie.isPending||X.isPending})]})}const Yj=5,TZe=2e3,CZe=3e4,kZe=5e3;function jZe(){const{printerId:t}=MD(),e=parseInt(t||"0",10),[n,r]=w.useState("stream"),[i,a]=w.useState(!1),[o,l]=w.useState(!0),[c,u]=w.useState(Date.now()),[d,f]=w.useState(!1),[m,p]=w.useState(!1),[b,v]=w.useState(0),[x,y]=w.useState(!1),[S,M]=w.useState(0),[N,A]=w.useState(1),[k,C]=w.useState({x:0,y:0}),[D,T]=w.useState(!1),[R,U]=w.useState({x:0,y:0}),[L,q]=w.useState(null),[j,W]=w.useState(null),K=w.useRef(null),V=w.useRef(null),J=w.useRef(null),ne=w.useRef(null),te=w.useRef(null),{data:z}=ft({queryKey:["printer",e],queryFn:()=>me.getPrinter(e),enabled:e>0});w.useEffect(()=>(z&&(document.title=`${z.name} - Camera`),()=>{document.title="Bambuddy"}),[z]);const H=w.useRef(!1);w.useEffect(()=>{const Y=`/api/v1/printers/${e}/camera/stop`;H.current=!1;const pe=()=>{e>0&&!H.current&&(H.current=!0,navigator.sendBeacon(Y))},we=()=>{pe()};window.addEventListener("beforeunload",we);const ae=K.current;return()=>{window.removeEventListener("beforeunload",we),ae&&(ae.src=""),pe()}},[e]),w.useEffect(()=>{if(o&&!d){const pe=setTimeout(()=>{l(!1)},n==="stream"?3e3:2e4);return()=>clearTimeout(pe)}},[n,o,c,d]),w.useEffect(()=>{const Y=()=>{const pe=!!document.fullscreenElement;p(pe),A(1),C({x:0,y:0}),n==="stream"&&!d&&(K.current&&(K.current.src=""),setTimeout(()=>{l(!0),u(Date.now())},200))};return document.addEventListener("fullscreenchange",Y),()=>document.removeEventListener("fullscreenchange",Y)},[n,d]),w.useEffect(()=>{let Y;const pe=()=>{clearTimeout(Y),Y=setTimeout(()=>{localStorage.setItem("cameraWindowState",JSON.stringify({width:window.outerWidth,height:window.outerHeight,left:window.screenX,top:window.screenY}))},500)};return window.addEventListener("resize",pe),()=>{clearTimeout(Y),window.removeEventListener("resize",pe)}},[]),w.useEffect(()=>()=>{J.current&&clearTimeout(J.current),ne.current&&clearInterval(ne.current),te.current&&clearInterval(te.current)},[]);const Z=w.useCallback(()=>{if(b>=Yj){y(!1),a(!0);return}const Y=Math.min(TZe*Math.pow(2,b),CZe);y(!0),M(Math.ceil(Y/1e3)),ne.current=setInterval(()=>{M(pe=>pe<=1?(ne.current&&clearInterval(ne.current),0):pe-1)},1e3),J.current=setTimeout(()=>{v(pe=>pe+1),y(!1),l(!0),a(!1),K.current&&(K.current.src=""),u(Date.now())},Y)},[b]);w.useEffect(()=>{if(n!=="stream"||o||x||d){te.current&&(clearInterval(te.current),te.current=null);return}return te.current=setInterval(async()=>{try{const Y=await fetch(`/api/v1/printers/${e}/camera/status`);if(Y.ok){const pe=await Y.json();(pe.stalled||!pe.active&&!i)&&(console.log(`Stream issue detected: stalled=${pe.stalled}, active=${pe.active}, reconnecting...`),te.current&&(clearInterval(te.current),te.current=null),l(!1),Z())}}catch{}},kZe),()=>{te.current&&(clearInterval(te.current),te.current=null)}},[n,o,i,x,d,e,Z]);const ee=()=>{l(!1),n==="stream"&&b<Yj?Z():a(!0)},he=()=>{if(l(!1),a(!1),v(0),y(!1),J.current&&clearTimeout(J.current),ne.current&&clearInterval(ne.current),K.current&&!localStorage.getItem("cameraWindowState")){const Y=K.current,pe=Y.naturalWidth,we=Y.naturalHeight;if(pe>0&&we>0){const De=window.outerWidth-window.innerWidth,Ke=window.outerHeight-window.innerHeight,et=pe+16+De,Ye=we+45+16+Ke;try{window.resizeTo(et,Ye)}catch{}}}},fe=()=>{e>0&&fetch(`/api/v1/printers/${e}/camera/stop`).catch(()=>{})},oe=Y=>{n===Y||d||(f(!0),l(!0),a(!1),v(0),y(!1),A(1),C({x:0,y:0}),J.current&&clearTimeout(J.current),ne.current&&clearInterval(ne.current),K.current&&(K.current.src=""),n==="stream"&&fe(),setTimeout(()=>{r(Y),u(Date.now()),f(!1)},100))},Ne=()=>{d||(f(!0),l(!0),a(!1),v(0),y(!1),J.current&&clearTimeout(J.current),ne.current&&clearInterval(ne.current),K.current&&(K.current.src=""),n==="stream"&&fe(),setTimeout(()=>{u(Date.now()),f(!1)},100))},ge=()=>{V.current&&(document.fullscreenElement?document.exitFullscreen():V.current.requestFullscreen())},Se=()=>{A(Y=>Math.min(Y+.5,4))},Re=()=>{A(Y=>{const pe=Math.max(Y-.5,1);return pe===1&&C({x:0,y:0}),pe})},de=Y=>{Y.preventDefault(),Y.deltaY<0?Se():Re()},Qe=Y=>{N>1&&(Y.preventDefault(),T(!0),U({x:Y.clientX-k.x,y:Y.clientY-k.y}))},G=w.useCallback(()=>{if(!V.current)return{x:300,y:200};const Y=V.current.getBoundingClientRect(),pe=Y.width*(N-1)/2,we=Y.height*(N-1)/2;return{x:Math.max(50,pe),y:Math.max(50,we)}},[N]),ie=Y=>{if(D&&N>1){const pe=Y.clientX-R.x,we=Y.clientY-R.y,ae=G();C({x:Math.max(-ae.x,Math.min(ae.x,pe)),y:Math.max(-ae.y,Math.min(ae.y,we))})}},X=()=>{T(!1)},$=Y=>{if(Y.length<2)return 0;const pe=Y[0].clientX-Y[1].clientX,we=Y[0].clientY-Y[1].clientY;return Math.sqrt(pe*pe+we*we)},I=Y=>Y.length<2?{x:Y[0].clientX,y:Y[0].clientY}:{x:(Y[0].clientX+Y[1].clientX)/2,y:(Y[0].clientY+Y[1].clientY)/2},ce=Y=>{Y.touches.length===2?(Y.preventDefault(),q($(Y.touches)),W(I(Y.touches))):Y.touches.length===1&&N>1&&(Y.preventDefault(),T(!0),U({x:Y.touches[0].clientX-k.x,y:Y.touches[0].clientY-k.y}))},Ee=Y=>{if(Y.touches.length===2&&L!==null){Y.preventDefault();const pe=$(Y.touches),we=pe/L;A(ke=>{const De=Math.max(1,Math.min(4,ke*we));return De===1&&C({x:0,y:0}),De}),q(pe);const ae=I(Y.touches);if(j){const ke=G();C(De=>({x:Math.max(-ke.x,Math.min(ke.x,De.x+(ae.x-j.x))),y:Math.max(-ke.y,Math.min(ke.y,De.y+(ae.y-j.y)))}))}W(ae)}else if(Y.touches.length===1&&D&&N>1){Y.preventDefault();const pe=Y.touches[0].clientX-R.x,we=Y.touches[0].clientY-R.y,ae=G();C({x:Math.max(-ae.x,Math.min(ae.x,pe)),y:Math.max(-ae.y,Math.min(ae.y,we))})}},Ie=Y=>{Y.touches.length<2&&(q(null),W(null)),Y.touches.length===0&&T(!1)},le=()=>{A(1),C({x:0,y:0})},B=d?"":n==="stream"?`/api/v1/printers/${e}/camera/stream?fps=10&t=${c}`:`/api/v1/printers/${e}/camera/snapshot?t=${c}`,O=o||d||x;return e?s.jsxs("div",{ref:V,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(fg,{className:"w-4 h-4"}),z?.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:()=>oe("stream"),disabled:O,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:()=>oe("snapshot"),disabled:O,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:Ne,disabled:O,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:n==="stream"?"Restart stream":"Refresh snapshot",children:s.jsx(Ar,{className:`w-4 h-4 text-bambu-gray ${O?"animate-spin":""}`})}),s.jsx("button",{onClick:ge,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded",title:m?"Exit fullscreen":"Fullscreen",children:m?s.jsx(xK,{className:"w-4 h-4 text-bambu-gray"}):s.jsx(Zhe,{className:"w-4 h-4 text-bambu-gray"})})]})]}),s.jsx("div",{className:"flex-1 flex items-center justify-center p-2 overflow-hidden",onWheel:de,onMouseMove:ie,onMouseUp:X,onMouseLeave:X,onTouchStart:ce,onTouchMove:Ee,onTouchEnd:Ie,style:{touchAction:"none"},children:s.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",children:[(o||d)&&!x&&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(Ar,{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..."})]})}),x&&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(Yg,{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 ",S,"s... (attempt ",b+1,"/",Yj,")"]}),s.jsx("button",{onClick:Ne,className:"px-4 py-2 bg-bambu-green text-white text-sm rounded hover:bg-bambu-green/80 transition-colors",children:"Reconnect now"})]})}),i&&!x&&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(Tn,{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:Ne,className:"px-4 py-2 bg-bambu-green text-white rounded hover:bg-bambu-green/80 transition-colors",children:"Retry"})]})}),s.jsx("img",{ref:K,src:B,alt:"Camera stream",className:"max-w-full max-h-full object-contain select-none",style:{transform:`scale(${N}) translate(${k.x/N}px, ${k.y/N}px)`,cursor:N>1?D?"grabbing":"grab":"default"},onError:B?ee:void 0,onLoad:B?he:void 0,onMouseDown:Qe,draggable:!1},c),s.jsxs("div",{className:"absolute bottom-4 left-4 flex items-center gap-1.5 bg-black/60 rounded-lg px-2 py-1.5",children:[s.jsx("button",{onClick:Re,disabled:N<=1,className:"p-1.5 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom out",children:s.jsx(VD,{className:"w-4 h-4 text-white"})}),s.jsxs("button",{onClick:le,className:"px-2 py-1 text-sm text-white hover:bg-white/10 rounded min-w-[48px]",title:"Reset zoom",children:[Math.round(N*100),"%"]}),s.jsx("button",{onClick:Se,disabled:N>=4,className:"p-1.5 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom in",children:s.jsx(HD,{className:"w-4 h-4 text-white"})})]})]})})]}):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 PZe(){const{id:t}=MD(),{mode:e}=oh(),{data:n,isLoading:r,error:i}=ft({queryKey:["external-link",t],queryFn:()=>me.getExternalLink(Number(t)),enabled:!!t});return r?s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx(mt,{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(Tn,{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"})}const fq=["DEBUG","INFO","WARNING","ERROR"],Zj={DEBUG:"text-gray-400",INFO:"text-blue-400",WARNING:"text-yellow-400",ERROR:"text-red-400"},RZe={DEBUG:QM,INFO:Zl,WARNING:Tn,ERROR:aa};function DZe(){const t=ln(),[e,n]=w.useState(!0),[r,i]=w.useState(new Set),[a,o]=w.useState(""),[l,c]=w.useState("ALL"),[u,d]=w.useState(!1),[f,m]=w.useState(!1),p=w.useRef(null),{data:b,isLoading:v,refetch:x}=ft({queryKey:["application-logs",l,a],queryFn:()=>Jp.getLogs({limit:200,level:l==="ALL"?void 0:l,search:a||void 0}),refetchInterval:f?2e3:!1,enabled:u});w.useEffect(()=>{u||m(!1)},[u]);const y=pt({mutationFn:()=>Jp.clearLogs(),onSuccess:()=>{t.invalidateQueries({queryKey:["application-logs"]})}});w.useEffect(()=>{e&&p.current&&b?.entries&&(p.current.scrollTop=p.current.scrollHeight)},[b?.entries,e]);const S=C=>{i(D=>{const T=new Set(D);return T.has(C)?T.delete(C):T.add(C),T})},M=C=>{const D=C.split(" ");return D.length>=2?D[1]:C},N=w.useMemo(()=>b?.entries??[],[b?.entries]),A=w.useMemo(()=>[...N].reverse(),[N]),k=({level:C})=>{const D=RZe[C]||Zl;return s.jsx(D,{className:`w-3.5 h-3.5 ${Zj[C]||"text-gray-400"}`})};return s.jsxs("div",{className:"bg-bambu-dark rounded-lg overflow-hidden",children:[s.jsxs("button",{onClick:()=>d(!u),className:"w-full flex items-center justify-between p-4 hover:bg-bambu-dark-tertiary/50 transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`p-2 rounded-lg ${f?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:s.jsx(QM,{className:"w-5 h-5"})}),s.jsxs("div",{className:"text-left",children:[s.jsx("p",{className:"font-medium text-white",children:"Application Logs"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:f?`Live streaming - ${b?.filtered_count??0} entries`:"View and filter application logs"})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[f&&s.jsxs("span",{className:"flex items-center gap-1.5 px-2 py-1 bg-bambu-green/20 rounded text-bambu-green text-xs",children:[s.jsx("span",{className:"w-1.5 h-1.5 bg-bambu-green rounded-full animate-pulse"}),"Live"]}),u?s.jsx(du,{className:"w-5 h-5 text-bambu-gray"}):s.jsx(Oi,{className:"w-5 h-5 text-bambu-gray"})]})]}),u&&s.jsxs("div",{className:"border-t border-bambu-dark-tertiary",children:[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 flex-wrap",children:[f?s.jsxs("button",{onClick:C=>{C.stopPropagation(),m(!1)},className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-red-500/20 text-red-400 hover:bg-red-500/30 rounded transition-colors",children:[s.jsx(cl,{className:"w-4 h-4"}),"Stop"]}):s.jsxs("button",{onClick:C=>{C.stopPropagation(),m(!0),x()},className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30 rounded transition-colors",children:[s.jsx(ol,{className:"w-4 h-4"}),"Start"]}),s.jsxs("button",{onClick:()=>y.mutate(),disabled:y.isPending||N.length===0,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-bambu-dark-tertiary text-bambu-gray hover:text-white hover:bg-bambu-dark-secondary rounded transition-colors disabled:opacity-50",children:[s.jsx(hn,{className:"w-4 h-4"}),"Clear"]}),s.jsx("button",{onClick:()=>x(),disabled:v,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-bambu-dark-tertiary text-bambu-gray hover:text-white hover:bg-bambu-dark-secondary rounded transition-colors disabled:opacity-50",children:s.jsx(Ar,{className:`w-4 h-4 ${v?"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:e,onChange:C=>n(C.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark-tertiary"}),"Auto-scroll"]}),s.jsxs("span",{className:"text-sm text-bambu-gray",children:[b?.filtered_count??0,"/",b?.total_in_file??0]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(Sa,{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 message or logger name...",value:a,onChange:C=>o(C.target.value),className:"w-full pl-8 pr-8 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),a&&s.jsx("button",{onClick:()=>o(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:s.jsx(Gt,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark-secondary rounded border border-bambu-dark-tertiary",children:[s.jsx("button",{onClick:()=>c("ALL"),className:`px-2 py-1.5 text-xs rounded-l transition-colors ${l==="ALL"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:"All"}),fq.map((C,D)=>s.jsx("button",{onClick:()=>c(C),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${D===fq.length-1?"rounded-r":""} ${l===C?`${Zj[C]} bg-bambu-dark-tertiary`:"text-bambu-gray hover:text-white"}`,children:C},C))]})]})]}),s.jsx("div",{ref:p,className:"overflow-auto font-mono text-xs bg-black min-h-[300px] max-h-[500px]",children:N.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center h-[300px] text-bambu-gray",children:[s.jsx("p",{className:"mb-2",children:"No log entries found"}),s.jsx("p",{className:"text-sm",children:"Log file may be empty or cleared"})]}):s.jsx("div",{className:"divide-y divide-bambu-dark-tertiary/30",children:A.map((C,D)=>{const T=r.has(D),R=C.message.includes(`
  8339. `);return s.jsx("div",{className:`p-2 cursor-pointer hover:bg-bambu-dark-secondary/50 transition-colors ${T?"bg-bambu-dark-secondary/30":""}`,onClick:()=>R&&S(D),children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:"text-bambu-gray/70 shrink-0 w-20",children:M(C.timestamp)}),s.jsx("span",{className:"shrink-0",children:s.jsx(k,{level:C.level})}),s.jsxs("span",{className:"text-purple-400/80 shrink-0 max-w-[200px] truncate",title:C.logger_name,children:["[",C.logger_name,"]"]}),s.jsx("span",{className:`flex-1 ${Zj[C.level]||"text-white/80"} ${!T&&R?"truncate":""}`,children:T?s.jsx("pre",{className:"whitespace-pre-wrap break-all",children:C.message}):C.message.split(`
  8340. `)[0]}),R&&s.jsx("span",{className:"text-bambu-gray/50 shrink-0",children:T?s.jsx(du,{className:"w-3.5 h-3.5"}):s.jsx(Oi,{className:"w-3.5 h-3.5"})})]})},D)})})}),s.jsx("div",{className:"flex items-center justify-between p-3 border-t border-bambu-dark-tertiary text-sm text-bambu-gray",children:f?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"}),"Auto-refreshing every 2 seconds"]}):s.jsx("span",{children:"Click Start to enable live log streaming"})})]})]})}function OZe(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(2)} GB`}function ei({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 mq({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 fd({title:t,icon:e,children:n}){return s.jsxs(Nt,{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 LZe(){const{t}=Gg(),e=ln(),[n,r]=w.useState(null),[i,a]=w.useState(!1),[o,l]=w.useState(!1),{data:c,isLoading:u,refetch:d,isFetching:f}=ft({queryKey:["systemInfo"],queryFn:me.getSystemInfo,refetchInterval:3e4}),{data:m}=ft({queryKey:["debugLogging"],queryFn:Jp.getDebugLoggingState,staleTime:10*1e3,refetchInterval:10*1e3}),{data:p}=ft({queryKey:["settings"],queryFn:me.getSettings}),{data:b}=ft({queryKey:["library-stats"],queryFn:me.getLibraryStats}),v=p?.time_format||"system",x=async()=>{l(!0);try{const N=await Jp.setDebugLogging(!m?.enabled);e.setQueryData(["debugLogging"],N)}catch(N){console.error("Failed to toggle debug logging:",N)}finally{l(!1)}},y=async()=>{r(null),a(!0);try{await Jp.downloadSupportBundle()}catch(N){r(N instanceof Error?N.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(mt,{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 S=c.storage.disk_percent_used>90?"bg-red-500":c.storage.disk_percent_used>75?"bg-yellow-500":"bg-bambu-green",M=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(Ar,{className:`w-4 h-4 ${f?"animate-spin":""}`}),t("common.refresh","Refresh")]})]}),s.jsx(fd,{title:t("system.application","Application"),icon:Kh,children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[s.jsx(ei,{icon:Kh,label:t("system.version","Version"),value:`v${c.app.version}`}),s.jsx(ei,{icon:Jn,label:t("system.uptime","System Uptime"),value:c.system.uptime_formatted}),s.jsx(ei,{icon:Kh,label:t("system.hostname","Hostname"),value:c.system.hostname})]})}),s.jsx(fd,{title:t("support.title","Support & Troubleshooting"),icon:vhe,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 ${m?.enabled?"bg-amber-500/20 text-amber-500":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:s.jsx(QM,{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:[m?.enabled?t("support.debugLoggingEnabled","Capturing detailed logs"):t("support.debugLoggingDisabled","Normal logging level"),m?.enabled&&m.duration_seconds!==null&&s.jsxs("span",{className:"text-amber-400 ml-2",children:["(",Math.floor(m.duration_seconds/60),"m ",m.duration_seconds%60,"s)"]})]})]})]}),s.jsxs("button",{onClick:x,disabled:o,className:`px-4 py-2 rounded-lg font-medium transition-colors flex items-center gap-2 ${m?.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(mt,{className:"w-4 h-4 animate-spin"}),m?.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($r,{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:y,disabled:i||!m?.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:m?.enabled?void 0:t("support.enableDebugFirst","Enable debug logging first"),children:[i&&s.jsx(mt,{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}),!m?.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.jsx(DZe,{})]})}),s.jsxs(fd,{title:t("system.database","Database"),icon:mg,children:[s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-4",children:[s.jsx(ei,{icon:Ja,label:t("system.totalArchives","Total Archives"),value:c.database.archives}),s.jsx(ei,{icon:JM,label:t("system.completed","Completed"),value:c.database.archives_completed,color:"text-green-500"}),s.jsx(ei,{icon:za,label:t("system.failed","Failed"),value:c.database.archives_failed,color:"text-red-500"}),s.jsx(ei,{icon:mt,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(ei,{icon:Wr,label:t("system.printers","Printers"),value:c.database.printers}),s.jsx(ei,{icon:FD,label:t("system.filaments","Filaments"),value:c.database.filaments}),s.jsx(ei,{icon:Ea,label:t("system.projects","Projects"),value:c.database.projects}),s.jsx(ei,{icon:Ws,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(ei,{icon:Jn,label:t("system.totalPrintTime","Total Print Time"),value:c.database.total_print_time_formatted}),s.jsx(ei,{icon:Ja,label:t("system.totalFilament","Total Filament Used"),value:`${c.database.total_filament_kg} kg`,subValue:`${c.database.total_filament_grams.toLocaleString()} g`})]})]}),s.jsxs(fd,{title:t("system.connectedPrinters","Connected Printers"),icon:Wr,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(N=>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:N.name})]}),s.jsxs("div",{className:"flex items-center gap-4 text-sm text-bambu-gray",children:[s.jsx("span",{children:N.model}),s.jsx("span",{className:`px-2 py-0.5 rounded ${N.state==="RUNNING"?"bg-bambu-green/20 text-bambu-green":N.state==="IDLE"?"bg-blue-500/20 text-blue-400":"bg-bambu-dark-tertiary"}`,children:N.state})]})]},N.id))}):s.jsx("p",{className:"text-bambu-gray",children:t("system.noPrintersConnected","No printers connected")})]}),s.jsx(fd,{title:t("system.storage","Storage"),icon:aE,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(mq,{percent:c.storage.disk_percent_used,color:S}),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-3 gap-4",children:[s.jsx(ei,{icon:Ja,label:t("system.archiveStorage","Archive Storage"),value:c.storage.archive_size_formatted}),s.jsx(ei,{icon:mg,label:t("system.databaseSize","Database Size"),value:c.storage.database_size_formatted}),b&&s.jsx(ei,{icon:al,label:t("system.fileManagerStorage","File Manager"),value:OZe(b.total_size_bytes),subValue:`${b.total_files} files, ${b.total_folders} folders`})]})]})}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[s.jsx(fd,{title:t("system.memory","Memory"),icon:Jhe,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(mq,{percent:c.memory.percent_used,color:M}),s.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[c.memory.available_formatted," ",t("system.available","available")]})]})})}),s.jsx(fd,{title:t("system.cpu","CPU"),icon:f_,children:s.jsx("div",{className:"space-y-4",children:s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsx(ei,{icon:f_,label:t("system.cores","Cores"),value:c.cpu.count,subValue:`${c.cpu.count_logical} logical`}),s.jsx(ei,{icon:f_,label:t("system.usage","Usage"),value:`${c.cpu.percent}%`})]})})})]}),s.jsx(fd,{title:t("system.systemDetails","System Details"),icon:Kh,children:s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsx(ei,{icon:Kh,label:t("system.os","Operating System"),value:c.system.platform,subValue:c.system.platform_release}),s.jsx(ei,{icon:f_,label:t("system.architecture","Architecture"),value:c.system.architecture}),s.jsx(ei,{icon:Kh,label:t("system.python","Python"),value:c.system.python_version}),s.jsx(ei,{icon:Jn,label:t("system.bootTime","Boot Time"),value:bg(c.system.boot_time,v)})]})})]})}function IZe(){const t=pl(),{login:e}=lh(),{showToast:n}=Yn(),{mode:r}=oh(),[i,a]=w.useState(""),[o,l]=w.useState(""),c=pt({mutationFn:()=>e(i,o),onSuccess:()=>{n("Logged in successfully"),t("/")},onError:d=>{n(d.message||"Login failed","error")}}),u=d=>{if(d.preventDefault(),!i||!o){n("Please enter username and password","error");return}c.mutate()};return s.jsx("div",{className:"min-h-screen flex items-center justify-center bg-bambu-dark p-4",children:s.jsxs("div",{className:"max-w-md w-full space-y-8 p-8 bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary shadow-lg",children:[s.jsxs("div",{className:"text-center",children:[s.jsx("div",{className:"flex items-center justify-center mb-6",children:s.jsx("img",{src:r==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-16"})}),s.jsx("h2",{className:"text-3xl font-bold text-white",children:"Bambuddy Login"}),s.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"Sign in to your account"})]}),s.jsxs("form",{className:"mt-8 space-y-6",onSubmit:u,children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{htmlFor:"username",className:"block text-sm font-medium text-white mb-2",children:"Username"}),s.jsx("input",{id:"username",type:"text",required:!0,value:i,onChange:d=>a(d.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:"Enter your username",autoComplete:"username"})]}),s.jsxs("div",{children:[s.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-white mb-2",children:"Password"}),s.jsx("input",{id:"password",type:"password",required:!0,value:o,onChange:d=>l(d.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:"Enter your password",autoComplete:"current-password"})]})]}),s.jsx("div",{children:s.jsx("button",{type:"submit",disabled:c.isPending,className:"w-full flex justify-center py-3 px-4 bg-bambu-green hover:bg-bambu-green-light text-white font-medium rounded-lg shadow-lg shadow-bambu-green/20 hover:shadow-bambu-green/30 focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:ring-offset-2 focus:ring-offset-bambu-dark-secondary transition-all disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-bambu-green",children:c.isPending?"Logging in...":"Sign in"})})]})]})})}function FZe(){const t=pl(),{showToast:e}=Yn(),{mode:n}=oh(),{refreshAuth:r}=lh(),[i,a]=w.useState(!1),[o,l]=w.useState(""),[c,u]=w.useState(""),[d,f]=w.useState(""),m=pt({mutationFn:()=>me.setupAuth({auth_enabled:i,admin_username:i?o:void 0,admin_password:i?c:void 0}),onSuccess:async b=>{await r(),b.auth_enabled?b.admin_created?(e("Authentication enabled and admin user created"),t("/login")):(e("Authentication enabled using existing admin users"),t("/login")):(e("Setup completed"),t("/"))},onError:b=>{e(b.message,"error")}}),p=b=>{if(b.preventDefault(),i&&(o||c)){if(!o||!c){e("Please enter both admin username and password, or leave both empty to use existing admin users","error");return}if(c!==d){e("Passwords do not match","error");return}if(c.length<6){e("Password must be at least 6 characters","error");return}}m.mutate()};return s.jsx("div",{className:"min-h-screen flex items-center justify-center bg-bambu-dark p-4",children:s.jsxs("div",{className:"max-w-md w-full space-y-8 p-8 bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary shadow-lg",children:[s.jsxs("div",{className:"text-center",children:[s.jsx("div",{className:"flex items-center justify-center mb-6",children:s.jsx("img",{src:n==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-16"})}),s.jsx("h2",{className:"text-3xl font-bold text-white",children:"Bambuddy Setup"}),s.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"Configure authentication for your Bambuddy instance"})]}),s.jsxs("form",{className:"mt-8 space-y-6",onSubmit:p,children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center p-4 bg-bambu-dark-secondary/50 rounded-lg border border-bambu-dark-tertiary",children:[s.jsx("input",{id:"auth-enabled",type:"checkbox",checked:i,onChange:b=>a(b.target.checked),className:"h-4 w-4 text-bambu-green focus:ring-bambu-green border-bambu-dark-tertiary rounded bg-bambu-dark-secondary"}),s.jsx("label",{htmlFor:"auth-enabled",className:"ml-3 block text-sm font-medium text-white",children:"Enable Authentication"})]}),i&&s.jsxs("div",{className:"space-y-4 mt-4",children:[s.jsx("div",{className:"p-3 bg-bambu-dark-secondary/50 border border-bambu-dark-tertiary rounded-lg",children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(Zl,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsxs("div",{className:"text-sm text-bambu-gray",children:[s.jsx("p",{className:"text-white font-medium mb-1",children:"Admin Account"}),s.jsx("p",{children:"If admin users already exist, authentication will be enabled using the existing admin accounts. Leave the fields below empty to use existing admins, or enter new credentials to create a new admin user."})]})]})}),s.jsxs("div",{children:[s.jsxs("label",{htmlFor:"admin-username",className:"block text-sm font-medium text-white mb-2",children:["Admin Username ",s.jsx("span",{className:"text-bambu-gray text-xs",children:"(optional if admin users exist)"})]}),s.jsx("input",{id:"admin-username",type:"text",value:o,onChange:b=>l(b.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:"Enter admin username (optional)",autoComplete:"username"})]}),s.jsxs("div",{children:[s.jsxs("label",{htmlFor:"admin-password",className:"block text-sm font-medium text-white mb-2",children:["Admin Password ",s.jsx("span",{className:"text-bambu-gray text-xs",children:"(optional if admin users exist)"})]}),s.jsx("input",{id:"admin-password",type:"password",value:c,onChange:b=>u(b.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:"Enter admin password (optional)",minLength:6,autoComplete:"new-password"})]}),c&&s.jsxs("div",{children:[s.jsx("label",{htmlFor:"confirm-password",className:"block text-sm font-medium text-white mb-2",children:"Confirm Password"}),s.jsx("input",{id:"confirm-password",type:"password",value:d,onChange:b=>f(b.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:"Confirm admin password",minLength:6,autoComplete:"new-password"})]})]})]}),s.jsx("div",{children:s.jsx("button",{type:"submit",disabled:m.isPending,className:"w-full flex justify-center py-3 px-4 bg-bambu-green hover:bg-bambu-green-light text-white font-medium rounded-lg shadow-lg shadow-bambu-green/20 hover:shadow-bambu-green/30 focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:ring-offset-2 focus:ring-offset-bambu-dark-secondary transition-all disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-bambu-green",children:m.isPending?"Setting up...":"Complete Setup"})})]})]})})}function UZe(){const t=pl(),{user:e}=lh(),{showToast:n}=Yn(),r=ln(),[i,a]=w.useState(!1),[o,l]=w.useState(null),[c,u]=w.useState(null),[d,f]=w.useState({username:"",password:"",role:"user"});w.useEffect(()=>{const A=k=>{k.key==="Escape"&&i&&(a(!1),f({username:"",password:"",role:"user"}))};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[i]);const{data:m=[],isLoading:p}=ft({queryKey:["users"],queryFn:()=>me.getUsers()}),b=pt({mutationFn:A=>me.createUser(A),onSuccess:()=>{r.invalidateQueries({queryKey:["users"]}),a(!1),f({username:"",password:"",role:"user"}),n("User created successfully")},onError:A=>{n(A.message,"error")}}),v=pt({mutationFn:({id:A,data:k})=>me.updateUser(A,k),onSuccess:()=>{r.invalidateQueries({queryKey:["users"]}),l(null),f({username:"",password:"",role:"user"}),n("User updated successfully")},onError:A=>{n(A.message,"error")}}),x=pt({mutationFn:A=>me.deleteUser(A),onSuccess:()=>{r.invalidateQueries({queryKey:["users"]}),n("User deleted successfully")},onError:A=>{n(A.message,"error")}}),y=()=>{if(!d.username||!d.password){n("Please fill in all required fields","error");return}b.mutate(d)},S=A=>{const k={username:d.username||void 0,password:d.password||void 0,role:d.role};k.password||delete k.password,v.mutate({id:A,data:k})},M=A=>{u(A)},N=A=>{l(A.id),f({username:A.username,password:"",role:A.role})};return e?.role!=="admin"?s.jsx("div",{className:"p-6",children:s.jsx(Nt,{children:s.jsx(Ct,{className:"py-6",children:s.jsxs("div",{className:"flex items-center gap-3 text-red-400",children:[s.jsx(vP,{className:"w-5 h-5"}),s.jsx("p",{className:"text-white",children:"You do not have permission to access this page."})]})})})}):s.jsxs("div",{className:"p-6",children:[s.jsxs("div",{className:"flex justify-between items-center mb-6",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("button",{onClick:()=>t("/settings?tab=users"),className:"p-2 rounded-lg bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors",title:"Back to Settings",children:s.jsx(oK,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx(cf,{className:"w-6 h-6 text-bambu-green"}),"User Management"]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Manage users and their access to your Bambuddy instance"})]})]}),s.jsxs(Me,{onClick:()=>{a(!0),f({username:"",password:"",role:"user"})},children:[s.jsx(rr,{className:"w-4 h-4"}),"Create User"]})]}),p?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(mt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):s.jsx(Nt,{children:s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"min-w-full divide-y divide-bambu-dark-tertiary",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-bambu-gray uppercase tracking-wider",children:"Username"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-bambu-gray uppercase tracking-wider",children:"Role"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-bambu-gray uppercase tracking-wider",children:"Status"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-bambu-gray uppercase tracking-wider",children:"Actions"})]})}),s.jsx("tbody",{className:"divide-y divide-bambu-dark-tertiary",children:m.map(A=>s.jsxs("tr",{className:"hover:bg-bambu-dark-tertiary/50 transition-colors",children:[s.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium text-white",children:o===A.id?s.jsx("input",{type:"text",value:d.username,onChange:k=>f({...d,username:k.target.value}),className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green"}):A.username}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm",children:o===A.id?s.jsxs("select",{value:d.role,onChange:k=>f({...d,role:k.target.value}),className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green",children:[s.jsx("option",{value:"user",children:"User"}),s.jsx("option",{value:"admin",children:"Admin"})]}):s.jsx("span",{className:`px-3 py-1 rounded-full text-xs font-medium ${A.role==="admin"?"bg-purple-500/20 text-purple-300":"bg-blue-500/20 text-blue-300"}`,children:A.role})}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm",children:s.jsx("span",{className:`px-3 py-1 rounded-full text-xs font-medium ${A.is_active?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:A.is_active?"Active":"Inactive"})}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium",children:o===A.id?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Me,{size:"sm",onClick:()=>S(A.id),disabled:v.isPending,children:[v.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(bs,{className:"w-4 h-4"}),"Save"]}),s.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>{l(null),f({username:"",password:"",role:"user"})},children:"Cancel"})]}):s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Me,{size:"sm",variant:"ghost",onClick:()=>N(A),children:[s.jsx(cE,{className:"w-4 h-4"}),"Edit"]}),A.id!==e?.id&&s.jsxs(Me,{size:"sm",variant:"ghost",onClick:()=>M(A.id),children:[s.jsx(hn,{className:"w-4 h-4"}),"Delete"]})]})})]},A.id))})]})})}),i&&s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:()=>{a(!1),f({username:"",password:"",role:"user"})},children:s.jsxs(Nt,{className:"w-full max-w-md",onClick:A=>A.stopPropagation(),children:[s.jsx(Er,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(cf,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Create User"})]}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>{a(!1),f({username:"",password:"",role:"user"})},children:s.jsx(Gt,{className:"w-5 h-5"})})]})}),s.jsxs(Ct,{children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Username"}),s.jsx("input",{type:"text",value:d.username,onChange:A=>f({...d,username:A.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:"Enter username",autoComplete:"username"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Password"}),s.jsx("input",{type:"password",value:d.password,onChange:A=>f({...d,password:A.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:"Enter password",autoComplete:"new-password",minLength:6})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Role"}),s.jsxs("select",{value:d.role,onChange:A=>f({...d,role:A.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",children:[s.jsx("option",{value:"user",children:"User"}),s.jsx("option",{value:"admin",children:"Admin"})]})]})]}),s.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[s.jsx(Me,{variant:"secondary",onClick:()=>{a(!1),f({username:"",password:"",role:"user"})},children:"Cancel"}),s.jsx(Me,{onClick:y,disabled:b.isPending||!d.username||!d.password,children:b.isPending?s.jsxs(s.Fragment,{children:[s.jsx(mt,{className:"w-4 h-4 animate-spin"}),"Creating..."]}):s.jsxs(s.Fragment,{children:[s.jsx(rr,{className:"w-4 h-4"}),"Create User"]})})]})]})]})}),c!==null&&s.jsx(zn,{title:"Delete User",message:"Are you sure you want to delete this user? This action cannot be undone.",confirmText:"Delete User",variant:"danger",onConfirm:()=>{x.mutate(c),u(null)},onCancel:()=>u(null)})]})}function zZe(){const t=w.useRef(null),e=w.useRef(null),n=ln(),[r,i]=w.useState(!1),a=w.useRef(new Set),o=w.useRef(null),l=w.useRef(new Map),c=w.useRef(null),u=w.useRef([]),d=w.useRef(!1),f=w.useRef(()=>{}),m=w.useCallback(()=>{if(d.current||u.current.length===0)return;d.current=!0;const S=()=>{const M=u.current.shift();M?requestAnimationFrame(()=>{f.current(M),u.current.length>0?setTimeout(S,16):d.current=!1}):d.current=!1};S()},[]),p=w.useCallback(()=>{if(t.current?.readyState===WebSocket.OPEN)return;const M=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,N=new WebSocket(M);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=k=>{try{const C=JSON.parse(k.data);C.type==="printer_status"&&C.printer_id!==void 0&&C.data?f.current(C):(u.current.push(C),m())}catch{}},N.onclose=k=>{console.log("[WebSocket] Closed",k.code,k.reason),A&&(clearInterval(A),A=null),i(!1),t.current=null,e.current=window.setTimeout(()=>{p()},3e3)},N.onerror=k=>{console.error("[WebSocket] Error",k),N.close()},t.current=N},[m]),b=w.useCallback((S,M)=>{const N=l.current.get(S)||{};l.current.set(S,{...N,...M}),c.current||(c.current=window.setTimeout(()=>{const A=new Map(l.current);l.current.clear(),c.current=null,requestAnimationFrame(()=>{A.forEach((k,C)=>{n.setQueryData(["printerStatus",C],D=>{const T={...D,...k};return T.wifi_signal==null&&D?.wifi_signal!=null&&(T.wifi_signal=D.wifi_signal),T})})})},100))},[n]),v=w.useCallback(S=>{a.current.add(S),o.current&&clearTimeout(o.current),o.current=window.setTimeout(()=>{const M=Array.from(a.current);a.current.clear(),o.current=null;let N=0;M.forEach(A=>{setTimeout(()=>{requestAnimationFrame(()=>{n.invalidateQueries({queryKey:[A]})})},N),N+=500})},3e3)},[n]),x=w.useCallback(S=>{switch(S.type){case"printer_status":S.printer_id!==void 0&&S.data&&b(S.printer_id,S.data);break;case"print_start":S.printer_id!==void 0&&n.invalidateQueries({queryKey:["printerStatus",S.printer_id]});break;case"print_complete":v("archives"),v("archiveStats");break;case"archive_created":v("archives"),v("archiveStats");break;case"archive_updated":v("archives");break;case"pong":break;case"plate_not_empty":window.dispatchEvent(new CustomEvent("plate-not-empty",{detail:{printer_id:S.printer_id,printer_name:S.printer_name,message:S.message}}));break}},[n,v,b]);w.useEffect(()=>{f.current=x},[x]),w.useEffect(()=>(p(),()=>{e.current&&clearTimeout(e.current),o.current&&clearTimeout(o.current),c.current&&clearTimeout(c.current),t.current&&t.current.close()}),[p]);const y=w.useCallback(S=>{t.current?.readyState===WebSocket.OPEN&&t.current.send(JSON.stringify(S))},[]);return{isConnected:r,sendMessage:y}}const BZe=new hue({defaultOptions:{queries:{staleTime:1e3*60,retry:1}}});function $Ze({children:t}){return zZe(),s.jsx(s.Fragment,{children:t})}function HZe({children:t}){const{authEnabled:e,loading:n,user:r}=lh();return n?s.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e&&!r?s.jsx(Aw,{to:"/login",replace:!0}):s.jsx(s.Fragment,{children:t})}function VZe({children:t}){const{authEnabled:e,loading:n,user:r}=lh();return n?s.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e?r?r.role!=="admin"?s.jsx(Aw,{to:"/",replace:!0}):s.jsx(s.Fragment,{children:t}):s.jsx(Aw,{to:"/login",replace:!0}):s.jsx(s.Fragment,{children:t})}function GZe({children:t}){const{authEnabled:e,loading:n}=lh();return n?s.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e?s.jsx(Aw,{to:"/login",replace:!0}):s.jsx(s.Fragment,{children:t})}function WZe(){return s.jsx(Ime,{children:s.jsx(Yme,{children:s.jsx(fue,{client:BZe,children:s.jsx($me,{children:s.jsx(Pce,{children:s.jsxs(oce,{children:[s.jsx(Ki,{path:"/setup",element:s.jsx(GZe,{children:s.jsx(FZe,{})})}),s.jsx(Ki,{path:"/login",element:s.jsx(IZe,{})}),s.jsx(Ki,{path:"/camera/:printerId",element:s.jsx(jZe,{})}),s.jsxs(Ki,{element:s.jsx(HZe,{children:s.jsx($Ze,{children:s.jsx(Wme,{})})}),children:[s.jsx(Ki,{index:!0,element:s.jsx(YPe,{})}),s.jsx(Ki,{path:"archives",element:s.jsx(NKe,{})}),s.jsx(Ki,{path:"queue",element:s.jsx(uYe,{})}),s.jsx(Ki,{path:"stats",element:s.jsx(MYe,{})}),s.jsx(Ki,{path:"profiles",element:s.jsx(aZe,{})}),s.jsx(Ki,{path:"maintenance",element:s.jsx(uZe,{})}),s.jsx(Ki,{path:"projects",element:s.jsx(hZe,{})}),s.jsx(Ki,{path:"projects/:id",element:s.jsx(yZe,{})}),s.jsx(Ki,{path:"files",element:s.jsx(AZe,{})}),s.jsx(Ki,{path:"settings",element:s.jsx(VZe,{children:s.jsx(KYe,{})})}),s.jsx(Ki,{path:"users",element:s.jsx(UZe,{})}),s.jsx(Ki,{path:"system",element:s.jsx(LZe,{})}),s.jsx(Ki,{path:"external/:id",element:s.jsx(PZe,{})})]})]})})})})})})}soe.createRoot(document.getElementById("root")).render(s.jsx(w.StrictMode,{children:s.jsx(WZe,{})}));