| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729 |
- function Qse(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 u_=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 VA={exports:{}},ib={};var YU;function Zse(){if(YU)return ib;YU=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 ib.Fragment=e,ib.jsx=n,ib.jsxs=n,ib}var QU;function Jse(){return QU||(QU=1,VA.exports=Zse()),VA.exports}var s=Jse(),GA={exports:{}},gn={};var ZU;function eoe(){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(){}},y=Object.assign,x={};function v(z,V,ne){this.props=z,this.context=V,this.refs=x,this.updater=ne||b}v.prototype.isReactComponent={},v.prototype.setState=function(z,V){if(typeof z!="object"&&typeof z!="function"&&z!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,z,V,"setState")},v.prototype.forceUpdate=function(z){this.updater.enqueueForceUpdate(this,z,"forceUpdate")};function S(){}S.prototype=v.prototype;function M(z,V,ne){this.props=z,this.context=V,this.refs=x,this.updater=ne||b}var E=M.prototype=new S;E.constructor=M,y(E,v.prototype),E.isPureReactComponent=!0;var A=Array.isArray;function k(){}var T={H:null,A:null,T:null,S:null},D=Object.prototype.hasOwnProperty;function C(z,V,ne){var ie=ne.ref;return{$$typeof:t,type:z,key:V,ref:ie!==void 0?ie:null,props:ne}}function R(z,V){return C(z.type,V,z.props)}function U(z){return typeof z=="object"&&z!==null&&z.$$typeof===t}function O(z){var V={"=":"=0",":":"=2"};return"$"+z.replace(/[=:]/g,function(ne){return V[ne]})}var q=/\/+/g;function j(z,V){return typeof z=="object"&&z!==null&&z.key!=null?O(""+z.key):V.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(V){z.status==="pending"&&(z.status="fulfilled",z.value=V)},function(V){z.status==="pending"&&(z.status="rejected",z.reason=V)})),z.status){case"fulfilled":return z.value;case"rejected":throw z.reason}}throw z}function X(z,V,ne,ie,he){var me=typeof z;(me==="undefined"||me==="boolean")&&(z=null);var oe=!1;if(z===null)oe=!0;else switch(me){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,X(oe(z._payload),V,ne,ie,he)}}if(oe)return he=he(z),oe=ie===""?"."+j(z,0):ie,A(he)?(ne="",oe!=null&&(ne=oe.replace(q,"$&/")+"/"),X(he,V,ne,"",function(Ne){return Ne})):he!=null&&(U(he)&&(he=R(he,ne+(he.key==null||z&&z.key===he.key?"":(""+he.key).replace(q,"$&/")+"/")+oe)),V.push(he)),1;oe=0;var Ae=ie===""?".":ie+":";if(A(z))for(var ge=0;ge<z.length;ge++)ie=z[ge],me=Ae+j(ie,ge),oe+=X(ie,V,ne,me,he);else if(ge=p(z),typeof ge=="function")for(z=ge.call(z),ge=0;!(ie=z.next()).done;)ie=ie.value,me=Ae+j(ie,ge++),oe+=X(ie,V,ne,me,he);else if(me==="object"){if(typeof z.then=="function")return X(W(z),V,ne,ie,he);throw V=String(z),Error("Objects are not valid as a React child (found: "+(V==="[object Object]"?"object with keys {"+Object.keys(z).join(", ")+"}":V)+"). If you meant to render a collection of children, use an array instead.")}return oe}function G(z,V,ne){if(z==null)return z;var ie=[],he=0;return X(z,ie,"","",function(me){return V.call(ne,me,he++)}),ie}function Z(z){if(z._status===-1){var V=z._result;V=V(),V.then(function(ne){(z._status===0||z._status===-1)&&(z._status=1,z._result=ne)},function(ne){(z._status===0||z._status===-1)&&(z._status=2,z._result=ne)}),z._status===-1&&(z._status=0,z._result=V)}if(z._status===1)return z._result.default;throw z._result}var te=typeof reportError=="function"?reportError:function(z){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var V=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof z=="object"&&z!==null&&typeof z.message=="string"?String(z.message):String(z),error:z});if(!window.dispatchEvent(V))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",z);return}console.error(z)},ee={map:G,forEach:function(z,V,ne){G(z,function(){V.apply(this,arguments)},ne)},count:function(z){var V=0;return G(z,function(){V++}),V},toArray:function(z){return G(z,function(V){return V})||[]},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=ee,gn.Component=v,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=T,gn.__COMPILER_RUNTIME={__proto__:null,c:function(z){return T.H.useMemoCache(z)}},gn.cache=function(z){return function(){return z.apply(null,arguments)}},gn.cacheSignal=function(){return null},gn.cloneElement=function(z,V,ne){if(z==null)throw Error("The argument must be a React element, but you passed "+z+".");var ie=y({},z.props),he=z.key;if(V!=null)for(me in V.key!==void 0&&(he=""+V.key),V)!D.call(V,me)||me==="key"||me==="__self"||me==="__source"||me==="ref"&&V.ref===void 0||(ie[me]=V[me]);var me=arguments.length-2;if(me===1)ie.children=ne;else if(1<me){for(var oe=Array(me),Ae=0;Ae<me;Ae++)oe[Ae]=arguments[Ae+2];ie.children=oe}return C(z.type,he,ie)},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,V,ne){var ie,he={},me=null;if(V!=null)for(ie in V.key!==void 0&&(me=""+V.key),V)D.call(V,ie)&&ie!=="key"&&ie!=="__self"&&ie!=="__source"&&(he[ie]=V[ie]);var oe=arguments.length-2;if(oe===1)he.children=ne;else if(1<oe){for(var Ae=Array(oe),ge=0;ge<oe;ge++)Ae[ge]=arguments[ge+2];he.children=Ae}if(z&&z.defaultProps)for(ie in oe=z.defaultProps,oe)he[ie]===void 0&&(he[ie]=oe[ie]);return C(z,me,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:Z}},gn.memo=function(z,V){return{$$typeof:u,type:z,compare:V===void 0?null:V}},gn.startTransition=function(z){var V=T.T,ne={};T.T=ne;try{var ie=z(),he=T.S;he!==null&&he(ne,ie),typeof ie=="object"&&ie!==null&&typeof ie.then=="function"&&ie.then(k,te)}catch(me){te(me)}finally{V!==null&&ne.types!==null&&(V.types=ne.types),T.T=V}},gn.unstable_useCacheRefresh=function(){return T.H.useCacheRefresh()},gn.use=function(z){return T.H.use(z)},gn.useActionState=function(z,V,ne){return T.H.useActionState(z,V,ne)},gn.useCallback=function(z,V){return T.H.useCallback(z,V)},gn.useContext=function(z){return T.H.useContext(z)},gn.useDebugValue=function(){},gn.useDeferredValue=function(z,V){return T.H.useDeferredValue(z,V)},gn.useEffect=function(z,V){return T.H.useEffect(z,V)},gn.useEffectEvent=function(z){return T.H.useEffectEvent(z)},gn.useId=function(){return T.H.useId()},gn.useImperativeHandle=function(z,V,ne){return T.H.useImperativeHandle(z,V,ne)},gn.useInsertionEffect=function(z,V){return T.H.useInsertionEffect(z,V)},gn.useLayoutEffect=function(z,V){return T.H.useLayoutEffect(z,V)},gn.useMemo=function(z,V){return T.H.useMemo(z,V)},gn.useOptimistic=function(z,V){return T.H.useOptimistic(z,V)},gn.useReducer=function(z,V,ne){return T.H.useReducer(z,V,ne)},gn.useRef=function(z){return T.H.useRef(z)},gn.useState=function(z){return T.H.useState(z)},gn.useSyncExternalStore=function(z,V,ne){return T.H.useSyncExternalStore(z,V,ne)},gn.useTransition=function(){return T.H.useTransition()},gn.version="19.2.3",gn}var JU;function Gg(){return JU||(JU=1,GA.exports=eoe()),GA.exports}var w=Gg();const Ur=ml(w),toe=Qse({__proto__:null,default:Ur},[w]);var WA={exports:{}},ab={},qA={exports:{}},KA={};var ez;function noe(){return ez||(ez=1,(function(t){function e(X,G){var Z=X.length;X.push(G);e:for(;0<Z;){var te=Z-1>>>1,ee=X[te];if(0<i(ee,G))X[te]=G,X[Z]=ee,Z=te;else break e}}function n(X){return X.length===0?null:X[0]}function r(X){if(X.length===0)return null;var G=X[0],Z=X.pop();if(Z!==G){X[0]=Z;e:for(var te=0,ee=X.length,z=ee>>>1;te<z;){var V=2*(te+1)-1,ne=X[V],ie=V+1,he=X[ie];if(0>i(ne,Z))ie<ee&&0>i(he,ne)?(X[te]=he,X[ie]=Z,te=ie):(X[te]=ne,X[V]=Z,te=V);else if(ie<ee&&0>i(he,Z))X[te]=he,X[ie]=Z,te=ie;else break e}}return G}function i(X,G){var Z=X.sortIndex-G.sortIndex;return Z!==0?Z:X.id-G.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;t.unstable_now=function(){return a.now()}}else{var 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,y=!1,x=!1,v=typeof setTimeout=="function"?setTimeout:null,S=typeof clearTimeout=="function"?clearTimeout:null,M=typeof setImmediate<"u"?setImmediate:null;function E(X){for(var G=n(u);G!==null;){if(G.callback===null)r(u);else if(G.startTime<=X)r(u),G.sortIndex=G.expirationTime,e(c,G);else break;G=n(u)}}function A(X){if(y=!1,E(X),!b)if(n(c)!==null)b=!0,k||(k=!0,O());else{var G=n(u);G!==null&&W(A,G.startTime-X)}}var k=!1,T=-1,D=5,C=-1;function R(){return x?!0:!(t.unstable_now()-C<D)}function U(){if(x=!1,k){var X=t.unstable_now();C=X;var G=!0;try{e:{b=!1,y&&(y=!1,S(T),T=-1),p=!0;var Z=m;try{t:{for(E(X),f=n(c);f!==null&&!(f.expirationTime>X&&R());){var te=f.callback;if(typeof te=="function"){f.callback=null,m=f.priorityLevel;var ee=te(f.expirationTime<=X);if(X=t.unstable_now(),typeof ee=="function"){f.callback=ee,E(X),G=!0;break t}f===n(c)&&r(c),E(X)}else r(c);f=n(c)}if(f!==null)G=!0;else{var z=n(u);z!==null&&W(A,z.startTime-X),G=!1}}break e}finally{f=null,m=Z,p=!1}G=void 0}}finally{G?O():k=!1}}}var O;if(typeof M=="function")O=function(){M(U)};else if(typeof MessageChannel<"u"){var q=new MessageChannel,j=q.port2;q.port1.onmessage=U,O=function(){j.postMessage(null)}}else O=function(){v(U,0)};function W(X,G){T=v(function(){X(t.unstable_now())},G)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(X){X.callback=null},t.unstable_forceFrameRate=function(X){0>X||125<X?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):D=0<X?Math.floor(1e3/X):5},t.unstable_getCurrentPriorityLevel=function(){return m},t.unstable_next=function(X){switch(m){case 1:case 2:case 3:var G=3;break;default:G=m}var Z=m;m=G;try{return X()}finally{m=Z}},t.unstable_requestPaint=function(){x=!0},t.unstable_runWithPriority=function(X,G){switch(X){case 1:case 2:case 3:case 4:case 5:break;default:X=3}var Z=m;m=X;try{return G()}finally{m=Z}},t.unstable_scheduleCallback=function(X,G,Z){var te=t.unstable_now();switch(typeof Z=="object"&&Z!==null?(Z=Z.delay,Z=typeof Z=="number"&&0<Z?te+Z:te):Z=te,X){case 1:var ee=-1;break;case 2:ee=250;break;case 5:ee=1073741823;break;case 4:ee=1e4;break;default:ee=5e3}return ee=Z+ee,X={id:d++,callback:G,priorityLevel:X,startTime:Z,expirationTime:ee,sortIndex:-1},Z>te?(X.sortIndex=Z,e(u,X),n(c)===null&&X===n(u)&&(y?(S(T),T=-1):y=!0,W(A,Z-te))):(X.sortIndex=ee,e(c,X),b||p||(b=!0,k||(k=!0,O()))),X},t.unstable_shouldYield=R,t.unstable_wrapCallback=function(X){var G=m;return function(){var Z=m;m=G;try{return X.apply(this,arguments)}finally{m=Z}}}})(KA)),KA}var tz;function roe(){return tz||(tz=1,qA.exports=noe()),qA.exports}var XA={exports:{}},Ca={};var nz;function ioe(){if(nz)return Ca;nz=1;var t=Gg();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 rz;function gq(){if(rz)return XA.exports;rz=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),XA.exports=ioe(),XA.exports}var iz;function aoe(){if(iz)return ab;iz=1;var t=roe(),e=Gg(),n=gq();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,N=g;;){var P=_.return;if(P===null)break;var F=P.alternate;if(F===null){if(N=P.return,N!==null){_=N;continue}break}if(P.child===F.child){for(F=P.child;F;){if(F===_)return c(P),h;if(F===N)return c(P),g;F=F.sibling}throw Error(r(188))}if(_.return!==N.return)_=P,N=F;else{for(var Q=!1,xe=P.child;xe;){if(xe===_){Q=!0,_=P,N=F;break}if(xe===N){Q=!0,N=P,_=F;break}xe=xe.sibling}if(!Q){for(xe=F.child;xe;){if(xe===_){Q=!0,_=F,N=P;break}if(xe===N){Q=!0,N=F,_=P;break}xe=xe.sibling}if(!Q)throw Error(r(189))}}if(_.alternate!==N)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"),y=Symbol.for("react.fragment"),x=Symbol.for("react.strict_mode"),v=Symbol.for("react.profiler"),S=Symbol.for("react.consumer"),M=Symbol.for("react.context"),E=Symbol.for("react.forward_ref"),A=Symbol.for("react.suspense"),k=Symbol.for("react.suspense_list"),T=Symbol.for("react.memo"),D=Symbol.for("react.lazy"),C=Symbol.for("react.activity"),R=Symbol.for("react.memo_cache_sentinel"),U=Symbol.iterator;function O(h){return h===null||typeof h!="object"?null:(h=U&&h[U]||h["@@iterator"],typeof h=="function"?h:null)}var q=Symbol.for("react.client.reference");function 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 y:return"Fragment";case v:return"Profiler";case x:return"StrictMode";case A:return"Suspense";case k:return"SuspenseList";case C: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 E:var g=h.render;return h=h.displayName,h||(h=g.displayName||g.name||"",h=h!==""?"ForwardRef("+h+")":"ForwardRef"),h;case T: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,X=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,G=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Z={pending:!1,data:null,method:null,action:null},te=[],ee=-1;function z(h){return{current:h}}function V(h){0>ee||(h.current=te[ee],te[ee]=null,ee--)}function ne(h,g){ee++,te[ee]=h.current,h.current=g}var ie=z(null),he=z(null),me=z(null),oe=z(null);function Ae(h,g){switch(ne(me,g),ne(he,h),ne(ie,null),g.nodeType){case 9:case 11:h=(h=g.documentElement)&&(h=h.namespaceURI)?yU(h):0;break;default:if(h=g.tagName,g=g.namespaceURI)g=yU(g),h=vU(g,h);else switch(h){case"svg":h=1;break;case"math":h=2;break;default:h=0}}V(ie),ne(ie,h)}function ge(){V(ie),V(he),V(me)}function Ne(h){h.memoizedState!==null&&ne(oe,h);var g=ie.current,_=vU(g,h.type);g!==_&&(ne(he,h),ne(ie,_))}function _e(h){he.current===h&&(V(ie),V(he)),oe.current===h&&(V(oe),eb._currentValue=Z)}var le,He;function H(h){if(le===void 0)try{throw Error()}catch(_){var g=_.stack.trim().match(/\n( *(at )?)/);le=g&&g[1]||"",He=-1<_.stack.indexOf(`
- at`)?" (<anonymous>)":-1<_.stack.indexOf("@")?"@unknown:0:0":""}return`
- `+le+h+He}var J=!1;function K(h,g){if(!h||J)return"";J=!0;var _=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var N={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]}};N.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var P=Object.getOwnPropertyDescriptor(N.DetermineComponentFrameRoot,"name");P&&P.configurable&&Object.defineProperty(N.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var F=N.DetermineComponentFrameRoot(),Q=F[0],xe=F[1];if(Q&&xe){var Re=Q.split(`
- `),at=xe.split(`
- `);for(P=N=0;N<Re.length&&!Re[N].includes("DetermineComponentFrameRoot");)N++;for(;P<at.length&&!at[P].includes("DetermineComponentFrameRoot");)P++;if(N===Re.length||P===at.length)for(N=Re.length-1,P=at.length-1;1<=N&&0<=P&&Re[N]!==at[P];)P--;for(;1<=N&&0<=P;N--,P--)if(Re[N]!==at[P]){if(N!==1||P!==1)do if(N--,P--,0>P||Re[N]!==at[P]){var bt=`
- `+Re[N].replace(" at new "," at ");return h.displayName&&bt.includes("<anonymous>")&&(bt=bt.replace("<anonymous>",h.displayName)),bt}while(1<=N&&0<=P);break}}}finally{J=!1,Error.prepareStackTrace=_}return(_=h?h.displayName||h.name:"")?H(_):""}function B(h,g){switch(h.tag){case 26:case 27:case 5:return H(h.type);case 16:return H("Lazy");case 13:return h.child!==g&&g!==null?H("Suspense Fallback"):H("Suspense");case 19:return H("SuspenseList");case 0:case 15:return K(h.type,!1);case 11:return K(h.type.render,!1);case 1:return K(h.type,!0);case 31:return H("Activity");default:return""}}function I(h){try{var g="",_=null;do g+=B(h,_),_=h,h=h.return;while(h);return g}catch(N){return`
- Error generating stack: `+N.message+`
- `+N.stack}}var ce=Object.prototype.hasOwnProperty,Ee=t.unstable_scheduleCallback,Ie=t.unstable_cancelCallback,ue=t.unstable_shouldYield,$=t.unstable_requestPaint,L=t.unstable_now,Y=t.unstable_getCurrentPriorityLevel,pe=t.unstable_ImmediatePriority,Se=t.unstable_UserBlockingPriority,ae=t.unstable_NormalPriority,je=t.unstable_LowPriority,De=t.unstable_IdlePriority,Xe=t.log,et=t.unstable_setDisableYieldValue,Qe=null,se=null;function ye(h){if(typeof Xe=="function"&&et(h),se&&typeof se.setStrictMode=="function")try{se.setStrictMode(Qe,h)}catch{}}var ke=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 Te(h,g,_){var N=h.pendingLanes;if(N===0)return 0;var P=0,F=h.suspendedLanes,Q=h.pingedLanes;h=h.warmLanes;var xe=N&134217727;return xe!==0?(N=xe&~F,N!==0?P=Le(N):(Q&=xe,Q!==0?P=Le(Q):_||(_=xe&~h,_!==0&&(P=Le(_))))):(xe=N&~F,xe!==0?P=Le(xe):Q!==0?P=Le(Q):_||(_=N&~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 We(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,_,N,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,Re=h.expirationTimes,at=h.hiddenUpdates;for(_=Q&~_;0<_;){var bt=31-ke(_),_t=1<<bt;xe[bt]=0,Re[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}N!==0&&yn(h,N,0),F!==0&&P===0&&h.tag!==0&&(h.suspendedLanes|=F&~(Q&~g))}function yn(h,g,_){h.pendingLanes|=g,h.suspendedLanes&=~g;var N=31-ke(g);h.entangledLanes|=g,h.entanglements[N]=h.entanglements[N]|1073741824|_&261930}function xt(h,g){var _=h.entangledLanes|=g;for(h=h.entanglements;_;){var N=31-ke(_),P=1<<N;P&g|h[N]&g&&(h[N]|=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=G.p;return h!==0?h:(h=window.event,h===void 0?32:HU(h.type))}function Cr(h,g){var _=G.p;try{return G.p=h,g()}finally{G.p=_}}var er=Math.random().toString(36).slice(2),Un="__reactFiber$"+er,yr="__reactProps$"+er,Ci="__reactContainer$"+er,gi="__reactEvents$"+er,we="__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[we],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=AU(h);h!==null;){if(_=h[Un])return _;h=AU(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 Vt(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 de(h){h[lt]=!0}var Pe=new Set,Ge={};function qe(h,g){Ve(h,g),Ve(h+"Capture",g)}function Ve(h,g){for(Ge[h]=g,h=0;h<g.length;h++)Pe.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={},Nt={};function St(h){return ce.call(Nt,h)?!0:ce.call(Dt,h)?!1:wt.test(h)?Nt[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 N=g.toLowerCase().slice(0,5);if(N!=="data-"&&N!=="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,_,N){if(N===null)h.removeAttribute(_);else{switch(typeof N){case"undefined":case"function":case"symbol":case"boolean":h.removeAttribute(_);return}h.setAttributeNS(g,_,""+N)}}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 Qt(h,g,_){var N=Object.getOwnPropertyDescriptor(h.constructor.prototype,g);if(!h.hasOwnProperty(g)&&typeof N<"u"&&typeof N.get=="function"&&typeof N.set=="function"){var P=N.get,F=N.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:N.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=Qt(h,g,""+h[g])}}function be(h){if(!h)return!1;var g=h._valueTracker;if(!g)return!0;var _=g.getValue(),N="";return h&&(N=ct(h)?h.checked?"true":"false":h.value),h=N,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,_,N,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(_)):N!=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,_,N,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}N=N??P,N=typeof N!="function"&&typeof N!="symbol"&&!!N,h.checked=xe?h.checked:!!N,h.defaultChecked=!!N,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,_,N){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&&N&&(h[_].defaultSelected=!0)}else{for(_=""+Rt(_),g=null,P=0;P<h.length;P++){if(h[P].value===_){h[P].selected=!0,N&&(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,_,N){if(g==null){if(N!=null){if(_!=null)throw Error(r(92));if(W(N)){if(1<N.length)throw Error(r(93));N=N[0]}_=N}_==null&&(_=""),g=_}_=Rt(g),h.defaultValue=_,N=h.textContent,N===_&&N!==""&&N!==null&&(h.value=N),Kt(h)}function vr(h,g){if(g){var _=h.firstChild;if(_&&_===h.lastChild&&_.nodeType===3){_.nodeValue=g;return}}h.textContent=g}var Qn=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 N=g.indexOf("--")===0;_==null||typeof _=="boolean"||_===""?N?h.setProperty(g,""):g==="float"?h.cssFloat="":h[g]="":N?h.setProperty(g,_):typeof _!="number"||_===0||Qn.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 N in _)!_.hasOwnProperty(N)||g!=null&&g.hasOwnProperty(N)||(N.indexOf("--")===0?h.setProperty(N,""):N==="float"?h.cssFloat="":h[N]="");for(var P in g)N=g[P],g.hasOwnProperty(P)&&_[P]!==N&&kr(h,P,N)}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 qie=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"]]),Kie=/^[\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 tv(h){return Kie.test(""+h)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":h}function fc(){}var BE=null;function $E(h){return h=h.target||h.srcElement||window,h.correspondingUseElement&&(h=h.correspondingUseElement),h.nodeType===3?h.parentNode:h}var gm=null,xm=null;function bI(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 N=_[g];if(N!==h&&N.form===h.form){var P=N[yr]||null;if(!P)throw Error(r(90));Xt(N,P.value,P.defaultValue,P.defaultValue,P.checked,P.defaultChecked,P.type,P.name)}}for(g=0;g<_.length;g++)N=_[g],N.form===h.form&&be(N)}break e;case"textarea":$n(h,_.value,_.defaultValue);break e;case"select":g=_.value,g!=null&&ki(h,!!_.multiple,g,!1)}}}var HE=!1;function yI(h,g,_){if(HE)return h(g,_);HE=!0;try{var N=h(g);return N}finally{if(HE=!1,(gm!==null||xm!==null)&&($v(),gm&&(g=gm,h=xm,xm=gm=null,bI(g),h)))for(g=0;g<h.length;g++)bI(h[g])}}function xx(h,g){var _=h.stateNode;if(_===null)return null;var N=_[yr]||null;if(N===null)return null;_=N[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":(N=!N.disabled)||(h=h.type,N=!(h==="button"||h==="input"||h==="select"||h==="textarea")),h=!N;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"),VE=!1;if(mc)try{var bx={};Object.defineProperty(bx,"passive",{get:function(){VE=!0}}),window.addEventListener("test",bx,bx),window.removeEventListener("test",bx,bx)}catch{VE=!1}var ku=null,GE=null,nv=null;function vI(){if(nv)return nv;var h,g=GE,_=g.length,N,P="value"in ku?ku.value:ku.textContent,F=P.length;for(h=0;h<_&&g[h]===P[h];h++);var Q=_-h;for(N=1;N<=Q&&g[_-N]===P[F-N];N++);return nv=P.slice(h,1<N?1-N:void 0)}function rv(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 iv(){return!0}function _I(){return!1}function ls(h){function g(_,N,P,F,Q){this._reactName=_,this._targetInst=P,this.type=N,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)?iv:_I,this.isPropagationStopped=_I,this}return f(g.prototype,{preventDefault:function(){this.defaultPrevented=!0;var _=this.nativeEvent;_&&(_.preventDefault?_.preventDefault():typeof _.returnValue!="unknown"&&(_.returnValue=!1),this.isDefaultPrevented=iv)},stopPropagation:function(){var _=this.nativeEvent;_&&(_.stopPropagation?_.stopPropagation():typeof _.cancelBubble!="unknown"&&(_.cancelBubble=!0),this.isPropagationStopped=iv)},persist:function(){},isPersistent:iv}),g}var vh={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(h){return h.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},av=ls(vh),yx=f({},vh,{view:0,detail:0}),Xie=ls(yx),WE,qE,vx,sv=f({},yx,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:XE,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!==vx&&(vx&&h.type==="mousemove"?(WE=h.screenX-vx.screenX,qE=h.screenY-vx.screenY):qE=WE=0,vx=h),WE)},movementY:function(h){return"movementY"in h?h.movementY:qE}}),wI=ls(sv),Yie=f({},sv,{dataTransfer:0}),Qie=ls(Yie),Zie=f({},yx,{relatedTarget:0}),KE=ls(Zie),Jie=f({},vh,{animationName:0,elapsedTime:0,pseudoElement:0}),eae=ls(Jie),tae=f({},vh,{clipboardData:function(h){return"clipboardData"in h?h.clipboardData:window.clipboardData}}),nae=ls(tae),rae=f({},vh,{data:0}),SI=ls(rae),iae={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},aae={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"},sae={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function oae(h){var g=this.nativeEvent;return g.getModifierState?g.getModifierState(h):(h=sae[h])?!!g[h]:!1}function XE(){return oae}var lae=f({},yx,{key:function(h){if(h.key){var g=iae[h.key]||h.key;if(g!=="Unidentified")return g}return h.type==="keypress"?(h=rv(h),h===13?"Enter":String.fromCharCode(h)):h.type==="keydown"||h.type==="keyup"?aae[h.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:XE,charCode:function(h){return h.type==="keypress"?rv(h):0},keyCode:function(h){return h.type==="keydown"||h.type==="keyup"?h.keyCode:0},which:function(h){return h.type==="keypress"?rv(h):h.type==="keydown"||h.type==="keyup"?h.keyCode:0}}),cae=ls(lae),uae=f({},sv,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),MI=ls(uae),dae=f({},yx,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:XE}),hae=ls(dae),fae=f({},vh,{propertyName:0,elapsedTime:0,pseudoElement:0}),mae=ls(fae),pae=f({},sv,{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}),gae=ls(pae),xae=f({},vh,{newState:0,oldState:0}),bae=ls(xae),yae=[9,13,27,32],YE=mc&&"CompositionEvent"in window,_x=null;mc&&"documentMode"in document&&(_x=document.documentMode);var vae=mc&&"TextEvent"in window&&!_x,NI=mc&&(!YE||_x&&8<_x&&11>=_x),EI=" ",AI=!1;function TI(h,g){switch(h){case"keyup":return yae.indexOf(g.keyCode)!==-1;case"keydown":return g.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function CI(h){return h=h.detail,typeof h=="object"&&"data"in h?h.data:null}var bm=!1;function _ae(h,g){switch(h){case"compositionend":return CI(g);case"keypress":return g.which!==32?null:(AI=!0,EI);case"textInput":return h=g.data,h===EI&&AI?null:h;default:return null}}function wae(h,g){if(bm)return h==="compositionend"||!YE&&TI(h,g)?(h=vI(),nv=GE=ku=null,bm=!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 NI&&g.locale!=="ko"?null:g.data;default:return null}}var Sae={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 kI(h){var g=h&&h.nodeName&&h.nodeName.toLowerCase();return g==="input"?!!Sae[h.type]:g==="textarea"}function jI(h,g,_,N){gm?xm?xm.push(N):xm=[N]:gm=N,g=Xv(g,"onChange"),0<g.length&&(_=new av("onChange","change",null,_,N),h.push({event:_,listeners:g}))}var wx=null,Sx=null;function Mae(h){fU(h,0)}function ov(h){var g=Vt(h);if(be(g))return h}function PI(h,g){if(h==="change")return g}var RI=!1;if(mc){var QE;if(mc){var ZE="oninput"in document;if(!ZE){var DI=document.createElement("div");DI.setAttribute("oninput","return;"),ZE=typeof DI.oninput=="function"}QE=ZE}else QE=!1;RI=QE&&(!document.documentMode||9<document.documentMode)}function OI(){wx&&(wx.detachEvent("onpropertychange",LI),Sx=wx=null)}function LI(h){if(h.propertyName==="value"&&ov(Sx)){var g=[];jI(g,Sx,h,$E(h)),yI(Mae,g)}}function Nae(h,g,_){h==="focusin"?(OI(),wx=g,Sx=_,wx.attachEvent("onpropertychange",LI)):h==="focusout"&&OI()}function Eae(h){if(h==="selectionchange"||h==="keyup"||h==="keydown")return ov(Sx)}function Aae(h,g){if(h==="click")return ov(g)}function Tae(h,g){if(h==="input"||h==="change")return ov(g)}function Cae(h,g){return h===g&&(h!==0||1/h===1/g)||h!==h&&g!==g}var Cs=typeof Object.is=="function"?Object.is:Cae;function Mx(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),N=Object.keys(g);if(_.length!==N.length)return!1;for(N=0;N<_.length;N++){var P=_[N];if(!ce.call(g,P)||!Cs(h[P],g[P]))return!1}return!0}function II(h){for(;h&&h.firstChild;)h=h.firstChild;return h}function FI(h,g){var _=II(h);h=0;for(var N;_;){if(_.nodeType===3){if(N=h+_.textContent.length,h<=g&&N>=g)return{node:_,offset:g-h};h=N}e:{for(;_;){if(_.nextSibling){_=_.nextSibling;break e}_=_.parentNode}_=void 0}_=II(_)}}function UI(h,g){return h&&g?h===g?!0:h&&h.nodeType===3?!1:g&&g.nodeType===3?UI(h,g.parentNode):"contains"in h?h.contains(g):h.compareDocumentPosition?!!(h.compareDocumentPosition(g)&16):!1:!1}function zI(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 JE(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 kae=mc&&"documentMode"in document&&11>=document.documentMode,ym=null,e2=null,Nx=null,t2=!1;function BI(h,g,_){var N=_.window===_?_.document:_.nodeType===9?_:_.ownerDocument;t2||ym==null||ym!==ut(N)||(N=ym,"selectionStart"in N&&JE(N)?N={start:N.selectionStart,end:N.selectionEnd}:(N=(N.ownerDocument&&N.ownerDocument.defaultView||window).getSelection(),N={anchorNode:N.anchorNode,anchorOffset:N.anchorOffset,focusNode:N.focusNode,focusOffset:N.focusOffset}),Nx&&Mx(Nx,N)||(Nx=N,N=Xv(e2,"onSelect"),0<N.length&&(g=new av("onSelect","select",null,g,_),h.push({event:g,listeners:N}),g.target=ym)))}function _h(h,g){var _={};return _[h.toLowerCase()]=g.toLowerCase(),_["Webkit"+h]="webkit"+g,_["Moz"+h]="moz"+g,_}var vm={animationend:_h("Animation","AnimationEnd"),animationiteration:_h("Animation","AnimationIteration"),animationstart:_h("Animation","AnimationStart"),transitionrun:_h("Transition","TransitionRun"),transitionstart:_h("Transition","TransitionStart"),transitioncancel:_h("Transition","TransitionCancel"),transitionend:_h("Transition","TransitionEnd")},n2={},$I={};mc&&($I=document.createElement("div").style,"AnimationEvent"in window||(delete vm.animationend.animation,delete vm.animationiteration.animation,delete vm.animationstart.animation),"TransitionEvent"in window||delete vm.transitionend.transition);function wh(h){if(n2[h])return n2[h];if(!vm[h])return h;var g=vm[h],_;for(_ in g)if(g.hasOwnProperty(_)&&_ in $I)return n2[h]=g[_];return h}var HI=wh("animationend"),VI=wh("animationiteration"),GI=wh("animationstart"),jae=wh("transitionrun"),Pae=wh("transitionstart"),Rae=wh("transitioncancel"),WI=wh("transitionend"),qI=new Map,r2="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(" ");r2.push("scrollEnd");function Bo(h,g){qI.set(h,g),qe(g,[h])}var lv=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=[],_m=0,i2=0;function cv(){for(var h=_m,g=i2=_m=0;g<h;){var _=no[g];no[g++]=null;var N=no[g];no[g++]=null;var P=no[g];no[g++]=null;var F=no[g];if(no[g++]=null,N!==null&&P!==null){var Q=N.pending;Q===null?P.next=P:(P.next=Q.next,Q.next=P),N.pending=P}F!==0&&KI(_,P,F)}}function uv(h,g,_,N){no[_m++]=h,no[_m++]=g,no[_m++]=_,no[_m++]=N,i2|=N,h.lanes|=N,h=h.alternate,h!==null&&(h.lanes|=N)}function a2(h,g,_,N){return uv(h,g,_,N),dv(h)}function Sh(h,g){return uv(h,null,null,g),dv(h)}function KI(h,g,_){h.lanes|=_;var N=h.alternate;N!==null&&(N.lanes|=_);for(var P=!1,F=h.return;F!==null;)F.childLanes|=_,N=F.alternate,N!==null&&(N.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-ke(_),h=F.hiddenUpdates,N=h[P],N===null?h[P]=[g]:N.push(g),g.lane=_|536870912),F):null}function dv(h){if(50<qx)throw qx=0,mA=null,Error(r(185));for(var g=h.return;g!==null;)h=g,g=h.return;return h.tag===3?h.stateNode:null}var wm={};function Dae(h,g,_,N){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=N,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ks(h,g,_,N){return new Dae(h,g,_,N)}function s2(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 XI(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 hv(h,g,_,N,P,F){var Q=0;if(N=h,typeof h=="function")s2(h)&&(Q=1);else if(typeof h=="string")Q=Use(h,_,ie.current)?26:h==="html"||h==="head"||h==="body"?27:5;else e:switch(h){case C:return h=ks(31,_,g,P),h.elementType=C,h.lanes=F,h;case y:return Mh(_.children,P,F,g);case x:Q=8,P|=24;break;case v:return h=ks(12,_,g,P|2),h.elementType=v,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 E:Q=11;break e;case T:Q=14;break e;case D:Q=16,N=null;break e}Q=29,_=Error(r(130,h===null?"null":typeof h,"")),N=null}return g=ks(Q,_,g,P),g.elementType=h,g.type=N,g.lanes=F,g}function Mh(h,g,_,N){return h=ks(7,h,N,g),h.lanes=_,h}function o2(h,g,_){return h=ks(6,h,null,g),h.lanes=_,h}function YI(h){var g=ks(18,null,null,0);return g.stateNode=h,g}function l2(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 QI=new WeakMap;function ro(h,g){if(typeof h=="object"&&h!==null){var _=QI.get(h);return _!==void 0?_:(g={value:h,source:g,stack:I(g)},QI.set(h,g),g)}return{value:h,source:g,stack:I(g)}}var Sm=[],Mm=0,fv=null,Ex=0,io=[],ao=0,ju=null,vl=1,_l="";function gc(h,g){Sm[Mm++]=Ex,Sm[Mm++]=fv,fv=h,Ex=g}function ZI(h,g,_){io[ao++]=vl,io[ao++]=_l,io[ao++]=ju,ju=h;var N=vl;h=_l;var P=32-ke(N)-1;N&=~(1<<P),_+=1;var F=32-ke(g)+P;if(30<F){var Q=P-P%5;F=(N&(1<<Q)-1).toString(32),N>>=Q,P-=Q,vl=1<<32-ke(g)+P|_<<P|N,_l=F+h}else vl=1<<F|_<<P|N,_l=h}function c2(h){h.return!==null&&(gc(h,1),ZI(h,1,0))}function u2(h){for(;h===fv;)fv=Sm[--Mm],Sm[Mm]=null,Ex=Sm[--Mm],Sm[Mm]=null;for(;h===ju;)ju=io[--ao],io[ao]=null,_l=io[--ao],io[ao]=null,vl=io[--ao],io[ao]=null}function JI(h,g){io[ao++]=vl,io[ao++]=_l,io[ao++]=ju,vl=g.id,_l=g.overflow,ju=h}var ca=null,Pr=null,Ln=!1,Pu=null,so=!1,d2=Error(r(519));function Ru(h){var g=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Ax(ro(g,h)),d2}function eF(h){var g=h.stateNode,_=h.type,N=h.memoizedProps;switch(g[Un]=h,g[yr]=N,_){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;_<Xx.length;_++)jn(Xx[_],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,N.value,N.defaultValue,N.checked,N.defaultChecked,N.type,N.name,!0);break;case"select":jn("invalid",g);break;case"textarea":jn("invalid",g),ui(g,N.value,N.defaultValue,N.children)}_=N.children,typeof _!="string"&&typeof _!="number"&&typeof _!="bigint"||g.textContent===""+_||N.suppressHydrationWarning===!0||xU(g.textContent,_)?(N.popover!=null&&(jn("beforetoggle",g),jn("toggle",g)),N.onScroll!=null&&jn("scroll",g),N.onScrollEnd!=null&&jn("scrollend",g),N.onClick!=null&&(g.onclick=fc),g=!0):g=!1,g||Ru(h,!0)}function tF(h){for(ca=h.return;ca;)switch(ca.tag){case 5:case 31:case 13:so=!1;return;case 27:case 3:so=!0;return;default:ca=ca.return}}function Nm(h){if(h!==ca)return!1;if(!Ln)return tF(h),Ln=!0,!1;var g=h.tag,_;if((_=g!==3&&g!==27)&&((_=g===5)&&(_=h.type,_=!(_!=="form"&&_!=="button")||CA(h.type,h.memoizedProps)),_=!_),_&&Pr&&Ru(h),tF(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,qu(h.type)?(h=DA,DA=null,Pr=h):Pr=g):Pr=ca?lo(h.stateNode.nextSibling):null;return!0}function Nh(){Pr=ca=null,Ln=!1}function h2(){var h=Pu;return h!==null&&(hs===null?hs=h:hs.push.apply(hs,h),Pu=null),h}function Ax(h){Pu===null?Pu=[h]:Pu.push(h)}var f2=z(null),Eh=null,xc=null;function Du(h,g,_){ne(f2,g._currentValue),g._currentValue=_}function bc(h){h._currentValue=f2.current,V(f2)}function m2(h,g,_){for(;h!==null;){var N=h.alternate;if((h.childLanes&g)!==g?(h.childLanes|=g,N!==null&&(N.childLanes|=g)):N!==null&&(N.childLanes&g)!==g&&(N.childLanes|=g),h===_)break;h=h.return}}function p2(h,g,_,N){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 Re=0;Re<g.length;Re++)if(xe.context===g[Re]){F.lanes|=_,xe=F.alternate,xe!==null&&(xe.lanes|=_),m2(F.return,_,h),N||(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|=_),m2(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,_,N){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(eb):h=[eb])}P=P.return}h!==null&&p2(g,h,_,N),g.flags|=262144}function mv(h){for(h=h.firstContext;h!==null;){if(!Cs(h.context._currentValue,h.memoizedValue))return!0;h=h.next}return!1}function Ah(h){Eh=h,xc=null,h=h.dependencies,h!==null&&(h.firstContext=null)}function ua(h){return nF(Eh,h)}function pv(h,g){return Eh===null&&Ah(h),nF(h,g)}function nF(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 Oae=typeof AbortController<"u"?AbortController:function(){var h=[],g=this.signal={aborted:!1,addEventListener:function(_,N){h.push(N)}};this.abort=function(){g.aborted=!0,h.forEach(function(_){return _()})}},Lae=t.unstable_scheduleCallback,Iae=t.unstable_NormalPriority,xi={$$typeof:M,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function g2(){return{controller:new Oae,data:new Map,refCount:0}}function Tx(h){h.refCount--,h.refCount===0&&Lae(Iae,function(){h.controller.abort()})}var Cx=null,x2=0,Am=0,Tm=null;function Fae(h,g){if(Cx===null){var _=Cx=[];x2=0,Am=vA(),Tm={status:"pending",value:void 0,then:function(N){_.push(N)}}}return x2++,g.then(rF,rF),g}function rF(){if(--x2===0&&Cx!==null){Tm!==null&&(Tm.status="fulfilled");var h=Cx;Cx=null,Am=0,Tm=null;for(var g=0;g<h.length;g++)(0,h[g])()}}function Uae(h,g){var _=[],N={status:"pending",value:null,reason:null,then:function(P){_.push(P)}};return h.then(function(){N.status="fulfilled",N.value=g;for(var P=0;P<_.length;P++)(0,_[P])(g)},function(P){for(N.status="rejected",N.reason=P,P=0;P<_.length;P++)(0,_[P])(void 0)}),N}var iF=X.S;X.S=function(h,g){B5=L(),typeof g=="object"&&g!==null&&typeof g.then=="function"&&Fae(h,g),iF!==null&&iF(h,g)};var Th=z(null);function b2(){var h=Th.current;return h!==null?h:_r.pooledCache}function gv(h,g){g===null?ne(Th,Th.current):ne(Th,g.pool)}function aF(){var h=b2();return h===null?null:{parent:xi._currentValue,pool:h}}var Cm=Error(r(460)),y2=Error(r(474)),xv=Error(r(542)),bv={then:function(){}};function sF(h){return h=h.status,h==="fulfilled"||h==="rejected"}function oF(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,cF(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(N){if(g.status==="pending"){var P=g;P.status="fulfilled",P.value=N}},function(N){if(g.status==="pending"){var P=g;P.status="rejected",P.reason=N}})}switch(g.status){case"fulfilled":return g.value;case"rejected":throw h=g.reason,cF(h),h}throw kh=g,Cm}}function Ch(h){try{var g=h._init;return g(h._payload)}catch(_){throw _!==null&&typeof _=="object"&&typeof _.then=="function"?(kh=_,Cm):_}}var kh=null;function lF(){if(kh===null)throw Error(r(459));var h=kh;return kh=null,h}function cF(h){if(h===Cm||h===xv)throw Error(r(483))}var km=null,kx=0;function yv(h){var g=kx;return kx+=1,km===null&&(km=[]),oF(km,h,g)}function jx(h,g){g=g.props.ref,h.ref=g!==void 0?g:null}function vv(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 uF(h){function g(Ye,ze){if(h){var rt=Ye.deletions;rt===null?(Ye.deletions=[ze],Ye.flags|=16):rt.push(ze)}}function _(Ye,ze){if(!h)return null;for(;ze!==null;)g(Ye,ze),ze=ze.sibling;return null}function N(Ye){for(var ze=new Map;Ye!==null;)Ye.key!==null?ze.set(Ye.key,Ye):ze.set(Ye.index,Ye),Ye=Ye.sibling;return ze}function P(Ye,ze){return Ye=pc(Ye,ze),Ye.index=0,Ye.sibling=null,Ye}function F(Ye,ze,rt){return Ye.index=rt,h?(rt=Ye.alternate,rt!==null?(rt=rt.index,rt<ze?(Ye.flags|=67108866,ze):rt):(Ye.flags|=67108866,ze)):(Ye.flags|=1048576,ze)}function Q(Ye){return h&&Ye.alternate===null&&(Ye.flags|=67108866),Ye}function xe(Ye,ze,rt,vt){return ze===null||ze.tag!==6?(ze=o2(rt,Ye.mode,vt),ze.return=Ye,ze):(ze=P(ze,rt),ze.return=Ye,ze)}function Re(Ye,ze,rt,vt){var tn=rt.type;return tn===y?bt(Ye,ze,rt.props.children,vt,rt.key):ze!==null&&(ze.elementType===tn||typeof tn=="object"&&tn!==null&&tn.$$typeof===D&&Ch(tn)===ze.type)?(ze=P(ze,rt.props),jx(ze,rt),ze.return=Ye,ze):(ze=hv(rt.type,rt.key,rt.props,null,Ye.mode,vt),jx(ze,rt),ze.return=Ye,ze)}function at(Ye,ze,rt,vt){return ze===null||ze.tag!==4||ze.stateNode.containerInfo!==rt.containerInfo||ze.stateNode.implementation!==rt.implementation?(ze=l2(rt,Ye.mode,vt),ze.return=Ye,ze):(ze=P(ze,rt.children||[]),ze.return=Ye,ze)}function bt(Ye,ze,rt,vt,tn){return ze===null||ze.tag!==7?(ze=Mh(rt,Ye.mode,vt,tn),ze.return=Ye,ze):(ze=P(ze,rt),ze.return=Ye,ze)}function _t(Ye,ze,rt){if(typeof ze=="string"&&ze!==""||typeof ze=="number"||typeof ze=="bigint")return ze=o2(""+ze,Ye.mode,rt),ze.return=Ye,ze;if(typeof ze=="object"&&ze!==null){switch(ze.$$typeof){case p:return rt=hv(ze.type,ze.key,ze.props,null,Ye.mode,rt),jx(rt,ze),rt.return=Ye,rt;case b:return ze=l2(ze,Ye.mode,rt),ze.return=Ye,ze;case D:return ze=Ch(ze),_t(Ye,ze,rt)}if(W(ze)||O(ze))return ze=Mh(ze,Ye.mode,rt,null),ze.return=Ye,ze;if(typeof ze.then=="function")return _t(Ye,yv(ze),rt);if(ze.$$typeof===M)return _t(Ye,pv(Ye,ze),rt);vv(Ye,ze)}return null}function ot(Ye,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(Ye,ze,""+rt,vt);if(typeof rt=="object"&&rt!==null){switch(rt.$$typeof){case p:return rt.key===tn?Re(Ye,ze,rt,vt):null;case b:return rt.key===tn?at(Ye,ze,rt,vt):null;case D:return rt=Ch(rt),ot(Ye,ze,rt,vt)}if(W(rt)||O(rt))return tn!==null?null:bt(Ye,ze,rt,vt,null);if(typeof rt.then=="function")return ot(Ye,ze,yv(rt),vt);if(rt.$$typeof===M)return ot(Ye,ze,pv(Ye,rt),vt);vv(Ye,rt)}return null}function ht(Ye,ze,rt,vt,tn){if(typeof vt=="string"&&vt!==""||typeof vt=="number"||typeof vt=="bigint")return Ye=Ye.get(rt)||null,xe(ze,Ye,""+vt,tn);if(typeof vt=="object"&&vt!==null){switch(vt.$$typeof){case p:return Ye=Ye.get(vt.key===null?rt:vt.key)||null,Re(ze,Ye,vt,tn);case b:return Ye=Ye.get(vt.key===null?rt:vt.key)||null,at(ze,Ye,vt,tn);case D:return vt=Ch(vt),ht(Ye,ze,rt,vt,tn)}if(W(vt)||O(vt))return Ye=Ye.get(rt)||null,bt(ze,Ye,vt,tn,null);if(typeof vt.then=="function")return ht(Ye,ze,rt,yv(vt),tn);if(vt.$$typeof===M)return ht(Ye,ze,rt,pv(ze,vt),tn);vv(ze,vt)}return null}function qt(Ye,ze,rt,vt){for(var tn=null,Gn=null,Zt=ze,vn=ze=0,On=null;Zt!==null&&vn<rt.length;vn++){Zt.index>vn?(On=Zt,Zt=null):On=Zt.sibling;var Wn=ot(Ye,Zt,rt[vn],vt);if(Wn===null){Zt===null&&(Zt=On);break}h&&Zt&&Wn.alternate===null&&g(Ye,Zt),ze=F(Wn,ze,vn),Gn===null?tn=Wn:Gn.sibling=Wn,Gn=Wn,Zt=On}if(vn===rt.length)return _(Ye,Zt),Ln&&gc(Ye,vn),tn;if(Zt===null){for(;vn<rt.length;vn++)Zt=_t(Ye,rt[vn],vt),Zt!==null&&(ze=F(Zt,ze,vn),Gn===null?tn=Zt:Gn.sibling=Zt,Gn=Zt);return Ln&&gc(Ye,vn),tn}for(Zt=N(Zt);vn<rt.length;vn++)On=ht(Zt,Ye,vn,rt[vn],vt),On!==null&&(h&&On.alternate!==null&&Zt.delete(On.key===null?vn:On.key),ze=F(On,ze,vn),Gn===null?tn=On:Gn.sibling=On,Gn=On);return h&&Zt.forEach(function(Zu){return g(Ye,Zu)}),Ln&&gc(Ye,vn),tn}function an(Ye,ze,rt,vt){if(rt==null)throw Error(r(151));for(var tn=null,Gn=null,Zt=ze,vn=ze=0,On=null,Wn=rt.next();Zt!==null&&!Wn.done;vn++,Wn=rt.next()){Zt.index>vn?(On=Zt,Zt=null):On=Zt.sibling;var Zu=ot(Ye,Zt,Wn.value,vt);if(Zu===null){Zt===null&&(Zt=On);break}h&&Zt&&Zu.alternate===null&&g(Ye,Zt),ze=F(Zu,ze,vn),Gn===null?tn=Zu:Gn.sibling=Zu,Gn=Zu,Zt=On}if(Wn.done)return _(Ye,Zt),Ln&&gc(Ye,vn),tn;if(Zt===null){for(;!Wn.done;vn++,Wn=rt.next())Wn=_t(Ye,Wn.value,vt),Wn!==null&&(ze=F(Wn,ze,vn),Gn===null?tn=Wn:Gn.sibling=Wn,Gn=Wn);return Ln&&gc(Ye,vn),tn}for(Zt=N(Zt);!Wn.done;vn++,Wn=rt.next())Wn=ht(Zt,Ye,vn,Wn.value,vt),Wn!==null&&(h&&Wn.alternate!==null&&Zt.delete(Wn.key===null?vn:Wn.key),ze=F(Wn,ze,vn),Gn===null?tn=Wn:Gn.sibling=Wn,Gn=Wn);return h&&Zt.forEach(function(Yse){return g(Ye,Yse)}),Ln&&gc(Ye,vn),tn}function hr(Ye,ze,rt,vt){if(typeof rt=="object"&&rt!==null&&rt.type===y&&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===y){if(ze.tag===7){_(Ye,ze.sibling),vt=P(ze,rt.props.children),vt.return=Ye,Ye=vt;break e}}else if(ze.elementType===tn||typeof tn=="object"&&tn!==null&&tn.$$typeof===D&&Ch(tn)===ze.type){_(Ye,ze.sibling),vt=P(ze,rt.props),jx(vt,rt),vt.return=Ye,Ye=vt;break e}_(Ye,ze);break}else g(Ye,ze);ze=ze.sibling}rt.type===y?(vt=Mh(rt.props.children,Ye.mode,vt,rt.key),vt.return=Ye,Ye=vt):(vt=hv(rt.type,rt.key,rt.props,null,Ye.mode,vt),jx(vt,rt),vt.return=Ye,Ye=vt)}return Q(Ye);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){_(Ye,ze.sibling),vt=P(ze,rt.children||[]),vt.return=Ye,Ye=vt;break e}else{_(Ye,ze);break}else g(Ye,ze);ze=ze.sibling}vt=l2(rt,Ye.mode,vt),vt.return=Ye,Ye=vt}return Q(Ye);case D:return rt=Ch(rt),hr(Ye,ze,rt,vt)}if(W(rt))return qt(Ye,ze,rt,vt);if(O(rt)){if(tn=O(rt),typeof tn!="function")throw Error(r(150));return rt=tn.call(rt),an(Ye,ze,rt,vt)}if(typeof rt.then=="function")return hr(Ye,ze,yv(rt),vt);if(rt.$$typeof===M)return hr(Ye,ze,pv(Ye,rt),vt);vv(Ye,rt)}return typeof rt=="string"&&rt!==""||typeof rt=="number"||typeof rt=="bigint"?(rt=""+rt,ze!==null&&ze.tag===6?(_(Ye,ze.sibling),vt=P(ze,rt),vt.return=Ye,Ye=vt):(_(Ye,ze),vt=o2(rt,Ye.mode,vt),vt.return=Ye,Ye=vt),Q(Ye)):_(Ye,ze)}return function(Ye,ze,rt,vt){try{kx=0;var tn=hr(Ye,ze,rt,vt);return km=null,tn}catch(Zt){if(Zt===Cm||Zt===xv)throw Zt;var Gn=ks(29,Zt,null,Ye.mode);return Gn.lanes=vt,Gn.return=Ye,Gn}}}var jh=uF(!0),dF=uF(!1),Ou=!1;function v2(h){h.updateQueue={baseState:h.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function _2(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 Lu(h){return{lane:h,tag:0,payload:null,callback:null,next:null}}function Iu(h,g,_){var N=h.updateQueue;if(N===null)return null;if(N=N.shared,(Zn&2)!==0){var P=N.pending;return P===null?g.next=g:(g.next=P.next,P.next=g),N.pending=g,g=dv(h),KI(h,null,_),g}return uv(h,N,g,_),dv(h)}function Px(h,g,_){if(g=g.updateQueue,g!==null&&(g=g.shared,(_&4194048)!==0)){var N=g.lanes;N&=h.pendingLanes,_|=N,g.lanes=_,xt(h,_)}}function w2(h,g){var _=h.updateQueue,N=h.alternate;if(N!==null&&(N=N.updateQueue,_===N)){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:N.baseState,firstBaseUpdate:P,lastBaseUpdate:F,shared:N.shared,callbacks:N.callbacks},h.updateQueue=_;return}h=_.lastBaseUpdate,h===null?_.firstBaseUpdate=g:h.next=g,_.lastBaseUpdate=g}var S2=!1;function Rx(){if(S2){var h=Tm;if(h!==null)throw h}}function Dx(h,g,_,N){S2=!1;var P=h.updateQueue;Ou=!1;var F=P.firstBaseUpdate,Q=P.lastBaseUpdate,xe=P.shared.pending;if(xe!==null){P.shared.pending=null;var Re=xe,at=Re.next;Re.next=null,Q===null?F=at:Q.next=at,Q=Re;var bt=h.alternate;bt!==null&&(bt=bt.updateQueue,xe=bt.lastBaseUpdate,xe!==Q&&(xe===null?bt.firstBaseUpdate=at:xe.next=at,bt.lastBaseUpdate=Re))}if(F!==null){var _t=P.baseState;Q=0,bt=at=Re=null,xe=F;do{var ot=xe.lane&-536870913,ht=ot!==xe.lane;if(ht?(Dn&ot)===ot:(N&ot)===ot){ot!==0&&ot===Am&&(S2=!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:Ou=!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,Re=_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&&(Re=_t),P.baseState=Re,P.firstBaseUpdate=at,P.lastBaseUpdate=bt,F===null&&(P.shared.lanes=0),$u|=Q,h.lanes=Q,h.memoizedState=_t}}function hF(h,g){if(typeof h!="function")throw Error(r(191,h));h.call(g)}function fF(h,g){var _=h.callbacks;if(_!==null)for(h.callbacks=null,h=0;h<_.length;h++)hF(_[h],g)}var jm=z(null),_v=z(0);function mF(h,g){h=Ac,ne(_v,h),ne(jm,g),Ac=h|g.baseLanes}function M2(){ne(_v,Ac),ne(jm,jm.current)}function N2(){Ac=_v.current,V(jm),V(_v)}var js=z(null),oo=null;function Fu(h){var g=h.alternate;ne(di,di.current&1),ne(js,h),oo===null&&(g===null||jm.current!==null||g.memoizedState!==null)&&(oo=h)}function E2(h){ne(di,di.current),ne(js,h),oo===null&&(oo=h)}function pF(h){h.tag===22?(ne(di,di.current),ne(js,h),oo===null&&(oo=h)):Uu()}function Uu(){ne(di,di.current),ne(js,js.current)}function Ps(h){V(js),oo===h&&(oo=null),V(di)}var di=z(0);function wv(h){for(var g=h;g!==null;){if(g.tag===13){var _=g.memoizedState;if(_!==null&&(_=_.dehydrated,_===null||PA(_)||RA(_)))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,Sv=!1,Pm=!1,Ph=!1,Mv=0,Ox=0,Rm=null,zae=0;function Qr(){throw Error(r(321))}function A2(h,g){if(g===null)return!1;for(var _=0;_<g.length&&_<h.length;_++)if(!Cs(h[_],g[_]))return!1;return!0}function T2(h,g,_,N,P,F){return yc=F,bn=g,g.memoizedState=null,g.updateQueue=null,g.lanes=0,X.H=h===null||h.memoizedState===null?ZF:H2,Ph=!1,F=_(N,P),Ph=!1,Pm&&(F=xF(g,_,N,P)),gF(h),F}function gF(h){X.H=Fx;var g=ur!==null&&ur.next!==null;if(yc=0,bi=ur=bn=null,Sv=!1,Ox=0,Rm=null,g)throw Error(r(300));h===null||yi||(h=h.dependencies,h!==null&&mv(h)&&(yi=!0))}function xF(h,g,_,N){bn=h;var P=0;do{if(Pm&&(Rm=null),Ox=0,Pm=!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)}X.H=JF,F=g(_,N)}while(Pm);return F}function Bae(){var h=X.H,g=h.useState()[0];return g=typeof g.then=="function"?Lx(g):g,h=h.useState()[0],(ur!==null?ur.memoizedState:null)!==h&&(bn.flags|=1024),g}function C2(){var h=Mv!==0;return Mv=0,h}function k2(h,g,_){g.updateQueue=h.updateQueue,g.flags&=-2053,h.lanes&=~_}function j2(h){if(Sv){for(h=h.memoizedState;h!==null;){var g=h.queue;g!==null&&(g.pending=null),h=h.next}Sv=!1}yc=0,bi=ur=bn=null,Pm=!1,Ox=Mv=0,Rm=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 Nv(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Lx(h){var g=Ox;return Ox+=1,Rm===null&&(Rm=[]),h=oF(Rm,h,g),g=bn,(bi===null?g.memoizedState:bi.next)===null&&(g=g.alternate,X.H=g===null||g.memoizedState===null?ZF:H2),h}function Ev(h){if(h!==null&&typeof h=="object"){if(typeof h.then=="function")return Lx(h);if(h.$$typeof===M)return ua(h)}throw Error(r(438,String(h)))}function P2(h){var g=null,_=bn.updateQueue;if(_!==null&&(g=_.memoCache),g==null){var N=bn.alternate;N!==null&&(N=N.updateQueue,N!==null&&(N=N.memoCache,N!=null&&(g={data:N.data.map(function(P){return P.slice()}),index:0})))}if(g==null&&(g={data:[],index:0}),_===null&&(_=Nv(),bn.updateQueue=_),_.memoCache=g,_=g.data[g.index],_===void 0)for(_=g.data[g.index]=Array(h),N=0;N<h;N++)_[N]=R;return g.index++,_}function vc(h,g){return typeof g=="function"?g(h):g}function Av(h){var g=hi();return R2(g,ur,h)}function R2(h,g,_){var N=h.queue;if(N===null)throw Error(r(311));N.lastRenderedReducer=_;var P=h.baseQueue,F=N.pending;if(F!==null){if(P!==null){var Q=P.next;P.next=F.next,F.next=Q}g.baseQueue=P=F,N.pending=null}if(F=h.baseState,P===null)h.memoizedState=F;else{g=P.next;var xe=Q=null,Re=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)Re!==null&&(Re=Re.next={lane:0,revertLane:0,gesture:null,action:at.action,hasEagerState:at.hasEagerState,eagerState:at.eagerState,next:null}),_t===Am&&(bt=!0);else if((yc&ot)===ot){at=at.next,ot===Am&&(bt=!0);continue}else _t={lane:0,revertLane:at.revertLane,gesture:null,action:at.action,hasEagerState:at.hasEagerState,eagerState:at.eagerState,next:null},Re===null?(xe=Re=_t,Q=F):Re=Re.next=_t,bn.lanes|=ot,$u|=ot;_t=at.action,Ph&&_(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},Re===null?(xe=Re=ot,Q=F):Re=Re.next=ot,bn.lanes|=_t,$u|=_t;at=at.next}while(at!==null&&at!==g);if(Re===null?Q=F:Re.next=xe,!Cs(F,h.memoizedState)&&(yi=!0,bt&&(_=Tm,_!==null)))throw _;h.memoizedState=F,h.baseState=Q,h.baseQueue=Re,N.lastRenderedState=F}return P===null&&(N.lanes=0),[h.memoizedState,N.dispatch]}function D2(h){var g=hi(),_=g.queue;if(_===null)throw Error(r(311));_.lastRenderedReducer=h;var N=_.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,N]}function bF(h,g,_){var N=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,I2(_F.bind(null,N,P,h),[h]),P.getSnapshot!==g||Q||bi!==null&&bi.memoizedState.tag&1){if(N.flags|=2048,Dm(9,{destroy:void 0},vF.bind(null,N,P,_,g),null),_r===null)throw Error(r(349));F||(yc&127)!==0||yF(N,g,_)}return _}function yF(h,g,_){h.flags|=16384,h={getSnapshot:g,value:_},g=bn.updateQueue,g===null?(g=Nv(),bn.updateQueue=g,g.stores=[h]):(_=g.stores,_===null?g.stores=[h]:_.push(h))}function vF(h,g,_,N){g.value=_,g.getSnapshot=N,wF(g)&&SF(h)}function _F(h,g,_){return _(function(){wF(g)&&SF(h)})}function wF(h){var g=h.getSnapshot;h=h.value;try{var _=g();return!Cs(h,_)}catch{return!0}}function SF(h){var g=Sh(h,2);g!==null&&fs(g,h,2)}function O2(h){var g=Ga();if(typeof h=="function"){var _=h;if(h=_(),Ph){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 MF(h,g,_,N){return h.baseState=_,R2(h,ur,typeof N=="function"?N:vc)}function $ae(h,g,_,N,P){if(kv(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)}};X.T!==null?_(!0):F.isTransition=!1,N(F),_=g.pending,_===null?(F.next=g.pending=F,NF(g,F)):(F.next=_.next,g.pending=_.next=F)}}function NF(h,g){var _=g.action,N=g.payload,P=h.state;if(g.isTransition){var F=X.T,Q={};X.T=Q;try{var xe=_(P,N),Re=X.S;Re!==null&&Re(Q,xe),EF(h,g,xe)}catch(at){L2(h,g,at)}finally{F!==null&&Q.types!==null&&(F.types=Q.types),X.T=F}}else try{F=_(P,N),EF(h,g,F)}catch(at){L2(h,g,at)}}function EF(h,g,_){_!==null&&typeof _=="object"&&typeof _.then=="function"?_.then(function(N){AF(h,g,N)},function(N){return L2(h,g,N)}):AF(h,g,_)}function AF(h,g,_){g.status="fulfilled",g.value=_,TF(g),h.state=_,g=h.pending,g!==null&&(_=g.next,_===g?h.pending=null:(_=_.next,g.next=_,NF(h,_)))}function L2(h,g,_){var N=h.pending;if(h.pending=null,N!==null){N=N.next;do g.status="rejected",g.reason=_,TF(g),g=g.next;while(g!==N)}h.action=null}function TF(h){h=h.listeners;for(var g=0;g<h.length;g++)(0,h[g])()}function CF(h,g){return g}function kF(h,g){if(Ln){var _=_r.formState;if(_!==null){e:{var N=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),N=P.data==="F!";break e}}Ru(N)}N=!1}N&&(g=_[0])}}return _=Ga(),_.memoizedState=_.baseState=g,N={pending:null,lanes:0,dispatch:null,lastRenderedReducer:CF,lastRenderedState:g},_.queue=N,_=XF.bind(null,bn,N),N.dispatch=_,N=O2(!1),F=$2.bind(null,bn,!1,N.queue),N=Ga(),P={state:g,dispatch:null,action:h,pending:null},N.queue=P,_=$ae.bind(null,bn,P,F,_),P.dispatch=_,N.memoizedState=h,[g,_,!1]}function jF(h){var g=hi();return PF(g,ur,h)}function PF(h,g,_){if(g=R2(h,g,CF)[0],h=Av(vc)[0],typeof g=="object"&&g!==null&&typeof g.then=="function")try{var N=Lx(g)}catch(Q){throw Q===Cm?xv:Q}else N=g;g=hi();var P=g.queue,F=P.dispatch;return _!==g.memoizedState&&(bn.flags|=2048,Dm(9,{destroy:void 0},Hae.bind(null,P,_),null)),[N,F,h]}function Hae(h,g){h.action=g}function RF(h){var g=hi(),_=ur;if(_!==null)return PF(g,_,h);hi(),g=g.memoizedState,_=hi();var N=_.queue.dispatch;return _.memoizedState=h,[g,N,!1]}function Dm(h,g,_,N){return h={tag:h,create:_,deps:N,inst:g,next:null},g=bn.updateQueue,g===null&&(g=Nv(),bn.updateQueue=g),_=g.lastEffect,_===null?g.lastEffect=h.next=h:(N=_.next,_.next=h,h.next=N,g.lastEffect=h),h}function DF(){return hi().memoizedState}function Tv(h,g,_,N){var P=Ga();bn.flags|=h,P.memoizedState=Dm(1|g,{destroy:void 0},_,N===void 0?null:N)}function Cv(h,g,_,N){var P=hi();N=N===void 0?null:N;var F=P.memoizedState.inst;ur!==null&&N!==null&&A2(N,ur.memoizedState.deps)?P.memoizedState=Dm(g,F,_,N):(bn.flags|=h,P.memoizedState=Dm(1|g,F,_,N))}function OF(h,g){Tv(8390656,8,h,g)}function I2(h,g){Cv(2048,8,h,g)}function Vae(h){bn.flags|=4;var g=bn.updateQueue;if(g===null)g=Nv(),bn.updateQueue=g,g.events=[h];else{var _=g.events;_===null?g.events=[h]:_.push(h)}}function LF(h){var g=hi().memoizedState;return Vae({ref:g,nextImpl:h}),function(){if((Zn&2)!==0)throw Error(r(440));return g.impl.apply(void 0,arguments)}}function IF(h,g){return Cv(4,2,h,g)}function FF(h,g){return Cv(4,4,h,g)}function UF(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 zF(h,g,_){_=_!=null?_.concat([h]):null,Cv(4,4,UF.bind(null,g,h),_)}function F2(){}function BF(h,g){var _=hi();g=g===void 0?null:g;var N=_.memoizedState;return g!==null&&A2(g,N[1])?N[0]:(_.memoizedState=[h,g],h)}function $F(h,g){var _=hi();g=g===void 0?null:g;var N=_.memoizedState;if(g!==null&&A2(g,N[1]))return N[0];if(N=h(),Ph){ye(!0);try{h()}finally{ye(!1)}}return _.memoizedState=[N,g],N}function U2(h,g,_){return _===void 0||(yc&1073741824)!==0&&(Dn&261930)===0?h.memoizedState=g:(h.memoizedState=_,h=H5(),bn.lanes|=h,$u|=h,_)}function HF(h,g,_,N){return Cs(_,g)?_:jm.current!==null?(h=U2(h,_,N),Cs(h,g)||(yi=!0),h):(yc&42)===0||(yc&1073741824)!==0&&(Dn&261930)===0?(yi=!0,h.memoizedState=_):(h=H5(),bn.lanes|=h,$u|=h,g)}function VF(h,g,_,N,P){var F=G.p;G.p=F!==0&&8>F?F:8;var Q=X.T,xe={};X.T=xe,$2(h,!1,g,_);try{var Re=P(),at=X.S;if(at!==null&&at(xe,Re),Re!==null&&typeof Re=="object"&&typeof Re.then=="function"){var bt=Uae(Re,N);Ix(h,g,bt,Os(h))}else Ix(h,g,N,Os(h))}catch(_t){Ix(h,g,{then:function(){},status:"rejected",reason:_t},Os())}finally{G.p=F,Q!==null&&xe.types!==null&&(Q.types=xe.types),X.T=Q}}function Gae(){}function z2(h,g,_,N){if(h.tag!==5)throw Error(r(476));var P=GF(h).queue;VF(h,P,g,Z,_===null?Gae:function(){return WF(h),_(N)})}function GF(h){var g=h.memoizedState;if(g!==null)return g;g={memoizedState:Z,baseState:Z,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vc,lastRenderedState:Z},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 WF(h){var g=GF(h);g.next===null&&(g=h.alternate.memoizedState),Ix(h,g.next.queue,{},Os())}function B2(){return ua(eb)}function qF(){return hi().memoizedState}function KF(){return hi().memoizedState}function Wae(h){for(var g=h.return;g!==null;){switch(g.tag){case 24:case 3:var _=Os();h=Lu(_);var N=Iu(g,h,_);N!==null&&(fs(N,g,_),Px(N,g,_)),g={cache:g2()},h.payload=g;return}g=g.return}}function qae(h,g,_){var N=Os();_={lane:N,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null},kv(h)?YF(g,_):(_=a2(h,g,_,N),_!==null&&(fs(_,h,N),QF(_,g,N)))}function XF(h,g,_){var N=Os();Ix(h,g,_,N)}function Ix(h,g,_,N){var P={lane:N,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null};if(kv(h))YF(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 uv(h,g,P,0),_r===null&&cv(),!1}catch{}if(_=a2(h,g,P,N),_!==null)return fs(_,h,N),QF(_,g,N),!0}return!1}function $2(h,g,_,N){if(N={lane:2,revertLane:vA(),gesture:null,action:N,hasEagerState:!1,eagerState:null,next:null},kv(h)){if(g)throw Error(r(479))}else g=a2(h,_,N,2),g!==null&&fs(g,h,2)}function kv(h){var g=h.alternate;return h===bn||g!==null&&g===bn}function YF(h,g){Pm=Sv=!0;var _=h.pending;_===null?g.next=g:(g.next=_.next,_.next=g),h.pending=g}function QF(h,g,_){if((_&4194048)!==0){var N=g.lanes;N&=h.pendingLanes,_|=N,g.lanes=_,xt(h,_)}}var Fx={readContext:ua,use:Ev,useCallback:Qr,useContext:Qr,useEffect:Qr,useImperativeHandle:Qr,useLayoutEffect:Qr,useInsertionEffect:Qr,useMemo:Qr,useReducer:Qr,useRef:Qr,useState:Qr,useDebugValue:Qr,useDeferredValue:Qr,useTransition:Qr,useSyncExternalStore:Qr,useId:Qr,useHostTransitionStatus:Qr,useFormState:Qr,useActionState:Qr,useOptimistic:Qr,useMemoCache:Qr,useCacheRefresh:Qr};Fx.useEffectEvent=Qr;var ZF={readContext:ua,use:Ev,useCallback:function(h,g){return Ga().memoizedState=[h,g===void 0?null:g],h},useContext:ua,useEffect:OF,useImperativeHandle:function(h,g,_){_=_!=null?_.concat([h]):null,Tv(4194308,4,UF.bind(null,g,h),_)},useLayoutEffect:function(h,g){return Tv(4194308,4,h,g)},useInsertionEffect:function(h,g){Tv(4,2,h,g)},useMemo:function(h,g){var _=Ga();g=g===void 0?null:g;var N=h();if(Ph){ye(!0);try{h()}finally{ye(!1)}}return _.memoizedState=[N,g],N},useReducer:function(h,g,_){var N=Ga();if(_!==void 0){var P=_(g);if(Ph){ye(!0);try{_(g)}finally{ye(!1)}}}else P=g;return N.memoizedState=N.baseState=P,h={pending:null,lanes:0,dispatch:null,lastRenderedReducer:h,lastRenderedState:P},N.queue=h,h=h.dispatch=qae.bind(null,bn,h),[N.memoizedState,h]},useRef:function(h){var g=Ga();return h={current:h},g.memoizedState=h},useState:function(h){h=O2(h);var g=h.queue,_=XF.bind(null,bn,g);return g.dispatch=_,[h.memoizedState,_]},useDebugValue:F2,useDeferredValue:function(h,g){var _=Ga();return U2(_,h,g)},useTransition:function(){var h=O2(!1);return h=VF.bind(null,bn,h.queue,!0,!1),Ga().memoizedState=h,[!1,h]},useSyncExternalStore:function(h,g,_){var N=bn,P=Ga();if(Ln){if(_===void 0)throw Error(r(407));_=_()}else{if(_=g(),_r===null)throw Error(r(349));(Dn&127)!==0||yF(N,g,_)}P.memoizedState=_;var F={value:_,getSnapshot:g};return P.queue=F,OF(_F.bind(null,N,F,h),[h]),N.flags|=2048,Dm(9,{destroy:void 0},vF.bind(null,N,F,_,g),null),_},useId:function(){var h=Ga(),g=_r.identifierPrefix;if(Ln){var _=_l,N=vl;_=(N&~(1<<32-ke(N)-1)).toString(32)+_,g="_"+g+"R_"+_,_=Mv++,0<_&&(g+="H"+_.toString(32)),g+="_"}else _=zae++,g="_"+g+"r_"+_.toString(32)+"_";return h.memoizedState=g},useHostTransitionStatus:B2,useFormState:kF,useActionState:kF,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=$2.bind(null,bn,!0,_),_.dispatch=g,[h,g]},useMemoCache:P2,useCacheRefresh:function(){return Ga().memoizedState=Wae.bind(null,bn)},useEffectEvent:function(h){var g=Ga(),_={impl:h};return g.memoizedState=_,function(){if((Zn&2)!==0)throw Error(r(440));return _.impl.apply(void 0,arguments)}}},H2={readContext:ua,use:Ev,useCallback:BF,useContext:ua,useEffect:I2,useImperativeHandle:zF,useInsertionEffect:IF,useLayoutEffect:FF,useMemo:$F,useReducer:Av,useRef:DF,useState:function(){return Av(vc)},useDebugValue:F2,useDeferredValue:function(h,g){var _=hi();return HF(_,ur.memoizedState,h,g)},useTransition:function(){var h=Av(vc)[0],g=hi().memoizedState;return[typeof h=="boolean"?h:Lx(h),g]},useSyncExternalStore:bF,useId:qF,useHostTransitionStatus:B2,useFormState:jF,useActionState:jF,useOptimistic:function(h,g){var _=hi();return MF(_,ur,h,g)},useMemoCache:P2,useCacheRefresh:KF};H2.useEffectEvent=LF;var JF={readContext:ua,use:Ev,useCallback:BF,useContext:ua,useEffect:I2,useImperativeHandle:zF,useInsertionEffect:IF,useLayoutEffect:FF,useMemo:$F,useReducer:D2,useRef:DF,useState:function(){return D2(vc)},useDebugValue:F2,useDeferredValue:function(h,g){var _=hi();return ur===null?U2(_,h,g):HF(_,ur.memoizedState,h,g)},useTransition:function(){var h=D2(vc)[0],g=hi().memoizedState;return[typeof h=="boolean"?h:Lx(h),g]},useSyncExternalStore:bF,useId:qF,useHostTransitionStatus:B2,useFormState:RF,useActionState:RF,useOptimistic:function(h,g){var _=hi();return ur!==null?MF(_,ur,h,g):(_.baseState=h,[h,_.queue.dispatch])},useMemoCache:P2,useCacheRefresh:KF};JF.useEffectEvent=LF;function V2(h,g,_,N){g=h.memoizedState,_=_(N,g),_=_==null?g:f({},g,_),h.memoizedState=_,h.lanes===0&&(h.updateQueue.baseState=_)}var G2={enqueueSetState:function(h,g,_){h=h._reactInternals;var N=Os(),P=Lu(N);P.payload=g,_!=null&&(P.callback=_),g=Iu(h,P,N),g!==null&&(fs(g,h,N),Px(g,h,N))},enqueueReplaceState:function(h,g,_){h=h._reactInternals;var N=Os(),P=Lu(N);P.tag=1,P.payload=g,_!=null&&(P.callback=_),g=Iu(h,P,N),g!==null&&(fs(g,h,N),Px(g,h,N))},enqueueForceUpdate:function(h,g){h=h._reactInternals;var _=Os(),N=Lu(_);N.tag=2,g!=null&&(N.callback=g),g=Iu(h,N,_),g!==null&&(fs(g,h,_),Px(g,h,_))}};function e5(h,g,_,N,P,F,Q){return h=h.stateNode,typeof h.shouldComponentUpdate=="function"?h.shouldComponentUpdate(N,F,Q):g.prototype&&g.prototype.isPureReactComponent?!Mx(_,N)||!Mx(P,F):!0}function t5(h,g,_,N){h=g.state,typeof g.componentWillReceiveProps=="function"&&g.componentWillReceiveProps(_,N),typeof g.UNSAFE_componentWillReceiveProps=="function"&&g.UNSAFE_componentWillReceiveProps(_,N),g.state!==h&&G2.enqueueReplaceState(g,g.state,null)}function Rh(h,g){var _=g;if("ref"in g){_={};for(var N in g)N!=="ref"&&(_[N]=g[N])}if(h=h.defaultProps){_===g&&(_=f({},_));for(var P in h)_[P]===void 0&&(_[P]=h[P])}return _}function n5(h){lv(h)}function r5(h){console.error(h)}function i5(h){lv(h)}function jv(h,g){try{var _=h.onUncaughtError;_(g.value,{componentStack:g.stack})}catch(N){setTimeout(function(){throw N})}}function a5(h,g,_){try{var N=h.onCaughtError;N(_.value,{componentStack:_.stack,errorBoundary:g.tag===1?g.stateNode:null})}catch(P){setTimeout(function(){throw P})}}function W2(h,g,_){return _=Lu(_),_.tag=3,_.payload={element:null},_.callback=function(){jv(h,g)},_}function s5(h){return h=Lu(h),h.tag=3,h}function o5(h,g,_,N){var P=_.type.getDerivedStateFromError;if(typeof P=="function"){var F=N.value;h.payload=function(){return P(F)},h.callback=function(){a5(g,_,N)}}var Q=_.stateNode;Q!==null&&typeof Q.componentDidCatch=="function"&&(h.callback=function(){a5(g,_,N),typeof P!="function"&&(Hu===null?Hu=new Set([this]):Hu.add(this));var xe=N.stack;this.componentDidCatch(N.value,{componentStack:xe!==null?xe:""})})}function Kae(h,g,_,N,P){if(_.flags|=32768,N!==null&&typeof N=="object"&&typeof N.then=="function"){if(g=_.alternate,g!==null&&Em(g,_,P,!0),_=js.current,_!==null){switch(_.tag){case 31:case 13:return oo===null?Hv():_.alternate===null&&Zr===0&&(Zr=3),_.flags&=-257,_.flags|=65536,_.lanes=P,N===bv?_.flags|=16384:(g=_.updateQueue,g===null?_.updateQueue=new Set([N]):g.add(N),xA(h,N,P)),!1;case 22:return _.flags|=65536,N===bv?_.flags|=16384:(g=_.updateQueue,g===null?(g={transitions:null,markerInstances:null,retryQueue:new Set([N])},_.updateQueue=g):(_=g.retryQueue,_===null?g.retryQueue=new Set([N]):_.add(N)),xA(h,N,P)),!1}throw Error(r(435,_.tag))}return xA(h,N,P),Hv(),!1}if(Ln)return g=js.current,g!==null?((g.flags&65536)===0&&(g.flags|=256),g.flags|=65536,g.lanes=P,N!==d2&&(h=Error(r(422),{cause:N}),Ax(ro(h,_)))):(N!==d2&&(g=Error(r(423),{cause:N}),Ax(ro(g,_))),h=h.current.alternate,h.flags|=65536,P&=-P,h.lanes|=P,N=ro(N,_),P=W2(h.stateNode,N,P),w2(h,P),Zr!==4&&(Zr=2)),!1;var F=Error(r(520),{cause:N});if(F=ro(F,_),Wx===null?Wx=[F]:Wx.push(F),Zr!==4&&(Zr=2),g===null)return!0;N=ro(N,_),_=g;do{switch(_.tag){case 3:return _.flags|=65536,h=P&-P,_.lanes|=h,h=W2(_.stateNode,N,h),w2(_,h),!1;case 1:if(g=_.type,F=_.stateNode,(_.flags&128)===0&&(typeof g.getDerivedStateFromError=="function"||F!==null&&typeof F.componentDidCatch=="function"&&(Hu===null||!Hu.has(F))))return _.flags|=65536,P&=-P,_.lanes|=P,P=s5(P),o5(P,h,_,N),w2(_,P),!1}_=_.return}while(_!==null);return!1}var q2=Error(r(461)),yi=!1;function da(h,g,_,N){g.child=h===null?dF(g,null,_,N):jh(g,h.child,_,N)}function l5(h,g,_,N,P){_=_.render;var F=g.ref;if("ref"in N){var Q={};for(var xe in N)xe!=="ref"&&(Q[xe]=N[xe])}else Q=N;return Ah(g),N=T2(h,g,_,Q,F,P),xe=C2(),h!==null&&!yi?(k2(h,g,P),_c(h,g,P)):(Ln&&xe&&c2(g),g.flags|=1,da(h,g,N,P),g.child)}function c5(h,g,_,N,P){if(h===null){var F=_.type;return typeof F=="function"&&!s2(F)&&F.defaultProps===void 0&&_.compare===null?(g.tag=15,g.type=F,u5(h,g,F,N,P)):(h=hv(_.type,null,N,g,g.mode,P),h.ref=g.ref,h.return=g,g.child=h)}if(F=h.child,!tA(h,P)){var Q=F.memoizedProps;if(_=_.compare,_=_!==null?_:Mx,_(Q,N)&&h.ref===g.ref)return _c(h,g,P)}return g.flags|=1,h=pc(F,N),h.ref=g.ref,h.return=g,g.child=h}function u5(h,g,_,N,P){if(h!==null){var F=h.memoizedProps;if(Mx(F,N)&&h.ref===g.ref)if(yi=!1,g.pendingProps=N=F,tA(h,P))(h.flags&131072)!==0&&(yi=!0);else return g.lanes=h.lanes,_c(h,g,P)}return K2(h,g,_,N,P)}function d5(h,g,_,N){var P=N.children,F=h!==null?h.memoizedState:null;if(h===null&&g.stateNode===null&&(g.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),N.mode==="hidden"){if((g.flags&128)!==0){if(F=F!==null?F.baseLanes|_:_,h!==null){for(N=g.child=h.child,P=0;N!==null;)P=P|N.lanes|N.childLanes,N=N.sibling;N=P&~F}else N=0,g.child=null;return h5(h,g,F,_,N)}if((_&536870912)!==0)g.memoizedState={baseLanes:0,cachePool:null},h!==null&&gv(g,F!==null?F.cachePool:null),F!==null?mF(g,F):M2(),pF(g);else return N=g.lanes=536870912,h5(h,g,F!==null?F.baseLanes|_:_,_,N)}else F!==null?(gv(g,F.cachePool),mF(g,F),Uu(),g.memoizedState=null):(h!==null&&gv(g,null),M2(),Uu());return da(h,g,P,_),g.child}function Ux(h,g){return h!==null&&h.tag===22||g.stateNode!==null||(g.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),g.sibling}function h5(h,g,_,N,P){var F=b2();return F=F===null?null:{parent:xi._currentValue,pool:F},g.memoizedState={baseLanes:_,cachePool:F},h!==null&&gv(g,null),M2(),pF(g),h!==null&&Em(h,g,N,!0),g.childLanes=P,null}function Pv(h,g){return g=Dv({mode:g.mode,children:g.children},h.mode),g.ref=h.ref,h.child=g,g.return=h,g}function f5(h,g,_){return jh(g,h.child,null,_),h=Pv(g,g.pendingProps),h.flags|=2,Ps(g),g.memoizedState=null,h}function Xae(h,g,_){var N=g.pendingProps,P=(g.flags&128)!==0;if(g.flags&=-129,h===null){if(Ln){if(N.mode==="hidden")return h=Pv(g,N),g.lanes=536870912,Ux(null,h);if(E2(g),(h=Pr)?(h=NU(h,so),h=h!==null&&h.data==="&"?h:null,h!==null&&(g.memoizedState={dehydrated:h,treeContext:ju!==null?{id:vl,overflow:_l}:null,retryLane:536870912,hydrationErrors:null},_=YI(h),_.return=g,g.child=_,ca=g,Pr=null)):h=null,h===null)throw Ru(g);return g.lanes=536870912,null}return Pv(g,N)}var F=h.memoizedState;if(F!==null){var Q=F.dehydrated;if(E2(g),P)if(g.flags&256)g.flags&=-257,g=f5(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(N=_r,N!==null&&(Q=Yt(N,_),Q!==0&&Q!==F.retryLane))throw F.retryLane=Q,Sh(h,Q),fs(N,h,Q),q2;Hv(),g=f5(h,g,_)}else h=F.treeContext,Pr=lo(Q.nextSibling),ca=g,Ln=!0,Pu=null,so=!1,h!==null&&JI(g,h),g=Pv(g,N),g.flags|=4096;return g}return h=pc(h.child,{mode:N.mode,children:N.children}),h.ref=g.ref,g.child=h,h.return=g,h}function Rv(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 K2(h,g,_,N,P){return Ah(g),_=T2(h,g,_,N,void 0,P),N=C2(),h!==null&&!yi?(k2(h,g,P),_c(h,g,P)):(Ln&&N&&c2(g),g.flags|=1,da(h,g,_,P),g.child)}function m5(h,g,_,N,P,F){return Ah(g),g.updateQueue=null,_=xF(g,N,_,P),gF(h),N=C2(),h!==null&&!yi?(k2(h,g,F),_c(h,g,F)):(Ln&&N&&c2(g),g.flags|=1,da(h,g,_,F),g.child)}function p5(h,g,_,N,P){if(Ah(g),g.stateNode===null){var F=wm,Q=_.contextType;typeof Q=="object"&&Q!==null&&(F=ua(Q)),F=new _(N,F),g.memoizedState=F.state!==null&&F.state!==void 0?F.state:null,F.updater=G2,g.stateNode=F,F._reactInternals=g,F=g.stateNode,F.props=N,F.state=g.memoizedState,F.refs={},v2(g),Q=_.contextType,F.context=typeof Q=="object"&&Q!==null?ua(Q):wm,F.state=g.memoizedState,Q=_.getDerivedStateFromProps,typeof Q=="function"&&(V2(g,_,Q,N),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&&G2.enqueueReplaceState(F,F.state,null),Dx(g,N,F,P),Rx(),F.state=g.memoizedState),typeof F.componentDidMount=="function"&&(g.flags|=4194308),N=!0}else if(h===null){F=g.stateNode;var xe=g.memoizedProps,Re=Rh(_,xe);F.props=Re;var at=F.context,bt=_.contextType;Q=wm,typeof bt=="object"&&bt!==null&&(Q=ua(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)&&t5(g,F,N,Q),Ou=!1;var ot=g.memoizedState;F.state=ot,Dx(g,N,F,P),Rx(),at=g.memoizedState,xe||ot!==at||Ou?(typeof _t=="function"&&(V2(g,_,_t,N),at=g.memoizedState),(Re=Ou||e5(g,_,Re,N,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=N,g.memoizedState=at),F.props=N,F.state=at,F.context=Q,N=Re):(typeof F.componentDidMount=="function"&&(g.flags|=4194308),N=!1)}else{F=g.stateNode,_2(h,g),Q=g.memoizedProps,bt=Rh(_,Q),F.props=bt,_t=g.pendingProps,ot=F.context,at=_.contextType,Re=wm,typeof at=="object"&&at!==null&&(Re=ua(at)),xe=_.getDerivedStateFromProps,(at=typeof xe=="function"||typeof F.getSnapshotBeforeUpdate=="function")||typeof F.UNSAFE_componentWillReceiveProps!="function"&&typeof F.componentWillReceiveProps!="function"||(Q!==_t||ot!==Re)&&t5(g,F,N,Re),Ou=!1,ot=g.memoizedState,F.state=ot,Dx(g,N,F,P),Rx();var ht=g.memoizedState;Q!==_t||ot!==ht||Ou||h!==null&&h.dependencies!==null&&mv(h.dependencies)?(typeof xe=="function"&&(V2(g,_,xe,N),ht=g.memoizedState),(bt=Ou||e5(g,_,bt,N,ot,ht,Re)||h!==null&&h.dependencies!==null&&mv(h.dependencies))?(at||typeof F.UNSAFE_componentWillUpdate!="function"&&typeof F.componentWillUpdate!="function"||(typeof F.componentWillUpdate=="function"&&F.componentWillUpdate(N,ht,Re),typeof F.UNSAFE_componentWillUpdate=="function"&&F.UNSAFE_componentWillUpdate(N,ht,Re)),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=N,g.memoizedState=ht),F.props=N,F.state=ht,F.context=Re,N=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),N=!1)}return F=N,Rv(h,g),N=(g.flags&128)!==0,F||N?(F=g.stateNode,_=N&&typeof _.getDerivedStateFromError!="function"?null:F.render(),g.flags|=1,h!==null&&N?(g.child=jh(g,h.child,null,P),g.child=jh(g,null,_,P)):da(h,g,_,P),g.memoizedState=F.state,h=g.child):h=_c(h,g,P),h}function g5(h,g,_,N){return Nh(),g.flags|=256,da(h,g,_,N),g.child}var X2={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Y2(h){return{baseLanes:h,cachePool:aF()}}function Q2(h,g,_){return h=h!==null?h.childLanes&~_:0,g&&(h|=Ds),h}function x5(h,g,_){var N=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?Fu(g):Uu(),(h=Pr)?(h=NU(h,so),h=h!==null&&h.data!=="&"?h:null,h!==null&&(g.memoizedState={dehydrated:h,treeContext:ju!==null?{id:vl,overflow:_l}:null,retryLane:536870912,hydrationErrors:null},_=YI(h),_.return=g,g.child=_,ca=g,Pr=null)):h=null,h===null)throw Ru(g);return RA(h)?g.lanes=32:g.lanes=536870912,null}var xe=N.children;return N=N.fallback,P?(Uu(),P=g.mode,xe=Dv({mode:"hidden",children:xe},P),N=Mh(N,P,_,null),xe.return=g,N.return=g,xe.sibling=N,g.child=xe,N=g.child,N.memoizedState=Y2(_),N.childLanes=Q2(h,Q,_),g.memoizedState=X2,Ux(null,N)):(Fu(g),Z2(g,xe))}var Re=h.memoizedState;if(Re!==null&&(xe=Re.dehydrated,xe!==null)){if(F)g.flags&256?(Fu(g),g.flags&=-257,g=J2(h,g,_)):g.memoizedState!==null?(Uu(),g.child=h.child,g.flags|=128,g=null):(Uu(),xe=N.fallback,P=g.mode,N=Dv({mode:"visible",children:N.children},P),xe=Mh(xe,P,_,null),xe.flags|=2,N.return=g,xe.return=g,N.sibling=xe,g.child=N,jh(g,h.child,null,_),N=g.child,N.memoizedState=Y2(_),N.childLanes=Q2(h,Q,_),g.memoizedState=X2,g=Ux(null,N));else if(Fu(g),RA(xe)){if(Q=xe.nextSibling&&xe.nextSibling.dataset,Q)var at=Q.dgst;Q=at,N=Error(r(419)),N.stack="",N.digest=Q,Ax({value:N,source:null,stack:null}),g=J2(h,g,_)}else if(yi||Em(h,g,_,!1),Q=(_&h.childLanes)!==0,yi||Q){if(Q=_r,Q!==null&&(N=Yt(Q,_),N!==0&&N!==Re.retryLane))throw Re.retryLane=N,Sh(h,N),fs(Q,h,N),q2;PA(xe)||Hv(),g=J2(h,g,_)}else PA(xe)?(g.flags|=192,g.child=h.child,g=null):(h=Re.treeContext,Pr=lo(xe.nextSibling),ca=g,Ln=!0,Pu=null,so=!1,h!==null&&JI(g,h),g=Z2(g,N.children),g.flags|=4096);return g}return P?(Uu(),xe=N.fallback,P=g.mode,Re=h.child,at=Re.sibling,N=pc(Re,{mode:"hidden",children:N.children}),N.subtreeFlags=Re.subtreeFlags&65011712,at!==null?xe=pc(at,xe):(xe=Mh(xe,P,_,null),xe.flags|=2),xe.return=g,N.return=g,N.sibling=xe,g.child=N,Ux(null,N),N=g.child,xe=h.child.memoizedState,xe===null?xe=Y2(_):(P=xe.cachePool,P!==null?(Re=xi._currentValue,P=P.parent!==Re?{parent:Re,pool:Re}:P):P=aF(),xe={baseLanes:xe.baseLanes|_,cachePool:P}),N.memoizedState=xe,N.childLanes=Q2(h,Q,_),g.memoizedState=X2,Ux(h.child,N)):(Fu(g),_=h.child,h=_.sibling,_=pc(_,{mode:"visible",children:N.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=Dv({mode:"visible",children:g},h.mode),g.return=h,h.child=g}function Dv(h,g){return h=ks(22,h,null,g),h.lanes=0,h}function J2(h,g,_){return jh(g,h.child,null,_),h=Z2(g,g.pendingProps.children),h.flags|=2,g.memoizedState=null,h}function b5(h,g,_){h.lanes|=g;var N=h.alternate;N!==null&&(N.lanes|=g),m2(h.return,g,_)}function eA(h,g,_,N,P,F){var Q=h.memoizedState;Q===null?h.memoizedState={isBackwards:g,rendering:null,renderingStartTime:0,last:N,tail:_,tailMode:P,treeForkCount:F}:(Q.isBackwards=g,Q.rendering=null,Q.renderingStartTime=0,Q.last=N,Q.tail=_,Q.tailMode=P,Q.treeForkCount=F)}function y5(h,g,_){var N=g.pendingProps,P=N.revealOrder,F=N.tail;N=N.children;var Q=di.current,xe=(Q&2)!==0;if(xe?(Q=Q&1|2,g.flags|=128):Q&=1,ne(di,Q),da(h,g,N,_),N=Ln?Ex:0,!xe&&h!==null&&(h.flags&128)!==0)e:for(h=g.child;h!==null;){if(h.tag===13)h.memoizedState!==null&&b5(h,_,g);else if(h.tag===19)b5(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&&wv(h)===null&&(P=_),_=_.sibling;_=P,_===null?(P=g.child,g.child=null):(P=_.sibling,_.sibling=null),eA(g,!1,P,_,F,N);break;case"backwards":case"unstable_legacy-backwards":for(_=null,P=g.child,g.child=null;P!==null;){if(h=P.alternate,h!==null&&wv(h)===null){g.child=P;break}h=P.sibling,P.sibling=_,_=P,P=h}eA(g,!0,_,null,F,N);break;case"together":eA(g,!1,null,null,void 0,N);break;default:g.memoizedState=null}return g.child}function _c(h,g,_){if(h!==null&&(g.dependencies=h.dependencies),$u|=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 tA(h,g){return(h.lanes&g)!==0?!0:(h=h.dependencies,!!(h!==null&&mv(h)))}function Yae(h,g,_){switch(g.tag){case 3:Ae(g,g.stateNode.containerInfo),Du(g,xi,h.memoizedState.cache),Nh();break;case 27:case 5:Ne(g);break;case 4:Ae(g,g.stateNode.containerInfo);break;case 10:Du(g,g.type,g.memoizedProps.value);break;case 31:if(g.memoizedState!==null)return g.flags|=128,E2(g),null;break;case 13:var N=g.memoizedState;if(N!==null)return N.dehydrated!==null?(Fu(g),g.flags|=128,null):(_&g.child.childLanes)!==0?x5(h,g,_):(Fu(g),h=_c(h,g,_),h!==null?h.sibling:null);Fu(g);break;case 19:var P=(h.flags&128)!==0;if(N=(_&g.childLanes)!==0,N||(Em(h,g,_,!1),N=(_&g.childLanes)!==0),P){if(N)return y5(h,g,_);g.flags|=128}if(P=g.memoizedState,P!==null&&(P.rendering=null,P.tail=null,P.lastEffect=null),ne(di,di.current),N)break;return null;case 22:return g.lanes=0,d5(h,g,_,g.pendingProps);case 24:Du(g,xi,h.memoizedState.cache)}return _c(h,g,_)}function v5(h,g,_){if(h!==null)if(h.memoizedProps!==g.pendingProps)yi=!0;else{if(!tA(h,_)&&(g.flags&128)===0)return yi=!1,Yae(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 N=g.pendingProps;if(h=Ch(g.elementType),g.type=h,typeof h=="function")s2(h)?(N=Rh(h,N),g.tag=1,g=p5(null,g,h,N,_)):(g.tag=0,g=K2(null,g,h,N,_));else{if(h!=null){var P=h.$$typeof;if(P===E){g.tag=11,g=l5(null,g,h,N,_);break e}else if(P===T){g.tag=14,g=c5(null,g,h,N,_);break e}}throw g=j(h)||h,Error(r(306,g,""))}}return g;case 0:return K2(h,g,g.type,g.pendingProps,_);case 1:return N=g.type,P=Rh(N,g.pendingProps),p5(h,g,N,P,_);case 3:e:{if(Ae(g,g.stateNode.containerInfo),h===null)throw Error(r(387));N=g.pendingProps;var F=g.memoizedState;P=F.element,_2(h,g),Dx(g,N,null,_);var Q=g.memoizedState;if(N=Q.cache,Du(g,xi,N),N!==F.cache&&p2(g,[xi],_,!0),Rx(),N=Q.element,F.isDehydrated)if(F={element:N,isDehydrated:!1,cache:Q.cache},g.updateQueue.baseState=F,g.memoizedState=F,g.flags&256){g=g5(h,g,N,_);break e}else if(N!==P){P=ro(Error(r(424)),g),Ax(P),g=g5(h,g,N,_);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),ca=g,Ln=!0,Pu=null,so=!0,_=dF(g,null,N,_),g.child=_;_;)_.flags=_.flags&-3|4096,_=_.sibling;else{if(Nh(),N===P){g=_c(h,g,_);break e}da(h,g,N,_)}g=g.child}return g;case 26:return Rv(h,g),h===null?(_=jU(g.type,null,g.pendingProps,null))?g.memoizedState=_:Ln||(_=g.type,h=g.pendingProps,N=Yv(me.current).createElement(_),N[Un]=g,N[yr]=h,ha(N,_,h),de(N),g.stateNode=N):g.memoizedState=jU(g.type,h.memoizedProps,g.pendingProps,h.memoizedState),null;case 27:return Ne(g),h===null&&Ln&&(N=g.stateNode=TU(g.type,g.pendingProps,me.current),ca=g,so=!0,P=Pr,qu(g.type)?(DA=P,Pr=lo(N.firstChild)):Pr=P),da(h,g,g.pendingProps.children,_),Rv(h,g),h===null&&(g.flags|=4194304),g.child;case 5:return h===null&&Ln&&((P=N=Pr)&&(N=Ese(N,g.type,g.pendingProps,so),N!==null?(g.stateNode=N,ca=g,Pr=lo(N.firstChild),so=!1,P=!0):P=!1),P||Ru(g)),Ne(g),P=g.type,F=g.pendingProps,Q=h!==null?h.memoizedProps:null,N=F.children,CA(P,F)?N=null:Q!==null&&CA(P,Q)&&(g.flags|=32),g.memoizedState!==null&&(P=T2(h,g,Bae,null,null,_),eb._currentValue=P),Rv(h,g),da(h,g,N,_),g.child;case 6:return h===null&&Ln&&((h=_=Pr)&&(_=Ase(_,g.pendingProps,so),_!==null?(g.stateNode=_,ca=g,Pr=null,h=!0):h=!1),h||Ru(g)),null;case 13:return x5(h,g,_);case 4:return Ae(g,g.stateNode.containerInfo),N=g.pendingProps,h===null?g.child=jh(g,null,N,_):da(h,g,N,_),g.child;case 11:return l5(h,g,g.type,g.pendingProps,_);case 7:return da(h,g,g.pendingProps,_),g.child;case 8:return da(h,g,g.pendingProps.children,_),g.child;case 12:return da(h,g,g.pendingProps.children,_),g.child;case 10:return N=g.pendingProps,Du(g,g.type,N.value),da(h,g,N.children,_),g.child;case 9:return P=g.type._context,N=g.pendingProps.children,Ah(g),P=ua(P),N=N(P),g.flags|=1,da(h,g,N,_),g.child;case 14:return c5(h,g,g.type,g.pendingProps,_);case 15:return u5(h,g,g.type,g.pendingProps,_);case 19:return y5(h,g,_);case 31:return Xae(h,g,_);case 22:return d5(h,g,_,g.pendingProps);case 24:return Ah(g),N=ua(xi),h===null?(P=b2(),P===null&&(P=_r,F=g2(),P.pooledCache=F,F.refCount++,F!==null&&(P.pooledCacheLanes|=_),P=F),g.memoizedState={parent:N,cache:P},v2(g),Du(g,xi,P)):((h.lanes&_)!==0&&(_2(h,g),Dx(g,null,null,_),Rx()),P=h.memoizedState,F=g.memoizedState,P.parent!==N?(P={parent:N,cache:N},g.memoizedState=P,g.lanes===0&&(g.memoizedState=g.updateQueue.baseState=P),Du(g,xi,N)):(N=F.cache,Du(g,xi,N),N!==P.cache&&p2(g,[xi],_,!0))),da(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 nA(h,g,_,N,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(q5())h.flags|=8192;else throw kh=bv,y2}else h.flags&=-16777217}function _5(h,g){if(g.type!=="stylesheet"||(g.state.loading&4)!==0)h.flags&=-16777217;else if(h.flags|=16777216,!LU(g))if(q5())h.flags|=8192;else throw kh=bv,y2}function Ov(h,g){g!==null&&(h.flags|=4),h.flags&16384&&(g=h.tag!==22?Ot():536870912,h.lanes|=g,Fm|=g)}function zx(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 N=null;_!==null;)_.alternate!==null&&(N=_),_=_.sibling;N===null?g||h.tail===null?h.tail=null:h.tail.sibling=null:N.sibling=null}}function Rr(h){var g=h.alternate!==null&&h.alternate.child===h.child,_=0,N=0;if(g)for(var P=h.child;P!==null;)_|=P.lanes|P.childLanes,N|=P.subtreeFlags&65011712,N|=P.flags&65011712,P.return=h,P=P.sibling;else for(P=h.child;P!==null;)_|=P.lanes|P.childLanes,N|=P.subtreeFlags,N|=P.flags,P.return=h,P=P.sibling;return h.subtreeFlags|=N,h.childLanes=_,g}function Qae(h,g,_){var N=g.pendingProps;switch(u2(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,N=null,h!==null&&(N=h.memoizedState.cache),g.memoizedState.cache!==N&&(g.flags|=2048),bc(xi),ge(),_.pendingContext&&(_.context=_.pendingContext,_.pendingContext=null),(h===null||h.child===null)&&(Nm(g)?wc(g):h===null||h.memoizedState.isDehydrated&&(g.flags&256)===0||(g.flags|=1024,h2())),Rr(g),null;case 26:var P=g.type,F=g.memoizedState;return h===null?(wc(g),F!==null?(Rr(g),_5(g,F)):(Rr(g),nA(g,P,null,N,_))):F?F!==h.memoizedState?(wc(g),Rr(g),_5(g,F)):(Rr(g),g.flags&=-16777217):(h=h.memoizedProps,h!==N&&wc(g),Rr(g),nA(g,P,h,N,_)),null;case 27:if(_e(g),_=me.current,P=g.type,h!==null&&g.stateNode!=null)h.memoizedProps!==N&&wc(g);else{if(!N){if(g.stateNode===null)throw Error(r(166));return Rr(g),null}h=ie.current,Nm(g)?eF(g):(h=TU(P,N,_),g.stateNode=h,wc(g))}return Rr(g),null;case 5:if(_e(g),P=g.type,h!==null&&g.stateNode!=null)h.memoizedProps!==N&&wc(g);else{if(!N){if(g.stateNode===null)throw Error(r(166));return Rr(g),null}if(F=ie.current,Nm(g))eF(g);else{var Q=Yv(me.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 N.is=="string"?Q.createElement("select",{is:N.is}):Q.createElement("select"),N.multiple?F.multiple=!0:N.size&&(F.size=N.size);break;default:F=typeof N.is=="string"?Q.createElement(P,{is:N.is}):Q.createElement(P)}}F[Un]=g,F[yr]=N;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(ha(F,P,N),P){case"button":case"input":case"select":case"textarea":N=!!N.autoFocus;break e;case"img":N=!0;break e;default:N=!1}N&&wc(g)}}return Rr(g),nA(g,g.type,h===null?null:h.memoizedProps,g.pendingProps,_),null;case 6:if(h&&g.stateNode!=null)h.memoizedProps!==N&&wc(g);else{if(typeof N!="string"&&g.stateNode===null)throw Error(r(166));if(h=me.current,Nm(g)){if(h=g.stateNode,_=g.memoizedProps,N=null,P=ca,P!==null)switch(P.tag){case 27:case 5:N=P.memoizedProps}h[Un]=g,h=!!(h.nodeValue===_||N!==null&&N.suppressHydrationWarning===!0||xU(h.nodeValue,_)),h||Ru(g,!0)}else h=Yv(h).createTextNode(N),h[Un]=g,g.stateNode=h}return Rr(g),null;case 31:if(_=g.memoizedState,h===null||h.memoizedState!==null){if(N=Nm(g),_!==null){if(h===null){if(!N)throw Error(r(318));if(h=g.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(557));h[Un]=g}else Nh(),(g.flags&128)===0&&(g.memoizedState=null),g.flags|=4;Rr(g),h=!1}else _=h2(),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(N=g.memoizedState,h===null||h.memoizedState!==null&&h.memoizedState.dehydrated!==null){if(P=Nm(g),N!==null&&N.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 Nh(),(g.flags&128)===0&&(g.memoizedState=null),g.flags|=4;Rr(g),P=!1}else P=h2(),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):(_=N!==null,h=h!==null&&h.memoizedState!==null,_&&(N=g.child,P=null,N.alternate!==null&&N.alternate.memoizedState!==null&&N.alternate.memoizedState.cachePool!==null&&(P=N.alternate.memoizedState.cachePool.pool),F=null,N.memoizedState!==null&&N.memoizedState.cachePool!==null&&(F=N.memoizedState.cachePool.pool),F!==P&&(N.flags|=2048)),_!==h&&_&&(g.child.flags|=8192),Ov(g,g.updateQueue),Rr(g),null);case 4:return ge(),h===null&&MA(g.stateNode.containerInfo),Rr(g),null;case 10:return bc(g.type),Rr(g),null;case 19:if(V(di),N=g.memoizedState,N===null)return Rr(g),null;if(P=(g.flags&128)!==0,F=N.rendering,F===null)if(P)zx(N,!1);else{if(Zr!==0||h!==null&&(h.flags&128)!==0)for(h=g.child;h!==null;){if(F=wv(h),F!==null){for(g.flags|=128,zx(N,!1),h=F.updateQueue,g.updateQueue=h,Ov(g,h),g.subtreeFlags=0,h=_,_=g.child;_!==null;)XI(_,h),_=_.sibling;return ne(di,di.current&1|2),Ln&&gc(g,N.treeForkCount),g.child}h=h.sibling}N.tail!==null&&L()>zv&&(g.flags|=128,P=!0,zx(N,!1),g.lanes=4194304)}else{if(!P)if(h=wv(F),h!==null){if(g.flags|=128,P=!0,h=h.updateQueue,g.updateQueue=h,Ov(g,h),zx(N,!0),N.tail===null&&N.tailMode==="hidden"&&!F.alternate&&!Ln)return Rr(g),null}else 2*L()-N.renderingStartTime>zv&&_!==536870912&&(g.flags|=128,P=!0,zx(N,!1),g.lanes=4194304);N.isBackwards?(F.sibling=g.child,g.child=F):(h=N.last,h!==null?h.sibling=F:g.child=F,N.last=F)}return N.tail!==null?(h=N.tail,N.rendering=h,N.tail=h.sibling,N.renderingStartTime=L(),h.sibling=null,_=di.current,ne(di,P?_&1|2:_&1),Ln&&gc(g,N.treeForkCount),h):(Rr(g),null);case 22:case 23:return Ps(g),N2(),N=g.memoizedState!==null,h!==null?h.memoizedState!==null!==N&&(g.flags|=8192):N&&(g.flags|=8192),N?(_&536870912)!==0&&(g.flags&128)===0&&(Rr(g),g.subtreeFlags&6&&(g.flags|=8192)):Rr(g),_=g.updateQueue,_!==null&&Ov(g,_.retryQueue),_=null,h!==null&&h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(_=h.memoizedState.cachePool.pool),N=null,g.memoizedState!==null&&g.memoizedState.cachePool!==null&&(N=g.memoizedState.cachePool.pool),N!==_&&(g.flags|=2048),h!==null&&V(Th),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(u2(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 _e(g),null;case 31:if(g.memoizedState!==null){if(Ps(g),g.alternate===null)throw Error(r(340));Nh()}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));Nh()}return h=g.flags,h&65536?(g.flags=h&-65537|128,g):null;case 19:return V(di),null;case 4:return ge(),null;case 10:return bc(g.type),null;case 22:case 23:return Ps(g),N2(),h!==null&&V(Th),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 w5(h,g){switch(u2(g),g.tag){case 3:bc(xi),ge();break;case 26:case 27:case 5:_e(g);break;case 4:ge();break;case 31:g.memoizedState!==null&&Ps(g);break;case 13:Ps(g);break;case 19:V(di);break;case 10:bc(g.type);break;case 22:case 23:Ps(g),N2(),h!==null&&V(Th);break;case 24:bc(xi)}}function Bx(h,g){try{var _=g.updateQueue,N=_!==null?_.lastEffect:null;if(N!==null){var P=N.next;_=P;do{if((_.tag&h)===h){N=void 0;var F=_.create,Q=_.inst;N=F(),Q.destroy=N}_=_.next}while(_!==P)}}catch(xe){sr(g,g.return,xe)}}function zu(h,g,_){try{var N=g.updateQueue,P=N!==null?N.lastEffect:null;if(P!==null){var F=P.next;N=F;do{if((N.tag&h)===h){var Q=N.inst,xe=Q.destroy;if(xe!==void 0){Q.destroy=void 0,P=g;var Re=_,at=xe;try{at()}catch(bt){sr(P,Re,bt)}}}N=N.next}while(N!==F)}}catch(bt){sr(g,g.return,bt)}}function S5(h){var g=h.updateQueue;if(g!==null){var _=h.stateNode;try{fF(g,_)}catch(N){sr(h,h.return,N)}}}function M5(h,g,_){_.props=Rh(h.type,h.memoizedProps),_.state=h.memoizedState;try{_.componentWillUnmount()}catch(N){sr(h,g,N)}}function $x(h,g){try{var _=h.ref;if(_!==null){switch(h.tag){case 26:case 27:case 5:var N=h.stateNode;break;case 30:N=h.stateNode;break;default:N=h.stateNode}typeof _=="function"?h.refCleanup=_(N):_.current=N}}catch(P){sr(h,g,P)}}function wl(h,g){var _=h.ref,N=h.refCleanup;if(_!==null)if(typeof N=="function")try{N()}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 N5(h){var g=h.type,_=h.memoizedProps,N=h.stateNode;try{e:switch(g){case"button":case"input":case"select":case"textarea":_.autoFocus&&N.focus();break e;case"img":_.src?N.src=_.src:_.srcSet&&(N.srcset=_.srcSet)}}catch(P){sr(h,h.return,P)}}function rA(h,g,_){try{var N=h.stateNode;vse(N,h.type,_,g),N[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&&qu(h.type)||h.tag===4}function iA(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&&qu(h.type)||h.flags&2||h.child===null||h.tag===4)continue e;h.child.return=h,h=h.child}if(!(h.flags&2))return h.stateNode}}function aA(h,g,_){var N=h.tag;if(N===5||N===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(N!==4&&(N===27&&qu(h.type)&&(_=h.stateNode,g=null),h=h.child,h!==null))for(aA(h,g,_),h=h.sibling;h!==null;)aA(h,g,_),h=h.sibling}function Lv(h,g,_){var N=h.tag;if(N===5||N===6)h=h.stateNode,g?_.insertBefore(h,g):_.appendChild(h);else if(N!==4&&(N===27&&qu(h.type)&&(_=h.stateNode),h=h.child,h!==null))for(Lv(h,g,_),h=h.sibling;h!==null;)Lv(h,g,_),h=h.sibling}function A5(h){var g=h.stateNode,_=h.memoizedProps;try{for(var N=h.type,P=g.attributes;P.length;)g.removeAttributeNode(P[0]);ha(g,N,_),g[Un]=h,g[yr]=_}catch(F){sr(h,h.return,F)}}var Sc=!1,vi=!1,sA=!1,T5=typeof WeakSet=="function"?WeakSet:Set,Gi=null;function Jae(h,g){if(h=h.containerInfo,AA=r_,h=zI(h),JE(h)){if("selectionStart"in h)var _={start:h.selectionStart,end:h.selectionEnd};else e:{_=(_=h.ownerDocument)&&_.defaultView||window;var N=_.getSelection&&_.getSelection();if(N&&N.rangeCount!==0){_=N.anchorNode;var P=N.anchorOffset,F=N.focusNode;N=N.focusOffset;try{_.nodeType,F.nodeType}catch{_=null;break e}var Q=0,xe=-1,Re=-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||N!==0&&_t.nodeType!==3||(Re=Q+N),_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===N&&(Re=Q),(ht=_t.nextSibling)!==null)break;_t=ot,ot=_t.parentNode}_t=ht}_=xe===-1||Re===-1?null:{start:xe,end:Re}}else _=null}_=_||{start:0,end:0}}else _=null;for(TA={focusedElem:h,selectionRange:_},r_=!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,N=_.stateNode;try{var qt=Rh(_.type,P);h=N.getSnapshotBeforeUpdate(qt,F),N.__reactInternalSnapshotBeforeUpdate=h}catch(an){sr(_,_.return,an)}}break;case 3:if((h&1024)!==0){if(h=g.stateNode.containerInfo,_=h.nodeType,_===9)jA(h);else if(_===1)switch(h.nodeName){case"HEAD":case"HTML":case"BODY":jA(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 C5(h,g,_){var N=_.flags;switch(_.tag){case 0:case 11:case 15:Nc(h,_),N&4&&Bx(5,_);break;case 1:if(Nc(h,_),N&4)if(h=_.stateNode,g===null)try{h.componentDidMount()}catch(Q){sr(_,_.return,Q)}else{var P=Rh(_.type,g.memoizedProps);g=g.memoizedState;try{h.componentDidUpdate(P,g,h.__reactInternalSnapshotBeforeUpdate)}catch(Q){sr(_,_.return,Q)}}N&64&&S5(_),N&512&&$x(_,_.return);break;case 3:if(Nc(h,_),N&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{fF(h,g)}catch(Q){sr(_,_.return,Q)}}break;case 27:g===null&&N&4&&A5(_);case 26:case 5:Nc(h,_),g===null&&N&4&&N5(_),N&512&&$x(_,_.return);break;case 12:Nc(h,_);break;case 31:Nc(h,_),N&4&&P5(h,_);break;case 13:Nc(h,_),N&4&&R5(h,_),N&64&&(h=_.memoizedState,h!==null&&(h=h.dehydrated,h!==null&&(_=lse.bind(null,_),Tse(h,_))));break;case 22:if(N=_.memoizedState!==null||Sc,!N){g=g!==null&&g.memoizedState!==null||vi,P=Sc;var F=vi;Sc=N,(vi=g)&&!F?Ec(h,_,(_.subtreeFlags&8772)!==0):Nc(h,_),Sc=P,vi=F}break;case 30:break;default:Nc(h,_)}}function k5(h){var g=h.alternate;g!==null&&(h.alternate=null,k5(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,cs=!1;function Mc(h,g,_){for(_=_.child;_!==null;)j5(h,g,_),_=_.sibling}function j5(h,g,_){if(se&&typeof se.onCommitFiberUnmount=="function")try{se.onCommitFiberUnmount(Qe,_)}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 N=Ir,P=cs;qu(_.type)&&(Ir=_.stateNode,cs=!1),Mc(h,g,_),Qx(_.stateNode),Ir=N,cs=P;break;case 5:vi||wl(_,g);case 6:if(N=Ir,P=cs,Ir=null,Mc(h,g,_),Ir=N,cs=P,Ir!==null)if(cs)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&&(cs?(h=Ir,SU(h.nodeType===9?h.body:h.nodeName==="HTML"?h.ownerDocument.body:h,_.stateNode),Wm(h)):SU(Ir,_.stateNode));break;case 4:N=Ir,P=cs,Ir=_.stateNode.containerInfo,cs=!0,Mc(h,g,_),Ir=N,cs=P;break;case 0:case 11:case 14:case 15:zu(2,_,g),vi||zu(4,_,g),Mc(h,g,_);break;case 1:vi||(wl(_,g),N=_.stateNode,typeof N.componentWillUnmount=="function"&&M5(_,g,N)),Mc(h,g,_);break;case 21:Mc(h,g,_);break;case 22:vi=(N=vi)||_.memoizedState!==null,Mc(h,g,_),vi=N;break;default:Mc(h,g,_)}}function P5(h,g){if(g.memoizedState===null&&(h=g.alternate,h!==null&&(h=h.memoizedState,h!==null))){h=h.dehydrated;try{Wm(h)}catch(_){sr(g,g.return,_)}}}function R5(h,g){if(g.memoizedState===null&&(h=g.alternate,h!==null&&(h=h.memoizedState,h!==null&&(h=h.dehydrated,h!==null))))try{Wm(h)}catch(_){sr(g,g.return,_)}}function ese(h){switch(h.tag){case 31:case 13:case 19:var g=h.stateNode;return g===null&&(g=h.stateNode=new T5),g;case 22:return h=h.stateNode,g=h._retryCache,g===null&&(g=h._retryCache=new T5),g;default:throw Error(r(435,h.tag))}}function Iv(h,g){var _=ese(h);g.forEach(function(N){if(!_.has(N)){_.add(N);var P=cse.bind(null,h,N);N.then(P,P)}})}function us(h,g){var _=g.deletions;if(_!==null)for(var N=0;N<_.length;N++){var P=_[N],F=h,Q=g,xe=Q;e:for(;xe!==null;){switch(xe.tag){case 27:if(qu(xe.type)){Ir=xe.stateNode,cs=!1;break e}break;case 5:Ir=xe.stateNode,cs=!1;break e;case 3:case 4:Ir=xe.stateNode.containerInfo,cs=!0;break e}xe=xe.return}if(Ir===null)throw Error(r(160));j5(F,Q,P),Ir=null,cs=!1,F=P.alternate,F!==null&&(F.return=null),P.return=null}if(g.subtreeFlags&13886)for(g=g.child;g!==null;)D5(g,h),g=g.sibling}var $o=null;function D5(h,g){var _=h.alternate,N=h.flags;switch(h.tag){case 0:case 11:case 14:case 15:us(g,h),ds(h),N&4&&(zu(3,h,h.return),Bx(3,h),zu(5,h,h.return));break;case 1:us(g,h),ds(h),N&512&&(vi||_===null||wl(_,_.return)),N&64&&Sc&&(h=h.updateQueue,h!==null&&(N=h.callbacks,N!==null&&(_=h.shared.hiddenCallbacks,h.shared.hiddenCallbacks=_===null?N:_.concat(N))));break;case 26:var P=$o;if(us(g,h),ds(h),N&512&&(vi||_===null||wl(_,_.return)),N&4){var F=_!==null?_.memoizedState:null;if(N=h.memoizedState,_===null)if(N===null)if(h.stateNode===null){e:{N=h.type,_=h.memoizedProps,P=P.ownerDocument||P;t:switch(N){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(N),P.head.insertBefore(F,P.querySelector("head > title"))),ha(F,N,_),F[Un]=h,de(F),N=F;break e;case"link":var Q=DU("link","href",P).get(N+(_.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(N),ha(F,N,_),P.head.appendChild(F);break;case"meta":if(Q=DU("meta","content",P).get(N+(_.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(N),ha(F,N,_),P.head.appendChild(F);break;default:throw Error(r(468,N))}F[Un]=h,de(F),N=F}h.stateNode=N}else OU(P,h.type,h.stateNode);else h.stateNode=RU(P,N,h.memoizedProps);else F!==N?(F===null?_.stateNode!==null&&(_=_.stateNode,_.parentNode.removeChild(_)):F.count--,N===null?OU(P,h.type,h.stateNode):RU(P,N,h.memoizedProps)):N===null&&h.stateNode!==null&&rA(h,h.memoizedProps,_.memoizedProps)}break;case 27:us(g,h),ds(h),N&512&&(vi||_===null||wl(_,_.return)),_!==null&&N&4&&rA(h,h.memoizedProps,_.memoizedProps);break;case 5:if(us(g,h),ds(h),N&512&&(vi||_===null||wl(_,_.return)),h.flags&32){P=h.stateNode;try{vr(P,"")}catch(qt){sr(h,h.return,qt)}}N&4&&h.stateNode!=null&&(P=h.memoizedProps,rA(h,P,_!==null?_.memoizedProps:P)),N&1024&&(sA=!0);break;case 6:if(us(g,h),ds(h),N&4){if(h.stateNode===null)throw Error(r(162));N=h.memoizedProps,_=h.stateNode;try{_.nodeValue=N}catch(qt){sr(h,h.return,qt)}}break;case 3:if(Jv=null,P=$o,$o=Qv(g.containerInfo),us(g,h),$o=P,ds(h),N&4&&_!==null&&_.memoizedState.isDehydrated)try{Wm(g.containerInfo)}catch(qt){sr(h,h.return,qt)}sA&&(sA=!1,O5(h));break;case 4:N=$o,$o=Qv(h.stateNode.containerInfo),us(g,h),ds(h),$o=N;break;case 12:us(g,h),ds(h);break;case 31:us(g,h),ds(h),N&4&&(N=h.updateQueue,N!==null&&(h.updateQueue=null,Iv(h,N)));break;case 13:us(g,h),ds(h),h.child.flags&8192&&h.memoizedState!==null!=(_!==null&&_.memoizedState!==null)&&(Uv=L()),N&4&&(N=h.updateQueue,N!==null&&(h.updateQueue=null,Iv(h,N)));break;case 22:P=h.memoizedState!==null;var Re=_!==null&&_.memoizedState!==null,at=Sc,bt=vi;if(Sc=at||P,vi=bt||Re,us(g,h),vi=bt,Sc=at,ds(h),N&8192)e:for(g=h.stateNode,g._visibility=P?g._visibility&-2:g._visibility|1,P&&(_===null||Re||Sc||vi||Dh(h)),_=null,g=h;;){if(g.tag===5||g.tag===26){if(_===null){Re=_=g;try{if(F=Re.stateNode,P)Q=F.style,typeof Q.setProperty=="function"?Q.setProperty("display","none","important"):Q.display="none";else{xe=Re.stateNode;var _t=Re.memoizedProps.style,ot=_t!=null&&_t.hasOwnProperty("display")?_t.display:null;xe.style.display=ot==null||typeof ot=="boolean"?"":(""+ot).trim()}}catch(qt){sr(Re,Re.return,qt)}}}else if(g.tag===6){if(_===null){Re=g;try{Re.stateNode.nodeValue=P?"":Re.memoizedProps}catch(qt){sr(Re,Re.return,qt)}}}else if(g.tag===18){if(_===null){Re=g;try{var ht=Re.stateNode;P?MU(ht,!0):MU(Re.stateNode,!1)}catch(qt){sr(Re,Re.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}N&4&&(N=h.updateQueue,N!==null&&(_=N.retryQueue,_!==null&&(N.retryQueue=null,Iv(h,_))));break;case 19:us(g,h),ds(h),N&4&&(N=h.updateQueue,N!==null&&(h.updateQueue=null,Iv(h,N)));break;case 30:break;case 21:break;default:us(g,h),ds(h)}}function ds(h){var g=h.flags;if(g&2){try{for(var _,N=h.return;N!==null;){if(E5(N)){_=N;break}N=N.return}if(_==null)throw Error(r(160));switch(_.tag){case 27:var P=_.stateNode,F=iA(h);Lv(h,F,P);break;case 5:var Q=_.stateNode;_.flags&32&&(vr(Q,""),_.flags&=-33);var xe=iA(h);Lv(h,xe,Q);break;case 3:case 4:var Re=_.stateNode.containerInfo,at=iA(h);aA(h,at,Re);break;default:throw Error(r(161))}}catch(bt){sr(h,h.return,bt)}h.flags&=-3}g&4096&&(h.flags&=-4097)}function O5(h){if(h.subtreeFlags&1024)for(h=h.child;h!==null;){var g=h;O5(g),g.tag===5&&g.flags&1024&&g.stateNode.reset(),h=h.sibling}}function Nc(h,g){if(g.subtreeFlags&8772)for(g=g.child;g!==null;)C5(h,g.alternate,g),g=g.sibling}function Dh(h){for(h=h.child;h!==null;){var g=h;switch(g.tag){case 0:case 11:case 14:case 15:zu(4,g,g.return),Dh(g);break;case 1:wl(g,g.return);var _=g.stateNode;typeof _.componentWillUnmount=="function"&&M5(g,g.return,_),Dh(g);break;case 27:Qx(g.stateNode);case 26:case 5:wl(g,g.return),Dh(g);break;case 22:g.memoizedState===null&&Dh(g);break;case 30:Dh(g);break;default:Dh(g)}h=h.sibling}}function Ec(h,g,_){for(_=_&&(g.subtreeFlags&8772)!==0,g=g.child;g!==null;){var N=g.alternate,P=h,F=g,Q=F.flags;switch(F.tag){case 0:case 11:case 15:Ec(P,F,_),Bx(4,F);break;case 1:if(Ec(P,F,_),N=F,P=N.stateNode,typeof P.componentDidMount=="function")try{P.componentDidMount()}catch(at){sr(N,N.return,at)}if(N=F,P=N.updateQueue,P!==null){var xe=N.stateNode;try{var Re=P.shared.hiddenCallbacks;if(Re!==null)for(P.shared.hiddenCallbacks=null,P=0;P<Re.length;P++)hF(Re[P],xe)}catch(at){sr(N,N.return,at)}}_&&Q&64&&S5(F),$x(F,F.return);break;case 27:A5(F);case 26:case 5:Ec(P,F,_),_&&N===null&&Q&4&&N5(F),$x(F,F.return);break;case 12:Ec(P,F,_);break;case 31:Ec(P,F,_),_&&Q&4&&P5(P,F);break;case 13:Ec(P,F,_),_&&Q&4&&R5(P,F);break;case 22:F.memoizedState===null&&Ec(P,F,_),$x(F,F.return);break;case 30:break;default:Ec(P,F,_)}g=g.sibling}}function oA(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&&Tx(_))}function lA(h,g){h=null,g.alternate!==null&&(h=g.alternate.memoizedState.cache),g=g.memoizedState.cache,g!==h&&(g.refCount++,h!=null&&Tx(h))}function Ho(h,g,_,N){if(g.subtreeFlags&10256)for(g=g.child;g!==null;)L5(h,g,_,N),g=g.sibling}function L5(h,g,_,N){var P=g.flags;switch(g.tag){case 0:case 11:case 15:Ho(h,g,_,N),P&2048&&Bx(9,g);break;case 1:Ho(h,g,_,N);break;case 3:Ho(h,g,_,N),P&2048&&(h=null,g.alternate!==null&&(h=g.alternate.memoizedState.cache),g=g.memoizedState.cache,g!==h&&(g.refCount++,h!=null&&Tx(h)));break;case 12:if(P&2048){Ho(h,g,_,N),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(Re){sr(g,g.return,Re)}}else Ho(h,g,_,N);break;case 31:Ho(h,g,_,N);break;case 13:Ho(h,g,_,N);break;case 23:break;case 22:F=g.stateNode,Q=g.alternate,g.memoizedState!==null?F._visibility&2?Ho(h,g,_,N):Hx(h,g):F._visibility&2?Ho(h,g,_,N):(F._visibility|=2,Om(h,g,_,N,(g.subtreeFlags&10256)!==0||!1)),P&2048&&oA(Q,g);break;case 24:Ho(h,g,_,N),P&2048&&lA(g.alternate,g);break;default:Ho(h,g,_,N)}}function Om(h,g,_,N,P){for(P=P&&((g.subtreeFlags&10256)!==0||!1),g=g.child;g!==null;){var F=h,Q=g,xe=_,Re=N,at=Q.flags;switch(Q.tag){case 0:case 11:case 15:Om(F,Q,xe,Re,P),Bx(8,Q);break;case 23:break;case 22:var bt=Q.stateNode;Q.memoizedState!==null?bt._visibility&2?Om(F,Q,xe,Re,P):Hx(F,Q):(bt._visibility|=2,Om(F,Q,xe,Re,P)),P&&at&2048&&oA(Q.alternate,Q);break;case 24:Om(F,Q,xe,Re,P),P&&at&2048&&lA(Q.alternate,Q);break;default:Om(F,Q,xe,Re,P)}g=g.sibling}}function Hx(h,g){if(g.subtreeFlags&10256)for(g=g.child;g!==null;){var _=h,N=g,P=N.flags;switch(N.tag){case 22:Hx(_,N),P&2048&&oA(N.alternate,N);break;case 24:Hx(_,N),P&2048&&lA(N.alternate,N);break;default:Hx(_,N)}g=g.sibling}}var Vx=8192;function Lm(h,g,_){if(h.subtreeFlags&Vx)for(h=h.child;h!==null;)I5(h,g,_),h=h.sibling}function I5(h,g,_){switch(h.tag){case 26:Lm(h,g,_),h.flags&Vx&&h.memoizedState!==null&&zse(_,$o,h.memoizedState,h.memoizedProps);break;case 5:Lm(h,g,_);break;case 3:case 4:var N=$o;$o=Qv(h.stateNode.containerInfo),Lm(h,g,_),$o=N;break;case 22:h.memoizedState===null&&(N=h.alternate,N!==null&&N.memoizedState!==null?(N=Vx,Vx=16777216,Lm(h,g,_),Vx=N):Lm(h,g,_));break;default:Lm(h,g,_)}}function F5(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 Gx(h){var g=h.deletions;if((h.flags&16)!==0){if(g!==null)for(var _=0;_<g.length;_++){var N=g[_];Gi=N,z5(N,h)}F5(h)}if(h.subtreeFlags&10256)for(h=h.child;h!==null;)U5(h),h=h.sibling}function U5(h){switch(h.tag){case 0:case 11:case 15:Gx(h),h.flags&2048&&zu(9,h,h.return);break;case 3:Gx(h);break;case 12:Gx(h);break;case 22:var g=h.stateNode;h.memoizedState!==null&&g._visibility&2&&(h.return===null||h.return.tag!==13)?(g._visibility&=-3,Fv(h)):Gx(h);break;default:Gx(h)}}function Fv(h){var g=h.deletions;if((h.flags&16)!==0){if(g!==null)for(var _=0;_<g.length;_++){var N=g[_];Gi=N,z5(N,h)}F5(h)}for(h=h.child;h!==null;){switch(g=h,g.tag){case 0:case 11:case 15:zu(8,g,g.return),Fv(g);break;case 22:_=g.stateNode,_._visibility&2&&(_._visibility&=-3,Fv(g));break;default:Fv(g)}h=h.sibling}}function z5(h,g){for(;Gi!==null;){var _=Gi;switch(_.tag){case 0:case 11:case 15:zu(8,_,g);break;case 23:case 22:if(_.memoizedState!==null&&_.memoizedState.cachePool!==null){var N=_.memoizedState.cachePool.pool;N!=null&&N.refCount++}break;case 24:Tx(_.memoizedState.cache)}if(N=_.child,N!==null)N.return=_,Gi=N;else e:for(_=h;Gi!==null;){N=Gi;var P=N.sibling,F=N.return;if(k5(N),N===_){Gi=null;break e}if(P!==null){P.return=F,Gi=P;break e}Gi=F}}}var tse={getCacheForType:function(h){var g=ua(xi),_=g.data.get(h);return _===void 0&&(_=h(),g.data.set(h,_)),_},cacheSignal:function(){return ua(xi).controller.signal}},nse=typeof WeakMap=="function"?WeakMap:Map,Zn=0,_r=null,kn=null,Dn=0,ar=0,Rs=null,Bu=!1,Im=!1,cA=!1,Ac=0,Zr=0,$u=0,Oh=0,uA=0,Ds=0,Fm=0,Wx=null,hs=null,dA=!1,Uv=0,B5=0,zv=1/0,Bv=null,Hu=null,ji=0,Vu=null,Um=null,Tc=0,hA=0,fA=null,$5=null,qx=0,mA=null;function Os(){return(Zn&2)!==0&&Dn!==0?Dn&-Dn:X.T!==null?vA():Cn()}function H5(){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 fs(h,g,_){(h===_r&&(ar===2||ar===9)||h.cancelPendingCommit!==null)&&(zm(h,0),Gu(h,Dn,Ds,!1)),on(h,_),((Zn&2)===0||h!==_r)&&(h===_r&&((Zn&2)===0&&(Oh|=_),Zr===4&&Gu(h,Dn,Ds,!1)),Sl(h))}function V5(h,g,_){if((Zn&6)!==0)throw Error(r(327));var N=!_&&(g&127)===0&&(g&h.expiredLanes)===0||We(h,g),P=N?ase(h,g):gA(h,g,!0),F=N;do{if(P===0){Im&&!N&&Gu(h,g,0,!1);break}else{if(_=h.current.alternate,F&&!rse(_)){P=gA(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=Wx;var Re=xe.current.memoizedState.isDehydrated;if(Re&&(zm(xe,Q).flags|=256),Q=gA(xe,Q,!1),Q!==2){if(cA&&!Re){xe.errorRecoveryDisabledLanes|=F,Oh|=F,P=4;break e}F=hs,hs=P,F!==null&&(hs===null?hs=F:hs.push.apply(hs,F))}P=Q}if(F=!1,P!==2)continue}}if(P===1){zm(h,0),Gu(h,g,0,!0);break}e:{switch(N=h,F=P,F){case 0:case 1:throw Error(r(345));case 4:if((g&4194048)!==g)break;case 6:Gu(N,g,Ds,!Bu);break e;case 2:hs=null;break;case 3:case 5:break;default:throw Error(r(329))}if((g&62914560)===g&&(P=Uv+300-L(),10<P)){if(Gu(N,g,Ds,!Bu),Te(N,0,!0)!==0)break e;Tc=g,N.timeoutHandle=_U(G5.bind(null,N,_,hs,Bv,dA,g,Ds,Oh,Fm,Bu,F,"Throttled",-0,0),P);break e}G5(N,_,hs,Bv,dA,g,Ds,Oh,Fm,Bu,F,null,-0,0)}}break}while(!0);Sl(h)}function G5(h,g,_,N,P,F,Q,xe,Re,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},I5(g,F,_t);var qt=(F&62914560)===F?Uv-L():(F&4194048)===F?B5-L():0;if(qt=Bse(_t,qt),qt!==null){Tc=F,h.cancelPendingCommit=qt(J5.bind(null,h,g,F,_,N,P,Q,xe,Re,bt,_t,null,ot,ht)),Gu(h,F,Q,!at);return}}J5(h,g,F,_,N,P,Q,xe,Re)}function rse(h){for(var g=h;;){var _=g.tag;if((_===0||_===11||_===15)&&g.flags&16384&&(_=g.updateQueue,_!==null&&(_=_.stores,_!==null)))for(var N=0;N<_.length;N++){var P=_[N],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 Gu(h,g,_,N){g&=~uA,g&=~Oh,h.suspendedLanes|=g,h.pingedLanes&=~g,N&&(h.warmLanes|=g),N=h.expirationTimes;for(var P=g;0<P;){var F=31-ke(P),Q=1<<F;N[F]=-1,P&=~Q}_!==0&&yn(h,_,g)}function $v(){return(Zn&6)===0?(Kx(0),!1):!0}function pA(){if(kn!==null){if(ar===0)var h=kn.return;else h=kn,xc=Eh=null,j2(h),km=null,kx=0,h=kn;for(;h!==null;)w5(h.alternate,h),h=h.return;kn=null}}function zm(h,g){var _=h.timeoutHandle;_!==-1&&(h.timeoutHandle=-1,Sse(_)),_=h.cancelPendingCommit,_!==null&&(h.cancelPendingCommit=null,_()),Tc=0,pA(),_r=h,kn=_=pc(h.current,null),Dn=g,ar=0,Rs=null,Bu=!1,Im=We(h,g),cA=!1,Fm=Ds=uA=Oh=$u=Zr=0,hs=Wx=null,dA=!1,(g&8)!==0&&(g|=g&32);var N=h.entangledLanes;if(N!==0)for(h=h.entanglements,N&=g;0<N;){var P=31-ke(N),F=1<<P;g|=h[P],N&=~F}return Ac=g,cv(),_}function W5(h,g){bn=null,X.H=Fx,g===Cm||g===xv?(g=lF(),ar=3):g===y2?(g=lF(),ar=4):ar=g===q2?8:g!==null&&typeof g=="object"&&typeof g.then=="function"?6:1,Rs=g,kn===null&&(Zr=1,jv(h,ro(g,h.current)))}function q5(){var h=js.current;return h===null?!0:(Dn&4194048)===Dn?oo===null:(Dn&62914560)===Dn||(Dn&536870912)!==0?h===oo:!1}function K5(){var h=X.H;return X.H=Fx,h===null?Fx:h}function X5(){var h=X.A;return X.A=tse,h}function Hv(){Zr=4,Bu||(Dn&4194048)!==Dn&&js.current!==null||(Im=!0),($u&134217727)===0&&(Oh&134217727)===0||_r===null||Gu(_r,Dn,Ds,!1)}function gA(h,g,_){var N=Zn;Zn|=2;var P=K5(),F=X5();(_r!==h||Dn!==g)&&(Bv=null,zm(h,g)),g=!1;var Q=Zr;e:do try{if(ar!==0&&kn!==null){var xe=kn,Re=Rs;switch(ar){case 8:pA(),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,Bm(h,xe,Re,at),_&&Im){Q=0;break e}break;default:at=ar,ar=0,Rs=null,Bm(h,xe,Re,at)}}ise(),Q=Zr;break}catch(bt){W5(h,bt)}while(!0);return g&&h.shellSuspendCounter++,xc=Eh=null,Zn=N,X.H=P,X.A=F,kn===null&&(_r=null,Dn=0,cv()),Q}function ise(){for(;kn!==null;)Y5(kn)}function ase(h,g){var _=Zn;Zn|=2;var N=K5(),P=X5();_r!==h||Dn!==g?(Bv=null,zv=L()+500,zm(h,g)):Im=We(h,g);e:do try{if(ar!==0&&kn!==null){g=kn;var F=Rs;t:switch(ar){case 1:ar=0,Rs=null,Bm(h,g,F,1);break;case 2:case 9:if(sF(F)){ar=0,Rs=null,Q5(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:sF(F)?(ar=0,Rs=null,Q5(g)):(ar=0,Rs=null,Bm(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?LU(Q):xe.stateNode.complete){ar=0,Rs=null;var Re=xe.sibling;if(Re!==null)kn=Re;else{var at=xe.return;at!==null?(kn=at,Vv(at)):kn=null}break t}}ar=0,Rs=null,Bm(h,g,F,5);break;case 6:ar=0,Rs=null,Bm(h,g,F,6);break;case 8:pA(),Zr=6;break e;default:throw Error(r(462))}}sse();break}catch(bt){W5(h,bt)}while(!0);return xc=Eh=null,X.H=N,X.A=P,Zn=_,kn!==null?0:(_r=null,Dn=0,cv(),Zr)}function sse(){for(;kn!==null&&!ue();)Y5(kn)}function Y5(h){var g=v5(h.alternate,h,Ac);h.memoizedProps=h.pendingProps,g===null?Vv(h):kn=g}function Q5(h){var g=h,_=g.alternate;switch(g.tag){case 15:case 0:g=m5(_,g,g.pendingProps,g.type,void 0,Dn);break;case 11:g=m5(_,g,g.pendingProps,g.type.render,g.ref,Dn);break;case 5:j2(g);default:w5(_,g),g=kn=XI(g,Ac),g=v5(_,g,Ac)}h.memoizedProps=h.pendingProps,g===null?Vv(h):kn=g}function Bm(h,g,_,N){xc=Eh=null,j2(g),km=null,kx=0;var P=g.return;try{if(Kae(h,P,g,_,Dn)){Zr=1,jv(h,ro(_,h.current)),kn=null;return}}catch(F){if(P!==null)throw kn=P,F;Zr=1,jv(h,ro(_,h.current)),kn=null;return}g.flags&32768?(Ln||N===1?h=!0:Im||(Dn&536870912)!==0?h=!1:(Bu=h=!0,(N===2||N===9||N===3||N===6)&&(N=js.current,N!==null&&N.tag===13&&(N.flags|=16384))),Z5(g,h)):Vv(g)}function Vv(h){var g=h;do{if((g.flags&32768)!==0){Z5(g,Bu);return}h=g.return;var _=Qae(g.alternate,g,Ac);if(_!==null){kn=_;return}if(g=g.sibling,g!==null){kn=g;return}kn=g=h}while(g!==null);Zr===0&&(Zr=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);Zr=6,kn=null}function J5(h,g,_,N,P,F,Q,xe,Re){h.cancelPendingCommit=null;do Gv();while(ji!==0);if((Zn&6)!==0)throw Error(r(327));if(g!==null){if(g===h.current)throw Error(r(177));if(F=g.lanes|g.childLanes,F|=i2,Ut(h,_,F,Q,xe,Re),h===_r&&(kn=_r=null,Dn=0),Um=g,Vu=h,Tc=_,hA=F,fA=P,$5=N,(g.subtreeFlags&10256)!==0||(g.flags&10256)!==0?(h.callbackNode=null,h.callbackPriority=0,use(ae,function(){return iU(),null})):(h.callbackNode=null,h.callbackPriority=0),N=(g.flags&13878)!==0,(g.subtreeFlags&13878)!==0||N){N=X.T,X.T=null,P=G.p,G.p=2,Q=Zn,Zn|=4;try{Jae(h,g,_)}finally{Zn=Q,G.p=P,X.T=N}}ji=1,eU(),tU(),nU()}}function eU(){if(ji===1){ji=0;var h=Vu,g=Um,_=(g.flags&13878)!==0;if((g.subtreeFlags&13878)!==0||_){_=X.T,X.T=null;var N=G.p;G.p=2;var P=Zn;Zn|=4;try{D5(g,h);var F=TA,Q=zI(h.containerInfo),xe=F.focusedElem,Re=F.selectionRange;if(Q!==xe&&xe&&xe.ownerDocument&&UI(xe.ownerDocument.documentElement,xe)){if(Re!==null&&JE(xe)){var at=Re.start,bt=Re.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(Re.start,qt),hr=Re.end===void 0?an:Math.min(Re.end,qt);!ht.extend&&an>hr&&(Q=hr,hr=an,an=Q);var Ye=FI(xe,an),ze=FI(xe,hr);if(Ye&&ze&&(ht.rangeCount!==1||ht.anchorNode!==Ye.node||ht.anchorOffset!==Ye.offset||ht.focusNode!==ze.node||ht.focusOffset!==ze.offset)){var rt=_t.createRange();rt.setStart(Ye.node,Ye.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}}r_=!!AA,TA=AA=null}finally{Zn=P,G.p=N,X.T=_}}h.current=g,ji=2}}function tU(){if(ji===2){ji=0;var h=Vu,g=Um,_=(g.flags&8772)!==0;if((g.subtreeFlags&8772)!==0||_){_=X.T,X.T=null;var N=G.p;G.p=2;var P=Zn;Zn|=4;try{C5(h,g.alternate,g)}finally{Zn=P,G.p=N,X.T=_}}ji=3}}function nU(){if(ji===4||ji===3){ji=0,$();var h=Vu,g=Um,_=Tc,N=$5;(g.subtreeFlags&10256)!==0||(g.flags&10256)!==0?ji=5:(ji=0,Um=Vu=null,rU(h,h.pendingLanes));var P=h.pendingLanes;if(P===0&&(Hu=null),Tt(_),g=g.stateNode,se&&typeof se.onCommitFiberRoot=="function")try{se.onCommitFiberRoot(Qe,g,void 0,(g.current.flags&128)===128)}catch{}if(N!==null){g=X.T,P=G.p,G.p=2,X.T=null;try{for(var F=h.onRecoverableError,Q=0;Q<N.length;Q++){var xe=N[Q];F(xe.value,{componentStack:xe.stack})}}finally{X.T=g,G.p=P}}(Tc&3)!==0&&Gv(),Sl(h),P=h.pendingLanes,(_&261930)!==0&&(P&42)!==0?h===mA?qx++:(qx=0,mA=h):qx=0,Kx(0)}}function rU(h,g){(h.pooledCacheLanes&=g)===0&&(g=h.pooledCache,g!=null&&(h.pooledCache=null,Tx(g)))}function Gv(){return eU(),tU(),nU(),iU()}function iU(){if(ji!==5)return!1;var h=Vu,g=hA;hA=0;var _=Tt(Tc),N=X.T,P=G.p;try{G.p=32>_?32:_,X.T=null,_=fA,fA=null;var F=Vu,Q=Tc;if(ji=0,Um=Vu=null,Tc=0,(Zn&6)!==0)throw Error(r(331));var xe=Zn;if(Zn|=4,U5(F.current),L5(F,F.current,Q,_),Zn=xe,Kx(0,!1),se&&typeof se.onPostCommitFiberRoot=="function")try{se.onPostCommitFiberRoot(Qe,F)}catch{}return!0}finally{G.p=P,X.T=N,rU(h,g)}}function aU(h,g,_){g=ro(_,g),g=W2(h.stateNode,g,2),h=Iu(h,g,2),h!==null&&(on(h,2),Sl(h))}function sr(h,g,_){if(h.tag===3)aU(h,h,_);else for(;g!==null;){if(g.tag===3){aU(g,h,_);break}else if(g.tag===1){var N=g.stateNode;if(typeof g.type.getDerivedStateFromError=="function"||typeof N.componentDidCatch=="function"&&(Hu===null||!Hu.has(N))){h=ro(_,h),_=s5(2),N=Iu(g,_,2),N!==null&&(o5(_,N,g,h),on(N,2),Sl(N));break}}g=g.return}}function xA(h,g,_){var N=h.pingCache;if(N===null){N=h.pingCache=new nse;var P=new Set;N.set(g,P)}else P=N.get(g),P===void 0&&(P=new Set,N.set(g,P));P.has(_)||(cA=!0,P.add(_),h=ose.bind(null,h,g,_),g.then(h,h))}function ose(h,g,_){var N=h.pingCache;N!==null&&N.delete(g),h.pingedLanes|=h.suspendedLanes&_,h.warmLanes&=~_,_r===h&&(Dn&_)===_&&(Zr===4||Zr===3&&(Dn&62914560)===Dn&&300>L()-Uv?(Zn&2)===0&&zm(h,0):uA|=_,Fm===Dn&&(Fm=0)),Sl(h)}function sU(h,g){g===0&&(g=Ot()),h=Sh(h,g),h!==null&&(on(h,g),Sl(h))}function lse(h){var g=h.memoizedState,_=0;g!==null&&(_=g.retryLane),sU(h,_)}function cse(h,g){var _=0;switch(h.tag){case 31:case 13:var N=h.stateNode,P=h.memoizedState;P!==null&&(_=P.retryLane);break;case 19:N=h.stateNode;break;case 22:N=h.stateNode._retryCache;break;default:throw Error(r(314))}N!==null&&N.delete(g),sU(h,_)}function use(h,g){return Ee(h,g)}var Wv=null,$m=null,bA=!1,qv=!1,yA=!1,Wu=0;function Sl(h){h!==$m&&h.next===null&&($m===null?Wv=$m=h:$m=$m.next=h),qv=!0,bA||(bA=!0,hse())}function Kx(h,g){if(!yA&&qv){yA=!0;do for(var _=!1,N=Wv;N!==null;){if(h!==0){var P=N.pendingLanes;if(P===0)var F=0;else{var Q=N.suspendedLanes,xe=N.pingedLanes;F=(1<<31-ke(42|h)+1)-1,F&=P&~(Q&~xe),F=F&201326741?F&201326741|1:F?F|2:0}F!==0&&(_=!0,uU(N,F))}else F=Dn,F=Te(N,N===_r?F:0,N.cancelPendingCommit!==null||N.timeoutHandle!==-1),(F&3)===0||We(N,F)||(_=!0,uU(N,F));N=N.next}while(_);yA=!1}}function dse(){oU()}function oU(){qv=bA=!1;var h=0;Wu!==0&&wse()&&(h=Wu);for(var g=L(),_=null,N=Wv;N!==null;){var P=N.next,F=lU(N,g);F===0?(N.next=null,_===null?Wv=P:_.next=P,P===null&&($m=_)):(_=N,(h!==0||(F&3)!==0)&&(qv=!0)),N=P}ji!==0&&ji!==5||Kx(h),Wu!==0&&(Wu=0)}function lU(h,g){for(var _=h.suspendedLanes,N=h.pingedLanes,P=h.expirationTimes,F=h.pendingLanes&-62914561;0<F;){var Q=31-ke(F),xe=1<<Q,Re=P[Q];Re===-1?((xe&_)===0||(xe&N)!==0)&&(P[Q]=it(xe,g)):Re<=g&&(h.expiredLanes|=xe),F&=~xe}if(g=_r,_=Dn,_=Te(h,h===g?_:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),N=h.callbackNode,_===0||h===g&&(ar===2||ar===9)||h.cancelPendingCommit!==null)return N!==null&&N!==null&&Ie(N),h.callbackNode=null,h.callbackPriority=0;if((_&3)===0||We(h,_)){if(g=_&-_,g===h.callbackPriority)return g;switch(N!==null&&Ie(N),Tt(_)){case 2:case 8:_=Se;break;case 32:_=ae;break;case 268435456:_=De;break;default:_=ae}return N=cU.bind(null,h),_=Ee(_,N),h.callbackPriority=g,h.callbackNode=_,g}return N!==null&&N!==null&&Ie(N),h.callbackPriority=2,h.callbackNode=null,2}function cU(h,g){if(ji!==0&&ji!==5)return h.callbackNode=null,h.callbackPriority=0,null;var _=h.callbackNode;if(Gv()&&h.callbackNode!==_)return null;var N=Dn;return N=Te(h,h===_r?N:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),N===0?null:(V5(h,N,g),lU(h,L()),h.callbackNode!=null&&h.callbackNode===_?cU.bind(null,h):null)}function uU(h,g){if(Gv())return null;V5(h,g,!0)}function hse(){Mse(function(){(Zn&6)!==0?Ee(pe,dse):oU()})}function vA(){if(Wu===0){var h=Am;h===0&&(h=Fe,Fe<<=1,(Fe&261888)===0&&(Fe=256)),Wu=h}return Wu}function dU(h){return h==null||typeof h=="symbol"||typeof h=="boolean"?null:typeof h=="function"?h:tv(""+h)}function hU(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 fse(h,g,_,N,P){if(g==="submit"&&_&&_.stateNode===P){var F=dU((P[yr]||null).action),Q=N.submitter;Q&&(g=(g=Q[yr]||null)?dU(g.formAction):Q.getAttribute("formAction"),g!==null&&(F=g,Q=null));var xe=new av("action","action",null,N,P);h.push({event:xe,listeners:[{instance:null,listener:function(){if(N.defaultPrevented){if(Wu!==0){var Re=Q?hU(P,Q):new FormData(P);z2(_,{pending:!0,data:Re,method:P.method,action:F},null,Re)}}else typeof F=="function"&&(xe.preventDefault(),Re=Q?hU(P,Q):new FormData(P),z2(_,{pending:!0,data:Re,method:P.method,action:F},F,Re))},currentTarget:P}]})}}for(var _A=0;_A<r2.length;_A++){var wA=r2[_A],mse=wA.toLowerCase(),pse=wA[0].toUpperCase()+wA.slice(1);Bo(mse,"on"+pse)}Bo(HI,"onAnimationEnd"),Bo(VI,"onAnimationIteration"),Bo(GI,"onAnimationStart"),Bo("dblclick","onDoubleClick"),Bo("focusin","onFocus"),Bo("focusout","onBlur"),Bo(jae,"onTransitionRun"),Bo(Pae,"onTransitionStart"),Bo(Rae,"onTransitionCancel"),Bo(WI,"onTransitionEnd"),Ve("onMouseEnter",["mouseout","mouseover"]),Ve("onMouseLeave",["mouseout","mouseover"]),Ve("onPointerEnter",["pointerout","pointerover"]),Ve("onPointerLeave",["pointerout","pointerover"]),qe("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),qe("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),qe("onBeforeInput",["compositionend","keypress","textInput","paste"]),qe("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),qe("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),qe("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Xx="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(" "),gse=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Xx));function fU(h,g){g=(g&4)!==0;for(var _=0;_<h.length;_++){var N=h[_],P=N.event;N=N.listeners;e:{var F=void 0;if(g)for(var Q=N.length-1;0<=Q;Q--){var xe=N[Q],Re=xe.instance,at=xe.currentTarget;if(xe=xe.listener,Re!==F&&P.isPropagationStopped())break e;F=xe,P.currentTarget=at;try{F(P)}catch(bt){lv(bt)}P.currentTarget=null,F=Re}else for(Q=0;Q<N.length;Q++){if(xe=N[Q],Re=xe.instance,at=xe.currentTarget,xe=xe.listener,Re!==F&&P.isPropagationStopped())break e;F=xe,P.currentTarget=at;try{F(P)}catch(bt){lv(bt)}P.currentTarget=null,F=Re}}}}function jn(h,g){var _=g[gi];_===void 0&&(_=g[gi]=new Set);var N=h+"__bubble";_.has(N)||(mU(g,h,2,!1),_.add(N))}function SA(h,g,_){var N=0;g&&(N|=4),mU(_,h,N,g)}var Kv="_reactListening"+Math.random().toString(36).slice(2);function MA(h){if(!h[Kv]){h[Kv]=!0,Pe.forEach(function(_){_!=="selectionchange"&&(gse.has(_)||SA(_,!1,h),SA(_,!0,h))});var g=h.nodeType===9?h:h.ownerDocument;g===null||g[Kv]||(g[Kv]=!0,SA("selectionchange",!1,g))}}function mU(h,g,_,N){switch(HU(g)){case 2:var P=Vse;break;case 8:P=Gse;break;default:P=UA}_=P.bind(null,g,_,h),P=void 0,!VE||g!=="touchstart"&&g!=="touchmove"&&g!=="wheel"||(P=!0),N?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 NA(h,g,_,N,P){var F=N;if((g&1)===0&&(g&2)===0&&N!==null)e:for(;;){if(N===null)return;var Q=N.tag;if(Q===3||Q===4){var xe=N.stateNode.containerInfo;if(xe===P)break;if(Q===4)for(Q=N.return;Q!==null;){var Re=Q.tag;if((Re===3||Re===4)&&Q.stateNode.containerInfo===P)return;Q=Q.return}for(;xe!==null;){if(Q=Pt(xe),Q===null)return;if(Re=Q.tag,Re===5||Re===6||Re===26||Re===27){N=F=Q;continue e}xe=xe.parentNode}}N=N.return}yI(function(){var at=F,bt=$E(_),_t=[];e:{var ot=qI.get(h);if(ot!==void 0){var ht=av,qt=h;switch(h){case"keypress":if(rv(_)===0)break e;case"keydown":case"keyup":ht=cae;break;case"focusin":qt="focus",ht=KE;break;case"focusout":qt="blur",ht=KE;break;case"beforeblur":case"afterblur":ht=KE;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=wI;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ht=Qie;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ht=hae;break;case HI:case VI:case GI:ht=eae;break;case WI:ht=mae;break;case"scroll":case"scrollend":ht=Xie;break;case"wheel":ht=gae;break;case"copy":case"cut":case"paste":ht=nae;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ht=MI;break;case"toggle":case"beforetoggle":ht=bae}var an=(g&4)!==0,hr=!an&&(h==="scroll"||h==="scrollend"),Ye=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||Ye===null||(vt=xx(ze,Ye),vt!=null&&an.push(Yx(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&&_!==BE&&(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=wI,vt="onMouseLeave",Ye="onMouseEnter",ze="mouse",(h==="pointerout"||h==="pointerover")&&(an=MI,vt="onPointerLeave",Ye="onPointerEnter",ze="pointer"),hr=ht==null?ot:Vt(ht),rt=qt==null?ot:Vt(qt),ot=new an(vt,ze+"leave",ht,_,bt),ot.target=hr,ot.relatedTarget=rt,vt=null,Pt(bt)===at&&(an=new an(Ye,ze+"enter",qt,_,bt),an.target=rt,an.relatedTarget=hr,vt=an),hr=vt,ht&&qt)t:{for(an=xse,Ye=ht,ze=qt,rt=0,vt=Ye;vt;vt=an(vt))rt++;vt=0;for(var tn=ze;tn;tn=an(tn))vt++;for(;0<rt-vt;)Ye=an(Ye),rt--;for(;0<vt-rt;)ze=an(ze),vt--;for(;rt--;){if(Ye===ze||ze!==null&&Ye===ze.alternate){an=Ye;break t}Ye=an(Ye),ze=an(ze)}an=null}else an=null;ht!==null&&pU(_t,ot,ht,an,!1),qt!==null&&hr!==null&&pU(_t,hr,qt,an,!0)}}e:{if(ot=at?Vt(at):window,ht=ot.nodeName&&ot.nodeName.toLowerCase(),ht==="select"||ht==="input"&&ot.type==="file")var Gn=PI;else if(kI(ot))if(RI)Gn=Tae;else{Gn=Eae;var Zt=Nae}else ht=ot.nodeName,!ht||ht.toLowerCase()!=="input"||ot.type!=="checkbox"&&ot.type!=="radio"?at&&jr(at.elementType)&&(Gn=PI):Gn=Aae;if(Gn&&(Gn=Gn(h,at))){jI(_t,Gn,_,bt);break e}Zt&&Zt(h,ot,at),h==="focusout"&&at&&ot.type==="number"&&at.memoizedProps.value!=null&&cn(ot,"number",ot.value)}switch(Zt=at?Vt(at):window,h){case"focusin":(kI(Zt)||Zt.contentEditable==="true")&&(ym=Zt,e2=at,Nx=null);break;case"focusout":Nx=e2=ym=null;break;case"mousedown":t2=!0;break;case"contextmenu":case"mouseup":case"dragend":t2=!1,BI(_t,_,bt);break;case"selectionchange":if(kae)break;case"keydown":case"keyup":BI(_t,_,bt)}var vn;if(YE)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 bm?TI(h,_)&&(On="onCompositionEnd"):h==="keydown"&&_.keyCode===229&&(On="onCompositionStart");On&&(NI&&_.locale!=="ko"&&(bm||On!=="onCompositionStart"?On==="onCompositionEnd"&&bm&&(vn=vI()):(ku=bt,GE="value"in ku?ku.value:ku.textContent,bm=!0)),Zt=Xv(at,On),0<Zt.length&&(On=new SI(On,h,null,_,bt),_t.push({event:On,listeners:Zt}),vn?On.data=vn:(vn=CI(_),vn!==null&&(On.data=vn)))),(vn=vae?_ae(h,_):wae(h,_))&&(On=Xv(at,"onBeforeInput"),0<On.length&&(Zt=new SI("onBeforeInput","beforeinput",null,_,bt),_t.push({event:Zt,listeners:On}),Zt.data=vn)),fse(_t,h,at,_,bt)}fU(_t,g)})}function Yx(h,g,_){return{instance:h,listener:g,currentTarget:_}}function Xv(h,g){for(var _=g+"Capture",N=[];h!==null;){var P=h,F=P.stateNode;if(P=P.tag,P!==5&&P!==26&&P!==27||F===null||(P=xx(h,_),P!=null&&N.unshift(Yx(h,P,F)),P=xx(h,g),P!=null&&N.push(Yx(h,P,F))),h.tag===3)return N;h=h.return}return[]}function xse(h){if(h===null)return null;do h=h.return;while(h&&h.tag!==5&&h.tag!==27);return h||null}function pU(h,g,_,N,P){for(var F=g._reactName,Q=[];_!==null&&_!==N;){var xe=_,Re=xe.alternate,at=xe.stateNode;if(xe=xe.tag,Re!==null&&Re===N)break;xe!==5&&xe!==26&&xe!==27||at===null||(Re=at,P?(at=xx(_,F),at!=null&&Q.unshift(Yx(_,at,Re))):P||(at=xx(_,F),at!=null&&Q.push(Yx(_,at,Re)))),_=_.return}Q.length!==0&&h.push({event:g,listeners:Q})}var bse=/\r\n?/g,yse=/\u0000|\uFFFD/g;function gU(h){return(typeof h=="string"?h:""+h).replace(bse,`
- `).replace(yse,"")}function xU(h,g){return g=gU(g),gU(h)===g}function dr(h,g,_,N,P,F){switch(_){case"children":typeof N=="string"?g==="body"||g==="textarea"&&N===""||vr(h,N):(typeof N=="number"||typeof N=="bigint")&&g!=="body"&&vr(h,""+N);break;case"className":Oe(h,"class",N);break;case"tabIndex":Oe(h,"tabindex",N);break;case"dir":case"role":case"viewBox":case"width":case"height":Oe(h,_,N);break;case"style":to(h,N,F);break;case"data":if(g!=="object"){Oe(h,"data",N);break}case"src":case"href":if(N===""&&(g!=="a"||_!=="href")){h.removeAttribute(_);break}if(N==null||typeof N=="function"||typeof N=="symbol"||typeof N=="boolean"){h.removeAttribute(_);break}N=tv(""+N),h.setAttribute(_,N);break;case"action":case"formAction":if(typeof N=="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(N==null||typeof N=="symbol"||typeof N=="boolean"){h.removeAttribute(_);break}N=tv(""+N),h.setAttribute(_,N);break;case"onClick":N!=null&&(h.onclick=fc);break;case"onScroll":N!=null&&jn("scroll",h);break;case"onScrollEnd":N!=null&&jn("scrollend",h);break;case"dangerouslySetInnerHTML":if(N!=null){if(typeof N!="object"||!("__html"in N))throw Error(r(61));if(_=N.__html,_!=null){if(P.children!=null)throw Error(r(60));h.innerHTML=_}}break;case"multiple":h.multiple=N&&typeof N!="function"&&typeof N!="symbol";break;case"muted":h.muted=N&&typeof N!="function"&&typeof N!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(N==null||typeof N=="function"||typeof N=="boolean"||typeof N=="symbol"){h.removeAttribute("xlink:href");break}_=tv(""+N),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":N!=null&&typeof N!="function"&&typeof N!="symbol"?h.setAttribute(_,""+N):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":N&&typeof N!="function"&&typeof N!="symbol"?h.setAttribute(_,""):h.removeAttribute(_);break;case"capture":case"download":N===!0?h.setAttribute(_,""):N!==!1&&N!=null&&typeof N!="function"&&typeof N!="symbol"?h.setAttribute(_,N):h.removeAttribute(_);break;case"cols":case"rows":case"size":case"span":N!=null&&typeof N!="function"&&typeof N!="symbol"&&!isNaN(N)&&1<=N?h.setAttribute(_,N):h.removeAttribute(_);break;case"rowSpan":case"start":N==null||typeof N=="function"||typeof N=="symbol"||isNaN(N)?h.removeAttribute(_):h.setAttribute(_,N);break;case"popover":jn("beforetoggle",h),jn("toggle",h),Mt(h,"popover",N);break;case"xlinkActuate":gt(h,"http://www.w3.org/1999/xlink","xlink:actuate",N);break;case"xlinkArcrole":gt(h,"http://www.w3.org/1999/xlink","xlink:arcrole",N);break;case"xlinkRole":gt(h,"http://www.w3.org/1999/xlink","xlink:role",N);break;case"xlinkShow":gt(h,"http://www.w3.org/1999/xlink","xlink:show",N);break;case"xlinkTitle":gt(h,"http://www.w3.org/1999/xlink","xlink:title",N);break;case"xlinkType":gt(h,"http://www.w3.org/1999/xlink","xlink:type",N);break;case"xmlBase":gt(h,"http://www.w3.org/XML/1998/namespace","xml:base",N);break;case"xmlLang":gt(h,"http://www.w3.org/XML/1998/namespace","xml:lang",N);break;case"xmlSpace":gt(h,"http://www.w3.org/XML/1998/namespace","xml:space",N);break;case"is":Mt(h,"is",N);break;case"innerText":case"textContent":break;default:(!(2<_.length)||_[0]!=="o"&&_[0]!=="O"||_[1]!=="n"&&_[1]!=="N")&&(_=qie.get(_)||_,Mt(h,_,N))}}function EA(h,g,_,N,P,F){switch(_){case"style":to(h,N,F);break;case"dangerouslySetInnerHTML":if(N!=null){if(typeof N!="object"||!("__html"in N))throw Error(r(61));if(_=N.__html,_!=null){if(P.children!=null)throw Error(r(60));h.innerHTML=_}}break;case"children":typeof N=="string"?vr(h,N):(typeof N=="number"||typeof N=="bigint")&&vr(h,""+N);break;case"onScroll":N!=null&&jn("scroll",h);break;case"onScrollEnd":N!=null&&jn("scrollend",h);break;case"onClick":N!=null&&(h.onclick=fc);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Ge.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 N=="function")){typeof F!="function"&&F!==null&&(_ in h?h[_]=null:h.hasAttribute(_)&&h.removeAttribute(_)),h.addEventListener(g,N,P);break e}_ in h?h[_]=N:N===!0?h.setAttribute(_,""):Mt(h,_,N)}}}function ha(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 N=!1,P=!1,F;for(F in _)if(_.hasOwnProperty(F)){var Q=_[F];if(Q!=null)switch(F){case"src":N=!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),N&&dr(h,g,"src",_.src,_,null);return;case"input":jn("invalid",h);var xe=F=Q=P=null,Re=null,at=null;for(N in _)if(_.hasOwnProperty(N)){var bt=_[N];if(bt!=null)switch(N){case"name":P=bt;break;case"type":Q=bt;break;case"checked":Re=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,N,bt,_,null)}}tr(h,F,xe,Re,at,Q,P,!1);return;case"select":jn("invalid",h),N=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":N=xe;default:dr(h,g,P,xe,_,null)}g=F,_=Q,h.multiple=!!N,g!=null?ki(h,!!N,g,!1):_!=null&&ki(h,!!N,_,!0);return;case"textarea":jn("invalid",h),F=P=N=null;for(Q in _)if(_.hasOwnProperty(Q)&&(xe=_[Q],xe!=null))switch(Q){case"value":N=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,N,P,F);return;case"option":for(Re in _)_.hasOwnProperty(Re)&&(N=_[Re],N!=null)&&(Re==="selected"?h.selected=N&&typeof N!="function"&&typeof N!="symbol":dr(h,g,Re,N,_,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(N=0;N<Xx.length;N++)jn(Xx[N],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)&&(N=_[at],N!=null))switch(at){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,g));default:dr(h,g,at,N,_,null)}return;default:if(jr(g)){for(bt in _)_.hasOwnProperty(bt)&&(N=_[bt],N!==void 0&&EA(h,g,bt,N,_,void 0));return}}for(xe in _)_.hasOwnProperty(xe)&&(N=_[xe],N!=null&&dr(h,g,xe,N,_,null))}function vse(h,g,_,N){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,Re=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":Re=_t;default:N.hasOwnProperty(ht)||dr(h,g,ht,null,N,_t)}}for(var ot in N){var ht=N[ot];if(_t=_[ot],N.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,N,_t)}}Xt(h,Q,xe,Re,at,bt,F,P);return;case"select":ht=Q=xe=ot=null;for(F in _)if(Re=_[F],_.hasOwnProperty(F)&&Re!=null)switch(F){case"value":break;case"multiple":ht=Re;default:N.hasOwnProperty(F)||dr(h,g,F,null,N,Re)}for(P in N)if(F=N[P],Re=_[P],N.hasOwnProperty(P)&&(F!=null||Re!=null))switch(P){case"value":ot=F;break;case"defaultValue":xe=F;break;case"multiple":Q=F;default:F!==Re&&dr(h,g,P,F,N,Re)}g=xe,_=Q,N=ht,ot!=null?ki(h,!!_,ot,!1):!!N!=!!_&&(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&&!N.hasOwnProperty(xe))switch(xe){case"value":break;case"children":break;default:dr(h,g,xe,null,N,P)}for(Q in N)if(P=N[Q],F=_[Q],N.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,N,F)}$n(h,ot,ht);return;case"option":for(var qt in _)ot=_[qt],_.hasOwnProperty(qt)&&ot!=null&&!N.hasOwnProperty(qt)&&(qt==="selected"?h.selected=!1:dr(h,g,qt,null,N,ot));for(Re in N)ot=N[Re],ht=_[Re],N.hasOwnProperty(Re)&&ot!==ht&&(ot!=null||ht!=null)&&(Re==="selected"?h.selected=ot&&typeof ot!="function"&&typeof ot!="symbol":dr(h,g,Re,ot,N,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&&!N.hasOwnProperty(an)&&dr(h,g,an,null,N,ot);for(at in N)if(ot=N[at],ht=_[at],N.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,N,ht)}return;default:if(jr(g)){for(var hr in _)ot=_[hr],_.hasOwnProperty(hr)&&ot!==void 0&&!N.hasOwnProperty(hr)&&EA(h,g,hr,void 0,N,ot);for(bt in N)ot=N[bt],ht=_[bt],!N.hasOwnProperty(bt)||ot===ht||ot===void 0&&ht===void 0||EA(h,g,bt,ot,N,ht);return}}for(var Ye in _)ot=_[Ye],_.hasOwnProperty(Ye)&&ot!=null&&!N.hasOwnProperty(Ye)&&dr(h,g,Ye,null,N,ot);for(_t in N)ot=N[_t],ht=_[_t],!N.hasOwnProperty(_t)||ot===ht||ot==null&&ht==null||dr(h,g,_t,ot,N,ht)}function bU(h){switch(h){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function _se(){if(typeof performance.getEntriesByType=="function"){for(var h=0,g=0,_=performance.getEntriesByType("resource"),N=0;N<_.length;N++){var P=_[N],F=P.transferSize,Q=P.initiatorType,xe=P.duration;if(F&&xe&&bU(Q)){for(Q=0,xe=P.responseEnd,N+=1;N<_.length;N++){var Re=_[N],at=Re.startTime;if(at>xe)break;var bt=Re.transferSize,_t=Re.initiatorType;bt&&bU(_t)&&(Re=Re.responseEnd,Q+=bt*(Re<xe?1:(xe-at)/(Re-at)))}if(--N,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 AA=null,TA=null;function Yv(h){return h.nodeType===9?h:h.ownerDocument}function yU(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 vU(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 CA(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 kA=null;function wse(){var h=window.event;return h&&h.type==="popstate"?h===kA?!1:(kA=h,!0):(kA=null,!1)}var _U=typeof setTimeout=="function"?setTimeout:void 0,Sse=typeof clearTimeout=="function"?clearTimeout:void 0,wU=typeof Promise=="function"?Promise:void 0,Mse=typeof queueMicrotask=="function"?queueMicrotask:typeof wU<"u"?function(h){return wU.resolve(null).then(h).catch(Nse)}:_U;function Nse(h){setTimeout(function(){throw h})}function qu(h){return h==="head"}function SU(h,g){var _=g,N=0;do{var P=_.nextSibling;if(h.removeChild(_),P&&P.nodeType===8)if(_=P.data,_==="/$"||_==="/&"){if(N===0){h.removeChild(P),Wm(g);return}N--}else if(_==="$"||_==="$?"||_==="$~"||_==="$!"||_==="&")N++;else if(_==="html")Qx(h.ownerDocument.documentElement);else if(_==="head"){_=h.ownerDocument.head,Qx(_);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"&&Qx(h.ownerDocument.body);_=P}while(_);Wm(g)}function MU(h,g){var _=h;h=0;do{var N=_.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||""),N&&N.nodeType===8)if(_=N.data,_==="/$"){if(h===0)break;h--}else _!=="$"&&_!=="$?"&&_!=="$~"&&_!=="$!"||h++;_=N}while(_)}function jA(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":jA(_),st(_);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(_.rel.toLowerCase()==="stylesheet")continue}h.removeChild(_)}}function Ese(h,g,_,N){for(;h.nodeType===1;){var P=_;if(h.nodeName.toLowerCase()!==g.toLowerCase()){if(!N&&(h.nodeName!=="INPUT"||h.type!=="hidden"))break}else if(N){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 Ase(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 NU(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 PA(h){return h.data==="$?"||h.data==="$~"}function RA(h){return h.data==="$!"||h.data==="$?"&&h.ownerDocument.readyState!=="loading"}function Tse(h,g){var _=h.ownerDocument;if(h.data==="$~")h._reactRetry=g;else if(h.data!=="$?"||_.readyState!=="loading")g();else{var N=function(){g(),_.removeEventListener("DOMContentLoaded",N)};_.addEventListener("DOMContentLoaded",N),h._reactRetry=N}}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 DA=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 AU(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 TU(h,g,_){switch(g=Yv(_),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 Qx(h){for(var g=h.attributes;g.length;)h.removeAttributeNode(g[0]);st(h)}var co=new Map,CU=new Set;function Qv(h){return typeof h.getRootNode=="function"?h.getRootNode():h.nodeType===9?h:h.ownerDocument}var Cc=G.d;G.d={f:Cse,r:kse,D:jse,C:Pse,L:Rse,m:Dse,X:Lse,S:Ose,M:Ise};function Cse(){var h=Cc.f(),g=$v();return h||g}function kse(h){var g=Bt(h);g!==null&&g.tag===5&&g.type==="form"?WF(g):Cc.r(h)}var Hm=typeof document>"u"?null:document;function kU(h,g,_){var N=Hm;if(N&&typeof g=="string"&&g){var P=yt(g);P='link[rel="'+h+'"][href="'+P+'"]',typeof _=="string"&&(P+='[crossorigin="'+_+'"]'),CU.has(P)||(CU.add(P),h={rel:h,crossOrigin:_,href:g},N.querySelector(P)===null&&(g=N.createElement("link"),ha(g,"link",h),de(g),N.head.appendChild(g)))}}function jse(h){Cc.D(h),kU("dns-prefetch",h,null)}function Pse(h,g){Cc.C(h,g),kU("preconnect",h,g)}function Rse(h,g,_){Cc.L(h,g,_);var N=Hm;if(N&&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=Vm(h);break;case"script":F=Gm(h)}co.has(F)||(h=f({rel:"preload",href:g==="image"&&_&&_.imageSrcSet?void 0:h,as:g},_),co.set(F,h),N.querySelector(P)!==null||g==="style"&&N.querySelector(Zx(F))||g==="script"&&N.querySelector(Jx(F))||(g=N.createElement("link"),ha(g,"link",h),de(g),N.head.appendChild(g)))}}function Dse(h,g){Cc.m(h,g);var _=Hm;if(_&&h){var N=g&&typeof g.as=="string"?g.as:"script",P='link[rel="modulepreload"][as="'+yt(N)+'"][href="'+yt(h)+'"]',F=P;switch(N){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":F=Gm(h)}if(!co.has(F)&&(h=f({rel:"modulepreload",href:h},g),co.set(F,h),_.querySelector(P)===null)){switch(N){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(_.querySelector(Jx(F)))return}N=_.createElement("link"),ha(N,"link",h),de(N),_.head.appendChild(N)}}}function Ose(h,g,_){Cc.S(h,g,_);var N=Hm;if(N&&h){var P=Jt(N).hoistableStyles,F=Vm(h);g=g||"default";var Q=P.get(F);if(!Q){var xe={loading:0,preload:null};if(Q=N.querySelector(Zx(F)))xe.loading=5;else{h=f({rel:"stylesheet",href:h,"data-precedence":g},_),(_=co.get(F))&&OA(h,_);var Re=Q=N.createElement("link");de(Re),ha(Re,"link",h),Re._p=new Promise(function(at,bt){Re.onload=at,Re.onerror=bt}),Re.addEventListener("load",function(){xe.loading|=1}),Re.addEventListener("error",function(){xe.loading|=2}),xe.loading|=4,Zv(Q,g,N)}Q={type:"stylesheet",instance:Q,count:1,state:xe},P.set(F,Q)}}}function Lse(h,g){Cc.X(h,g);var _=Hm;if(_&&h){var N=Jt(_).hoistableScripts,P=Gm(h),F=N.get(P);F||(F=_.querySelector(Jx(P)),F||(h=f({src:h,async:!0},g),(g=co.get(P))&&LA(h,g),F=_.createElement("script"),de(F),ha(F,"link",h),_.head.appendChild(F)),F={type:"script",instance:F,count:1,state:null},N.set(P,F))}}function Ise(h,g){Cc.M(h,g);var _=Hm;if(_&&h){var N=Jt(_).hoistableScripts,P=Gm(h),F=N.get(P);F||(F=_.querySelector(Jx(P)),F||(h=f({src:h,async:!0,type:"module"},g),(g=co.get(P))&&LA(h,g),F=_.createElement("script"),de(F),ha(F,"link",h),_.head.appendChild(F)),F={type:"script",instance:F,count:1,state:null},N.set(P,F))}}function jU(h,g,_,N){var P=(P=me.current)?Qv(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=Vm(_.href),_=Jt(P).hoistableStyles,N=_.get(g),N||(N={type:"style",instance:null,count:0,state:null},_.set(g,N)),N):{type:"void",instance:null,count:0,state:null};case"link":if(_.rel==="stylesheet"&&typeof _.href=="string"&&typeof _.precedence=="string"){h=Vm(_.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||Fse(P,h,_,Q.state))),g&&N===null)throw Error(r(528,""));return Q}if(g&&N!==null)throw Error(r(529,""));return null;case"script":return g=_.async,_=_.src,typeof _=="string"&&g&&typeof g!="function"&&typeof g!="symbol"?(g=Gm(_),_=Jt(P).hoistableScripts,N=_.get(g),N||(N={type:"script",instance:null,count:0,state:null},_.set(g,N)),N):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,h))}}function Vm(h){return'href="'+yt(h)+'"'}function Zx(h){return'link[rel="stylesheet"]['+h+"]"}function PU(h){return f({},h,{"data-precedence":h.precedence,precedence:null})}function Fse(h,g,_,N){h.querySelector('link[rel="preload"][as="style"]['+g+"]")?N.loading=1:(g=h.createElement("link"),N.preload=g,g.addEventListener("load",function(){return N.loading|=1}),g.addEventListener("error",function(){return N.loading|=2}),ha(g,"link",_),de(g),h.head.appendChild(g))}function Gm(h){return'[src="'+yt(h)+'"]'}function Jx(h){return"script[async]"+h}function RU(h,g,_){if(g.count++,g.instance===null)switch(g.type){case"style":var N=h.querySelector('style[data-href~="'+yt(_.href)+'"]');if(N)return g.instance=N,de(N),N;var P=f({},_,{"data-href":_.href,"data-precedence":_.precedence,href:null,precedence:null});return N=(h.ownerDocument||h).createElement("style"),de(N),ha(N,"style",P),Zv(N,_.precedence,h),g.instance=N;case"stylesheet":P=Vm(_.href);var F=h.querySelector(Zx(P));if(F)return g.state.loading|=4,g.instance=F,de(F),F;N=PU(_),(P=co.get(P))&&OA(N,P),F=(h.ownerDocument||h).createElement("link"),de(F);var Q=F;return Q._p=new Promise(function(xe,Re){Q.onload=xe,Q.onerror=Re}),ha(F,"link",N),g.state.loading|=4,Zv(F,_.precedence,h),g.instance=F;case"script":return F=Gm(_.src),(P=h.querySelector(Jx(F)))?(g.instance=P,de(P),P):(N=_,(P=co.get(F))&&(N=f({},_),LA(N,P)),h=h.ownerDocument||h,P=h.createElement("script"),de(P),ha(P,"link",N),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&&(N=g.instance,g.state.loading|=4,Zv(N,_.precedence,h));return g.instance}function Zv(h,g,_){for(var N=_.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),P=N.length?N[N.length-1]:null,F=P,Q=0;Q<N.length;Q++){var xe=N[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 OA(h,g){h.crossOrigin==null&&(h.crossOrigin=g.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=g.referrerPolicy),h.title==null&&(h.title=g.title)}function LA(h,g){h.crossOrigin==null&&(h.crossOrigin=g.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=g.referrerPolicy),h.integrity==null&&(h.integrity=g.integrity)}var Jv=null;function DU(h,g,_){if(Jv===null){var N=new Map,P=Jv=new Map;P.set(_,N)}else P=Jv,N=P.get(_),N||(N=new Map,P.set(_,N));if(N.has(h))return N;for(N.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=N.get(Q);xe?xe.push(F):N.set(Q,[F])}}return N}function OU(h,g,_){h=h.ownerDocument||h,h.head.insertBefore(_,g==="title"?h.querySelector("head > title"):null)}function Use(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 LU(h){return!(h.type==="stylesheet"&&(h.state.loading&3)===0)}function zse(h,g,_,N){if(_.type==="stylesheet"&&(typeof N.media!="string"||matchMedia(N.media).matches!==!1)&&(_.state.loading&4)===0){if(_.instance===null){var P=Vm(N.href),F=g.querySelector(Zx(P));if(F){g=F._p,g!==null&&typeof g=="object"&&typeof g.then=="function"&&(h.count++,h=e_.bind(h),g.then(h,h)),_.state.loading|=4,_.instance=F,de(F);return}F=g.ownerDocument||g,N=PU(N),(P=co.get(P))&&OA(N,P),F=F.createElement("link"),de(F);var Q=F;Q._p=new Promise(function(xe,Re){Q.onload=xe,Q.onerror=Re}),ha(F,"link",N),_.instance=F}h.stylesheets===null&&(h.stylesheets=new Map),h.stylesheets.set(_,g),(g=_.state.preload)&&(_.state.loading&3)===0&&(h.count++,_=e_.bind(h),g.addEventListener("load",_),g.addEventListener("error",_))}}var IA=0;function Bse(h,g){return h.stylesheets&&h.count===0&&n_(h,h.stylesheets),0<h.count||0<h.imgCount?function(_){var N=setTimeout(function(){if(h.stylesheets&&n_(h,h.stylesheets),h.unsuspend){var F=h.unsuspend;h.unsuspend=null,F()}},6e4+g);0<h.imgBytes&&IA===0&&(IA=62500*_se());var P=setTimeout(function(){if(h.waitingForImages=!1,h.count===0&&(h.stylesheets&&n_(h,h.stylesheets),h.unsuspend)){var F=h.unsuspend;h.unsuspend=null,F()}},(h.imgBytes>IA?50:800)+g);return h.unsuspend=_,function(){h.unsuspend=null,clearTimeout(N),clearTimeout(P)}}:null}function e_(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)n_(this,this.stylesheets);else if(this.unsuspend){var h=this.unsuspend;this.unsuspend=null,h()}}}var t_=null;function n_(h,g){h.stylesheets=null,h.unsuspend!==null&&(h.count++,t_=new Map,g.forEach($se,h),t_=null,e_.call(h))}function $se(h,g){if(!(g.state.loading&4)){var _=t_.get(h);if(_)var N=_.get(null);else{_=new Map,t_.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),N=Q)}N&&_.set(null,N)}P=g.instance,Q=P.getAttribute("data-precedence"),F=_.get(Q)||N,F===N&&_.set(null,P),_.set(Q,P),this.count++,N=e_.bind(this),P.addEventListener("load",N),P.addEventListener("error",N),F?F.parentNode.insertBefore(P,F.nextSibling):(h=h.nodeType===9?h.head:h,h.insertBefore(P,h.firstChild)),g.state.loading|=4}}var eb={$$typeof:M,Provider:null,Consumer:null,_currentValue:Z,_currentValue2:Z,_threadCount:0};function Hse(h,g,_,N,P,F,Q,xe,Re){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=N,this.onUncaughtError=P,this.onCaughtError=F,this.onRecoverableError=Q,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Re,this.incompleteTransitions=new Map}function IU(h,g,_,N,P,F,Q,xe,Re,at,bt,_t){return h=new Hse(h,g,_,Q,Re,at,bt,_t,xe),g=1,F===!0&&(g|=24),F=ks(3,null,null,g),h.current=F,F.stateNode=h,g=g2(),g.refCount++,h.pooledCache=g,g.refCount++,F.memoizedState={element:N,isDehydrated:_,cache:g},v2(F),h}function FU(h){return h?(h=wm,h):wm}function UU(h,g,_,N,P,F){P=FU(P),N.context===null?N.context=P:N.pendingContext=P,N=Lu(g),N.payload={element:_},F=F===void 0?null:F,F!==null&&(N.callback=F),_=Iu(h,N,g),_!==null&&(fs(_,h,g),Px(_,h,g))}function zU(h,g){if(h=h.memoizedState,h!==null&&h.dehydrated!==null){var _=h.retryLane;h.retryLane=_!==0&&_<g?_:g}}function FA(h,g){zU(h,g),(h=h.alternate)&&zU(h,g)}function BU(h){if(h.tag===13||h.tag===31){var g=Sh(h,67108864);g!==null&&fs(g,h,67108864),FA(h,67108864)}}function $U(h){if(h.tag===13||h.tag===31){var g=Os();g=sn(g);var _=Sh(h,g);_!==null&&fs(_,h,g),FA(h,g)}}var r_=!0;function Vse(h,g,_,N){var P=X.T;X.T=null;var F=G.p;try{G.p=2,UA(h,g,_,N)}finally{G.p=F,X.T=P}}function Gse(h,g,_,N){var P=X.T;X.T=null;var F=G.p;try{G.p=8,UA(h,g,_,N)}finally{G.p=F,X.T=P}}function UA(h,g,_,N){if(r_){var P=zA(N);if(P===null)NA(h,g,N,i_,_),VU(h,N);else if(qse(P,h,g,_,N))N.stopPropagation();else if(VU(h,N),g&4&&-1<Wse.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 Re=1<<31-ke(Q);xe.entanglements[1]|=Re,Q&=~Re}Sl(F),(Zn&6)===0&&(zv=L()+500,Kx(0))}}break;case 31:case 13:xe=Sh(F,2),xe!==null&&fs(xe,F,2),$v(),FA(F,2)}if(F=zA(N),F===null&&NA(h,g,N,i_,_),F===P)break;P=F}P!==null&&N.stopPropagation()}else NA(h,g,N,null,_)}}function zA(h){return h=$E(h),BA(h)}var i_=null;function BA(h){if(i_=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 i_=h,null}function HU(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 Se:return 8;case ae:case je:return 32;case De:return 268435456;default:return 32}default:return 32}}var $A=!1,Ku=null,Xu=null,Yu=null,tb=new Map,nb=new Map,Qu=[],Wse="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 VU(h,g){switch(h){case"focusin":case"focusout":Ku=null;break;case"dragenter":case"dragleave":Xu=null;break;case"mouseover":case"mouseout":Yu=null;break;case"pointerover":case"pointerout":tb.delete(g.pointerId);break;case"gotpointercapture":case"lostpointercapture":nb.delete(g.pointerId)}}function rb(h,g,_,N,P,F){return h===null||h.nativeEvent!==F?(h={blockedOn:g,domEventName:_,eventSystemFlags:N,nativeEvent:F,targetContainers:[P]},g!==null&&(g=Bt(g),g!==null&&BU(g)),h):(h.eventSystemFlags|=N,g=h.targetContainers,P!==null&&g.indexOf(P)===-1&&g.push(P),h)}function qse(h,g,_,N,P){switch(g){case"focusin":return Ku=rb(Ku,h,g,_,N,P),!0;case"dragenter":return Xu=rb(Xu,h,g,_,N,P),!0;case"mouseover":return Yu=rb(Yu,h,g,_,N,P),!0;case"pointerover":var F=P.pointerId;return tb.set(F,rb(tb.get(F)||null,h,g,_,N,P)),!0;case"gotpointercapture":return F=P.pointerId,nb.set(F,rb(nb.get(F)||null,h,g,_,N,P)),!0}return!1}function GU(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(){$U(_)});return}}else if(g===31){if(g=l(_),g!==null){h.blockedOn=g,Cr(h.priority,function(){$U(_)});return}}else if(g===3&&_.stateNode.current.memoizedState.isDehydrated){h.blockedOn=_.tag===3?_.stateNode.containerInfo:null;return}}}h.blockedOn=null}function a_(h){if(h.blockedOn!==null)return!1;for(var g=h.targetContainers;0<g.length;){var _=zA(h.nativeEvent);if(_===null){_=h.nativeEvent;var N=new _.constructor(_.type,_);BE=N,_.target.dispatchEvent(N),BE=null}else return g=Bt(_),g!==null&&BU(g),h.blockedOn=_,!1;g.shift()}return!0}function WU(h,g,_){a_(h)&&_.delete(g)}function Kse(){$A=!1,Ku!==null&&a_(Ku)&&(Ku=null),Xu!==null&&a_(Xu)&&(Xu=null),Yu!==null&&a_(Yu)&&(Yu=null),tb.forEach(WU),nb.forEach(WU)}function s_(h,g){h.blockedOn===g&&(h.blockedOn=null,$A||($A=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Kse)))}var o_=null;function qU(h){o_!==h&&(o_=h,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){o_===h&&(o_=null);for(var g=0;g<h.length;g+=3){var _=h[g],N=h[g+1],P=h[g+2];if(typeof N!="function"){if(BA(N||_)===null)continue;break}var F=Bt(_);F!==null&&(h.splice(g,3),g-=3,z2(F,{pending:!0,data:P,method:_.method,action:N},N,P))}}))}function Wm(h){function g(Re){return s_(Re,h)}Ku!==null&&s_(Ku,h),Xu!==null&&s_(Xu,h),Yu!==null&&s_(Yu,h),tb.forEach(g),nb.forEach(g);for(var _=0;_<Qu.length;_++){var N=Qu[_];N.blockedOn===h&&(N.blockedOn=null)}for(;0<Qu.length&&(_=Qu[0],_.blockedOn===null);)GU(_),_.blockedOn===null&&Qu.shift();if(_=(h.ownerDocument||h).$$reactFormReplay,_!=null)for(N=0;N<_.length;N+=3){var P=_[N],F=_[N+1],Q=P[yr]||null;if(typeof F=="function")Q||qU(_);else if(Q){var xe=null;if(F&&F.hasAttribute("formAction")){if(P=F,Q=F[yr]||null)xe=Q.formAction;else if(BA(P)!==null)continue}else xe=Q.action;typeof xe=="function"?_[N+1]=xe:(_.splice(N,3),N-=3),qU(_)}}}function KU(){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),N||setTimeout(_,20)}function _(){if(!N&&!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 N=!1,P=null;return navigation.addEventListener("navigate",h),navigation.addEventListener("navigatesuccess",g),navigation.addEventListener("navigateerror",g),setTimeout(_,100),function(){N=!0,navigation.removeEventListener("navigate",h),navigation.removeEventListener("navigatesuccess",g),navigation.removeEventListener("navigateerror",g),P!==null&&(P(),P=null)}}}function HA(h){this._internalRoot=h}l_.prototype.render=HA.prototype.render=function(h){var g=this._internalRoot;if(g===null)throw Error(r(409));var _=g.current,N=Os();UU(_,N,h,g,null,null)},l_.prototype.unmount=HA.prototype.unmount=function(){var h=this._internalRoot;if(h!==null){this._internalRoot=null;var g=h.containerInfo;UU(h.current,2,null,h,null,null),$v(),g[Ci]=null}};function l_(h){this._internalRoot=h}l_.prototype.unstable_scheduleHydration=function(h){if(h){var g=Cn();h={blockedOn:null,target:h,priority:g};for(var _=0;_<Qu.length&&g!==0&&g<Qu[_].priority;_++);Qu.splice(_,0,h),_===0&&GU(h)}};var XU=e.version;if(XU!=="19.2.3")throw Error(r(527,XU,"19.2.3"));G.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 Xse={bundleType:0,version:"19.2.3",rendererPackageName:"react-dom",currentDispatcherRef:X,reconcilerVersion:"19.2.3"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var c_=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!c_.isDisabled&&c_.supportsFiber)try{Qe=c_.inject(Xse),se=c_}catch{}}return ab.createRoot=function(h,g){if(!i(h))throw Error(r(299));var _=!1,N="",P=n5,F=r5,Q=i5;return g!=null&&(g.unstable_strictMode===!0&&(_=!0),g.identifierPrefix!==void 0&&(N=g.identifierPrefix),g.onUncaughtError!==void 0&&(P=g.onUncaughtError),g.onCaughtError!==void 0&&(F=g.onCaughtError),g.onRecoverableError!==void 0&&(Q=g.onRecoverableError)),g=IU(h,1,!1,null,null,_,N,null,P,F,Q,KU),h[Ci]=g.current,MA(h),new HA(g)},ab.hydrateRoot=function(h,g,_){if(!i(h))throw Error(r(299));var N=!1,P="",F=n5,Q=r5,xe=i5,Re=null;return _!=null&&(_.unstable_strictMode===!0&&(N=!0),_.identifierPrefix!==void 0&&(P=_.identifierPrefix),_.onUncaughtError!==void 0&&(F=_.onUncaughtError),_.onCaughtError!==void 0&&(Q=_.onCaughtError),_.onRecoverableError!==void 0&&(xe=_.onRecoverableError),_.formState!==void 0&&(Re=_.formState)),g=IU(h,1,!0,g,_??null,N,P,Re,F,Q,xe,KU),g.context=FU(null),_=g.current,N=Os(),N=sn(N),P=Lu(N),P.callback=null,Iu(_,P,N),_=N,g.current.lanes=_,on(g,_),Sl(g),h[Ci]=g.current,MA(h),new l_(g)},ab.version="19.2.3",ab}var az;function soe(){if(az)return WA.exports;az=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),WA.exports=aoe(),WA.exports}var ooe=soe();const dn=t=>typeof t=="string",sb=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},sz=t=>t==null?"":""+t,loe=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},coe=/###/g,oz=t=>t&&t.indexOf("###")>-1?t.replace(coe,"."):t,lz=t=>!t||dn(t),e0=(t,e,n)=>{const r=dn(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(lz(t))return{};const a=oz(r[i]);!t[a]&&n&&(t[a]=new n),Object.prototype.hasOwnProperty.call(t,a)?t=t[a]:t={},++i}return lz(t)?{}:{obj:t,k:oz(r[i])}},cz=(t,e,n)=>{const{obj:r,k:i}=e0(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=e0(t,o,Object);for(;l.obj===void 0&&o.length;)a=`${o[o.length-1]}.${a}`,o=o.slice(0,o.length-1),l=e0(t,o,Object),l?.obj&&typeof l.obj[`${l.k}.${a}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${a}`]=n},uoe=(t,e,n,r)=>{const{obj:i,k:a}=e0(t,e,Object);i[a]=i[a]||[],i[a].push(n)},Mw=(t,e)=>{const{obj:n,k:r}=e0(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},doe=(t,e,n)=>{const r=Mw(t,n);return r!==void 0?r:Mw(e,n)},xq=(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]):xq(t[r],e[r],n):t[r]=e[r]);return t},qm=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var hoe={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const foe=t=>dn(t)?t.replace(/[&<>"'\/]/g,e=>hoe[e]):t;class moe{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 poe=[" ",",","?","!",";"],goe=new moe(20),xoe=(t,e,n)=>{e=e||"",n=n||"";const r=poe.filter(o=>e.indexOf(o)<0&&n.indexOf(o)<0);if(r.length===0)return!0;const i=goe.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},Jj=(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},M0=t=>t?.replace("_","-"),boe={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 Nw{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||boe,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 Nw(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new Nw(this.logger,e)}}var Ul=new Nw;let YM=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 uz extends YM{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=Mw(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:Jj(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),cz(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=Mw(this.data,l)||{};o.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?xq(c,r,a):c={...c,...r},cz(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 bq={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 yq=Symbol("i18next/PATH_KEY");function yoe(){const t=[],e=Object.create(null);let n;return e.get=(r,i)=>(n?.revoke?.(),i===yq?t:(t.push(i),n=Proxy.revocable(r,e),n.proxy)),Proxy.revocable(Object.create(null),e).proxy}function eP(t,e){const{[yq]:n}=t(yoe());return n.join(e?.keySeparator??".")}const dz={},YA=t=>!dn(t)&&typeof t!="boolean"&&typeof t!="number";class Ew extends YM{constructor(e,n={}){super(),loe(["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=YA(i.res);return!(r.returnObjects===!1&&a)}extractFromKey(e,n){let r=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;r===void 0&&(r=":");const i=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let a=n.ns||this.options.defaultNS||[];const o=r&&e.indexOf(r)>-1,l=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!xoe(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=eP(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 y=p?.usedKey||l,x=p?.exactUsedKey||l,v=["[object Number]","[object Function]","[object RegExp]"],S=i.joinArrays!==void 0?i.joinArrays:this.options.joinArrays,M=!this.i18nFormat||this.i18nFormat.handleAsObject,E=i.count!==void 0&&!dn(i.count),A=Ew.hasDefaultValue(i),k=E?this.pluralResolver.getSuffix(f,i.count,i):"",T=i.ordinal&&E?this.pluralResolver.getSuffix(f,i.count,{ordinal:!1}):"",D=E&&!i.ordinal&&i.count===0,C=D&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${k}`]||i[`defaultValue${T}`]||i.defaultValue;let R=b;M&&!b&&A&&(R=C);const U=YA(R),O=Object.prototype.toString.apply(R);if(M&&R&&U&&v.indexOf(O)<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(y,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:y;for(const X in R)if(Object.prototype.hasOwnProperty.call(R,X)){const G=`${W}${o}${X}`;A&&!b?j[X]=this.translate(G,{...i,defaultValue:YA(C)?C[X]:void 0,joinArrays:!1,ns:c}):j[X]=this.translate(G,{...i,joinArrays:!1,ns:c}),j[X]===G&&(j[X]=R[X])}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=C),this.isValidLookup(b)||(j=!0,b=l);const X=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&j?void 0:b,G=A&&C!==b&&this.options.updateMissing;if(j||q||G){if(this.logger.log(G?"updateKey":"missingKey",f,u,l,G?C: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 Z=[];const te=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&te&&te[0])for(let z=0;z<te.length;z++)Z.push(te[z]);else this.options.saveMissingTo==="all"?Z=this.languageUtils.toResolveHierarchy(i.lng||this.language):Z.push(i.lng||this.language);const ee=(z,V,ne)=>{const ie=A&&ne!==b?ne:X;this.options.missingKeyHandler?this.options.missingKeyHandler(z,u,V,ie,G,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(z,u,V,ie,G,i),this.emit("missingKey",z,u,V,b)};this.options.saveMissing&&(this.options.saveMissingPlurals&&E?Z.forEach(z=>{const V=this.pluralResolver.getSuffixes(z,i);D&&i[`defaultValue${this.options.pluralSeparator}zero`]&&V.indexOf(`${this.options.pluralSeparator}zero`)<0&&V.push(`${this.options.pluralSeparator}zero`),V.forEach(ne=>{ee([z],l+ne,i[`defaultValue${ne}`]||C)})}):ee(Z,l,C))}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=bq.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!=="",y=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);f.forEach(x=>{this.isValidLookup(r)||(l=x,!dz[`${y[0]}-${x}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(l)&&(dz[`${y[0]}-${x}`]=!0,this.logger.warn(`key "${i}" for languages "${y.join(", ")}" won't get resolved as namespace "${l}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),y.forEach(v=>{if(this.isValidLookup(r))return;o=v;const S=[d];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(S,d,v,x,n);else{let E;m&&(E=this.pluralResolver.getSuffix(v,n.count,n));const A=`${this.options.pluralSeparator}zero`,k=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(m&&(n.ordinal&&E.indexOf(k)===0&&S.push(d+E.replace(k,this.options.pluralSeparator)),S.push(d+E),p&&S.push(d+A)),b){const T=`${d}${this.options.contextSeparator||"_"}${n.context}`;S.push(T),m&&(n.ordinal&&E.indexOf(k)===0&&S.push(T+E.replace(k,this.options.pluralSeparator)),S.push(T+E),p&&S.push(T+A))}}let M;for(;M=S.pop();)this.isValidLookup(r)||(a=M,r=this.getResource(v,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 hz{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Ul.create("languageUtils")}getScriptPartFromCode(e){if(e=M0(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=M0(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 fz={zero:0,one:1,two:2,few:3,many:4,other:5},mz={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class voe{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=Ul.create("pluralResolver"),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){const r=M0(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!"),mz;if(!e.match(/-|_/))return mz;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)=>fz[i]-fz[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 pz=(t,e,n,r=".",i=!0)=>{let a=doe(t,e,n);return!a&&i&&dn(n)&&(a=Jj(t,n,r),a===void 0&&(a=Jj(e,n,r))),a},QA=t=>t.replace(/\$/g,"$$$$");class gz{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:y,nestingOptionsSeparator:x,maxReplaces:v,alwaysFormat:S}=e.interpolation;this.escape=n!==void 0?n:foe,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=a?qm(a):o||"{{",this.suffix=l?qm(l):c||"}}",this.formatSeparator=u||",",this.unescapePrefix=d?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":d||"",this.nestingPrefix=m?qm(m):p||qm("$t("),this.nestingSuffix=b?qm(b):y||qm(")"),this.nestingOptionsSeparator=x||",",this.maxReplaces=v||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 v=pz(n,c,p,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(v,void 0,r,{...i,...n,interpolationkey:p}):v}const b=p.split(this.formatSeparator),y=b.shift().trim(),x=b.join(this.formatSeparator).trim();return this.format(pz(n,c,y,this.options.keySeparator,this.options.ignoreJSONStructure),x,r,{...i,...n,interpolationkey:y})};this.resetRegExp();const d=i?.missingInterpolationHandler||this.options.missingInterpolationHandler,f=i?.interpolation?.skipOnVariables!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:p=>QA(p)},{regex:this.regexp,safeValue:p=>this.escapeValue?QA(this.escape(p)):QA(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=sz(o));const y=p.safeValue(o);if(e=e.replace(a[0],y),f?(p.regex.lastIndex+=o.length,p.regex.lastIndex-=a[0].length):p.regex.lastIndex=0,l++,l>=this.maxReplaces)break}}),e}nest(e,n,r={}){let i,a,o;const l=(c,u)=>{const d=this.nestingOptionsSeparator;if(c.indexOf(d)<0)return c;const f=c.split(new RegExp(`${d}[ ]*{`));let 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(y){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,y),`${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=sz(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 _oe=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}},xz=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(M0(r),i),e[o]=l),l(n)}},woe=t=>(e,n,r)=>t(M0(n),r)(e);class Soe{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?xz:woe;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()]=xz(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}=_oe(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 Moe=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class Noe extends YM{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=>{uoe(c.loaded,[a],o),Moe(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}),bz=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),d_=()=>{},Eoe=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class t0 extends YM{constructor(e={},n){if(super(),this.options=bz(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,...bz(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=Soe;const d=new hz(this.options);this.store=new uz(this.options.resources,this.options);const f=this.services;f.logger=Ul,f.resourceStore=this.store,f.languageUtils=d,f.pluralResolver=new voe(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 gz(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new Noe(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=d_),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=sb(),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=d_){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=sb();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=d_),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"&&bq.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=sb();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=eP(f,{...this.options,...o})),`${c.keyPrefix}${u}${f}`)):(typeof a=="function"&&(a=eP(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=sb();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=sb();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 hz(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 t0(e,n);return r.createInstance=t0.createInstance,r}cloneInstance(e={},n=d_){const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},a=new t0(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 uz(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 gz(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 ss=t0.createInstance();ss.createInstance;ss.dir;ss.init;ss.loadResources;ss.reloadResources;ss.use;ss.changeLanguage;ss.getFixedT;ss.t;ss.exists;ss.setDefaultNamespace;ss.hasLoadedNamespace;ss.loadNamespaces;ss.loadLanguages;const Aoe=(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);Of(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),t?.services?.logger?.warn?t.services.logger.warn(...i):console?.warn&&console.warn(...i)},yz={},vq=(t,e,n,r)=>{Of(n)&&yz[n]||(Of(n)&&(yz[n]=new Date),Aoe(t,e,n,r))},_q=(t,e)=>()=>{if(t.isInitialized)e();else{const n=()=>{setTimeout(()=>{t.off("initialized",n)},0),e()};t.on("initialized",n)}},tP=(t,e,n)=>{t.loadNamespaces(e,_q(t,n))},vz=(t,e,n,r)=>{if(Of(n)&&(n=[n]),t.options.preload&&t.options.preload.indexOf(e)>-1)return tP(t,n,r);n.forEach(i=>{t.options.ns.indexOf(i)<0&&t.options.ns.push(i)}),t.loadLanguages(e,_q(t,r))},Toe=(t,e,n={})=>!e.languages||!e.languages.length?(vq(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}}),Of=t=>typeof t=="string",Coe=t=>typeof t=="object"&&t!==null,koe=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,joe={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},Poe=t=>joe[t],Roe=t=>t.replace(koe,Poe);let nP={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:Roe,transDefaultProps:void 0};const Doe=(t={})=>{nP={...nP,...t}},Ooe=()=>nP;let wq;const Loe=t=>{wq=t},Ioe=()=>wq,Foe={type:"3rdParty",init(t){Doe(t.options.react),Loe(t)}},Uoe=w.createContext();class zoe{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var JA={exports:{}},eT={};var _z;function Boe(){if(_z)return eT;_z=1;var t=Gg();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}}),y=b[0].inst,x=b[1];return a(function(){y.value=p,y.getSnapshot=m,c(y)&&x({inst:y})},[f,p,m]),i(function(){return c(y)&&x({inst:y}),f(function(){c(y)&&x({inst:y})})},[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 eT.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:d,eT}var wz;function Sq(){return wz||(wz=1,JA.exports=Boe()),JA.exports}var _D=Sq();const $oe=(t,e)=>Of(e)?e:Coe(e)&&Of(e.defaultValue)?e.defaultValue:Array.isArray(t)?t[t.length-1]:t,Hoe={t:$oe,ready:!1},Voe=()=>()=>{},Wg=(t,e={})=>{const{i18n:n}=e,{i18n:r,defaultNS:i}=w.useContext(Uoe)||{},a=n||r||Ioe();a&&!a.reportNamespaces&&(a.reportNamespaces=new zoe),a||vq(a,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const o=w.useMemo(()=>({...Ooe(),...a?.options?.react,...e}),[a,e]),{useSuspense:l,keyPrefix:c}=o,u=i||a?.options?.defaultNS,d=Of(u)?[u]:u||["translation"],f=w.useMemo(()=>d,d);a?.reportNamespaces?.addUsedNamespaces?.(f);const m=w.useRef(0),p=w.useCallback(C=>{if(!a)return Voe;const{bindI18n:R,bindI18nStore:U}=o,O=()=>{m.current+=1,C()};return R&&a.on(R,O),U&&a.store.on(U,O),()=>{R&&R.split(" ").forEach(q=>a.off(q,O)),U&&U.split(" ").forEach(q=>a.store.off(q,O))}},[a,o]),b=w.useRef(),y=w.useCallback(()=>{if(!a)return Hoe;const C=!!(a.isInitialized||a.initializedStoreOnce)&&f.every(W=>Toe(W,a,o)),R=e.lng||a.language,U=m.current,O=b.current;if(O&&O.ready===C&&O.lng===R&&O.keyPrefix===c&&O.revision===U)return O;const j={t:a.getFixedT(R,o.nsMode==="fallback"?f:f[0],c),ready:C,lng:R,keyPrefix:c,revision:U};return b.current=j,j},[a,f,c,o,e.lng]),[x,v]=w.useState(0),{t:S,ready:M}=_D.useSyncExternalStore(p,y,y);w.useEffect(()=>{if(a&&!M&&!l){const C=()=>v(R=>R+1);e.lng?vz(a,e.lng,f,C):tP(a,f,C)}},[a,e.lng,f,M,l,x]);const E=a||{},A=w.useRef(null),k=w.useRef(),T=C=>{const R=Object.getOwnPropertyDescriptors(C);R.__original&&delete R.__original;const U=Object.create(Object.getPrototypeOf(C),R);if(!Object.prototype.hasOwnProperty.call(U,"__original"))try{Object.defineProperty(U,"__original",{value:C,writable:!1,enumerable:!1,configurable:!1})}catch{}return U},D=w.useMemo(()=>{const C=E,R=C?.language;let U=C;C&&(A.current&&A.current.__original===C?k.current!==R?(U=T(C),A.current=U,k.current=R):U=A.current:(U=T(C),A.current=U,k.current=R));const O=[S,U,M];return O.t=S,O.i18n=U,O.ready=M,O},[S,E,M,E.resolvedLanguage,E.language,E.languages]);if(a&&l&&!M)throw new Promise(C=>{const R=()=>C();e.lng?vz(a,e.lng,f,R):tP(a,f,R)});return D},{slice:Goe,forEach:Woe}=[];function qoe(t){return Woe.call(Goe.call(arguments,1),e=>{if(e)for(const n in e)t[n]===void 0&&(t[n]=e[n])}),t}function Koe(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 Sz=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,Xoe=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(!Sz.test(r.domain))throw new TypeError("option domain is invalid");a+=`; Domain=${r.domain}`}if(r.path){if(!Sz.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},Mz={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=Xoe(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 Yoe={name:"cookie",lookup(t){let{lookupCookie:e}=t;if(e&&typeof document<"u")return Mz.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:n,cookieMinutes:r,cookieDomain:i,cookieOptions:a}=e;n&&typeof document<"u"&&Mz.create(n,t,r,i,a)}},Qoe={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 Km=null;const Nz=()=>{if(Km!==null)return Km;try{if(Km=typeof window<"u"&&window.localStorage!==null,!Km)return!1;const t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{Km=!1}return Km};var Joe={name:"localStorage",lookup(t){let{lookupLocalStorage:e}=t;if(e&&Nz())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:n}=e;n&&Nz()&&window.localStorage.setItem(n,t)}};let Xm=null;const Ez=()=>{if(Xm!==null)return Xm;try{if(Xm=typeof window<"u"&&window.sessionStorage!==null,!Xm)return!1;const t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{Xm=!1}return Xm};var ele={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)}},tle={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}},nle={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}},rle={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}},ile={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 Mq=!1;try{document.cookie,Mq=!0}catch{}const Nq=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];Mq||Nq.splice(1,1);const ale=()=>({order:Nq,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=qoe(n,this.options||{},ale()),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(Yoe),this.addDetector(Qoe),this.addDetector(Joe),this.addDetector(ele),this.addDetector(tle),this.addDetector(nle),this.addDetector(rle),this.addDetector(ile),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&&!Koe(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 sle={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?"}},ole={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?"}},lle={en:{translation:sle},de:{translation:ole}};ss.use(Eq).use(Foe).init({resources:lle,fallbackLng:"en",supportedLngs:["en","de"],detection:{order:["localStorage","navigator","htmlTag"],lookupLocalStorage:"bambutrack_language",caches:["localStorage"]},interpolation:{escapeValue:!1},react:{useSuspense:!1}});const Az=[{code:"en",name:"English",nativeName:"English"},{code:"de",name:"German",nativeName:"Deutsch"}];var Tz="popstate";function cle(t={}){function e(r,i){let{pathname:a,search:o,hash:l}=r.location;return rP("",{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:N0(i)}return dle(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 ule(){return Math.random().toString(36).substring(2,10)}function Cz(t,e){return{usr:t.state,key:t.key,idx:e}}function rP(t,e,n=null,r){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof e=="string"?qg(e):e,state:n,key:e&&e.key||r||ule()}}function N0({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 qg(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 dle(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(),v=x==null?null:x-u;u=x,c&&c({action:l,location:y.location,delta:v})}function m(x,v){l="PUSH";let S=rP(y.location,x,v);u=d()+1;let M=Cz(S,u),E=y.createHref(S);try{o.pushState(M,"",E)}catch(A){if(A instanceof DOMException&&A.name==="DataCloneError")throw A;i.location.assign(E)}a&&c&&c({action:l,location:y.location,delta:1})}function p(x,v){l="REPLACE";let S=rP(y.location,x,v);u=d();let M=Cz(S,u),E=y.createHref(S);o.replaceState(M,"",E),a&&c&&c({action:l,location:y.location,delta:0})}function b(x){return hle(x)}let y={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(Tz,f),c=x,()=>{i.removeEventListener(Tz,f),c=null}},createHref(x){return e(i,x)},createURL:b,encodeLocation(x){let v=b(x);return{pathname:v.pathname,search:v.search,hash:v.hash}},push:m,replace:p,go(x){return o.go(x)}};return y}function hle(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:N0(t);return r=r.replace(/ $/,"%20"),!e&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function Aq(t,e,n="/"){return fle(t,e,n,!1)}function fle(t,e,n,r){let i=typeof e=="string"?qg(e):e,a=du(i.pathname||"/",n);if(a==null)return null;let o=Tq(t);mle(o);let l=null;for(let c=0;l==null&&c<o.length;++c){let u=Nle(a);l=Sle(o[c],u,r)}return l}function Tq(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=ru([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}".`),Tq(o.children,e,m,f,c)),!(o.path==null&&!o.index)&&e.push({path:f,score:_le(f,o.index),routesMeta:m})};return t.forEach((o,l)=>{if(o.path===""||!o.path?.includes("?"))a(o,l);else for(let c of Cq(o.path))a(o,l,!0,c)}),e}function Cq(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=Cq(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 mle(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:wle(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var ple=/^:[\w-]+$/,gle=3,xle=2,ble=1,yle=10,vle=-2,kz=t=>t==="*";function _le(t,e){let n=t.split("/"),r=n.length;return n.some(kz)&&(r+=vle),e&&(r+=xle),n.filter(i=>!kz(i)).reduce((i,a)=>i+(ple.test(a)?gle:a===""?ble:yle),r)}function wle(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 Sle(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=Aw({path:c.relativePath,caseSensitive:c.caseSensitive,end:u},d),m=c.route;if(!f&&u&&n&&!r[r.length-1].route.index&&(f=Aw({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},d)),!f)return null;Object.assign(i,f.params),o.push({params:i,pathname:ru([a,f.pathname]),pathnameBase:Cle(ru([a,f.pathnameBase])),route:m}),f.pathnameBase!=="/"&&(a=ru([a,f.pathnameBase]))}return o}function Aw(t,e){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,r]=Mle(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 Mle(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 Nle(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 du(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 Ale(t,e="/"){let{pathname:n,search:r="",hash:i=""}=typeof t=="string"?qg(t):t,a;return n?(n=n.replace(/\/\/+/g,"/"),n.startsWith("/")?a=jz(n.substring(1),"/"):a=jz(n,e)):a=e,{pathname:a,search:kle(r),hash:jle(i)}}function jz(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 tT(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 Tle(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function wD(t){let e=Tle(t);return e.map((n,r)=>r===e.length-1?n.pathname:n.pathnameBase)}function SD(t,e,n,r=!1){let i;typeof t=="string"?i=qg(t):(i={...t},Br(!i.pathname||!i.pathname.includes("?"),tT("?","pathname","search",i)),Br(!i.pathname||!i.pathname.includes("#"),tT("#","pathname","hash",i)),Br(!i.search||!i.search.includes("#"),tT("#","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=Ale(i,l),u=o&&o!=="/"&&o.endsWith("/"),d=(a||o===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}var ru=t=>t.join("/").replace(/\/\/+/g,"/"),Cle=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),kle=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,jle=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t,Ple=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 Rle(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}function Dle(t){return t.map(e=>e.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var kq=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function jq(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(kq)try{let a=new URL(window.location.href),o=n.startsWith("//")?new URL(a.protocol+n):new URL(n),l=du(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 Pq=["POST","PUT","PATCH","DELETE"];new Set(Pq);var Ole=["GET",...Pq];new Set(Ole);var Kg=w.createContext(null);Kg.displayName="DataRouter";var QM=w.createContext(null);QM.displayName="DataRouterState";var Lle=w.createContext(!1),Rq=w.createContext({isTransitioning:!1});Rq.displayName="ViewTransition";var Ile=w.createContext(new Map);Ile.displayName="Fetchers";var Fle=w.createContext(null);Fle.displayName="Await";var eo=w.createContext(null);eo.displayName="Navigation";var xy=w.createContext(null);xy.displayName="Location";var Uo=w.createContext({outlet:null,matches:[],isDataRoute:!1});Uo.displayName="Route";var MD=w.createContext(null);MD.displayName="RouteError";var Dq="REACT_ROUTER_ERROR",Ule="REDIRECT",zle="ROUTE_ERROR_RESPONSE";function Ble(t){if(t.startsWith(`${Dq}:${Ule}:{`))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 $le(t){if(t.startsWith(`${Dq}:${zle}:{`))try{let e=JSON.parse(t.slice(40));if(typeof e=="object"&&e&&typeof e.status=="number"&&typeof e.statusText=="string")return new Ple(e.status,e.statusText,e.data)}catch{}}function Hle(t,{relative:e}={}){Br(Xg(),"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}=by(t,{relative:e}),l=a;return n!=="/"&&(l=a==="/"?n:ru([n,a])),r.createHref({pathname:l,search:o,hash:i})}function Xg(){return w.useContext(xy)!=null}function lc(){return Br(Xg(),"useLocation() may be used only in the context of a <Router> component."),w.useContext(xy).location}var Oq="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Lq(t){w.useContext(eo).static||w.useLayoutEffect(t)}function pl(){let{isDataRoute:t}=w.useContext(Uo);return t?ice():Vle()}function Vle(){Br(Xg(),"useNavigate() may be used only in the context of a <Router> component.");let t=w.useContext(Kg),{basename:e,navigator:n}=w.useContext(eo),{matches:r}=w.useContext(Uo),{pathname:i}=lc(),a=JSON.stringify(wD(r)),o=w.useRef(!1);return Lq(()=>{o.current=!0}),w.useCallback((c,u={})=>{if(Ro(o.current,Oq),!o.current)return;if(typeof c=="number"){n.go(c);return}let d=SD(c,JSON.parse(a),i,u.relative==="path");t==null&&e!=="/"&&(d.pathname=d.pathname==="/"?e:ru([e,d.pathname])),(u.replace?n.replace:n.push)(d,u.state,u)},[e,n,a,i,t])}var Gle=w.createContext(null);function Wle(t){let e=w.useContext(Uo).outlet;return w.useMemo(()=>e&&w.createElement(Gle.Provider,{value:t},e),[e,t])}function ND(){let{matches:t}=w.useContext(Uo),e=t[t.length-1];return e?e.params:{}}function by(t,{relative:e}={}){let{matches:n}=w.useContext(Uo),{pathname:r}=lc(),i=JSON.stringify(wD(n));return w.useMemo(()=>SD(t,JSON.parse(i),r,e==="path"),[t,i,r,e])}function qle(t,e){return Iq(t,e)}function Iq(t,e,n,r,i){Br(Xg(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:a}=w.useContext(eo),{matches:o}=w.useContext(Uo),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||"";Uq(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.
- Please change the parent <Route path="${S}"> to <Route path="${S==="/"?"*":`${S}/*`}">.`)}let m=lc(),p;if(e){let S=typeof e=="string"?qg(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||"/",y=b;if(d!=="/"){let S=d.replace(/^\//,"").split("/");y="/"+b.replace(/^\//,"").split("/").slice(S.length).join("/")}let x=Aq(t,{pathname:y});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 v=Zle(x&&x.map(S=>Object.assign({},S,{params:Object.assign({},c,S.params),pathname:ru([d,a.encodeLocation?a.encodeLocation(S.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:S.pathname]),pathnameBase:S.pathnameBase==="/"?d:ru([d,a.encodeLocation?a.encodeLocation(S.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:S.pathnameBase])})),o,n,r,i);return e&&v?w.createElement(xy.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...p},navigationType:"POP"}},v):v}function Kle(){let t=rce(),e=Rle(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 Xle=w.createElement(Kle,null),Fq=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=$le(t.digest);n&&(t=n)}let e=t!==void 0?w.createElement(Uo.Provider,{value:this.props.routeContext},w.createElement(MD.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?w.createElement(Yle,{error:t},e):e}};Fq.contextType=Lle;var nT=new WeakMap;function Yle({children:t,error:e}){let{basename:n}=w.useContext(eo);if(typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){let r=Ble(e.digest);if(r){let i=nT.get(e);if(i)throw i;let a=jq(r.location,n);if(kq&&!nT.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 nT.set(e,o),o}return w.createElement("meta",{httpEquiv:"refresh",content:`0;url=${a.absoluteURL||a.to}`})}}return t}function Qle({routeContext:t,match:e,children:n}){let r=w.useContext(Kg);return r&&r.static&&r.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=e.route.id),w.createElement(Uo.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:Dle(n.matches),errorInfo:f})}:void 0;return a.reduceRight((d,f,m)=>{let p,b=!1,y=null,x=null;n&&(p=o&&f.route.id?o[f.route.id]:void 0,y=f.route.errorElement||Xle,l&&(c<0&&m===0?(Uq("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 v=e.concat(a.slice(0,m+1)),S=()=>{let M;return p?M=y:b?M=x:f.route.Component?M=w.createElement(f.route.Component,null):f.route.element?M=f.route.element:M=d,w.createElement(Qle,{match:f,routeContext:{outlet:d,matches:v,isDataRoute:n!=null},children:M})};return n&&(f.route.ErrorBoundary||f.route.errorElement||m===0)?w.createElement(Fq,{location:n.location,revalidation:n.revalidation,component:y,error:p,children:S(),routeContext:{outlet:null,matches:v,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 Jle(t){let e=w.useContext(Kg);return Br(e,ED(t)),e}function ece(t){let e=w.useContext(QM);return Br(e,ED(t)),e}function tce(t){let e=w.useContext(Uo);return Br(e,ED(t)),e}function AD(t){let e=tce(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 nce(){return AD("useRouteId")}function rce(){let t=w.useContext(MD),e=ece("useRouteError"),n=AD("useRouteError");return t!==void 0?t:e.errors?.[n]}function ice(){let{router:t}=Jle("useNavigate"),e=AD("useNavigate"),n=w.useRef(!1);return Lq(()=>{n.current=!0}),w.useCallback(async(i,a={})=>{Ro(n.current,Oq),n.current&&(typeof i=="number"?await t.navigate(i):await t.navigate(i,{fromRouteId:e,...a}))},[t,e])}var Pz={};function Uq(t,e,n){!e&&!Pz[t]&&(Pz[t]=!0,Ro(!1,n))}w.memo(ace);function ace({routes:t,future:e,state:n,onError:r}){return Iq(t,void 0,n,r,e)}function Tw({to:t,replace:e,state:n,relative:r}){Br(Xg(),"<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(Uo),{pathname:o}=lc(),l=pl(),c=SD(t,wD(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 sce(t){return Wle(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 oce({basename:t="/",children:e=null,location:n,navigationType:r="POP",navigator:i,static:a=!1,unstable_useTransitions:o}){Br(!Xg(),"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=qg(n));let{pathname:u="/",search:d="",hash:f="",state:m=null,key:p="default"}=n,b=w.useMemo(()=>{let y=du(u,l);return y==null?null:{location:{pathname:y,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(xy.Provider,{children:e,value:b}))}function lce({children:t,location:e}){return qle(iP(t),e)}function iP(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,iP(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=iP(r.props.children,a)),n.push(o)}),n}var Y1="get",Q1="application/x-www-form-urlencoded";function ZM(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function cce(t){return ZM(t)&&t.tagName.toLowerCase()==="button"}function uce(t){return ZM(t)&&t.tagName.toLowerCase()==="form"}function dce(t){return ZM(t)&&t.tagName.toLowerCase()==="input"}function hce(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function fce(t,e){return t.button===0&&(!e||e==="_self")&&!hce(t)}function aP(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 mce(t,e){let n=aP(t);return e&&e.forEach((r,i)=>{n.has(i)||e.getAll(i).forEach(a=>{n.append(i,a)})}),n}var h_=null;function pce(){if(h_===null)try{new FormData(document.createElement("form"),0),h_=!1}catch{h_=!0}return h_}var gce=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function rT(t){return t!=null&&!gce.has(t)?(Ro(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Q1}"`),null):t}function xce(t,e){let n,r,i,a,o;if(uce(t)){let l=t.getAttribute("action");r=l?du(l,e):null,n=t.getAttribute("method")||Y1,i=rT(t.getAttribute("enctype"))||Q1,a=new FormData(t)}else if(cce(t)||dce(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?du(c,e):null,n=t.getAttribute("formmethod")||l.getAttribute("method")||Y1,i=rT(t.getAttribute("formenctype"))||rT(l.getAttribute("enctype"))||Q1,a=new FormData(l,t),!pce()){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=Y1,r=null,i=Q1,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 TD(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function bce(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&&du(i.pathname,e)==="/"?i.pathname=`${e.replace(/\/$/,"")}/_root.${r}`:i.pathname=`${i.pathname.replace(/\/$/,"")}.${r}`,i}async function yce(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 vce(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 _ce(t,e,n){let r=await Promise.all(t.map(async i=>{let a=e.routes[i.route.id];if(a){let o=await yce(a,n);return o.links?o.links():[]}return[]}));return Nce(r.flat(1).filter(vce).filter(i=>i.rel==="stylesheet"||i.rel==="preload").map(i=>i.rel==="stylesheet"?{...i,rel:"prefetch",as:"style"}:{...i,rel:"prefetch"}))}function Rz(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 wce(t,e,{includeHydrateFallback:n}={}){return Sce(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 Sce(t){return[...new Set(t)]}function Mce(t){let e={},n=Object.keys(t).sort();for(let r of n)e[r]=t[r];return e}function Nce(t,e){let n=new Set;return new Set(e),t.reduce((r,i)=>{let a=JSON.stringify(Mce(i));return n.has(a)||(n.add(a),r.push({key:a,link:i})),r},[])}function zq(){let t=w.useContext(Kg);return TD(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function Ece(){let t=w.useContext(QM);return TD(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var CD=w.createContext(void 0);CD.displayName="FrameworkContext";function Bq(){let t=w.useContext(CD);return TD(t,"You must render this element inside a <HydratedRouter> element"),t}function Ace(t,e){let n=w.useContext(CD),[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 y=v=>{v.forEach(S=>{o(S.isIntersecting)})},x=new IntersectionObserver(y,{threshold:.5});return m.current&&x.observe(m.current),()=>{x.disconnect()}}},[t]),w.useEffect(()=>{if(r){let y=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(y)}}},[r]);let p=()=>{i(!0)},b=()=>{i(!1),o(!1)};return n?t!=="intent"?[a,m,{}]:[a,m,{onFocus:ob(l,p),onBlur:ob(c,b),onMouseEnter:ob(u,p),onMouseLeave:ob(d,b),onTouchStart:ob(f,p)}]:[!1,m,{}]}function ob(t,e){return n=>{t&&t(n),n.defaultPrevented||e(n)}}function Tce({page:t,...e}){let{router:n}=zq(),r=w.useMemo(()=>Aq(n.routes,t,n.basename),[n.routes,t,n.basename]);return r?w.createElement(kce,{page:t,matches:r,...e}):null}function Cce(t){let{manifest:e,routeModules:n}=Bq(),[r,i]=w.useState([]);return w.useEffect(()=>{let a=!1;return _ce(t,e,n).then(o=>{a||i(o)}),()=>{a=!0}},[t,e,n]),r}function kce({page:t,matches:e,...n}){let r=lc(),{future:i,manifest:a,routeModules:o}=Bq(),{basename:l}=zq(),{loaderData:c,matches:u}=Ece(),d=w.useMemo(()=>Rz(t,e,u,a,r,"data"),[t,e,u,a,r]),f=w.useMemo(()=>Rz(t,e,u,a,r,"assets"),[t,e,u,a,r]),m=w.useMemo(()=>{if(t===r.pathname+r.search+r.hash)return[];let y=new Set,x=!1;if(e.forEach(S=>{let M=a.routes[S.route.id];!M||!M.hasLoader||(!d.some(E=>E.route.id===S.route.id)&&S.route.id in c&&o[S.route.id]?.shouldRevalidate||M.hasClientLoader?x=!0:y.add(S.route.id))}),y.size===0)return[];let v=bce(t,l,i.unstable_trailingSlashAwareDataRequests,"data");return x&&y.size>0&&v.searchParams.set("_routes",e.filter(S=>y.has(S.route.id)).map(S=>S.route.id).join(",")),[v.pathname+v.search]},[l,i.unstable_trailingSlashAwareDataRequests,c,r,a,d,e,t,o]),p=w.useMemo(()=>wce(f,a),[f,a]),b=Cce(f);return w.createElement(w.Fragment,null,m.map(y=>w.createElement("link",{key:y,rel:"prefetch",as:"fetch",href:y,...n})),p.map(y=>w.createElement("link",{key:y,rel:"modulepreload",href:y,...n})),b.map(({key:y,link:x})=>w.createElement("link",{key:y,nonce:n.nonce,...x,crossOrigin:x.crossOrigin??n.crossOrigin})))}function jce(...t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}var Pce=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Pce&&(window.__reactRouterVersion="7.13.0")}catch{}function Rce({basename:t,children:e,unstable_useTransitions:n,window:r}){let i=w.useRef();i.current==null&&(i.current=cle({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(oce,{basename:t,children:e,location:o.location,navigationType:o.action,navigator:a,unstable_useTransitions:n})}var $q=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,gs=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:y,unstable_useTransitions:x}=w.useContext(eo),v=typeof u=="string"&&$q.test(u),S=jq(u,y);u=S.to;let M=Hle(u,{relative:i}),[E,A,k]=Ace(r,p),T=Lce(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||T(R)}let C=w.createElement("a",{...p,...k,href:S.absoluteURL||M,onClick:S.isExternal||a?e:D,ref:jce(b,A),target:c,"data-discover":!v&&n==="render"?"true":void 0});return E&&!v?w.createElement(w.Fragment,null,C,w.createElement(Tce,{page:M})):C});gs.displayName="Link";var Lb=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=by(o,{relative:u.relative}),m=lc(),p=w.useContext(QM),{navigator:b,basename:y}=w.useContext(eo),x=p!=null&&Bce(f)&&l===!0,v=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,v=v.toLowerCase()),M&&y&&(M=du(M,y)||M);const E=v!=="/"&&v.endsWith("/")?v.length-1:v.length;let A=S===v||!i&&S.startsWith(v)&&S.charAt(E)==="/",k=M!=null&&(M===v||!i&&M.startsWith(v)&&M.charAt(v.length)==="/"),T={isActive:A,isPending:k,isTransitioning:x},D=A?e:void 0,C;typeof r=="function"?C=r(T):C=[r,A?"active":null,k?"pending":null,x?"transitioning":null].filter(Boolean).join(" ");let R=typeof a=="function"?a(T):a;return w.createElement(gs,{...u,"aria-current":D,className:C,ref:d,style:R,to:o,viewTransition:l},typeof c=="function"?c(T):c)});Lb.displayName="NavLink";var Dce=w.forwardRef(({discover:t="render",fetcherKey:e,navigate:n,reloadDocument:r,replace:i,state:a,method:o=Y1,action:l,onSubmit:c,relative:u,preventScrollReset:d,viewTransition:f,unstable_defaultShouldRevalidate:m,...p},b)=>{let{unstable_useTransitions:y}=w.useContext(eo),x=Uce(),v=zce(l,{relative:u}),S=o.toLowerCase()==="get"?"get":"post",M=typeof l=="string"&&$q.test(l),E=A=>{if(c&&c(A),A.defaultPrevented)return;A.preventDefault();let k=A.nativeEvent.submitter,T=k?.getAttribute("formmethod")||o,D=()=>x(k||A.currentTarget,{fetcherKey:e,method:T,navigate:n,replace:i,state:a,relative:u,preventScrollReset:d,viewTransition:f,unstable_defaultShouldRevalidate:m});y&&n!==!1?w.startTransition(()=>D()):D()};return w.createElement("form",{ref:b,method:S,action:v,onSubmit:r?c:E,...p,"data-discover":!M&&t==="render"?"true":void 0})});Dce.displayName="Form";function Oce(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Hq(t){let e=w.useContext(Kg);return Br(e,Oce(t)),e}function Lce(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=by(t,{relative:a});return w.useCallback(m=>{if(fce(m,e)){m.preventDefault();let p=n!==void 0?n:N0(d)===N0(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 Vq(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(aP(t)),n=w.useRef(!1),r=lc(),i=w.useMemo(()=>mce(r.search,n.current?null:e.current),[r.search]),a=pl(),o=w.useCallback((l,c)=>{const u=aP(typeof l=="function"?l(new URLSearchParams(i)):l);n.current=!0,a("?"+u,c)},[a,i]);return[i,o]}var Ice=0,Fce=()=>`__${String(++Ice)}__`;function Uce(){let{router:t}=Hq("useSubmit"),{basename:e}=w.useContext(eo),n=nce(),r=t.fetch,i=t.navigate;return w.useCallback(async(a,o={})=>{let{action:l,method:c,encType:u,formData:d,body:f}=xce(a,e);if(o.navigate===!1){let m=o.fetcherKey||Fce();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 zce(t,{relative:e}={}){let{basename:n}=w.useContext(eo),r=w.useContext(Uo);Br(r,"useFormAction must be used inside a RouteContext");let[i]=r.matches.slice(-1),a={...by(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:ru([n,a.pathname])),N0(a)}function Bce(t,{relative:e}={}){let n=w.useContext(Rq);Br(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=Hq("useViewTransitionState"),i=by(t,{relative:e});if(!n.isTransitioning)return!1;let a=du(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=du(n.nextLocation.pathname,r)||n.nextLocation.pathname;return Aw(i.pathname,o)!=null||Aw(i.pathname,a)!=null}var Qc=gq();const $ce=ml(Qc);var lm=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(){}},Hce={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},Vce=class{#t=Hce;#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)}},lf=new Vce;function Gce(t){setTimeout(t,0)}var Lf=typeof window>"u"||"Deno"in globalThis;function Ia(){}function Wce(t,e){return typeof t=="function"?t(e):t}function sP(t){return typeof t=="number"&&t>=0&&t!==1/0}function Gq(t,e){return Math.max(t+(e||0)-Date.now(),0)}function Ld(t,e){return typeof t=="function"?t(e):t}function yo(t,e){return typeof t=="function"?t(e):t}function Dz(t,e){const{type:n="all",exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:l}=t;if(o){if(r){if(e.queryHash!==kD(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 Oz(t,e){const{exact:n,status:r,predicate:i,mutationKey:a}=t;if(a){if(!e.options.mutationKey)return!1;if(n){if(If(e.options.mutationKey)!==If(a))return!1}else if(!E0(e.options.mutationKey,a))return!1}return!(r&&e.state.status!==r||i&&!i(e))}function kD(t,e){return(e?.queryKeyHashFn||If)(t)}function If(t){return JSON.stringify(t,(e,n)=>oP(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 qce=Object.prototype.hasOwnProperty;function jD(t,e,n=0){if(t===e)return t;if(n>500)return e;const r=Lz(t)&&Lz(e);if(!r&&!(oP(t)&&oP(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:qce.call(t,f))&&u++;continue}if(m===null||p===null||typeof m!="object"||typeof p!="object"){c[f]=p;continue}const b=jD(m,p,n+1);c[f]=b,b===m&&u++}return a===l&&u===a?t:c}function A0(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 Lz(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function oP(t){if(!Iz(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!Iz(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function Iz(t){return Object.prototype.toString.call(t)==="[object Object]"}function Kce(t){return new Promise(e=>{lf.setTimeout(e,t)})}function lP(t,e,n){return typeof n.structuralSharing=="function"?n.structuralSharing(t,e):n.structuralSharing!==!1?jD(t,e):e}function Xce(t,e,n=0){const r=[...t,e];return n&&r.length>n?r.slice(1):r}function Yce(t,e,n=0){const r=[e,...t];return n&&r.length>n?r.slice(0,-1):r}var PD=Symbol();function Wq(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===PD?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function RD(t,e){return typeof t=="function"?t(...e):!!t}function Qce(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 lm{#t;#e;#n;constructor(){super(),this.#n=t=>{if(!Lf&&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"}},DD=new Zce;function cP(){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 Jce=Gce;function eue(){let t=[],e=0,n=l=>{l()},r=l=>{l()},i=Jce;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=eue(),tue=class extends lm{#t=!0;#e;#n;constructor(){super(),this.#n=t=>{if(!Lf&&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}},Cw=new tue;function nue(t){return Math.min(1e3*2**t,3e4)}function qq(t){return(t??"online")==="online"?Cw.isOnline():!0}var uP=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function Kq(t){let e=!1,n=0,r;const i=cP(),a=()=>i.status!=="pending",o=y=>{if(!a()){const x=new uP(y);m(x),t.onCancel?.(x)}},l=()=>{e=!0},c=()=>{e=!1},u=()=>DD.isFocused()&&(t.networkMode==="always"||Cw.isOnline())&&t.canRun(),d=()=>qq(t.networkMode)&&t.canRun(),f=y=>{a()||(r?.(),i.resolve(y))},m=y=>{a()||(r?.(),i.reject(y))},p=()=>new Promise(y=>{r=x=>{(a()||u())&&y(x)},t.onPause?.()}).then(()=>{r=void 0,a()||t.onContinue?.()}),b=()=>{if(a())return;let y;const x=n===0?t.initialPromise:void 0;try{y=x??t.fn()}catch(v){y=Promise.reject(v)}Promise.resolve(y).then(f).catch(v=>{if(a())return;const S=t.retry??(Lf?0:3),M=t.retryDelay??nue,E=typeof M=="function"?M(n,v):M,A=S===!0||typeof S=="number"&&n<S||typeof S=="function"&&S(n,v);if(e||!A){m(v);return}n++,t.onFail?.(n,v),Kce(E).then(()=>u()?void 0:p()).then(()=>{e?m(v):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 Xq=class{#t;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),sP(this.gcTime)&&(this.#t=lf.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(Lf?1/0:300*1e3))}clearGcTimeout(){this.#t&&(lf.clearTimeout(this.#t),this.#t=void 0)}},rue=class extends Xq{#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=Uz(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=Uz(this.options);e.data!==void 0&&(this.setState(Fz(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(t,e){const n=lP(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===PD||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>Ld(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!Gq(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=Wq(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=Kq({initialPromise:e?.initialPromise,fn:o.fetchFn,onCancel:l=>{l instanceof uP&&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 uP){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,...Yq(n.data,this.options),fetchMeta:t.meta??null};case"success":const r={...n,...Fz(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 Yq(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:qq(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function Fz(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Uz(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 OD=class extends lm{constructor(t,e){super(),this.options=e,this.#t=t,this.#s=null,this.#o=cP(),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),zz(this.#e,this.options)?this.#p():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return dP(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return dP(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&&!A0(this.options,e)&&this.#t.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const r=this.hasListeners();r&&Bz(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)||Ld(this.options.staleTime,this.#e)!==Ld(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 aue(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=Ld(this.options.staleTime,this.#e);if(Lf||this.#i.isStale||!sP(t))return;const n=Gq(this.#i.dataUpdatedAt,t)+1;this.#c=lf.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,!(Lf||yo(this.options.enabled,this.#e)===!1||!sP(this.#l)||this.#l===0)&&(this.#u=lf.setInterval(()=>{(this.options.refetchIntervalInBackground||DD.isFocused())&&this.#p()},this.#l))}#y(){this.#g(),this.#b(this.#x())}#v(){this.#c&&(lf.clearTimeout(this.#c),this.#c=void 0)}#_(){this.#u&&(lf.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(),C=!D&&zz(t,e),R=D&&Bz(t,n,e,r);(C||R)&&(d={...d,...Yq(u.data,t.options)}),e._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:p,errorUpdatedAt:b,status:y}=d;m=d.data;let x=!1;if(e.placeholderData!==void 0&&m===void 0&&y==="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&&(y="success",m=lP(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=lP(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(),y="error");const v=d.fetchStatus==="fetching",S=y==="pending",M=y==="error",E=S&&v,A=m!==void 0,T={status:y,fetchStatus:d.fetchStatus,isPending:S,isSuccess:y==="success",isError:M,isInitialLoading:E,isLoading:E,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:v,isRefetching:v&&!S,isLoadingError:M&&!A,isPaused:d.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:M&&A,isStale:LD(t,e),refetch:this.refetch,promise:this.#o,isEnabled:yo(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const D=T.data!==void 0,C=T.status==="error"&&!D,R=q=>{C?q.reject(T.error):D&&q.resolve(T.data)},U=()=>{const q=this.#o=T.promise=cP();R(q)},O=this.#o;switch(O.status){case"pending":t.queryHash===n.queryHash&&R(O);break;case"fulfilled":(C||T.data!==O.value)&&U();break;case"rejected":(!C||T.error!==O.reason)&&U();break}}return T}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),A0(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 iue(t,e){return yo(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function zz(t,e){return iue(t,e)||t.state.data!==void 0&&dP(t,e,e.refetchOnMount)}function dP(t,e,n){if(yo(e.enabled,t)!==!1&&Ld(e.staleTime,t)!=="static"){const r=typeof n=="function"?n(t):n;return r==="always"||r!==!1&&LD(t,e)}return!1}function Bz(t,e,n,r){return(t!==e||yo(r.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&LD(t,n)}function LD(t,e){return yo(e.enabled,t)!==!1&&t.isStaleByTime(Ld(e.staleTime,t))}function aue(t,e){return!A0(t.getCurrentResult(),e)}function $z(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=>{Qce(b,()=>e.signal,()=>d=!0)},m=Wq(e.options,e.fetchOptions),p=async(b,y,x)=>{if(d)return Promise.reject();if(y==null&&b.pages.length)return Promise.resolve(b);const S=(()=>{const k={client:e.client,queryKey:e.queryKey,pageParam:y,direction:x?"backward":"forward",meta:e.options.meta};return f(k),k})(),M=await m(S),{maxPages:E}=e.options,A=x?Yce:Xce;return{pages:A(b.pages,M,E),pageParams:A(b.pageParams,y,E)}};if(i&&a.length){const b=i==="backward",y=b?sue:Hz,x={pages:a,pageParams:o},v=y(r,x);l=await p(x,v,b)}else{const b=t??a.length;do{const y=c===0?o[0]??r.initialPageParam:Hz(r,l);if(c>0&&y==null)break;l=await p(l,y),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 Hz(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 sue(t,{pages:e,pageParams:n}){return e.length>0?t.getPreviousPageParam?.(e[0],e,n[0],n):void 0}var oue=class extends Xq{#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||Qq(),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=Kq({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 Qq(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var lue=class extends lm{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 oue({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=f_(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=f_(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=f_(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=f_(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=>Oz(e,n))}findAll(t={}){return this.getAll().filter(e=>Oz(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 f_(t){return t.options.scope?.id}var cue=class extends lm{#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),A0(this.options,n)||this.#t.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),n?.mutationKey&&this.options.mutationKey&&If(n.mutationKey)!==If(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??Qq();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 Vz(t,e){const n=new Set(e);return t.filter(r=>!n.has(r))}function uue(t,e,n){const r=t.slice(0);return r[e]=n,r}var due=class extends lm{#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||!A0(d,m)});!c&&!u||(c&&(this.#d=r,this.#r=i),this.#e=a,this.hasListeners()&&(c&&(Vz(n,i).forEach(d=>{d.destroy()}),Vz(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=jD(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 OD(this.#t,i);n.push({defaultedQueryOptions:i,observer:o})}),n}#l(t,e){const n=this.#r.indexOf(t);n!==-1&&(this.#e=uue(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)})})}}},hue=class extends lm{constructor(t={}){super(),this.config=t,this.#t=new Map}#t;build(t,e,n){const r=e.queryKey,i=e.queryHash??kD(r,e);let a=this.get(i);return a||(a=new rue({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=>Dz(e,n))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(n=>Dz(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()})})}},fue=class{#t;#e;#n;#i;#r;#a;#o;#s;constructor(t={}){this.#t=t.queryCache||new hue,this.#e=t.mutationCache||new lue,this.#n=t.defaultOptions||{},this.#i=new Map,this.#r=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=DD.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#t.onFocus())}),this.#s=Cw.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(Ld(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=Wce(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(Ld(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=$z(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(Ia).catch(Ia)}ensureInfiniteQueryData(t){return t.behavior=$z(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return Cw.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(If(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(If(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=kD(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===PD&&(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},mue=({client:t,children:e})=>(w.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),s.jsx(Zq.Provider,{value:t,children:e})),Jq=w.createContext(!1),eK=()=>w.useContext(Jq);Jq.Provider;function pue(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var gue=w.createContext(pue()),tK=()=>w.useContext(gue),nK=(t,e,n)=>{const r=n?.state.error&&typeof t.throwOnError=="function"?RD(t.throwOnError,[n.state.error,n]):t.throwOnError;(t.suspense||t.experimental_prefetchInRender||r)&&(e.isReset()||(t.retryOnMount=!1))},rK=t=>{w.useEffect(()=>{t.clearReset()},[t])},iK=({result:t,errorResetBoundary:e,throwOnError:n,query:r,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(i&&t.data===void 0||RD(n,[t.error,r])),aK=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))}},sK=(t,e)=>t.isLoading&&t.isFetching&&!e,hP=(t,e)=>t?.suspense&&e.isPending,kw=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function xue({queries:t,...e},n){const r=ln(),i=eK(),a=tK(),o=w.useMemo(()=>t.map(y=>{const x=r.defaultQueryOptions(y);return x._optimisticResults=i?"isRestoring":"optimistic",x}),[t,r,i]);o.forEach(y=>{aK(y);const x=r.getQueryCache().get(y.queryHash);nK(y,a,x)}),rK(a);const[l]=w.useState(()=>new due(r,o,e)),[c,u,d]=l.getOptimisticResult(o,e.combine),f=!i&&e.subscribed!==!1;w.useSyncExternalStore(w.useCallback(y=>f?l.subscribe(ai.batchCalls(y)):Ia,[l,f]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),w.useEffect(()=>{l.setQueries(o,e)},[o,e,l]);const p=c.some((y,x)=>hP(o[x],y))?c.flatMap((y,x)=>{const v=o[x];if(v){const S=new OD(r,v);if(hP(v,y))return kw(v,S,a);sK(y,i)&&kw(v,S,a)}return[]}):[];if(p.length>0)throw Promise.all(p);const b=c.find((y,x)=>{const v=o[x];return v&&iK({result:y,errorResetBoundary:a,throwOnError:v.throwOnError,query:r.getQueryCache().get(v.queryHash),suspense:v.suspense})});if(b?.error)throw b.error;return u(d())}function bue(t,e,n){const r=eK(),i=tK(),a=ln(),o=a.defaultQueryOptions(t);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);const l=a.getQueryCache().get(o.queryHash);o._optimisticResults=r?"isRestoring":"optimistic",aK(o),nK(o,i,l),rK(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]),hP(o,d))throw kw(o,u,i);if(iK({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&&!Lf&&sK(d,r)&&(c?kw(o,u,i):l?.promise)?.catch(Ia).finally(()=>{u.updateResult()}),o.notifyOnChangeProps?d:u.trackResult(d)}function ft(t,e){return bue(t,OD)}function pt(t,e){const n=ln(),[r]=w.useState(()=>new cue(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&&RD(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}const oK=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim();const yue=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const vue=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase());const Gz=t=>{const e=vue(t);return e.charAt(0).toUpperCase()+e.slice(1)};var _ue={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 wue=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0;return!1};const Sue=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,..._ue,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:oK("lucide",i),...!a&&!wue(l)&&{"aria-hidden":"true"},...l},[...o.map(([u,d])=>w.createElement(u,d)),...Array.isArray(a)?a:[a]]));const Ke=(t,e)=>{const n=w.forwardRef(({className:r,...i},a)=>w.createElement(Sue,{ref:a,iconNode:e,className:oK(`lucide-${yue(Gz(t))}`,`lucide-${t}`,r),...i}));return n.displayName=Gz(t),n};const Mue=[["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"}]],Nue=Ke("air-vent",Mue);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=Ke("archive",Eue);const Aue=[["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"}]],Tue=Ke("arrow-down-wide-narrow",Aue);const Cue=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],T0=Ke("arrow-down",Cue);const kue=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],lK=Ke("arrow-left",kue);const jue=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],fP=Ke("arrow-right",jue);const Pue=[["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"}]],cK=Ke("arrow-up-down",Pue);const Rue=[["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"}]],Due=Ke("arrow-up-narrow-wide",Rue);const Oue=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],fg=Ke("arrow-up",Oue);const Lue=[["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"}]],_f=Ke("bell",Lue);const Iue=[["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"}]],Fue=Ke("bold",Iue);const Uue=[["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"}]],zue=Ke("book",Uue);const Bue=[["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"}]],$ue=Ke("bookmark",Bue);const Hue=[["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=Ke("box",Hue);const Vue=[["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"}]],uK=Ke("briefcase",Vue);const Gue=[["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"}]],JM=Ke("bug",Gue);const Wue=[["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"}]],que=Ke("cable",Wue);const Kue=[["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"}]],Xue=Ke("calculator",Kue);const Yue=[["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"}]],Que=Ke("calendar-days",Yue);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=Ke("calendar",Zue);const Jue=[["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"}]],mg=Ke("camera",Jue);const ede=[["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"}]],tde=Ke("chart-column",ede);const nde=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],ts=Ke("check",nde);const rde=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Oi=Ke("chevron-down",rde);const ide=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Ff=Ke("chevron-left",ide);const ade=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Qs=Ke("chevron-right",ade);const sde=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],hu=Ke("chevron-up",sde);const ode=[["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=Ke("circle-alert",ode);const lde=[["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"}]],iT=Ke("circle-arrow-up",lde);const cde=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Hn=Ke("circle-check-big",cde);const ude=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],eN=Ke("circle-check",ude);const dde=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],hde=Ke("circle-dot",dde);const fde=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],mde=Ke("circle-stop",fde);const pde=[["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=Ke("circle-x",pde);const gde=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],mP=Ke("circle",gde);const xde=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Jn=Ke("clock",xde);const bde=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],tN=Ke("cloud",bde);const yde=[["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"}]],vde=Ke("code-xml",yde);const _de=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],dK=Ke("code",_de);const wde=[["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"}]],Sde=Ke("coffee",wde);const Mde=[["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"}]],Nde=Ke("cog",Mde);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"}]],Ade=Ke("compass",Ede);const Tde=[["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"}]],sl=Ke("copy",Tde);const Cde=[["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"}]],m_=Ke("cpu",Cde);const kde=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5v14a9 3 0 0 0 18 0V5",key:"aqi0yr"}]],jde=Ke("cylinder",kde);const Pde=[["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"}]],pg=Ke("database",Pde);const Rde=[["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"}]],pP=Ke("dollar-sign",Rde);const Dde=[["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=Ke("download",Dde);const Ode=[["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"}]],ID=Ke("droplet",Ode);const Lde=[["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"}]],FD=Ke("droplets",Lde);const Ide=[["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"}]],Id=Ke("ellipsis-vertical",Ide);const Fde=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],aT=Ke("equal",Fde);const Ude=[["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=Ke("external-link",Ude);const zde=[["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"}]],nN=Ke("eye-off",zde);const Bde=[["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"}]],Uf=Ke("eye",Bde);const $de=[["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"}]],hK=Ke("fan",$de);const Hde=[["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"}]],wf=Ke("file-box",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:"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"}]],jw=Ke("file-code",Vde);const Gde=[["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"}]],Wde=Ke("file-exclamation-point",Gde);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:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]],Pw=Ke("file-spreadsheet",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"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],Ya=Ke("file-text",Kde);const Xde=[["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"}]],rN=Ke("file",Xde);const Yde=[["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"}]],Fd=Ke("film",Yde);const Qde=[["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=Ke("flame",Qde);const Jde=[["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=Ke("folder-kanban",Jde);const ehe=[["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"}]],ol=Ke("folder-open",ehe);const the=[["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"}]],nhe=Ke("folder-plus",the);const rhe=[["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"}]],ihe=Ke("folder-tree",rhe);const ahe=[["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"}]],fK=Ke("folder",ahe);const she=[["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"}]],ohe=Ke("fullscreen",she);const lhe=[["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"}]],iN=Ke("funnel",lhe);const che=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],aN=Ke("gauge",che);const uhe=[["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"}]],dhe=Ke("gift",uhe);const hhe=[["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=Ke("git-compare",hhe);const fhe=[["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"}]],Wz=Ke("github",fhe);const mhe=[["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"}]],Ud=Ke("globe",mhe);const phe=[["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"}]],gg=Ke("grip-vertical",phe);const ghe=[["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"}]],mK=Ke("hand",ghe);const xhe=[["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"}]],sN=Ke("hard-drive",xhe);const bhe=[["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"}]],yhe=Ke("hash",bhe);const vhe=[["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"}]],_he=Ke("headphones",vhe);const whe=[["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"}]],She=Ke("heart",whe);const Mhe=[["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"}]],Rw=Ke("history",Mhe);const Nhe=[["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"}]],oN=Ke("house",Nhe);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"}]],yy=Ke("image",Ehe);const Ahe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Ql=Ke("info",Ahe);const The=[["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"}]],Che=Ke("italic",The);const khe=[["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"}]],cf=Ke("key",khe);const jhe=[["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"}]],gP=Ke("keyboard",jhe);const Phe=[["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"}]],ll=Ke("layers",Phe);const Rhe=[["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"}]],lN=Ke("layout-grid",Rhe);const Dhe=[["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"}]],Ohe=Ke("link-2-off",Dhe);const Lhe=[["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=Ke("link-2",Lhe);const Ihe=[["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"}]],Yg=Ke("link",Ihe);const Fhe=[["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"}]],pK=Ke("list-ordered",Fhe);const Uhe=[["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"}]],xP=Ke("list-todo",Uhe);const zhe=[["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"}]],cN=Ke("list",zhe);const Bhe=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],mt=Ke("loader-circle",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 9.9-1",key:"1mm8w8"}]],qz=Ke("lock-open",$he);const Hhe=[["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"}]],sT=Ke("lock",Hhe);const Vhe=[["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"}]],Kz=Ke("log-in",Vhe);const Ghe=[["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"}]],bP=Ke("log-out",Ghe);const Whe=[["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"}]],qhe=Ke("mail",Whe);const Khe=[["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"}]],Xhe=Ke("map",Khe);const Yhe=[["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"}]],gK=Ke("maximize-2",Yhe);const Qhe=[["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=Ke("maximize",Qhe);const Jhe=[["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"}]],efe=Ke("memory-stick",Jhe);const tfe=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],nfe=Ke("menu",tfe);const rfe=[["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"}]],xK=Ke("minimize-2",rfe);const ife=[["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"}]],bK=Ke("minimize",ife);const afe=[["path",{d:"M5 12h14",key:"1ays0h"}]],yP=Ke("minus",afe);const sfe=[["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"}]],ofe=Ke("monitor",sfe);const lfe=[["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"}]],Dw=Ke("moon",lfe);const cfe=[["path",{d:"M18 8L22 12L18 16",key:"1r0oui"}],["path",{d:"M2 12H22",key:"1m8cig"}]],ufe=Ke("move-right",cfe);const dfe=[["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"}]],vP=Ke("music",dfe);const hfe=[["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"}]],Zl=Ke("package",hfe);const ffe=[["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"}]],UD=Ke("palette",ffe);const mfe=[["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"}]],zD=Ke("pause",mfe);const pfe=[["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"}]],zf=Ke("pen-line",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"}]],uN=Ke("pen",gfe);const xfe=[["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"}]],sa=Ke("pencil",xfe);const bfe=[["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"}]],yfe=Ke("phone",bfe);const vfe=[["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"}]],cl=Ke("play",vfe);const _fe=[["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=Ke("plug",_fe);const wfe=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],rr=Ke("plus",wfe);const Sfe=[["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"}]],dN=Ke("power-off",Sfe);const Mfe=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],Su=Ke("power",Mfe);const Nfe=[["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=Ke("printer",Nfe);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"}]],yK=Ke("qr-code",Efe);const Afe=[["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=Ke("refresh-cw",Afe);const Tfe=[["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"}]],cm=Ke("rotate-ccw",Tfe);const Cfe=[["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"}]],kfe=Ke("ruler",Cfe);const jfe=[["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"}]],ys=Ke("save",jfe);const Pfe=[["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"}]],Ow=Ke("scan-search",Pfe);const Rfe=[["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"}]],Dfe=Ke("scissors",Rfe);const Ofe=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Ma=Ke("search",Ofe);const Lfe=[["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"}]],BD=Ke("send",Lfe);const Ife=[["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"}]],Xh=Ke("server",Ife);const Ffe=[["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"}]],Xd=Ke("settings-2",Ffe);const Ufe=[["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"}]],hN=Ke("settings",Ufe);const zfe=[["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"}]],_P=Ke("shield",zfe);const Bfe=[["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"}]],vK=Ke("shopping-cart",Bfe);const $fe=[["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"}]],Hfe=Ke("signal",$fe);const Vfe=[["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"}]],Gfe=Ke("skip-back",Vfe);const Wfe=[["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"}]],Lw=Ke("skip-forward",Wfe);const qfe=[["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"}]],Xz=Ke("sliders-vertical",qfe);const Kfe=[["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"}]],C0=Ke("sparkles",Kfe);const Xfe=[["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"}]],Do=Ke("square-check-big",Xfe);const Yfe=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}]],Qfe=Ke("square-minus",Yfe);const Zfe=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Oo=Ke("square",Zfe);const Jfe=[["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"}]],Bf=Ke("star",Jfe);const eme=[["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"}]],_K=Ke("sticky-note",eme);const tme=[["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"}]],Yz=Ke("sun",tme);const nme=[["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"}]],xg=Ke("tag",nme);const rme=[["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"}]],wK=Ke("target",rme);const ime=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],SK=Ke("terminal",ime);const ame=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],sme=Ke("text-align-center",ame);const ome=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],lme=Ke("text-align-end",ome);const cme=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],ume=Ke("text-align-start",cme);const dme=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],fN=Ke("thermometer",dme);const hme=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],Td=Ke("timer",hme);const fme=[["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=Ke("trash-2",fme);const mme=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],MK=Ke("trending-down",mme);const pme=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],NK=Ke("trending-up",pme);const gme=[["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=Ke("triangle-alert",gme);const xme=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],bme=Ke("underline",xme);const yme=[["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"}]],$D=Ke("unlink",yme);const vme=[["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=Ke("upload",vme);const _me=[["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"}]],wP=Ke("user",_me);const wme=[["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"}]],uf=Ke("users",wme);const Sme=[["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"}]],HD=Ke("video",Sme);const Mme=[["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"}]],Nme=Ke("volume-2",Mme);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"}]],Ame=Ke("volume-x",Eme);const Tme=[["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"}]],Cme=Ke("wand-sparkles",Tme);const kme=[["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"}]],Qg=Ke("wifi-off",kme);const jme=[["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"}]],Jp=Ke("wifi",jme);const Pme=[["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=Ke("wind",Pme);const Rme=[["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"}]],Yd=Ke("wrench",Rme);const Dme=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Ht=Ke("x",Dme);const Ome=[["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"}]],$f=Ke("zap",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:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],VD=Ke("zoom-in",Lme);const Ime=[["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"}]],GD=Ke("zoom-out",Ime),xn="/api/v1";let Iw=localStorage.getItem("auth_token");function Ib(t){Iw=t,t?localStorage.setItem("auth_token",t):localStorage.removeItem("auth_token")}function Qz(){return Iw}async function Ce(t,e={}){const n={"Content-Type":"application/json",...e.headers};Iw&&(n.Authorization=`Bearer ${Iw}`);const r=await fetch(`${xn}${t}`,{...e,cache:"no-store",headers:n});if(!r.ok){r.status===401&&Ib(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 fe={getAuthStatus:()=>Ce("/auth/status"),setupAuth:t=>Ce("/auth/setup",{method:"POST",body:JSON.stringify(t)}),login:t=>Ce("/auth/login",{method:"POST",body:JSON.stringify(t)}),logout:()=>Ce("/auth/logout",{method:"POST"}),getCurrentUser:()=>Ce("/auth/me"),disableAuth:()=>Ce("/auth/disable",{method:"POST"}),getUsers:()=>Ce("/users/"),getUser:t=>Ce(`/users/${t}`),createUser:t=>Ce("/users/",{method:"POST",body:JSON.stringify(t)}),updateUser:(t,e)=>Ce(`/users/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteUser:t=>Ce(`/users/${t}`,{method:"DELETE"}),getPrinters:()=>Ce("/printers/"),getPrinter:t=>Ce(`/printers/${t}`),createPrinter:t=>Ce("/printers/",{method:"POST",body:JSON.stringify(t)}),updatePrinter:(t,e)=>Ce(`/printers/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deletePrinter:(t,e=!0)=>Ce(`/printers/${t}?delete_archives=${e}`,{method:"DELETE"}),getPrinterStatus:t=>Ce(`/printers/${t}/status`),refreshPrinterStatus:t=>Ce(`/printers/${t}/refresh-status`,{method:"POST"}),connectPrinter:t=>Ce(`/printers/${t}/connect`,{method:"POST"}),disconnectPrinter:t=>Ce(`/printers/${t}/disconnect`,{method:"POST"}),testExternalCamera:(t,e,n)=>Ce(`/printers/${t}/camera/external/test?url=${encodeURIComponent(e)}&camera_type=${encodeURIComponent(n)}`,{method:"POST"}),stopPrint:t=>Ce(`/printers/${t}/print/stop`,{method:"POST"}),pausePrint:t=>Ce(`/printers/${t}/print/pause`,{method:"POST"}),resumePrint:t=>Ce(`/printers/${t}/print/resume`,{method:"POST"}),setChamberLight:(t,e)=>Ce(`/printers/${t}/chamber-light?on=${e}`,{method:"POST"}),getPrintableObjects:t=>Ce(`/printers/${t}/print/objects`),skipObjects:(t,e)=>Ce(`/printers/${t}/print/skip-objects`,{method:"POST",body:JSON.stringify(e)}),refreshAmsSlot:(t,e,n)=>Ce(`/printers/${t}/ams/${e}/slot/${n}/refresh`,{method:"POST"}),enableMQTTLogging:t=>Ce(`/printers/${t}/logging/enable`,{method:"POST"}),disableMQTTLogging:t=>Ce(`/printers/${t}/logging/disable`,{method:"POST"}),getMQTTLogs:t=>Ce(`/printers/${t}/logging`),clearMQTTLogs:t=>Ce(`/printers/${t}/logging`,{method:"DELETE"}),getPrinterFiles:(t,e="/")=>Ce(`/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)=>Ce(`/printers/${t}/files?path=${encodeURIComponent(e)}`,{method:"DELETE"}),getPrinterStorage:t=>Ce(`/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)),Ce(`/archives/?${i}`)},getArchive:t=>Ce(`/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)),Ce(`/archives/search?${n}`)},rebuildSearchIndex:()=>Ce("/archives/search/rebuild-index",{method:"POST"}),updateArchive:(t,e)=>Ce(`/archives/${t}`,{method:"PATCH",body:JSON.stringify(e)}),toggleFavorite:t=>Ce(`/archives/${t}/favorite`,{method:"POST"}),deleteArchive:t=>Ce(`/archives/${t}`,{method:"DELETE"}),getArchiveStats:()=>Ce("/archives/stats"),recalculateCosts:()=>Ce("/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)),Ce(`/archives/analysis/failures?${e}`)},compareArchives:t=>Ce(`/archives/compare?archive_ids=${t.join(",")}`),findSimilarArchives:(t,e=10)=>Ce(`/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=>Ce(`/archives/${t}/duplicates`),backfillContentHashes:()=>Ce("/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=>Ce(`/archives/${t}/timelapse/scan`,{method:"POST"}),selectArchiveTimelapse:(t,e)=>Ce(`/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=>Ce(`/archives/${t}/timelapse/info`),getTimelapseThumbnails:(t,e=10)=>Ce(`/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)=>Ce(`/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=>Ce(`/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=>Ce(`/archives/${t}/f3d`,{method:"DELETE"}),getArchiveQRCodeUrl:(t,e=200)=>`${xn}/archives/${t}/qrcode?size=${e}`,getArchiveCapabilities:t=>Ce(`/archives/${t}/capabilities`),getArchiveProjectPage:t=>Ce(`/archives/${t}/project-page`),updateArchiveProjectPage:(t,e)=>Ce(`/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=>Ce(`/archives/${t}/plates`),getArchiveFilamentRequirements:(t,e)=>Ce(`/archives/${t}/filament-requirements${e!==void 0?`?plate_id=${e}`:""}`),reprintArchive:(t,e,n)=>Ce(`/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:()=>Ce("/settings/"),updateSettings:t=>Ce("/settings/",{method:"PUT",body:JSON.stringify(t)}),getMQTTStatus:()=>Ce("/settings/mqtt/status"),resetSettings:()=>Ce("/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:()=>Ce("/settings/check-ffmpeg"),getCloudStatus:()=>Ce("/cloud/status"),cloudLogin:(t,e,n="global")=>Ce("/cloud/login",{method:"POST",body:JSON.stringify({email:t,password:e,region:n})}),cloudVerify:(t,e)=>Ce("/cloud/verify",{method:"POST",body:JSON.stringify({email:t,code:e})}),cloudSetToken:t=>Ce("/cloud/token",{method:"POST",body:JSON.stringify({access_token:t})}),cloudLogout:()=>Ce("/cloud/logout",{method:"POST"}),getCloudSettings:(t="02.04.00.70")=>Ce(`/cloud/settings?version=${t}`),getCloudSettingDetail:t=>Ce(`/cloud/settings/${t}`),createCloudSetting:t=>Ce("/cloud/settings",{method:"POST",body:JSON.stringify(t)}),updateCloudSetting:(t,e)=>Ce(`/cloud/settings/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteCloudSetting:t=>Ce(`/cloud/settings/${t}`,{method:"DELETE"}),getCloudDevices:()=>Ce("/cloud/devices"),getCloudFields:t=>Ce(`/cloud/fields/${t}`),getAllCloudFields:()=>Ce("/cloud/fields"),getFilamentInfo:t=>Ce("/cloud/filament-info",{method:"POST",body:JSON.stringify(t)}),getSmartPlugs:()=>Ce("/smart-plugs/"),getSmartPlug:t=>Ce(`/smart-plugs/${t}`),getSmartPlugByPrinter:t=>Ce(`/smart-plugs/by-printer/${t}`),createSmartPlug:t=>Ce("/smart-plugs/",{method:"POST",body:JSON.stringify(t)}),updateSmartPlug:(t,e)=>Ce(`/smart-plugs/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteSmartPlug:t=>Ce(`/smart-plugs/${t}`,{method:"DELETE"}),controlSmartPlug:(t,e)=>Ce(`/smart-plugs/${t}/control`,{method:"POST",body:JSON.stringify({action:e})}),getSmartPlugStatus:t=>Ce(`/smart-plugs/${t}/status`),testSmartPlugConnection:(t,e,n)=>Ce("/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:()=>Ce("/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:()=>Ce("/smart-plugs/discover/devices"),testHAConnection:(t,e)=>Ce("/smart-plugs/ha/test-connection",{method:"POST",body:JSON.stringify({url:t,token:e})}),getHAEntities:t=>{const e=t?`?search=${encodeURIComponent(t)}`:"";return Ce(`/smart-plugs/ha/entities${e}`)},getHASensorEntities:()=>Ce("/smart-plugs/ha/sensors"),getQueue:(t,e)=>{const n=new URLSearchParams;return t&&n.set("printer_id",String(t)),e&&n.set("status",e),Ce(`/queue/?${n}`)},getQueueItem:t=>Ce(`/queue/${t}`),addToQueue:t=>Ce("/queue/",{method:"POST",body:JSON.stringify(t)}),updateQueueItem:(t,e)=>Ce(`/queue/${t}`,{method:"PATCH",body:JSON.stringify(e)}),removeFromQueue:t=>Ce(`/queue/${t}`,{method:"DELETE"}),reorderQueue:t=>Ce("/queue/reorder",{method:"POST",body:JSON.stringify({items:t})}),cancelQueueItem:t=>Ce(`/queue/${t}/cancel`,{method:"POST"}),stopQueueItem:t=>Ce(`/queue/${t}/stop`,{method:"POST"}),startQueueItem:t=>Ce(`/queue/${t}/start`,{method:"POST"}),bulkUpdateQueue:t=>Ce("/queue/bulk",{method:"PATCH",body:JSON.stringify(t)}),getKProfiles:(t,e="0.4")=>Ce(`/printers/${t}/kprofiles/?nozzle_diameter=${e}`),setKProfile:(t,e)=>Ce(`/printers/${t}/kprofiles/`,{method:"POST",body:JSON.stringify(e)}),deleteKProfile:(t,e)=>Ce(`/printers/${t}/kprofiles/`,{method:"DELETE",body:JSON.stringify(e)}),setKProfilesBatch:(t,e)=>Ce(`/printers/${t}/kprofiles/batch`,{method:"POST",body:JSON.stringify(e)}),getKProfileNotes:t=>Ce(`/printers/${t}/kprofiles/notes`),setKProfileNote:(t,e,n)=>Ce(`/printers/${t}/kprofiles/notes`,{method:"PUT",body:JSON.stringify({setting_id:e,note:n})}),deleteKProfileNote:(t,e)=>Ce(`/printers/${t}/kprofiles/notes/${encodeURIComponent(e)}`,{method:"DELETE"}),getSlotPresets:t=>Ce(`/printers/${t}/slot-presets`),getSlotPreset:(t,e,n)=>Ce(`/printers/${t}/slot-presets/${e}/${n}`),saveSlotPreset:(t,e,n,r,i)=>Ce(`/printers/${t}/slot-presets/${e}/${n}?preset_id=${encodeURIComponent(r)}&preset_name=${encodeURIComponent(i)}`,{method:"PUT"}),deleteSlotPreset:(t,e,n)=>Ce(`/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()),Ce(`/printers/${t}/slots/${e}/${n}/configure?${i}`,{method:"POST"})},resetAmsSlot:(t,e,n)=>Ce(`/printers/${t}/ams/${e}/tray/${n}/reset`,{method:"POST"}),listFilaments:()=>Ce("/filaments/"),getFilament:t=>Ce(`/filaments/${t}`),getFilamentsByType:t=>Ce(`/filaments/by-type/${t}`),getNotificationProviders:()=>Ce("/notifications/"),getNotificationProvider:t=>Ce(`/notifications/${t}`),createNotificationProvider:t=>Ce("/notifications/",{method:"POST",body:JSON.stringify(t)}),updateNotificationProvider:(t,e)=>Ce(`/notifications/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteNotificationProvider:t=>Ce(`/notifications/${t}`,{method:"DELETE"}),testNotificationProvider:t=>Ce(`/notifications/${t}/test`,{method:"POST"}),testNotificationConfig:t=>Ce("/notifications/test-config",{method:"POST",body:JSON.stringify(t)}),testAllNotificationProviders:()=>Ce("/notifications/test-all",{method:"POST"}),getNotificationTemplates:()=>Ce("/notification-templates"),getNotificationTemplate:t=>Ce(`/notification-templates/${t}`),updateNotificationTemplate:(t,e)=>Ce(`/notification-templates/${t}`,{method:"PUT",body:JSON.stringify(e)}),resetNotificationTemplate:t=>Ce(`/notification-templates/${t}/reset`,{method:"POST"}),getTemplateVariables:()=>Ce("/notification-templates/variables"),previewTemplate:t=>Ce("/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)),Ce(`/notifications/logs?${e}`)},getNotificationLogStats:(t=7)=>Ce(`/notifications/logs/stats?days=${t}`),clearNotificationLogs:(t=30)=>Ce(`/notifications/logs?older_than_days=${t}`,{method:"DELETE"}),getSpoolmanStatus:()=>Ce("/spoolman/status"),connectSpoolman:()=>Ce("/spoolman/connect",{method:"POST"}),disconnectSpoolman:()=>Ce("/spoolman/disconnect",{method:"POST"}),syncPrinterAms:t=>Ce(`/spoolman/sync/${t}`,{method:"POST"}),syncAllPrintersAms:()=>Ce("/spoolman/sync-all",{method:"POST"}),getSpoolmanSpools:()=>Ce("/spoolman/spools"),getSpoolmanFilaments:()=>Ce("/spoolman/filaments"),getUnlinkedSpools:()=>Ce("/spoolman/spools/unlinked"),linkSpool:(t,e)=>Ce(`/spoolman/spools/${t}/link`,{method:"POST",body:JSON.stringify({tray_uuid:e})}),getVersion:()=>Ce("/updates/version"),checkForUpdates:()=>Ce("/updates/check"),applyUpdate:()=>Ce("/updates/apply",{method:"POST"}),getUpdateStatus:()=>Ce("/updates/status"),getMaintenanceTypes:()=>Ce("/maintenance/types"),createMaintenanceType:t=>Ce("/maintenance/types",{method:"POST",body:JSON.stringify(t)}),updateMaintenanceType:(t,e)=>Ce(`/maintenance/types/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteMaintenanceType:t=>Ce(`/maintenance/types/${t}`,{method:"DELETE"}),getMaintenanceOverview:()=>Ce("/maintenance/overview"),getPrinterMaintenance:t=>Ce(`/maintenance/printers/${t}`),updateMaintenanceItem:(t,e)=>Ce(`/maintenance/items/${t}`,{method:"PATCH",body:JSON.stringify(e)}),performMaintenance:(t,e)=>Ce(`/maintenance/items/${t}/perform`,{method:"POST",body:JSON.stringify({notes:e})}),getMaintenanceHistory:t=>Ce(`/maintenance/items/${t}/history`),getMaintenanceSummary:()=>Ce("/maintenance/summary"),setPrinterHours:(t,e)=>Ce(`/maintenance/printers/${t}/hours?total_hours=${e}`,{method:"PATCH"}),assignMaintenanceType:(t,e)=>Ce(`/maintenance/printers/${t}/assign/${e}`,{method:"POST"}),removeMaintenanceItem:t=>Ce(`/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=>Ce(`/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)),Ce(`/printers/${t}/camera/check-plate?${n.toString()}`)},getPlateDetectionStatus:t=>Ce(`/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)),Ce(`/printers/${t}/camera/plate-detection/calibrate?${n.toString()}`,{method:"POST"})},deletePlateCalibration:t=>Ce(`/printers/${t}/camera/plate-detection/calibrate`,{method:"DELETE"}),getPlateReferences:t=>Ce(`/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),Ce(`/printers/${t}/camera/plate-detection/references/${e}?${r.toString()}`,{method:"PUT"})},deletePlateReference:(t,e)=>Ce(`/printers/${t}/camera/plate-detection/references/${e}`,{method:"DELETE"}),getExternalLinks:()=>Ce("/external-links/"),getExternalLink:t=>Ce(`/external-links/${t}`),createExternalLink:t=>Ce("/external-links/",{method:"POST",body:JSON.stringify(t)}),updateExternalLink:(t,e)=>Ce(`/external-links/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteExternalLink:t=>Ce(`/external-links/${t}`,{method:"DELETE"}),reorderExternalLinks:t=>Ce("/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=>Ce(`/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),Ce(`/projects/?${e}`)},getProject:t=>Ce(`/projects/${t}`),createProject:t=>Ce("/projects/",{method:"POST",body:JSON.stringify(t)}),updateProject:(t,e)=>Ce(`/projects/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteProject:t=>Ce(`/projects/${t}`,{method:"DELETE"}),getProjectArchives:(t,e=100,n=0)=>Ce(`/projects/${t}/archives?limit=${e}&offset=${n}`),addArchivesToProject:(t,e)=>Ce(`/projects/${t}/add-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),removeArchivesFromProject:(t,e)=>Ce(`/projects/${t}/remove-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),addQueueItemsToProject:(t,e)=>Ce(`/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)=>Ce(`/projects/${t}/attachments/${encodeURIComponent(e)}`,{method:"DELETE"}),getProjectBOM:t=>Ce(`/projects/${t}/bom`),createBOMItem:(t,e)=>Ce(`/projects/${t}/bom`,{method:"POST",body:JSON.stringify(e)}),updateBOMItem:(t,e,n)=>Ce(`/projects/${t}/bom/${e}`,{method:"PATCH",body:JSON.stringify(n)}),deleteBOMItem:(t,e)=>Ce(`/projects/${t}/bom/${e}`,{method:"DELETE"}),getTemplates:()=>Ce("/projects/templates/"),createTemplateFromProject:t=>Ce(`/projects/${t}/create-template`,{method:"POST"}),createProjectFromTemplate:(t,e)=>Ce(`/projects/from-template/${t}${e?`?name=${encodeURIComponent(e)}`:""}`,{method:"POST"}),getProjectTimeline:(t,e=50)=>Ce(`/projects/${t}/timeline?limit=${e}`),exportProjectJson:t=>Ce(`/projects/${t}/export?format=json`),importProject:t=>Ce("/projects/import",{method:"POST",body:JSON.stringify(t)}),getAPIKeys:()=>Ce("/api-keys/"),createAPIKey:t=>Ce("/api-keys/",{method:"POST",body:JSON.stringify(t)}),updateAPIKey:(t,e)=>Ce(`/api-keys/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteAPIKey:t=>Ce(`/api-keys/${t}`,{method:"DELETE"}),getAMSHistory:(t,e,n=24)=>Ce(`/ams-history/${t}/${e}?hours=${n}`),getSystemInfo:()=>Ce("/system/info"),getLibraryFolders:()=>Ce("/library/folders"),createLibraryFolder:t=>Ce("/library/folders",{method:"POST",body:JSON.stringify(t)}),updateLibraryFolder:(t,e)=>Ce(`/library/folders/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteLibraryFolder:t=>Ce(`/library/folders/${t}`,{method:"DELETE"}),getLibraryFoldersByProject:t=>Ce(`/library/folders/by-project/${t}`),getLibraryFoldersByArchive:t=>Ce(`/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)),Ce(`/library/files?${n}`)},getLibraryFile:t=>Ce(`/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)=>Ce(`/library/files/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteLibraryFile:t=>Ce(`/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)=>Ce("/library/files/move",{method:"POST",body:JSON.stringify({file_ids:t,folder_id:e})}),bulkDeleteLibrary:(t,e)=>Ce("/library/bulk-delete",{method:"POST",body:JSON.stringify({file_ids:t,folder_ids:e})}),getLibraryStats:()=>Ce("/library/stats"),addLibraryFilesToQueue:t=>Ce("/library/files/add-to-queue",{method:"POST",body:JSON.stringify({file_ids:t})}),printLibraryFile:(t,e,n)=>Ce(`/library/files/${t}/print?printer_id=${e}`,{method:"POST",body:n?JSON.stringify(n):void 0}),getLibraryFilePlates:t=>Ce(`/library/files/${t}/plates`),getLibraryFileFilamentRequirements:(t,e)=>Ce(`/library/files/${t}/filament-requirements${e!==void 0?`?plate_id=${e}`:""}`)},Ml={getInfo:()=>Ce("/discovery/info"),getStatus:()=>Ce("/discovery/status"),startDiscovery:(t=10)=>Ce(`/discovery/start?duration=${t}`,{method:"POST"}),stopDiscovery:()=>Ce("/discovery/stop",{method:"POST"}),getDiscoveredPrinters:()=>Ce("/discovery/printers"),startSubnetScan:(t,e=1)=>Ce("/discovery/scan",{method:"POST",body:JSON.stringify({subnet:t,timeout:e})}),getScanStatus:()=>Ce("/discovery/scan/status"),stopSubnetScan:()=>Ce("/discovery/scan/stop",{method:"POST"})},Z1={getSettings:()=>Ce("/settings/virtual-printer"),getModels:()=>Ce("/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),Ce(`/settings/virtual-printer?${e.toString()}`,{method:"PUT"})}},Up={list:()=>Ce("/pending-uploads/"),getCount:()=>Ce("/pending-uploads/count"),get:t=>Ce(`/pending-uploads/${t}`),archive:(t,e)=>Ce(`/pending-uploads/${t}/archive`,{method:"POST",body:JSON.stringify(e||{})}),discard:t=>Ce(`/pending-uploads/${t}`,{method:"DELETE"}),archiveAll:()=>Ce("/pending-uploads/archive-all",{method:"POST"}),discardAll:()=>Ce("/pending-uploads/discard-all",{method:"DELETE"})},J1={checkUpdates:()=>Ce("/firmware/updates"),checkPrinterUpdate:t=>Ce(`/firmware/updates/${t}`),prepareUpload:t=>Ce(`/firmware/updates/${t}/prepare`),startUpload:t=>Ce(`/firmware/updates/${t}/upload`,{method:"POST"}),getUploadStatus:t=>Ce(`/firmware/updates/${t}/upload/status`)},eg={getDebugLoggingState:()=>Ce("/support/debug-logging"),setDebugLogging:t=>Ce("/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 Ce(`/support/logs${n?`?${n}`:""}`)},clearLogs:()=>Ce("/support/logs",{method:"DELETE"})},AK=w.createContext(void 0);function Fme({children:t}){const[e,n]=w.useState(()=>{const T=localStorage.getItem("theme-mode"),D=localStorage.getItem("theme");return T||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(()=>{fe.getSettings().then(T=>{T.dark_style&&(i(T.dark_style),localStorage.setItem("dark-style",T.dark_style)),T.dark_background&&(o(T.dark_background),localStorage.setItem("dark-background",T.dark_background)),T.dark_accent&&(c(T.dark_accent),localStorage.setItem("dark-accent",T.dark_accent)),T.light_style&&(d(T.light_style),localStorage.setItem("light-style",T.light_style)),T.light_background&&(m(T.light_background),localStorage.setItem("light-background",T.light_background)),T.light_accent&&(b(T.light_accent),localStorage.setItem("light-accent",T.light_accent))}).catch(()=>{})},[]),w.useEffect(()=>{const T=document.documentElement;T.classList.remove("dark","style-classic","style-glow","style-vibrant","bg-neutral","bg-warm","bg-cool","bg-oled","bg-slate","bg-forest","accent-green","accent-teal","accent-blue","accent-orange","accent-purple","accent-red"),e==="dark"?(T.classList.add("dark"),T.classList.add(`style-${r}`),T.classList.add(`bg-${a}`),T.classList.add(`accent-${l}`)):(T.classList.add(`style-${u}`),T.classList.add(`bg-${f}`),T.classList.add(`accent-${p}`)),localStorage.setItem("theme-mode",e),localStorage.removeItem("theme")},[e,r,a,l,u,f,p]);const y=()=>n(T=>T==="dark"?"light":"dark"),x=T=>n(T),v=T=>{i(T),localStorage.setItem("dark-style",T),fe.updateSettings({dark_style:T}).catch(()=>{})},S=T=>{o(T),localStorage.setItem("dark-background",T),fe.updateSettings({dark_background:T}).catch(()=>{})},M=T=>{c(T),localStorage.setItem("dark-accent",T),fe.updateSettings({dark_accent:T}).catch(()=>{})},E=T=>{d(T),localStorage.setItem("light-style",T),fe.updateSettings({light_style:T}).catch(()=>{})},A=T=>{m(T),localStorage.setItem("light-background",T),fe.updateSettings({light_background:T}).catch(()=>{})},k=T=>{b(T),localStorage.setItem("light-accent",T),fe.updateSettings({light_accent:T}).catch(()=>{})};return s.jsx(AK.Provider,{value:{mode:e,darkStyle:r,darkBackground:a,darkAccent:l,lightStyle:u,lightBackground:f,lightAccent:p,toggleMode:y,setMode:x,setDarkStyle:v,setDarkBackground:S,setDarkAccent:M,setLightStyle:E,setLightBackground:A,setLightAccent:k},children:t})}function lh(){const t=w.useContext(AK);if(!t)throw new Error("useTheme must be used within ThemeProvider");return t}function Et({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 Nr({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 Ume(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 zme({onClose:t,navItems:e,sidebarItems:n}){const{t:r}=Wg(),i=Ume(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(Et,{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(gP,{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(Ht,{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(Et,{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 Bme({plug:t}){const e=ln(),[n,r]=w.useState(null),{data:i,isLoading:a}=ft({queryKey:["smart-plug-status",t.id],queryFn:()=>fe.getSmartPlugStatus(t.id),refetchInterval:1e4}),o=pt({mutationFn:f=>fe.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(Jp,{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($f,{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(Qg,{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(Su,{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(dN,{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 Jz({onClose:t}){const{data:e,isLoading:n}=ft({queryKey:["smart-plugs"],queryFn:fe.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(Bme,{plug:i},i.id))})})]})}const TK=[{name:"globe",icon:Ud},{name:"link",icon:Yg},{name:"external-link",icon:Gr},{name:"book",icon:zue},{name:"file-text",icon:Ya},{name:"home",icon:oN},{name:"star",icon:Bf},{name:"heart",icon:She},{name:"bookmark",icon:$ue},{name:"shopping-cart",icon:vK},{name:"music",icon:vP},{name:"video",icon:HD},{name:"image",icon:yy},{name:"camera",icon:mg},{name:"map",icon:Xhe},{name:"compass",icon:Ade},{name:"coffee",icon:Sde},{name:"gift",icon:dhe},{name:"wrench",icon:Yd},{name:"zap",icon:$f},{name:"cloud",icon:tN},{name:"database",icon:pg},{name:"folder",icon:fK},{name:"mail",icon:qhe},{name:"phone",icon:yfe},{name:"user",icon:wP},{name:"users",icon:uf},{name:"server",icon:Xh},{name:"terminal",icon:SK},{name:"code",icon:dK}];function mN(t){return TK.find(n=>n.name===t)?.icon||Yg}function $me({value:t,onChange:e}){const[n,r]=w.useState(!1),i=mN(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:TK.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 eB=768;function CK(){const[t,e]=w.useState(()=>typeof window<"u"?window.innerWidth<eB:!1);return w.useEffect(()=>{const n=window.matchMedia(`(max-width: ${eB-1}px)`),r=i=>{e(i.matches)};return e(n.matches),n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),t}const kK=w.createContext(void 0);function Hme({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 fe.getAuthStatus();if(!d.current)return;if(i(x.auth_enabled),o(x.requires_setup),x.auth_enabled)if(Qz())try{const S=await fe.getCurrentUser();if(!d.current)return;n(S)}catch{if(Ib(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,v)=>{const S=await fe.login({username:x,password:v});Ib(S.access_token),n(S.user)},p=()=>{Ib(null),n(null),fe.logout().catch(()=>{}),window.location.href="/login"},b=async()=>{if(r&&Qz())try{const x=await fe.getCurrentUser();d.current&&n(x)}catch{Ib(null),d.current&&n(null)}},y=async()=>{await f()};return s.jsx(kK.Provider,{value:{user:e,authEnabled:r,requiresSetup:a,loading:l,login:m,logout:p,refreshUser:b,refreshAuth:y},children:t})}function ch(){const t=w.useContext(kK);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t}const k0=[{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:tde,labelKey:"nav.stats"},{id:"profiles",to:"/profiles",icon:tN,labelKey:"nav.profiles"},{id:"maintenance",to:"/maintenance",icon:Yd,labelKey:"nav.maintenance"},{id:"projects",to:"/projects",icon:Ea,labelKey:"nav.projects"},{id:"files",to:"/files",icon:ol,labelKey:"nav.files"},{id:"settings",to:"/settings",icon:hN,labelKey:"nav.settings"}];function Vme(){const t=localStorage.getItem("sidebarOrder");if(t)try{return JSON.parse(t)}catch{return k0.map(e=>e.id)}return k0.map(e=>e.id)}function Gme(t){localStorage.setItem("sidebarOrder",JSON.stringify(t))}function oT(t){return t.startsWith("ext-")}function jK(){return localStorage.getItem("defaultView")||"/"}function Wme(t){localStorage.setItem("defaultView",t)}function qme(){const t=pl(),e=lc(),{mode:n,toggleMode:r}=lh(),{t:i}=Wg(),a=CK(),{user:o,authEnabled:l,logout:c}=ch(),[u,d]=w.useState(()=>localStorage.getItem("sidebarExpanded")!=="false"),[f,m]=w.useState(!1),[p,b]=w.useState(!1),[y,x]=w.useState(!1),[v,S]=w.useState(Vme),[M,E]=w.useState(null),[A,k]=w.useState(null),T=w.useRef(!1),[D,C]=w.useState(()=>sessionStorage.getItem("dismissedUpdateVersion")),[R,U]=w.useState(null),{data:O}=ft({queryKey:["version"],queryFn:fe.getVersion,staleTime:1/0}),{data:q}=ft({queryKey:["settings"],queryFn:fe.getSettings,staleTime:300*1e3}),{data:j}=ft({queryKey:["updateCheck"],queryFn:fe.checkForUpdates,enabled:q?.check_updates!==!1,staleTime:3600*1e3,refetchInterval:3600*1e3}),{data:W}=ft({queryKey:["external-links"],queryFn:fe.getExternalLinks}),{data:X}=ft({queryKey:["smart-plugs"],queryFn:fe.getSmartPlugs,staleTime:30*1e3}),G=X?.some(K=>K.show_in_switchbar)??!1,{data:Z}=ft({queryKey:["debugLogging"],queryFn:eg.getDebugLoggingState,staleTime:60*1e3,refetchInterval:60*1e3}),{data:te}=ft({queryKey:["queue","pending"],queryFn:()=>fe.getQueue(void 0,"pending"),staleTime:5*1e3,refetchInterval:5*1e3,refetchOnWindowFocus:!0}),ee=te?.length??0,{data:z}=ft({queryKey:["pending-uploads","count"],queryFn:Up.getCount,staleTime:5*1e3,refetchInterval:5*1e3,refetchOnWindowFocus:!0}),V=z?.count??0,[ne,ie]=w.useState(null);w.useEffect(()=>{if(!Z?.enabled||!Z.enabled_at){ie(null);return}const K=new Date(Z.enabled_at).getTime(),B=()=>{ie(Math.floor((Date.now()-K)/1e3))};B();const I=setInterval(B,1e3);return()=>clearInterval(I)},[Z?.enabled,Z?.enabled_at]);const he=w.useMemo(()=>new Map(k0.map(K=>[K.id,K])),[]),me=w.useMemo(()=>new Map((W||[]).map(K=>[`ext-${K.id}`,K])),[W]),oe=(()=>{const K=[],B=new Set,I=l&&o?.role==="user";for(const ce of v)I&&ce==="settings"||(he.has(ce)||me.has(ce))&&(K.push(ce),B.add(ce));for(const ce of k0)I&&ce.id==="settings"||B.has(ce.id)||(K.push(ce.id),B.add(ce.id));for(const ce of W||[]){const Ee=`ext-${ce.id}`;B.has(Ee)||(K.push(Ee),B.add(Ee))}return K})(),Ae=(K,B)=>{E(B),K.dataTransfer.effectAllowed="move",K.dataTransfer.setData("text/plain",B)},ge=(K,B)=>{K.preventDefault(),K.dataTransfer.dropEffect="move",k(B)},Ne=()=>{k(null)},_e=(K,B)=>{if(K.preventDefault(),M===null||M===B){E(null),k(null);return}const I=[...oe],ce=I.indexOf(M),Ee=I.indexOf(B);if(ce===-1||Ee===-1){E(null),k(null);return}I.splice(ce,1),I.splice(Ee,0,M),S(I),Gme(I),E(null),k(null)},le=()=>{E(null),k(null)},He=j?.update_available&&j.latest_version&&j.latest_version!==D,H=()=>{j?.latest_version&&(sessionStorage.setItem("dismissedUpdateVersion",j.latest_version),C(j.latest_version))};w.useEffect(()=>{if(!T.current&&e.pathname==="/"){const K=jK();K!=="/"&&(T.current=!0,t(K,{replace:!0}))}},[e.pathname,t]),w.useEffect(()=>{localStorage.setItem("sidebarExpanded",String(u))},[u]),w.useEffect(()=>{a&&m(!1)},[e.pathname,a]),w.useEffect(()=>{const K=B=>{const I=B.detail;U({printer_id:I.printer_id,printer_name:I.printer_name,message:I.message})};return window.addEventListener("plate-not-empty",K),()=>window.removeEventListener("plate-not-empty",K)},[]);const J=w.useCallback(K=>{const B=K.target;if(!(B.tagName==="INPUT"||B.tagName==="TEXTAREA"||B.isContentEditable)&&!K.metaKey&&!K.ctrlKey&&!K.altKey){const I=parseInt(K.key);if(I>=1&&I<=oe.length&&I<=9){const ce=oe[I-1];if(K.preventDefault(),oT(ce)){const Ee=ce.replace("ext-","");t(`/external/${Ee}`)}else{const Ee=he.get(ce);Ee&&t(Ee.to)}return}switch(K.key){case"?":K.preventDefault(),b(!0);break;case"Escape":b(!1);break}}},[t,oe,he]);return w.useEffect(()=>(document.addEventListener("keydown",J),()=>document.removeEventListener("keydown",J)),[J]),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(nfe,{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(K=>{if(oT(K)){const I=me.get(K);if(!I)return null;const ce=I.custom_icon?null:mN(I.icon);return s.jsx("li",{draggable:!0,onDragStart:Ee=>Ae(Ee,K),onDragOver:Ee=>ge(Ee,K),onDragLeave:Ne,onDrop:Ee=>_e(Ee,K),onDragEnd:le,className:`relative ${M===K?"opacity-50":""} ${A===K&&M!==K?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:s.jsxs(Lb,{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(gg,{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})]})},K)}else{const I=he.get(K);if(!I)return null;const{to:ce,icon:Ee,labelKey:Ie}=I,ue=K==="queue"&&ee>0,$=K==="archives"&&V>0,L=ue?ee:$?V:0,Y=ue||$;return s.jsx("li",{draggable:!0,onDragStart:pe=>Ae(pe,K),onDragOver:pe=>ge(pe,K),onDragLeave:Ne,onDrop:pe=>_e(pe,K),onDragEnd:le,className:`relative ${M===K?"opacity-50":""} ${A===K&&M!==K?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:s.jsxs(Lb,{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(gg,{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 ${$?"bg-blue-500 text-white":"bg-yellow-500 text-black"}`,children:L>99?"99+":L})]}),(a||u)&&s.jsx("span",{children:i(Ie)})]})},K)}})})}),!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(Ff,{className:"w-5 h-5"}):s.jsx(Qs,{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:[G&&s.jsxs("div",{className:"relative",children:[s.jsx("button",{onMouseEnter:()=>x(!0),className:`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${y?"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"})}),y&&s.jsx(Jz,{onClose:()=>x(!1)})]}),s.jsx(Lb,{to:"/system",className:({isActive:K})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${K?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:s.jsx(Ql,{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(Wz,{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(gP,{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(Yz,{className:"w-5 h-5"}):s.jsx(Dw,{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(bP,{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",O?.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(iT,{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(iT,{className:"w-5 h-5"})}),G&&s.jsxs("div",{className:"relative",children:[s.jsx("button",{onMouseEnter:()=>x(!0),className:`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${y?"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"})}),y&&s.jsx(Jz,{onClose:()=>x(!1)})]}),s.jsx(Lb,{to:"/system",className:({isActive:K})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${K?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:s.jsx(Ql,{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(Wz,{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(gP,{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(Yz,{className:"w-5 h-5"}):s.jsx(Dw,{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(bP,{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:[Z?.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(JM,{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"}),ne!==null&&s.jsxs("span",{className:"text-amber-300/70 ml-2",children:["(",Math.floor(ne/60),"m ",ne%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"})})]})}),He&&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(iT,{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:H,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:i("common.dismiss",{defaultValue:"Dismiss"}),children:s.jsx(Ht,{className:"w-4 h-4"})})]}),s.jsx(sce,{})]}),p&&s.jsx(zme,{onClose:()=>b(!1),sidebarItems:oe.map(K=>{if(oT(K)){const B=me.get(K);return B?{type:"external",label:B.name}:null}else{const B=he.get(K);return B?{type:"nav",label:B.labelKey,labelKey:B.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 n0(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 bg(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 yg(t,e="system",n){const r=Si(t);if(!r)return"";const a=n0(n??{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"},e);return r.toLocaleString(void 0,a)}function Kme(t,e="system",n){const i=n0({...{hour:"2-digit",minute:"2-digit"},...n},e);return t.toLocaleTimeString([],i)}const PK=w.createContext(void 0);function Yn(){const t=w.useContext(PK);if(!t)throw new Error("useToast must be used within a ToastProvider");return t}const Xme={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(Ql,{className:"w-5 h-5 text-blue-400"}),loading:s.jsx(mt,{className:"w-5 h-5 text-bambu-green animate-spin"})},Yme={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 Qme({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(PK.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 ${Yme[o.type]}`,children:[Xme[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(Ht,{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 tB(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 Jme(t,e){if(e)return fK;switch(t.toLowerCase().split(".").pop()||""){case"3mf":return wf;case"gcode":return Ya;case"mp4":case"avi":return Fd;case"png":case"jpg":case"jpeg":return yy;default:return rN}}const epe=[{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 tpe({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"),[y,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:v,isLoading:S,refetch:M}=ft({queryKey:["printerFiles",t,a],queryFn:()=>fe.getPrinterFiles(t,a)}),{data:E}=ft({queryKey:["printerStorage",t],queryFn:()=>fe.getPrinterStorage(t),staleTime:3e4}),A=pt({mutationFn:async j=>{for(const W of j)await fe.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)},T=()=>{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(X=>{const G=new Set(X);return G.has(j)?G.delete(j):G.add(j),G})},C=()=>{if(!v?.files)return;const j=v.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(fe.getPrinterFileDownloadUrl(t,j[0]),"_blank"),c(new Set);return}x({current:0,total:j.length});try{const W=await fe.downloadPrinterFilesAsZip(t,j),X=URL.createObjectURL(W),G=document.createElement("a");G.href=X,G.download=`${e.replace(/[^a-zA-Z0-9]/g,"_")}-files.zip`,document.body.appendChild(G),G.click(),document.body.removeChild(G),URL.revokeObjectURL(X),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)}},O=()=>{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(sN,{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:[E&&(E.used_bytes!=null||E.free_bytes!=null)&&s.jsxs("div",{className:"text-sm text-bambu-gray flex items-center gap-2",children:[E.used_bytes!=null&&s.jsxs("span",{children:["Used: ",tB(E.used_bytes)]}),E.used_bytes!=null&&E.free_bytes!=null&&s.jsx("span",{className:"text-bambu-dark-tertiary",children:"|"}),E.free_bytes!=null&&s.jsxs("span",{children:["Free: ",tB(E.free_bytes)]})]}),s.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Ht,{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(Ma,{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(cK,{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:epe.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:T,disabled:a==="/",className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-50 disabled:cursor-not-allowed",children:s.jsx(Ff,{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"})}):v?.files?.length?s.jsx("div",{className:"space-y-1",children:[...v.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 X=j.mtime?new Date(j.mtime).getTime():0,G=W.mtime?new Date(W.mtime).getTime():0;return X-G}case"date-desc":{const X=j.mtime?new Date(j.mtime).getTime():0;return(W.mtime?new Date(W.mtime).getTime():0)-X}default:return j.name.localeCompare(W.name)}}).map(j=>{const W=Jme(j.name,j.is_directory),X=l.has(j.path);return s.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg cursor-pointer transition-colors ${X?"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:G=>D(j.path,G),className:"flex-shrink-0 text-bambu-gray hover:text-white",children:X?s.jsx(Do,{className:"w-5 h-5 text-bambu-green"}):s.jsx(Oo,{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(Ff,{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?`${v?.files?.filter(j=>j.name.toLowerCase().includes(u.toLowerCase())).length||0} of ${v?.files?.length||0} items`:`${v?.files?.length||0} items`}),v?.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(Qfe,{className:"w-4 h-4"}),"Deselect All"]}):s.jsxs("button",{onClick:C,className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors",children:[s.jsx(Do,{className:"w-4 h-4"}),"Select All"]})})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Me,{variant:"secondary",disabled:l.size===0||y!==null,onClick:U,children:y?s.jsxs(s.Fragment,{children:[s.jsx(mt,{className:"w-4 h-4 animate-spin"}),y.current,"/",y.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:O,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 npe="embeddedCameraState_",nB=5,rpe=2e3,ipe=3e4,ape=5e3,lT={x:window.innerWidth-420,y:20,width:400,height:300};function spe({printerId:t,printerName:e,viewerIndex:n=0,onClose:r}){const i=`${npe}${t}`,a=()=>{try{const ye=localStorage.getItem(i);if(ye){const ke=JSON.parse(ye);return{x:Math.min(Math.max(0,ke.x),window.innerWidth-100),y:Math.min(Math.max(0,ke.y),window.innerHeight-100),width:Math.max(200,Math.min(ke.width,window.innerWidth-20)),height:Math.max(150,Math.min(ke.height,window.innerHeight-20))}}}catch{}const se=n*30;return{...lT,x:Math.max(0,lT.x-se),y:Math.max(0,lT.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,y]=w.useState(!1),[x,v]=w.useState(!1),[S,M]=w.useState(1),[E,A]=w.useState({x:0,y:0}),[k,T]=w.useState(!1),[D,C]=w.useState({x:0,y:0}),[R,U]=w.useState(null),[O,q]=w.useState(null),[j,W]=w.useState(!1),[X,G]=w.useState(!0),[Z,te]=w.useState(Date.now()),[ee,z]=w.useState(0),[V,ne]=w.useState(!1),[ie,he]=w.useState(0),me=w.useRef(null),oe=w.useRef(null),Ae=w.useRef(null),ge=w.useRef(null),Ne=w.useRef(null),{data:_e}=ft({queryKey:["printer",t],queryFn:()=>fe.getPrinter(t),enabled:t>0});w.useEffect(()=>{const se=setTimeout(()=>{localStorage.setItem(i,JSON.stringify(o))},500);return()=>clearTimeout(se)},[o,i]);const le=w.useRef(!1);w.useEffect(()=>{le.current=!1;const se=`/api/v1/printers/${t}/camera/stop`,ye=()=>{t>0&&!le.current&&(le.current=!0,navigator.sendBeacon(se))},ke=oe.current;return()=>{ke&&(ke.src=""),ye(),Ae.current&&clearTimeout(Ae.current),ge.current&&clearInterval(ge.current),Ne.current&&clearInterval(Ne.current)}},[t]),w.useEffect(()=>{if(X){const se=setTimeout(()=>G(!1),3e3);return()=>clearTimeout(se)}},[X,Z]);const He=w.useCallback(()=>{if(ee>=nB){ne(!1),W(!0);return}const se=Math.min(rpe*Math.pow(2,ee),ipe);ne(!0),he(Math.ceil(se/1e3)),ge.current=setInterval(()=>{he(ye=>ye<=1?(ge.current&&clearInterval(ge.current),0):ye-1)},1e3),Ae.current=setTimeout(()=>{z(ye=>ye+1),ne(!1),G(!0),W(!1),oe.current&&(oe.current.src=""),te(Date.now())},se)},[ee]);w.useEffect(()=>{if(X||V||b){Ne.current&&(clearInterval(Ne.current),Ne.current=null);return}return Ne.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)&&(Ne.current&&(clearInterval(Ne.current),Ne.current=null),G(!1),He())}}catch{}},ape),()=>{Ne.current&&(clearInterval(Ne.current),Ne.current=null)}},[X,j,V,b,t,He]),w.useEffect(()=>{const se=()=>{const ye=!!document.fullscreenElement;v(ye),ye||(M(1),A({x:0,y:0}))};return document.addEventListener("fullscreenchange",se),()=>document.removeEventListener("fullscreenchange",se)},[]);const H=()=>{me.current&&(document.fullscreenElement?document.exitFullscreen():me.current.requestFullscreen())},J=()=>{M(se=>Math.min(se+.5,4))},K=()=>{M(se=>{const ye=Math.max(se-.5,1);return ye===1&&A({x:0,y:0}),ye})},B=se=>{se.preventDefault(),se.deltaY<0?J():K()},I=se=>{S>1&&(se.preventDefault(),T(!0),C({x:se.clientX-E.x,y:se.clientY-E.y}))},ce=w.useCallback(()=>{if(!me.current||!oe.current)return{x:200,y:150};const se=me.current.getBoundingClientRect(),ye=se.width*(S-1)/2,ke=se.height*(S-1)/2;return{x:Math.max(50,ye),y:Math.max(50,ke)}},[S]),Ee=se=>{if(k&&S>1){const ye=se.clientX-D.x,ke=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,ke))})}},Ie=()=>{T(!1)},ue=se=>{if(se.length<2)return 0;const ye=se[0].clientX-se[1].clientX,ke=se[0].clientY-se[1].clientY;return Math.sqrt(ye*ye+ke*ke)},$=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},L=se=>{se.touches.length===2?(se.preventDefault(),U(ue(se.touches)),q($(se.touches))):se.touches.length===1&&S>1&&(se.preventDefault(),T(!0),C({x:se.touches[0].clientX-E.x,y:se.touches[0].clientY-E.y}))},Y=se=>{if(se.touches.length===2&&R!==null){se.preventDefault();const ye=ue(se.touches),ke=ye/R;M(dt=>{const re=Math.max(1,Math.min(4,dt*ke));return re===1&&A({x:0,y:0}),re}),U(ye);const Ue=$(se.touches);if(O){const dt=ce();A(re=>({x:Math.max(-dt.x,Math.min(dt.x,re.x+(Ue.x-O.x))),y:Math.max(-dt.y,Math.min(dt.y,re.y+(Ue.y-O.y)))}))}q(Ue)}else if(se.touches.length===1&&k&&S>1){se.preventDefault();const ye=se.touches[0].clientX-D.x,ke=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,ke))})}},pe=se=>{se.touches.length<2&&(U(null),q(null)),se.touches.length===0&&T(!1)},Se=()=>{M(1),A({x:0,y:0})},ae=()=>{G(!1),ee<nB?He():W(!0)},je=()=>{G(!1),W(!1),z(0),ne(!1),Ae.current&&clearTimeout(Ae.current),ge.current&&clearInterval(ge.current)},De=()=>{G(!0),W(!1),z(0),ne(!1),Ae.current&&clearTimeout(Ae.current),ge.current&&clearInterval(ge.current),fetch(`/api/v1/printers/${t}/camera/stop`).catch(()=>{}),oe.current&&(oe.current.src=""),setTimeout(()=>te(Date.now()),100)},Xe=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=ke=>{if(c)l(Ue=>({...Ue,x:Math.max(0,Math.min(ke.clientX-m.x,window.innerWidth-Ue.width)),y:Math.max(0,Math.min(ke.clientY-m.y,window.innerHeight-Ue.height))}));else if(d&&me.current){const Ue=me.current.getBoundingClientRect();l(dt=>({...dt,width:Math.max(200,Math.min(ke.clientX-Ue.left,window.innerWidth-dt.x-10)),height:Math.max(150,Math.min(ke.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 Qe=`/api/v1/printers/${t}/camera/stream?fps=10&t=${Z}`;return s.jsxs("div",{ref:me,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:Xe,children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-white truncate",children:[s.jsx(gg,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"truncate",children:_e?.name||e})]}),s.jsxs("div",{className:"flex items-center gap-1 no-drag",children:[s.jsx("button",{onClick:De,disabled:X||V,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 ${X?"animate-spin":""}`})}),s.jsx("button",{onClick:H,className:"p-1 hover:bg-bambu-dark-tertiary rounded",title:x?"Exit fullscreen":"Fullscreen",children:x?s.jsx(bK,{className:"w-3.5 h-3.5 text-bambu-gray"}):s.jsx(ohe,{className:"w-3.5 h-3.5 text-bambu-gray"})}),s.jsx("button",{onClick:()=>y(!b),className:"p-1 hover:bg-bambu-dark-tertiary rounded",title:b?"Expand":"Minimize",children:b?s.jsx(gK,{className:"w-3.5 h-3.5 text-bambu-gray"}):s.jsx(xK,{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(Ht,{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:B,onMouseMove:Ee,onMouseUp:Ie,onMouseLeave:Ie,onTouchStart:L,onTouchMove:Y,onTouchEnd:pe,style:{touchAction:"none"},children:[X&&!V&&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"})}),V&&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(Qg,{className:"w-6 h-6 text-orange-400 mx-auto mb-2"}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:["Reconnecting in ",ie,"s..."]})]})}),j&&!V&&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:Qe,alt:"Camera stream",className:"max-w-full max-h-full object-contain select-none",style:{transform:`scale(${S}) translate(${E.x/S}px, ${E.y/S}px)`,cursor:S>1?k?"grabbing":"grab":"default"},onError:ae,onLoad:je,onMouseDown:I,draggable:!1},Z),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:K,disabled:S<=1,className:"p-1 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom out",children:s.jsx(GD,{className:"w-3.5 h-3.5 text-white"})}),s.jsxs("button",{onClick:Se,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:J,disabled:S>=4,className:"p-1 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom in",children:s.jsx(VD,{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 ope({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:y}=ft({queryKey:["mqtt-logs",t],queryFn:()=>fe.getMQTTLogs(t),refetchInterval:1e3}),x=pt({mutationFn:()=>fe.enableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),v=pt({mutationFn:()=>fe.disableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),S=pt({mutationFn:()=>fe.clearMQTTLogs(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}});w.useEffect(()=>{const C=R=>{R.key==="Escape"&&n()};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[n]),w.useEffect(()=>{i&&m.current&&(m.current.scrollTop=m.current.scrollHeight)},[p?.logs,i]);const M=C=>{l(R=>{const U=new Set(R);return U.has(C)?U.delete(C):U.add(C),U})},E=C=>new Date(C).toLocaleTimeString("en-US",{hour12:!1,fractionalSecondDigits:3}),A=(C,R)=>{if(C==null)return"<empty>";const U=typeof C=="string"?JSON.parse(C):C,O=JSON.stringify(U,null,R?2:0);return!R&&O.length>100?O.substring(0,100)+"...":O},k=p?.logging_enabled??!1,T=w.useMemo(()=>p?.logs??[],[p?.logs]),D=w.useMemo(()=>T.filter(C=>{if(d!=="all"&&C.direction!==d)return!1;if(c.trim()){const R=c.toLowerCase(),U=C.topic.toLowerCase().includes(R),q=JSON.stringify(C.payload).toLowerCase().includes(R);return U||q}return!0}),[T,c,d]);return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg max-w-4xl w-full max-h-[85vh] flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:"MQTT Debug Log"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:e})]}),s.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Ht,{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:()=>v.mutate(),disabled:v.isPending,children:[s.jsx(Oo,{className:"w-4 h-4"}),"Stop"]}):s.jsxs(Me,{size:"sm",onClick:()=>x.mutate(),disabled:x.isPending,children:[s.jsx(cl,{className:"w-4 h-4"}),"Start Logging"]}),s.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>S.mutate(),disabled:S.isPending||T.length===0,children:[s.jsx(hn,{className:"w-4 h-4"}),"Clear"]}),s.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>y(),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:C=>a(C.target.checked),className:"rounded border-bambu-dark-tertiary"}),"Auto-scroll"]}),s.jsxs("span",{className:"text-sm text-bambu-gray",children:[D.length,"/",T.length]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(Ma,{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:C=>u(C.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(Ht,{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(T0,{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(fg,{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:T.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[s.jsx("p",{className:"mb-2",children:"No messages logged yet"}),!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((C,R)=>{const U=o.has(R),O=C.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:E(C.timestamp)}),s.jsx("span",{className:`shrink-0 ${O?"text-blue-400":"text-green-400"}`,title:O?"Incoming":"Outgoing",children:O?s.jsx(T0,{className:"w-3 h-3"}):s.jsx(fg,{className:"w-3 h-3"})}),s.jsx("span",{className:"text-purple-400 shrink-0",children:C.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(C.payload,!0)}):s.jsx("pre",{className:"mt-1 text-white/80 truncate",children:A(C.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 SP={"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 lpe(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:Ql}}}function MP(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 cpe(t){return t.filter(e=>{const n=parseInt(e.code.replace("0x",""),16)||0,r=MP(e.attr,n);return SP[r]!==void 0})}function upe(){return"https://wiki.bambulab.com/en/hms/home"}function dpe({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=MP(i.attr,a);return SP[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(Ht,{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}=lpe(i.severity),d=parseInt(i.code.replace("0x",""),16)||0,f=MP(i.attr,d),m=SP[f],p=upe(),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 hpe(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 fpe({printerId:t}){const{data:e}=ft({queryKey:["queue",t,"pending"],queryFn:()=>fe.getQueue(t,"pending"),refetchInterval:3e4}),n=e?.[0],r=e?.length||0;return r===0?null:s.jsx(gs,{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"}),hpe(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(Qs,{className:"w-4 h-4 text-bambu-gray"})]})]})})}function RK(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=RK(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=RK(t))&&(r&&(r+=" "),r+=e);return r}var mpe=["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 WD(t){if(typeof t!="string")return!1;var e=mpe;return e.includes(t)}var ppe=["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"],gpe=new Set(ppe);function DK(t){return typeof t!="string"?!1:gpe.has(t)}function OK(t){return typeof t=="string"&&t.startsWith("data-")}function ns(t){if(typeof t!="object"||t===null)return{};var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(DK(n)||OK(n))&&(e[n]=t[n]);return e}function Hf(t){if(t==null)return null;if(w.isValidElement(t)&&typeof t.props=="object"&&t.props!==null){var e=t.props;return ns(e)}return typeof t=="object"&&!Array.isArray(t)?ns(t):null}function Aa(t){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(DK(n)||OK(n)||WD(n))&&(e[n]=t[n]);return e}function xpe(t){return t==null?null:w.isValidElement(t)?Aa(t.props):typeof t=="object"&&!Array.isArray(t)?Aa(t):null}var bpe=["children","width","height","viewBox","className","style","title","desc"];function NP(){return NP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},NP.apply(null,arguments)}function ype(t,e){if(t==null)return{};var n,r,i=vpe(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 vpe(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 qD=w.forwardRef((t,e)=>{var{children:n,width:r,height:i,viewBox:a,className:o,style:l,title:c,desc:u}=t,d=ype(t,bpe),f=a||{width:r,height:i,x:0,y:0},m=Bn("recharts-surface",o);return w.createElement("svg",NP({},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)}),_pe=["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 wpe(t,e){if(t==null)return{};var n,r,i=Spe(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 Spe(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=wpe(t,_pe),a=Bn("recharts-layer",r);return w.createElement("g",EP({className:a},Aa(i),{ref:e}),n)}),LK=w.createContext(null),Mpe=()=>w.useContext(LK);function Er(t){return function(){return t}}const IK=Math.cos,Fw=Math.sin,gl=Math.sqrt,Uw=Math.PI,pN=2*Uw,AP=Math.PI,TP=2*AP,Yh=1e-6,Npe=TP-Yh;function FK(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 FK;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 Ape{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=e==null?FK: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>Yh)if(!(Math.abs(f*c-u*d)>Yh)||!a)this._append`L${this._x1=e},${this._y1=n}`;else{let p=r-o,b=i-l,y=c*c+u*u,x=p*p+b*b,v=Math.sqrt(y),S=Math.sqrt(m),M=a*Math.tan((AP-Math.acos((y+m-x)/(2*v*S)))/2),E=M/S,A=M/v;Math.abs(E-1)>Yh&&this._append`L${e+E*d},${n+E*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)>Yh||Math.abs(this._y1-d)>Yh)&&this._append`L${u},${d}`,r&&(m<0&&(m=m%TP+TP),m>Npe?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>Yh&&this._append`A${r},${r},0,${+(m>=AP)},${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 KD(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 Ape(e)}function XD(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function UK(t){this._context=t}UK.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 gN(t){return new UK(t)}function zK(t){return t[0]}function BK(t){return t[1]}function $K(t,e){var n=Er(!0),r=null,i=gN,a=null,o=KD(l);t=typeof t=="function"?t:t===void 0?zK:Er(t),e=typeof e=="function"?e:e===void 0?BK:Er(e);function l(c){var u,d=(c=XD(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:Er(+c),l):t},l.y=function(c){return arguments.length?(e=typeof c=="function"?c:Er(+c),l):e},l.defined=function(c){return arguments.length?(n=typeof c=="function"?c:Er(!!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 p_(t,e,n){var r=null,i=Er(!0),a=null,o=gN,l=null,c=KD(u);t=typeof t=="function"?t:t===void 0?zK:Er(+t),e=typeof e=="function"?e:Er(e===void 0?0:+e),n=typeof n=="function"?n:n===void 0?BK:Er(+n);function u(f){var m,p,b,y=(f=XD(f)).length,x,v=!1,S,M=new Array(y),E=new Array(y);for(a==null&&(l=o(S=c())),m=0;m<=y;++m){if(!(m<y&&i(x=f[m],m,f))===v)if(v=!v)p=m,l.areaStart(),l.lineStart();else{for(l.lineEnd(),l.lineStart(),b=m-1;b>=p;--b)l.point(M[b],E[b]);l.lineEnd(),l.areaEnd()}v&&(M[m]=+t(x,m,f),E[m]=+e(x,m,f),l.point(r?+r(x,m,f):M[m],n?+n(x,m,f):E[m]))}if(S)return l=null,S+""||null}function d(){return $K().defined(i).curve(o).context(a)}return u.x=function(f){return arguments.length?(t=typeof f=="function"?f:Er(+f),r=null,u):t},u.x0=function(f){return arguments.length?(t=typeof f=="function"?f:Er(+f),u):t},u.x1=function(f){return arguments.length?(r=f==null?null:typeof f=="function"?f:Er(+f),u):r},u.y=function(f){return arguments.length?(e=typeof f=="function"?f:Er(+f),n=null,u):e},u.y0=function(f){return arguments.length?(e=typeof f=="function"?f:Er(+f),u):e},u.y1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:Er(+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:Er(!!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 HK{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 Tpe(t){return new HK(t,!0)}function Cpe(t){return new HK(t,!1)}const YD={draw(t,e){const n=gl(e/Uw);t.moveTo(n,0),t.arc(0,0,n,0,pN)}},kpe={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()}},VK=gl(1/3),jpe=VK*2,Ppe={draw(t,e){const n=gl(e/jpe),r=n*VK;t.moveTo(0,-n),t.lineTo(r,0),t.lineTo(0,n),t.lineTo(-r,0),t.closePath()}},Rpe={draw(t,e){const n=gl(e),r=-n/2;t.rect(r,r,n,n)}},Dpe=.8908130915292852,GK=Fw(Uw/10)/Fw(7*Uw/10),Ope=Fw(pN/10)*GK,Lpe=-IK(pN/10)*GK,Ipe={draw(t,e){const n=gl(e*Dpe),r=Ope*n,i=Lpe*n;t.moveTo(0,-n),t.lineTo(r,i);for(let a=1;a<5;++a){const o=pN*a/5,l=IK(o),c=Fw(o);t.lineTo(c*n,-l*n),t.lineTo(l*r-c*i,c*r+l*i)}t.closePath()}},cT=gl(3),Fpe={draw(t,e){const n=-gl(e/(cT*3));t.moveTo(0,n*2),t.lineTo(-cT*n,-n),t.lineTo(cT*n,-n),t.closePath()}},uo=-.5,ho=gl(3)/2,CP=1/gl(12),Upe=(CP/2+1)*3,zpe={draw(t,e){const n=gl(e/Upe),r=n/2,i=n*CP,a=r,o=n*CP+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 Bpe(t,e){let n=null,r=KD(i);t=typeof t=="function"?t:Er(t||YD),e=typeof e=="function"?e:Er(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:Er(a),i):t},i.size=function(a){return arguments.length?(e=typeof a=="function"?a:Er(+a),i):e},i.context=function(a){return arguments.length?(n=a??null,i):n},i}function zw(){}function Bw(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 WK(t){this._context=t}WK.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:Bw(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:Bw(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:zw,areaEnd:zw,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:Bw(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: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:Bw(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function Vpe(t){return new KK(t)}function XK(t){this._context=t}XK.prototype={areaStart:zw,areaEnd:zw,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 Gpe(t){return new XK(t)}function rB(t){return t<0?-1:1}function iB(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(rB(a)+rB(o))*Math.min(Math.abs(a),Math.abs(o),.5*Math.abs(l))||0}function aB(t,e){var n=t._x1-t._x0;return n?(3*(t._y1-t._y0)/n-e)/2:e}function uT(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 $w(t){this._context=t}$w.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:uT(this,this._t0,aB(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,uT(this,aB(this,n=iB(this,t,e)),n);break;default:uT(this,this._t0,n=iB(this,t,e));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e,this._t0=n}}};function YK(t){this._context=new QK(t)}(YK.prototype=Object.create($w.prototype)).point=function(t,e){$w.prototype.point.call(this,e,t)};function QK(t){this._context=t}QK.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 Wpe(t){return new $w(t)}function qpe(t){return new YK(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=sB(t),i=sB(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 sB(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 Kpe(t){return new ZK(t)}function xN(t,e){this._context=t,this._t=e}xN.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 Xpe(t){return new xN(t,.5)}function Ype(t){return new xN(t,0)}function Qpe(t){return new xN(t,1)}function Vf(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 kP(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 Jpe(t){const e=[];return e.key=t,e}function ege(){var t=Er([]),e=kP,n=Vf,r=Zpe;function i(a){var o=Array.from(t.apply(this,arguments),Jpe),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=XD(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:Er(Array.from(a)),i):t},i.value=function(a){return arguments.length?(r=typeof a=="function"?a:Er(+a),i):r},i.order=function(a){return arguments.length?(e=a==null?kP:typeof a=="function"?a:Er(Array.from(a)),i):e},i.offset=function(a){return arguments.length?(n=a??Vf,i):n},i}function tge(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}Vf(t,e)}}function nge(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}Vf(t,e)}}function rge(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 y=t[e[b]],x=y[r][1]||0,v=y[r-1][1]||0;p+=x-v}c+=f,u+=p*f}i[r-1][1]+=i[r-1][0]=n,c&&(n-=u/c)}i[r-1][1]+=i[r-1][0]=n,Vf(t,e)}}var dT={},hT={},oB;function ige(){return oB||(oB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==="__proto__"}t.isUnsafeProperty=e})(hT)),hT}var fT={},lB;function JK(){return lB||(lB=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})(fT)),fT}var mT={},cB;function QD(){return cB||(cB=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})(mT)),mT}var pT={},gT={},uB;function age(){return uB||(uB=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})(gT)),gT}var dB;function ZD(){return dB||(dB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=age(),n=QD();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})(pT)),pT}var hB;function JD(){return hB||(hB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=ige(),n=JK(),r=QD(),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})(dT)),dT}var xT,fB;function sge(){return fB||(fB=1,xT=JD().get),xT}var oge=sge();const Gf=ml(oge);var lge=4;function Cd(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:lge,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+Cd(l)+a:i+a},"")}var ea=t=>t===0?0:t>0?1:-1,ul=t=>typeof t=="number"&&t!=+t,Wf=t=>typeof t=="string"&&t.indexOf("%")===t.length-1,zt=t=>(typeof t=="number"||t instanceof Number)&&!ul(t),Lo=t=>zt(t)||typeof t=="string",cge=0,j0=t=>{var e=++cge;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(Wf(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},eX=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)?Cd(t+n*(e-t)):e}function tX(t,e,n){if(!(!t||!t.length))return t.find(r=>r&&(typeof e=="function"?e(r):Gf(r,e))===n)}var Hr=t=>t===null||typeof t>"u",vy=t=>Hr(t)?t:"".concat(t.charAt(0).toUpperCase()).concat(t.slice(1));function vs(t){return t!=null}function uh(){}var uge=["type","size","sizeType"];function jP(){return jP=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},jP.apply(null,arguments)}function mB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function pB(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?mB(Object(n),!0).forEach(function(r){dge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):mB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function dge(t,e,n){return(e=hge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function hge(t){var e=fge(t,"string");return typeof e=="symbol"?e:e+""}function fge(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function mge(t,e){if(t==null)return{};var n,r,i=pge(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 pge(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 nX={symbolCircle:YD,symbolCross:kpe,symbolDiamond:Ppe,symbolSquare:Rpe,symbolStar:Ipe,symbolTriangle:Fpe,symbolWye:zpe},gge=Math.PI/180,xge=t=>{var e="symbol".concat(vy(t));return nX[e]||YD},bge=(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*gge;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}},yge=(t,e)=>{nX["symbol".concat(vy(t))]=e},eO=t=>{var{type:e="circle",size:n=64,sizeType:r="area"}=t,i=mge(t,uge),a=pB(pB({},i),{},{type:e,size:n,sizeType:r}),o="circle";typeof e=="string"&&(o=e);var l=()=>{var m=xge(o),p=Bpe().type(m).size(bge(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",jP({},f,{className:Bn("recharts-symbols",c),transform:"translate(".concat(u,", ").concat(d,")"),d:l()})):null};eO.registerSymbol=yge;var rX=t=>"radius"in t&&"startAngle"in t&&"endAngle"in t,tO=(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=>{WD(i)&&(r[i]=(a=>n[i](n,a)))}),r},vge=(t,e,n)=>r=>(t(e,n,r),null),_y=(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];WD(i)&&typeof a=="function"&&(r||(r={}),r[i]=vge(a,e,n))}),r};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 _ge(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){wge(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 wge(t,e,n){return(e=Sge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Sge(t){var e=Mge(t,"string");return typeof e=="symbol"?e:e+""}function Mge(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=_ge({},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 Hw(){return Hw=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Hw.apply(null,arguments)}function xB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Nge(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?xB(Object(n),!0).forEach(function(r){Ege(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):xB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Ege(t,e,n){return(e=Age(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Age(t){var e=Tge(t,"string");return typeof e=="symbol"?e:e+""}function Tge(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,Cge={align:"center",iconSize:14,inactiveColor:"#ccc",layout:"horizontal",verticalAlign:"middle"};function kge(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,`
- A`).concat(a,",").concat(a,",0,1,1,").concat(2*o,",").concat(i,`
- H`).concat(xo,"M").concat(2*o,",").concat(i,`
- 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=Nge({},e);return delete d.legendIcon,w.cloneElement(e.legendIcon,d)}return w.createElement(eO,{fill:l,cx:i,cy:i,size:xo,sizeType:"diameter",type:c})}function jge(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,y=m?m(d.value,d,f):d.value;return w.createElement("li",Hw({className:p,style:c,key:"legend-item-".concat(f)},_y(t,d,f)),w.createElement(qD,{width:n,height:n,viewBox:l,style:u,"aria-label":"".concat(y," legend icon")},w.createElement(kge,{data:d,iconType:o,inactiveColor:a})),w.createElement("span",{className:"recharts-legend-item-text",style:{color:b}},y))})}var Pge=t=>{var e=Kr(t,Cge),{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(jge,Hw({},e,{payload:n})))},bT={},yT={},bB;function Rge(){return bB||(bB=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})(yT)),yT}var vT={},yB;function Dge(){return yB||(yB=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})(vT)),vT}var _T={},vB;function iX(){return vB||(vB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n}t.identity=e})(_T)),_T}var wT={},ST={},MT={},_B;function Oge(){return _B||(_B=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Number.isSafeInteger(n)&&n>=0}t.isLength=e})(MT)),MT}var wB;function nO(){return wB||(wB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Oge();function n(r){return r!=null&&typeof r!="function"&&e.isLength(r.length)}t.isArrayLike=n})(ST)),ST}var NT={},SB;function Lge(){return SB||(SB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="object"&&n!==null}t.isObjectLike=e})(NT)),NT}var MB;function Ige(){return MB||(MB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=nO(),n=Lge();function r(i){return n.isObjectLike(i)&&e.isArrayLike(i)}t.isArrayLikeObject=r})(wT)),wT}var ET={},AT={},NB;function Fge(){return NB||(NB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=JD();function n(r){return function(i){return e.get(i,r)}}t.property=n})(AT)),AT}var TT={},CT={},kT={},jT={},EB;function aX(){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})(jT)),jT}var PT={},AB;function sX(){return AB||(AB=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})(PT)),PT}var RT={},TB;function oX(){return TB||(TB=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})(RT)),RT}var CB;function Uge(){return CB||(CB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=aX(),n=sX(),r=oX();function i(d,f,m){return typeof m!="function"?i(d,f,()=>{}):a(d,f,function p(b,y,x,v,S,M){const E=m(b,y,x,v,S,M);return E!==void 0?!!E:a(b,y,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 y=0;y<b.length;y++){const x=b[y];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,y]of f.entries()){const x=d.get(b);if(m(x,y,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 y=0;y<f.length;y++){const x=f[y];let v=!1;for(let S=0;S<d.length;S++){if(b.has(S))continue;const M=d[S];let E=!1;if(m(M,x,y,d,f,p)&&(E=!0),E){b.add(S),v=!0;break}}if(!v)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})(kT)),kT}var kB;function lX(){return kB||(kB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Uge();function n(r,i){return e.isMatchWith(r,i,()=>{})}t.isMatch=n})(CT)),CT}var DT={},OT={},LT={},jB;function zge(){return jB||(jB=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})(LT)),LT}var IT={},PB;function rO(){return PB||(PB=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})(IT)),IT}var FT={},RB;function cX(){return RB||(RB=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]",y="[object DataView]",x="[object Uint8Array]",v="[object Uint8ClampedArray]",S="[object Uint16Array]",M="[object Uint32Array]",E="[object BigUint64Array]",A="[object Int8Array]",k="[object Int16Array]",T="[object Int32Array]",D="[object BigInt64Array]",C="[object Float32Array]",R="[object Float64Array]";t.argumentsTag=a,t.arrayBufferTag=m,t.arrayTag=d,t.bigInt64ArrayTag=D,t.bigUint64ArrayTag=E,t.booleanTag=i,t.dataViewTag=y,t.dateTag=l,t.errorTag=b,t.float32ArrayTag=C,t.float64ArrayTag=R,t.functionTag=f,t.int16ArrayTag=k,t.int32ArrayTag=T,t.int8ArrayTag=A,t.mapTag=c,t.numberTag=r,t.objectTag=p,t.regexpTag=e,t.setTag=u,t.stringTag=n,t.symbolTag=o,t.uint16ArrayTag=S,t.uint32ArrayTag=M,t.uint8ArrayTag=x,t.uint8ClampedArrayTag=v})(FT)),FT}var UT={},DB;function Bge(){return DB||(DB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}t.isTypedArray=e})(UT)),UT}var OB;function uX(){return OB||(OB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=zge(),n=rO(),r=cX(),i=sX(),a=Bge();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 y=b?.(d,f,m,p);if(y!==void 0)return y;if(i.isPrimitive(d))return d;if(p.has(d))return p.get(d);if(Array.isArray(d)){const x=new Array(d.length);p.set(d,x);for(let v=0;v<d.length;v++)x[v]=l(d[v],v,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[v,S]of d)x.set(v,l(S,v,m,p,b));return x}if(d instanceof Set){const x=new Set;p.set(d,x);for(const v of d)x.add(l(v,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 v=0;v<d.length;v++)x[v]=l(d[v],v,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 y=[...Object.keys(f),...e.getSymbols(f)];for(let x=0;x<y.length;x++){const v=y[x],S=Object.getOwnPropertyDescriptor(d,v);(S==null||S.writable)&&(d[v]=l(f[v],v,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})(OT)),OT}var LB;function $ge(){return LB||(LB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=uX();function n(r){return e.cloneDeepWithImpl(r,void 0,r,new Map,void 0)}t.cloneDeep=n})(DT)),DT}var IB;function Hge(){return IB||(IB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=lX(),n=$ge();function r(i){return i=n.cloneDeep(i),a=>e.isMatch(a,i)}t.matches=r})(TT)),TT}var zT={},BT={},$T={},FB;function Vge(){return FB||(FB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=uX(),n=rO(),r=cX();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})($T)),$T}var UB;function Gge(){return UB||(UB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Vge();function n(r){return e.cloneDeepWith(r)}t.cloneDeep=n})(BT)),BT}var HT={},VT={},zB;function dX(){return zB||(zB=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})(VT)),VT}var GT={},BB;function Wge(){return BB||(BB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=rO();function n(r){return r!==null&&typeof r=="object"&&e.getTag(r)==="[object Arguments]"}t.isArguments=n})(GT)),GT}var $B;function qge(){return $B||($B=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=JK(),n=dX(),r=Wge(),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})(HT)),HT}var HB;function Kge(){return HB||(HB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=lX(),n=QD(),r=Gge(),i=JD(),a=qge();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})(zT)),zT}var VB;function Xge(){return VB||(VB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=iX(),n=Fge(),r=Hge(),i=Kge();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 GB;function Yge(){return GB||(GB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Rge(),n=Dge(),r=iX(),i=Ige(),a=Xge();function o(l,c=r.identity){return i.isArrayLikeObject(l)?e.uniqBy(Array.from(l),n.ary(a.iteratee(c),1)):[]}t.uniqBy=o})(bT)),bT}var WT,WB;function Qge(){return WB||(WB=1,WT=Yge().uniqBy),WT}var Zge=Qge();const qB=ml(Zge);function hX(t,e,n){return e===!0?qB(t,n):typeof e=="function"?qB(t,e):t}var qT={exports:{}},KT={};var KB;function Jge(){if(KB)return KT;KB=1;var t=Gg(),e=Sq();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 KT.useSyncExternalStoreWithSelector=function(u,d,f,m,p){var b=a(null);if(b.current===null){var y={hasValue:!1,value:null};b.current=y}else y=b.current;b=l(function(){function v(k){if(!S){if(S=!0,M=k,k=m(k),p!==void 0&&y.hasValue){var T=y.value;if(p(T,k))return E=T}return E=k}if(T=E,r(M,k))return T;var D=m(k);return p!==void 0&&p(T,D)?(M=k,T):(M=k,E=D)}var S=!1,M,E,A=f===void 0?null:f;return[function(){return v(d())},A===null?void 0:function(){return v(A())}]},[d,f,m,p]);var x=i(u,b[0],b[1]);return o(function(){y.hasValue=!0,y.value=x},[x]),c(x),x},KT}var XB;function exe(){return XB||(XB=1,qT.exports=Jge()),qT.exports}var fX=exe(),iO=w.createContext(null),txe=t=>t,Mr=()=>{var t=w.useContext(iO);return t?t.store.dispatch:txe},ew=()=>{},nxe=()=>ew,rxe=(t,e)=>t===e;function Gt(t){var e=w.useContext(iO),n=w.useMemo(()=>e?r=>{if(r!=null)return t(r)}:ew,[e,t]);return fX.useSyncExternalStoreWithSelector(e?e.subscription.addNestedSub:nxe,e?e.store.getState:ew,e?e.store.getState:ew,n,rxe)}function ixe(t,e=`expected a function, instead received ${typeof t}`){if(typeof t!="function")throw new TypeError(e)}function axe(t,e=`expected an object, instead received ${typeof t}`){if(typeof t!="object")throw new TypeError(e)}function sxe(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 YB=t=>Array.isArray(t)?t:[t];function oxe(t){const e=Array.isArray(t[0])?t[0]:t;return sxe(e,"createSelector expects all input-selectors to be functions, but received the following types: "),e}function lxe(t,e){const n=[],{length:r}=t;for(let i=0;i<r;i++)n.push(t[i].apply(null,e));return n}var cxe=class{constructor(t){this.value=t}deref(){return this.value}},uxe=typeof WeakRef<"u"?WeakRef:cxe,dxe=0,QB=1;function g_(){return{s:dxe,v:void 0,o:null,p:null}}function mX(t,e={}){let n=g_();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 y=b.get(p);y===void 0?(l=g_(),b.set(p,l)):l=y}else{let b=l.p;b===null&&(l.p=b=new Map);const y=b.get(p);y===void 0?(l=g_(),b.set(p,l)):l=y}}const u=l;let d;if(l.s===QB)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 uxe(d):d}return u.s=QB,u.v=d,d}return o.clearCache=()=>{n=g_(),o.resetResultsCount()},o.resultsCount=()=>a,o.resetResultsCount=()=>{a=0},o}function hxe(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()),ixe(u,`createSelector expects an output function after the inputs, but received: [${typeof u}]`);const d={...n,...c},{memoize:f,memoizeOptions:m=[],argsMemoize:p=mX,argsMemoizeOptions:b=[]}=d,y=YB(m),x=YB(b),v=oxe(i),S=f(function(){return a++,u.apply(null,arguments)},...y),M=p(function(){o++;const A=lxe(v,arguments);return l=S.apply(null,A),l},...x);return Object.assign(M,{resultFunc:u,memoizedResultFunc:S,dependencies:v,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>l,recomputations:()=>a,resetRecomputations:()=>{a=0},memoize:f,argsMemoize:p})};return Object.assign(r,{withTypes:()=>r}),r}var tt=hxe(mX),fxe=Object.assign((t,e=tt)=>{axe(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:()=>fxe}),XT={},YT={},QT={},ZB;function mxe(){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})(QT)),QT}var ZT={},JT={},JB;function pX(){return JB||(JB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="symbol"||n instanceof Symbol}t.isSymbol=e})(JT)),JT}var e8;function pxe(){return e8||(e8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=pX(),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 t8;function gxe(){return t8||(t8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=mxe(),n=pxe(),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 y=p;for(let x=0;x<b.length&&y!=null;++x)y=y[b[x]];return y},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 y=0;y<f.length;y++){const x=e.compareValues(p.criteria[y],b.criteria[y],l[y]);if(x!==0)return x}return 0}).map(p=>p.original)}t.orderBy=i})(YT)),YT}var eC={},n8;function xxe(){return n8||(n8=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})(eC)),eC}var tC={},r8;function gX(){return r8||(r8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=dX(),n=nO(),r=aX(),i=oX();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})(tC)),tC}var i8;function bxe(){return i8||(i8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=gxe(),n=xxe(),r=gX();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})(XT)),XT}var nC,a8;function yxe(){return a8||(a8=1,nC=bxe().sortBy),nC}var vxe=yxe();const bN=ml(vxe);var xX=t=>t.legend.settings,_xe=t=>t.legend.size,wxe=t=>t.legend.payload,Sxe=tt([wxe,xX],(t,e)=>{var{itemSorter:n}=e,r=t.flat(1);return n?bN(r,n):r});function Mxe(){return Gt(Sxe)}var x_=1;function bX(){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)>x_||Math.abs(o.left-e.left)>x_||Math.abs(o.top-e.top)>x_||Math.abs(o.width-e.width)>x_)&&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 ga(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 Nxe=typeof Symbol=="function"&&Symbol.observable||"@@observable",s8=Nxe,rC=()=>Math.random().toString(36).substring(7).split("").join("."),Exe={INIT:`@@redux/INIT${rC()}`,REPLACE:`@@redux/REPLACE${rC()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${rC()}`},Vw=Exe;function aO(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 yX(t,e,n){if(typeof t!="function")throw new Error(ga(2));if(typeof e=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(ga(0));if(typeof e=="function"&&typeof n>"u"&&(n=e,e=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(ga(1));return n(yX)(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,v)=>{o.set(v,x)}))}function d(){if(c)throw new Error(ga(3));return i}function f(x){if(typeof x!="function")throw new Error(ga(4));if(c)throw new Error(ga(5));let v=!0;u();const S=l++;return o.set(S,x),function(){if(v){if(c)throw new Error(ga(6));v=!1,u(),o.delete(S),a=null}}}function m(x){if(!aO(x))throw new Error(ga(7));if(typeof x.type>"u")throw new Error(ga(8));if(typeof x.type!="string")throw new Error(ga(17));if(c)throw new Error(ga(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(ga(10));r=x,m({type:Vw.REPLACE})}function b(){const x=f;return{subscribe(v){if(typeof v!="object"||v===null)throw new Error(ga(11));function S(){const E=v;E.next&&E.next(d())}return S(),{unsubscribe:x(S)}},[s8](){return this}}}return m({type:Vw.INIT}),{dispatch:m,subscribe:f,getState:d,replaceReducer:p,[s8]:b}}function Axe(t){Object.keys(t).forEach(e=>{const n=t[e];if(typeof n(void 0,{type:Vw.INIT})>"u")throw new Error(ga(12));if(typeof n(void 0,{type:Vw.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(ga(13))})}function vX(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{Axe(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(ga(14));u[f]=b,c=c||b!==p}return c=c||r.length!==Object.keys(o).length,c?u:o}}function Gw(...t){return t.length===0?e=>e:t.length===1?t[0]:t.reduce((e,n)=>(...r)=>e(n(...r)))}function Txe(...t){return e=>(n,r)=>{const i=e(n,r);let a=()=>{throw new Error(ga(15))};const o={getState:i.getState,dispatch:(c,...u)=>a(c,...u)},l=t.map(c=>c(o));return a=Gw(...l)(i.dispatch),{...i,dispatch:a}}}function _X(t){return aO(t)&&"type"in t&&typeof t.type=="string"}var wX=Symbol.for("immer-nothing"),o8=Symbol.for("immer-draftable"),rs=Symbol.for("immer-state");function Qo(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var Gs=Object,vg=Gs.getPrototypeOf,Ww="constructor",yN="prototype",PP="configurable",qw="enumerable",tw="writable",P0="value",fu=t=>!!t&&!!t[rs];function dl(t){return t?SX(t)||_N(t)||!!t[o8]||!!t[Ww]?.[o8]||wN(t)||SN(t):!1}var Cxe=Gs[yN][Ww].toString(),l8=new WeakMap;function SX(t){if(!t||!sO(t))return!1;const e=vg(t);if(e===null||e===Gs[yN])return!0;const n=Gs.hasOwnProperty.call(e,Ww)&&e[Ww];if(n===Object)return!0;if(!zp(n))return!1;let r=l8.get(n);return r===void 0&&(r=Function.toString.call(n),l8.set(n,r)),r===Cxe}function vN(t,e,n=!0){wy(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 wy(t){const e=t[rs];return e?e.type_:_N(t)?1:wN(t)?2:SN(t)?3:0}var c8=(t,e,n=wy(t))=>n===2?t.has(e):Gs[yN].hasOwnProperty.call(t,e),RP=(t,e,n=wy(t))=>n===2?t.get(e):t[e],Kw=(t,e,n,r=wy(t))=>{r===2?t.set(e,n):r===3?t.add(n):t[e]=n};function kxe(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}var _N=Array.isArray,wN=t=>t instanceof Map,SN=t=>t instanceof Set,sO=t=>typeof t=="object",zp=t=>typeof t=="function",iC=t=>typeof t=="boolean";function jxe(t){const e=+t;return Number.isInteger(e)&&String(e)===t}var qc=t=>t.copy_||t.base_,oO=t=>t.modified_?t.copy_:t.base_;function DP(t,e){if(wN(t))return new Map(t);if(SN(t))return new Set(t);if(_N(t))return Array[yN].slice.call(t);const n=SX(t);if(e===!0||e==="class_only"&&!n){const r=Gs.getOwnPropertyDescriptors(t);delete r[rs];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const o=i[a],l=r[o];l[tw]===!1&&(l[tw]=!0,l[PP]=!0),(l.get||l.set)&&(r[o]={[PP]:!0,[tw]:!0,[qw]:l[qw],[P0]:t[o]})}return Gs.create(vg(t),r)}else{const r=vg(t);if(r!==null&&n)return{...t};const i=Gs.create(r);return Gs.assign(i,t)}}function lO(t,e=!1){return MN(t)||fu(t)||!dl(t)||(wy(t)>1&&Gs.defineProperties(t,{set:b_,add:b_,clear:b_,delete:b_}),Gs.freeze(t),e&&vN(t,(n,r)=>{lO(r,!0)},!1)),t}function Pxe(){Qo(2)}var b_={[P0]:Pxe};function MN(t){return t===null||!sO(t)?!0:Gs.isFrozen(t)}var Xw="MapSet",OP="Patches",u8="ArrayMethods",MX={};function qf(t){const e=MX[t];return e||Qo(0,t),e}var d8=t=>!!MX[t],R0,NX=()=>R0,Rxe=(t,e)=>({drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:d8(Xw)?qf(Xw):void 0,arrayMethodsPlugin_:d8(u8)?qf(u8):void 0});function h8(t,e){e&&(t.patchPlugin_=qf(OP),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function LP(t){IP(t),t.drafts_.forEach(Dxe),t.drafts_=null}function IP(t){t===R0&&(R0=t.parent_)}var f8=t=>R0=Rxe(R0,t);function Dxe(t){const e=t[rs];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function m8(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];if(t!==void 0&&t!==n){n[rs].modified_&&(LP(e),Qo(4)),dl(t)&&(t=p8(e,t));const{patchPlugin_:i}=e;i&&i.generateReplacementPatches_(n[rs].base_,t,e)}else t=p8(e,n);return Oxe(e,t,!0),LP(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==wX?t:void 0}function p8(t,e){if(MN(e))return e;const n=e[rs];if(!n)return Yw(e,t.handledSet_,t);if(!NN(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);TX(n,t)}return n.copy_}function Oxe(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&lO(e,n)}function EX(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var NN=(t,e)=>t.scope_===e,Lxe=[];function AX(t,e,n,r){const i=qc(t),a=t.type_;if(r!==void 0&&RP(i,r,a)===e){Kw(i,r,n,a);return}if(!t.draftLocations_){const l=t.draftLocations_=new Map;vN(i,(c,u)=>{if(fu(u)){const d=l.get(u)||[];d.push(c),l.set(u,d)}})}const o=t.draftLocations_.get(e)??Lxe;for(const l of o)Kw(i,l,n,a)}function Ixe(t,e,n){t.callbacks_.push(function(i){const a=e;if(!a||!NN(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const o=oO(a);AX(t,a.draft_??a,o,n),TX(a,i)})}function TX(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 Fxe(t,e,n){const{scope_:r}=t;if(fu(n)){const i=n[rs];NN(i,r)&&i.callbacks_.push(function(){nw(t);const o=oO(i);AX(t,n,o,e)})}else dl(n)&&t.callbacks_.push(function(){const a=qc(t);t.type_===3?a.has(n)&&Yw(n,r.handledSet_,r):RP(a,e,t.type_)===n&&r.drafts_.length>1&&(t.assigned_.get(e)??!1)===!0&&t.copy_&&Yw(RP(t.copy_,e,t.type_),r.handledSet_,r)})}function Yw(t,e,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||fu(t)||e.has(t)||!dl(t)||MN(t)||(e.add(t),vN(t,(r,i)=>{if(fu(i)){const a=i[rs];if(NN(a,n)){const o=oO(a);Kw(t,r,o,t.type_),EX(a)}}else dl(i)&&Yw(i,e,n)})),t}function Uxe(t,e){const n=_N(t),r={type_:n?1:0,scope_:e?e.scope_:NX(),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=Qw;n&&(i=[r],a=D0);const{revoke:o,proxy:l}=Proxy.revocable(i,a);return r.draft_=l,r.revoke_=o,[l,r]}var Qw={get(t,e){if(e===rs)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=qc(t);if(!c8(i,e,t.type_))return zxe(t,i,e);const a=i[e];if(t.finalized_||!dl(a)||r&&t.operationMethod&&n?.isMutatingArrayMethod(t.operationMethod)&&jxe(e))return a;if(a===aC(t.base_,e)){nw(t);const o=t.type_===1?+e:e,l=UP(t.scope_,a,t,o);return t.copy_[o]=l}return a},has(t,e){return e in qc(t)},ownKeys(t){return Reflect.ownKeys(qc(t))},set(t,e,n){const r=CX(qc(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=aC(qc(t),e),a=i?.[rs];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_.set(e,!1),!0;if(kxe(n,i)&&(n!==void 0||c8(t.base_,e,t.type_)))return!0;nw(t),FP(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),Fxe(t,e,n)),!0},deleteProperty(t,e){return nw(t),aC(t.base_,e)!==void 0||e in t.base_?(t.assigned_.set(e,!1),FP(t)):t.assigned_.delete(e),t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=qc(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{[tw]:!0,[PP]:t.type_!==1||e!=="length",[qw]:r[qw],[P0]:n[e]}},defineProperty(){Qo(11)},getPrototypeOf(t){return vg(t.base_)},setPrototypeOf(){Qo(12)}},D0={};for(let t in Qw){let e=Qw[t];D0[t]=function(){const n=arguments;return n[0]=n[0][0],e.apply(this,n)}}D0.deleteProperty=function(t,e){return D0.set.call(this,t,e,void 0)};D0.set=function(t,e,n){return Qw.set.call(this,t[0],e,n,t[0])};function aC(t,e){const n=t[rs];return(n?qc(n):t)[e]}function zxe(t,e,n){const r=CX(e,n);return r?P0 in r?r[P0]:r.get?.call(t.draft_):void 0}function CX(t,e){if(!(e in t))return;let n=vg(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=vg(n)}}function FP(t){t.modified_||(t.modified_=!0,t.parent_&&FP(t.parent_))}function nw(t){t.copy_||(t.assigned_=new Map,t.copy_=DP(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var Bxe=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(n,r,i)=>{if(zp(n)&&!zp(r)){const o=r;r=n;const l=this;return function(u=o,...d){return l.produce(u,f=>r.call(this,f,...d))}}zp(r)||Qo(6),i!==void 0&&!zp(i)&&Qo(7);let a;if(dl(n)){const o=f8(this),l=UP(o,n,void 0);let c=!0;try{a=r(l),c=!1}finally{c?LP(o):IP(o)}return h8(o,i),m8(a,o)}else if(!n||!sO(n)){if(a=r(n),a===void 0&&(a=n),a===wX&&(a=void 0),this.autoFreeze_&&lO(a,!0),i){const o=[],l=[];qf(OP).generateReplacementPatches_(n,a,{patches_:o,inversePatches_:l}),i(o,l)}return a}else Qo(1,n)},this.produceWithPatches=(n,r)=>{if(zp(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]},iC(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),iC(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),iC(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){dl(e)||Qo(8),fu(e)&&(e=al(e));const n=f8(this),r=UP(n,e,void 0);return r[rs].isManual_=!0,IP(n),r}finishDraft(e,n){const r=e&&e[rs];(!r||!r.isManual_)&&Qo(9);const{scope_:i}=r;return h8(i,n),m8(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=qf(OP).applyPatches_;return fu(e)?i(e,n):this.produce(e,a=>i(a,n))}};function UP(t,e,n,r){const[i,a]=wN(e)?qf(Xw).proxyMap_(e,n):SN(e)?qf(Xw).proxySet_(e,n):Uxe(e,n);return(n?.scope_??NX()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?Ixe(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 al(t){return fu(t)||Qo(10,t),kX(t)}function kX(t){if(!dl(t)||MN(t))return t;const e=t[rs];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=DP(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=DP(t,!0);return vN(n,(i,a)=>{Kw(n,i,kX(a))},r),e&&(e.finalized_=!1),n}var $xe=new Bxe,jX=$xe.produce;function PX(t){return({dispatch:n,getState:r})=>i=>a=>typeof a=="function"?a(n,r,t):i(a)}var Hxe=PX(),Vxe=PX,Gxe=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?Gw:Gw.apply(null,arguments)};function Io(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=>_X(r)&&r.type===t,n}var RX=class Fb extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,Fb.prototype)}static get[Symbol.species](){return Fb}concat(...e){return super.concat.apply(this,e)}prepend(...e){return e.length===1&&Array.isArray(e[0])?new Fb(...e[0].concat(this)):new Fb(...e.concat(this))}};function g8(t){return dl(t)?jX(t,()=>{}):t}function y_(t,e,n){return t.has(e)?t.get(e):t.set(e,n(e)).get(e)}function Wxe(t){return typeof t=="boolean"}var qxe=()=>function(e){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:i=!0,actionCreatorCheck:a=!0}=e??{};let o=new RX;return n&&(Wxe(n)?o.push(Hxe):o.push(Vxe(n.extraArgument))),o},DX="RTK_autoBatch",Fr=()=>t=>({payload:t,meta:{[DX]:!0}}),x8=t=>e=>{setTimeout(e,t)},OX=(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:x8(10):t.type==="callback"?t.queueNotification:x8(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?.[DX],a=!i,a&&(o||(o=!0,c(u))),r.dispatch(d)}finally{i=!0}}})},Kxe=t=>function(n){const{autoBatch:r=!0}=n??{};let i=new RX(t);return r&&i.push(OX(typeof r=="object"?r:void 0)),i};function Xxe(t){const e=qxe(),{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(aO(n))l=vX(n);else throw new Error(qs(1));let c;typeof r=="function"?c=r(e):c=e();let u=Gw;i&&(u=Gxe({trace:!1,...typeof i=="object"&&i}));const d=Txe(...c),f=Kxe(d);let m=typeof o=="function"?o(f):f();const p=u(...m);return yX(l,a,p)}function LX(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 Yxe(t){return typeof t=="function"}function Qxe(t,e){let[n,r,i]=LX(e),a;if(Yxe(t))a=()=>g8(t());else{const l=g8(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(fu(d)){const p=f(d,c);return p===void 0?d:p}else{if(dl(d))return jX(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",Jxe=(t=21)=>{let e="",n=t;for(;n--;)e+=Zxe[Math.random()*64|0];return e},ebe=Symbol.for("rtk-slice-createasyncthunk");function tbe(t,e){return`${t}/${e}`}function nbe({creators:t}={}){const e=t?.asyncThunk?.[ebe];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(ibe()):r.reducers)||{},l=Object.keys(o),c={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},u={addCase(M,E){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]=E,u},addMatcher(M,E){return c.sliceMatchers.push({matcher:M,reducer:E}),u},exposeAction(M,E){return c.actionCreators[M]=E,u},exposeCaseReducer(M,E){return c.sliceCaseReducersByName[M]=E,u}};l.forEach(M=>{const E=o[M],A={reducerName:M,type:tbe(i,M),createNotation:typeof r.reducers=="function"};sbe(E)?lbe(A,E,u,e):abe(A,E,u)});function d(){const[M={},E=[],A=void 0]=typeof r.extraReducers=="function"?LX(r.extraReducers):[r.extraReducers],k={...M,...c.sliceCaseReducersByType};return Qxe(r.initialState,T=>{for(let D in k)T.addCase(D,k[D]);for(let D of c.sliceMatchers)T.addMatcher(D.matcher,D.reducer);for(let D of E)T.addMatcher(D.matcher,D.reducer);A&&T.addDefaultCase(A)})}const f=M=>M,m=new Map,p=new WeakMap;let b;function y(M,E){return b||(b=d()),b(M,E)}function x(){return b||(b=d()),b.getInitialState()}function v(M,E=!1){function A(T){let D=T[M];return typeof D>"u"&&E&&(D=y_(p,A,x)),D}function k(T=f){const D=y_(m,E,()=>new WeakMap);return y_(D,T,()=>{const C={};for(const[R,U]of Object.entries(r.selectors??{}))C[R]=rbe(U,T,()=>y_(p,T,x),E);return C})}return{reducerPath:M,getSelectors:k,get selectors(){return k(A)},selectSlice:A}}const S={name:i,reducer:y,actions:c.actionCreators,caseReducers:c.sliceCaseReducersByName,getInitialState:x,...v(a),injectInto(M,{reducerPath:E,...A}={}){const k=E??a;return M.inject({reducerPath:k,reducer:y},A),{...S,...v(k,!0)}}};return S}}function rbe(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 Es=nbe();function ibe(){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 abe({type:t,reducerName:e,createNotation:n},r,i){let a,o;if("reducer"in r){if(n&&!obe(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?Io(t,o):Io(t))}function sbe(t){return t._reducerDefinitionType==="asyncThunk"}function obe(t){return t._reducerDefinitionType==="reducerWithPrepare"}function lbe({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||v_,pending:l||v_,rejected:c||v_,settled:u||v_})}function v_(){}var cbe="task",IX="listener",FX="completed",cO="cancelled",ube=`task-${cO}`,dbe=`task-${FX}`,zP=`${IX}-${cO}`,hbe=`${IX}-${FX}`,EN=class{constructor(t){this.code=t,this.message=`${cbe} ${cO} (reason: ${t})`}name="TaskAbortError";message},uO=(t,e)=>{if(typeof t!="function")throw new TypeError(qs(32))},Zw=()=>{},UX=(t,e=Zw)=>(t.catch(e),t),zX=(t,e)=>(t.addEventListener("abort",e,{once:!0}),()=>t.removeEventListener("abort",e)),Sf=t=>{if(t.aborted)throw new EN(t.reason)};function BX(t,e){let n=Zw;return new Promise((r,i)=>{const a=()=>i(new EN(t.reason));if(t.aborted){a();return}n=zX(t,a),e.finally(()=>n()).then(r,i)}).finally(()=>{n=Zw})}var fbe=async(t,e)=>{try{return await Promise.resolve(),{status:"ok",value:await t()}}catch(n){return{status:n instanceof EN?"cancelled":"rejected",error:n}}finally{e?.()}},Jw=t=>e=>UX(BX(t,e).then(n=>(Sf(t),n))),$X=t=>{const e=Jw(t);return n=>e(new Promise(r=>setTimeout(r,n)))},{assign:tg}=Object,b8={},AN="listenerMiddleware",mbe=(t,e)=>{const n=r=>zX(t,()=>r.abort(t.reason));return(r,i)=>{uO(r);const a=new AbortController;n(a);const o=fbe(async()=>{Sf(t),Sf(a.signal);const l=await r({pause:Jw(a.signal),delay:$X(a.signal),signal:a.signal});return Sf(a.signal),l},()=>a.abort(dbe));return i?.autoJoin&&e.push(o.catch(Zw)),{result:Jw(t)(o),cancel(){a.abort(ube)}}}},pbe=(t,e)=>{const n=async(r,i)=>{Sf(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 BX(e,Promise.race(l));return Sf(e),c}finally{a()}};return(r,i)=>UX(n(r,i))},HX=t=>{let{type:e,actionCreator:n,matcher:r,predicate:i,effect:a}=t;if(e)i=Io(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 uO(a),{predicate:i,type:e,effect:a}},VX=tg(t=>{const{type:e,predicate:n,effect:r}=HX(t);return{id:Jxe(),effect:r,type:e,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(qs(22))}}},{withTypes:()=>VX}),y8=(t,e)=>{const{type:n,effect:r,predicate:i}=HX(e);return Array.from(t.values()).find(a=>(typeof n=="string"?a.type===n:a.predicate===i)&&a.effect===r)},BP=t=>{t.pending.forEach(e=>{e.abort(zP)})},gbe=(t,e)=>()=>{for(const n of e.keys())BP(n);t.clear()},v8=(t,e,n)=>{try{t(e,n)}catch(r){setTimeout(()=>{throw r},0)}},GX=tg(Io(`${AN}/add`),{withTypes:()=>GX}),xbe=Io(`${AN}/removeAll`),WX=tg(Io(`${AN}/remove`),{withTypes:()=>WX}),bbe=(...t)=>{console.error(`${AN}/error`,...t)},Sy=(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=bbe}=t;uO(o);const l=p=>(p.unsubscribe=()=>e.delete(p.id),e.set(p.id,p),b=>{p.unsubscribe(),b?.cancelActive&&BP(p)}),c=p=>{const b=y8(e,p)??VX(p);return l(b)};tg(c,{withTypes:()=>c});const u=p=>{const b=y8(e,p);return b&&(b.unsubscribe(),p.cancelActive&&BP(b)),!!b};tg(u,{withTypes:()=>u});const d=async(p,b,y,x)=>{const v=new AbortController,S=pbe(c,v.signal),M=[];try{p.pending.add(v),r(p),await Promise.resolve(p.effect(b,tg({},y,{getOriginalState:x,condition:(E,A)=>S(E,A).then(Boolean),take:S,delay:$X(v.signal),pause:Jw(v.signal),extra:a,signal:v.signal,fork:mbe(v.signal,M),unsubscribe:p.unsubscribe,subscribe:()=>{e.set(p.id,p)},cancelActiveListeners:()=>{p.pending.forEach((E,A,k)=>{E!==v&&(E.abort(zP),k.delete(E))})},cancel:()=>{v.abort(zP),p.pending.delete(v)},throwIfCancelled:()=>{Sf(v.signal)}})))}catch(E){E instanceof EN||v8(o,E,{raisedBy:"effect"})}finally{await Promise.all(M),v.abort(hbe),i(p),p.pending.delete(v)}},f=gbe(e,n);return{middleware:p=>b=>y=>{if(!_X(y))return b(y);if(GX.match(y))return c(y.payload);if(xbe.match(y)){f();return}if(WX.match(y))return u(y.payload);let x=p.getState();const v=()=>{if(x===b8)throw new Error(qs(23));return x};let S;try{if(S=b(y),e.size>0){const M=p.getState(),E=Array.from(e.values());for(const A of E){let k=!1;try{k=A.predicate(y,M,x)}catch(T){k=!1,v8(o,T,{raisedBy:"predicate"})}k&&d(A,y,p,v)}}}finally{x=b8}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 ybe={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},qX=Es({name:"chartLayout",initialState:ybe,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:vbe,setLayout:_be,setChartSize:wbe,setScale:Sbe}=qX.actions,Mbe=qX.reducer;function KX(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 _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 Wp(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){Nbe(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 Nbe(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=Abe(t,"string");return typeof e=="symbol"?e:e+""}function Abe(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:Lo(e)?Gf(t,e,n):typeof e=="function"?e(t):n}var Tbe=(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 Wp(Wp({},t),{},{[a]:t[a]+(r||0)});if((l==="horizontal"||l==="vertical"&&a==="center")&&o!=="middle"&&zt(t[o]))return Wp(Wp({},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",XX=(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},YX=(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,y=i==="category"&&o.bandwidth?o.bandwidth()/b:0;if(y=p==="angleAxis"&&a&&a.length>=2?ea(a[0]-a[1])*2*y:y,f||m){var x=(f||m||[]).map((v,S)=>{var M=r?r.indexOf(v):v,E=o.map(M);return pn(E)?{coordinate:E+y,value:v,offset:y,index:S}:null}).filter(vs);return x}return c&&u?u.map((v,S)=>{var M=o.map(v);return pn(M)?{coordinate:M+y,value:v,index:S,offset:y}:null}).filter(vs):o.ticks&&d!=null?o.ticks(d).map((v,S)=>{var M=o.map(v);return pn(M)?{coordinate:M+y,value:v,index:S,offset:y}:null}).filter(vs):o.domain().map((v,S)=>{var M=o.map(v);return pn(M)?{coordinate:M+y,value:r?r[v]:v,index:S,offset:y}:null}).filter(vs)},Cbe=(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},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,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)}}}},jbe=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)}}}},Pbe={sign:kbe,expand:tge,none:Vf,silhouette:nge,wiggle:rge,positive:jbe},Rbe=(t,e,n)=>{var r,i=(r=Pbe[n])!==null&&r!==void 0?r:Vf,a=ege().keys(e).value((l,c)=>Number(ir(l,c,0))).order(kP).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 QX(t){return t==null?void 0:String(t)}function eS(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=tX(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 w8=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},Dbe=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]},Obe=t=>{var e=t.flat(2).filter(zt);return[Math.min(...e),Math.max(...e)]},Lbe=t=>[t[0]===1/0?0:t[0],t[1]===-1/0?0:t[1]],Ibe=(t,e,n)=>{if(t!=null)return Lbe(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=KX(u,e,n),f=Obe(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]))},S8=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,M8=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,Qd=(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=bN(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 N8(t){var{tooltipEntrySettings:e,dataKey:n,payload:r,value:i,name:a}=t;return Wp(Wp({},e),{},{dataKey:n,payload:r,value:i,name:a})}function dh(t,e){if(t)return String(t);if(typeof e=="string")return e}var Fbe=(t,e)=>{if(e==="horizontal")return t.chartX;if(e==="vertical")return t.chartY},Ube=(t,e)=>e==="centric"?t.angle:t.radius,Mu=t=>t.layout.width,Nu=t=>t.layout.height,zbe=t=>t.layout.scale,ZX=t=>t.layout.margin,TN=tt(t=>t.cartesianAxis.xAxis,t=>Object.values(t)),CN=tt(t=>t.cartesianAxis.yAxis,t=>Object.values(t)),JX="data-recharts-item-index",eY="data-recharts-item-id",My=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 __(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){Bbe(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 Bbe(t,e,n){return(e=$be(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function $be(t){var e=Hbe(t,"string");return typeof e=="symbol"?e:e+""}function Hbe(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 Vbe=t=>t.brush.height;function Gbe(t){var e=CN(t);return e.reduce((n,r)=>{if(r.orientation==="left"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:My;return n+i}return n},0)}function Wbe(t){var e=CN(t);return e.reduce((n,r)=>{if(r.orientation==="right"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:My;return n+i}return n},0)}function qbe(t){var e=TN(t);return e.reduce((n,r)=>r.orientation==="top"&&!r.mirror&&!r.hide?n+r.height:n,0)}function Kbe(t){var e=TN(t);return e.reduce((n,r)=>r.orientation==="bottom"&&!r.mirror&&!r.hide?n+r.height:n,0)}var zi=tt([Mu,Nu,ZX,Vbe,Gbe,Wbe,qbe,Kbe,xX,_xe],(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=__(__({},f),d),p=m.bottom;m.bottom+=r,m=Tbe(m,c,u);var b=t-m.left-m.right,y=e-m.top-m.bottom;return __(__({brushBottom:p},m),{},{width:Math.max(b,0),height:Math.max(y,0)})}),Xbe=tt(zi,t=>({x:t.left,y:t.top,width:t.width,height:t.height})),dO=tt(Mu,Nu,(t,e)=>({x:0,y:0,width:t,height:e})),Ybe=w.createContext(null),Bi=()=>w.useContext(Ybe)!=null,kN=t=>t.brush,jN=tt([kN,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})),sC={},oC={},lC={},A8;function Qbe(){return A8||(A8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r,{signal:i,edges:a}={}){let o,l=null;const c=a!=null&&a.includes("leading"),u=a==null||a.includes("trailing"),d=()=>{l!==null&&(n.apply(o,l),o=void 0,l=null)},f=()=>{u&&d(),y()};let m=null;const p=()=>{m!=null&&clearTimeout(m),m=setTimeout(()=>{m=null,f()},r)},b=()=>{m!==null&&(clearTimeout(m),m=null)},y=()=>{b(),o=void 0,l=null},x=()=>{d()},v=function(...S){if(i?.aborted)return;o=this,l=S;const M=m==null;p(),c&&M&&d()};return v.schedule=p,v.cancel=y,v.flush=x,i?.addEventListener("abort",y,{once:!0}),v}t.debounce=e})(lC)),lC}var T8;function Zbe(){return T8||(T8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Qbe();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(...y){d=r.apply(this,y),f=null},i,{edges:u}),p=function(...y){return c!=null&&(f===null&&(f=Date.now()),Date.now()-f>=c)?(d=r.apply(this,y),f=Date.now(),m.cancel(),m.schedule(),d):(m.apply(this,y),d)},b=()=>(m.flush(),d);return p.cancel=m.cancel,p.flush=b,p}t.debounce=n})(oC)),oC}var C8;function Jbe(){return C8||(C8=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})(sC)),sC}var cC,k8;function e0e(){return k8||(k8=1,cC=Jbe().throttle),cC}var t0e=e0e();const n0e=ml(t0e);var tS=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}},tY=(t,e,n)=>{var{width:r=zl.width,height:i=zl.height,aspect:a,maxHeight:o}=n,l=Wf(r)?t:Number(r),c=Wf(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}},r0e={width:0,height:0,overflow:"visible"},i0e={width:0,overflowX:"visible"},a0e={height:0,overflowY:"visible"},s0e={},o0e=t=>{var{width:e,height:n}=t,r=Wf(e),i=Wf(n);return r&&i?r0e:r?i0e:i?a0e:s0e};function l0e(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 $P(){return $P=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},$P.apply(null,arguments)}function j8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function P8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?j8(Object(n),!0).forEach(function(r){c0e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):j8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function c0e(t,e,n){return(e=u0e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function u0e(t){var e=d0e(t,"string");return typeof e=="symbol"?e:e+""}function d0e(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 nY=w.createContext(zl.initialDimension);function h0e(t){return Jl(t.width)&&Jl(t.height)}function rY(t){var{children:e,width:n,height:r}=t,i=w.useMemo(()=>({width:n,height:r}),[n,r]);return h0e(i)?w.createElement(nY.Provider,{value:i},e):null}var hO=()=>w.useContext(nY),f0e=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,y=w.useRef(null),x=w.useRef();x.current=p,w.useImperativeHandle(e,()=>y.current);var[v,S]=w.useState({containerWidth:r.width,containerHeight:r.height}),M=w.useCallback((D,C)=>{S(R=>{var U=Math.round(D),O=Math.round(C);return R.containerWidth===U&&R.containerHeight===O?R:{containerWidth:U,containerHeight:O}})},[]);w.useEffect(()=>{if(y.current==null||typeof ResizeObserver>"u")return uh;var D=O=>{var q,j=O[0];if(j!=null){var{width:W,height:X}=j.contentRect;M(W,X),(q=x.current)===null||q===void 0||q.call(x,W,X)}};d>0&&(D=n0e(D,d,{trailing:!0,leading:!1}));var C=new ResizeObserver(D),{width:R,height:U}=y.current.getBoundingClientRect();return M(R,U),C.observe(y.current),()=>{C.disconnect()}},[M,d]);var{containerWidth:E,containerHeight:A}=v;tS(!n||n>0,"The aspect(%s) must be greater than zero.",n);var{calculatedWidth:k,calculatedHeight:T}=tY(E,A,{width:i,height:a,aspect:n,maxHeight:c});return tS(k!=null&&k>0||T!=null&&T>0,`The width(%s) and height(%s) of chart should be greater than 0,
- please check the style of container, or the props width(%s) and height(%s),
- or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the
- height and width.`,k,T,i,a,o,l,n),w.createElement("div",{id:f?"".concat(f):void 0,className:Bn("recharts-responsive-container",m),style:P8(P8({},b),{},{width:i,height:a,minWidth:o,minHeight:l,maxHeight:c}),ref:y},w.createElement("div",{style:o0e({width:i,height:a})},w.createElement(rY,{width:k,height:T},u)))}),rw=w.forwardRef((t,e)=>{var n=hO();if(Jl(n.width)&&Jl(n.height))return t.children;var{width:r,height:i}=l0e({width:t.width,height:t.height,aspect:t.aspect}),{calculatedWidth:a,calculatedHeight:o}=tY(void 0,void 0,{width:r,height:i,aspect:t.aspect,maxHeight:t.maxHeight});return zt(a)&&zt(o)?w.createElement(rY,{width:a,height:o},t.children):w.createElement(f0e,$P({},t,{width:r,height:i,ref:e}))});function fO(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 Ny=()=>{var t,e=Bi(),n=Gt(Xbe),r=Gt(jN),i=(t=Gt(kN))===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}},m0e={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},iY=()=>{var t;return(t=Gt(zi))!==null&&t!==void 0?t:m0e},mO=()=>Gt(Mu),pO=()=>Gt(Nu),p0e=()=>Gt(t=>t.layout.margin),Fn=t=>t.layout.layoutType,hh=()=>Gt(Fn),gO=()=>{var t=hh();if(t==="horizontal"||t==="vertical")return t},aY=t=>{var e=t.layout.layoutType;if(e==="centric"||e==="radial")return e},g0e=()=>{var t=hh();return t!==void 0},Ey=t=>{var e=Mr(),n=Bi(),{width:r,height:i}=t,a=hO(),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(wbe({width:o,height:l}))},[e,n,o,l]),null},sY=Symbol.for("immer-nothing"),R8=Symbol.for("immer-draftable"),Zs=Symbol.for("immer-state");function Zo(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var O0=Object.getPrototypeOf;function _g(t){return!!t&&!!t[Zs]}function Kf(t){return t?oY(t)||Array.isArray(t)||!!t[R8]||!!t.constructor?.[R8]||Ay(t)||RN(t):!1}var x0e=Object.prototype.constructor.toString(),D8=new WeakMap;function oY(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=D8.get(n);return r===void 0&&(r=Function.toString.call(n),D8.set(n,r)),r===x0e}function nS(t,e,n=!0){PN(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 PN(t){const e=t[Zs];return e?e.type_:Array.isArray(t)?1:Ay(t)?2:RN(t)?3:0}function HP(t,e){return PN(t)===2?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function lY(t,e,n){const r=PN(t);r===2?t.set(e,n):r===3?t.add(n):t[e]=n}function b0e(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}function Ay(t){return t instanceof Map}function RN(t){return t instanceof Set}function Qh(t){return t.copy_||t.base_}function VP(t,e){if(Ay(t))return new Map(t);if(RN(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=oY(t);if(e===!0||e==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(t);delete r[Zs];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(O0(t),r)}else{const r=O0(t);if(r!==null&&n)return{...t};const i=Object.create(r);return Object.assign(i,t)}}function xO(t,e=!1){return DN(t)||_g(t)||!Kf(t)||(PN(t)>1&&Object.defineProperties(t,{set:w_,add:w_,clear:w_,delete:w_}),Object.freeze(t),e&&Object.values(t).forEach(n=>xO(n,!0))),t}function y0e(){Zo(2)}var w_={value:y0e};function DN(t){return t===null||typeof t!="object"?!0:Object.isFrozen(t)}var v0e={};function Xf(t){const e=v0e[t];return e||Zo(0,t),e}var L0;function cY(){return L0}function _0e(t,e){return{drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function O8(t,e){e&&(Xf("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function GP(t){WP(t),t.drafts_.forEach(w0e),t.drafts_=null}function WP(t){t===L0&&(L0=t.parent_)}function L8(t){return L0=_0e(L0,t)}function w0e(t){const e=t[Zs];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function I8(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];return t!==void 0&&t!==n?(n[Zs].modified_&&(GP(e),Zo(4)),Kf(t)&&(t=rS(e,t),e.parent_||iS(e,t)),e.patches_&&Xf("Patches").generateReplacementPatches_(n[Zs].base_,t,e.patches_,e.inversePatches_)):t=rS(e,n,[]),GP(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==sY?t:void 0}function rS(t,e,n){if(DN(e))return e;const r=t.immer_.shouldUseStrictIteration(),i=e[Zs];if(!i)return nS(e,(a,o)=>F8(t,i,e,a,o,n),r),e;if(i.scope_!==t)return e;if(!i.modified_)return iS(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),nS(o,(c,u)=>F8(t,i,a,c,u,n,l),r),iS(t,a,!1),n&&t.patches_&&Xf("Patches").generatePatches_(i,n,t.patches_,t.inversePatches_)}return i.copy_}function F8(t,e,n,r,i,a,o){if(i==null||typeof i!="object"&&!o)return;const l=DN(i);if(!(l&&!o)){if(_g(i)){const c=a&&e&&e.type_!==3&&!HP(e.assigned_,r)?a.concat(r):void 0,u=rS(t,i,c);if(lY(n,r,u),_g(u))t.canAutoFreeze_=!1;else return}else o&&n.add(i);if(Kf(i)&&!l){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1||e&&e.base_&&e.base_[r]===i&&l)return;rS(t,i),(!e||!e.scope_.parent_)&&typeof r!="symbol"&&(Ay(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&iS(t,i)}}}function iS(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&xO(e,n)}function S0e(t,e){const n=Array.isArray(t),r={type_:n?1:0,scope_:e?e.scope_:cY(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,a=bO;n&&(i=[r],a=I0);const{revoke:o,proxy:l}=Proxy.revocable(i,a);return r.draft_=l,r.revoke_=o,l}var bO={get(t,e){if(e===Zs)return t;const n=Qh(t);if(!HP(n,e))return M0e(t,n,e);const r=n[e];return t.finalized_||!Kf(r)?r:r===uC(t.base_,e)?(dC(t),t.copy_[e]=KP(r,t)):r},has(t,e){return e in Qh(t)},ownKeys(t){return Reflect.ownKeys(Qh(t))},set(t,e,n){const r=uY(Qh(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=uC(Qh(t),e),a=i?.[Zs];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(b0e(n,i)&&(n!==void 0||HP(t.base_,e)))return!0;dC(t),qP(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 uC(t.base_,e)!==void 0||e in t.base_?(t.assigned_[e]=!1,dC(t),qP(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=Qh(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{writable:!0,configurable:t.type_!==1||e!=="length",enumerable:r.enumerable,value:n[e]}},defineProperty(){Zo(11)},getPrototypeOf(t){return O0(t.base_)},setPrototypeOf(){Zo(12)}},I0={};nS(bO,(t,e)=>{I0[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});I0.deleteProperty=function(t,e){return I0.set.call(this,t,e,void 0)};I0.set=function(t,e,n){return bO.set.call(this,t[0],e,n,t[0])};function uC(t,e){const n=t[Zs];return(n?Qh(n):t)[e]}function M0e(t,e,n){const r=uY(e,n);return r?"value"in r?r.value:r.get?.call(t.draft_):void 0}function uY(t,e){if(!(e in t))return;let n=O0(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=O0(n)}}function qP(t){t.modified_||(t.modified_=!0,t.parent_&&qP(t.parent_))}function dC(t){t.copy_||(t.copy_=VP(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var N0e=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"&&Zo(6),r!==void 0&&typeof r!="function"&&Zo(7);let i;if(Kf(e)){const a=L8(this),o=KP(e,void 0);let l=!0;try{i=n(o),l=!1}finally{l?GP(a):WP(a)}return O8(a,r),I8(i,a)}else if(!e||typeof e!="object"){if(i=n(e),i===void 0&&(i=e),i===sY&&(i=void 0),this.autoFreeze_&&xO(i,!0),r){const a=[],o=[];Xf("Patches").generateReplacementPatches_(e,i,a,o),r(a,o)}return i}else Zo(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){Kf(t)||Zo(8),_g(t)&&(t=E0e(t));const e=L8(this),n=KP(t,void 0);return n[Zs].isManual_=!0,WP(e),n}finishDraft(t,e){const n=t&&t[Zs];(!n||!n.isManual_)&&Zo(9);const{scope_:r}=n;return O8(r,e),I8(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=Xf("Patches").applyPatches_;return _g(t)?r(t,e):this.produce(t,i=>r(i,e))}};function KP(t,e){const n=Ay(t)?Xf("MapSet").proxyMap_(t,e):RN(t)?Xf("MapSet").proxySet_(t,e):S0e(t,e);return(e?e.scope_:cY()).drafts_.push(n),n}function E0e(t){return _g(t)||Zo(10,t),dY(t)}function dY(t){if(!Kf(t)||DN(t))return t;const e=t[Zs];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=VP(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=VP(t,!0);return nS(n,(i,a)=>{lY(n,i,dY(a))},r),e&&(e.finalized_=!1),n}var A0e=new N0e;A0e.produce;var T0e={settings:{layout:"horizontal",align:"center",verticalAlign:"middle",itemSorter:"value"},size:{width:0,height:0},payload:[]},hY=Es({name:"legend",initialState:T0e,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=al(t).payload.indexOf(n);i>-1&&(t.payload[i]=r)},prepare:Fr()},removeLegendPayload:{reducer(t,e){var n=al(t).payload.indexOf(e.payload);n>-1&&t.payload.splice(n,1)},prepare:Fr()}}}),{setLegendSize:U8,setLegendSettings:C0e,addLegendPayload:fY,replaceLegendPayload:mY,removeLegendPayload:pY}=hY.actions,k0e=hY.reducer,j0e=["contextPayload"];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 wg(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){P0e(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 P0e(t,e,n){return(e=R0e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function R0e(t){var e=D0e(t,"string");return typeof e=="symbol"?e:e+""}function D0e(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 O0e(t,e){if(t==null)return{};var n,r,i=L0e(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 L0e(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 I0e(t){return t.value}function F0e(t){var{contextPayload:e}=t,n=O0e(t,j0e),r=hX(e,t.payloadUniqBy,I0e),i=wg(wg({},n),{},{payload:r});return w.isValidElement(t.content)?w.cloneElement(t.content,i):typeof t.content=="function"?w.createElement(t.content,i):w.createElement(Pge,i)}function U0e(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}),wg(wg({},u),d)}function z0e(t){var e=Mr();return w.useEffect(()=>{e(C0e(t))},[e,t]),null}function B0e(t){var e=Mr();return w.useEffect(()=>(e(U8(t)),()=>{e(U8({width:0,height:0}))}),[e,t]),null}function $0e(t,e,n,r){return t==="vertical"&&e!=null?{height:e}:t==="horizontal"?{width:n||r}:null}var H0e={align:"center",iconSize:14,inactiveColor:"#ccc",itemSorter:"value",layout:"horizontal",verticalAlign:"bottom"};function yO(t){var e=Kr(t,H0e),n=Mxe(),r=Mpe(),i=p0e(),{width:a,height:o,wrapperStyle:l,portal:c}=e,[u,d]=bX([n]),f=mO(),m=pO();if(f==null||m==null)return null;var p=f-(i?.left||0)-(i?.right||0),b=$0e(e.layout,o,a,p),y=c?l:wg(wg({position:"absolute",width:b?.width||a||"auto",height:b?.height||o||"auto"},U0e(l,e,i,f,m,u)),l),x=c??r;if(x==null||n==null)return null;var v=w.createElement("div",{className:"recharts-legend-wrapper",style:y,ref:d},w.createElement(z0e,{layout:e.layout,align:e.align,verticalAlign:e.verticalAlign,itemSorter:e.itemSorter}),!c&&w.createElement(B0e,{width:u.width,height:u.height}),w.createElement(F0e,XP({},e,b,{margin:i,chartWidth:f,chartHeight:m,contextPayload:n})));return Qc.createPortal(v,x)}yO.displayName="Legend";function YP(){return YP=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},YP.apply(null,arguments)}function B8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function lb(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?B8(Object(n),!0).forEach(function(r){V0e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):B8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function V0e(t,e,n){return(e=G0e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function G0e(t){var e=W0e(t,"string");return typeof e=="symbol"?e:e+""}function W0e(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 q0e(t){return Array.isArray(t)&&Lo(t[0])&&Lo(t[1])?t.join(" ~ "):t}var Ym={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},K0e=t=>{var{separator:e=Ym.separator,contentStyle:n,itemStyle:r,labelStyle:i=Ym.labelStyle,payload:a,formatter:o,itemSorter:l,wrapperClassName:c,labelClassName:u,label:d,labelFormatter:f,accessibilityLayer:m=Ym.accessibilityLayer}=t,p=()=>{if(a&&a.length){var A={padding:0,margin:0},k=(l?bN(a,l):a).map((T,D)=>{if(T.type==="none")return null;var C=T.formatter||o||q0e,{value:R,name:U}=T,O=R,q=U;if(C){var j=C(R,U,T,D,a);if(Array.isArray(j))[O,q]=j;else if(j!=null)O=j;else return null}var W=lb(lb({},Ym.itemStyle),{},{color:T.color||Ym.itemStyle.color},r);return w.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(D),style:W},Lo(q)?w.createElement("span",{className:"recharts-tooltip-item-name"},q):null,Lo(q)?w.createElement("span",{className:"recharts-tooltip-item-separator"},e):null,w.createElement("span",{className:"recharts-tooltip-item-value"},O),w.createElement("span",{className:"recharts-tooltip-item-unit"},T.unit||""))});return w.createElement("ul",{className:"recharts-tooltip-item-list",style:A},k)}return null},b=lb(lb({},Ym.contentStyle),n),y=lb({margin:0},i),x=!Hr(d),v=x?d:"",S=Bn("recharts-default-tooltip",c),M=Bn("recharts-tooltip-label",u);x&&f&&a!==void 0&&a!==null&&(v=f(d,a));var E=m?{role:"status","aria-live":"assertive"}:{};return w.createElement("div",YP({className:S,style:b},E),w.createElement("p",{className:M,style:y},w.isValidElement(v)?v:"".concat(v)),p())},cb="recharts-tooltip-wrapper",X0e={visibility:"hidden"};function Y0e(t){var{coordinate:e,translateX:n,translateY:r}=t;return Bn(cb,{["".concat(cb,"-right")]:zt(n)&&e&&zt(e.x)&&n>=e.x,["".concat(cb,"-left")]:zt(n)&&e&&zt(e.x)&&n<e.x,["".concat(cb,"-bottom")]:zt(r)&&e&&zt(e.y)&&r>=e.y,["".concat(cb,"-top")]:zt(r)&&e&&zt(e.y)&&r<e.y})}function $8(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 y=f+l,x=m+u;return y>x?Math.max(d,m):Math.max(f,m)}function Q0e(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=$8({allowEscapeViewBox:e,coordinate:n,key:"x",offset:i,position:a,reverseDirection:o,tooltipDimension:l.width,viewBox:u,viewBoxDimension:u.width}),m=$8({allowEscapeViewBox:e,coordinate:n,key:"y",offset:r,position:a,reverseDirection:o,tooltipDimension:l.height,viewBox:u,viewBoxDimension:u.height}),d=Q0e({translateX:f,translateY:m,useTranslate3d:c})):d=X0e,{cssProperties:d,cssClasses:Y0e({translateX:f,translateY:m,coordinate:n})}}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 S_(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){QP(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 QP(t,e,n){return(e=J0e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function J0e(t){var e=eye(t,"string");return typeof e=="symbol"?e:e+""}function eye(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 tye extends w.PureComponent{constructor(){super(...arguments),QP(this,"state",{dismissed:!1,dismissedAtCoordinate:{x:0,y:0}}),QP(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:y,innerRef:x,hasPortalFromProps:v}=this.props,S=typeof u=="number"?u:u.x,M=typeof u=="number"?u:u.y,{cssClasses:E,cssProperties:A}=Z0e({allowEscapeViewBox:n,coordinate:o,offsetLeft:S,offsetTop:M,position:d,reverseDirection:f,tooltipBox:{height:y.height,width:y.width},useTranslate3d:m,viewBox:p}),k=v?{}:S_(S_({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}),T=S_(S_({},k),{},{visibility:!this.state.dismissed&&e&&l?"visible":"hidden"},b);return w.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",tabIndex:-1,className:E,style:T,ref:x},a)}}var gY=()=>{var t;return(t=Gt(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 V8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function G8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?V8(Object(n),!0).forEach(function(r){nye(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 nye(t,e,n){return(e=rye(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function rye(t){var e=iye(t,"string");return typeof e=="symbol"?e:e+""}function iye(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 W8={curveBasisClosed:Hpe,curveBasisOpen:Vpe,curveBasis:$pe,curveBumpX:Tpe,curveBumpY:Cpe,curveLinearClosed:Gpe,curveLinear:gN,curveMonotoneX:Wpe,curveMonotoneY:qpe,curveNatural:Kpe,curveStep:Xpe,curveStepAfter:Qpe,curveStepBefore:Ype},aS=t=>pn(t.x)&&pn(t.y),q8=t=>t.base!=null&&aS(t.base)&&aS(t),ub=t=>t.x,db=t=>t.y,aye=(t,e)=>{if(typeof t=="function")return t;var n="curve".concat(vy(t));if((n==="curveMonotone"||n==="curveBump")&&e){var r=W8["".concat(n).concat(e==="vertical"?"Y":"X")];if(r)return r}return W8[n]||gN},K8={connectNulls:!1,type:"linear"},sye=t=>{var{type:e=K8.type,points:n=[],baseLine:r,layout:i,connectNulls:a=K8.connectNulls}=t,o=aye(e,i),l=a?n.filter(aS):n;if(Array.isArray(r)){var c,u=n.map((b,y)=>G8(G8({},b),{},{base:r[y]}));i==="vertical"?c=p_().y(db).x1(ub).x0(b=>b.base.x):c=p_().x(ub).y1(db).y0(b=>b.base.y);var d=c.defined(q8).curve(o),f=a?u.filter(q8):u;return d(f)}var m;i==="vertical"&&zt(r)?m=p_().y(db).x1(ub).x0(r):zt(r)?m=p_().x(ub).y1(db).y0(r):m=$K().x(ub).y(db);var p=m.defined(aS).curve(o);return p(l)},ng=t=>{var{className:e,points:n,path:r,pathRef:i}=t,a=hh();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?sye(o):r;return w.createElement("path",ZP({},ns(t),tO(t),{className:Bn("recharts-curve",e),d:l===null?void 0:l,ref:i}))},oye=["x","y","top","left","width","height","className"];function JP(){return JP=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},JP.apply(null,arguments)}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 lye(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){cye(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 cye(t,e,n){return(e=uye(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function uye(t){var e=dye(t,"string");return typeof e=="symbol"?e:e+""}function dye(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 hye(t,e){if(t==null)return{};var n,r,i=fye(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 fye(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 mye=(t,e,n,r,i,a)=>"M".concat(t,",").concat(i,"v").concat(r,"M").concat(a,",").concat(e,"h").concat(n),pye=t=>{var{x:e=0,y:n=0,top:r=0,left:i=0,width:a=0,height:o=0,className:l}=t,c=hye(t,oye),u=lye({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",JP({},Aa(u),{className:Bn("recharts-cross",l),d:mye(e,n,a,o,r,i)}))};function gye(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 Y8(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 Q8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Y8(Object(n),!0).forEach(function(r){xye(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Y8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function xye(t,e,n){return(e=bye(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function bye(t){var e=yye(t,"string");return typeof e=="symbol"?e:e+""}function yye(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 vye=t=>t.replace(/([A-Z])/g,e=>"-".concat(e.toLowerCase())),xY=(t,e,n)=>t.map(r=>"".concat(vye(r)," ").concat(e,"ms ").concat(n)).join(","),_ye=(t,e)=>[Object.keys(t),Object.keys(e)].reduce((n,r)=>n.filter(i=>r.includes(i))),F0=(t,e)=>Object.keys(e).reduce((n,r)=>Q8(Q8({},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){wye(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 wye(t,e,n){return(e=Sye(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Sye(t){var e=Mye(t,"string");return typeof e=="symbol"?e:e+""}function Mye(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 sS=(t,e,n)=>t+(e-t)*n,e3=t=>{var{from:e,to:n}=t;return e!==n},bY=(t,e,n)=>{var r=F0((i,a)=>{if(e3(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?F0((i,a)=>e3(a)&&r[i]!=null?Ri(Ri({},a),{},{velocity:sS(a.velocity,r[i].velocity,n),from:sS(a.from,r[i].from,n)}):a,e):bY(t,r,n-1)};function Nye(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=()=>F0((m,p)=>p.from,l),u=()=>!Object.values(l).filter(e3).length,d=null,f=m=>{o||(o=m);var p=m-o,b=p/n.dt;l=bY(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=F0((y,x)=>sS(...x,n(m)),c);if(a(Ri(Ri(Ri({},t),e),p)),m<1)l=o.setTimeout(d);else{var b=F0((y,x)=>sS(...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 Aye=(t,e,n,r,i,a)=>{var o=_ye(t,e);return n==null?()=>(i(Ri(Ri({},t),e)),()=>{}):n.isStepper===!0?Nye(t,e,n,o,i,a):Eye(t,e,n,r,o,i,a)};var oS=1e-4,yY=(t,e)=>[0,3*t,3*e-6*t,3*t-3*e+1],vY=(t,e)=>t.map((n,r)=>n*e**r).reduce((n,r)=>n+r),J8=(t,e)=>n=>{var r=yY(t,e);return vY(r,n)},Tye=(t,e)=>n=>{var r=yY(t,e),i=[...r.map((a,o)=>a*o).slice(1),0];return vY(i,n)},Cye=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]]},kye=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=Cye(n[0]);if(i)return i}}return n.length===4?n:[0,0,1,1]},jye=(t,e,n,r)=>{var i=J8(t,n),a=J8(e,r),o=Tye(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)<oS||b<oS)return a(f);f=l(f-p/b)}return a(f)};return c.isStepper=!1,c},e6=function(){return jye(...kye(...arguments))},Pye=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)<oS&&Math.abs(f)<oS?[l,0]:[m,f]};return a.isStepper=!0,a.dt=i,a},Rye=t=>{if(typeof t=="string")switch(t){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return e6(t);case"spring":return Pye();default:if(t.split("(")[0]==="cubic-bezier")return e6(t)}return typeof t=="function"?t:null};function Dye(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 Oye{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 Lye(){return Dye(new Oye)}var Iye=w.createContext(Lye);function Fye(t,e){var n=w.useContext(Iye);return w.useMemo(()=>e??n(t),[t,e,n])}var Uye=()=>!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout),Ty={isSsr:Uye()},zye={begin:0,duration:1e3,easing:"ease",isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},t6={t:0},hC={t:1};function Zg(t){var e=Kr(t,zye),{isActive:n,canBegin:r,duration:i,easing:a,begin:o,onAnimationEnd:l,onAnimationStart:c,children:u}=e,d=n==="auto"?!Ty.isSsr:n,f=Fye(e.animationId,e.animationManager),[m,p]=w.useState(d?t6:hC),b=w.useRef(null);return w.useEffect(()=>{d||p(hC)},[d]),w.useEffect(()=>{if(!d||!r)return uh;var y=Aye(t6,hC,Rye(a),i,p,f.getTimeoutController()),x=()=>{b.current=y()};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 Jg(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"animation-",n=w.useRef(j0(e)),r=w.useRef(t);return r.current!==t&&(n.current=j0(e),r.current=t),n.current}var Bye=["radius"],$ye=["radius"],n6,r6,i6,a6,s6,o6,l6,c6,u6,d6;function h6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function f6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?h6(Object(n),!0).forEach(function(r){Hye(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):h6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Hye(t,e,n){return(e=Vye(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Vye(t){var e=Gye(t,"string");return typeof e=="symbol"?e:e+""}function Gye(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 lS(){return lS=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},lS.apply(null,arguments)}function m6(t,e){if(t==null)return{};var n,r,i=Wye(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 Wye(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 Nl(t,e){return e||(e=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}var p6=(t,e,n,r,i)=>{var a=Cd(n),o=Cd(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 y,x=(y=i[p])!==null&&y!==void 0?y:0;m[p]=x>l?l:x}f=ni(n6||(n6=Nl(["M",",",""])),t,e+c*m[0]),m[0]>0&&(f+=ni(r6||(r6=Nl(["A ",",",",0,0,",",",",",""])),m[0],m[0],d,t+u*m[0],e)),f+=ni(i6||(i6=Nl(["L ",",",""])),t+n-u*m[1],e),m[1]>0&&(f+=ni(a6||(a6=Nl(["A ",",",",0,0,",`,
- `,",",""])),m[1],m[1],d,t+n,e+c*m[1])),f+=ni(s6||(s6=Nl(["L ",",",""])),t+n,e+r-c*m[2]),m[2]>0&&(f+=ni(o6||(o6=Nl(["A ",",",",0,0,",`,
- `,",",""])),m[2],m[2],d,t+n-u*m[2],e+r)),f+=ni(l6||(l6=Nl(["L ",",",""])),t+u*m[3],e+r),m[3]>0&&(f+=ni(c6||(c6=Nl(["A ",",",",0,0,",`,
- `,",",""])),m[3],m[3],d,t,e+r-c*m[3])),f+="Z"}else if(l>0&&i===+i&&i>0){var v=Math.min(l,i);f=ni(u6||(u6=Nl(["M ",",",`
- A `,",",",0,0,",",",",",`
- L `,",",`
- A `,",",",0,0,",",",",",`
- L `,",",`
- A `,",",",0,0,",",",",",`
- L `,",",`
- A `,",",",0,0,",",",","," Z"])),t,e+c*v,v,v,d,t+u*v,e,t+n-u*v,e,v,v,d,t+n,e+c*v,t+n,e+r-c*v,v,v,d,t+n-u*v,e+r,t+u*v,e+r,v,v,d,t,e+r-c*v)}else f=ni(d6||(d6=Nl(["M ",","," h "," v "," h "," Z"])),t,e,n,r,-n);return f},g6={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},_Y=t=>{var e=Kr(t,g6),n=w.useRef(null),[r,i]=w.useState(-1);w.useEffect(()=>{if(n.current&&n.current.getTotalLength)try{var G=n.current.getTotalLength();G&&i(G)}catch{}},[]);var{x:a,y:o,width:l,height:c,radius:u,className:d}=e,{animationEasing:f,animationDuration:m,animationBegin:p,isAnimationActive:b,isUpdateAnimationActive:y}=e,x=w.useRef(l),v=w.useRef(c),S=w.useRef(a),M=w.useRef(o),E=w.useMemo(()=>({x:a,y:o,width:l,height:c,radius:u}),[a,o,l,c,u]),A=Jg(E,"rectangle-");if(a!==+a||o!==+o||l!==+l||c!==+c||l===0||c===0)return null;var k=Bn("recharts-rectangle",d);if(!y){var T=Aa(e),{radius:D}=T,C=m6(T,Bye);return w.createElement("path",lS({},C,{x:Cd(a),y:Cd(o),width:Cd(l),height:Cd(c),radius:typeof u=="number"?u:void 0,className:k,d:p6(a,o,l,c,u)}))}var R=x.current,U=v.current,O=S.current,q=M.current,j="0px ".concat(r===-1?1:r,"px"),W="".concat(r,"px 0px"),X=xY(["strokeDasharray"],m,typeof f=="string"?f:g6.animationEasing);return w.createElement(Zg,{animationId:A,key:A,canBegin:r>0,duration:m,easing:f,isActive:y,begin:p},G=>{var Z=nr(R,l,G),te=nr(U,c,G),ee=nr(O,a,G),z=nr(q,o,G);n.current&&(x.current=Z,v.current=te,S.current=ee,M.current=z);var V;b?G>0?V={transition:X,strokeDasharray:W}:V={strokeDasharray:j}:V={strokeDasharray:W};var ne=Aa(e),{radius:ie}=ne,he=m6(ne,$ye);return w.createElement("path",lS({},he,{radius:typeof u=="number"?u:void 0,className:k,d:p6(ee,z,Z,te,u),ref:n,style:f6(f6({},V),e.style)}))})};function x6(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 b6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?x6(Object(n),!0).forEach(function(r){qye(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):x6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function qye(t,e,n){return(e=Kye(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Kye(t){var e=Xye(t,"string");return typeof e=="symbol"?e:e+""}function Xye(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var cS=Math.PI/180,Yye=t=>t*180/Math.PI,Ni=(t,e,n,r)=>({x:t+Math.cos(-cS*r)*n,y:e+Math.sin(-cS*r)*n}),wY=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},Qye=(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=Qye({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:Yye(c),angleInRadian:c}},Jye=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}},eve=(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},tve=(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}=Jye(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?b6(b6({},e),{},{radius:i,angle:eve(d,e)}):null};function SY(t){var{cx:e,cy:n,radius:r,startAngle:i,endAngle:a}=t,o=Ni(e,n,r,i),l=Ni(e,n,r,a);return{points:[o,l],cx:e,cy:n,radius:r,startAngle:i,endAngle:a}}var y6,v6,_6,w6,S6,M6,N6;function t3(){return t3=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},t3.apply(null,arguments)}function df(t,e){return e||(e=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}var nve=(t,e)=>{var n=ea(e-t),r=Math.min(Math.abs(e-t),359.999);return n*r},M_=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)/cS,f=c?i:i+a*d,m=Ni(e,n,u,f),p=Ni(e,n,r,f),b=c?i-a*d:i,y=Ni(e,n,u*Math.cos(d*cS),b);return{center:m,circleTangency:p,lineTangency:y,theta:d}},MY=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:a,endAngle:o}=t,l=nve(a,o),c=a+l,u=Ni(e,n,i,a),d=Ni(e,n,i,c),f=ni(y6||(y6=df(["M ",",",`
- A `,",",`,0,
- `,",",`,
- `,",",`
- `])),u.x,u.y,i,i,+(Math.abs(l)>180),+(a>c),d.x,d.y);if(r>0){var m=Ni(e,n,r,a),p=Ni(e,n,r,c);f+=ni(v6||(v6=df(["L ",",",`
- A `,",",`,0,
- `,",",`,
- `,","," Z"])),p.x,p.y,r,r,+(Math.abs(l)>180),+(a<=c),m.x,m.y)}else f+=ni(_6||(_6=df(["L ",","," Z"])),e,n);return f},rve=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}=M_({cx:e,cy:n,radius:i,angle:c,sign:d,cornerRadius:a,cornerIsExternal:l}),{circleTangency:b,lineTangency:y,theta:x}=M_({cx:e,cy:n,radius:i,angle:u,sign:-d,cornerRadius:a,cornerIsExternal:l}),v=l?Math.abs(c-u):Math.abs(c-u)-p-x;if(v<0)return o?ni(w6||(w6=df(["M ",",",`
- a`,",",",0,0,1,",`,0
- a`,",",",0,0,1,",`,0
- `])),m.x,m.y,a,a,a*2,a,a,-a*2):MY({cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:c,endAngle:u});var S=ni(S6||(S6=df(["M ",",",`
- A`,",",",0,0,",",",",",`
- A`,",",",0,",",",",",",",`
- A`,",",",0,0,",",",",",`
- `])),m.x,m.y,a,a,+(d<0),f.x,f.y,i,i,+(v>180),+(d<0),b.x,b.y,a,a,+(d<0),y.x,y.y);if(r>0){var{circleTangency:M,lineTangency:E,theta:A}=M_({cx:e,cy:n,radius:r,angle:c,sign:d,isExternal:!0,cornerRadius:a,cornerIsExternal:l}),{circleTangency:k,lineTangency:T,theta:D}=M_({cx:e,cy:n,radius:r,angle:u,sign:-d,isExternal:!0,cornerRadius:a,cornerIsExternal:l}),C=l?Math.abs(c-u):Math.abs(c-u)-A-D;if(C<0&&a===0)return"".concat(S,"L").concat(e,",").concat(n,"Z");S+=ni(M6||(M6=df(["L",",",`
- A`,",",",0,0,",",",",",`
- A`,",",",0,",",",",",",",`
- A`,",",",0,0,",",",",","Z"])),T.x,T.y,a,a,+(d<0),k.x,k.y,r,r,+(C>180),+(d>0),M.x,M.y,a,a,+(d<0),E.x,E.y)}else S+=ni(N6||(N6=df(["L",",","Z"])),e,n);return S},ive={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},NY=t=>{var e=Kr(t,ive),{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),y;return b>0&&Math.abs(u-d)<360?y=rve({cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:Math.min(b,p/2),forceCornerRadius:l,cornerIsExternal:c,startAngle:u,endAngle:d}):y=MY({cx:n,cy:r,innerRadius:i,outerRadius:a,startAngle:u,endAngle:d}),w.createElement("path",t3({},Aa(e),{className:m,d:y}))};function ave(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(rX(e)){if(t==="centric"){var{cx:r,cy:i,innerRadius:a,outerRadius:o,angle:l}=e,c=Ni(r,i,a,l),u=Ni(r,i,o,l);return[{x:c.x,y:c.y},{x:u.x,y:u.y}]}return SY(e)}}var fC={},mC={},pC={},E6;function sve(){return E6||(E6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=pX();function n(r){return e.isSymbol(r)?NaN:Number(r)}t.toNumber=n})(pC)),pC}var A6;function ove(){return A6||(A6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=sve();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})(mC)),mC}var T6;function lve(){return T6||(T6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=gX(),n=ove();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})(fC)),fC}var gC,C6;function cve(){return C6||(C6=1,gC=lve().range),gC}var uve=cve();const EY=ml(uve);function zd(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function dve(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function vO(t){let e,n,r;t.length!==2?(e=zd,n=(l,c)=>zd(t(l),c),r=(l,c)=>t(l)-c):(e=t===zd||t===dve?t:hve,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 hve(){return 0}function AY(t){return t===null?NaN:+t}function*fve(t,e){for(let n of t)n!=null&&(n=+n)>=n&&(yield n)}const mve=vO(zd),Cy=mve.right;vO(AY).center;class k6 extends Map{constructor(e,n=xve){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(j6(this,e))}has(e){return super.has(j6(this,e))}set(e,n){return super.set(pve(this,e),n)}delete(e){return super.delete(gve(this,e))}}function j6({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function pve({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}function gve({_intern:t,_key:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}function xve(t){return t!==null&&typeof t=="object"?t.valueOf():t}function bve(t=zd){if(t===zd)return TY;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 TY(t,e){return(t==null||!(t>=t))-(e==null||!(e>=e))||(t<e?-1:t>e?1:0)}const yve=Math.sqrt(50),vve=Math.sqrt(10),_ve=Math.sqrt(2);function uS(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>=yve?10:a>=vve?5:a>=_ve?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?uS(t,e,n*2):[l,c,u]}function n3(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?uS(e,t,n):uS(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 r3(t,e,n){return e=+e,t=+t,n=+n,uS(t,e,n)[2]}function i3(t,e,n){e=+e,t=+t,n=+n;const r=e<t,i=r?r3(e,t,n):r3(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}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 R6(t,e){let n;for(const r of t)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);return n}function CY(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?TY:bve(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));CY(t,e,p,b,i)}const a=t[e];let o=n,l=r;for(hb(t,n,e),i(t[r],a)>0&&hb(t,n,r);o<l;){for(hb(t,o,l),++o,--l;i(t[o],a)<0;)++o;for(;i(t[l],a)>0;)--l}i(t[n],a)===0?hb(t,n,l):(++l,hb(t,l,r)),l<=e&&(n=l+1),e<=l&&(r=l-1)}return t}function hb(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function wve(t,e,n){if(t=Float64Array.from(fve(t)),!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return R6(t);if(e>=1)return P6(t);var r,i=(r-1)*e,a=Math.floor(i),o=P6(CY(t,a).subarray(0,a+1)),l=R6(t.subarray(a+1));return o+(l-o)*(i-a)}}function Sve(t,e,n=AY){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 Mve(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 zo(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 a3=Symbol("implicit");function _O(){var t=new k6,e=[],n=[],r=a3;function i(a){let o=t.get(a);if(o===void 0){if(r!==a3)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 k6;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 _O(e,n).unknown(r)},zo.apply(i,arguments),i}function wO(){var t=_O().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,y=p?r:i;a=(y-b)/Math.max(1,m-c+u*2),l&&(a=Math.floor(a)),b+=(y-b-a*(m-c))*d,o=a*(1-c),l&&(b=Math.round(b),o=Math.round(o));var x=Mve(m).map(function(v){return b+a*v});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 wO(e(),[r,i]).round(l).paddingInner(c).paddingOuter(u).align(d)},zo.apply(f(),arguments)}function kY(t){var e=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,delete t.paddingOuter,t.copy=function(){return kY(e())},t}function Nve(){return kY(wO.apply(null,arguments).paddingInner(1))}function SO(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function jY(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function ky(){}var U0=.7,dS=1/U0,rg="\\s*([+-]?\\d+)\\s*",z0="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Wl="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Eve=/^#([0-9a-f]{3,8})$/,Ave=new RegExp(`^rgb\\(${rg},${rg},${rg}\\)$`),Tve=new RegExp(`^rgb\\(${Wl},${Wl},${Wl}\\)$`),Cve=new RegExp(`^rgba\\(${rg},${rg},${rg},${z0}\\)$`),kve=new RegExp(`^rgba\\(${Wl},${Wl},${Wl},${z0}\\)$`),jve=new RegExp(`^hsl\\(${z0},${Wl},${Wl}\\)$`),Pve=new RegExp(`^hsla\\(${z0},${Wl},${Wl},${z0}\\)$`),D6={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};SO(ky,B0,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:O6,formatHex:O6,formatHex8:Rve,formatHsl:Dve,formatRgb:L6,toString:L6});function O6(){return this.rgb().formatHex()}function Rve(){return this.rgb().formatHex8()}function Dve(){return PY(this).formatHsl()}function L6(){return this.rgb().formatRgb()}function B0(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=Eve.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?I6(e):n===3?new _s(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?N_(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?N_(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=Ave.exec(t))?new _s(e[1],e[2],e[3],1):(e=Tve.exec(t))?new _s(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Cve.exec(t))?N_(e[1],e[2],e[3],e[4]):(e=kve.exec(t))?N_(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=jve.exec(t))?z6(e[1],e[2]/100,e[3]/100,1):(e=Pve.exec(t))?z6(e[1],e[2]/100,e[3]/100,e[4]):D6.hasOwnProperty(t)?I6(D6[t]):t==="transparent"?new _s(NaN,NaN,NaN,0):null}function I6(t){return new _s(t>>16&255,t>>8&255,t&255,1)}function N_(t,e,n,r){return r<=0&&(t=e=n=NaN),new _s(t,e,n,r)}function Ove(t){return t instanceof ky||(t=B0(t)),t?(t=t.rgb(),new _s(t.r,t.g,t.b,t.opacity)):new _s}function s3(t,e,n,r){return arguments.length===1?Ove(t):new _s(t,e,n,r??1)}function _s(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}SO(_s,s3,jY(ky,{brighter(t){return t=t==null?dS:Math.pow(dS,t),new _s(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?U0:Math.pow(U0,t),new _s(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new _s(Mf(this.r),Mf(this.g),Mf(this.b),hS(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:F6,formatHex:F6,formatHex8:Lve,formatRgb:U6,toString:U6}));function F6(){return`#${hf(this.r)}${hf(this.g)}${hf(this.b)}`}function Lve(){return`#${hf(this.r)}${hf(this.g)}${hf(this.b)}${hf((isNaN(this.opacity)?1:this.opacity)*255)}`}function U6(){const t=hS(this.opacity);return`${t===1?"rgb(":"rgba("}${Mf(this.r)}, ${Mf(this.g)}, ${Mf(this.b)}${t===1?")":`, ${t})`}`}function hS(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Mf(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function hf(t){return t=Mf(t),(t<16?"0":"")+t.toString(16)}function z6(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Jo(t,e,n,r)}function PY(t){if(t instanceof Jo)return new Jo(t.h,t.s,t.l,t.opacity);if(t instanceof ky||(t=B0(t)),!t)return new Jo;if(t instanceof Jo)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 Jo(o,l,c,t.opacity)}function Ive(t,e,n,r){return arguments.length===1?PY(t):new Jo(t,e,n,r??1)}function Jo(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}SO(Jo,Ive,jY(ky,{brighter(t){return t=t==null?dS:Math.pow(dS,t),new Jo(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?U0:Math.pow(U0,t),new Jo(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 _s(xC(t>=240?t-240:t+120,i,r),xC(t,i,r),xC(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new Jo(B6(this.h),E_(this.s),E_(this.l),hS(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=hS(this.opacity);return`${t===1?"hsl(":"hsla("}${B6(this.h)}, ${E_(this.s)*100}%, ${E_(this.l)*100}%${t===1?")":`, ${t})`}`}}));function B6(t){return t=(t||0)%360,t<0?t+360:t}function E_(t){return Math.max(0,Math.min(1,t||0))}function xC(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 MO=t=>()=>t;function Fve(t,e){return function(n){return t+n*e}}function Uve(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 zve(t){return(t=+t)==1?RY:function(e,n){return n-e?Uve(e,n,t):MO(isNaN(e)?n:e)}}function RY(t,e){var n=e-t;return n?Fve(t,n):MO(isNaN(t)?e:t)}const $6=(function t(e){var n=zve(e);function r(i,a){var o=n((i=s3(i)).r,(a=s3(a)).r),l=n(i.g,a.g),c=n(i.b,a.b),u=RY(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 Bve(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 $ve(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Hve(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]=ex(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 Vve(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function fS(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function Gve(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]=ex(t[i],e[i]):r[i]=e[i];return function(a){for(i in n)r[i]=n[i](a);return r}}var o3=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,bC=new RegExp(o3.source,"g");function Wve(t){return function(){return t}}function qve(t){return function(e){return t(e)+""}}function Kve(t,e){var n=o3.lastIndex=bC.lastIndex=0,r,i,a,o=-1,l=[],c=[];for(t=t+"",e=e+"";(r=o3.exec(t))&&(i=bC.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:fS(r,i)})),n=bC.lastIndex;return n<e.length&&(a=e.slice(n),l[o]?l[o]+=a:l[++o]=a),l.length<2?c[0]?qve(c[0].x):Wve(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 ex(t,e){var n=typeof e,r;return e==null||n==="boolean"?MO(e):(n==="number"?fS:n==="string"?(r=B0(e))?(e=r,$6):Kve:e instanceof B0?$6:e instanceof Date?Vve:$ve(e)?Bve:Array.isArray(e)?Hve:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?Gve:fS)(t,e)}function NO(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}function Xve(t,e){e===void 0&&(e=t,t=ex);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 Yve(t){return function(){return t}}function mS(t){return+t}var H6=[0,1];function Qa(t){return t}function l3(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:Yve(isNaN(e)?NaN:.5)}function Qve(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=l3(i,r),a=n(o,a)):(r=l3(r,i),a=n(a,o)),function(l){return a(r(l))}}function Jve(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]=l3(t[o],t[o+1]),a[o]=n(e[o],e[o+1]);return function(l){var c=Cy(t,l,1,r)-1;return a[c](i[c](l))}}function jy(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function ON(){var t=H6,e=H6,n=ex,r,i,a,o=Qa,l,c,u;function d(){var m=Math.min(t.length,e.length);return o!==Qa&&(o=Qve(t[0],t[m-1])),l=m>2?Jve: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),fS)))(m)))},f.domain=function(m){return arguments.length?(t=Array.from(m,mS),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=NO,d()},f.clamp=function(m){return arguments.length?(o=m?!0:Qa,d()):o!==Qa},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 ON()(Qa,Qa)}function e_e(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function pS(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 Sg(t){return t=pS(Math.abs(t)),t?t[1]:NaN}function t_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 n_e(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var r_e=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function $0(t){if(!(e=r_e.exec(t)))throw new Error("invalid format: "+t);var e;return new AO({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]})}$0.prototype=AO.prototype;function AO(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+""}AO.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 i_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 gS;function a_e(t,e){var n=pS(t,e);if(!n)return gS=void 0,t.toPrecision(e);var r=n[0],i=n[1],a=i-(gS=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")+pS(t,Math.max(0,e+a-1))[0]}function V6(t,e){var n=pS(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 G6={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:e_e,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)=>V6(t*100,e),r:V6,s:a_e,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function W6(t){return t}var q6=Array.prototype.map,K6=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function s_e(t){var e=t.grouping===void 0||t.thousands===void 0?W6:t_e(q6.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?W6:n_e(q6.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=$0(f);var p=f.fill,b=f.align,y=f.sign,x=f.symbol,v=f.zero,S=f.width,M=f.comma,E=f.precision,A=f.trim,k=f.type;k==="n"?(M=!0,k="g"):G6[k]||(E===void 0&&(E=12),A=!0,k="g"),(v||p==="0"&&b==="=")&&(v=!0,p="0",b="=");var T=(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:""),C=G6[k],R=/[defgprs%]/.test(k);E=E===void 0?6:/[gprs]/.test(k)?Math.max(1,Math.min(21,E)):Math.max(0,Math.min(20,E));function U(O){var q=T,j=D,W,X,G;if(k==="c")j=C(O)+j,O="";else{O=+O;var Z=O<0||1/O<0;if(O=isNaN(O)?c:C(Math.abs(O),E),A&&(O=i_e(O)),Z&&+O==0&&y!=="+"&&(Z=!1),q=(Z?y==="("?y:l:y==="-"||y==="("?"":y)+q,j=(k==="s"&&!isNaN(O)&&gS!==void 0?K6[8+gS/3]:"")+j+(Z&&y==="("?")":""),R){for(W=-1,X=O.length;++W<X;)if(G=O.charCodeAt(W),48>G||G>57){j=(G===46?i+O.slice(W+1):O.slice(W))+j,O=O.slice(0,W);break}}}M&&!v&&(O=e(O,1/0));var te=q.length+O.length+j.length,ee=te<S?new Array(S-te+1).join(p):"";switch(M&&v&&(O=e(ee+O,ee.length?S-j.length:1/0),ee=""),b){case"<":O=q+O+j+ee;break;case"=":O=q+ee+O+j;break;case"^":O=ee.slice(0,te=ee.length>>1)+q+O+j+ee.slice(te);break;default:O=ee+q+O+j;break}return a(O)}return U.toString=function(){return f+""},U}function d(f,m){var p=Math.max(-8,Math.min(8,Math.floor(Sg(m)/3)))*3,b=Math.pow(10,-p),y=u((f=$0(f),f.type="f",f),{suffix:K6[8+p/3]});return function(x){return y(b*x)}}return{format:u,formatPrefix:d}}var A_,TO,DY;o_e({thousands:",",grouping:[3],currency:["$",""]});function o_e(t){return A_=s_e(t),TO=A_.format,DY=A_.formatPrefix,A_}function l_e(t){return Math.max(0,-Sg(Math.abs(t)))}function c_e(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Sg(e)/3)))*3-Sg(Math.abs(t)))}function u_e(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,Sg(e)-Sg(t))+1}function OY(t,e,n,r){var i=i3(t,e,n),a;switch(r=$0(r??",f"),r.type){case"s":{var o=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(a=c_e(i,o))&&(r.precision=a),DY(r,o)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(a=u_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=l_e(i))&&(r.precision=a-(r.type==="%")*2);break}}return TO(r)}function fh(t){var e=t.domain;return t.ticks=function(n){var r=e();return n3(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var i=e();return OY(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=r3(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 LY(){var t=EO();return t.copy=function(){return jy(t,LY())},zo.apply(t,arguments),fh(t)}function IY(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,mS),n):t.slice()},n.unknown=function(r){return arguments.length?(e=r,n):e},n.copy=function(){return IY(t).unknown(e)},t=arguments.length?Array.from(t,mS):[0,1],fh(n)}function FY(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 X6(t){return Math.log(t)}function Y6(t){return Math.exp(t)}function d_e(t){return-Math.log(-t)}function h_e(t){return-Math.exp(-t)}function f_e(t){return isFinite(t)?+("1e"+t):t<0?0:t}function m_e(t){return t===10?f_e:t===Math.E?Math.exp:e=>Math.pow(t,e)}function p_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 Q6(t){return(e,n)=>-t(-e,n)}function CO(t){const e=t(X6,Y6),n=e.domain;let r=10,i,a;function o(){return i=p_e(r),a=m_e(r),n()[0]<0?(i=Q6(i),a=Q6(a),t(d_e,h_e)):t(X6,Y6),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,y;const x=l==null?10:+l;let v=[];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(y=m<0?b/a(-m):b*a(m),!(y<u)){if(y>d)break;v.push(y)}}else for(;m<=p;++m)for(b=r-1;b>=1;--b)if(y=m>0?b/a(-m):b*a(m),!(y<u)){if(y>d)break;v.push(y)}v.length*2<x&&(v=n3(u,d,x))}else v=n3(m,p,Math.min(p-m,x)).map(a);return f?v.reverse():v},e.tickFormat=(l,c)=>{if(l==null&&(l=10),c==null&&(c=r===10?"s":","),typeof c!="function"&&(!(r%1)&&(c=$0(c)).precision==null&&(c.trim=!0),c=TO(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(FY(n(),{floor:l=>a(Math.floor(i(l))),ceil:l=>a(Math.ceil(i(l)))})),e}function UY(){const t=CO(ON()).domain([1,10]);return t.copy=()=>jy(t,UY()).base(t.base()),zo.apply(t,arguments),t}function Z6(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function J6(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function kO(t){var e=1,n=t(Z6(e),J6(e));return n.constant=function(r){return arguments.length?t(Z6(e=+r),J6(e)):e},fh(n)}function zY(){var t=kO(ON());return t.copy=function(){return jy(t,zY()).constant(t.constant())},zo.apply(t,arguments)}function e$(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function g_e(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function x_e(t){return t<0?-t*t:t*t}function jO(t){var e=t(Qa,Qa),n=1;function r(){return n===1?t(Qa,Qa):n===.5?t(g_e,x_e):t(e$(n),e$(1/n))}return e.exponent=function(i){return arguments.length?(n=+i,r()):n},fh(e)}function PO(){var t=jO(ON());return t.copy=function(){return jy(t,PO()).exponent(t.exponent())},zo.apply(t,arguments),t}function b_e(){return PO.apply(null,arguments).exponent(.5)}function t$(t){return Math.sign(t)*t*t}function y_e(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function BY(){var t=EO(),e=[0,1],n=!1,r;function i(a){var o=y_e(t(a));return isNaN(o)?r:n?Math.round(o):o}return i.invert=function(a){return t.invert(t$(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,mS)).map(t$)),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 BY(t.domain(),e).round(n).clamp(t.clamp()).unknown(r)},zo.apply(i,arguments),fh(i)}function $Y(){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]=Sve(t,o/l);return a}function a(o){return o==null||isNaN(o=+o)?r:e[Cy(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(zd),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 $Y().domain(t).range(e).unknown(r)},zo.apply(a,arguments)}function HY(){var t=0,e=1,n=1,r=[.5],i=[0,1],a;function o(c){return c!=null&&c<=c?i[Cy(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 HY().domain([t,e]).range(i).unknown(a)},zo.apply(fh(o),arguments)}function VY(){var t=[.5],e=[0,1],n,r=1;function i(a){return a!=null&&a<=a?e[Cy(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 VY().domain(t).range(e).unknown(n)},zo.apply(i,arguments)}const yC=new Date,vC=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)=>(yC.setTime(+a),vC.setTime(+o),t(yC),t(vC),Math.floor(n(yC,vC))),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 xS=$i(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);xS.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):xS);xS.range;const Zc=1e3,To=Zc*60,Jc=To*60,mu=Jc*24,RO=mu*7,n$=mu*30,_C=mu*365,ff=$i(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*Zc)},(t,e)=>(e-t)/Zc,t=>t.getUTCSeconds());ff.range;const DO=$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());DO.range;const OO=$i(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*To)},(t,e)=>(e-t)/To,t=>t.getUTCMinutes());OO.range;const LO=$i(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Zc-t.getMinutes()*To)},(t,e)=>{t.setTime(+t+e*Jc)},(t,e)=>(e-t)/Jc,t=>t.getHours());LO.range;const IO=$i(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*Jc)},(t,e)=>(e-t)/Jc,t=>t.getUTCHours());IO.range;const Py=$i(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*To)/mu,t=>t.getDate()-1);Py.range;const LN=$i(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/mu,t=>t.getUTCDate()-1);LN.range;const GY=$i(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/mu,t=>Math.floor(t/mu));GY.range;function um(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)/RO)}const IN=um(0),bS=um(1),v_e=um(2),__e=um(3),Mg=um(4),w_e=um(5),S_e=um(6);IN.range;bS.range;v_e.range;__e.range;Mg.range;w_e.range;S_e.range;function dm(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)/RO)}const FN=dm(0),yS=dm(1),M_e=dm(2),N_e=dm(3),Ng=dm(4),E_e=dm(5),A_e=dm(6);FN.range;yS.range;M_e.range;N_e.range;Ng.range;E_e.range;A_e.range;const FO=$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());FO.range;const UO=$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());UO.range;const pu=$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());pu.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)});pu.range;const gu=$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());gu.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)});gu.range;function WY(t,e,n,r,i,a){const o=[[ff,1,Zc],[ff,5,5*Zc],[ff,15,15*Zc],[ff,30,30*Zc],[a,1,To],[a,5,5*To],[a,15,15*To],[a,30,30*To],[i,1,Jc],[i,3,3*Jc],[i,6,6*Jc],[i,12,12*Jc],[r,1,mu],[r,2,2*mu],[n,1,RO],[e,1,n$],[e,3,3*n$],[t,1,_C]];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=vO(([,,x])=>x).right(o,m);if(p===o.length)return t.every(i3(u/_C,d/_C,f));if(p===0)return xS.every(Math.max(i3(u,d,f),1));const[b,y]=o[m/o[p-1][2]<o[p][2]/m?p-1:p];return b.every(y)}return[l,c]}const[T_e,C_e]=WY(gu,UO,FN,GY,IO,OO),[k_e,j_e]=WY(pu,FO,IN,Py,LO,DO);function wC(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 SC(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 fb(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function P_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=mb(i),d=pb(i),f=mb(a),m=pb(a),p=mb(o),b=pb(o),y=mb(l),x=pb(l),v=mb(c),S=pb(c),M={a:G,A:Z,b:te,B:ee,c:null,d:l$,e:l$,f:t1e,g:d1e,G:f1e,H:Z_e,I:J_e,j:e1e,L:qY,m:n1e,M:r1e,p:z,q:V,Q:d$,s:h$,S:i1e,u:a1e,U:s1e,V:o1e,w:l1e,W:c1e,x:null,X:null,y:u1e,Y:h1e,Z:m1e,"%":u$},E={a:ne,A:ie,b:he,B:me,c:null,d:c$,e:c$,f:b1e,g:T1e,G:k1e,H:p1e,I:g1e,j:x1e,L:XY,m:y1e,M:v1e,p:oe,q:Ae,Q:d$,s:h$,S:_1e,u:w1e,U:S1e,V:M1e,w:N1e,W:E1e,x:null,X:null,y:A1e,Y:C1e,Z:j1e,"%":u$},A={a:R,A:U,b:O,B:q,c:j,d:s$,e:s$,f:K_e,g:a$,G:i$,H:o$,I:o$,j:V_e,L:q_e,m:H_e,M:G_e,p:C,q:$_e,Q:Y_e,s:Q_e,S:W_e,u:I_e,U:F_e,V:U_e,w:L_e,W:z_e,x:W,X,y:a$,Y:i$,Z:B_e,"%":X_e};M.x=k(n,M),M.X=k(r,M),M.c=k(e,M),E.x=k(n,E),E.X=k(r,E),E.c=k(e,E);function k(ge,Ne){return function(_e){var le=[],He=-1,H=0,J=ge.length,K,B,I;for(_e instanceof Date||(_e=new Date(+_e));++He<J;)ge.charCodeAt(He)===37&&(le.push(ge.slice(H,He)),(B=r$[K=ge.charAt(++He)])!=null?K=ge.charAt(++He):B=K==="e"?" ":"0",(I=Ne[K])&&(K=I(_e,B)),le.push(K),H=He+1);return le.push(ge.slice(H,He)),le.join("")}}function T(ge,Ne){return function(_e){var le=fb(1900,void 0,1),He=D(le,ge,_e+="",0),H,J;if(He!=_e.length)return null;if("Q"in le)return new Date(le.Q);if("s"in le)return new Date(le.s*1e3+("L"in le?le.L:0));if(Ne&&!("Z"in le)&&(le.Z=0),"p"in le&&(le.H=le.H%12+le.p*12),le.m===void 0&&(le.m="q"in le?le.q:0),"V"in le){if(le.V<1||le.V>53)return null;"w"in le||(le.w=1),"Z"in le?(H=SC(fb(le.y,0,1)),J=H.getUTCDay(),H=J>4||J===0?yS.ceil(H):yS(H),H=LN.offset(H,(le.V-1)*7),le.y=H.getUTCFullYear(),le.m=H.getUTCMonth(),le.d=H.getUTCDate()+(le.w+6)%7):(H=wC(fb(le.y,0,1)),J=H.getDay(),H=J>4||J===0?bS.ceil(H):bS(H),H=Py.offset(H,(le.V-1)*7),le.y=H.getFullYear(),le.m=H.getMonth(),le.d=H.getDate()+(le.w+6)%7)}else("W"in le||"U"in le)&&("w"in le||(le.w="u"in le?le.u%7:"W"in le?1:0),J="Z"in le?SC(fb(le.y,0,1)).getUTCDay():wC(fb(le.y,0,1)).getDay(),le.m=0,le.d="W"in le?(le.w+6)%7+le.W*7-(J+5)%7:le.w+le.U*7-(J+6)%7);return"Z"in le?(le.H+=le.Z/100|0,le.M+=le.Z%100,SC(le)):wC(le)}}function D(ge,Ne,_e,le){for(var He=0,H=Ne.length,J=_e.length,K,B;He<H;){if(le>=J)return-1;if(K=Ne.charCodeAt(He++),K===37){if(K=Ne.charAt(He++),B=A[K in r$?Ne.charAt(He++):K],!B||(le=B(ge,_e,le))<0)return-1}else if(K!=_e.charCodeAt(le++))return-1}return le}function C(ge,Ne,_e){var le=u.exec(Ne.slice(_e));return le?(ge.p=d.get(le[0].toLowerCase()),_e+le[0].length):-1}function R(ge,Ne,_e){var le=p.exec(Ne.slice(_e));return le?(ge.w=b.get(le[0].toLowerCase()),_e+le[0].length):-1}function U(ge,Ne,_e){var le=f.exec(Ne.slice(_e));return le?(ge.w=m.get(le[0].toLowerCase()),_e+le[0].length):-1}function O(ge,Ne,_e){var le=v.exec(Ne.slice(_e));return le?(ge.m=S.get(le[0].toLowerCase()),_e+le[0].length):-1}function q(ge,Ne,_e){var le=y.exec(Ne.slice(_e));return le?(ge.m=x.get(le[0].toLowerCase()),_e+le[0].length):-1}function j(ge,Ne,_e){return D(ge,e,Ne,_e)}function W(ge,Ne,_e){return D(ge,n,Ne,_e)}function X(ge,Ne,_e){return D(ge,r,Ne,_e)}function G(ge){return o[ge.getDay()]}function Z(ge){return a[ge.getDay()]}function te(ge){return c[ge.getMonth()]}function ee(ge){return l[ge.getMonth()]}function z(ge){return i[+(ge.getHours()>=12)]}function V(ge){return 1+~~(ge.getMonth()/3)}function ne(ge){return o[ge.getUTCDay()]}function ie(ge){return a[ge.getUTCDay()]}function he(ge){return c[ge.getUTCMonth()]}function me(ge){return l[ge.getUTCMonth()]}function oe(ge){return i[+(ge.getUTCHours()>=12)]}function Ae(ge){return 1+~~(ge.getUTCMonth()/3)}return{format:function(ge){var Ne=k(ge+="",M);return Ne.toString=function(){return ge},Ne},parse:function(ge){var Ne=T(ge+="",!1);return Ne.toString=function(){return ge},Ne},utcFormat:function(ge){var Ne=k(ge+="",E);return Ne.toString=function(){return ge},Ne},utcParse:function(ge){var Ne=T(ge+="",!0);return Ne.toString=function(){return ge},Ne}}}var r$={"-":"",_:" ",0:"0"},oa=/^\s*\d+/,R_e=/^%/,D_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 O_e(t){return t.replace(D_e,"\\$&")}function mb(t){return new RegExp("^(?:"+t.map(O_e).join("|")+")","i")}function pb(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function L_e(t,e,n){var r=oa.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function I_e(t,e,n){var r=oa.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function F_e(t,e,n){var r=oa.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function U_e(t,e,n){var r=oa.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function z_e(t,e,n){var r=oa.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function i$(t,e,n){var r=oa.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function a$(t,e,n){var r=oa.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function B_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 $_e(t,e,n){var r=oa.exec(e.slice(n,n+1));return r?(t.q=r[0]*3-3,n+r[0].length):-1}function H_e(t,e,n){var r=oa.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function s$(t,e,n){var r=oa.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function V_e(t,e,n){var r=oa.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function o$(t,e,n){var r=oa.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function G_e(t,e,n){var r=oa.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function W_e(t,e,n){var r=oa.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function q_e(t,e,n){var r=oa.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function K_e(t,e,n){var r=oa.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function X_e(t,e,n){var r=R_e.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function Y_e(t,e,n){var r=oa.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function Q_e(t,e,n){var r=oa.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function l$(t,e){return Xn(t.getDate(),e,2)}function Z_e(t,e){return Xn(t.getHours(),e,2)}function J_e(t,e){return Xn(t.getHours()%12||12,e,2)}function e1e(t,e){return Xn(1+Py.count(pu(t),t),e,3)}function qY(t,e){return Xn(t.getMilliseconds(),e,3)}function t1e(t,e){return qY(t,e)+"000"}function n1e(t,e){return Xn(t.getMonth()+1,e,2)}function r1e(t,e){return Xn(t.getMinutes(),e,2)}function i1e(t,e){return Xn(t.getSeconds(),e,2)}function a1e(t){var e=t.getDay();return e===0?7:e}function s1e(t,e){return Xn(IN.count(pu(t)-1,t),e,2)}function KY(t){var e=t.getDay();return e>=4||e===0?Mg(t):Mg.ceil(t)}function o1e(t,e){return t=KY(t),Xn(Mg.count(pu(t),t)+(pu(t).getDay()===4),e,2)}function l1e(t){return t.getDay()}function c1e(t,e){return Xn(bS.count(pu(t)-1,t),e,2)}function u1e(t,e){return Xn(t.getFullYear()%100,e,2)}function d1e(t,e){return t=KY(t),Xn(t.getFullYear()%100,e,2)}function h1e(t,e){return Xn(t.getFullYear()%1e4,e,4)}function f1e(t,e){var n=t.getDay();return t=n>=4||n===0?Mg(t):Mg.ceil(t),Xn(t.getFullYear()%1e4,e,4)}function m1e(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+Xn(e/60|0,"0",2)+Xn(e%60,"0",2)}function c$(t,e){return Xn(t.getUTCDate(),e,2)}function p1e(t,e){return Xn(t.getUTCHours(),e,2)}function g1e(t,e){return Xn(t.getUTCHours()%12||12,e,2)}function x1e(t,e){return Xn(1+LN.count(gu(t),t),e,3)}function XY(t,e){return Xn(t.getUTCMilliseconds(),e,3)}function b1e(t,e){return XY(t,e)+"000"}function y1e(t,e){return Xn(t.getUTCMonth()+1,e,2)}function v1e(t,e){return Xn(t.getUTCMinutes(),e,2)}function _1e(t,e){return Xn(t.getUTCSeconds(),e,2)}function w1e(t){var e=t.getUTCDay();return e===0?7:e}function S1e(t,e){return Xn(FN.count(gu(t)-1,t),e,2)}function YY(t){var e=t.getUTCDay();return e>=4||e===0?Ng(t):Ng.ceil(t)}function M1e(t,e){return t=YY(t),Xn(Ng.count(gu(t),t)+(gu(t).getUTCDay()===4),e,2)}function N1e(t){return t.getUTCDay()}function E1e(t,e){return Xn(yS.count(gu(t)-1,t),e,2)}function A1e(t,e){return Xn(t.getUTCFullYear()%100,e,2)}function T1e(t,e){return t=YY(t),Xn(t.getUTCFullYear()%100,e,2)}function C1e(t,e){return Xn(t.getUTCFullYear()%1e4,e,4)}function k1e(t,e){var n=t.getUTCDay();return t=n>=4||n===0?Ng(t):Ng.ceil(t),Xn(t.getUTCFullYear()%1e4,e,4)}function j1e(){return"+0000"}function u$(){return"%"}function d$(t){return+t}function h$(t){return Math.floor(+t/1e3)}var Qm,QY,ZY;P1e({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 P1e(t){return Qm=P_e(t),QY=Qm.format,Qm.parse,ZY=Qm.utcFormat,Qm.utcParse,Qm}function R1e(t){return new Date(t)}function D1e(t){return t instanceof Date?+t:+new Date(+t)}function zO(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"),y=u("%I:%M"),x=u("%I %p"),v=u("%a %d"),S=u("%b %d"),M=u("%B"),E=u("%Y");function A(k){return(c(k)<k?p:l(k)<k?b:o(k)<k?y:a(k)<k?x:r(k)<k?i(k)<k?v:S:n(k)<k?M:E)(k)}return d.invert=function(k){return new Date(f(k))},d.domain=function(k){return arguments.length?m(Array.from(k,D1e)):m().map(R1e)},d.ticks=function(k){var T=m();return t(T[0],T[T.length-1],k??10)},d.tickFormat=function(k,T){return T==null?A:u(T)},d.nice=function(k){var T=m();return(!k||typeof k.range!="function")&&(k=e(T[0],T[T.length-1],k??10)),k?m(FY(T,k)):d},d.copy=function(){return jy(d,zO(t,e,n,r,i,a,o,l,c,u))},d}function O1e(){return zo.apply(zO(k_e,j_e,pu,FO,IN,Py,LO,DO,ff,QY).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function L1e(){return zo.apply(zO(T_e,C_e,gu,UO,FN,LN,IO,OO,ff,ZY).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function UN(){var t=0,e=1,n,r,i,a,o=Qa,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(ex),u.rangeRound=d(NO),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 mh(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function JY(){var t=fh(UN()(Qa));return t.copy=function(){return mh(t,JY())},Eu.apply(t,arguments)}function eQ(){var t=CO(UN()).domain([1,10]);return t.copy=function(){return mh(t,eQ()).base(t.base())},Eu.apply(t,arguments)}function tQ(){var t=kO(UN());return t.copy=function(){return mh(t,tQ()).constant(t.constant())},Eu.apply(t,arguments)}function BO(){var t=jO(UN());return t.copy=function(){return mh(t,BO()).exponent(t.exponent())},Eu.apply(t,arguments)}function I1e(){return BO.apply(null,arguments).exponent(.5)}function nQ(){var t=[],e=Qa;function n(r){if(r!=null&&!isNaN(r=+r))return e((Cy(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(zd),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)=>wve(t,a/r))},n.copy=function(){return nQ(e).domain(t)},Eu.apply(n,arguments)}function zN(){var t=0,e=.5,n=1,r=1,i,a,o,l,c,u=Qa,d,f=!1,m;function p(y){return isNaN(y=+y)?m:(y=.5+((y=+d(y))-a)*(r*y<r*a?l:c),u(f?Math.max(0,Math.min(1,y)):y))}p.domain=function(y){return arguments.length?([t,e,n]=y,i=d(t=+t),a=d(e=+e),o=d(n=+n),l=i===a?0:.5/(a-i),c=a===o?0:.5/(o-a),r=a<i?-1:1,p):[t,e,n]},p.clamp=function(y){return arguments.length?(f=!!y,p):f},p.interpolator=function(y){return arguments.length?(u=y,p):u};function b(y){return function(x){var v,S,M;return arguments.length?([v,S,M]=x,u=Xve(y,[v,S,M]),p):[u(0),u(.5),u(1)]}}return p.range=b(ex),p.rangeRound=b(NO),p.unknown=function(y){return arguments.length?(m=y,p):m},function(y){return d=y,i=y(t),a=y(e),o=y(n),l=i===a?0:.5/(a-i),c=a===o?0:.5/(o-a),r=a<i?-1:1,p}}function rQ(){var t=fh(zN()(Qa));return t.copy=function(){return mh(t,rQ())},Eu.apply(t,arguments)}function iQ(){var t=CO(zN()).domain([.1,1,10]);return t.copy=function(){return mh(t,iQ()).base(t.base())},Eu.apply(t,arguments)}function aQ(){var t=kO(zN());return t.copy=function(){return mh(t,aQ()).constant(t.constant())},Eu.apply(t,arguments)}function $O(){var t=jO(zN());return t.copy=function(){return mh(t,$O()).exponent(t.exponent())},Eu.apply(t,arguments)}function F1e(){return $O.apply(null,arguments).exponent(.5)}const Ub=Object.freeze(Object.defineProperty({__proto__:null,scaleBand:wO,scaleDiverging:rQ,scaleDivergingLog:iQ,scaleDivergingPow:$O,scaleDivergingSqrt:F1e,scaleDivergingSymlog:aQ,scaleIdentity:IY,scaleImplicit:a3,scaleLinear:LY,scaleLog:UY,scaleOrdinal:_O,scalePoint:Nve,scalePow:PO,scaleQuantile:$Y,scaleQuantize:HY,scaleRadial:BY,scaleSequential:JY,scaleSequentialLog:eQ,scaleSequentialPow:BO,scaleSequentialQuantile:nQ,scaleSequentialSqrt:I1e,scaleSequentialSymlog:tQ,scaleSqrt:b_e,scaleSymlog:zY,scaleThreshold:VY,scaleTime:O1e,scaleUtc:L1e,tickFormat:OY},Symbol.toStringTag,{value:"Module"}));var Au=t=>t.chartData,BN=tt([Au],t=>{var e=t.chartData!=null?t.chartData.length-1:0;return{chartData:t.chartData,computedData:t.computedData,dataEndIndex:e,dataStartIndex:0}}),HO=(t,e,n,r)=>r?BN(t):Au(t),sQ=(t,e,n)=>n?BN(t):Au(t);function xu(t){if(Array.isArray(t)&&t.length===2){var[e,n]=t;if(pn(e)&&pn(n))return!0}return!1}function f$(t,e,n){return n?t:[Math.min(t[0],e[0]),Math.max(t[1],e[1])]}function oQ(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(xu(o))return o}}function U1e(t,e,n){if(!(!n&&e==null)){if(typeof t=="function"&&e!=null)try{var r=t(e,n);if(xu(r))return f$(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"&&S8.test(i)){var c=S8.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"&&M8.test(a)){var d=M8.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(xu(m))return e==null?m:f$(m,e,n)}}}var tx=1e9,z1e={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},GO,zr=!0,Fo="[DecimalError] ",Nf=Fo+"Invalid argument: ",VO=Fo+"Exponent out of range: ",nx=Math.floor,Zh=Math.pow,B1e=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,$s,Qi=1e7,Lr=7,lQ=9007199254740991,vS=nx(lQ/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 iu(this,new this.constructor(t))};Wt.dividedToIntegerBy=Wt.idiv=function(t){var e=this,n=e.constructor;return Sr(iu(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(Fo+"NaN");if(n.s<1)throw Error(Fo+(n.s?"NaN":"-Infinity"));return n.eq($s)?new r(0):(zr=!1,e=iu(H0(n,a),H0(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?dQ(e,t):cQ(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(Fo+"NaN");return n.s?(zr=!1,e=iu(n,t,0,1).times(t),zr=!0,n.minus(e)):Sr(new r(n),i)};Wt.naturalExponential=Wt.exp=function(){return uQ(this)};Wt.naturalLogarithm=Wt.ln=function(){return H0(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?cQ(e,t):dQ(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(Nf+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(Fo+"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=nx((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(iu(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%Qi|0,e=l/Qi|0;a[i]=(a[i]+e)%Qi|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,tx),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=Yf(r,!0):(ec(t,0,tx),e===void 0?e=i.rounding:ec(e,0,8),r=Sr(new i(r),t+1,e),n=Yf(r,!0,t+1)),n};Wt.toFixed=function(t,e){var n,r,i=this,a=i.constructor;return t===void 0?Yf(i):(ec(t,0,tx),e===void 0?e=a.rounding:ec(e,0,8),r=Sr(new a(i),t+Ai(i)+1,e),n=Yf(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(Fo+"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)<=lQ){for(i=new c($s),e=Math.ceil(r/Lr+4),zr=!1;n%2&&(i=i.times(l),p$(i.d,e)),n=nx(n/2),n!==0;)l=l.times(l),p$(l.d,e);return zr=!0,t.s<0?new c($s).div(i):Sr(i,r)}}else if(a<0)throw Error(Fo+"NaN");return a=a<0&&t.d[Math.max(e,n)]&1?-1:1,l.s=1,zr=!1,i=t.times(H0(l,r+u)),zr=!0,i=uQ(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=Yf(i,n<=a.toExpNeg||n>=a.toExpPos)):(ec(t,1,tx),e===void 0?e=a.rounding:ec(e,0,8),i=Sr(new a(i),t,e),n=Ai(i),r=Yf(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,tx),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 Yf(t,e<=n.toExpNeg||e>=n.toExpPos)};function cQ(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)/Qi|0,c[a]%=Qi;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(Nf+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+=gd(n)),a+=r;o=t[e],r=o+"",n=Lr-r.length,n&&(a+=gd(n))}else if(o===0)return"0";for(;o%10===0;)o/=10;return a+o}var iu=(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%Qi|0,o=a/Qi|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*Qi+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,y,x,v,S,M,E,A,k,T,D,C=r.constructor,R=r.s==i.s?1:-1,U=r.d,O=i.d;if(!r.s)return new C(r);if(!i.s)throw Error(Fo+"Division by zero");for(c=r.e-i.e,T=O.length,A=U.length,p=new C(R),b=p.d=[],u=0;O[u]==(U[u]||0);)++u;if(O[u]>(U[u]||0)&&--c,a==null?S=a=C.precision:o?S=a+(Ai(r)-Ai(i))+1:S=a,S<0)return new C(0);if(S=S/Lr+2|0,u=0,T==1)for(d=0,O=O[0],S++;(u<A||d)&&S--;u++)M=d*Qi+(U[u]||0),b[u]=M/O|0,d=M%O|0;else{for(d=Qi/(O[0]+1)|0,d>1&&(O=t(O,d),U=t(U,d),T=O.length,A=U.length),E=T,y=U.slice(0,T),x=y.length;x<T;)y[x++]=0;D=O.slice(),D.unshift(0),k=O[0],O[1]>=Qi/2&&++k;do d=0,l=e(O,y,T,x),l<0?(v=y[0],T!=x&&(v=v*Qi+(y[1]||0)),d=v/k|0,d>1?(d>=Qi&&(d=Qi-1),f=t(O,d),m=f.length,x=y.length,l=e(f,y,m,x),l==1&&(d--,n(f,T<m?D:O,m))):(d==0&&(l=d=1),f=O.slice()),m=f.length,m<x&&f.unshift(0),n(y,f,x),l==-1&&(x=y.length,l=e(O,y,T,x),l<1&&(d++,n(y,T<x?D:O,x))),x=y.length):l===0&&(d++,y=[0]),b[u++]=d,l&&y[0]?y[x++]=U[E]||0:(y=[U[E]],x=1);while((E++<A||y[0]!==void 0)&&S--)}return b[0]||b.shift(),p.e=c,Sr(p,o?a+Ai(p)+1:a)}})();function uQ(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(VO+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(iu(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 MC(t,e,n){if(e>t.LN10.sd())throw zr=!0,n&&(t.precision=n),Error(Fo+"LN10 precision limit exceeded");return Sr(new t(t.LN10),e)}function gd(t){for(var e="";t--;)e+="0";return e}function H0(t,e){var n,r,i,a,o,l,c,u,d,f=1,m=10,p=t,b=p.d,y=p.constructor,x=y.precision;if(p.s<1)throw Error(Fo+(p.s?"NaN":"-Infinity"));if(p.eq($s))return new y(0);if(e==null?(zr=!1,u=x):u=e,p.eq(10))return e==null&&(zr=!0),MC(y,u);if(u+=m,y.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 y("0."+n),a++):p=new y(r+"."+n.slice(1))}else return c=MC(y,u+2,x).times(a+""),p=H0(new y(r+"."+n.slice(1)),u-m).plus(c),y.precision=x,e==null?(zr=!0,Sr(p,x)):p;for(l=o=p=iu(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(iu(o,new y(i),u)),Bl(c.d).slice(0,u)===Bl(l.d).slice(0,u))return l=l.times(2),a!==0&&(l=l.plus(MC(y,u+2,x).times(a+""))),l=iu(l,new y(f),u),y.precision=x,e==null?(zr=!0,Sr(l,x)):l;l=c,i+=2}}function m$(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=nx(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>vS||t.e<-vS))throw Error(VO+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=nx(-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)==Qi&&(f[0]=1,++t.e);break}else{if(f[d]+=a,f[d]!=Qi)break;f[d--]=0,a=1}for(r=f.length;f[--r]===0;)f.pop();if(zr&&(t.e>vS||t.e<-vS))throw Error(VO+Ai(t));return t}function dQ(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]=Qi-1;--c[a],c[i]+=Qi}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 Yf(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)+gd(r):o>1&&(a=a.charAt(0)+"."+a.slice(1)),a=a+(i<0?"e":"e+")+i):i<0?(a="0."+gd(-i-1)+a,n&&(r=n-o)>0&&(a+=gd(r))):i>=o?(a+=gd(i+1-o),n&&(r=n-i-1)>0&&(a=a+"."+gd(r))):((r=i+1)<o&&(a=a.slice(0,r)+"."+a.slice(r)),n&&(r=n-o)>0&&(i+1===o&&(a+="."),a+=gd(r))),t.s<0?"-"+a:a}function p$(t,e){if(t.length>e)return t.length=e,!0}function hQ(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(Nf+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 m$(o,a.toString())}else if(typeof a!="string")throw Error(Nf+a);if(a.charCodeAt(0)===45?(a=a.slice(1),o.s=-1):o.s=1,B1e.test(a))m$(o,a);else throw Error(Nf+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=hQ,i.config=i.set=$1e,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 $1e(t){if(!t||typeof t!="object")throw Error(Fo+"Object expected");var e,n,r,i=["precision",1,tx,"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(nx(r)===r&&r>=i[e+1]&&r<=i[e+2])this[n]=r;else throw Error(Nf+n+": "+r);if((r=t[n="LN10"])!==void 0)if(r==Math.LN10)this[n]=new this(r);else throw Error(Nf+n+": "+r);return this}var GO=hQ(z1e);$s=new GO(1);const cr=GO;function fQ(t){var e;return t===0?e=1:e=Math.floor(new cr(t).abs().log(10).toNumber())+1,e}function mQ(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 pQ=t=>{var[e,n]=t,[r,i]=[e,n];return e>n&&([r,i]=[n,e]),[r,i]},gQ=(t,e,n)=>{if(t.lte(0))return new cr(0);var r=fQ(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()))},H1e=(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(fQ(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},xQ=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=gQ(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?xQ(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))})},V1e=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]=pQ([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 H1e(l,i,a);var{step:d,tickMin:f,tickMax:m}=xQ(l,c,o,a,0),p=mQ(f,m.add(new cr(.1).mul(d)),d);return n>r?p.reverse():p},G1e=function(e,n){var[r,i]=e,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,[o,l]=pQ([r,i]);if(o===-1/0||l===1/0)return[r,i];if(o===l)return[o];var c=Math.max(n,2),u=gQ(new cr(l).sub(o).div(c-1),a,0),d=[...mQ(new cr(o),new cr(l),u),l];return a===!1&&(d=d.map(f=>Math.round(f))),r>i?d.reverse():d},bQ=t=>t.rootProps.maxBarSize,W1e=t=>t.rootProps.barGap,yQ=t=>t.rootProps.barCategoryGap,q1e=t=>t.rootProps.barSize,Ry=t=>t.rootProps.stackOffset,vQ=t=>t.rootProps.reverseStackOrder,WO=t=>t.options.chartName,qO=t=>t.rootProps.syncId,_Q=t=>t.rootProps.syncMethod,KO=t=>t.options.eventEmitter,K1e=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},Lh={allowDecimals:!1,allowDataOverflow:!1,angleAxisId:0,reversed:!1,scale:"auto",tick:!0,type:"auto"},El={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!0,includeHidden:!1,radiusAxisId:0,reversed:!1,scale:"auto",tick:!0,tickCount:5,type:"auto"},$N=(t,e)=>{if(!(!t||!e))return t!=null&&t.reversed?[e[1],e[0]]:e};function HN(t,e,n){if(n!=="auto")return n;if(t!=null)return xl(t,e)?"category":"number"}function g$(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?g$(Object(n),!0).forEach(function(r){X1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):g$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function X1e(t,e,n){return(e=Y1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Y1e(t){var e=Q1e(t,"string");return typeof e=="symbol"?e:e+""}function Q1e(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 x$={allowDataOverflow:Lh.allowDataOverflow,allowDecimals:Lh.allowDecimals,allowDuplicatedCategory:!1,dataKey:void 0,domain:void 0,id:Lh.angleAxisId,includeHidden:!1,name:void 0,reversed:Lh.reversed,scale:Lh.scale,tick:Lh.tick,tickCount:void 0,ticks:void 0,type:Lh.type,unit:void 0},b$={allowDataOverflow:El.allowDataOverflow,allowDecimals:El.allowDecimals,allowDuplicatedCategory:El.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:El.radiusAxisId,includeHidden:El.includeHidden,name:void 0,reversed:El.reversed,scale:El.scale,tick:El.tick,tickCount:El.tickCount,ticks:void 0,type:El.type,unit:void 0},Z1e=(t,e)=>{if(e!=null)return t.polarAxis.angleAxis[e]},XO=tt([Z1e,aY],(t,e)=>{var n;if(t!=null)return t;var r=(n=HN(e,"angleAxis",x$.type))!==null&&n!==void 0?n:"category";return _S(_S({},x$),{},{type:r})}),J1e=(t,e)=>t.polarAxis.radiusAxis[e],YO=tt([J1e,aY],(t,e)=>{var n;if(t!=null)return t;var r=(n=HN(e,"radiusAxis",b$.type))!==null&&n!==void 0?n:"category";return _S(_S({},b$),{},{type:r})}),VN=t=>t.polarOptions,QO=tt([Mu,Nu,zi],wY),wQ=tt([VN,QO],(t,e)=>{if(t!=null)return Ba(t.innerRadius,e,0)}),SQ=tt([VN,QO],(t,e)=>{if(t!=null)return Ba(t.outerRadius,e,e*.8)}),ewe=t=>{if(t==null)return[0,0];var{startAngle:e,endAngle:n}=t;return[e,n]},MQ=tt([VN],ewe);tt([XO,MQ],$N);var NQ=tt([QO,wQ,SQ],(t,e,n)=>{if(!(t==null||e==null||n==null))return[e,n]});tt([YO,NQ],$N);var EQ=tt([Fn,VN,wQ,SQ,Mu,Nu],(t,e,n,r,i,a)=>{if(!(t!=="centric"&&t!=="radial"||e==null||n==null||r==null)){var{cx:o,cy:l,startAngle:c,endAngle:u}=e;return{cx: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,Dy=(t,e,n)=>n;function GN(t){return t?.id}function AQ(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=GN(l);u.forEach((f,m)=>{var p=a==null||i?m:String(ir(f,a,null)),b=ir(f,l.dataKey,0),y;o.has(p)?y=o.get(p):y={},Object.assign(y,{[d]:b}),o.set(p,y)})}}),Array.from(o.values())}function WN(t){return"stackId"in t&&t.stackId!=null&&t.dataKey!=null}var qN=(t,e)=>t===e?!0:t==null||e==null?!1:t[0]===e[0]&&t[1]===e[1];function KN(t,e){return Array.isArray(t)&&Array.isArray(e)&&t.length===0&&e.length===0?!0:t===e}function twe(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 la=t=>{var e=Fn(t);return e==="horizontal"?"xAxis":e==="vertical"?"yAxis":e==="centric"?"angleAxis":"radiusAxis"},rx=t=>t.tooltip.settings.axisId;function nwe(t){if(t in Ub)return Ub[t]();var e="scale".concat(vy(t));if(e in Ub)return Ub[e]()}function y$(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 v$(t,e,n){if(typeof t=="function")return y$(t.copy().domain(e).range(n));if(t!=null){var r=nwe(t);if(r!=null)return r.domain(e).range(n),y$(r)}}var TQ=(t,e)=>{if(e!=null)switch(t){case"linear":{if(!xu(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 _$(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 wS(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?_$(Object(n),!0).forEach(function(r){rwe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):_$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function rwe(t,e,n){return(e=iwe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function iwe(t){var e=awe(t,"string");return typeof e=="symbol"?e:e+""}function awe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var c3=[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},CQ=(t,e)=>t.cartesianAxis.xAxis[e],cc=(t,e)=>{var n=CQ(t,e);return n??Xi},Yi={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:c3,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:My},kQ=(t,e)=>t.cartesianAxis.yAxis[e],uc=(t,e)=>{var n=kQ(t,e);return n??Yi},swe={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??swe},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 XO(t,n);case"radiusAxis":return YO(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},owe=(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))}},ix=(t,e,n)=>{switch(e){case"xAxis":return cc(t,n);case"yAxis":return uc(t,n);case"angleAxis":return XO(t,n);case"radiusAxis":return YO(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},jQ=t=>t.graphicalItems.cartesianItems.some(e=>e.type==="bar")||t.graphicalItems.polarItems.some(e=>e.type==="radialBar");function JO(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 Oy=t=>t.graphicalItems.cartesianItems,lwe=tt([Xr,Dy],JO),e4=(t,e,n)=>t.filter(n).filter(r=>e?.includeHidden===!0?!0:!r.hide),Ly=tt([Oy,ci,lwe],e4,{memoizeOptions:{resultEqualityCheck:KN}}),PQ=tt([Ly],t=>t.filter(e=>e.type==="area"||e.type==="bar").filter(WN)),RQ=t=>t.filter(e=>!("stackId"in e)||e.stackId===void 0),cwe=tt([Ly],RQ),t4=t=>t.map(e=>e.data).filter(Boolean).flat(1),uwe=tt([Ly],t4,{memoizeOptions:{resultEqualityCheck:KN}}),n4=(t,e)=>{var{chartData:n=[],dataStartIndex:r,dataEndIndex:i}=e;return t.length>0?t:n.slice(r,i+1)},r4=tt([uwe,HO],n4),i4=(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})),XN=tt([r4,ci,Ly],i4);function DQ(t,e){switch(t){case"xAxis":return e.direction==="x";case"yAxis":return e.direction==="y";default:return!1}}function iw(t){if(Lo(t)||t instanceof Date){var e=Number(t);if(pn(e))return e}}function w$(t){if(Array.isArray(t)){var e=[iw(t[0]),iw(t[1])];return xu(e)?e:void 0}var n=iw(t);if(n!=null)return[n,n]}function bu(t){return t.map(iw).filter(vs)}function dwe(t,e,n){return!n||typeof e!="number"||ul(e)?[]:n.length?bu(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=la(t),n=rx(t);return ix(t,e,n)},Iy=tt([Hi],t=>t?.dataKey),hwe=tt([PQ,HO,Hi],AQ),OQ=(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(GN);return[l,{stackedData:Rbe(t,d,n),graphicalItems:u}]}))},SS=tt([hwe,PQ,Ry,vQ],OQ),LQ=(t,e,n,r)=>{var{dataStartIndex:i,dataEndIndex:a}=e;if(r==null&&n!=="zAxis"){var o=Ibe(t,i,a);if(!(o!=null&&o[0]===0&&o[1]===0))return o}},fwe=tt([ci],t=>t.allowDataOverflow),a4=t=>{var e;if(t==null||!("domain"in t))return c3;if(t.domain!=null)return t.domain;if("ticks"in t&&t.ticks!=null){if(t.type==="number"){var n=bu(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:c3},s4=tt([ci],a4),o4=tt([s4,fwe],oQ),mwe=tt([SS,Au,Xr,o4],LQ,{memoizeOptions:{resultEqualityCheck:qN}}),YN=t=>t.errorBars,pwe=(t,e,n)=>t.flatMap(r=>e[r.id]).filter(Boolean).filter(r=>DQ(n,r)),MS=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]}},l4=(t,e,n,r,i)=>{var a,o;if(n.length>0&&t.forEach(l=>{n.forEach(c=>{var u,d,f=(u=r[c.id])===null||u===void 0?void 0:u.filter(v=>DQ(i,v)),m=ir(l,(d=e.dataKey)!==null&&d!==void 0?d:c.dataKey),p=dwe(l,m,f);if(p.length>=2){var b=Math.min(...p),y=Math.max(...p);(a==null||b<a)&&(a=b),(o==null||y>o)&&(o=y)}var x=w$(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=w$(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]},gwe=tt([r4,ci,cwe,YN,Xr],l4,{memoizeOptions:{resultEqualityCheck:qN}});function xwe(t){var{value:e}=t;if(Lo(e)||e instanceof Date)return e}var bwe=(t,e,n)=>{var r=t.map(xwe).filter(i=>i!=null);return n&&(e.dataKey==null||e.allowDuplicatedCategory&&eX(r))?EY(0,t.length):e.allowDuplicatedCategory?r:Array.from(new Set(r))},IQ=t=>t.referenceElements.dots,ax=(t,e,n)=>t.filter(r=>r.ifOverflow==="extendDomain").filter(r=>e==="xAxis"?r.xAxisId===n:r.yAxisId===n),ywe=tt([IQ,Xr,Dy],ax),FQ=t=>t.referenceElements.areas,vwe=tt([FQ,Xr,Dy],ax),UQ=t=>t.referenceElements.lines,_we=tt([UQ,Xr,Dy],ax),zQ=(t,e)=>{if(t!=null){var n=bu(t.map(r=>e==="xAxis"?r.x:r.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]}},wwe=tt(ywe,Xr,zQ),BQ=(t,e)=>{if(t!=null){var n=bu(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)]}},Swe=tt([vwe,Xr],BQ);function Mwe(t){var e;if(t.x!=null)return bu([t.x]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.x);return n==null||n.length===0?[]:bu(n)}function Nwe(t){var e;if(t.y!=null)return bu([t.y]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.y);return n==null||n.length===0?[]:bu(n)}var $Q=(t,e)=>{if(t!=null){var n=t.flatMap(r=>e==="xAxis"?Mwe(r):Nwe(r));if(n.length!==0)return[Math.min(...n),Math.max(...n)]}},Ewe=tt([_we,Xr],$Q),Awe=tt(wwe,Ewe,Swe,(t,e,n)=>MS(t,n,e)),c4=(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?MS(r,a,i):MS(a,i);return U1e(e,u,t.allowDataOverflow)},Twe=tt([ci,s4,o4,mwe,gwe,Awe,Fn,Xr],c4,{memoizeOptions:{resultEqualityCheck:qN}}),Cwe=[0,1],u4=(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"?bwe(r,t,u):i==="expand"?Cwe:o}},d4=tt([ci,Fn,r4,XN,Ry,Xr,Twe],u4);function kwe(t){return t in Ub}var HQ=(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(vy(r));return kwe(a)?a:"point"}}},ph=tt([ci,jQ,WO],HQ);function h4(t,e,n,r){if(!(n==null||r==null))return typeof t.scale=="function"?v$(t.scale,n,r):v$(e,n,r)}var f4=(t,e,n)=>{var r=a4(e);if(!(n!=="auto"&&n!=="linear")){if(e!=null&&e.tickCount&&Array.isArray(r)&&(r[0]==="auto"||r[1]==="auto")&&xu(t))return V1e(t,e.tickCount,e.allowDecimals);if(e!=null&&e.tickCount&&e.type==="number"&&xu(t))return G1e(t,e.tickCount,e.allowDecimals)}},m4=tt([d4,ix,ph],f4),p4=(t,e,n,r)=>{if(r!=="angleAxis"&&t?.type==="number"&&xu(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},jwe=tt([ci,d4,m4,Xr],p4),Pwe=tt(XN,ci,(t,e)=>{if(!(!e||e.type!=="number")){var n=1/0,r=Array.from(bu(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}}),VQ=tt(Pwe,Fn,yQ,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}),Rwe=(t,e,n)=>{var r=cc(t,e);return r==null||typeof r.padding!="string"?0:VQ(t,"xAxis",e,n,r.padding)},Dwe=(t,e,n)=>{var r=uc(t,e);return r==null||typeof r.padding!="string"?0:VQ(t,"yAxis",e,n,r.padding)},Owe=tt(cc,Rwe,(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}}),Lwe=tt(uc,Dwe,(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}}),Iwe=tt([zi,Owe,jN,kN,(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]}),Fwe=tt([zi,Fn,Lwe,jN,kN,(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]}),Fy=(t,e,n,r)=>{var i;switch(e){case"xAxis":return Iwe(t,n,r);case"yAxis":return Fwe(t,n,r);case"zAxis":return(i=ZO(t,n))===null||i===void 0?void 0:i.range;case"angleAxis":return MQ(t);case"radiusAxis":return NQ(t,n);default:return}},GQ=tt([ci,Fy],$N),Uwe=tt([ph,jwe],TQ),Eg=tt([ci,ph,Uwe,GQ],h4);tt([Ly,YN,Xr],pwe);function WQ(t,e){return t.id<e.id?-1:t.id>e.id?1:0}var QN=(t,e)=>e,ZN=(t,e,n)=>n,zwe=tt(TN,QN,ZN,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(WQ)),Bwe=tt(CN,QN,ZN,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(WQ)),qQ=(t,e)=>({width:t.width,height:e.height}),$we=(t,e)=>{var n=typeof e.width=="number"?e.width:My;return{width:n,height:t.height}},KQ=tt(zi,cc,qQ),Hwe=(t,e,n)=>{switch(e){case"top":return t.top;case"bottom":return n-t.bottom;default:return 0}},Vwe=(t,e,n)=>{switch(e){case"left":return t.left;case"right":return n-t.right;default:return 0}},Gwe=tt(Nu,zi,zwe,QN,ZN,(t,e,n,r,i)=>{var a={},o;return n.forEach(l=>{var c=qQ(e,l);o==null&&(o=Hwe(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}),Wwe=tt(Mu,zi,Bwe,QN,ZN,(t,e,n,r,i)=>{var a={},o;return n.forEach(l=>{var c=$we(e,l);o==null&&(o=Vwe(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}),qwe=(t,e)=>{var n=cc(t,e);if(n!=null)return Gwe(t,n.orientation,n.mirror)},Kwe=tt([zi,cc,qwe,(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}}}),Xwe=(t,e)=>{var n=uc(t,e);if(n!=null)return Wwe(t,n.orientation,n.mirror)},Ywe=tt([zi,uc,Xwe,(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}}}),XQ=tt(zi,uc,(t,e)=>{var n=typeof e.width=="number"?e.width:My;return{width:n,height:t.height}}),S$=(t,e,n)=>{switch(e){case"xAxis":return KQ(t,n).width;case"yAxis":return XQ(t,n).height;default:return}},YQ=(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&&eX(c))return c}},g4=tt([Fn,XN,ci,Xr],YQ),QQ=(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)}},x4=tt([Fn,XN,ix,Xr],QQ),M$=tt([Fn,owe,ph,Eg,g4,x4,Fy,m4,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}}}),Qwe=(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 y=f||i;return y?y.map((x,v)=>{var S=o?o.indexOf(x):x,M=r.map(S);return pn(M)?{index:v,coordinate:M+b,value:x,offset:b}:null}).filter(vs):u&&l?l.map((x,v)=>{var S=r.map(x);return pn(S)?{coordinate:S+b,value:x,index:v,offset:b}:null}).filter(vs):r.ticks?r.ticks(m).map((x,v)=>{var S=r.map(x);return pn(S)?{coordinate:S+b,value:x,index:v,offset:b}:null}).filter(vs):r.domain().map((x,v)=>{var S=r.map(x);return pn(S)?{coordinate:S+b,value:o?o[x]:x,index:v,offset:b}:null}).filter(vs)}},ZQ=tt([Fn,ix,ph,Eg,m4,Fy,g4,x4,Xr],Qwe),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(vs):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(vs):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(vs)}},tc=tt([Fn,ix,Eg,Fy,g4,x4,Xr],Zwe),nc=tt(ci,Eg,(t,e)=>{if(!(t==null||e==null))return wS(wS({},t),{},{scale:e})}),Jwe=tt([ci,ph,d4,GQ],h4);tt((t,e,n)=>ZO(t,n),Jwe,(t,e)=>{if(!(t==null||e==null))return wS(wS({},t),{},{scale:e})});var eSe=tt([Fn,TN,CN],(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}}),JQ=t=>t.options.defaultTooltipEventType,eZ=t=>t.options.validateTooltipEventTypes;function tZ(t,e,n){if(t==null)return e;var r=t?"axis":"item";return n==null?e:n.includes(r)?r:e}function b4(t,e){var n=JQ(t),r=eZ(t);return tZ(e,n,r)}function tSe(t){return Gt(e=>b4(e,t))}var nZ=(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},nSe=t=>t.tooltip.settings,Md={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},rSe={itemInteraction:{click:Md,hover:Md},axisInteraction:{click:Md,hover:Md},keyboardInteraction:Md,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}},rZ=Es({name:"tooltip",initialState:rSe,reducers:{addTooltipEntrySettings:{reducer(t,e){t.tooltipItemPayloads.push(e.payload)},prepare:Fr()},replaceTooltipEntrySettings:{reducer(t,e){var{prev:n,next:r}=e.payload,i=al(t).tooltipItemPayloads.indexOf(n);i>-1&&(t.tooltipItemPayloads[i]=r)},prepare:Fr()},removeTooltipEntrySettings:{reducer(t,e){var n=al(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:iSe,replaceTooltipEntrySettings:aSe,removeTooltipEntrySettings:sSe,setTooltipSettingsState:oSe,setActiveMouseOverItemIndex:iZ,mouseLeaveItem:lSe,mouseLeaveChart:aZ,setActiveClickItemIndex:cSe,setMouseOverAxisIndex:sZ,setMouseClickAxisIndex:uSe,setSyncInteraction:u3,setKeyboardInteraction:d3}=rZ.actions,dSe=rZ.reducer;function N$(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?N$(Object(n),!0).forEach(function(r){hSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):N$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function hSe(t,e,n){return(e=fSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function fSe(t){var e=mSe(t,"string");return typeof e=="symbol"?e:e+""}function mSe(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 pSe(t,e,n){return e==="axis"?n==="click"?t.axisInteraction.click:t.axisInteraction.hover:n==="click"?t.itemInteraction.click:t.itemInteraction.hover}function gSe(t){return t.index!=null}var oZ=(t,e,n,r)=>{if(e==null)return Md;var i=pSe(t,e,n);if(i==null)return Md;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(gSe(i)){if(a)return T_(T_({},i),{},{active:!0})}else if(r!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:r,graphicalItemId:void 0};return T_(T_({},Md),{},{coordinate:i.coordinate})};function xSe(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 bSe(t,e){var n=xSe(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 ySe(t,e,n){if(n==null||e==null)return!0;var r=ir(t,e);return r==null||!xu(n)?!0:bSe(r,n)}var y4=(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||ySe(u,n,r)?String(c):null},lZ=(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}}},cZ=(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})},uZ=t=>t.options.tooltipPayloadSearcher,sx=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 A$(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){vSe(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 vSe(t,e,n){return(e=_Se(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function _Se(t){var e=wSe(t,"string");return typeof e=="symbol"?e:e+""}function wSe(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 SSe(t,e){return t??e}var dZ=(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:y,settings:x}=p,v=SSe(y,l),S=Array.isArray(v)?KX(v,u,d):v,M=(b=x?.dataKey)!==null&&b!==void 0?b:r,E=x?.nameKey,A;if(r&&Array.isArray(S)&&!Array.isArray(S[0])&&o==="axis"?A=tX(S,r,i):A=a(S,e,c,E),Array.isArray(A))A.forEach(T=>{var D=A$(A$({},x),{},{name:T.name,unit:T.unit,color:void 0,fill:void 0});m.push(N8({tooltipEntrySettings:D,dataKey:T.dataKey,payload:T.payload,value:ir(T.payload,T.dataKey),name:T.name}))});else{var k;m.push(N8({tooltipEntrySettings:x,dataKey:M,payload:A,value:ir(A,M),name:(k=ir(A,E))!==null&&k!==void 0?k:x?.name}))}return m},f)}},v4=tt([Hi,jQ,WO],HQ),MSe=tt([t=>t.graphicalItems.cartesianItems,t=>t.graphicalItems.polarItems],(t,e)=>[...t,...e]),NSe=tt([la,rx],JO),ox=tt([MSe,Hi,NSe],e4,{memoizeOptions:{resultEqualityCheck:KN}}),ESe=tt([ox],t=>t.filter(WN)),ASe=tt([ox],t4,{memoizeOptions:{resultEqualityCheck:KN}}),lx=tt([ASe,Au],n4),TSe=tt([ESe,Au,Hi],AQ),_4=tt([lx,Hi,ox],i4),hZ=tt([Hi],a4),CSe=tt([Hi],t=>t.allowDataOverflow),fZ=tt([hZ,CSe],oQ),kSe=tt([ox],t=>t.filter(WN)),jSe=tt([TSe,kSe,Ry,vQ],OQ),PSe=tt([jSe,Au,la,fZ],LQ),RSe=tt([ox],RQ),DSe=tt([lx,Hi,RSe,YN,la],l4,{memoizeOptions:{resultEqualityCheck:qN}}),OSe=tt([IQ,la,rx],ax),LSe=tt([OSe,la],zQ),ISe=tt([FQ,la,rx],ax),FSe=tt([ISe,la],BQ),USe=tt([UQ,la,rx],ax),zSe=tt([USe,la],$Q),BSe=tt([LSe,zSe,FSe],MS),$Se=tt([Hi,hZ,fZ,PSe,DSe,BSe,Fn,la],c4),Uy=tt([Hi,Fn,lx,_4,Ry,la,$Se],u4),HSe=tt([Uy,Hi,v4],f4),VSe=tt([Hi,Uy,HSe,la],p4),mZ=t=>{var e=la(t),n=rx(t),r=!1;return Fy(t,e,n,r)},pZ=tt([Hi,mZ],$N),gZ=tt([Hi,v4,VSe,pZ],h4),GSe=tt([Fn,_4,Hi,la],YQ),WSe=tt([Fn,_4,Hi,la],QQ),qSe=(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(vs):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(vs)}}},Tu=tt([Fn,Hi,v4,gZ,mZ,GSe,WSe,la],qSe),w4=tt([JQ,eZ,nSe],(t,e,n)=>tZ(n.shared,t,e)),xZ=t=>t.tooltip.settings.trigger,S4=t=>t.tooltip.settings.defaultIndex,zy=tt([sx,w4,xZ,S4],oZ),Zd=tt([zy,lx,Iy,Uy],y4),bZ=tt([Tu,Zd],nZ),M4=tt([zy],t=>{if(t)return t.dataKey}),KSe=tt([zy],t=>{if(t)return t.graphicalItemId}),yZ=tt([sx,w4,xZ,S4],cZ),XSe=tt([Mu,Nu,Fn,zi,Tu,S4,yZ],lZ),YSe=tt([zy,XSe],(t,e)=>t!=null&&t.coordinate?t.coordinate:e),QSe=tt([zy],t=>{var e;return(e=t?.active)!==null&&e!==void 0?e:!1}),ZSe=tt([yZ,Zd,Au,Iy,bZ,uZ,w4],dZ),JSe=tt([ZSe],t=>{if(t!=null){var e=t.map(n=>n.payload).filter(n=>n!=null);return Array.from(new Set(e))}});function T$(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?T$(Object(n),!0).forEach(function(r){eMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):T$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function eMe(t,e,n){return(e=tMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function tMe(t){var e=nMe(t,"string");return typeof e=="symbol"?e:e+""}function nMe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var rMe=()=>Gt(Hi),iMe=()=>{var t=rMe(),e=Gt(Tu),n=Gt(gZ);return Qd(!t||!n?void 0:C$(C$({},t),{},{scale:n}),e)};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 Zm(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){aMe(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 aMe(t,e,n){return(e=sMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function sMe(t){var e=oMe(t,"string");return typeof e=="symbol"?e:e+""}function oMe(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 lMe=(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}},cMe=(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),Ni(r.cx,r.cy,o,a)),{},{angle:a,radius:o})}var l=i.coordinate,{angle:c}=r;return Zm(Zm(Zm({},r),Ni(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 uMe(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 vZ=(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,y=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||y==null))if(ea(b-p)!==ea(y-b)){var v=[];if(ea(y-b)===ea(i[1]-i[0])){x=y;var S=b+i[1]-i[0];v[0]=Math.min(S,(S+p)/2),v[1]=Math.max(S,(S+p)/2)}else{x=p;var M=y+i[1]-i[0];v[0]=Math.min(b,(M+b)/2),v[1]=Math.max(b,(M+b)/2)}var E=[Math.min(b,(x+b)/2),Math.max(b,(x+b)/2)];if(t>E[0]&&t<=E[1]||t>=v[0]&&t<=v[1]){var A;return(A=n[l])===null||A===void 0?void 0:A.index}}else{var k=Math.min(p,y),T=Math.max(p,y);if(t>(k+b)/2&&t<=(T+b)/2){var D;return(D=n[l])===null||D===void 0?void 0:D.index}}}else if(e)for(var C=0;C<o;C++){var R=e[C];if(R!=null){var U=e[C+1],O=e[C-1];if(C===0&&U!=null&&t<=(R.coordinate+U.coordinate)/2||C===o-1&&O!=null&&t>(R.coordinate+O.coordinate)/2||C>0&&C<o-1&&O!=null&&U!=null&&t>(R.coordinate+O.coordinate)/2&&t<=(R.coordinate+U.coordinate)/2)return R.index}}return-1},_Z=()=>Gt(WO),N4=(t,e)=>e,wZ=(t,e,n)=>n,E4=(t,e,n,r)=>r,dMe=tt(Tu,t=>bN(t,e=>e.coordinate)),A4=tt([sx,N4,wZ,E4],oZ),T4=tt([A4,lx,Iy,Uy],y4),hMe=(t,e,n)=>{if(e!=null){var r=sx(t);return e==="axis"?n==="hover"?r.axisInteraction.hover.dataKey:r.axisInteraction.click.dataKey:n==="hover"?r.itemInteraction.hover.dataKey:r.itemInteraction.click.dataKey}},SZ=tt([sx,N4,wZ,E4],cZ),NS=tt([Mu,Nu,Fn,zi,Tu,E4,SZ],lZ),fMe=tt([A4,NS],(t,e)=>{var n;return(n=t.coordinate)!==null&&n!==void 0?n:e}),MZ=tt([Tu,T4],nZ),mMe=tt([SZ,T4,Au,Iy,MZ,uZ,N4],dZ),pMe=tt([A4,T4],(t,e)=>({isActive:t.active&&e!=null,activeIndex:e})),gMe=(t,e,n,r,i,a,o)=>{if(!(!t||!n||!r||!i)&&uMe(t,o)){var l=Fbe(t,e),c=vZ(l,a,i,n,r),u=lMe(e,i,c,t);return{activeIndex:String(c),activeCoordinate:u}}},xMe=(t,e,n,r,i,a,o)=>{if(!(!t||!r||!i||!a||!n)){var l=tve(t,n);if(l){var c=Ube(l,e),u=vZ(c,o,a,r,i),d=cMe(e,a,u,l);return{activeIndex:String(u),activeCoordinate:d}}}},bMe=(t,e,n,r,i,a,o,l)=>{if(!(!t||!e||!r||!i||!a))return e==="horizontal"||e==="vertical"?gMe(t,e,r,i,a,o,l):xMe(t,e,n,r,i,a,o)},yMe=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}}),vMe=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:twe}});function j$(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 P$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?j$(Object(n),!0).forEach(function(r){_Me(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):j$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function _Me(t,e,n){return(e=wMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function wMe(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 MMe={},NMe={zIndexMap:Object.values(oi).reduce((t,e)=>P$(P$({},t),{},{[e]:{element:void 0,panoramaElement:void 0,consumers:0}}),MMe)},EMe=new Set(Object.values(oi));function AMe(t){return EMe.has(t)}var NZ=Es({name:"zIndex",initialState:NMe,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&&!AMe(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:TMe,unregisterZIndexPortal:CMe,registerZIndexPortalElement:kMe,unregisterZIndexPortalElement:jMe}=NZ.actions,PMe=NZ.reducer;function $a(t){var{zIndex:e,children:n}=t,r=g0e(),i=r&&e!==void 0&&e!==0,a=Bi(),o=Mr();w.useLayoutEffect(()=>i?(o(TMe({zIndex:e})),()=>{o(CMe({zIndex:e}))}):uh,[o,e,i]);var l=Gt(c=>yMe(c,e,a));return i?l?Qc.createPortal(n,l):null:n}function h3(){return h3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},h3.apply(null,arguments)}function R$(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?R$(Object(n),!0).forEach(function(r){RMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):R$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function RMe(t,e,n){return(e=DMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function DMe(t){var e=OMe(t,"string");return typeof e=="symbol"?e:e+""}function OMe(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 LMe(t){var{cursor:e,cursorComp:n,cursorProps:r}=t;return w.isValidElement(e)?w.cloneElement(e,r):w.createElement(n,r)}function IMe(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,y,x;if(d==="ScatterChart")b=f,y=pye,x=oi.cursorLine;else if(d==="BarChart")b=gye(l,f,a,o),y=_Y,x=oi.cursorRectangle;else if(l==="radial"&&rX(f)){var{cx:v,cy:S,radius:M,startAngle:E,endAngle:A}=SY(f);b={cx:v,cy:S,startAngle:E,endAngle:A,innerRadius:M,outerRadius:M},y=NY,x=oi.cursorLine}else b={points:ave(l,f,a)},y=ng,x=oi.cursorLine;var k=typeof c=="object"&&"className"in c?c.className:void 0,T=C_(C_(C_(C_({stroke:"#ccc",pointerEvents:"none"},a),b),Hf(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(LMe,{cursor:c,cursorComp:y,cursorProps:T}))}function FMe(t){var e=iMe(),n=iY(),r=hh(),i=_Z();return e==null||n==null||r==null||i==null?null:w.createElement(IMe,h3({},t,{offset:n,layout:r,tooltipAxisBandSize:e,chartName:i}))}var EZ=w.createContext(null),UMe=()=>w.useContext(EZ),NC={exports:{}},D$;function zMe(){return D$||(D$=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 y=n?n+u:u;if(!this._events[y])return!1;var x=this._events[y],v=arguments.length,S,M;if(x.fn){switch(x.once&&this.removeListener(u,x.fn,void 0,!0),v){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(v-1);M<v;M++)S[M-1]=arguments[M];x.fn.apply(x.context,S)}else{var E=x.length,A;for(M=0;M<E;M++)switch(x[M].once&&this.removeListener(u,x[M].fn,void 0,!0),v){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(v-1);A<v;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 y=0,x=[],v=b.length;y<v;y++)(b[y].fn!==d||m&&!b[y].once||f&&b[y].context!==f)&&x.push(b[y]);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})(NC)),NC.exports}var BMe=zMe();const $Me=ml(BMe);var V0=new $Me,f3="recharts.syncEvent.tooltip",O$="recharts.syncEvent.brush",JN=(t,e)=>{if(e&&Array.isArray(t)){var n=Number.parseInt(e,10);if(!ul(n))return t[n]}},HMe={chartName:"",tooltipPayloadSearcher:()=>{},eventEmitter:void 0,defaultTooltipEventType:"axis"},AZ=Es({name:"options",initialState:HMe,reducers:{createEventEmitter:t=>{t.eventEmitter==null&&(t.eventEmitter=Symbol("rechartsEventEmitter"))}}}),VMe=AZ.reducer,{createEventEmitter:GMe}=AZ.actions;function WMe(t){return t.tooltip.syncInteraction}var qMe={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},TZ=Es({name:"chartData",initialState:qMe,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:L$,setDataStartEndIndexes:KMe,setComputedData:ZQe}=TZ.actions,XMe=TZ.reducer,YMe=["x","y"];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 Jm(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){QMe(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 QMe(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=JMe(t,"string");return typeof e=="symbol"?e:e+""}function JMe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function eNe(t,e){if(t==null)return{};var n,r,i=tNe(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 tNe(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 nNe(){var t=Gt(qO),e=Gt(KO),n=Mr(),r=Gt(_Q),i=Gt(Tu),a=hh(),o=Ny(),l=Gt(c=>c.rootProps.className);w.useEffect(()=>{if(t==null)return uh;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}=p,x=eNe(p,YMe),{x:v,y:S,width:M,height:E}=d.payload.sourceViewBox,A=Jm(Jm({},x),{},{x:o.x+(M?(b-v)/M:0)*o.width,y:o.y+(E?(y-S)/E:0)*o.height});n(Jm(Jm({},d),{},{payload:Jm(Jm({},d.payload),{},{coordinate:A})}))}else n(d);return}if(i!=null){var k;if(typeof r=="function"){var T={activeTooltipIndex:d.payload.index==null?void 0:Number(d.payload.index),isTooltipActive:d.payload.active,activeIndex:d.payload.index==null?void 0:Number(d.payload.index),activeLabel:d.payload.label,activeDataKey:d.payload.dataKey,activeCoordinate:d.payload.coordinate},D=r(i,T);k=i[D]}else r==="value"&&(k=i.find(X=>String(X.value)===d.payload.label));var{coordinate:C}=d.payload;if(k==null||d.payload.active===!1||C==null||o==null){n(u3({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}=C,O=Math.min(R,o.x+o.width),q=Math.min(U,o.y+o.height),j={x:a==="horizontal"?k.coordinate:O,y:a==="horizontal"?q:k.coordinate},W=u3({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 V0.on(f3,c),()=>{V0.off(f3,c)}},[l,n,e,t,r,i,a,o])}function rNe(){var t=Gt(qO),e=Gt(KO),n=Mr();w.useEffect(()=>{if(t==null)return uh;var r=(i,a,o)=>{e!==o&&t===i&&n(KMe(a))};return V0.on(O$,r),()=>{V0.off(O$,r)}},[n,e,t])}function iNe(){var t=Mr();w.useEffect(()=>{t(GMe())},[t]),nNe(),rNe()}function aNe(t,e,n,r,i,a){var o=Gt(p=>hMe(p,t,e)),l=Gt(KO),c=Gt(qO),u=Gt(_Q),d=Gt(WMe),f=d?.active,m=Ny();w.useEffect(()=>{if(!f&&c!=null&&l!=null){var p=u3({active:a,coordinate:n,dataKey:o,index:i,label:typeof r=="number"?String(r):r,sourceViewBox:m,graphicalItemId:void 0});V0.emit(f3,c,p,l)}},[f,n,o,i,r,l,c,u,a,m])}function F$(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 U$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?F$(Object(n),!0).forEach(function(r){sNe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):F$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function sNe(t,e,n){return(e=oNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function oNe(t){var e=lNe(t,"string");return typeof e=="symbol"?e:e+""}function lNe(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 cNe(t){return t.dataKey}function uNe(t,e){return w.isValidElement(t)?w.cloneElement(t,e):typeof t=="function"?w.createElement(t,e):w.createElement(K0e,e)}var z$=[],dNe={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 aw(t){var e,n,r=Kr(t,dNe),{active:i,allowEscapeViewBox:a,animationDuration:o,animationEasing:l,content:c,filterNull:u,isAnimationActive:d,offset:f,payloadUniqBy:m,position:p,reverseDirection:b,useTranslate3d:y,wrapperStyle:x,cursor:v,shared:S,trigger:M,defaultIndex:E,portal:A,axisId:k}=r,T=Mr(),D=typeof E=="number"?String(E):E;w.useEffect(()=>{T(oSe({shared:S,trigger:M,axisId:k,active:i,defaultIndex:D}))},[T,S,M,k,i,D]);var C=Ny(),R=gY(),U=tSe(S),{activeIndex:O,isActive:q}=(e=Gt(oe=>pMe(oe,U,M,D)))!==null&&e!==void 0?e:{},j=Gt(oe=>mMe(oe,U,M,D)),W=Gt(oe=>MZ(oe,U,M,D)),X=Gt(oe=>fMe(oe,U,M,D)),G=j,Z=UMe(),te=(n=i??q)!==null&&n!==void 0?n:!1,[ee,z]=bX([G,te]),V=U==="axis"?W:void 0;aNe(U,M,X,V,O,te);var ne=A??Z;if(ne==null||C==null||U==null)return null;var ie=G??z$;te||(ie=z$),u&&ie.length&&(ie=hX(ie.filter(oe=>oe.value!=null&&(oe.hide!==!0||r.includeHidden)),m,cNe));var he=ie.length>0,me=w.createElement(tye,{allowEscapeViewBox:a,animationDuration:o,animationEasing:l,isAnimationActive:d,active:te,coordinate:X,hasPayload:he,offset:f,position:p,reverseDirection:b,useTranslate3d:y,viewBox:C,wrapperStyle:x,lastBoundingBox:ee,innerRef:z,hasPortalFromProps:!!A},uNe(c,U$(U$({},r),{},{payload:ie,label:V,active:te,activeIndex:O,coordinate:X,accessibilityLayer:R})));return w.createElement(w.Fragment,null,Qc.createPortal(me,ne),te&&w.createElement(FMe,{cursor:v,tooltipEventType:U,coordinate:X,payload:ie,index:O}))}var By=t=>null;By.displayName="Cell";function hNe(t,e,n){return(e=fNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function fNe(t){var e=mNe(t,"string");return typeof e=="symbol"?e:e+""}function mNe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}class pNe{constructor(e){hNe(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 B$(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 gNe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?B$(Object(n),!0).forEach(function(r){xNe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):B$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function xNe(t,e,n){return(e=bNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function bNe(t){var e=yNe(t,"string");return typeof e=="symbol"?e:e+""}function yNe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var vNe={cacheSize:2e3,enableCache:!0},CZ=gNe({},vNe),$$=new pNe(CZ.cacheSize),_Ne={position:"absolute",top:"-20000px",left:0,padding:0,margin:0,border:"none",whiteSpace:"pre"},H$="recharts_measurement_span";function wNe(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 V$=(t,e)=>{try{var n=document.getElementById(H$);n||(n=document.createElement("span"),n.setAttribute("id",H$),n.setAttribute("aria-hidden","true"),document.body.appendChild(n)),Object.assign(n.style,_Ne,e),n.textContent="".concat(t);var r=n.getBoundingClientRect();return{width:r.width,height:r.height}}catch{return{width:0,height:0}}},r0=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null||Ty.isSsr)return{width:0,height:0};if(!CZ.enableCache)return V$(e,n);var r=wNe(e,n),i=$$.get(r);if(i)return i;var a=V$(e,n);return $$.set(r,a),a},kZ;function SNe(t,e,n){return(e=MNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function MNe(t){var e=NNe(t,"string");return typeof e=="symbol"?e:e+""}function NNe(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$=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,W$=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,ENe=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,ANe=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,TNe={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},CNe=["cm","mm","pt","pc","in","Q","px"];function kNe(t){return CNe.includes(t)}var qp="NaN";function jNe(t,e){return t*TNe[e]}class ba{static parse(e){var n,[,r,i]=(n=ANe.exec(e))!==null&&n!==void 0?n:[];return r==null?ba.NaN:new ba(parseFloat(r),i??"")}constructor(e,n){this.num=e,this.unit=n,this.num=e,this.unit=n,ul(e)&&(this.unit=""),n!==""&&!ENe.test(n)&&(this.num=NaN,this.unit=""),kNe(n)&&(this.num=jNe(e,n),this.unit="px")}add(e){return this.unit!==e.unit?new ba(NaN,""):new ba(this.num+e.num,this.unit)}subtract(e){return this.unit!==e.unit?new ba(NaN,""):new ba(this.num-e.num,this.unit)}multiply(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new ba(NaN,""):new ba(this.num*e.num,this.unit||e.unit)}divide(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new ba(NaN,""):new ba(this.num/e.num,this.unit||e.unit)}toString(){return"".concat(this.num).concat(this.unit)}isNaN(){return ul(this.num)}}kZ=ba;SNe(ba,"NaN",new kZ(NaN,""));function jZ(t){if(t==null||t.includes(qp))return qp;for(var e=t;e.includes("*")||e.includes("/");){var n,[,r,i,a]=(n=G$.exec(e))!==null&&n!==void 0?n:[],o=ba.parse(r??""),l=ba.parse(a??""),c=i==="*"?o.multiply(l):o.divide(l);if(c.isNaN())return qp;e=e.replace(G$,c.toString())}for(;e.includes("+")||/.-\d+(?:\.\d+)?/.test(e);){var u,[,d,f,m]=(u=W$.exec(e))!==null&&u!==void 0?u:[],p=ba.parse(d??""),b=ba.parse(m??""),y=f==="+"?p.add(b):p.subtract(b);if(y.isNaN())return qp;e=e.replace(W$,y.toString())}return e}var q$=/\(([^()]*)\)/;function PNe(t){for(var e=t,n;(n=q$.exec(e))!=null;){var[,r]=n;e=e.replace(q$,jZ(r))}return e}function RNe(t){var e=t.replace(/\s+/g,"");return e=PNe(e),e=jZ(e),e}function DNe(t){try{return RNe(t)}catch{return qp}}function EC(t){var e=DNe(t.slice(5,-1));return e===qp?"":e}var ONe=["x","y","lineHeight","capHeight","fill","scaleToFit","textAnchor","verticalAnchor"],LNe=["dx","dy","angle","className","breakAll"];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 K$(t,e){if(t==null)return{};var n,r,i=INe(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 INe(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 PZ=/[ \f\n\r\t\v\u2028\u2029]+/,RZ=t=>{var{children:e,breakAll:n,style:r}=t;try{var i=[];Hr(e)||(n?i=e.toString().split(""):i=e.toString().split(PZ));var a=i.map(l=>({word:l,width:r0(l,r).width})),o=n?0:r0(" ",r).width;return{wordsWithComputedWidth:a,spaceWidth:o}}catch{return null}};function FNe(t){return t==="start"||t==="middle"||t==="end"||t==="inherit"}var DZ=(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},[]),OZ=t=>t.reduce((e,n)=>e.width>n.width?e:n),UNe="…",X$=(t,e,n,r,i,a,o,l)=>{var c=t.slice(0,e),u=RZ({breakAll:n,style:r,children:c+UNe});if(!u)return[!1,[]];var d=DZ(u.wordsWithComputedWidth,a,o,l),f=d.length>i||OZ(d).width>Number(a);return[f,d]},zNe=(t,e,n,r,i)=>{var{maxLines:a,children:o,style:l,breakAll:c}=t,u=zt(a),d=String(o),f=DZ(e,r,n,i);if(!u||i)return f;var m=f.length>a||OZ(f).width>Number(r);if(!m)return f;for(var p=0,b=d.length-1,y=0,x;p<=b&&y<=d.length-1;){var v=Math.floor((p+b)/2),S=v-1,[M,E]=X$(d,S,c,l,a,r,n,i),[A]=X$(d,v,c,l,a,r,n,i);if(!M&&!A&&(p=v+1),M&&A&&(b=v-1),!M&&A){x=E;break}y++}return x||f},Y$=t=>{var e=Hr(t)?[]:t.toString().split(PZ);return[{words:e,width:void 0}]},BNe=t=>{var{width:e,scaleToFit:n,children:r,style:i,breakAll:a,maxLines:o}=t;if((e||n)&&!Ty.isSsr){var l,c,u=RZ({breakAll:a,children:r,style:i});if(u){var{wordsWithComputedWidth:d,spaceWidth:f}=u;l=d,c=f}else return Y$(r);return zNe({breakAll:a,children:r,maxLines:o,style:i},l,c,e,!!n)}return Y$(r)},LZ="#808080",$Ne={angle:0,breakAll:!1,capHeight:"0.71em",fill:LZ,lineHeight:"1em",scaleToFit:!1,textAnchor:"start",verticalAnchor:"end",x:0,y:0},eE=w.forwardRef((t,e)=>{var n=Kr(t,$Ne),{x:r,y:i,lineHeight:a,capHeight:o,fill:l,scaleToFit:c,textAnchor:u,verticalAnchor:d}=n,f=K$(n,ONe),m=w.useMemo(()=>BNe({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:y,className:x,breakAll:v}=f,S=K$(f,LNe);if(!Lo(r)||!Lo(i)||m.length===0)return null;var M=Number(r)+(zt(p)?p:0),E=Number(i)+(zt(b)?b:0);if(!pn(M)||!pn(E))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=[],T=m[0];if(c&&T!=null){var D=T.width,{width:C}=f;k.push("scale(".concat(zt(C)&&zt(D)?C/D:1,")"))}return y&&k.push("rotate(".concat(y,", ").concat(M,", ").concat(E,")")),k.length&&(S.transform=k.join(" ")),w.createElement("text",m3({},Aa(S),{ref:e,x:M,y:E,className:Bn("recharts-text",x),textAnchor:u,fill:l.includes("url")?LZ:l}),m.map((R,U)=>{var O=R.words.join(v?"":" ");return w.createElement("tspan",{x:M,dy:U===0?A:a,key:"".concat(O,"-").concat(U)},O)}))});eE.displayName="Text";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 Al(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){HNe(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 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)}var WNe=t=>{var{viewBox:e,position:n,offset:r=0,parentViewBox:i}=t,{x:a,y:o,height:l,upperWidth:c,lowerWidth:u}=fO(e),d=a,f=a+(c-u)/2,m=(d+f)/2,p=(c+u)/2,b=d+c/2,y=l>=0?1:-1,x=y*r,v=y>0?"end":"start",S=y>0?"start":"end",M=c>=0?1:-1,E=M*r,A=M>0?"end":"start",k=M>0?"start":"end",T=i;if(n==="top"){var D={x:d+c/2,y:o-x,horizontalAnchor:"middle",verticalAnchor:v};return T&&(D.height=Math.max(o-T.y,0),D.width=c),D}if(n==="bottom"){var C={x:f+u/2,y:o+l+x,horizontalAnchor:"middle",verticalAnchor:S};return T&&(C.height=Math.max(T.y+T.height-(o+l),0),C.width=u),C}if(n==="left"){var R={x:m-E,y:o+l/2,horizontalAnchor:A,verticalAnchor:"middle"};return T&&(R.width=Math.max(R.x-T.x,0),R.height=l),R}if(n==="right"){var U={x:m+p+E,y:o+l/2,horizontalAnchor:k,verticalAnchor:"middle"};return T&&(U.width=Math.max(T.x+T.width-U.x,0),U.height=l),U}var O=T?{width:p,height:l}:{};return n==="insideLeft"?Al({x:m+E,y:o+l/2,horizontalAnchor:k,verticalAnchor:"middle"},O):n==="insideRight"?Al({x:m+p-E,y:o+l/2,horizontalAnchor:A,verticalAnchor:"middle"},O):n==="insideTop"?Al({x:d+c/2,y:o+x,horizontalAnchor:"middle",verticalAnchor:S},O):n==="insideBottom"?Al({x:f+u/2,y:o+l-x,horizontalAnchor:"middle",verticalAnchor:v},O):n==="insideTopLeft"?Al({x:d+E,y:o+x,horizontalAnchor:k,verticalAnchor:S},O):n==="insideTopRight"?Al({x:d+c-E,y:o+x,horizontalAnchor:A,verticalAnchor:S},O):n==="insideBottomLeft"?Al({x:f+E,y:o+l-x,horizontalAnchor:k,verticalAnchor:v},O):n==="insideBottomRight"?Al({x:f+u-E,y:o+l-x,horizontalAnchor:A,verticalAnchor:v},O):n&&typeof n=="object"&&(zt(n.x)||Wf(n.x))&&(zt(n.y)||Wf(n.y))?Al({x:a+Ba(n.x,p),y:o+Ba(n.y,l),horizontalAnchor:"end",verticalAnchor:"end"},O):Al({x:b,y:o+l/2,horizontalAnchor:"middle",verticalAnchor:"middle"},O)},qNe=["labelRef"],KNe=["content"];function Z$(t,e){if(t==null)return{};var n,r,i=XNe(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 XNe(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 J$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function zb(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?J$(Object(n),!0).forEach(function(r){YNe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):J$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function YNe(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=ZNe(t,"string");return typeof e=="symbol"?e:e+""}function ZNe(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 Kc(){return Kc=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Kc.apply(null,arguments)}var IZ=w.createContext(null),FZ=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(IZ.Provider,{value:c},l)},UZ=()=>{var t=w.useContext(IZ),e=Ny();return t||(e?fO(e):void 0)},JNe=w.createContext(null),eEe=()=>{var t=w.useContext(JNe),e=Gt(EQ);return t||e},tEe=t=>{var{value:e,formatter:n}=t,r=Hr(t.children)?e:t.children;return typeof n=="function"?n(r):r},C4=t=>t!=null&&typeof t=="function",nEe=(t,e)=>{var n=ea(e-t),r=Math.min(Math.abs(e-t),360);return n*r},rEe=(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,y=nEe(f,m),x=y>=0?1:-1,v,S;switch(e){case"insideStart":v=f+x*a,S=p;break;case"insideEnd":v=m-x*a,S=!p;break;case"end":v=m+x*a,S=p;break;default:throw new Error("Unsupported position ".concat(e))}S=y<=0?S:!S;var M=Ni(l,c,b,v),E=Ni(l,c,b,v+(S?1:-1)*359),A="M".concat(M.x,",").concat(M.y,`
- A`).concat(b,",").concat(b,",0,1,").concat(S?0:1,`,
- `).concat(E.x,",").concat(E.y),k=Hr(t.id)?j0("recharts-radial-line-"):t.id;return w.createElement("text",Kc({},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))},iEe=(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}=Ni(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}=Ni(r,i,m,u);return{x:p,y:b,textAnchor:"middle",verticalAnchor:"middle"}},sw=t=>t!=null&&"cx"in t&&zt(t.cx),aEe={angle:0,offset:5,zIndex:oi.label,position:"middle",textBreakAll:!1};function sEe(t){if(!sw(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 xd(t){var e=Kr(t,aEe),{viewBox:n,parentViewBox:r,position:i,value:a,children:o,content:l,className:c="",textBreakAll:u,labelRef:d}=e,f=eEe(),m=UZ(),p=i==="center"?m:f??m,b,y,x;n==null?b=p:sw(n)?b=n:b=fO(n);var v=sEe(b);if(!b||Hr(a)&&Hr(o)&&!w.isValidElement(l)&&typeof l!="function")return null;var S=zb(zb({},e),{},{viewBox:b});if(w.isValidElement(l)){var{labelRef:M}=S,E=Z$(S,qNe);return w.cloneElement(l,E)}if(typeof l=="function"){var{content:A}=S,k=Z$(S,KNe);if(y=w.createElement(l,k),w.isValidElement(y))return y}else y=tEe(e);var T=Aa(e);if(sw(b)){if(i==="insideStart"||i==="insideEnd"||i==="end")return rEe(e,i,y,T,b);x=iEe(b,e.offset,e.position)}else{if(!v)return null;var D=WNe({viewBox:v,position:i,offset:e.offset,parentViewBox:sw(r)?void 0:r});x=zb(zb({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(eE,Kc({ref:d,className:Bn("recharts-label",c)},T,x,{textAnchor:FNe(T.textAnchor)?T.textAnchor:x.textAnchor,breakAll:u}),y))}xd.displayName="Label";var oEe=(t,e,n)=>{if(!t)return null;var r={viewBox:e,labelRef:n};return t===!0?w.createElement(xd,Kc({key:"label-implicit"},r)):Lo(t)?w.createElement(xd,Kc({key:"label-implicit",value:t},r)):w.isValidElement(t)?t.type===xd?w.cloneElement(t,zb({key:"label-implicit"},r)):w.createElement(xd,Kc({key:"label-implicit",content:t},r)):C4(t)?w.createElement(xd,Kc({key:"label-implicit",content:t},r)):t&&typeof t=="object"?w.createElement(xd,Kc({},t,{key:"label-implicit"},r)):null};function zZ(t){var{label:e,labelRef:n}=t,r=UZ();return oEe(e,r,n)||null}var AC={},TC={},eH;function lEe(){return eH||(eH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n[n.length-1]}t.last=e})(TC)),TC}var CC={},tH;function cEe(){return tH||(tH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Array.isArray(n)?n:Array.from(n)}t.toArray=e})(CC)),CC}var nH;function uEe(){return nH||(nH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=lEe(),n=cEe(),r=nO();function i(a){if(r.isArrayLike(a))return e.last(n.toArray(a))}t.last=i})(AC)),AC}var kC,rH;function dEe(){return rH||(rH=1,kC=uEe().last),kC}var hEe=dEe();const fEe=ml(hEe);var mEe=["valueAccessor"],pEe=["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 iH(t,e){if(t==null)return{};var n,r,i=gEe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function gEe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var xEe=t=>Array.isArray(t.value)?fEe(t.value):t.value,BZ=w.createContext(void 0),k4=BZ.Provider,$Z=w.createContext(void 0),bEe=$Z.Provider;function yEe(){return w.useContext(BZ)}function vEe(){return w.useContext($Z)}function ow(t){var{valueAccessor:e=xEe}=t,n=iH(t,mEe),{dataKey:r,clockWise:i,id:a,textBreakAll:o,zIndex:l}=n,c=iH(n,pEe),u=yEe(),d=vEe(),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,y=Hr(r)?e(m,p):ir(m.payload,r),x=Hr(a)?{}:{id:"".concat(a,"-").concat(p)};return w.createElement(xd,ES({key:"label-".concat(p)},Aa(m),c,x,{fill:(b=n.fill)!==null&&b!==void 0?b:m.fill,parentViewBox:m.parentViewBox,value:y,textBreakAll:o,viewBox:m.viewBox,index:p,zIndex:0}))})))}ow.displayName="LabelList";function tE(t){var{label:e}=t;return e?e===!0?w.createElement(ow,{key:"labelList-implicit"}):w.isValidElement(e)||C4(e)?w.createElement(ow,{key:"labelList-implicit",content:e}):typeof e=="object"?w.createElement(ow,ES({key:"labelList-implicit"},e,{type:String(e.type)})):null:null}function p3(){return p3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},p3.apply(null,arguments)}var HZ=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",p3({},ns(t),tO(t),{className:a,cx:e,cy:n,r})):null},VZ=t=>t.graphicalItems.polarItems,_Ee=tt([Xr,Dy],JO),nE=tt([VZ,ci,_Ee],e4),wEe=tt([nE],t4),rE=tt([wEe,BN],n4),SEe=tt([rE,ci,nE],i4);tt([rE,ci,nE],(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 aH=()=>{},MEe=tt([rE,ci,nE,YN,Xr],l4),NEe=tt([ci,s4,o4,aH,MEe,aH,Fn,Xr],c4),GZ=tt([ci,Fn,rE,SEe,Ry,Xr,NEe],u4),EEe=tt([GZ,ix,ph],f4),AEe=tt([ci,GZ,EEe,Xr],p4);tt([ph,AEe],TQ);var TEe={radiusAxis:{},angleAxis:{}},WZ=Es({name:"polarAxis",initialState:TEe,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:JQe,removeRadiusAxis:eZe,addAngleAxis:tZe,removeAngleAxis:nZe}=WZ.actions,CEe=WZ.reducer;function qZ(t){return t&&typeof t=="object"&&"className"in t&&typeof t.className=="string"?t.className:""}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 oH(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){kEe(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 kEe(t,e,n){return(e=jEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function jEe(t){var e=PEe(t,"string");return typeof e=="symbol"?e:e+""}function PEe(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 REe=(t,e)=>e,j4=tt([VZ,REe],(t,e)=>t.filter(n=>n.type==="pie").find(n=>n.id===e)),DEe=[],P4=(t,e,n)=>n?.length===0?DEe:n,KZ=tt([BN,j4,P4],(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=>oH(oH({},e.presentationProps),a.props))),i!=null)return i}}),OEe=tt([KZ,j4,P4],(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:dh(o,e.dataKey),color:l,payload:r,type:e.legendType}})}),LEe=tt([KZ,j4,P4,zi],(t,e,n,r)=>{if(!(e==null||t==null))return I2e({offset:r,pieSettings:e,displayedData:t,cells:n})}),jC={exports:{}},fr={};var lH;function IEe(){if(lH)return fr;lH=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(y){if(typeof y=="object"&&y!==null){var x=y.$$typeof;switch(x){case t:switch(y=y.type,y){case n:case i:case r:case c:case u:case m:return y;default:switch(y=y&&y.$$typeof,y){case o:case l:case f:case d:return y;case a:return y;default:return 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(y){return b(y)===a},fr.isContextProvider=function(y){return b(y)===o},fr.isElement=function(y){return typeof y=="object"&&y!==null&&y.$$typeof===t},fr.isForwardRef=function(y){return b(y)===l},fr.isFragment=function(y){return b(y)===n},fr.isLazy=function(y){return b(y)===f},fr.isMemo=function(y){return b(y)===d},fr.isPortal=function(y){return b(y)===e},fr.isProfiler=function(y){return b(y)===i},fr.isStrictMode=function(y){return b(y)===r},fr.isSuspense=function(y){return b(y)===c},fr.isSuspenseList=function(y){return b(y)===u},fr.isValidElementType=function(y){return typeof y=="string"||typeof y=="function"||y===n||y===i||y===r||y===c||y===u||typeof y=="object"&&y!==null&&(y.$$typeof===f||y.$$typeof===d||y.$$typeof===o||y.$$typeof===a||y.$$typeof===l||y.$$typeof===p||y.getModuleId!==void 0)},fr.typeOf=b,fr}var cH;function FEe(){return cH||(cH=1,jC.exports=IEe()),jC.exports}var UEe=FEe(),uH=t=>typeof t=="string"?t:t?t.displayName||t.name||"Component":"",dH=null,PC=null,XZ=t=>{if(t===dH&&Array.isArray(PC))return PC;var e=[];return w.Children.forEach(t,n=>{Hr(n)||(UEe.isFragment(n)?e=e.concat(XZ(n.props.children)):e.push(n))}),PC=e,dH=t,e};function R4(t,e){var n=[],r=[];return Array.isArray(e)?r=e.map(i=>uH(i)):r=[uH(e)],XZ(t).forEach(i=>{var a=Gf(i,"type.displayName")||Gf(i,"type.name");a&&r.indexOf(a)!==-1&&n.push(i)}),n}var D4=t=>t&&typeof t=="object"&&"clipDot"in t?!!t.clipDot:!0,RC={},hH;function zEe(){return hH||(hH=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})(RC)),RC}var DC,fH;function BEe(){return fH||(fH=1,DC=zEe().isPlainObject),DC}var $Ee=BEe();const HEe=ml($Ee);var mH,pH,gH,xH,bH;function yH(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 vH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?yH(Object(n),!0).forEach(function(r){VEe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):yH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function VEe(t,e,n){return(e=GEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function GEe(t){var e=WEe(t,"string");return typeof e=="symbol"?e:e+""}function WEe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function AS(){return AS=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},AS.apply(null,arguments)}function gb(t,e){return e||(e=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}var _H=(t,e,n,r,i)=>{var a=n-r,o;return o=ni(mH||(mH=gb(["M ",",",""])),t,e),o+=ni(pH||(pH=gb(["L ",",",""])),t+n,e),o+=ni(gH||(gH=gb(["L ",",",""])),t+n-a/2,e+i),o+=ni(xH||(xH=gb(["L ",",",""])),t+n-a/2-r,e+i),o+=ni(bH||(bH=gb(["L ",","," Z"])),t,e),o},qEe={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},KEe=t=>{var e=Kr(t,qEe),{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),y=w.useRef(i),x=w.useRef(a),v=w.useRef(o),S=w.useRef(n),M=w.useRef(r),E=Jg(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",AS({},Aa(e),{className:A,d:_H(n,r,i,a,o)})));var k=y.current,T=x.current,D=v.current,C=S.current,R=M.current,U="0px ".concat(p===-1?1:p,"px"),O="".concat(p,"px 0px"),q=xY(["strokeDasharray"],u,c);return w.createElement(Zg,{animationId:E,key:E,canBegin:p>0,duration:u,easing:c,isActive:f,begin:d},j=>{var W=nr(k,i,j),X=nr(T,a,j),G=nr(D,o,j),Z=nr(C,n,j),te=nr(R,r,j);m.current&&(y.current=W,x.current=X,v.current=G,S.current=Z,M.current=te);var ee=j>0?{transition:q,strokeDasharray:O}:{strokeDasharray:U};return w.createElement("path",AS({},Aa(e),{className:A,d:_H(Z,te,W,X,G),ref:m,style:vH(vH({},ee),e.style)}))})},XEe=["option","shapeType","activeClassName"];function YEe(t,e){if(t==null)return{};var n,r,i=QEe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function QEe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function wH(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 TS(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?wH(Object(n),!0).forEach(function(r){ZEe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):wH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function ZEe(t,e,n){return(e=JEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function JEe(t){var e=e2e(t,"string");return typeof e=="symbol"?e:e+""}function e2e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function t2e(t,e){return TS(TS({},e),t)}function n2e(t,e){return t==="symbols"}function SH(t){var{shapeType:e,elementProps:n}=t;switch(e){case"rectangle":return w.createElement(_Y,n);case"trapezoid":return w.createElement(KEe,n);case"sector":return w.createElement(NY,n);case"symbols":if(n2e(e))return w.createElement(eO,n);break;case"curve":return w.createElement(ng,n);default:return null}}function r2e(t){return w.isValidElement(t)?t.props:t}function O4(t){var{option:e,shapeType:n,activeClassName:r="recharts-active-shape"}=t,i=YEe(t,XEe),a;if(w.isValidElement(e))a=w.cloneElement(e,TS(TS({},i),r2e(e)));else if(typeof e=="function")a=e(i,i.index);else if(HEe(e)&&typeof e!="boolean"){var o=t2e(e,i);a=w.createElement(SH,{shapeType:n,elementProps:o})}else{var l=i;a=w.createElement(SH,{shapeType:n,elementProps:l})}return i.isActive?w.createElement(qr,{className:r},a):a}var L4=(t,e,n)=>{var r=Mr();return(i,a)=>o=>{t?.(i,a,o),r(iZ({activeIndex:String(a),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}},I4=t=>{var e=Mr();return(n,r)=>i=>{t?.(n,r,i),e(lSe())}},F4=(t,e,n)=>{var r=Mr();return(i,a)=>o=>{t?.(i,a,o),r(cSe({activeIndex:String(a),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function iE(t){var{tooltipEntrySettings:e}=t,n=Mr(),r=Bi(),i=w.useRef(null);return w.useLayoutEffect(()=>{r||(i.current===null?n(iSe(e)):i.current!==e&&n(aSe({prev:i.current,next:e})),i.current=e)},[e,n,r]),w.useLayoutEffect(()=>()=>{i.current&&(n(sSe(i.current)),i.current=null)},[n]),null}function U4(t){var{legendPayload:e}=t,n=Mr(),r=Bi(),i=w.useRef(null);return w.useLayoutEffect(()=>{r||(i.current===null?n(fY(e)):i.current!==e&&n(mY({prev:i.current,next:e})),i.current=e)},[n,r,e]),w.useLayoutEffect(()=>()=>{i.current&&(n(pY(i.current)),i.current=null)},[n]),null}function i2e(t){var{legendPayload:e}=t,n=Mr(),r=Gt(Fn),i=w.useRef(null);return w.useLayoutEffect(()=>{r!=="centric"&&r!=="radial"||(i.current===null?n(fY(e)):i.current!==e&&n(mY({prev:i.current,next:e})),i.current=e)},[n,r,e]),w.useLayoutEffect(()=>()=>{i.current&&(n(pY(i.current)),i.current=null)},[n]),null}var OC,a2e=()=>{var[t]=w.useState(()=>j0("uid-"));return t},s2e=(OC=toe.useId)!==null&&OC!==void 0?OC:a2e;function o2e(t,e){var n=s2e();return e||(t?"".concat(t,"-").concat(n):n)}var l2e=w.createContext(void 0),aE=t=>{var{id:e,type:n,children:r}=t,i=o2e("recharts-".concat(n),e);return w.createElement(l2e.Provider,{value:i},r(i))},c2e={cartesianItems:[],polarItems:[]},YZ=Es({name:"graphicalItems",initialState:c2e,reducers:{addCartesianGraphicalItem:{reducer(t,e){t.cartesianItems.push(e.payload)},prepare:Fr()},replaceCartesianGraphicalItem:{reducer(t,e){var{prev:n,next:r}=e.payload,i=al(t).cartesianItems.indexOf(n);i>-1&&(t.cartesianItems[i]=r)},prepare:Fr()},removeCartesianGraphicalItem:{reducer(t,e){var n=al(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=al(t).polarItems.indexOf(e.payload);n>-1&&t.polarItems.splice(n,1)},prepare:Fr()}}}),{addCartesianGraphicalItem:u2e,replaceCartesianGraphicalItem:d2e,removeCartesianGraphicalItem:h2e,addPolarGraphicalItem:f2e,removePolarGraphicalItem:m2e}=YZ.actions,p2e=YZ.reducer,g2e=t=>{var e=Mr(),n=w.useRef(null);return w.useLayoutEffect(()=>{n.current===null?e(u2e(t)):n.current!==t&&e(d2e({prev:n.current,next:t})),n.current=t},[e,t]),w.useLayoutEffect(()=>()=>{n.current&&(e(h2e(n.current)),n.current=null)},[e]),null},z4=w.memo(g2e);function x2e(t){var e=Mr();return w.useLayoutEffect(()=>(e(f2e(t)),()=>{e(m2e(t))}),[e,t]),null}var b2e=["key"],y2e=["onMouseEnter","onClick","onMouseLeave"],v2e=["id"],_2e=["id"];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 ri(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){w2e(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 w2e(t,e,n){return(e=S2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function S2e(t){var e=M2e(t,"string");return typeof e=="symbol"?e:e+""}function M2e(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 Jd(){return Jd=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},Jd.apply(null,arguments)}function sE(t,e){if(t==null)return{};var n,r,i=N2e(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function N2e(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function E2e(t){var e=w.useMemo(()=>R4(t.children,By),[t.children]),n=Gt(r=>OEe(r,t.id,e));return n==null?null:w.createElement(i2e,{legendPayload:n})}var A2e=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:dh(l,e),hide:c,type:u,color:o,unit:"",graphicalItemId:d}};return w.createElement(iE,{tooltipEntrySettings:f})}),T2e=(t,e)=>t>e?"start":t<e?"end":"middle",C2e=(t,e,n)=>Ba(typeof e=="function"?e(t):e,n,n*.8),k2e=(t,e,n)=>{var{top:r,left:i,width:a,height:o}=e,l=wY(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=C2e(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}},j2e=(t,e)=>{var n=ea(e-t),r=Math.min(Math.abs(e-t),360);return n*r},P2e=(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=sE(e,b2e);return w.createElement(ng,Jd({},i,{type:"linear",className:n}))},R2e=(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",qZ(t));return w.createElement(eE,Jd({},e,{alignmentBaseline:"middle",className:i}),r)};function D2e(t){var{sectors:e,props:n,showLabels:r}=t,{label:i,labelLine:a,dataKey:o}=n;if(!r||!i||!e)return null;var l=ns(n),c=Hf(i),u=Hf(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,y=Ni(m.cx,m.cy,m.outerRadius+d,b),x=ri(ri(ri(ri({},l),m),{},{stroke:"none"},c),{},{index:p,textAnchor:T2e(y.x,m.cx)},y),v=ri(ri(ri(ri({},l),m),{},{fill:"none",stroke:m.fill},u),{},{index:p,points:[Ni(m.cx,m.cy,m.outerRadius,b),y],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&&P2e(a,v),R2e(i,x,ir(m,o))))});return w.createElement(qr,{className:"recharts-pie-labels"},f)}function O2e(t){var{sectors:e,props:n,showLabels:r}=t,{label:i}=n;return typeof i=="object"&&i!=null&&"position"in i?w.createElement(tE,{label:i}):w.createElement(D2e,{sectors:e,props:n,showLabels:r})}function L2e(t){var{sectors:e,activeShape:n,inactiveShape:r,allOtherPieProps:i,shape:a,id:o}=t,l=Gt(Zd),c=Gt(M4),u=Gt(KSe),{onMouseEnter:d,onClick:f,onMouseLeave:m}=i,p=sE(i,y2e),b=L4(d,i.dataKey,o),y=I4(m),x=F4(f,i.dataKey,o);return e==null||e.length===0?null:w.createElement(w.Fragment,null,e.map((v,S)=>{if(v?.startAngle===0&&v?.endAngle===0&&e.length!==1)return null;var M=u==null||u===o,E=String(S)===l&&(c==null||i.dataKey===c)&&M,A=l?r:null,k=n&&E?n:A,T=ri(ri({},v),{},{stroke:v.stroke,tabIndex:-1,[JX]:S,[eY]:o});return w.createElement(qr,Jd({key:"sector-".concat(v?.startAngle,"-").concat(v?.endAngle,"-").concat(v.midAngle,"-").concat(S),tabIndex:-1,className:"recharts-pie-sector"},_y(p,v,S),{onMouseEnter:b(v,S),onMouseLeave:y(v,S),onClick:x(v,S)}),w.createElement(O4,Jd({option:a??k,index:S,shapeType:"sector",isActive:E},T)))}))}function I2e(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=j2e(l,c),b=Math.abs(p),y=r.length<=1?0:(e=n.paddingAngle)!==null&&e!==void 0?e:0,x=r.filter(k=>ir(k,u,0)!==0).length,v=(b>=360?x:x-1)*y,S=b-x*m-v,M=r.reduce((k,T)=>{var D=ir(T,u,0);return k+(zt(D)?D:0)},0),E;if(M>0){var A;E=r.map((k,T)=>{var D=ir(k,u,0),C=ir(k,d,T),R=k2e(n,a,k),U=(zt(D)?D:0)/M,O,q=ri(ri({},k),i&&i[T]&&i[T].props);T?O=A.endAngle+ea(p)*y*(D!==0?1:0):O=l;var j=O+ea(p)*((D!==0?m:0)+U*S),W=(O+j)/2,X=(R.innerRadius+R.outerRadius)/2,G=[{name:C,value:D,payload:q,dataKey:u,type:f,graphicalItemId:n.id}],Z=Ni(R.cx,R.cy,X,W);return A=ri(ri(ri(ri({},n.presentationProps),{},{percent:U,cornerRadius:typeof o=="string"?parseFloat(o):o,name:C,tooltipPayload:G,midAngle:W,middleRadius:X,tooltipPosition:Z},q),R),{},{value:D,dataKey:u,startAngle:O,endAngle:j,payload:q,paddingAngle:ea(p)*y}),A})}return E}function F2e(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(bEe,{value:e?i:void 0},r)}function U2e(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=Jg(e,"recharts-pie-"),b=n.current,[y,x]=w.useState(!1),v=w.useCallback(()=>{typeof m=="function"&&m(),x(!1)},[m]),S=w.useCallback(()=>{typeof f=="function"&&f(),x(!0)},[f]);return w.createElement(F2e,{showLabels:!y,sectors:i},w.createElement(Zg,{animationId:p,begin:o,duration:l,isActive:a,easing:c,onAnimationStart:S,onAnimationEnd:v,key:p},M=>{var E,A=[],k=i&&i[0],T=(E=k?.startAngle)!==null&&E!==void 0?E:0;return i?.forEach((D,C)=>{var R=b&&b[C],U=C>0?Gf(D,"paddingAngle",0):0;if(R){var O=nr(R.endAngle-R.startAngle,D.endAngle-D.startAngle,M),q=ri(ri({},D),{},{startAngle:T+U,endAngle:T+O+U});A.push(q),T=q.endAngle}else{var{endAngle:j,startAngle:W}=D,X=nr(0,j-W,M),G=ri(ri({},D),{},{startAngle:T+U,endAngle:T+X+U});A.push(G),T=G.endAngle}}),n.current=A,w.createElement(qr,null,w.createElement(L2e,{sectors:A,activeShape:u,inactiveShape:d,allOtherPieProps:e,shape:e.shape,id:r}))}),w.createElement(O2e,{showLabels:!y,sectors:i,props:e}),e.children)}var z2e={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 B2e(t){var{id:e}=t,n=sE(t,v2e),{hide:r,className:i,rootTabIndex:a}=t,o=w.useMemo(()=>R4(t.children,By),[t.children]),l=Gt(d=>LEe(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(A2e,{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(U2e,{props:ri(ri({},n),{},{sectors:l}),previousSectorsRef:c,id:e})))}function QZ(t){var e=Kr(t,z2e),{id:n}=e,r=sE(e,_2e),i=ns(r);return w.createElement(aE,{id:n,type:"pie"},a=>w.createElement(w.Fragment,null,w.createElement(x2e,{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,Jd({},r,{id:a})),w.createElement(B2e,Jd({},r,{id:a}))))}QZ.displayName="Pie";var $2e=["points"];function NH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function LC(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?NH(Object(n),!0).forEach(function(r){H2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):NH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function H2e(t,e,n){return(e=V2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function V2e(t){var e=G2e(t,"string");return typeof e=="symbol"?e:e+""}function G2e(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)}function W2e(t,e){if(t==null)return{};var n,r,i=q2e(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 q2e(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 K2e(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=W2e(a,$2e);return w.createElement(HZ,CS({},l,{className:i}))}function X2e(t,e){return t==null?!1:e?!0:t.length===1}function ZZ(t){var{points:e,dot:n,className:r,dotClassName:i,dataKey:a,baseProps:o,needClip:l,clipPathId:c,zIndex:u=oi.scatter}=t;if(!X2e(e,n))return null;var d=D4(n),f=xpe(n),m=e.map((b,y)=>{var x,v,S=LC(LC(LC({r:3},o),f),{},{index:y,cx:(x=b.x)!==null&&x!==void 0?x:void 0,cy:(v=b.y)!==null&&v!==void 0?v:void 0,dataKey:a,value:b.value,payload:b.payload,points:e});return w.createElement(K2e,{key:"dot-".concat(y),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,CS({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 AH(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){Y2e(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 Y2e(t,e,n){return(e=Q2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Q2e(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 JZ=0,J2e={xAxis:{},yAxis:{},zAxis:{}},eJ=Es({name:"cartesianAxis",initialState:J2e,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]=AH(AH({},i),{},{width:r,widthHistory:l})}}}}),{addXAxis:eAe,replaceXAxis:tAe,removeXAxis:nAe,addYAxis:rAe,replaceYAxis:iAe,removeYAxis:aAe,addZAxis:rZe,replaceZAxis:iZe,removeZAxis:aZe,updateYAxisWidth:sAe}=eJ.actions,oAe=eJ.reducer,lAe=tt([zi],t=>({top:t.top,bottom:t.bottom,left:t.left,right:t.right})),cAe=tt([lAe,Mu,Nu],(t,e,n)=>{if(!(!t||e==null||n==null))return{x:t.left,y:t.top,width:Math.max(0,e-t.left-t.right),height:Math.max(0,n-t.top-t.bottom)}}),oE=()=>Gt(cAe),uAe=()=>Gt(JSe);function TH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function IC(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?TH(Object(n),!0).forEach(function(r){dAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):TH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function dAe(t,e,n){return(e=hAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function hAe(t){var e=fAe(t,"string");return typeof e=="symbol"?e:e+""}function fAe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var mAe=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=IC(IC(IC({},l),Hf(i)),tO(i)),u;return w.isValidElement(i)?u=w.cloneElement(i,c):typeof i=="function"?u=i(c):u=w.createElement(HZ,c),w.createElement(qr,{className:"recharts-active-dot",clipPath:o},u)};function g3(t){var{points:e,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:o=oi.activeDot}=t,l=Gt(Zd),c=uAe();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(mAe,{point:u,childIndex:Number(l),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var CH=(t,e,n)=>{var r=n??t;if(!Hr(r))return Ba(r,e,0)},pAe=(t,e,n)=>{var r={},i=t.filter(WN),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(y=>y.dataKey),b=CH(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=CH(e,n,u.barSize);return{stackId:void 0,dataKeys:d,barSize:f}});return[...l,...c]};function kH(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 k_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?kH(Object(n),!0).forEach(function(r){gAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):kH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function gAe(t,e,n){return(e=xAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function xAe(t){var e=bAe(t,"string");return typeof e=="symbol"?e:e+""}function bAe(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 yAe(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 E,A={stackId:M.stackId,dataKeys:M.dataKeys,position:{offset:b.offset+b.size+l,size:d?f:(E=M.barSize)!==null&&E!==void 0?E:0}},k=[...S,A];return b=A.position,k},u)}else{var y=Ba(e,n,0,!0);n-2*y-(o-1)*l<=0&&(l=0);var x=(n-2*y-(o-1)*l)/o;x>1&&(x>>=0);var v=pn(i)?Math.min(x,i):x;c=r.reduce((S,M,E)=>[...S,{stackId:M.stackId,dataKeys:M.dataKeys,position:{offset:y+(x+l)*E+(x-v)/2,size:v}}],u)}return c}}var vAe=(t,e,n,r,i,a,o)=>{var l=Hr(o)?e:o,c=yAe(n,r,i!==a?i:a,t,l);return i!==a&&c!=null&&(c=c.map(u=>k_(k_({},u),{},{position:k_(k_({},u.position),{},{offset:u.position.offset-i/2})}))),c},_Ae=(t,e)=>{var n=GN(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)}}}},wAe=(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 SAe(t,e){return t&&typeof t=="object"&&"zIndex"in t&&typeof t.zIndex=="number"&&pn(t.zIndex)?t.zIndex:e}var tJ=t=>{var{chartData:e}=t,n=Mr(),r=Bi();return w.useEffect(()=>r?()=>{}:(n(L$(e)),()=>{n(L$(void 0))}),[e,n,r]),null},jH={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},nJ=Es({name:"brush",initialState:jH,reducers:{setBrushSettings(t,e){return e.payload==null?jH:e.payload}}}),{setBrushSettings:sZe}=nJ.actions,MAe=nJ.reducer,NAe=(t,e)=>{var{x:n,y:r}=t,{x:i,y:a}=e;return{x:Math.min(n,i),y:Math.min(r,a),width:Math.abs(i-n),height:Math.abs(a-r)}},EAe=t=>{var{x1:e,y1:n,x2:r,y2:i}=t;return NAe({x:e,y:n},{x:r,y:i})};function AAe(t){return(t%180+180)%180}var TAe=function(e){var{width:n,height:r}=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,a=AAe(i),o=a*Math.PI/180,l=Math.atan(r/n),c=o>l&&o<Math.PI-l?r/Math.sin(o):n/Math.cos(o);return Math.abs(c)},CAe={dots:[],areas:[],lines:[]},rJ=Es({name:"referenceElements",initialState:CAe,reducers:{addDot:(t,e)=>{t.dots.push(e.payload)},removeDot:(t,e)=>{var n=al(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=al(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=al(t).lines.findIndex(r=>r===e.payload);n!==-1&&t.lines.splice(n,1)}}}),{addDot:oZe,removeDot:lZe,addArea:cZe,removeArea:uZe,addLine:kAe,removeLine:jAe}=rJ.actions,PAe=rJ.reducer,iJ=w.createContext(void 0),RAe=t=>{var{children:e}=t,[n]=w.useState("".concat(j0("recharts"),"-clip")),r=oE();if(r==null)return null;var{x:i,y:a,width:o,height:l}=r;return w.createElement(iJ.Provider,{value:n},w.createElement("defs",null,w.createElement("clipPath",{id:n},w.createElement("rect",{x:i,y:a,height:l,width:o}))),e)},DAe=()=>w.useContext(iJ);class OAe{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 PH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function RH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?PH(Object(n),!0).forEach(function(r){LAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):PH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function LAe(t,e,n){return(e=IAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function IAe(t){var e=FAe(t,"string");return typeof e=="symbol"?e:e+""}function FAe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function kS(){return kS=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},kS.apply(null,arguments)}var UAe=(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",kS({},e,{className:"recharts-reference-line-line"}))}return n},zAe=(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},BAe=(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},$Ae=(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},HAe=(t,e,n,r,i,a,o)=>{var{x:l,y:c,segment:u,ifOverflow:d}=o,f=Lo(l),m=Lo(c);return m?zAe(c,d,r,a,e,n):f?BAe(l,d,r,i,t,n):u!=null&&u.length===2?$Ae(u,d,r,new OAe({x:t,y:e})):null};function VAe(t){var e=Mr();return w.useEffect(()=>(e(kAe(t)),()=>{e(jAe(t))})),null}function GAe(t){var{xAxisId:e,yAxisId:n,shape:r,className:i,ifOverflow:a}=t,o=Bi(),l=DAe(),c=Gt(T=>cc(T,e)),u=Gt(T=>uc(T,n)),d=Gt(T=>Eg(T,"xAxis",e,o)),f=Gt(T=>Eg(T,"yAxis",n,o)),m=Ny();if(!l||!m||c==null||u==null||d==null||f==null)return null;var p=HAe(d,f,m,t.position,c.orientation,u.orientation,t);if(!p)return null;var b=p[0],y=p[1];if(b==null||y==null)return null;var{x,y:v}=b,{x:S,y:M}=y,E=a==="hidden"?"url(#".concat(l,")"):void 0,A=RH(RH({clipPath:E},Aa(t)),{},{x1:x,y1:v,x2:S,y2:M}),k=EAe({x1:x,y1:v,x2:S,y2:M});return w.createElement($a,{zIndex:t.zIndex},w.createElement(qr,{className:Bn("recharts-reference-line",i)},UAe(r,A),w.createElement(FZ,kS({},k,{lowerWidth:k.width,upperWidth:k.width}),w.createElement(zZ,{label:t.label}),t.children)))}var WAe={ifOverflow:"discard",xAxisId:0,yAxisId:0,fill:"none",label:!1,stroke:"#ccc",fillOpacity:1,strokeWidth:1,position:"middle",zIndex:oi.line};function Bb(t){var e=Kr(t,WAe);return w.createElement(w.Fragment,null,w.createElement(VAe,{yAxisId:e.yAxisId,xAxisId:e.xAxisId,ifOverflow:e.ifOverflow,x:e.x,y:e.y,segment:e.segment}),w.createElement(GAe,e))}Bb.displayName="ReferenceLine";function aJ(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 qAe(t,e,n){var r={width:t.width+e.width,height:t.height+e.height};return TAe(r,n)}function KAe(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 G0(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 XAe(t,e){return aJ(t,e+1)}function YAe(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:aJ(r,u)};var y=c,x,v=()=>(x===void 0&&(x=n(b,y)),x),S=b.coordinate,M=c===0||G0(t,S,v,d,l);M||(c=0,d=o,u+=1),M&&(d=S+t*(v()/2+i),c+=u)},m;u<=a.length;)if(m=f(),m)return m.v;return[]}function QAe(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 E=r[y];if(E==null)return 0;var A=y,k,T=()=>(k===void 0&&(k=n(E,A)),k),D=E.coordinate,C=y===d||G0(t,D,T,f,c);if(!C)return m=!1,1;C&&(f=D+t*(T()/2+i))},b,y=d;y<o&&(b=p(),!(b!==0&&b===1));y+=u);if(m){for(var x=[],v=d;v<o;v+=u){var S=r[v];S!=null&&x.push(S)}return x}}return[]}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 Oa(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){ZAe(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 ZAe(t,e,n){return(e=JAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function JAe(t){var e=eTe(t,"string");return typeof e=="symbol"?e:e+""}function eTe(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 tTe(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,y,x=()=>(y===void 0&&(y=n(p,m)),y);if(m===o-1){var v=t*(b.coordinate+t*x()/2-c);a[m]=b=Oa(Oa({},b),{},{tickCoord:v>0?b.coordinate-v*t:b.coordinate})}else a[m]=b=Oa(Oa({},b),{},{tickCoord:b.coordinate});if(b.tickCoord!=null){var S=G0(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 nTe(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=G0(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,y=function(S){var M=o[S];if(M==null)return 1;var E=M,A,k=()=>(A===void 0&&(A=n(M,S)),A);if(S===0){var T=t*(E.coordinate-t*k()/2-c);o[S]=E=Oa(Oa({},E),{},{tickCoord:T<0?E.coordinate-T*t:E.coordinate})}else o[S]=E=Oa(Oa({},E),{},{tickCoord:E.coordinate});if(E.tickCoord!=null){var D=G0(t,E.tickCoord,k,c,u);D&&(c=E.tickCoord+t*(k()/2+i),o[S]=Oa(Oa({},E),{},{isShow:!0}))}},x=0;x<b;x++)y(x);return o}function B4(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)||Ty.isSsr){var m;return(m=XAe(i,zt(c)?c:0))!==null&&m!==void 0?m:[]}var p=[],b=l==="top"||l==="bottom"?"width":"height",y=d&&b==="width"?r0(d,{fontSize:e,letterSpacing:n}):{width:0,height:0},x=(A,k)=>{var T=typeof u=="function"?u(A.value,k):A.value;return b==="width"?qAe(r0(T,{fontSize:e,letterSpacing:n}),y,f):r0(T,{fontSize:e,letterSpacing:n})[b]},v=i[0],S=i[1],M=i.length>=2&&v!=null&&S!=null?ea(S.coordinate-v.coordinate):1,E=KAe(a,M,b);return c==="equidistantPreserveStart"?YAe(M,E,x,i,o):c==="equidistantPreserveEnd"?QAe(M,E,x,i,o):(c==="preserveStart"||c==="preserveStartEnd"?p=nTe(M,E,x,i,o,c==="preserveStartEnd"):p=tTe(M,E,x,i,o),p.filter(A=>A.isShow))}var rTe=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},iTe=["axisLine","width","height","className","hide","ticks","axisType"];function aTe(t,e){if(t==null)return{};var n,r,i=sTe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function sTe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function Qf(){return Qf=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},Qf.apply(null,arguments)}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 ti(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){oTe(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 oTe(t,e,n){return(e=lTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function lTe(t){var e=cTe(t,"string");return typeof e=="symbol"?e:e+""}function cTe(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 au={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 uTe(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),ns(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",Qf({},u,{className:Bn("recharts-cartesian-axis-line",Gf(l,"className"))}))}function dTe(t,e,n,r,i,a,o,l,c){var u,d,f,m,p,b,y=l?-1:1,x=t.tickSize||o,v=zt(t.tickCoord)?t.tickCoord:t.coordinate;switch(a){case"top":u=d=t.coordinate,m=n+ +!l*i,f=m-y*x,b=f-y*c,p=v;break;case"left":f=m=t.coordinate,d=e+ +!l*r,u=d-y*x,p=u-y*c,b=v;break;case"right":f=m=t.coordinate,d=e+ +l*r,u=d+y*x,p=u+y*c,b=v;break;default:u=d=t.coordinate,m=n+ +l*i,f=m+y*x,b=f+y*c,p=v;break}return{line:{x1:u,y1:f,x2:d,y2:m},tick:{x:p,y:b}}}function hTe(t,e){switch(t){case"left":return e?"start":"end";case"right":return e?"end":"start";default:return"middle"}}function fTe(t,e){switch(t){case"left":case"right":return"middle";case"top":return e?"start":"end";default:return e?"end":"start"}}function mTe(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,qZ(e))),i=w.createElement(eE,Qf({},n,{className:o}),r)}return i}var pTe=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:y,tickSize:x,tickMargin:v,fontSize:S,letterSpacing:M,getTicksConfig:E,events:A,axisType:k}=t,T=B4(ti(ti({},E),{},{ticks:n}),S,M),D=hTe(d,f),C=fTe(d,f),R=ns(E),U=Hf(r),O={};typeof i=="object"&&(O=i);var q=ti(ti({},R),{},{fill:"none"},O),j=T.map(G=>ti({entry:G},dTe(G,m,p,b,y,d,x,f,v))),W=j.map(G=>{var{entry:Z,line:te}=G;return w.createElement(qr,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(Z.value,"-").concat(Z.coordinate,"-").concat(Z.tickCoord)},i&&w.createElement("line",Qf({},q,te,{className:Bn("recharts-cartesian-axis-tick-line",Gf(i,"className"))})))}),X=j.map((G,Z)=>{var te,ee,{entry:z,tick:V}=G,ne=ti(ti(ti(ti({verticalAnchor:C},R),{},{textAnchor:D,stroke:"none",fill:a},V),{},{index:Z,payload:z,visibleTicksCount:T.length,tickFormatter:o,padding:c},u),{},{angle:(te=(ee=u?.angle)!==null&&ee!==void 0?ee:R.angle)!==null&&te!==void 0?te:0}),ie=ti(ti({},ne),U);return w.createElement(qr,Qf({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(z.value,"-").concat(z.coordinate,"-").concat(z.tickCoord)},_y(A,z,Z)),r&&w.createElement(mTe,{option:r,tickProps:ie,value:"".concat(typeof o=="function"?o(z.value,Z):z.value).concat(l||"")}))});return w.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(k,"-ticks")},X.length>0&&w.createElement($a,{zIndex:oi.label},w.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(k,"-tick-labels"),ref:e},X)),W.length>0&&w.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(k,"-tick-lines")},W))}),gTe=w.forwardRef((t,e)=>{var{axisLine:n,width:r,height:i,className:a,hide:o,ticks:l,axisType:c}=t,u=aTe(t,iTe),[d,f]=w.useState(""),[m,p]=w.useState(""),b=w.useRef(null);w.useImperativeHandle(e,()=>({getCalculatedWidth:()=>{var x;return rTe({ticks:b.current,label:(x=t.labelRef)===null||x===void 0?void 0:x.current,labelGapWithTick:5,tickSize:t.tickSize,tickMargin:t.tickMargin})}}));var y=w.useCallback(x=>{if(x){var v=x.getElementsByClassName("recharts-cartesian-axis-tick-value");b.current=v;var S=v[0];if(S){var M=window.getComputedStyle(S),E=M.fontSize,A=M.letterSpacing;(E!==d||A!==m)&&(f(E),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(uTe,{x:t.x,y:t.y,width:r,height:i,orientation:t.orientation,mirror:t.mirror,axisLine:n,otherSvgProps:ns(t)}),w.createElement(pTe,{ref:y,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(FZ,{x:t.x,y:t.y,width:t.width,height:t.height,lowerWidth:t.width,upperWidth:t.width},w.createElement(zZ,{label:t.label,labelRef:t.labelRef}),t.children)))}),$4=w.forwardRef((t,e)=>{var n=Kr(t,au);return w.createElement(gTe,Qf({},n,{ref:e}))});$4.displayName="CartesianAxis";var xTe=["x1","y1","x2","y2","key"],bTe=["offset"],yTe=["xAxisId","yAxisId"],vTe=["xAxisId","yAxisId"];function LH(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?LH(Object(n),!0).forEach(function(r){_Te(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):LH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function _Te(t,e,n){return(e=wTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function wTe(t){var e=STe(t,"string");return typeof e=="symbol"?e:e+""}function STe(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 mf(){return mf=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},mf.apply(null,arguments)}function jS(t,e){if(t==null)return{};var n,r,i=MTe(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 MTe(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 NTe=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 sJ(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=jS(n,xTe),f=(i=ns(d))!==null&&i!==void 0?i:{},{offset:m}=f,p=jS(f,bTe);r=w.createElement("line",mf({},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=jS(t,yTe),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(sJ,{key:"line-".concat(d),option:r,lineItemProps:f})});return w.createElement("g",{className:"recharts-cartesian-grid-horizontal"},c)}function ATe(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=jS(t,vTe),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(sJ,{option:r,lineItemProps:f,key:"line-".concat(d)})});return w.createElement("g",{className:"recharts-cartesian-grid-vertical"},c)}function TTe(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,y=b?i+o-f:p-f;if(y<=0)return null;var x=m%e.length;return w.createElement("rect",{key:"react-".concat(m),y:f,x:r,height:y,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 CTe(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,y=b?i+o-f:p-f;if(y<=0)return null;var x=m%n.length;return w.createElement("rect",{key:"react-".concat(m),x:f,y:a,width:y,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 kTe=(t,e)=>{var{xAxis:n,width:r,height:i,offset:a}=t;return XX(B4(Fa(Fa(Fa({},au),n),{},{ticks:YX(n),viewBox:{x:0,y:0,width:r,height:i}})),a.left,a.left+a.width,e)},jTe=(t,e)=>{var{yAxis:n,width:r,height:i,offset:a}=t;return XX(B4(Fa(Fa(Fa({},au),n),{},{ticks:YX(n),viewBox:{x:0,y:0,width:r,height:i}})),a.top,a.top+a.height,e)},PTe={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:oi.grid};function PS(t){var e=mO(),n=pO(),r=iY(),i=Fa(Fa({},Kr(t,PTe)),{},{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(),y=Gt(C=>M$(C,"xAxis",a,b)),x=Gt(C=>M$(C,"yAxis",o,b));if(!Jl(u)||!Jl(d)||!zt(l)||!zt(c))return null;var v=i.verticalCoordinatesGenerator||kTe,S=i.horizontalCoordinatesGenerator||jTe,{horizontalPoints:M,verticalPoints:E}=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);tS(Array.isArray(k),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof k,"]")),Array.isArray(k)&&(M=k)}if((!E||!E.length)&&typeof v=="function"){var T=p&&p.length,D=v({xAxis:y?Fa(Fa({},y),{},{ticks:T?p:y.ticks}):void 0,width:e??u,height:n??d,offset:r},T?!0:f);tS(Array.isArray(D),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof D,"]")),Array.isArray(D)&&(E=D)}return w.createElement($a,{zIndex:i.zIndex},w.createElement("g",{className:"recharts-cartesian-grid"},w.createElement(NTe,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),w.createElement(TTe,mf({},i,{horizontalPoints:M})),w.createElement(CTe,mf({},i,{verticalPoints:E})),w.createElement(ETe,mf({},i,{offset:r,horizontalPoints:M,xAxis:y,yAxis:x})),w.createElement(ATe,mf({},i,{offset:r,verticalPoints:E,xAxis:y,yAxis:x}))))}PS.displayName="CartesianGrid";var RTe={},oJ=Es({name:"errorBars",initialState:RTe,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:dZe,replaceErrorBar:hZe,removeErrorBar:fZe}=oJ.actions,DTe=oJ.reducer,OTe=["children"];function LTe(t,e){if(t==null)return{};var n,r,i=ITe(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 ITe(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 FTe={data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0},UTe=w.createContext(FTe);function lJ(t){var{children:e}=t,n=LTe(t,OTe);return w.createElement(UTe.Provider,{value:n},e)}function lE(t,e){var n,r,i=Gt(u=>cc(u,t)),a=Gt(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 H4(t){var{xAxisId:e,yAxisId:n,clipPathId:r}=t,i=oE(),{needClipX:a,needClipY:o,needClip:l}=lE(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 cJ=(t,e,n,r)=>nc(t,"xAxis",e,r),uJ=(t,e,n,r)=>tc(t,"xAxis",e,r),dJ=(t,e,n,r)=>nc(t,"yAxis",n,r),hJ=(t,e,n,r)=>tc(t,"yAxis",n,r),zTe=tt([Fn,cJ,dJ,uJ,hJ],(t,e,n,r,i)=>xl(t,"xAxis")?Qd(e,r,!1):Qd(n,i,!1)),BTe=(t,e,n,r,i)=>i;function $Te(t){return t.type==="line"}var HTe=tt([Oy,BTe],(t,e)=>t.filter($Te).find(n=>n.id===e)),VTe=tt([Fn,cJ,dJ,uJ,hJ,HTe,zTe,HO],(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 kCe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:f,bandSize:o,displayedData:p})}});function fJ(t){var e=Hf(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 FC={exports:{}},UC={};var IH;function GTe(){if(IH)return UC;IH=1;var t=Gg();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 UC.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(!v){if(v=!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 T=f(A);return m!==void 0&&m(k,T)?(S=A,k):(S=A,M=T)}var v=!1,S,M,E=d===void 0?null:d;return[function(){return x(u())},E===null?void 0:function(){return x(E())}]},[u,d,f,m]);var y=r(c,p[0],p[1]);return a(function(){b.hasValue=!0,b.value=y},[y]),l(y),y},UC}var FH;function WTe(){return FH||(FH=1,FC.exports=GTe()),FC.exports}WTe();function qTe(t){t()}function KTe(){let t=null,e=null;return{clear(){t=null,e=null},notify(){qTe(()=>{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 UH={notify(){},get:()=>[]};function XTe(t,e){let n,r=UH,i=0,a=!1;function o(y){d();const x=r.subscribe(y);let v=!1;return()=>{v||(v=!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=KTe())}function f(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=UH)}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 YTe=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",QTe=YTe(),ZTe=()=>typeof navigator<"u"&&navigator.product==="ReactNative",JTe=ZTe(),eCe=()=>QTe||JTe?w.useLayoutEffect:w.useEffect,tCe=eCe();function zH(t,e){return t===e?t!==0||e!==0||1/t===1/e:t!==t&&e!==e}function nCe(t,e){if(zH(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])||!zH(t[n[i]],e[n[i]]))return!1;return!0}var rCe=Symbol.for("react-redux-context"),iCe=typeof globalThis<"u"?globalThis:{};function aCe(){if(!w.createContext)return{};const t=iCe[rCe]??=new Map;let e=t.get(w.createContext);return e||(e=w.createContext(null),t.set(w.createContext,e)),e}var sCe=aCe();function oCe(t){const{children:e,context:n,serverState:r,store:i}=t,a=w.useMemo(()=>{const c=XTe(i);return{store:i,subscription:c,getServerState:r?()=>r:void 0}},[i,r]),o=w.useMemo(()=>i.getState(),[i]);tCe(()=>{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||sCe;return w.createElement(l.Provider,{value:a},e)}var lCe=oCe,cCe=new Set(["axisLine","tickLine","activeBar","activeDot","activeLabel","activeShape","allowEscapeViewBox","background","cursor","dot","label","line","margin","padding","position","shape","style","tick","wrapperStyle","radius"]);function uCe(t,e){return t==null&&e==null?!0:typeof t=="number"&&typeof e=="number"?t===e||t!==t&&e!==e:t===e}function $y(t,e){var n=new Set([...Object.keys(t),...Object.keys(e)]);for(var r of n)if(cCe.has(r)){if(t[r]==null&&e[r]==null)continue;if(!nCe(t[r],e[r]))return!1}else if(!uCe(t[r],e[r]))return!1;return!0}var dCe=["id"],hCe=["type","layout","connectNulls","needClip","shape"],fCe=["activeDot","animateNewValues","animationBegin","animationDuration","animationEasing","connectNulls","dot","hide","isAnimationActive","label","legendType","xAxisId","yAxisId","id"];function W0(){return W0=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},W0.apply(null,arguments)}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 Ol(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){mCe(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 mCe(t,e,n){return(e=pCe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function pCe(t){var e=gCe(t,"string");return typeof e=="symbol"?e:e+""}function gCe(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 V4(t,e){if(t==null)return{};var n,r,i=xCe(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 xCe(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 bCe=t=>{var{dataKey:e,name:n,stroke:r,legendType:i,hide:a}=t;return[{inactive:a,dataKey:e,type:i,color:r,value:dh(n,e),payload:t}]},yCe=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:uh,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:e,nameKey:void 0,name:dh(o,e),hide:l,type:u,color:r,unit:c,graphicalItemId:d}};return w.createElement(iE,{tooltipEntrySettings:f})}),mJ=(t,e)=>"".concat(e,"px ").concat(t-e,"px");function vCe(t,e){for(var n=t.length%2!==0?[...t,0]:t,r=[],i=0;i<e;++i)r=[...r,...n];return r}var _Ce=(t,e,n)=>{var r=n.reduce((p,b)=>p+b);if(!r)return mJ(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[...vCe(n,i),...l,...m].map(p=>"".concat(p,"px")).join(", ")};function wCe(t){var{clipPathId:e,points:n,props:r}=t,{dot:i,dataKey:a,needClip:o}=r,{id:l}=r,c=V4(r,dCe),u=ns(c);return w.createElement(ZZ,{points:n,dot:i,className:"recharts-line-dots",dotClassName:"recharts-line-dot",dataKey:a,baseProps:u,needClip:o,clipPathId:e})}function SCe(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(k4,{value:e?i:void 0},n)}function $H(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=V4(a,hCe),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(O4,W0({shapeType:"curve",option:d},m,{pathRef:n})),w.createElement(wCe,{points:r,clipPathId:e,props:a}))}function MCe(t){try{return t&&t.getTotalLength&&t.getTotalLength()||0}catch{return 0}}function NCe(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:y,onAnimationStart:x}=n,v=i.current,S=Jg(o,"recharts-line-"),M=w.useRef(S),[E,A]=w.useState(!1),k=!E,T=w.useCallback(()=>{typeof y=="function"&&y(),A(!1)},[y]),D=w.useCallback(()=>{typeof x=="function"&&x(),A(!0)},[x]),C=MCe(r.current),R=w.useRef(0);M.current!==S&&(R.current=a.current,M.current=S);var U=R.current;return w.createElement(SCe,{points:o,showLabels:k},n.children,w.createElement(Zg,{animationId:S,begin:u,duration:d,isActive:c,easing:f,onAnimationEnd:T,onAnimationStart:D,key:S},O=>{var q=nr(U,C+U,O),j=Math.min(q,C),W;if(c)if(l){var X="".concat(l).split(/[,\s]+/gim).map(te=>parseFloat(te));W=_Ce(j,C,X)}else W=mJ(C,j);else W=l==null?void 0:String(l);if(O>0&&C>0&&(i.current=o,a.current=Math.max(a.current,j)),v){var G=v.length/o.length,Z=O===1?o:o.map((te,ee)=>{var z=Math.floor(ee*G);if(v[z]){var V=v[z];return Ol(Ol({},te),{},{x:nr(V.x,te.x,O),y:nr(V.y,te.y,O)})}return m?Ol(Ol({},te),{},{x:nr(p*2,te.x,O),y:nr(b/2,te.y,O)}):Ol(Ol({},te),{},{x:te.x,y:te.y})});return i.current=Z,w.createElement($H,{props:n,points:Z,clipPathId:e,pathRef:r,strokeDasharray:W})}return w.createElement($H,{props:n,points:o,clipPathId:e,pathRef:r,strokeDasharray:W})}),w.createElement(tE,{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(NCe,{props:n,clipPathId:e,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:a})}var ACe=(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 TCe 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),y=f,{r:x,strokeWidth:v}=fJ(n),S=D4(n),M=x*2+v,E=m?"url(#clipPath-".concat(S?"":"dots-").concat(y,")"):void 0;return w.createElement($a,{zIndex:p},w.createElement(qr,{className:b},m&&w.createElement("defs",null,w.createElement(H4,{clipPathId:y,xAxisId:a,yAxisId:o}),!S&&w.createElement("clipPath",{id:"clipPath-dots-".concat(y)},w.createElement("rect",{x:c-M/2,y:l-M/2,width:u+M,height:d+M}))),w.createElement(lJ,{xAxisId:a,yAxisId:o,data:r,dataPointFormatter:ACe,errorBarOffset:0},w.createElement(ECe,{props:this.props,clipPathId:y}))),w.createElement(g3,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:E}))}}var pJ={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 CCe(t){var e=Kr(t,pJ),{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:y}=e,x=V4(e,fCe),{needClip:v}=lE(p,b),S=oE(),M=hh(),E=Bi(),A=Gt(R=>VTe(R,p,b,E,y));if(M!=="horizontal"&&M!=="vertical"||A==null||S==null)return null;var{height:k,width:T,x:D,y:C}=S;return w.createElement(TCe,W0({},x,{id:y,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:T,left:D,top:C,needClip:v}))}function kCe(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=eS({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),y=eS({axis:r,ticks:a,bandSize:l,entry:u,index:d});return b==null||y==null?null:{x:b,y,value:f,payload:u}}).filter(Boolean)}function jCe(t){var e=Kr(t,pJ),n=Bi();return w.createElement(aE,{id:e.id,type:"line"},r=>w.createElement(w.Fragment,null,w.createElement(U4,{legendPayload:bCe(e)}),w.createElement(yCe,{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(z4,{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(CCe,W0({},e,{id:r}))))}var gJ=w.memo(jCe,$y);gJ.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:JZ}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:JZ}var xJ=(t,e,n)=>nc(t,"xAxis",dc(t,e),n),bJ=(t,e,n)=>tc(t,"xAxis",dc(t,e),n),yJ=(t,e,n)=>nc(t,"yAxis",hc(t,e),n),vJ=(t,e,n)=>tc(t,"yAxis",hc(t,e),n),PCe=tt([Fn,xJ,yJ,bJ,vJ],(t,e,n,r,i)=>xl(t,"xAxis")?Qd(e,r,!1):Qd(n,i,!1)),RCe=(t,e)=>e,_J=tt([Oy,RCe],(t,e)=>t.filter(n=>n.type==="area").find(n=>n.id===e)),wJ=t=>{var e=Fn(t),n=xl(e,"xAxis");return n?"yAxis":"xAxis"},DCe=(t,e)=>{var n=wJ(t);return n==="yAxis"?hc(t,e):dc(t,e)},OCe=(t,e,n)=>SS(t,wJ(t),DCe(t,e),n),LCe=tt([_J,OCe],(t,e)=>{var n;if(!(t==null||e==null)){var{stackId:r}=t,i=GN(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]])}}}),ICe=tt([Fn,xJ,yJ,bJ,vJ,LCe,sQ,PCe,_J,K1e],(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 nke({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:f,areaSettings:c,stackedData:a,displayedData:b,chartBaseValue:u,bandSize:l})}}),FCe=["id"],UCe=["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 SJ(t,e){if(t==null)return{};var n,r,i=zCe(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 zCe(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 HH(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 Kp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?HH(Object(n),!0).forEach(function(r){BCe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):HH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function BCe(t,e,n){return(e=$Ce(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function $Ce(t){var e=HCe(t,"string");return typeof e=="symbol"?e:e+""}function HCe(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 RS(t,e){return t&&t!=="none"?t:e}var VCe=t=>{var{dataKey:e,name:n,stroke:r,fill:i,legendType:a,hide:o}=t;return[{inactive:o,dataKey:e,type:a,color:RS(r,i),value:dh(n,e),payload:t}]},GCe=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:uh,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:e,nameKey:void 0,name:dh(o,e),hide:l,type:u,color:RS(r,a),unit:c,graphicalItemId:d}};return w.createElement(iE,{tooltipEntrySettings:f})});function WCe(t){var{clipPathId:e,points:n,props:r}=t,{needClip:i,dot:a,dataKey:o}=r,l=ns(r);return w.createElement(ZZ,{points:n,dot:a,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:o,baseProps:l,needClip:i,clipPathId:e})}function qCe(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 Kp(Kp({},c),{},{value:a.value,payload:a.payload,parentViewBox:void 0,viewBox:c,fill:void 0})});return w.createElement(k4,{value:e?i:void 0},n)}function VH(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=SJ(a,FCe),p=ns(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(ng,Ef({},b,{id:f,points:e,connectNulls:u,type:l,baseLine:n,layout:o,stroke:"none",className:"recharts-area-area"})),c!=="none"&&w.createElement(ng,Ef({},p,{className:"recharts-area-curve",layout:o,type:l,connectNulls:u,fill:"none",points:e})),c!=="none"&&d&&w.createElement(ng,Ef({},p,{className:"recharts-area-curve",layout:o,type:l,connectNulls:u,fill:"none",points:n}))),w.createElement(WCe,{points:e,props:m,clipPathId:i}))}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.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 XCe(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 YCe(t){var{alpha:e,layout:n,points:r,baseLine:i,strokeWidth:a}=t;return n==="vertical"?w.createElement(KCe,{alpha:e,points:r,baseLine:i,strokeWidth:a}):w.createElement(XCe,{alpha:e,points:r,baseLine:i,strokeWidth:a})}function QCe(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]),y=Jg(b,"recharts-area-"),x=gO(),[v,S]=w.useState(!1),M=!v,E=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,T=a.current;return w.createElement(qCe,{showLabels:M,points:o},r.children,w.createElement(Zg,{animationId:y,begin:u,duration:d,isActive:c,easing:f,onAnimationEnd:E,onAnimationStart:A,key:y},D=>{if(k){var C=k.length/o.length,R=D===1?o:o.map((O,q)=>{var j=Math.floor(q*C);if(k[j]){var W=k[j];return Kp(Kp({},O),{},{x:nr(W.x,O.x,D),y:nr(W.y,O.y,D)})}return O}),U;return zt(l)?U=nr(T,l,D):Hr(l)||ul(l)?U=nr(T,0,D):U=l.map((O,q)=>{var j=Math.floor(q*C);if(Array.isArray(T)&&T[j]){var W=T[j];return Kp(Kp({},O),{},{x:nr(W.x,O.x,D),y:nr(W.y,O.y,D)})}return O}),D>0&&(i.current=R,a.current=U),w.createElement(VH,{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(YCe,{alpha:D,points:o,baseLine:l,layout:x,strokeWidth:r.strokeWidth}))),w.createElement(qr,{clipPath:"url(#animationClipPath-".concat(n,")")},w.createElement(VH,{points:o,baseLine:l,needClip:e,clipPathId:n,props:r})))}),w.createElement(tE,{label:r.label}))}function ZCe(t){var{needClip:e,clipPathId:n,props:r}=t,i=w.useRef(null),a=w.useRef();return w.createElement(QCe,{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}class JCe 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 y=Bn("recharts-area",i),x=m,{r:v,strokeWidth:S}=fJ(n),M=D4(n),E=v*2+S,A=l?"url(#clipPath-".concat(M?"":"dots-").concat(x,")"):void 0;return w.createElement($a,{zIndex:b},w.createElement(qr,{className:y},l&&w.createElement("defs",null,w.createElement(H4,{clipPathId:x,xAxisId:c,yAxisId:u}),!M&&w.createElement("clipPath",{id:"clipPath-dots-".concat(x)},w.createElement("rect",{x:o-E/2,y:a-E/2,width:d+E,height:f+E}))),w.createElement(ZCe,{needClip:l,clipPathId:x,props:this.props})),w.createElement(g3,{points:r,mainColor:RS(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:A}),this.props.isRange&&Array.isArray(p)&&w.createElement(g3,{points:p,mainColor:RS(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:A}))}}var MJ={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 eke(t){var e,n=Kr(t,MJ),{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:y,yAxisId:x}=n,v=SJ(n,UCe),S=hh(),M=_Z(),{needClip:E}=lE(y,x),A=Bi(),{points:k,isRange:T,baseLine:D}=(e=Gt(j=>ICe(j,t.id,A)))!==null&&e!==void 0?e:{},C=oE();if(S!=="horizontal"&&S!=="vertical"||C==null||M!=="AreaChart"&&M!=="ComposedChart")return null;var{height:R,width:U,x:O,y:q}=C;return!k||!k.length?null:w.createElement(JCe,Ef({},v,{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"?!Ty.isSsr:m,isRange:T,legendType:p,needClip:E,points:k,stroke:b,width:U,left:O,top:q,xAxisId:y,yAxisId:x}))}var tke=(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 nke(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,y=tke(a,o,n,l,c),x=a==="horizontal",v=!1,S=u.map((E,A)=>{var k,T,D,C;if(b)C=i[d+A];else{var R=ir(E,r);Array.isArray(R)?(C=R,v=!0):C=[y,R]}var U=(k=(T=C)===null||T===void 0?void 0:T[1])!==null&&k!==void 0?k:null,O=U==null||b&&!e&&ir(E,r)==null;if(x){var q;return{x:eS({axis:l,ticks:f,bandSize:p,entry:E,index:A}),y:O?null:(q=c.scale.map(U))!==null&&q!==void 0?q:null,value:C,payload:E}}return{x:O?null:(D=l.scale.map(U))!==null&&D!==void 0?D:null,y:eS({axis:c,ticks:m,bandSize:p,entry:E,index:A}),value:C,payload:E}}),M;return b||v?M=S.map(E=>{var A,k=Array.isArray(E.value)?E.value[0]:null;if(x){var T;return{x:E.x,y:k!=null&&E.y!=null&&(T=c.scale.map(k))!==null&&T!==void 0?T:null,payload:E.payload}}return{x:k!=null&&(A=l.scale.map(k))!==null&&A!==void 0?A:null,y:E.y,payload:E.payload}}):M=x?c.scale.map(y):l.scale.map(y),{points:S,baseLine:M??0,isRange:v}}function rke(t){var e=Kr(t,MJ),n=Bi();return w.createElement(aE,{id:e.id,type:"area"},r=>w.createElement(w.Fragment,null,w.createElement(U4,{legendPayload:VCe(e)}),w.createElement(GCe,{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(z4,{type:"area",id:r,data:e.data,dataKey:e.dataKey,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,stackId:QX(e.stackId),hide:e.hide,barSize:void 0,baseValue:e.baseValue,isPanorama:n,connectNulls:e.connectNulls}),w.createElement(eke,Ef({},e,{id:r}))))}var NJ=w.memo(rke,$y);NJ.displayName="Area";var ike="Invariant failed";function ake(t,e){throw new Error(ike)}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 DS(t){return w.createElement(O4,x3({shapeType:"rectangle",activeClassName:"recharts-active-bar"},t))}var ske=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||ake(),n)}},oke=(t,e,n)=>n,lke=(t,e)=>e,Hy=tt([Oy,lke],(t,e)=>t.filter(n=>n.type==="bar").find(n=>n.id===e)),cke=tt([Hy],t=>t?.maxBarSize),uke=(t,e,n,r)=>r,dke=tt([Fn,Oy,dc,hc,oke],(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")),hke=(t,e,n)=>{var r=Fn(t),i=dc(t,e),a=hc(t,e);if(!(i==null||a==null))return r==="horizontal"?SS(t,"yAxis",a,n):SS(t,"xAxis",i,n)},fke=(t,e)=>{var n=Fn(t),r=dc(t,e),i=hc(t,e);if(!(r==null||i==null))return n==="horizontal"?S$(t,"xAxis",r):S$(t,"yAxis",i)},mke=tt([dke,q1e,fke],pAe),pke=(t,e,n)=>{var r,i,a=Hy(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=bQ(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=Qd(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)),Qd(o,l)}},gke=tt([mke,bQ,W1e,yQ,pke,EJ,cke],vAe),xke=(t,e,n)=>{var r=dc(t,e);if(r!=null)return nc(t,"xAxis",r,n)},bke=(t,e,n)=>{var r=hc(t,e);if(r!=null)return nc(t,"yAxis",r,n)},yke=(t,e,n)=>{var r=dc(t,e);if(r!=null)return tc(t,"xAxis",r,n)},vke=(t,e,n)=>{var r=hc(t,e);if(r!=null)return tc(t,"yAxis",r,n)},_ke=tt([gke,Hy],wAe),wke=tt([hke,Hy],_Ae),Ske=tt([zi,dO,xke,bke,yke,vke,_ke,Fn,sQ,EJ,wke,Hy,uke],(t,e,n,r,i,a,o,l,c,u,d,f,m)=>{var{chartData:p,dataStartIndex:b,dataEndIndex:y}=c;if(!(f==null||o==null||e==null||l!=="horizontal"&&l!=="vertical"||n==null||r==null||i==null||a==null||u==null)){var{data:x}=f,v;if(x!=null&&x.length>0?v=x:v=p?.slice(b,y+1),v!=null)return Qke({layout:l,barSettings:f,pos:o,parentViewBox:e,bandSize:u,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,stackedData:d,displayedData:v,offset:t,cells:m,dataStartIndex:b})}}),Mke=["index"];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 Nke(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 AJ=w.createContext(void 0),Ake=t=>{var e=w.useContext(AJ);if(e!=null)return e.stackId;if(t!=null)return QX(t)},Tke=(t,e)=>"recharts-bar-stack-clip-path-".concat(t,"-").concat(e),Cke=t=>{var e=w.useContext(AJ);if(e!=null){var{stackId:n}=e;return"url(#".concat(Tke(n,t),")")}},TJ=t=>{var{index:e}=t,n=Nke(t,Mke),r=Cke(e);return w.createElement(qr,b3({className:"recharts-bar-stack-layer",clipPath:r},n))},kke=["onMouseEnter","onMouseLeave","onClick"],jke=["value","background","tooltipPosition"],Pke=["id"],Rke=["onMouseEnter","onClick","onMouseLeave"];function yu(){return yu=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},yu.apply(null,arguments)}function GH(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?GH(Object(n),!0).forEach(function(r){Dke(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):GH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Dke(t,e,n){return(e=Oke(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Oke(t){var e=Lke(t,"string");return typeof e=="symbol"?e:e+""}function Lke(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(t,e){if(t==null)return{};var n,r,i=Ike(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 Ike(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 Fke=t=>{var{dataKey:e,name:n,fill:r,legendType:i,hide:a}=t;return[{inactive:a,dataKey:e,type:i,color:r,value:dh(n,e),payload:t}]},Uke=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:uh,settings:{stroke:n,strokeWidth:r,fill:i,dataKey:e,nameKey:void 0,name:dh(a,e),hide:o,type:c,color:i,unit:l,graphicalItemId:u}};return w.createElement(iE,{tooltipEntrySettings:d})});function zke(t){var e=Gt(Zd),{data:n,dataKey:r,background:i,allOtherBarProps:a}=t,{onMouseEnter:o,onMouseLeave:l,onClick:c}=a,u=OS(a,kke),d=L4(o,r,a.id),f=I4(l),m=F4(c,r,a.id);if(!i||n==null)return null;var p=Hf(i);return w.createElement($a,{zIndex:SAe(i,oi.barBackground)},n.map((b,y)=>{var{value:x,background:v,tooltipPosition:S}=b,M=OS(b,jke);if(!v)return null;var E=d(b,y),A=f(b,y),k=m(b,y),T=Xa(Xa(Xa(Xa(Xa({option:i,isActive:String(y)===e},M),{},{fill:"#eee"},v),p),_y(u,b,y)),{},{onMouseEnter:E,onMouseLeave:A,onClick:k,dataKey:r,index:y,className:"recharts-bar-background-rectangle"});return w.createElement(DS,yu({key:"background-bar-".concat(y)},T))}))}function Bke(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(k4,{value:e?i:void 0},n)}function $ke(t){var{shape:e,activeBar:n,baseProps:r,entry:i,index:a,dataKey:o}=t,l=Gt(Zd),c=Gt(M4),u=n&&String(a)===l&&(c==null||o===c),d=u?n:e;return u?w.createElement($a,{zIndex:oi.activeBar},w.createElement(TJ,{index:a},w.createElement(DS,yu({},r,{name:String(r.name)},i,{isActive:u,option:d,index:a,dataKey:o})))):w.createElement(DS,yu({},r,{name:String(r.name)},i,{isActive:u,option:d,index:a,dataKey:o}))}function Hke(t){var{shape:e,baseProps:n,entry:r,index:i,dataKey:a}=t;return w.createElement(DS,yu({},n,{name:String(n.name)},r,{isActive:!1,option:e,index:i,dataKey:a}))}function Vke(t){var e,{data:n,props:r}=t,i=(e=ns(r))!==null&&e!==void 0?e:{},{id:a}=i,o=OS(i,Pke),{shape:l,dataKey:c,activeBar:u}=r,{onMouseEnter:d,onClick:f,onMouseLeave:m}=r,p=OS(r,Rke),b=L4(d,c,a),y=I4(m),x=F4(f,c,a);return n?w.createElement(w.Fragment,null,n.map((v,S)=>w.createElement(TJ,yu({index:S,key:"rectangle-".concat(v?.x,"-").concat(v?.y,"-").concat(v?.value,"-").concat(S),className:"recharts-bar-rectangle"},_y(p,v,S),{onMouseEnter:b(v,S),onMouseLeave:y(v,S),onClick:x(v,S)}),u?w.createElement($ke,{shape:l,activeBar:u,baseProps:o,entry:v,index:S,dataKey:c}):w.createElement(Hke,{shape:l,baseProps:o,entry:v,index:S,dataKey:c})))):null}function Gke(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=Jg(e,"recharts-bar-"),[p,b]=w.useState(!1),y=!p,x=w.useCallback(()=>{typeof u=="function"&&u(),b(!1)},[u]),v=w.useCallback(()=>{typeof d=="function"&&d(),b(!0)},[d]);return w.createElement(Bke,{showLabels:y,rects:r},w.createElement(Zg,{animationId:m,begin:o,duration:l,isActive:a,easing:c,onAnimationEnd:x,onAnimationStart:v,key:m},S=>{var M=S===1?r:r?.map((E,A)=>{var k=f&&f[A];if(k)return Xa(Xa({},E),{},{x:nr(k.x,E.x,S),y:nr(k.y,E.y,S),width:nr(k.width,E.width,S),height:nr(k.height,E.height,S)});if(i==="horizontal"){var T=nr(0,E.height,S),D=nr(E.stackedBarStart,E.y,S);return Xa(Xa({},E),{},{y:D,height:T})}var C=nr(0,E.width,S),R=nr(E.stackedBarStart,E.x,S);return Xa(Xa({},E),{},{width:C,x:R})});return S>0&&(n.current=M??null),M==null?null:w.createElement(qr,null,w.createElement(Vke,{props:e,data:M}))}),w.createElement(tE,{label:e.label}),e.children)}function Wke(t){var e=w.useRef(null);return w.createElement(Gke,{previousRectanglesRef:e,props:t})}var CJ=0,qke=(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 Kke 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(H4,{clipPathId:f,xAxisId:a,yAxisId:o})),w.createElement(qr,{className:"recharts-bar-rectangles",clipPath:l?"url(#clipPath-".concat(f,")"):void 0},w.createElement(zke,{data:n,dataKey:r,background:c,allOtherBarProps:this.props}),w.createElement(Wke,this.props)))}}var Xke={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:CJ,xAxisId:0,yAxisId:0,zIndex:oi.bar};function Yke(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}=lE(e,n),m=hh(),p=Bi(),b=R4(t.children,By),y=Gt(S=>Ske(S,t.id,p,b));if(m!=="vertical"&&m!=="horizontal")return null;var x,v=y?.[0];return v==null||v.height==null||v.width==null?x=0:x=m==="vertical"?v.height/2:v.width/2,w.createElement(lJ,{xAxisId:e,yAxisId:n,data:y,dataPointFormatter:qke,errorBarOffset:x},w.createElement(Kke,yu({},t,{layout:m,needClip:f,data:y,xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:o,animationBegin:l,animationDuration:c,animationEasing:u,isAnimationActive:d})))}function Qke(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:y}=t,x=e==="horizontal"?l:o,v=d?x.scale.domain():null,S=Dbe({numericAxis:x}),M=x.scale.map(S);return f.map((E,A)=>{var k,T,D,C,R,U;if(d){var O=d[A+y];if(O==null)return null;k=Cbe(O,v)}else k=ir(E,n),Array.isArray(k)||(k=[S,k]);var q=ske(r,CJ)(k[1],A);if(e==="horizontal"){var j,W=l.scale.map(k[0]),X=l.scale.map(k[1]);if(W==null||X==null)return null;T=w8({axis:o,ticks:c,bandSize:a,offset:i.offset,entry:E,index:A}),D=(j=X??W)!==null&&j!==void 0?j:void 0,C=i.size;var G=W-X;if(R=ul(G)?0:G,U={x:T,y:m.top,width:C,height:m.height},Math.abs(q)>0&&Math.abs(R)<Math.abs(q)){var Z=ea(R||q)*(Math.abs(q)-Math.abs(R));D-=Z,R+=Z}}else{var te=o.scale.map(k[0]),ee=o.scale.map(k[1]);if(te==null||ee==null)return null;if(T=te,D=w8({axis:l,ticks:u,bandSize:a,offset:i.offset,entry:E,index:A}),C=ee-te,R=i.size,U={x:m.left,y:D,width:m.width,height:R},Math.abs(q)>0&&Math.abs(C)<Math.abs(q)){var z=ea(C||q)*(Math.abs(q)-Math.abs(C));C+=z}}if(T==null||D==null||C==null||R==null)return null;var V=Xa(Xa({},E),{},{stackedBarStart:M,x:T,y:D,width:C,height:R,value:d?k:k[1],payload:E,background:U,tooltipPosition:{x:T+C/2,y:D+R/2},parentViewBox:b},p&&p[A]&&p[A].props);return V}).filter(Boolean)}function Zke(t){var e=Kr(t,Xke),n=Ake(e.stackId),r=Bi();return w.createElement(aE,{id:e.id,type:"bar"},i=>w.createElement(w.Fragment,null,w.createElement(U4,{legendPayload:Fke(e)}),w.createElement(Uke,{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(z4,{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(Yke,yu({},e,{id:i})))))}var kJ=w.memo(Zke,$y);kJ.displayName="Bar";var Jke=["domain","range"],eje=["domain","range"];function WH(t,e){if(t==null)return{};var n,r,i=tje(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 tje(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 qH(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 jJ(t,e){if(t===e)return!0;var{domain:n,range:r}=t,i=WH(t,Jke),{domain:a,range:o}=e,l=WH(e,eje);return!qH(n,a)||!qH(r,o)?!1:$y(i,l)}var nje=["type"],rje=["dangerouslySetInnerHTML","ticks","scale"],ije=["id","scale"];function y3(){return y3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},y3.apply(null,arguments)}function KH(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 XH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?KH(Object(n),!0).forEach(function(r){aje(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):KH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function aje(t,e,n){return(e=sje(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function sje(t){var e=oje(t,"string");return typeof e=="symbol"?e:e+""}function oje(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 v3(t,e){if(t==null)return{};var n,r,i=lje(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 lje(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 cje(t){var e=Mr(),n=w.useRef(null),r=gO(),{type:i}=t,a=v3(t,nje),o=HN(r,"xAxis",i),l=w.useMemo(()=>{if(o!=null)return XH(XH({},a),{},{type:o})},[a,o]);return w.useLayoutEffect(()=>{l!=null&&(n.current===null?e(eAe(l)):n.current!==l&&e(tAe({prev:n.current,next:l})),n.current=l)},[l,e]),w.useLayoutEffect(()=>()=>{n.current&&(e(nAe(n.current)),n.current=null)},[e]),null}var uje=t=>{var{xAxisId:e,className:n}=t,r=Gt(dO),i=Bi(),a="xAxis",o=Gt(v=>ZQ(v,a,e,i)),l=Gt(v=>KQ(v,e)),c=Gt(v=>Kwe(v,e)),u=Gt(v=>CQ(v,e));if(l==null||c==null||u==null)return null;var{dangerouslySetInnerHTML:d,ticks:f,scale:m}=t,p=v3(t,rje),{id:b,scale:y}=u,x=v3(u,ije);return w.createElement($4,y3({},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}))},dje={allowDataOverflow:Xi.allowDataOverflow,allowDecimals:Xi.allowDecimals,allowDuplicatedCategory:Xi.allowDuplicatedCategory,angle:Xi.angle,axisLine:au.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:au.tickLine,tickSize:au.tickSize,type:Xi.type,xAxisId:0},hje=t=>{var e=Kr(t,dje);return w.createElement(w.Fragment,null,w.createElement(cje,{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(uje,e))},LS=w.memo(hje,jJ);LS.displayName="XAxis";var fje=["type"],mje=["dangerouslySetInnerHTML","ticks","scale"],pje=["id","scale"];function _3(){return _3=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},_3.apply(null,arguments)}function YH(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 QH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?YH(Object(n),!0).forEach(function(r){gje(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):YH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function gje(t,e,n){return(e=xje(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function xje(t){var e=bje(t,"string");return typeof e=="symbol"?e:e+""}function bje(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 w3(t,e){if(t==null)return{};var n,r,i=yje(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 yje(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 vje(t){var e=Mr(),n=w.useRef(null),r=gO(),{type:i}=t,a=w3(t,fje),o=HN(r,"yAxis",i),l=w.useMemo(()=>{if(o!=null)return QH(QH({},a),{},{type:o})},[o,a]);return w.useLayoutEffect(()=>{l!=null&&(n.current===null?e(rAe(l)):n.current!==l&&e(iAe({prev:n.current,next:l})),n.current=l)},[l,e]),w.useLayoutEffect(()=>()=>{n.current&&(e(aAe(n.current)),n.current=null)},[e]),null}function _je(t){var{yAxisId:e,className:n,width:r,label:i}=t,a=w.useRef(null),o=w.useRef(null),l=Gt(dO),c=Bi(),u=Mr(),d="yAxis",f=Gt(k=>XQ(k,e)),m=Gt(k=>Ywe(k,e)),p=Gt(k=>ZQ(k,d,e,c)),b=Gt(k=>kQ(k,e));if(w.useLayoutEffect(()=>{if(!(r!=="auto"||!f||C4(i)||w.isValidElement(i)||b==null)){var k=a.current;if(k){var T=k.getCalculatedWidth();Math.round(f.width)!==Math.round(T)&&u(sAe({id:e,width:T}))}}},[p,f,u,i,e,r,b]),f==null||m==null||b==null)return null;var{dangerouslySetInnerHTML:y,ticks:x,scale:v}=t,S=w3(t,mje),{id:M,scale:E}=b,A=w3(b,pje);return w.createElement($4,_3({},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 wje={allowDataOverflow:Yi.allowDataOverflow,allowDecimals:Yi.allowDecimals,allowDuplicatedCategory:Yi.allowDuplicatedCategory,angle:Yi.angle,axisLine:au.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:au.tickLine,tickSize:au.tickSize,type:Yi.type,width:Yi.width,yAxisId:0},Sje=t=>{var e=Kr(t,wje);return w.createElement(w.Fragment,null,w.createElement(vje,{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(_je,e))},IS=w.memo(Sje,jJ);IS.displayName="YAxis";var Mje=(t,e)=>e,G4=tt([Mje,Fn,EQ,la,pZ,Tu,dMe,zi],bMe),W4=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)}},PJ=Io("mouseClick"),RJ=Sy();RJ.startListening({actionCreator:PJ,effect:(t,e)=>{var n=t.payload,r=G4(e.getState(),W4(n));r?.activeIndex!=null&&e.dispatch(uSe({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var S3=Io("mouseMove"),DJ=Sy(),j_=null;DJ.startListening({actionCreator:S3,effect:(t,e)=>{var n=t.payload;j_!==null&&cancelAnimationFrame(j_);var r=W4(n);j_=requestAnimationFrame(()=>{var i=e.getState(),a=b4(i,i.tooltip.settings.shared);if(a==="axis"){var o=G4(i,r);o?.activeIndex!=null?e.dispatch(sZ({activeIndex:o.activeIndex,activeDataKey:void 0,activeCoordinate:o.activeCoordinate})):e.dispatch(aZ())}j_=null})}});function Nje(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},OJ=Es({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=OJ.reducer,{updateOptions:Aje}=OJ.actions,Tje=null,Cje={updatePolarOptions:(t,e)=>e.payload},LJ=Es({name:"polarOptions",initialState:Tje,reducers:Cje}),{updatePolarOptions:kje}=LJ.actions,jje=LJ.reducer,IJ=Io("keyDown"),FJ=Io("focus"),q4=Sy();q4.startListening({actionCreator:IJ,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=y4(i,lx(n),Iy(n),Uy(n)),l=o==null?-1:Number(o);if(!(!Number.isFinite(l)||l<0)){var c=Tu(n);if(a==="Enter"){var u=NS(n,"axis","hover",String(i.index));e.dispatch(d3({active:!i.active,activeIndex:i.index,activeCoordinate:u}));return}var d=eSe(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=NS(n,"axis","hover",String(p));e.dispatch(d3({active:!0,activeIndex:p.toString(),activeCoordinate:b}))}}}}}});q4.startListening({actionCreator:FJ,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=NS(n,"axis","hover",String(a));e.dispatch(d3({active:!0,activeIndex:a,activeCoordinate:o}))}}}});var go=Io("externalEvent"),UJ=Sy(),zC=new Map;UJ.startListening({actionCreator:go,effect:(t,e)=>{var{handler:n,reactEvent:r}=t.payload;if(n!=null){r.persist();var i=r.type,a=zC.get(i);a!==void 0&&cancelAnimationFrame(a);var o=requestAnimationFrame(()=>{try{var l=e.getState(),c={activeCoordinate:YSe(l),activeDataKey:M4(l),activeIndex:Zd(l),activeLabel:bZ(l),activeTooltipIndex:Zd(l),isTooltipActive:QSe(l)};n(c,r)}finally{zC.delete(i)}});zC.set(i,o)}}});var Pje=tt([sx],t=>t.tooltipItemPayloads),Rje=tt([Pje,(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)}}}),zJ=Io("touchMove"),BJ=Sy();BJ.startListening({actionCreator:zJ,effect:(t,e)=>{var n=t.payload;if(!(n.touches==null||n.touches.length===0)){var r=e.getState(),i=b4(r,r.tooltip.settings.shared);if(i==="axis"){var a=n.touches[0];if(a==null)return;var o=G4(r,W4({clientX:a.clientX,clientY:a.clientY,currentTarget:n.currentTarget}));o?.activeIndex!=null&&e.dispatch(sZ({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(JX),f=(l=u.getAttribute(eY))!==null&&l!==void 0?l:void 0,m=ox(r).find(y=>y.id===f);if(d==null||m==null||f==null)return;var{dataKey:p}=m,b=Rje(r,d,f);e.dispatch(iZ({activeDataKey:p,activeIndex:d,activeCoordinate:b,activeGraphicalItemId:f}))}}}});var Dje=vX({brush:MAe,cartesianAxis:oAe,chartData:XMe,errorBars:DTe,graphicalItems:p2e,layout:Mbe,legend:k0e,options:VMe,polarAxis:CEe,polarOptions:jje,referenceElements:PAe,rootProps:Eje,tooltip:dSe,zIndex:PMe}),Oje=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"Chart";return Xxe({reducer:Dje,preloadedState:e,middleware:r=>{var i;return r({serializableCheck:!1,immutableCheck:!["commonjs","es6","production"].includes((i="es6")!==null&&i!==void 0?i:"")}).concat([RJ.middleware,DJ.middleware,q4.middleware,UJ.middleware,BJ.middleware])},enhancers:r=>{var i=r;return typeof r=="function"&&(i=r()),i.concat(OX({type:"raf"}))},devTools:{serialize:{replacer:Nje},name:"recharts-".concat(n)}})};function $J(t){var{preloadedState:e,children:n,reduxStoreName:r}=t,i=Bi(),a=w.useRef(null);if(i)return n;a.current==null&&(a.current=Oje(e,r));var o=iO;return w.createElement(lCe,{context:o,store:a.current},n)}function Lje(t){var{layout:e,margin:n}=t,r=Mr(),i=Bi();return w.useEffect(()=>{i||(r(_be(e)),r(vbe(n)))},[r,i,e,n]),null}var HJ=w.memo(Lje,$y);function VJ(t){var e=Mr();return w.useEffect(()=>{e(Aje(t))},[e,t]),null}function JH(t){var{zIndex:e,isPanorama:n}=t,r=w.useRef(null),i=Mr();return w.useLayoutEffect(()=>(r.current&&i(kMe({zIndex:e,element:r.current,isPanorama:n})),()=>{i(jMe({zIndex:e,isPanorama:n}))}),[i,e,n]),w.createElement("g",{tabIndex:-1,ref:r})}function eV(t){var{children:e,isPanorama:n}=t,r=Gt(vMe);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(JH,{key:o,zIndex:o,isPanorama:n})),e,a.map(o=>w.createElement(JH,{key:o,zIndex:o,isPanorama:n})))}var Ije=["children"];function Fje(t,e){if(t==null)return{};var n,r,i=Uje(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 Uje(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 FS(){return FS=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},FS.apply(null,arguments)}var zje={width:"100%",height:"100%",display:"block"},Bje=w.forwardRef((t,e)=>{var n=mO(),r=pO(),i=gY();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(qD,FS({},o,{title:l,desc:c,role:d,tabIndex:u,width:n,height:r,style:zje,ref:e}),a)}),$je=t=>{var{children:e}=t,n=Gt(jN);if(!n)return null;var{width:r,height:i,y:a,x:o}=n;return w.createElement(qD,{width:r,height:i,x:o,y:a},e)},tV=w.forwardRef((t,e)=>{var{children:n}=t,r=Fje(t,Ije),i=Bi();return i?w.createElement($je,null,w.createElement(eV,{isPanorama:!0},n)):w.createElement(Bje,FS({ref:e},r),w.createElement(eV,{isPanorama:!1},n))});function Hje(){var t=Mr(),[e,n]=w.useState(null),r=Gt(zbe);return w.useEffect(()=>{if(e!=null){var i=e.getBoundingClientRect(),a=i.width/e.offsetWidth;pn(a)&&a!==r&&t(Sbe(a))}},[e,t,r]),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 Vje(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){Gje(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 Gje(t,e,n){return(e=Wje(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Wje(t){var e=qje(t,"string");return typeof e=="symbol"?e:e+""}function qje(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 Bd(){return Bd=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},Bd.apply(null,arguments)}var Kje=()=>(iNe(),null);function US(t){if(typeof t=="number")return t;if(typeof t=="string"){var e=parseFloat(t);if(!Number.isNaN(e))return e}return 0}var Xje=w.forwardRef((t,e)=>{var n,r,i=w.useRef(null),[a,o]=w.useState({containerWidth:US((n=t.style)===null||n===void 0?void 0:n.width),containerHeight:US((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 y=b[0];if(y!=null){var{width:x,height:v}=y.contentRect;l(x,v)}},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",Bd({ref:c},t)))}),Yje=w.forwardRef((t,e)=>{var{width:n,height:r}=t,[i,a]=w.useState({containerWidth:US(n),containerHeight:US(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",Bd({ref:l},t)))}),Qje=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",Bd({ref:e},t)))}),Zje=w.forwardRef((t,e)=>{var{width:n,height:r}=t;return typeof n=="string"||typeof r=="string"?w.createElement(Yje,Bd({},t,{ref:e})):typeof n=="number"&&typeof r=="number"?w.createElement(Qje,Bd({},t,{width:n,height:r,ref:e})):w.createElement(w.Fragment,null,w.createElement(Ey,{width:n,height:r}),w.createElement("div",Bd({ref:e},t)))});function Jje(t){return t?Xje:Zje}var ePe=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:y,style:x,width:v,responsive:S,dispatchTouchEvents:M=!0}=t,E=w.useRef(null),A=Mr(),[k,T]=w.useState(null),[D,C]=w.useState(null),R=Hje(),U=hO(),O=U?.width>0?U.width:v,q=U?.height>0?U.height:i,j=w.useCallback(ge=>{R(ge),typeof e=="function"&&e(ge),T(ge),C(ge),ge!=null&&(E.current=ge)},[R,e,T,C]),W=w.useCallback(ge=>{A(PJ(ge)),A(go({handler:a,reactEvent:ge}))},[A,a]),X=w.useCallback(ge=>{A(S3(ge)),A(go({handler:u,reactEvent:ge}))},[A,u]),G=w.useCallback(ge=>{A(aZ()),A(go({handler:d,reactEvent:ge}))},[A,d]),Z=w.useCallback(ge=>{A(S3(ge)),A(go({handler:f,reactEvent:ge}))},[A,f]),te=w.useCallback(()=>{A(FJ())},[A]),ee=w.useCallback(ge=>{A(IJ(ge.key))},[A]),z=w.useCallback(ge=>{A(go({handler:o,reactEvent:ge}))},[A,o]),V=w.useCallback(ge=>{A(go({handler:l,reactEvent:ge}))},[A,l]),ne=w.useCallback(ge=>{A(go({handler:c,reactEvent:ge}))},[A,c]),ie=w.useCallback(ge=>{A(go({handler:m,reactEvent:ge}))},[A,m]),he=w.useCallback(ge=>{A(go({handler:y,reactEvent:ge}))},[A,y]),me=w.useCallback(ge=>{M&&A(zJ(ge)),A(go({handler:b,reactEvent:ge}))},[A,M,b]),oe=w.useCallback(ge=>{A(go({handler:p,reactEvent:ge}))},[A,p]),Ae=Jje(S);return w.createElement(EZ.Provider,{value:k},w.createElement(LK.Provider,{value:D},w.createElement(Ae,{width:O??x?.width,height:q??x?.height,className:Bn("recharts-wrapper",r),style:Vje({position:"relative",cursor:"default",width:O,height:q},x),onClick:W,onContextMenu:z,onDoubleClick:V,onFocus:te,onKeyDown:ee,onMouseDown:ne,onMouseEnter:X,onMouseLeave:G,onMouseMove:Z,onMouseUp:ie,onTouchEnd:oe,onTouchMove:me,onTouchStart:he,ref:j},w.createElement(Kje,null),n)))}),tPe=["width","height","responsive","children","className","style","compact","title","desc"];function nPe(t,e){if(t==null)return{};var n,r,i=rPe(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 rPe(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 GJ=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=nPe(t,tPe),m=ns(f);return c?w.createElement(w.Fragment,null,w.createElement(Ey,{width:n,height:r}),w.createElement(tV,{otherAttributes:m,title:u,desc:d},a)):w.createElement(ePe,{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(tV,{otherAttributes:m,title:u,desc:d,ref:e},w.createElement(RAe,null,a)))});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 iPe={top:5,right:5,bottom:5,left:5},aPe={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:iPe,responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},K4=w.forwardRef(function(e,n){var r,i=Kr(e.categoricalChartProps,aPe),{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($J,{preloadedState:{options:d},reduxStoreName:(r=u.id)!==null&&r!==void 0?r:a},w.createElement(tJ,{chartData:u.data}),w.createElement(HJ,{layout:i.layout,margin:i.margin}),w.createElement(VJ,{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(GJ,M3({},i,{ref:n})))}),sPe=["axis"],oPe=w.forwardRef((t,e)=>w.createElement(K4,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:sPe,tooltipPayloadSearcher:JN,categoricalChartProps:t,ref:e})),lPe=["axis","item"],cPe=w.forwardRef((t,e)=>w.createElement(K4,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:lPe,tooltipPayloadSearcher:JN,categoricalChartProps:t,ref:e}));function uPe(t){var e=Mr();return w.useEffect(()=>{e(kje(t))},[e,t]),null}var dPe=["layout"];function N3(){return N3=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},N3.apply(null,arguments)}function hPe(t,e){if(t==null)return{};var n,r,i=fPe(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 fPe(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 mPe={top:5,right:5,bottom:5,left:5},WJ={accessibilityLayer:!0,stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:mPe,reverseStackOrder:!1,syncMethod:"index",layout:"radial",responsive:!1,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"},pPe=w.forwardRef(function(e,n){var r,i=Kr(e.categoricalChartProps,WJ),{layout:a}=i,o=hPe(i,dPe),{chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d}=e,f={chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d,eventEmitter:void 0};return w.createElement($J,{preloadedState:{options:f},reduxStoreName:(r=i.id)!==null&&r!==void 0?r:l},w.createElement(tJ,{chartData:i.data}),w.createElement(HJ,{layout:a,margin:i.margin}),w.createElement(VJ,{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(uPe,{cx:i.cx,cy:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius}),w.createElement(GJ,N3({},o,{ref:n})))});function rV(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 iV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?rV(Object(n),!0).forEach(function(r){gPe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):rV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function gPe(t,e,n){return(e=xPe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function xPe(t){var e=bPe(t,"string");return typeof e=="symbol"?e:e+""}function bPe(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 yPe=["item"],vPe=iV(iV({},WJ),{},{layout:"centric",startAngle:0,endAngle:360}),_Pe=w.forwardRef((t,e)=>{var n=Kr(t,vPe);return w.createElement(pPe,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:yPe,tooltipPayloadSearcher:JN,categoricalChartProps:n,ref:e})}),wPe=["axis"],SPe=w.forwardRef((t,e)=>w.createElement(K4,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:wPe,tooltipPayloadSearcher:JN,categoricalChartProps:t,ref:e}));const aV=[{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 MPe({isOpen:t,onClose:e,printerId:n,printerName:r,amsId:i,amsLabel:a,initialMode:o="humidity",thresholds:l}){const{t:c}=Wg(),{mode:u}=lh(),[d,f]=w.useState("24h"),[m,p]=w.useState(o),b=u==="dark",{data:y}=ft({queryKey:["settings"],queryFn:fe.getSettings}),x=y?.time_format||"system";w.useEffect(()=>{if(!t)return;const ie=he=>{he.key==="Escape"&&e()};return window.addEventListener("keydown",ie),()=>window.removeEventListener("keydown",ie)},[t,e]);const v=aV.find(ie=>ie.value===d)?.hours||24,{data:S,isLoading:M,error:E}=ft({queryKey:["ams-history",n,i,v],queryFn:()=>fe.getAMSHistory(n,i,v),enabled:t,refetchInterval:6e4});if(!t)return null;const A=S?.data.map(ie=>{const he=Si(ie.recorded_at)||new Date,me={hour:"2-digit",minute:"2-digit",...v>24?{day:"numeric",month:"short"}:{}};return{time:he.getTime(),humidity:ie.humidity,temperature:ie.temperature,timeLabel:he.toLocaleTimeString([],n0(me,x))}})||[],k=l?.humidityGood||40,T=l?.humidityFair||60,D=l?.tempGood||30,C=l?.tempFair||35,R=A[A.length-1],U=R?.humidity,O=R?.temperature,q=ie=>{const he=ie.filter(_e=>_e!=null);if(he.length<4)return"stable";const me=he.slice(0,Math.floor(he.length/4)),oe=he.slice(-Math.floor(he.length/4)),Ae=me.reduce((_e,le)=>_e+le,0)/me.length,Ne=oe.reduce((_e,le)=>_e+le,0)/oe.length-Ae;return Math.abs(Ne)<2?"stable":Ne>0?"up":"down"},j=q(A.map(ie=>ie.humidity)),W=q(A.map(ie=>ie.temperature)),X=({trend:ie})=>ie==="up"?s.jsx(NK,{className:"w-4 h-4 text-red-400"}):ie==="down"?s.jsx(MK,{className:"w-4 h-4 text-green-400"}):s.jsx(yP,{className:"w-4 h-4 text-gray-400 dark:text-bambu-gray"}),G=ie=>ie==null?"#9ca3af":ie<=k?"#22a352":ie<=T?"#d4a017":"#c62828",Z=ie=>ie==null?"#9ca3af":ie<=D?"#22a352":ie<=C?"#d4a017":"#c62828",te=b?"#2d2d2d":"#ffffff",ee=b?"#1d1d1d":"#f3f4f6",z=b?"#3d3d3d":"#e5e7eb",V=b?"#ffffff":"#111827",ne=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:te},onClick:ie=>ie.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:V},children:[a," ",c("common.history","History")]}),s.jsx("p",{className:"text-sm",style:{color:ne},children:r})]}),s.jsx("button",{onClick:e,className:"p-2 rounded-lg transition-colors",style:{color:ne},children:s.jsx(Ht,{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:ee},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:ne}:void 0,children:[s.jsx(FD,{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:ne}:void 0,children:[s.jsx(fN,{className:"w-4 h-4"}),c("common.temperature","Temperature")]})]}),s.jsx("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor:ee},children:aV.map(ie=>s.jsx("button",{onClick:()=>f(ie.value),className:`px-3 py-1 text-sm rounded-md transition-colors ${d===ie.value?"bg-bambu-green text-white":""}`,style:d!==ie.value?{color:ne}:void 0,children:ie.label},ie.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:ee},children:[s.jsx("p",{className:"text-xs",style:{color:ne},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:G(U)},children:U!=null?`${U}%`:"—"}),s.jsx(X,{trend:j})]})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ee},children:[s.jsx("p",{className:"text-xs",style:{color:ne},children:c("common.average","Average")}),s.jsx("p",{className:"text-2xl font-bold",style:{color:V},children:S?.avg_humidity!=null?`${S.avg_humidity}%`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ee},children:[s.jsx("p",{className:"text-xs",style:{color:ne},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:ee},children:[s.jsx("p",{className:"text-xs",style:{color:ne},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:ee},children:[s.jsx("p",{className:"text-xs",style:{color:ne},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:Z(O)},children:O!=null?`${O}°C`:"—"}),s.jsx(X,{trend:W})]})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ee},children:[s.jsx("p",{className:"text-xs",style:{color:ne},children:c("common.average","Average")}),s.jsx("p",{className:"text-2xl font-bold",style:{color:V},children:S?.avg_temperature!=null?`${S.avg_temperature}°C`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ee},children:[s.jsx("p",{className:"text-xs",style:{color:ne},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:ee},children:[s.jsx("p",{className:"text-xs",style:{color:ne},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:ee},children:M?s.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:ne},children:c("common.loading","Loading...")}):E?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:ne},children:c("common.noData","No data available for this time range")}):s.jsx(rw,{width:"100%",height:300,children:s.jsxs(oPe,{data:A,children:[s.jsx(PS,{strokeDasharray:"3 3",stroke:b?"#3d3d3d":"#e5e7eb"}),s.jsx(LS,{dataKey:"time",type:"number",domain:["dataMin","dataMax"],tickFormatter:ie=>{const he=new Date(ie);return v>24?he.toLocaleDateString([],{day:"numeric",month:"short"}):he.toLocaleTimeString([],n0({hour:"2-digit",minute:"2-digit"},x))},stroke:b?"#9ca3af":"#6b7280",tick:{fontSize:12}}),s.jsx(IS,{stroke:b?"#9ca3af":"#6b7280",tick:{fontSize:12},domain:m==="humidity"?[0,100]:["auto","auto"],tickFormatter:ie=>m==="humidity"?`${ie}%`:`${ie}°C`}),s.jsx(aw,{contentStyle:{backgroundColor:b?"#2d2d2d":"#ffffff",border:`1px solid ${b?"#3d3d3d":"#e5e7eb"}`,borderRadius:"8px",color:b?"#fff":"#000"},labelFormatter:ie=>new Date(ie).toLocaleString(void 0,n0({year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"},x)),formatter:ie=>[m==="humidity"?`${ie??0}%`:`${ie??0}°C`,m==="humidity"?"Humidity":"Temperature"]}),s.jsx(yO,{}),m==="humidity"?s.jsxs(s.Fragment,{children:[s.jsx(Bb,{y:k,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),s.jsx(Bb,{y:T,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}):s.jsxs(s.Fragment,{children:[s.jsx(Bb,{y:D,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),s.jsx(Bb,{y:C,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}),s.jsx(gJ,{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:ne},children:c("amsHistory.recordingInfo","Data is recorded every 5 minutes while the printer is connected")})]})]})})}function BC({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),y=()=>{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 T=document.createElement("textarea");T.value=k,T.style.position="fixed",T.style.opacity="0",document.body.appendChild(T),T.select();try{document.execCommand("copy"),f(!0),setTimeout(()=>f(!1),2e3)}catch{console.error("Failed to copy to clipboard")}document.body.removeChild(T)};w.useEffect(()=>{if(o&&m.current&&p.current){const k=m.current.getBoundingClientRect(),T=p.current.offsetHeight,D=k.top,C=window.innerHeight-k.bottom;D<T+12&&C>D?u("bottom"):u("top")}},[o]);const v=()=>{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",E=k=>{if(!k)return!1;const T=k.replace("#",""),D=parseInt(T.slice(0,2),16),C=parseInt(T.slice(2,4),16),R=parseInt(T.slice(4,6),16);return(.299*D+.587*C+.114*R)/255>.6},A=t.colorHex?`#${t.colorHex.replace("#","")}`:null;return s.jsxs("div",{ref:m,className:`relative ${r}`,onMouseEnter:v,onMouseLeave:S,children:[e,o&&s.jsxs("div",{ref:p,className:`
- absolute left-1/2 -translate-x-1/2 z-50
- ${c==="top"?"bottom-full mb-2":"top-full mt-2"}
- animate-in fade-in-0 zoom-in-95 duration-150
- `,style:{maxWidth:"calc(100vw - 24px)"},children:[s.jsxs("div",{className:`
- w-52 bg-bambu-dark-secondary border border-bambu-dark-tertiary
- rounded-lg shadow-xl overflow-hidden
- backdrop-blur-sm
- `,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:`
- absolute inset-0 flex items-center justify-center
- font-semibold text-sm tracking-wide
- ${E(A)?"text-black/80":"text-white/90"}
- `,children:t.colorName}),s.jsx("div",{className:`
- absolute top-1.5 right-1.5 px-1.5 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider
- ${t.vendor==="Bambu Lab"?"bg-black/60 text-white":"bg-black/50 text-white/90"}
- `,children:t.vendor==="Bambu Lab"?"BBL":"GEN"})]}),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(FD,{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(),y()},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(ts,{className:"w-3 h-3 text-bambu-green"}):s.jsx(sl,{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(Xd,{className:"w-3.5 h-3.5"}),"Configure"]})})]})]}),s.jsx("div",{className:`
- absolute left-1/2 -translate-x-1/2 w-0 h-0
- border-l-[6px] border-l-transparent
- border-r-[6px] border-r-transparent
- ${c==="top"?"top-full border-t-[6px] border-t-bambu-dark-tertiary":"bottom-full border-b-[6px] border-b-bambu-dark-tertiary"}
- `})]})]})}function sV({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:`
- absolute left-1/2 -translate-x-1/2 bottom-full mb-2 z-50
- animate-in fade-in-0 zoom-in-95 duration-150
- `,children:[s.jsxs("div",{className:`
- bg-bambu-dark-secondary border border-bambu-dark-tertiary
- rounded-md shadow-lg overflow-hidden
- `,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(Xd,{className:"w-3.5 h-3.5"}),"Configure"]})})]}),s.jsx("div",{className:`
- absolute left-1/2 -translate-x-1/2 top-full w-0 h-0
- border-l-[5px] border-l-transparent
- border-r-[5px] border-r-transparent
- border-t-[5px] border-t-bambu-dark-tertiary
- `})]})]})}function NPe({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:fe.getUnlinkedSpools,enabled:t}),u=pt({mutationFn:f=>fe.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(Ht,{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(ts,{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 oV(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 APe=["PLA","PETG","ABS","ASA","TPU","PC","PA","NYLON","PVA","HIPS","PP","PET"];function lV(t){const e=t.replace(/@.+$/,"").trim(),n=e.toUpperCase();for(const i of APe){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 $C(t){return!t.startsWith("GF")&&!t.startsWith("P1")}const TPe={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"},CPe=[{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"}],kPe=[{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 jPe(t){const e=t.toLowerCase().trim();return TPe[e]||null}function PPe({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,y]=w.useState(""),[x,v]=w.useState(!1),[S,M]=w.useState(!1),{data:E,isLoading:A}=ft({queryKey:["cloudSettings"],queryFn:()=>fe.getCloudSettings(),enabled:t}),{data:k,isLoading:T}=ft({queryKey:["kprofiles",n,i],queryFn:()=>fe.getKProfiles(n,i),enabled:t&&!!n}),D=pt({mutationFn:async()=>{if(!o)throw new Error("No filament preset selected");const Z=E?.filament.find(ge=>ge.setting_id===o);if(!Z)throw new Error("Selected preset not found");const te=lV(Z.name),ee=c?.slot_id??-1,z=d||r.trayColor?.slice(0,6)||"FFFFFF",V=Z.name.replace(/@.+$/,"").trim();let ne=oV(o);if(!o.startsWith("GFS"))try{const ge=await fe.getCloudSettingDetail(o);ge.filament_id?ne=ge.filament_id:ge.base_id&&(ne=oV(ge.base_id),console.log(`Derived tray_info_idx from base_id: ${ge.base_id} -> ${ne}`))}catch(ge){console.warn("Failed to fetch preset detail for filament_id:",ge)}let ie=190,he=230;const me=te.material.toUpperCase();me.includes("PLA")?(ie=190,he=230):me.includes("PETG")?(ie=220,he=260):me.includes("ABS")||me.includes("ASA")?(ie=240,he=280):me.includes("TPU")?(ie=200,he=240):me.includes("PC")?(ie=260,he=300):(me.includes("PA")||me.includes("NYLON"))&&(ie=250,he=290);const oe=c?.k_value?parseFloat(c.k_value):0,Ae=await fe.configureAmsSlot(n,r.amsId,r.trayId,{tray_info_idx:ne,tray_type:te.material||"PLA",tray_sub_brands:V,tray_color:z+"FF",nozzle_temp_min:ie,nozzle_temp_max:he,cali_idx:ee,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 fe.saveSlotPreset(n,r.amsId,r.trayId,o,V)}catch(ge){console.warn("Failed to save slot preset mapping:",ge)}return Ae},onSuccess:()=>{v(!0),a?.(),setTimeout(()=>{v(!1),e()},1500)}}),C=pt({mutationFn:async()=>fe.resetAmsSlot(n,r.amsId,r.trayId),onSuccess:()=>{v(!0),a?.(),setTimeout(()=>{v(!1),e()},1500)}}),R=w.useMemo(()=>{if(!E?.filament)return[];const Z=b.toLowerCase();return E.filament.filter(te=>Z?te.name.toLowerCase().includes(Z):!0).sort((te,ee)=>{const z=$C(te.setting_id),V=$C(ee.setting_id);return z&&!V?-1:!z&&V?1:te.name.localeCompare(ee.name)})},[E?.filament,b]),U=w.useMemo(()=>{if(!o||!E?.filament)return null;const Z=E.filament.find(z=>z.setting_id===o);if(!Z)return null;let te=Z.name.replace(/@.+$/,"").trim();te.startsWith("# ")&&(te=te.slice(2).trim());const ee=lV(te);return{fullName:te,material:ee.material,brand:ee.brand}},[o,E?.filament]),O=U?.fullName||"",q=w.useMemo(()=>{if(!k?.profiles||!U)return[];const{fullName:Z,material:te,brand:ee}=U,z=Z.toUpperCase(),V=te.toUpperCase(),ne=ee.toUpperCase();if(!V||V.length<2)return[];const ie=k.profiles.filter(me=>{const oe=me.name.toUpperCase();if(ne)return!(!oe.includes(ne)||!oe.includes(V));if(oe.includes(z)||oe.includes(V))return!0;const ge={NYLON:["PA","PA-CF","PA6"],PA:["NYLON"]}[V]||[];for(const Ne of ge)if(oe.includes(Ne))return!0;return!1}),he=new Map;for(const me of ie){const oe=`${me.name}|${me.k_value}`,Ae=he.get(oe);Ae?me.extruder_id===1&&Ae.extruder_id===0&&he.set(oe,me):he.set(oe,me)}return Array.from(he.values())},[k?.profiles,U]);w.useEffect(()=>{if(t&&E?.filament){if(r.trayInfoIdx){const Z=E.filament.find(te=>te.setting_id===r.trayInfoIdx);Z&&l(Z.setting_id)}}else t||(l(""),u(null),f(""),p(""),y(""),v(!1))},[t,E?.filament,r.trayInfoIdx]),w.useEffect(()=>{q.length>0?u(q[0]):u(null)},[o,q]);const j=w.useCallback(Z=>{Z.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||T,X=o&&!D.isPending,G=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(Xd,{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(Ht,{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(eN,{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:Z=>y(Z.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:E?.filament?.length===0?"No cloud presets. Login to Bambu Cloud to sync.":"No matching presets found."}):R.map(Z=>s.jsx("button",{onClick:()=>l(Z.setting_id),className:`w-full p-2 rounded-lg border text-left transition-colors ${o===Z.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:Z.name}),$C(Z.setting_id)&&s.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-bambu-blue/20 text-bambu-blue",children:"Custom"})]})},Z.setting_id))})]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-2",children:["K Profile (Pressure Advance)",O&&s.jsxs("span",{className:"ml-2 text-xs text-bambu-blue",children:["Filtering for: ",O]})]}),q.length>0?s.jsxs("div",{className:"relative",children:[s.jsxs("select",{value:c?.name||"",onChange:Z=>{const te=q.find(ee=>ee.name===Z.target.value);u(te||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(Z=>s.jsxs("option",{value:Z.name,children:[Z.name," (K=",Z.k_value,")"]},`${Z.name}-${Z.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:[CPe.map(Z=>s.jsx("button",{onClick:()=>{f(Z.hex),p(Z.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${d===Z.hex?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:`#${Z.hex}`},title:Z.name},Z.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:kPe.map(Z=>s.jsx("button",{onClick:()=>{f(Z.hex),p(Z.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${d===Z.hex?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:`#${Z.hex}`},title:Z.name},Z.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:`#${G}`}}),s.jsx("input",{type:"text",placeholder:"Color name or hex (e.g., brown, FF8800)",value:m,onChange:Z=>{const te=Z.target.value;p(te);const ee=jPe(te);if(ee)f(ee);else{const z=te.replace(/[^0-9A-Fa-f]/g,"").toUpperCase();z.length===6?f(z):z.length===3&&f(z.split("").map(V=>V+V).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:()=>C.mutate(),disabled:C.isPending||D.isPending,className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:C.isPending?s.jsxs(s.Fragment,{children:[s.jsx(mt,{className:"w-4 h-4 animate-spin"}),"Resetting..."]}):s.jsxs(s.Fragment,{children:[s.jsx(cm,{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:!X,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(Xd,{className:"w-4 h-4"}),"Configure Slot"]})})]})]}),(D.isError||C.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||C.error?.message})]})]})}function RPe({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 cV=({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"})]}),uV={"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"},DPe={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 HC(t){if(!t)return null;if(uV[t])return uV[t];const e=t.split("-");if(e.length<2)return null;const n=e[1];return DPe[n]||null}function VC(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 GC(t){return(t??.02).toFixed(3)}function dV({side:t}){const{mode:e}=lh(),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 hV({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 OPe({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 LPe({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 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("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 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:"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 UPe({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 WC({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 fV({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=hV:a<=l?d=OPe:d=LPe,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 mV({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=IPe):t<=o?(l="#d4a017",c="Fair",u=FPe):(l="#c62828",c="Bad",u=UPe),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 Ju(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 pV(t){return t>50?"#00ae42":t>=15?"#f59e0b":"#ef4444"}function zPe(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function BPe(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 $Pe(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 HPe(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 qC(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 VPe({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 GPe({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 gV(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 xV({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,y]=w.useState(!1),[x,v]=w.useState(!1),[S,M]=w.useState(!0),[E,A]=w.useState(!1),[k,T]=w.useState(!1),[D,C]=w.useState(!1),[R,U]=w.useState(!1),[O,q]=w.useState(!1),[j,W]=w.useState(!1),[X,G]=w.useState(!1),[Z,te]=w.useState(!1),[ee,z]=w.useState(!1),[V,ne]=w.useState(!1),[ie,he]=w.useState(null),[me,oe]=w.useState(null),[Ae,ge]=w.useState(null),[Ne,_e]=w.useState(!1),[le,He]=w.useState(null),[H,J]=w.useState(!1),[K,B]=w.useState(!1),[I,ce]=w.useState(null),[Ee,Ie]=w.useState(!1),{data:ue}=ft({queryKey:["printerStatus",t.id],queryFn:()=>fe.getPrinterStatus(t.id),refetchInterval:3e4}),{data:$}=ft({queryKey:["firmwareUpdate",t.id],queryFn:()=>J1.checkPrinterUpdate(t.id),staleTime:300*1e3,refetchInterval:300*1e3}),L=w.useMemo(()=>{const Oe=new Set;if(ue?.ams)for(const gt of ue.ams)for(const Rt of gt.tray||[])Rt.tray_info_idx&&Oe.add(Rt.tray_info_idx);return ue?.vt_tray?.tray_info_idx&&Oe.add(ue.vt_tray.tray_info_idx),Array.from(Oe)},[ue?.ams,ue?.vt_tray]),{data:Y}=ft({queryKey:["filamentInfo",L],queryFn:()=>fe.getFilamentInfo(L),enabled:L.length>0,staleTime:300*1e3}),{data:pe}=ft({queryKey:["slotPresets",t.id],queryFn:()=>fe.getSlotPresets(t.id),staleTime:120*1e3}),[Se,ae]=w.useState(null);w.useEffect(()=>{ue?.wifi_signal!=null&&ae(ue.wifi_signal)},[ue?.wifi_signal]);const je=ue?.wifi_signal??Se,De=w.useRef(void 0);w.useEffect(()=>{ue?.connected!==void 0&&(De.current=ue.connected)},[ue?.connected]);const Xe=ue?.connected??De.current,et=w.useRef({});w.useEffect(()=>{ue?.ams_extruder_map&&Object.keys(ue.ams_extruder_map).length>0&&(et.current=ue.ams_extruder_map)},[ue?.ams_extruder_map]);const Qe=ue?.ams_extruder_map&&Object.keys(ue.ams_extruder_map).length>0?ue.ams_extruder_map:et.current,se=w.useRef([]);w.useEffect(()=>{ue?.ams&&ue.ams.length>0&&(se.current=ue.ams)},[ue?.ams]);const ye=ue?.ams&&ue.ams.length>0?ue.ams:se.current,ke=w.useRef(255),Ue=ue?.tray_now;Ue!==void 0&&Ue!==255&&(ke.current=Ue);const dt=Ue===void 0||Ue===255?ke.current:Ue,{data:re}=ft({queryKey:["smartPlugByPrinter",t.id],queryFn:()=>fe.getSmartPlugByPrinter(t.id)}),{data:Fe}=ft({queryKey:["smartPlugStatus",re?.id],queryFn:()=>re?fe.getSmartPlugStatus(re.id):null,enabled:!!re,refetchInterval:1e4}),{data:ve}=ft({queryKey:["queue",t.id,"pending"],queryFn:()=>fe.getQueue(t.id,"pending")}),$e=ve?.length||0,{data:Le}=ft({queryKey:["archives",t.id,"last"],queryFn:()=>fe.getArchives(t.id,1,0),enabled:ue?.connected&&ue?.state!=="RUNNING"}),Te=Le?.[0],We=e&&Xe===!1,it=pt({mutationFn:Oe=>fe.deletePrinter(t.id,Oe.deleteArchives),onSuccess:()=>{f.invalidateQueries({queryKey:["printers"]}),f.invalidateQueries({queryKey:["archives"]}),f.invalidateQueries({queryKey:["maintenanceOverview"]})}}),Ot=pt({mutationFn:()=>fe.connectPrinter(t.id),onSuccess:()=>{f.invalidateQueries({queryKey:["printerStatus",t.id]})}}),kt=pt({mutationFn:Oe=>re?fe.controlSmartPlug(re.id,Oe):Promise.reject("No plug"),onSuccess:()=>{f.invalidateQueries({queryKey:["smartPlugStatus",re?.id]})}}),on=pt({mutationFn:Oe=>re?fe.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:()=>fe.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:()=>fe.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:()=>fe.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=>fe.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=>fe.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=(ue?.state==="RUNNING"||ue?.state==="PAUSE"||ue?.state==="PAUSED")&&(ue?.printable_objects_count??0)>=2,{data:Cn,refetch:Cr}=ft({queryKey:["printableObjects",t.id],queryFn:()=>fe.getPrintableObjects(t.id),enabled:V||Tt,refetchInterval:V?5e3:Tt?3e4:!1}),er=pt({mutationFn:Oe=>fe.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),we=w.useRef(!1),Je=pt({mutationFn:({amsId:Oe,slotId:gt})=>fe.refreshAmsSlot(t.id,Oe,gt),onMutate:({amsId:Oe,slotId:gt})=>{gi.current&&clearTimeout(gi.current),Ci.current=!1,we.current=!1,yr({amsId:Oe,slotId:gt}),setTimeout(()=>{we.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 fe.getPlateReferences(t.id);lt(Oe)}catch{}},Vt=()=>{sn.mutate(!t.plate_detection_enabled)},Jt=async()=>{J(!0),He(null);try{const Oe=await fe.checkPlateEmpty(t.id,{includeDebugImage:!0});He(Oe),Bt()}catch(Oe){p(Oe instanceof Error?Oe.message:"Failed to check plate","error")}finally{J(!1)}},de=async Oe=>{B(!0);try{const gt=await fe.calibratePlateDetection(t.id,{label:Oe});if(gt.success){p(gt.message||"Calibration saved!","success"),Bt();const Rt=await fe.checkPlateEmpty(t.id,{includeDebugImage:!0});He(Rt)}else p(gt.message||"Calibration failed","error")}catch(gt){p(gt instanceof Error?gt.message:"Calibration failed","error")}finally{B(!1)}},Pe=async(Oe,gt)=>{try{await fe.updatePlateReferenceLabel(t.id,Oe,gt),Pt(null),Bt()}catch(Rt){p(Rt instanceof Error?Rt.message:"Failed to update label","error")}},Ge=async Oe=>{try{await fe.deletePlateReference(t.id,Oe),p("Reference deleted","success"),Bt();const gt=await fe.checkPlateEmpty(t.id,{includeDebugImage:!0});He(gt)}catch(gt){p(gt instanceof Error?gt.message:"Failed to delete reference","error")}},qe=async()=>{if(I){Ie(!0);try{await fe.updatePrinter(t.id,{plate_detection_roi:I}),p("Detection area saved","success"),ce(null);const Oe=await fe.checkPlateEmpty(t.id,{includeDebugImage:!0});He(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"&&le&&He(null)};return window.addEventListener("keydown",Oe),()=>window.removeEventListener("keydown",Oe)},[le]);const Ve=w.useRef(null);w.useEffect(()=>{if(!Un)return;const Oe=ue?.ams_status_main??0;return Oe!==0&&(Ci.current=!0,Ve.current&&(clearTimeout(Ve.current),Ve.current=null)),Ci.current&&Oe===0&&(we.current?(gi.current&&clearTimeout(gi.current),yr(null)):Ve.current||(Ve.current=setTimeout(()=>{gi.current&&clearTimeout(gi.current),yr(null)},2e3))),()=>{Ve.current&&clearTimeout(Ve.current)}},[ue?.ams_status_main,Un]);const[wt,Dt]=w.useState(null);if(We)return null;const Nt=()=>{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(Et,{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:$Pe(t.model),alt:t.model||"Printer",className:`object-contain rounded-lg bg-bambu-dark flex-shrink-0 ${Nt()}`}),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 ${ue?.connected?"bg-status-ok":"bg-status-error"}`,title:ue?.connected?"Connected":"Offline"})]}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:[t.model||"Unknown Model",r==="expanded"&&ue?.nozzles&&ue.nozzles[0]?.nozzle_diameter&&s.jsxs("span",{className:"ml-1.5 text-bambu-gray",title:ue.nozzles[0].nozzle_type||"Nozzle",children:["• ",ue.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:()=>y(!b),children:s.jsx(Id,{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),y(!1)},children:[s.jsx(sa,{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(),y(!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:()=>{C(!0),y(!1)},children:[s.jsx(SK,{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:()=>{v(!0),y(!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 ${ue?.connected?"bg-status-ok/20 text-status-ok":"bg-status-error/20 text-status-error"}`,children:[ue?.connected?s.jsx(Yg,{className:"w-3 h-3"}):s.jsx($D,{className:"w-3 h-3"}),ue?.connected?"Connected":"Offline"]}),ue?.connected&&je!=null&&s.jsxs("span",{className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs ${je>=-50||je>=-60?"bg-status-ok/20 text-status-ok":je>=-70?"bg-status-warning/20 text-status-warning":je>=-80?"bg-orange-500/20 text-orange-600":"bg-status-error/20 text-status-error"}`,title:`WiFi: ${je} dBm - ${HPe(je).label}`,children:[s.jsx(Hfe,{className:"w-3 h-3"}),je,"dBm"]}),ue?.connected&&(()=>{const Oe=ue.hms_errors?cpe(ue.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(Yd,{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(ll,{className:"w-3 h-3"}),$e]}),$?.update_available&&s.jsxs("button",{onClick:()=>_e(!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: ${$.current_version} → ${$.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(Et,{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:()=>{v(!1),M(!0)},children:"Cancel"}),s.jsx(Me,{variant:"danger",onClick:()=>{it.mutate({deleteArchives:S}),v(!1),M(!0)},children:"Delete"})]})]})})}),ue?.connected&&s.jsxs(s.Fragment,{children:[r==="compact"?s.jsx("div",{className:"mt-2",children:ue.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:`${ue.progress||0}%`}})}),s.jsxs("span",{className:"text-xs text-white",children:[Math.round(ue.progress||0),"%"]})]}):s.jsx("p",{className:"text-xs text-bambu-gray",children:gV(ue.state,ue.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:()=>ne(!0),disabled:!(ue.state==="RUNNING"||ue.state==="PAUSE"||ue.state==="PAUSED")||(ue.printable_objects_count??0)<2,className:`absolute top-2 right-2 p-1.5 rounded transition-colors z-10 ${(ue.state==="RUNNING"||ue.state==="PAUSE"||ue.state==="PAUSED")&&(ue.printable_objects_count??0)>=2?"text-bambu-gray hover:text-white hover:bg-white/10":"text-bambu-gray/30 cursor-not-allowed"}`,title:ue.state==="RUNNING"||ue.state==="PAUSE"||ue.state==="PAUSED"?(ue.printable_objects_count??0)>=2?"Skip objects":"Skip objects (requires 2+ objects)":"Skip objects (only while printing)",children:[s.jsx(cV,{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(VPe,{url:ue.state==="RUNNING"?ue.cover_url:null,printName:ue.state==="RUNNING"&&(ue.subtask_name||ue.current_print)||void 0}),s.jsx("div",{className:"flex-1 min-w-0",children:ue.current_print&&ue.state==="RUNNING"?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:ue.stg_cur_name||"Printing"}),s.jsx("p",{className:"text-white text-sm mb-2 truncate",children:ue.subtask_name||ue.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:`${ue.progress||0}%`}})}),s.jsxs("span",{className:"text-white",children:[Math.round(ue.progress||0),"%"]})]}),s.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-bambu-gray",children:[ue.remaining_time!=null&&ue.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"}),zPe(ue.remaining_time*60)]}),s.jsxs("span",{className:"text-bambu-green font-medium",title:"Estimated completion time",children:["ETA ",BPe(ue.remaining_time,c)]})]}),ue.layer_num!=null&&ue.total_layers!=null&&ue.total_layers>0&&s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(ll,{className:"w-3 h-3"}),ue.layer_num,"/",ue.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:gV(ue.state,ue.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:"—"})]}),Te?s.jsxs("p",{className:"text-xs text-bambu-gray mt-2 truncate",title:Te.print_name||Te.filename,children:["Last: ",Te.print_name||Te.filename,Te.completed_at&&s.jsxs("span",{className:"ml-1 text-bambu-gray/60",children:["• ",bg(Te.completed_at,{month:"short",day:"numeric"})]})]}):s.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:"Ready to print"})]})})]})]}),ue.state!=="RUNNING"&&s.jsx(fpe,{printerId:t.id})]}),ue.temperatures&&r==="expanded"&&(()=>{const Oe=ue.temperatures.nozzle_heating||ue.temperatures.nozzle_2_heating||!1,gt=ue.temperatures.bed_heating||!1,Rt=ue.temperatures.chamber_heating||!1,ct=t.nozzle_count===2||ue.temperatures.nozzle_2!==void 0,Qt=ue.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(WC,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-orange-400",isHeating:Oe}),ue.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(ue.temperatures.nozzle||0),"° / ",Math.round(ue.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(ue.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(WC,{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(ue.temperatures.bed||0),"°C"]})]}),ue.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(WC,{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(ue.temperatures.chamber||0),"°C"]})]}),ct&&s.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg",title:`Active: ${Qt==="L"?"Left":"Right"} nozzle`,children:[s.jsx("p",{className:`text-[11px] font-bold ${Qt==="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 ${Qt==="R"?"text-amber-400":"text-gray-500"}`,children:"R"})]})]})})(),r==="expanded"&&(()=>{const Oe=ue.state==="RUNNING",gt=ue.state==="PAUSED"||ue.state==="PAUSE",Rt=Oe||gt,ct=Ut.isPending||yn.isPending||xt.isPending,Qt=ue.cooling_fan_speed,Kt=ue.big_fan1_speed,be=ue.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 ${Qt&&Qt>0?"bg-cyan-500/10":"bg-bambu-dark"}`,title:"Part Cooling Fan",children:[s.jsx(hK,{className:`w-3.5 h-3.5 ${Qt&&Qt>0?"text-cyan-400":"text-bambu-gray/50"}`}),s.jsxs("span",{className:`text-[10px] ${Qt&&Qt>0?"text-cyan-400":"text-bambu-gray/50"}`,children:[Qt??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(Nue,{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:()=>G(!0),disabled:!Rt||ct,className:`
- flex items-center justify-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium
- transition-colors
- ${Rt?"bg-red-500/20 text-red-400 hover:bg-red-500/30":"bg-bambu-dark text-bambu-gray/50 cursor-not-allowed"}
- `,title:"Stop print",children:[s.jsx(Oo,{className:"w-3 h-3"}),"Stop"]}),s.jsxs("button",{onClick:()=>gt?z(!0):te(!0),disabled:!Rt||ct,className:`
- flex items-center justify-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium
- transition-colors
- ${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"}
- `,title:gt?"Resume print":"Pause print",children:[gt?s.jsx(cl,{className:"w-3 h-3"}):s.jsx(zD,{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||ue?.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 Qt=Qe[String(ct.id)],Kt=ct.id>=128?ct.id-128:ct.id,be=Qt!==void 0?Qt: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:Ju(ct.id,ct.tray.length)}),Rt&&(ut||It)&&s.jsx(dV,{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(fV,{humidity:ct.humidity,goodThreshold:a?.humidityGood,fairThreshold:a?.humidityFair,onClick:()=>he({amsId:ct.id,amsLabel:Ju(ct.id,ct.tray.length),mode:"humidity"}),compact:!0}),ct.temp!=null&&s.jsx(mV,{temp:ct.temp,goodThreshold:a?.tempGood,fairThreshold:a?.tempFair,onClick:()=>he({amsId:ct.id,amsLabel:Ju(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],Qn=Xt?.tray_type?{vendor:qC(Xt)?"Bambu Lab":"Generic",profile:ui?.name||vr?.preset_name||Xt.tray_sub_brands||Xt.tray_type,colorName:HC(Xt.tray_id_name)||VC(Xt.tray_color),colorHex:Xt.tray_color||null,kFactor:GC(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:pV(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"})}),ue?.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(Id,{className:"w-2.5 h-2.5 text-bambu-gray"})}),ue?.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"]})}),Qn?s.jsx(BC,{data:Qn,spoolman:{enabled:o,hasUnlinkedSpools:l,onLinkSpool:o&&Qn.trayUuid?jr=>{oe({trayUuid:jr,trayInfo:{type:Qn.profile,color:Qn.colorHex||"",location:`${Ju(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(sV,{configureSlot:{enabled:!0,onConfigure:()=>ge({amsId:ct.id,trayId:yt,trayCount:ct.tray.length})},children:to})]},yt)})})]},ct.id)})}),(gt.length>0||ue.vt_tray&&ue.vt_tray.tray_type)&&s.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[gt.map(ct=>{const Qt=Qe[String(ct.id)],Kt=ct.id>=128?ct.id-128:ct.id,be=Qt!==void 0?Qt: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:qC(yt)?"Bambu Lab":"Generic",profile:$n?.name||ui?.preset_name||yt.tray_sub_brands||yt.tray_type,colorName:HC(yt.tray_id_name)||VC(yt.tray_color),colorHex:yt.tray_color||null,kFactor:GC(yt.k),fillLevel:Xt?yt.remain:null,trayUuid:yt.tray_uuid||null}:null,Qn=yt?.id??0,kr=Un?.amsId===ct.id&&Un?.slotId===Qn,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:pV(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:Ju(ct.id,ct.tray.length)}),Rt&&(ut||It)&&s.jsx(dV,{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"})}),ue?.state!=="RUNNING"&&s.jsx("button",{onClick:jr=>{jr.stopPropagation(),Dt(wt?.amsId===ct.id&&wt?.slotId===Qn?null:{amsId:ct.id,slotId:Qn})},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(Id,{className:"w-2.5 h-2.5 text-bambu-gray"})}),ue?.state!=="RUNNING"&&wt?.amsId===ct.id&&wt?.slotId===Qn&&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:Qn}),Dt(null)},disabled:kr,children:[s.jsx(Ar,{className:`w-3 h-3 ${kr?"animate-spin":""}`}),"Re-read RFID"]})}),vr?s.jsx(BC,{data:vr,spoolman:{enabled:o,hasUnlinkedSpools:l,onLinkSpool:o&&vr.trayUuid?jr=>{oe({trayUuid:jr,trayInfo:{type:vr.profile,color:vr.colorHex||"",location:Ju(ct.id,ct.tray.length)}})}:void 0},configureSlot:{enabled:!0,onConfigure:()=>ge({amsId:ct.id,trayId:Qn,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(sV,{configureSlot:{enabled:!0,onConfigure:()=>ge({amsId:ct.id,trayId:Qn,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(mV,{temp:ct.temp,goodThreshold:a?.tempGood,fairThreshold:a?.tempFair,onClick:()=>he({amsId:ct.id,amsLabel:Ju(ct.id,ct.tray.length),mode:"temperature"}),compact:!0}),ct.humidity!=null&&s.jsx(fV,{humidity:ct.humidity,goodThreshold:a?.humidityGood,fairThreshold:a?.humidityFair,onClick:()=>he({amsId:ct.id,amsLabel:Ju(ct.id,ct.tray.length),mode:"humidity"}),compact:!0})]})]})]},ct.id)}),ue.vt_tray&&ue.vt_tray.tray_type&&(()=>{const ct=ue.vt_tray,Qt=dt===254,Kt=ct.tray_info_idx?Y?.[ct.tray_info_idx]:null,be=pe?.[1020],ut={vendor:qC(ct)?"Bambu Lab":"Generic",profile:Kt?.name||be?.preset_name||ct.tray_sub_brands||ct.tray_type||"Unknown",colorName:HC(ct.tray_id_name)||VC(ct.tray_color),colorHex:ct.tray_color||null,kFactor:GC(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 ${Qt?"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:Qt?"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(BC,{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($f,{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(Su,{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(dN,{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(!ue?.chamber_light),disabled:!ue?.connected||Yt.isPending,title:ue?.chamber_light?"Turn off chamber light":"Turn on chamber light",className:ue?.chamber_light?"bg-yellow-500/20 hover:bg-yellow-500/30 border-yellow-500/30":"",children:s.jsx(RPe,{on:ue?.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:!ue?.connected,title:u==="embedded"?"Open camera overlay":"Open camera in new window",children:s.jsx(HD,{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:Vt,disabled:!ue?.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(Ow,{className:"w-4 h-4"})}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:Jt,disabled:!ue?.connected||H,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:H?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:()=>T(!0),title:"Browse printer files",children:[s.jsx(sN,{className:"w-4 h-4"}),"Files"]})]})]})]}),k&&s.jsx(tpe,{printerId:t.id,printerName:t.name,onClose:()=>T(!1)}),D&&s.jsx(ope,{printerId:t.id,printerName:t.name,onClose:()=>C(!1)}),le&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>He(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:[le.needs_calibration?s.jsx(Ow,{className:"w-5 h-5 text-blue-500"}):le.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"}),le.reference_count!==void 0&&le.max_references&&s.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark-tertiary px-2 py-1 rounded",children:[le.reference_count,"/",le.max_references," refs"]})]}),s.jsx("button",{onClick:()=>He(null),className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:s.jsx(Ht,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[le.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."})]}),le.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 ${le.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 ${le.is_empty?"text-green-400":"text-yellow-400"}`,children:le.is_empty?"Plate appears empty":"Objects detected on plate"}),s.jsxs("p",{className:"text-sm text-bambu-gray mt-1",children:["Confidence: ",Math.round(le.confidence*100),"% | Difference: ",le.difference_percent.toFixed(1),"%"]})]}),le.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:le.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:le.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:fe.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:()=>Ge(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(Ht,{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:()=>Pe(Oe.index,st.label),onKeyDown:gt=>{gt.key==="Enter"&&Pe(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))})]}),!le.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:qe,disabled:Ee,children:Ee?s.jsx(mt,{className:"w-3 h-3 animate-spin"}):"Save"})]}):s.jsxs(Me,{variant:"ghost",size:"sm",onClick:()=>ce(le.roi||{x:.15,y:.35,w:.7,h:.55}),children:[s.jsx(sa,{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((le.roi?.x||.15)*100),"%, Y=",Math.round((le.roi?.y||.35)*100),"%, W=",Math.round((le.roi?.w||.7)*100),"%, H=",Math.round((le.roi?.h||.55)*100),"%"]})]})]}),s.jsx("div",{className:"flex justify-end gap-2 p-4 border-t border-bambu-dark-tertiary",children:le.needs_calibration?s.jsxs(s.Fragment,{children:[s.jsx(Me,{variant:"ghost",onClick:()=>He(null),children:"Cancel"}),s.jsx(Me,{onClick:()=>de(),disabled:K,children:K?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:()=>de(),disabled:K,children:K?"Adding...":`Add Reference (${Ze?.references.length||0}/${Ze?.max_references||5})`}),s.jsx(Me,{onClick:()=>He(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)}),O&&re&&s.jsx(zn,{title:"Power Off Printer",message:ue?.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)}),X&&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(),G(!1)},onCancel:()=>G(!1)}),Z&&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(),te(!1)},onCancel:()=>te(!1)}),ee&&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)}),V&&s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:()=>ne(!1),onKeyDown:Oe=>Oe.key==="Escape"&&ne(!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(cV,{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:()=>ne(!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(Ht,{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(ofe,{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"]})]}),(ue?.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 ",ue?.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:[ue?.cover_url?s.jsx("img",{src:`${ue.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[Qt,Kt,be,ut]=Cn.bbox_all,It=be-Qt,yt=ut-Kt,Xt=8,tr=100-Xt*2;Rt=Xt+(Oe.x-Qt)/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 Qt=Math.ceil(Math.sqrt(Cn.objects.length)),Kt=Math.floor(gt/Qt),be=gt%Qt,ut=Math.ceil(Cn.objects.length/Qt);Rt=15+be*(70/Qt)+35/Qt,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:`
- flex items-center gap-3 px-4 py-3 border-b border-gray-200 dark:border-bambu-dark-tertiary/50 last:border-0
- ${Oe.skipped?"bg-red-50 dark:bg-red-500/10":"hover:bg-gray-50 dark:hover:bg-bambu-dark/50"}
- `,children:[s.jsxs("div",{className:`
- w-12 h-12 flex-shrink-0 rounded-lg flex flex-col items-center justify-center
- ${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"}
- `,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||(ue?.layer_num??0)<=1,className:`px-4 py-2 text-xs font-medium rounded-lg transition-colors ${(ue?.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:(ue?.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(dpe,{printerName:t.name,errors:ue?.hms_errors||[],onClose:()=>W(!1)}),ie&&s.jsx(MPe,{isOpen:!!ie,onClose:()=>he(null),printerId:t.id,printerName:t.name,amsId:ie.amsId,amsLabel:ie.amsLabel,initialMode:ie.mode,thresholds:a}),me&&s.jsx(NPe,{isOpen:!!me,onClose:()=>oe(null),trayUuid:me.trayUuid,trayInfo:me.trayInfo}),Ae&&s.jsx(PPe,{isOpen:!!Ae,onClose:()=>ge(null),printerId:t.id,slotInfo:Ae,onSuccess:()=>{f.invalidateQueries({queryKey:["slotPresets",t.id]}),f.invalidateQueries({queryKey:["printerStatus",t.id]})}}),E&&s.jsx(KPe,{printer:t,onClose:()=>A(!1)}),Ne&&$&&s.jsx(qPe,{printer:t,firmwareInfo:$,onClose:()=>_e(!1)}),wt&&s.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>Dt(null)})]})}function WPe({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),[y,x]=w.useState("192.168.1.0/24"),[v,S]=w.useState({scanned:0,total:0});w.useEffect(()=>{Ml.getInfo().then(T=>{b(T.is_docker)}).catch(()=>{})},[]);const M=l.filter(T=>!n.includes(T.serial)),E=async()=>{d(""),c([]),o(!0),m(!1),S({scanned:0,total:0});try{if(p){await Ml.startSubnetScan(y);const T=setInterval(async()=>{try{const D=await Ml.getScanStatus();S({scanned:D.scanned,total:D.total});const C=await Ml.getDiscoveredPrinters();c(C),D.running||(clearInterval(T),o(!1),m(!0))}catch(D){console.error("Failed to get scan status:",D)}},500)}else{await Ml.startDiscovery(10);const T=setInterval(async()=>{try{const D=await Ml.getDiscoveredPrinters();c(D)}catch(D){console.error("Failed to get discovered printers:",D)}},1e3);setTimeout(async()=>{clearInterval(T);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(T){console.error("Failed to start discovery:",T),d(T instanceof Error?T.message:"Failed to start discovery"),o(!1),m(!0)}},A=T=>T?{O1D:"H2D",O1C:"H2C",O1S:"H2S","BL-P001":"X1C","BL-P002":"X1","BL-P003":"X1E",C11:"P1S",C12:"P1P",C13:"P2S",N2S:"A1",N1:"A1 Mini",X1C:"X1C",X1:"X1",X1E:"X1E",P1S:"P1S",P1P:"P1P",P2S:"P2S",A1:"A1","A1 Mini":"A1 Mini",H2D:"H2D",H2C:"H2C",H2S:"H2S"}[T]||T:"",k=T=>{const D=T.serial.startsWith("unknown-")?"":T.serial;i({...r,name:T.name||"",serial_number:D,ip_address:T.ip_address,model:A(T.model)}),c([])};return w.useEffect(()=>()=>{Ml.stopDiscovery().catch(()=>{}),Ml.stopSubnetScan().catch(()=>{})},[]),w.useEffect(()=>{const T=D=>{D.key==="Escape"&&t()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[t]),s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:t,children:s.jsx(Et,{className:"w-full max-w-md",onClick:T=>T.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:y,onChange:T=>x(T.target.value),placeholder:"192.168.1.0/24",disabled:a}),s.jsxs("p",{className:"mt-1 text-xs text-bambu-gray",children:["Docker detected. Enter your printer's subnet in CIDR notation. Requires ",s.jsx("code",{className:"text-bambu-green",children:"network_mode: host"})," in docker-compose.yml."]})]}),s.jsx(Me,{type:"button",variant:"secondary",onClick:E,disabled:a,className:"w-full",children:a?s.jsxs(s.Fragment,{children:[s.jsx(mt,{className:"w-4 h-4 animate-spin"}),p&&v.total>0?`Scanning... ${v.scanned}/${v.total}`:"Scanning..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Ma,{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(T=>s.jsxs("div",{className:"flex items-center justify-between p-2 bg-bambu-dark rounded-lg hover:bg-bambu-dark-secondary cursor-pointer transition-colors",onClick:()=>k(T),children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"font-medium text-white text-sm truncate",children:T.name||T.serial}),s.jsxs("p",{className:"text-xs text-bambu-gray truncate",children:[A(T.model)||"Unknown"," • ",T.ip_address,T.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"})]},T.serial))}),a&&s.jsx("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:p?"Scanning subnet for Bambu printers...":"Scanning network..."}),f&&!a&&l.length===0&&s.jsxs("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:["No printers found",p?" in the specified subnet":" on the network","."]}),f&&!a&&l.length>0&&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:T=>{T.preventDefault(),e(r)},className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),s.jsx("input",{type:"text",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.name,onChange:T=>i({...r,name:T.target.value}),placeholder:"My Printer"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address"}),s.jsx("input",{type:"text",required:!0,pattern:"\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.ip_address,onChange:T=>i({...r,ip_address:T.target.value}),placeholder:"192.168.1.100"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Serial Number"}),s.jsx("input",{type:"text",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.serial_number,onChange:T=>i({...r,serial_number:T.target.value}),placeholder:"01P00A000000000"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Code"}),s.jsx("input",{type:"password",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.access_code,onChange:T=>i({...r,access_code:T.target.value}),placeholder:"From printer settings"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Model (optional)"}),s.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.model||"",onChange:T=>i({...r,model:T.target.value}),children:[s.jsx("option",{value:"",children:"Select model..."}),s.jsxs("optgroup",{label:"H2 Series",children:[s.jsx("option",{value:"H2C",children:"H2C"}),s.jsx("option",{value:"H2D",children:"H2D"}),s.jsx("option",{value:"H2S",children:"H2S"})]}),s.jsxs("optgroup",{label:"X1 Series",children:[s.jsx("option",{value:"X1E",children:"X1E"}),s.jsx("option",{value:"X1C",children:"X1 Carbon"}),s.jsx("option",{value:"X1",children:"X1"})]}),s.jsxs("optgroup",{label:"P Series",children:[s.jsx("option",{value:"P2S",children:"P2S"}),s.jsx("option",{value:"P1S",children:"P1S"}),s.jsx("option",{value:"P1P",children:"P1P"})]}),s.jsxs("optgroup",{label:"A1 Series",children:[s.jsx("option",{value:"A1",children:"A1"}),s.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"auto_archive",checked:r.auto_archive,onChange:T=>i({...r,auto_archive:T.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsx("label",{htmlFor:"auto_archive",className:"text-sm text-bambu-gray",children:"Auto-archive completed prints"})]}),s.jsxs("div",{className:"flex gap-3 pt-4",children:[s.jsx(Me,{type:"button",variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),s.jsx(Me,{type:"submit",className:"flex-1",children:"Add Printer"})]})]})]})})})}function qPe({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:()=>J1.prepareUpload(t.id),staleTime:3e4}),p=pt({mutationFn:()=>J1.startUpload(t.id),onSuccess:()=>{c(!0);const y=setInterval(async()=>{try{const x=await J1.getUploadStatus(t.id);o(x),(x.status==="complete"||x.status==="error")&&(clearInterval(y),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(y)},onError:y=>{i(`Failed to start upload: ${y.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(Et,{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((y,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"}),y]},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 KPe({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=>fe.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(Et,{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 XPe(t){const{data:e}=ft({queryKey:["printerStatus",t],queryFn:()=>fe.getPrinterStatus(t),refetchInterval:3e4});return!e?.connected}function YPe({printer:t,plug:e,onPowerOn:n,isPowering:r}){const i=XPe(t.id),{data:a}=ft({queryKey:["smartPlugStatus",e.id],queryFn:()=>fe.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(Su,{className:"w-3 h-3"}),r?"...":"On"]})]}):null}function QPe(){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 V=localStorage.getItem("printerCardSize");return V?parseInt(V,10):2}),b=m===1?"compact":"expanded",y=ln(),[x,v]=w.useState(()=>{const V=localStorage.getItem("openEmbeddedCameras");if(V)try{const ne=JSON.parse(V);return new Map(ne.map(ie=>[ie.id,ie]))}catch{return new Map}return new Map});w.useEffect(()=>{const V=Array.from(x.values());V.length>0?localStorage.setItem("openEmbeddedCameras",JSON.stringify(V)):localStorage.removeItem("openEmbeddedCameras")},[x]);const{data:S,isLoading:M}=ft({queryKey:["printers"],queryFn:fe.getPrinters}),{data:E}=ft({queryKey:["settings"],queryFn:fe.getSettings});w.useEffect(()=>{E?.camera_view_mode==="window"&&x.size>0&&v(new Map)},[E?.camera_view_mode,x.size]);const{data:A}=ft({queryKey:["smart-plugs"],queryFn:fe.getSmartPlugs}),{data:k}=ft({queryKey:["maintenanceOverview"],queryFn:fe.getMaintenanceOverview,staleTime:60*1e3}),{data:T}=ft({queryKey:["spoolman-status"],queryFn:fe.getSpoolmanStatus,staleTime:60*1e3}),D=T?.enabled&&T?.connected,{data:C}=ft({queryKey:["unlinked-spools"],queryFn:fe.getUnlinkedSpools,enabled:!!D,staleTime:30*1e3}),R=C&&C.length>0,U=k?.reduce((V,ne)=>(V[ne.printer_id]={due_count:ne.due_count,warning_count:ne.warning_count,total_print_hours:ne.total_print_hours},V),{})||{},O=A?.reduce((V,ne)=>(ne.printer_id&&(V[ne.printer_id]=ne),V),{})||{},q=pt({mutationFn:fe.createPrinter,onSuccess:()=>{y.invalidateQueries({queryKey:["printers"]}),y.invalidateQueries({queryKey:["maintenanceOverview"]}),e(!1)}}),j=pt({mutationFn:V=>fe.controlSmartPlug(V,"on"),onSuccess:()=>{y.invalidateQueries({queryKey:["smart-plugs"]}),l(null)},onError:()=>{l(null)}}),W=()=>{const V=!n;r(V),localStorage.setItem("hideDisconnectedPrinters",String(V))},X=V=>{u(V),localStorage.setItem("printerSortBy",V)},G=()=>{const V=!d;f(V),localStorage.setItem("printerSortAsc",String(V))},Z=()=>{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"}},te=["S","M","L","XL"],ee=w.useMemo(()=>{if(!S)return[];const V=[...S];switch(c){case"name":V.sort((ne,ie)=>ne.name.localeCompare(ie.name));break;case"model":V.sort((ne,ie)=>(ne.model||"").localeCompare(ie.model||""));break;case"location":V.sort((ne,ie)=>{const he=ne.location||"",me=ie.location||"";return!he&&me?1:he&&!me?-1:he.localeCompare(me)||ne.name.localeCompare(ie.name)});break;case"status":V.sort((ne,ie)=>{const he=y.getQueryData(["printerStatus",ne.id]),me=y.getQueryData(["printerStatus",ie.id]),oe=Ae=>Ae?.connected?Ae.state==="RUNNING"?0:1:2;return oe(he)-oe(me)});break}return d||V.reverse(),V},[S,c,d,y]),z=w.useMemo(()=>{if(c!=="location")return null;const V={};return ee.forEach(ne=>{const ie=ne.location||"Ungrouped";V[ie]||(V[ie]=[]),V[ie].push(ne)}),V},[c,ee]);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(GPe,{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:V=>X(V.target.value),className:"text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg px-2 py-1.5 text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"name",children:"Name"}),s.jsx("option",{value:"status",children:"Status"}),s.jsx("option",{value:"model",children:"Model"}),s.jsx("option",{value:"location",children:"Location"})]}),s.jsx("button",{onClick:G,className:"p-1.5 rounded-lg hover:bg-bambu-dark-tertiary transition-colors",title:d?"Sort descending":"Sort ascending",children:d?s.jsx(fg,{className:"w-4 h-4 text-bambu-gray"}):s.jsx(T0,{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:te.map((V,ne)=>{const ie=ne+1,he=m===ie;return s.jsx("button",{onClick:()=>{p(ie),localStorage.setItem("printerCardSize",String(ie))},className:`px-2 py-1.5 text-xs font-medium transition-colors ${ne===0?"rounded-l-lg":""} ${ne===te.length-1?"rounded-r-lg":""} ${he?"bg-bambu-green text-white":"text-bambu-gray hover:bg-bambu-dark-tertiary hover:text-white"}`,title:`${V==="S"?"Small":V==="M"?"Medium":V==="L"?"Large":"Extra large"} cards`,children:V},V)})}),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(O).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(Su,{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(V=>O[V.id]).map(V=>s.jsx(YPe,{printer:V,plug:O[V.id],onPowerOn:ne=>{l(ne),j.mutate(ne)},isPowering:o===O[V.id]?.id},V.id)),S?.filter(V=>O[V.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(Et,{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(([V,ne])=>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"}),V,s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",ne.length,")"]})]}),s.jsx("div",{className:`grid gap-4 ${m>=3?"gap-6":""} ${Z()}`,children:ne.map(ie=>s.jsx(xV,{printer:ie,hideIfDisconnected:n,maintenanceInfo:U[ie.id],viewMode:b,cardSize:m,amsThresholds:E?{humidityGood:Number(E.ams_humidity_good)||40,humidityFair:Number(E.ams_humidity_fair)||60,tempGood:Number(E.ams_temp_good)||28,tempFair:Number(E.ams_temp_fair)||35}:void 0,spoolmanEnabled:D,hasUnlinkedSpools:R,timeFormat:E?.time_format||"system",cameraViewMode:E?.camera_view_mode||"window",onOpenEmbeddedCamera:(he,me)=>v(oe=>new Map(oe).set(he,{id:he,name:me}))},ie.id))})]},V))}):s.jsx("div",{className:`grid gap-4 ${m>=3?"gap-6":""} ${Z()}`,children:ee.map(V=>s.jsx(xV,{printer:V,hideIfDisconnected:n,maintenanceInfo:U[V.id],viewMode:b,cardSize:m,spoolmanEnabled:D,hasUnlinkedSpools:R,amsThresholds:E?{humidityGood:Number(E.ams_humidity_good)||40,humidityFair:Number(E.ams_humidity_fair)||60,tempGood:Number(E.ams_temp_good)||28,tempFair:Number(E.ams_temp_fair)||35}:void 0,timeFormat:E?.time_format||"system",cameraViewMode:E?.camera_view_mode||"window",onOpenEmbeddedCamera:(ne,ie)=>v(he=>new Map(he).set(ne,{id:ne,name:ie}))},V.id))}),t&&s.jsx(WPe,{onClose:()=>e(!1),onAdd:V=>q.mutate(V),existingSerials:S?.map(V=>V.serial_number)||[]}),Array.from(x.values()).map((V,ne)=>s.jsx(spe,{printerId:V.id,printerName:V.name,viewerIndex:ne,onClose:()=>v(ie=>{const he=new Map(ie);return he.delete(V.id),he})},V.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 JPe(){return ZPe()==="windows"?"bambustudio://":"bambustudioopen://"}function Xc(t){const e=JPe();window.location.href=`${e}${encodeURIComponent(t)}`}const X4="182",ig={ROTATE:0,DOLLY:1,PAN:2},Xp={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},e3e=0,bV=1,t3e=2,lw=1,n3e=2,$b=3,eh=0,ws=1,Il=2,su=0,ag=1,yV=2,vV=3,_V=4,r3e=5,ef=100,i3e=101,a3e=102,s3e=103,o3e=104,l3e=200,c3e=201,u3e=202,d3e=203,E3=204,A3=205,h3e=206,f3e=207,m3e=208,p3e=209,g3e=210,x3e=211,b3e=212,y3e=213,v3e=214,T3=0,C3=1,k3=2,Ag=3,j3=4,P3=5,R3=6,D3=7,Y4=0,_3e=1,w3e=2,ql=0,qJ=1,KJ=2,XJ=3,YJ=4,QJ=5,ZJ=6,JJ=7,eee=300,Zf=301,Tg=302,O3=303,L3=304,cE=306,I3=1e3,eu=1001,F3=1002,Na=1003,S3e=1004,P_=1005,Ua=1006,KC=1007,pf=1008,Hs=1009,tee=1010,nee=1011,q0=1012,Q4=1013,rc=1014,$l=1015,vu=1016,Z4=1017,J4=1018,K0=1020,ree=35902,iee=35899,aee=1021,see=1022,nl=1023,_u=1026,gf=1027,oee=1028,eL=1029,Cg=1030,tL=1031,nL=1033,cw=33776,uw=33777,dw=33778,hw=33779,U3=35840,z3=35841,B3=35842,$3=35843,H3=36196,V3=37492,G3=37496,W3=37488,q3=37489,K3=37490,X3=37491,Y3=37808,Q3=37809,Z3=37810,J3=37811,eR=37812,tR=37813,nR=37814,rR=37815,iR=37816,aR=37817,sR=37818,oR=37819,lR=37820,cR=37821,uR=36492,dR=36494,hR=36495,fR=36283,mR=36284,pR=36285,gR=36286,M3e=3200,lee=0,N3e=1,Nd="",vo="srgb",kg="srgb-linear",zS="linear",lr="srgb",ep=7680,wV=519,E3e=512,A3e=513,T3e=514,rL=515,C3e=516,k3e=517,iL=518,j3e=519,SV=35044,MV="300 es",Hl=2e3,BS=2001;function cee(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function $S(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function P3e(){const t=$S("canvas");return t.style.display="block",t}const NV={};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 X0(...t){const e=t.join(" ");e in NV||(NV[e]=!0,un(...t))}function R3e(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 hm=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"],fw=Math.PI/180,xR=180/Math.PI;function Vy(){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 D3e(t,e){return(t%e+e)%e}function XC(t,e,n){return(1-n)*t+n*e}function xb(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 ms(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 O3e={DEG2RAD:fw};let Mn=class uee{constructor(e=0,n=0){uee.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}},Jf=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],y=a[o+3];if(l<=0){e[n+0]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f;return}if(l>=1){e[n+0]=m,e[n+1]=p,e[n+2]=b,e[n+3]=y;return}if(f!==y||c!==m||u!==p||d!==b){let x=c*m+u*p+d*b+f*y;x<0&&(m=-m,p=-p,b=-b,y=-y,x=-x);let v=1-l;if(x<.9995){const S=Math.acos(x),M=Math.sin(S);v=Math.sin(v*S)/M,l=Math.sin(l*S)/M,c=c*v+m*l,u=u*v+p*l,d=d*v+b*l,f=f*v+y*l}else{c=c*v+m*l,u=u*v+p*l,d=d*v+b*l,f=f*v+y*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 dee{constructor(e=0,n=0,r=0){dee.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(AV.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(AV.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 YC.copy(this).projectOnVector(e),this.sub(YC)}reflect(e){return this.sub(YC.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 YC=new nt,AV=new Jf;let En=class hee{constructor(e,n,r,i,a,o,l,c,u){hee.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],y=i[0],x=i[3],v=i[6],S=i[1],M=i[4],E=i[7],A=i[2],k=i[5],T=i[8];return a[0]=o*y+l*S+c*A,a[3]=o*x+l*M+c*k,a[6]=o*v+l*E+c*T,a[1]=u*y+d*S+f*A,a[4]=u*x+d*M+f*k,a[7]=u*v+d*E+f*T,a[2]=m*y+p*S+b*A,a[5]=m*x+p*M+b*k,a[8]=m*v+p*E+b*T,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8];return n*o*d-n*l*u-r*a*d+r*l*c+i*a*u-i*o*c}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=d*o-l*u,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 y=1/b;return e[0]=f*y,e[1]=(i*u-d*r)*y,e[2]=(l*r-i*o)*y,e[3]=m*y,e[4]=(d*n-i*c)*y,e[5]=(i*a-l*n)*y,e[6]=p*y,e[7]=(r*c-u*n)*y,e[8]=(o*n-r*a)*y,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,i,a,o,l){const c=Math.cos(a),u=Math.sin(a);return this.set(r*c,r*u,-r*(c*o+u*l)+o+e,-i*u,i*c,-i*(-u*o+c*l)+l+n,0,0,1),this}scale(e,n){return this.premultiply(QC.makeScale(e,n)),this}rotate(e){return this.premultiply(QC.makeRotation(-e)),this}translate(e,n){return this.premultiply(QC.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 QC=new En,TV=new En().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),CV=new En().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function L3e(){const t={enabled:!0,workingColorSpace:kg,spaces:{},convert:function(i,a,o){return this.enabled===!1||a===o||!a||!o||(this.spaces[a].transfer===lr&&(i.r=ou(i.r),i.g=ou(i.g),i.b=ou(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=sg(i.r),i.g=sg(i.g),i.b=sg(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===Nd?zS: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 X0("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(i,a)},toWorkingColorSpace:function(i,a){return X0("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({[kg]:{primaries:e,whitePoint:r,transfer:zS,toXYZ:TV,fromXYZ:CV,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:vo},outputColorSpaceConfig:{drawingBufferColorSpace:vo}},[vo]:{primaries:e,whitePoint:r,transfer:lr,toXYZ:TV,fromXYZ:CV,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:vo}}}),t}const Vn=L3e();function ou(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function sg(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let tp,I3e=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{tp===void 0&&(tp=$S("canvas")),tp.width=e.width,tp.height=e.height;const i=tp.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),r=tp}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=$S("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]=ou(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(ou(n[r]/255)*255):n[r]=ou(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}},F3e=0,aL=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:F3e++}),this.uuid=Vy(),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?I3e.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 U3e=0;const JC=new nt;let bl=class mw extends hm{constructor(e=mw.DEFAULT_IMAGE,n=mw.DEFAULT_MAPPING,r=eu,i=eu,a=Ua,o=pf,l=nl,c=Hs,u=mw.DEFAULT_ANISOTROPY,d=Nd){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:U3e++}),this.uuid=Vy(),this.name="",this.source=new aL(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 En,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(JC).x}get height(){return this.source.getSize(JC).y}get depth(){return this.source.getSize(JC).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!==eee)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case I3:e.x=e.x-Math.floor(e.x);break;case eu:e.x=e.x<0?0:1;break;case F3: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 I3:e.y=e.y-Math.floor(e.y);break;case eu:e.y=e.y<0?0:1;break;case F3: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=eee;bl.DEFAULT_ANISOTROPY=1;let Mi=class fee{constructor(e=0,n=0,r=0,i=1){fee.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],y=c[2],x=c[6],v=c[10];if(Math.abs(d-m)<.01&&Math.abs(f-y)<.01&&Math.abs(b-x)<.01){if(Math.abs(d+m)<.1&&Math.abs(f+y)<.1&&Math.abs(b+x)<.1&&Math.abs(u+p+v-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const M=(u+1)/2,E=(p+1)/2,A=(v+1)/2,k=(d+m)/4,T=(f+y)/4,D=(b+x)/4;return M>E&&M>A?M<.01?(r=0,i=.707106781,a=.707106781):(r=Math.sqrt(M),i=k/r,a=T/r):E>A?E<.01?(r=.707106781,i=0,a=.707106781):(i=Math.sqrt(E),r=k/i,a=D/i):A<.01?(r=.707106781,i=.707106781,a=0):(a=Math.sqrt(A),r=T/a,i=D/a),this.set(r,i,a,n),this}let S=Math.sqrt((x-b)*(x-b)+(f-y)*(f-y)+(m-d)*(m-d));return Math.abs(S)<.001&&(S=1),this.x=(x-b)/S,this.y=(f-y)/S,this.z=(m-d)/S,this.w=Math.acos((u+p+v-1)/2),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this.w=n[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,n){return this.x=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}},z3e=class extends hm{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 aL(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 z3e{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}},mee=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=Na,this.minFilter=Na,this.wrapR=eu,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},B3e=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=Na,this.minFilter=Na,this.wrapR=eu,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},em=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(Vo.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(Vo.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=Vo.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,Vo):Vo.fromBufferAttribute(a,o),Vo.applyMatrix4(e.matrixWorld),this.expandByPoint(Vo);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),R_.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),R_.copy(r.boundingBox)),R_.applyMatrix4(e.matrixWorld),this.union(R_)}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,Vo),Vo.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(bb),D_.subVectors(this.max,bb),np.subVectors(e.a,bb),rp.subVectors(e.b,bb),ip.subVectors(e.c,bb),ed.subVectors(rp,np),td.subVectors(ip,rp),Ih.subVectors(np,ip);let n=[0,-ed.z,ed.y,0,-td.z,td.y,0,-Ih.z,Ih.y,ed.z,0,-ed.x,td.z,0,-td.x,Ih.z,0,-Ih.x,-ed.y,ed.x,0,-td.y,td.x,0,-Ih.y,Ih.x,0];return!ek(n,np,rp,ip,D_)||(n=[1,0,0,0,1,0,0,0,1],!ek(n,np,rp,ip,D_))?!1:(O_.crossVectors(ed,td),n=[O_.x,O_.y,O_.z],ek(n,np,rp,ip,D_))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Vo).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Vo).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],Vo=new nt,R_=new em,np=new nt,rp=new nt,ip=new nt,ed=new nt,td=new nt,Ih=new nt,bb=new nt,D_=new nt,O_=new nt,Fh=new nt;function ek(t,e,n,r,i){for(let a=0,o=t.length-3;a<=o;a+=3){Fh.fromArray(t,a);const l=i.x*Math.abs(Fh.x)+i.y*Math.abs(Fh.y)+i.z*Math.abs(Fh.z),c=e.dot(Fh),u=n.dot(Fh),d=r.dot(Fh);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>l)return!1}return!0}const $3e=new em,yb=new nt,tk=new nt;let uE=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):$3e.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;yb.subVectors(e,this.center);const n=yb.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(yb,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):(tk.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(yb.copy(e.center).add(tk)),this.expandByPoint(yb.copy(e.center).sub(tk))),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,nk=new nt,L_=new nt,nd=new nt,rk=new nt,I_=new nt,ik=new nt;let sL=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){nk.copy(e).add(n).multiplyScalar(.5),L_.copy(n).sub(e).normalize(),nd.copy(this.origin).sub(nk);const a=e.distanceTo(n)*.5,o=-this.direction.dot(L_),l=nd.dot(this.direction),c=-nd.dot(L_),u=nd.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 y=1/d;f*=y,m*=y,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(nk).addScaledVector(L_,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){rk.subVectors(n,e),I_.subVectors(r,e),ik.crossVectors(rk,I_);let o=this.direction.dot(ik),l;if(o>0){if(i)return null;l=1}else if(o<0)l=-1,o=-o;else return null;nd.subVectors(this.origin,e);const c=l*this.direction.dot(I_.crossVectors(nd,I_));if(c<0)return null;const u=l*this.direction.dot(rk.cross(nd));if(u<0||c+u>o)return null;const d=-l*nd.dot(ik);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 bR{constructor(e,n,r,i,a,o,l,c,u,d,f,m,p,b,y,x){bR.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,y,x)}set(e,n,r,i,a,o,l,c,u,d,f,m,p,b,y,x){const v=this.elements;return v[0]=e,v[4]=n,v[8]=r,v[12]=i,v[1]=a,v[5]=o,v[9]=l,v[13]=c,v[2]=u,v[6]=d,v[10]=f,v[14]=m,v[3]=p,v[7]=b,v[11]=y,v[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 bR().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/ap.setFromMatrixColumn(e,0).length(),a=1/ap.setFromMatrixColumn(e,1).length(),o=1/ap.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,y=l*f;n[0]=c*d,n[4]=-c*f,n[8]=u,n[1]=p+b*u,n[5]=m-y*u,n[9]=-l*c,n[2]=y-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,y=u*f;n[0]=m+y*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]=y+m*l,n[10]=o*c}else if(e.order==="ZXY"){const m=c*d,p=c*f,b=u*d,y=u*f;n[0]=m-y*l,n[4]=-o*f,n[8]=b+p*l,n[1]=p+b*l,n[5]=o*d,n[9]=y-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,y=l*f;n[0]=c*d,n[4]=b*u-p,n[8]=m*u+y,n[1]=c*f,n[5]=y*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,y=l*u;n[0]=c*d,n[4]=y-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-y*f}else if(e.order==="XZY"){const m=o*c,p=o*u,b=l*c,y=l*u;n[0]=c*d,n[4]=-f,n[8]=u*d,n[1]=m*f+y,n[5]=o*d,n[9]=p*f-b,n[2]=b*f-p,n[6]=l*d,n[10]=y*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(H3e,e,V3e)}lookAt(e,n,r){const i=this.elements;return Ls.subVectors(e,n),Ls.lengthSq()===0&&(Ls.z=1),Ls.normalize(),rd.crossVectors(r,Ls),rd.lengthSq()===0&&(Math.abs(r.z)===1?Ls.x+=1e-4:Ls.z+=1e-4,Ls.normalize(),rd.crossVectors(r,Ls)),rd.normalize(),F_.crossVectors(Ls,rd),i[0]=rd.x,i[4]=F_.x,i[8]=Ls.x,i[1]=rd.y,i[5]=F_.y,i[9]=Ls.y,i[2]=rd.z,i[6]=F_.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],y=r[6],x=r[10],v=r[14],S=r[3],M=r[7],E=r[11],A=r[15],k=i[0],T=i[4],D=i[8],C=i[12],R=i[1],U=i[5],O=i[9],q=i[13],j=i[2],W=i[6],X=i[10],G=i[14],Z=i[3],te=i[7],ee=i[11],z=i[15];return a[0]=o*k+l*R+c*j+u*Z,a[4]=o*T+l*U+c*W+u*te,a[8]=o*D+l*O+c*X+u*ee,a[12]=o*C+l*q+c*G+u*z,a[1]=d*k+f*R+m*j+p*Z,a[5]=d*T+f*U+m*W+p*te,a[9]=d*D+f*O+m*X+p*ee,a[13]=d*C+f*q+m*G+p*z,a[2]=b*k+y*R+x*j+v*Z,a[6]=b*T+y*U+x*W+v*te,a[10]=b*D+y*O+x*X+v*ee,a[14]=b*C+y*q+x*G+v*z,a[3]=S*k+M*R+E*j+A*Z,a[7]=S*T+M*U+E*W+A*te,a[11]=S*D+M*O+E*X+A*ee,a[15]=S*C+M*q+E*G+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],y=e[7],x=e[11],v=e[15],S=c*p-u*m,M=l*p-u*f,E=l*m-c*f,A=o*p-u*d,k=o*m-c*d,T=o*f-l*d;return n*(y*S-x*M+v*E)-r*(b*S-x*A+v*k)+i*(b*M-y*A+v*T)-a*(b*E-y*k+x*T)}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],y=e[13],x=e[14],v=e[15],S=f*x*u-y*m*u+y*c*p-l*x*p-f*c*v+l*m*v,M=b*m*u-d*x*u-b*c*p+o*x*p+d*c*v-o*m*v,E=d*y*u-b*f*u+b*l*p-o*y*p-d*l*v+o*f*v,A=b*f*c-d*y*c-b*l*m+o*y*m+d*l*x-o*f*x,k=n*S+r*M+i*E+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 T=1/k;return e[0]=S*T,e[1]=(y*m*a-f*x*a-y*i*p+r*x*p+f*i*v-r*m*v)*T,e[2]=(l*x*a-y*c*a+y*i*u-r*x*u-l*i*v+r*c*v)*T,e[3]=(f*c*a-l*m*a-f*i*u+r*m*u+l*i*p-r*c*p)*T,e[4]=M*T,e[5]=(d*x*a-b*m*a+b*i*p-n*x*p-d*i*v+n*m*v)*T,e[6]=(b*c*a-o*x*a-b*i*u+n*x*u+o*i*v-n*c*v)*T,e[7]=(o*m*a-d*c*a+d*i*u-n*m*u-o*i*p+n*c*p)*T,e[8]=E*T,e[9]=(b*f*a-d*y*a-b*r*p+n*y*p+d*r*v-n*f*v)*T,e[10]=(o*y*a-b*l*a+b*r*u-n*y*u-o*r*v+n*l*v)*T,e[11]=(d*l*a-o*f*a-d*r*u+n*f*u+o*r*p-n*l*p)*T,e[12]=A*T,e[13]=(d*y*i-b*f*i+b*r*m-n*y*m-d*r*x+n*f*x)*T,e[14]=(b*l*i-o*y*i-b*r*c+n*y*c+o*r*x-n*l*x)*T,e[15]=(o*f*i-d*l*i+d*r*c-n*f*c-o*r*m+n*l*m)*T,this}scale(e){const n=this.elements,r=e.x,i=e.y,a=e.z;return n[0]*=r,n[4]*=i,n[8]*=a,n[1]*=r,n[5]*=i,n[9]*=a,n[2]*=r,n[6]*=i,n[10]*=a,n[3]*=r,n[7]*=i,n[11]*=a,this}getMaxScaleOnAxis(){const e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,r,i))}makeTranslation(e,n,r){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,n,0,0,1,r,0,0,0,1),this}makeRotationX(e){const n=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,n,-r,0,0,r,n,0,0,0,0,1),this}makeRotationY(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,0,r,0,0,1,0,0,-r,0,n,0,0,0,0,1),this}makeRotationZ(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,0,r,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){const r=Math.cos(n),i=Math.sin(n),a=1-r,o=e.x,l=e.y,c=e.z,u=a*o,d=a*l;return this.set(u*o+r,u*l-i*c,u*c+i*l,0,u*l+i*c,d*l+r,d*c-i*o,0,u*c-i*l,d*c+i*o,a*c*c+r,0,0,0,0,1),this}makeScale(e,n,r){return this.set(e,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,n,r,i,a,o){return this.set(1,r,a,0,e,1,o,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,a=n._x,o=n._y,l=n._z,c=n._w,u=a+a,d=o+o,f=l+l,m=a*u,p=a*d,b=a*f,y=o*d,x=o*f,v=l*f,S=c*u,M=c*d,E=c*f,A=r.x,k=r.y,T=r.z;return i[0]=(1-(y+v))*A,i[1]=(p+E)*A,i[2]=(b-M)*A,i[3]=0,i[4]=(p-E)*k,i[5]=(1-(m+v))*k,i[6]=(x+S)*k,i[7]=0,i[8]=(b+M)*T,i[9]=(x-S)*T,i[10]=(1-(m+y))*T,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,n,r){const i=this.elements;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=ap.set(i[0],i[1],i[2]).length();const o=ap.set(i[4],i[5],i[6]).length(),l=ap.set(i[8],i[9],i[10]).length();this.determinant()<0&&(a=-a),Go.copy(this);const u=1/a,d=1/o,f=1/l;return Go.elements[0]*=u,Go.elements[1]*=u,Go.elements[2]*=u,Go.elements[4]*=d,Go.elements[5]*=d,Go.elements[6]*=d,Go.elements[8]*=f,Go.elements[9]*=f,Go.elements[10]*=f,n.setFromRotationMatrix(Go),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,y;if(c)b=a/(o-a),y=o*a/(o-a);else if(l===Hl)b=-(o+a)/(o-a),y=-2*o*a/(o-a);else if(l===BS)b=-o/(o-a),y=-o*a/(o-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+l);return u[0]=d,u[4]=0,u[8]=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]=y,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,y;if(c)b=1/(o-a),y=o/(o-a);else if(l===Hl)b=-2/(o-a),y=-(o+a)/(o-a);else if(l===BS)b=-1/(o-a),y=-a/(o-a);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+l);return u[0]=d,u[4]=0,u[8]=0,u[12]=m,u[1]=0,u[5]=f,u[9]=0,u[13]=p,u[2]=0,u[6]=0,u[10]=b,u[14]=y,u[3]=0,u[7]=0,u[11]=0,u[15]=1,this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<16;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<16;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e[n+9]=r[9],e[n+10]=r[10],e[n+11]=r[11],e[n+12]=r[12],e[n+13]=r[13],e[n+14]=r[14],e[n+15]=r[15],e}};const ap=new nt,Go=new mi,H3e=new nt(0,0,0),V3e=new nt(1,1,1),rd=new nt,F_=new nt,Ls=new nt,kV=new mi,jV=new Jf;let th=class pee{constructor(e=0,n=0,r=0,i=pee.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 kV.makeRotationFromQuaternion(e),this.setFromRotationMatrix(kV,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return jV.setFromEuler(this),this.setFromQuaternion(jV,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}};th.DEFAULT_ORDER="XYZ";let gee=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}},G3e=0;const PV=new nt,sp=new Jf,Pc=new mi,U_=new nt,vb=new nt,W3e=new nt,q3e=new Jf,RV=new nt(1,0,0),DV=new nt(0,1,0),OV=new nt(0,0,1),LV={type:"added"},K3e={type:"removed"},op={type:"childadded",child:null},ak={type:"childremoved",child:null};let Js=class pw extends hm{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:G3e++}),this.uuid=Vy(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=pw.DEFAULT_UP.clone();const e=new nt,n=new th,r=new Jf,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 En}}),this.matrix=new mi,this.matrixWorld=new mi,this.matrixAutoUpdate=pw.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=pw.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new gee,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 sp.setFromAxisAngle(e,n),this.quaternion.multiply(sp),this}rotateOnWorldAxis(e,n){return sp.setFromAxisAngle(e,n),this.quaternion.premultiply(sp),this}rotateX(e){return this.rotateOnAxis(RV,e)}rotateY(e){return this.rotateOnAxis(DV,e)}rotateZ(e){return this.rotateOnAxis(OV,e)}translateOnAxis(e,n){return PV.copy(e).applyQuaternion(this.quaternion),this.position.add(PV.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(RV,e)}translateY(e){return this.translateOnAxis(DV,e)}translateZ(e){return this.translateOnAxis(OV,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?U_.copy(e):U_.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),vb.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Pc.lookAt(vb,U_,this.up):Pc.lookAt(U_,vb,this.up),this.quaternion.setFromRotationMatrix(Pc),i&&(Pc.extractRotation(i.matrixWorld),sp.setFromRotationMatrix(Pc),this.quaternion.premultiply(sp.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(LV),op.child=e,this.dispatchEvent(op),op.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(K3e),ak.child=e,this.dispatchEvent(ak),ak.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(LV),op.child=e,this.dispatchEvent(op),op.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(vb,e,W3e),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(vb,q3e,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 Wo=new nt,Rc=new nt,sk=new nt,Dc=new nt,lp=new nt,cp=new nt,IV=new nt,ok=new nt,lk=new nt,ck=new nt,uk=new Mi,dk=new Mi,hk=new Mi;let _b=class Bp{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),Wo.subVectors(e,n),i.cross(Wo);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){Wo.subVectors(i,n),Rc.subVectors(r,n),sk.subVectors(e,n);const o=Wo.dot(Wo),l=Wo.dot(Rc),c=Wo.dot(sk),u=Rc.dot(Rc),d=Rc.dot(sk),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 uk.setScalar(0),dk.setScalar(0),hk.setScalar(0),uk.fromBufferAttribute(e,n),dk.fromBufferAttribute(e,r),hk.fromBufferAttribute(e,i),o.setScalar(0),o.addScaledVector(uk,a.x),o.addScaledVector(dk,a.y),o.addScaledVector(hk,a.z),o}static isFrontFacing(e,n,r,i){return Wo.subVectors(r,n),Rc.subVectors(e,n),Wo.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 Wo.subVectors(this.c,this.b),Rc.subVectors(this.a,this.b),Wo.cross(Rc).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Bp.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return Bp.getBarycoord(e,this.a,this.b,this.c,n)}getInterpolation(e,n,r,i,a){return Bp.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}containsPoint(e){return Bp.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Bp.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;lp.subVectors(i,r),cp.subVectors(a,r),ok.subVectors(e,r);const c=lp.dot(ok),u=cp.dot(ok);if(c<=0&&u<=0)return n.copy(r);lk.subVectors(e,i);const d=lp.dot(lk),f=cp.dot(lk);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(lp,o);ck.subVectors(e,a);const p=lp.dot(ck),b=cp.dot(ck);if(b>=0&&p<=b)return n.copy(a);const y=p*u-c*b;if(y<=0&&u>=0&&b<=0)return l=u/(u-b),n.copy(r).addScaledVector(cp,l);const x=d*b-p*f;if(x<=0&&f-d>=0&&p-b>=0)return IV.subVectors(a,i),l=(f-d)/(f-d+(p-b)),n.copy(i).addScaledVector(IV,l);const v=1/(x+y+m);return o=y*v,l=m*v,n.copy(r).addScaledVector(lp,o).addScaledVector(cp,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};const xee={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},id={h:0,s:0,l:0},z_={h:0,s:0,l:0};function fk(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=D3e(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=fk(o,a,e+1/3),this.g=fk(o,a,e),this.b=fk(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=xee[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=ou(e.r),this.g=ou(e.g),this.b=ou(e.b),this}copyLinearToSRGB(e){return this.r=sg(e.r),this.g=sg(e.g),this.b=sg(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(id),this.setHSL(id.h+e,id.s+n,id.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(id),e.getHSL(z_);const r=XC(id.h,z_.h,n),i=XC(id.s,z_.s,n),a=XC(id.l,z_.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=xee;let X3e=0,cx=class extends hm{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:X3e++}),this.uuid=Vy(),this.name="",this.type="Material",this.blending=ag,this.side=eh,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=E3,this.blendDst=A3,this.blendEquation=ef,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Rn(0,0,0),this.blendAlpha=0,this.depthFunc=Ag,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=wV,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=ep,this.stencilZFail=ep,this.stencilZPass=ep,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!==ag&&(r.blending=this.blending),this.side!==eh&&(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!==A3&&(r.blendDst=this.blendDst),this.blendEquation!==ef&&(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!==Ag&&(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!==wV&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==ep&&(r.stencilFail=this.stencilFail),this.stencilZFail!==ep&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==ep&&(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++}},oL=class extends cx{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 th,this.combine=Y4,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,B_=new Mn;let Y3e=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:Y3e++}),this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=r,this.usage=SV,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++)B_.fromBufferAttribute(this,n),B_.applyMatrix3(e),this.setXY(n,B_.x,B_.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=xb(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=ms(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=xb(n,this.array)),n}setX(e,n){return this.normalized&&(n=ms(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=xb(n,this.array)),n}setY(e,n){return this.normalized&&(n=ms(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=xb(n,this.array)),n}setZ(e,n){return this.normalized&&(n=ms(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=xb(n,this.array)),n}setW(e,n){return this.normalized&&(n=ms(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=ms(n,this.array),r=ms(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=ms(n,this.array),r=ms(r,this.array),i=ms(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=ms(n,this.array),r=ms(r,this.array),i=ms(i,this.array),a=ms(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!==SV&&(e.usage=this.usage),e}},bee=class extends Co{constructor(e,n,r){super(new Uint16Array(e),n,r)}},yee=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)}},Q3e=0;const fo=new mi,mk=new Js,up=new nt,Is=new em,wb=new em,Wi=new nt;let yl=class vee extends hm{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Q3e++}),this.uuid=Vy(),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(cee(e)?yee:bee)(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 En().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 mk.lookAt(e),mk.updateMatrix(),this.applyMatrix4(mk.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(up).negate(),this.translate(up.x,up.y,up.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 em);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 uE);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];wb.setFromBufferAttribute(l),this.morphTargetsRelative?(Wi.addVectors(Is.min,wb.min),Is.expandByPoint(Wi),Wi.addVectors(Is.max,wb.max),Is.expandByPoint(Wi)):(Is.expandByPoint(wb.min),Is.expandByPoint(wb.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&&(up.fromBufferAttribute(e,u),Wi.add(up)),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,y=new nt,x=new nt;function v(D,C,R){u.fromBufferAttribute(r,D),d.fromBufferAttribute(r,C),f.fromBufferAttribute(r,R),m.fromBufferAttribute(a,D),p.fromBufferAttribute(a,C),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)&&(y.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(y),l[C].add(y),l[R].add(y),c[D].add(x),c[C].add(x),c[R].add(x))}let S=this.groups;S.length===0&&(S=[{start:0,count:e.count}]);for(let D=0,C=S.length;D<C;++D){const R=S[D],U=R.start,O=R.count;for(let q=U,j=U+O;q<j;q+=3)v(e.getX(q+0),e.getX(q+1),e.getX(q+2))}const M=new nt,E=new nt,A=new nt,k=new nt;function T(D){A.fromBufferAttribute(i,D),k.copy(A);const C=l[D];M.copy(C),M.sub(A.multiplyScalar(A.dot(C))).normalize(),E.crossVectors(k,C);const U=E.dot(c[D])<0?-1:1;o.setXYZW(D,M.x,M.y,M.z,U)}for(let D=0,C=S.length;D<C;++D){const R=S[D],U=R.start,O=R.count;for(let q=U,j=U+O;q<j;q+=3)T(e.getX(q+0)),T(e.getX(q+1)),T(e.getX(q+2))}}computeVertexNormals(){const e=this.index,n=this.getAttribute("position");if(n!==void 0){let r=this.getAttribute("normal");if(r===void 0)r=new 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),y=e.getX(m+1),x=e.getX(m+2);i.fromBufferAttribute(n,b),a.fromBufferAttribute(n,y),o.fromBufferAttribute(n,x),d.subVectors(o,a),f.subVectors(i,a),d.cross(f),l.fromBufferAttribute(r,b),c.fromBufferAttribute(r,y),u.fromBufferAttribute(r,x),l.add(d),c.add(d),u.add(d),r.setXYZ(b,l.x,l.y,l.z),r.setXYZ(y,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 y=0,x=c.length;y<x;y++){l.isInterleavedBufferAttribute?p=c[y]*l.data.stride+l.offset:p=c[y]*d;for(let v=0;v<d;v++)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 vee,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 FV=new mi,Uh=new sL,$_=new uE,UV=new nt,H_=new nt,V_=new nt,G_=new nt,pk=new nt,W_=new nt,zV=new nt,q_=new nt;let hl=class extends Js{constructor(e=new yl,n=new oL){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){W_.set(0,0,0);for(let c=0,u=a.length;c<u;c++){const d=l[c],f=a[c];d!==0&&(pk.fromBufferAttribute(f,e),o?W_.addScaledVector(pk,d):W_.addScaledVector(pk.sub(n),d))}n.add(W_)}return n}raycast(e,n){const r=this.geometry,i=this.material,a=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),$_.copy(r.boundingSphere),$_.applyMatrix4(a),Uh.copy(e.ray).recast(e.near),!($_.containsPoint(Uh.origin)===!1&&(Uh.intersectSphere($_,UV)===null||Uh.origin.distanceToSquared(UV)>(e.far-e.near)**2))&&(FV.copy(a).invert(),Uh.copy(e.ray).applyMatrix4(FV),!(r.boundingBox!==null&&Uh.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,Uh)))}_computeIntersections(e,n,r){let i;const a=this.geometry,o=this.material,l=a.index,c=a.attributes.position,u=a.attributes.uv,d=a.attributes.uv1,f=a.attributes.normal,m=a.groups,p=a.drawRange;if(l!==null)if(Array.isArray(o))for(let b=0,y=m.length;b<y;b++){const x=m[b],v=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 E=S,A=M;E<A;E+=3){const k=l.getX(E),T=l.getX(E+1),D=l.getX(E+2);i=K_(this,v,e,r,u,d,f,k,T,D),i&&(i.faceIndex=Math.floor(E/3),i.face.materialIndex=x.materialIndex,n.push(i))}}else{const b=Math.max(0,p.start),y=Math.min(l.count,p.start+p.count);for(let x=b,v=y;x<v;x+=3){const S=l.getX(x),M=l.getX(x+1),E=l.getX(x+2);i=K_(this,o,e,r,u,d,f,S,M,E),i&&(i.faceIndex=Math.floor(x/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(o))for(let b=0,y=m.length;b<y;b++){const x=m[b],v=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 E=S,A=M;E<A;E+=3){const k=E,T=E+1,D=E+2;i=K_(this,v,e,r,u,d,f,k,T,D),i&&(i.faceIndex=Math.floor(E/3),i.face.materialIndex=x.materialIndex,n.push(i))}}else{const b=Math.max(0,p.start),y=Math.min(c.count,p.start+p.count);for(let x=b,v=y;x<v;x+=3){const S=x,M=x+1,E=x+2;i=K_(this,o,e,r,u,d,f,S,M,E),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===ws?c=r.intersectTriangle(o,a,i,!0,l):c=r.intersectTriangle(i,a,o,e.side===eh,l),c===null)return null;q_.copy(l),q_.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(q_);return u<n.near||u>n.far?null:{distance:u,point:q_.clone(),object:t}}function K_(t,e,n,r,i,a,o,l,c,u){t.getVertexPosition(l,H_),t.getVertexPosition(c,V_),t.getVertexPosition(u,G_);const d=Z3e(t,e,n,r,H_,V_,G_,zV);if(d){const f=new nt;_b.getBarycoord(zV,H_,V_,G_,f),i&&(d.uv=_b.getInterpolatedAttribute(i,l,c,u,f,new Mn)),a&&(d.uv1=_b.getInterpolatedAttribute(a,l,c,u,f,new Mn)),o&&(d.normal=_b.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};_b.getNormal(H_,V_,G_,m.normal),d.face=m,d.barycoord=f}return d}let lL=class _ee 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(y,x,v,S,M,E,A,k,T,D,C){const R=E/T,U=A/D,O=E/2,q=A/2,j=k/2,W=T+1,X=D+1;let G=0,Z=0;const te=new nt;for(let ee=0;ee<X;ee++){const z=ee*U-q;for(let V=0;V<W;V++){const ne=V*R-O;te[y]=ne*S,te[x]=z*M,te[v]=j,u.push(te.x,te.y,te.z),te[y]=0,te[x]=0,te[v]=k>0?1:-1,d.push(te.x,te.y,te.z),f.push(V/T),f.push(1-ee/D),G+=1}}for(let ee=0;ee<D;ee++)for(let z=0;z<T;z++){const V=m+z+W*ee,ne=m+z+W*(ee+1),ie=m+(z+1)+W*(ee+1),he=m+(z+1)+W*ee;c.push(V,ne,he),c.push(ne,ie,he),Z+=6}l.addGroup(p,Z,C),p+=Z,m+=G}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new _ee(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function jg(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=jg(t[n]);for(const i in r)e[i]=r[i]}return e}function J3e(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function wee(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Vn.workingColorSpace}const eRe={clone:jg,merge:qa};var tRe=`void main() {
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
- }`,nRe=`void main() {
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
- }`;let ic=class extends cx{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=tRe,this.fragmentShader=nRe,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=jg(e.uniforms),this.uniformsGroups=J3e(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}},See=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 ad=new nt,BV=new Mn,$V=new Mn;let So=class extends See{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=xR*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(fw*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return xR*2*Math.atan(Math.tan(fw*.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){ad.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(ad.x,ad.y).multiplyScalar(-e/ad.z),ad.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),r.set(ad.x,ad.y).multiplyScalar(-e/ad.z)}getViewSize(e,n){return this.getViewBounds(e,BV,$V),n.subVectors($V,BV)}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(fw*.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 dp=-90,hp=1;let rRe=class extends Js{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new So(dp,hp,e,n);i.layers=this.layers,this.add(i);const a=new So(dp,hp,e,n);a.layers=this.layers,this.add(a);const o=new So(dp,hp,e,n);o.layers=this.layers,this.add(o);const l=new So(dp,hp,e,n);l.layers=this.layers,this.add(l);const c=new So(dp,hp,e,n);c.layers=this.layers,this.add(c);const u=new So(dp,hp,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===BS)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 y=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(n,a),e.setRenderTarget(r,1,i),e.render(n,o),e.setRenderTarget(r,2,i),e.render(n,l),e.setRenderTarget(r,3,i),e.render(n,c),e.setRenderTarget(r,4,i),e.render(n,u),r.texture.generateMipmaps=y,e.setRenderTarget(r,5,i),e.render(n,d),e.setRenderTarget(f,m,p),e.xr.enabled=b,r.texture.needsPMREMUpdate=!0}},Mee=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}},Nee=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 Mee(i),this._setTextureOptions(n),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,n){this.texture.type=n.type,this.texture.colorSpace=n.colorSpace,this.texture.generateMipmaps=n.generateMipmaps,this.texture.minFilter=n.minFilter,this.texture.magFilter=n.magFilter;const r={uniforms:{tEquirect:{value:null}},vertexShader:`
- varying vec3 vWorldDirection;
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
- }
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }
- `,fragmentShader:`
- uniform sampler2D tEquirect;
- varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vec3 direction = normalize( vWorldDirection );
- vec2 sampleUV = equirectUv( direction );
- gl_FragColor = texture2D( tEquirect, sampleUV );
- }
- `},i=new lL(5,5,5),a=new ic({name:"CubemapFromEquirect",uniforms:jg(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:ws,blending:su});a.uniforms.tEquirect.value=n;const o=new hl(i,a),l=n.minFilter;return n.minFilter===pf&&(n.minFilter=Ua),new rRe(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)}},Hb=class extends Js{constructor(){super(),this.isGroup=!0,this.type="Group"}};const iRe={type:"move"};let gk=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Hb,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 Hb,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 Hb,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 y of e.hand.values()){const x=n.getJointPose(y,r),v=this._getHandJoint(u,y);x!==null&&(v.matrix.fromArray(x.transform.matrix),v.matrix.decompose(v.position,v.rotation,v.scale),v.matrixWorldNeedsUpdate=!0,v.jointRadius=x.radius),v.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(iRe)))}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 Hb;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}},aRe=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 th,this.environmentIntensity=1,this.environmentRotation=new th,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}},sRe=class extends bl{constructor(e=null,n=1,r=1,i,a,o,l,c,u=Na,d=Na,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 xk=new nt,oRe=new nt,lRe=new En;let bd=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=xk.subVectors(r,n).cross(oRe.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||lRe.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 zh=new uE,cRe=new Mn(.5,.5),X_=new nt;let cL=class{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=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],y=a[9],x=a[10],v=a[11],S=a[12],M=a[13],E=a[14],A=a[15];if(i[0].setComponents(u-o,p-d,v-b,A-S).normalize(),i[1].setComponents(u+o,p+d,v+b,A+S).normalize(),i[2].setComponents(u+l,p+f,v+y,A+M).normalize(),i[3].setComponents(u-l,p-f,v-y,A-M).normalize(),r)i[4].setComponents(c,m,x,E).normalize(),i[5].setComponents(u-c,p-m,v-x,A-E).normalize();else if(i[4].setComponents(u-c,p-m,v-x,A-E).normalize(),n===Hl)i[5].setComponents(u+c,p+m,v+x,A+E).normalize();else if(n===BS)i[5].setComponents(c,m,x,E).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(),zh.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),zh.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(zh)}intersectsSprite(e){zh.center.set(0,0,0);const n=cRe.distanceTo(e.center);return zh.radius=.7071067811865476+n,zh.applyMatrix4(e.matrixWorld),this.intersectsSphere(zh)}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(X_.x=i.normal.x>0?e.max.x:e.min.x,X_.y=i.normal.y>0?e.max.y:e.min.y,X_.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(X_)<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 cx{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 HS=new nt,VS=new nt,HV=new mi,Sb=new sL,Y_=new uE,bk=new nt,VV=new nt;let uRe=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++)HS.fromBufferAttribute(n,i-1),VS.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=HS.distanceTo(VS);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(),Y_.copy(r.boundingSphere),Y_.applyMatrix4(i),Y_.radius+=a,e.ray.intersectsSphere(Y_)===!1)return;HV.copy(i).invert(),Sb.copy(e.ray).applyMatrix4(HV);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 y=p,x=b-1;y<x;y+=u){const v=d.getX(y),S=d.getX(y+1),M=Q_(this,e,Sb,c,v,S,y);M&&n.push(M)}if(this.isLineLoop){const y=d.getX(b-1),x=d.getX(p),v=Q_(this,e,Sb,c,y,x,b-1);v&&n.push(v)}}else{const p=Math.max(0,o.start),b=Math.min(m.count,o.start+o.count);for(let y=p,x=b-1;y<x;y+=u){const v=Q_(this,e,Sb,c,y,y+1,y);v&&n.push(v)}if(this.isLineLoop){const y=Q_(this,e,Sb,c,b-1,p,b-1);y&&n.push(y)}}}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,o=i.length;a<o;a++){const l=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=a}}}}};function Q_(t,e,n,r,i,a,o){const l=t.geometry.attributes.position;if(HS.fromBufferAttribute(l,i),VS.fromBufferAttribute(l,a),n.distanceSqToSegment(HS,VS,bk,VV)>r)return;bk.applyMatrix4(t.matrixWorld);const u=e.ray.origin.distanceTo(bk);if(!(u<e.near||u>e.far))return{distance:u,point:VV.clone().applyMatrix4(t.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:t}}const GV=new nt,WV=new nt;let dRe=class extends uRe{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)GV.fromBufferAttribute(n,i),WV.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+GV.distanceTo(WV);e.setAttribute("lineDistance",new Ks(r,1))}else un("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},Y0=class extends bl{constructor(e,n,r=rc,i,a,o,l=Na,c=Na,u,d=_u,f=1){if(d!==_u&&d!==gf)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 aL(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 hRe extends Y0{constructor(e,n=rc,r=Zf,i,a,o=Na,l=Na,c,u=_u){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 Aee extends bl{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}let uL=class Tee 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=[],y=[],x=[];for(let v=0;v<d;v++){const S=v*m-o;for(let M=0;M<u;M++){const E=M*f-a;b.push(E,-S,0),y.push(0,0,1),x.push(M/l),x.push(1-v/c)}}for(let v=0;v<c;v++)for(let S=0;S<l;S++){const M=S+u*v,E=S+u*(v+1),A=S+1+u*(v+1),k=S+1+u*v;p.push(M,E,k),p.push(E,A,k)}this.setIndex(p),this.setAttribute("position",new Ks(b,3)),this.setAttribute("normal",new Ks(y,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 Tee(e.width,e.height,e.widthSegments,e.heightSegments)}};class fRe extends ic{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class mRe extends cx{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=lee,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 th,this.combine=Y4,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 pRe=class extends cx{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=M3e,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}},gRe=class extends cx{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}},Cee=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 yk=new mi,qV=new nt,KV=new nt;let xRe=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 cL,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;qV.setFromMatrixPosition(e.matrixWorld),n.position.copy(qV),KV.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(KV),n.updateMatrixWorld(),yk.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(yk,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(yk)}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}},dL=class extends See{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 bRe extends xRe{constructor(){super(new dL(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class XV extends Cee{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 bRe}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 yRe=class extends Cee{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}},vRe=class extends So{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},YV=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 _Re extends dRe{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 y=m===a?r:i;y.toArray(u,p),p+=3,y.toArray(u,p),p+=3,y.toArray(u,p),p+=3,y.toArray(u,p),p+=3}const d=new 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 wRe extends hm{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 QV(t,e,n,r){const i=SRe(r);switch(n){case aee:return t*e;case oee:return t*e/i.components*i.byteLength;case eL:return t*e/i.components*i.byteLength;case Cg:return t*e*2/i.components*i.byteLength;case tL:return t*e*2/i.components*i.byteLength;case see:return t*e*3/i.components*i.byteLength;case nl:return t*e*4/i.components*i.byteLength;case nL:return t*e*4/i.components*i.byteLength;case cw:case uw:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case dw:case hw:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case z3:case $3:return Math.max(t,16)*Math.max(e,8)/4;case U3:case B3:return Math.max(t,8)*Math.max(e,8)/2;case H3:case V3:case W3:case q3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case G3:case K3:case X3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case Y3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case Q3: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 J3:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case eR:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case tR:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case nR:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case rR:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case iR:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case aR:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case sR:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case oR:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case lR:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case cR:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case uR:case dR:case hR:return Math.ceil(t/4)*Math.ceil(e/4)*16;case fR:case mR:return Math.ceil(t/4)*Math.ceil(e/4)*8;case pR:case gR:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}function SRe(t){switch(t){case Hs:case tee:return{byteLength:1,components:1};case q0:case nee:case vu:return{byteLength:2,components:1};case Z4:case J4:return{byteLength:2,components:4};case rc:case Q4:case $l:return{byteLength:4,components:1};case ree:case iee:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:X4}}));typeof window<"u"&&(window.__THREE__?un("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=X4);function kee(){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 MRe(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],y=f[p];y.start<=b.start+b.count+1?b.count=Math.max(b.count,y.start+y.count-b.start):(++m,f[m]=y)}f.length=m+1;for(let p=0,b=f.length;p<b;p++){const y=f[p];t.bufferSubData(u,y.start*d.BYTES_PER_ELEMENT,d,y.start,y.count)}c.clearUpdateRanges()}c.onUploadCallback()}function i(l){return l.isInterleavedBufferAttribute&&(l=l.data),e.get(l)}function a(l){l.isInterleavedBufferAttribute&&(l=l.data);const c=e.get(l);c&&(t.deleteBuffer(c.buffer),e.delete(l))}function o(l,c){if(l.isInterleavedBufferAttribute&&(l=l.data),l.isGLBufferAttribute){const d=e.get(l);(!d||d.version<l.version)&&e.set(l,{buffer:l.buffer,type:l.type,bytesPerElement:l.elementSize,version:l.version});return}const u=e.get(l);if(u===void 0)e.set(l,n(l,c));else if(u.version<l.version){if(u.size!==l.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");r(u.buffer,l,c),u.version=l.version}}return{get:i,remove:a,update:o}}var NRe=`#ifdef USE_ALPHAHASH
- if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
- #endif`,ERe=`#ifdef USE_ALPHAHASH
- const float ALPHA_HASH_SCALE = 0.05;
- float hash2D( vec2 value ) {
- return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
- }
- float hash3D( vec3 value ) {
- return hash2D( vec2( hash2D( value.xy ), value.z ) );
- }
- float getAlphaHashThreshold( vec3 position ) {
- float maxDeriv = max(
- length( dFdx( position.xyz ) ),
- length( dFdy( position.xyz ) )
- );
- float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
- vec2 pixScales = vec2(
- exp2( floor( log2( pixScale ) ) ),
- exp2( ceil( log2( pixScale ) ) )
- );
- vec2 alpha = vec2(
- hash3D( floor( pixScales.x * position.xyz ) ),
- hash3D( floor( pixScales.y * position.xyz ) )
- );
- float lerpFactor = fract( log2( pixScale ) );
- float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
- float a = min( lerpFactor, 1.0 - lerpFactor );
- vec3 cases = vec3(
- x * x / ( 2.0 * a * ( 1.0 - a ) ),
- ( x - 0.5 * a ) / ( 1.0 - a ),
- 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
- );
- float threshold = ( x < ( 1.0 - a ) )
- ? ( ( x < a ) ? cases.x : cases.y )
- : cases.z;
- return clamp( threshold , 1.0e-6, 1.0 );
- }
- #endif`,ARe=`#ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
- #endif`,TRe=`#ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,CRe=`#ifdef USE_ALPHATEST
- #ifdef ALPHA_TO_COVERAGE
- diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
- if ( diffuseColor.a == 0.0 ) discard;
- #else
- if ( diffuseColor.a < alphaTest ) discard;
- #endif
- #endif`,kRe=`#ifdef USE_ALPHATEST
- uniform float alphaTest;
- #endif`,jRe=`#ifdef USE_AOMAP
- float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
- reflectedLight.indirectDiffuse *= ambientOcclusion;
- #if defined( USE_CLEARCOAT )
- clearcoatSpecularIndirect *= ambientOcclusion;
- #endif
- #if defined( USE_SHEEN )
- sheenSpecularIndirect *= ambientOcclusion;
- #endif
- #if defined( USE_ENVMAP ) && defined( STANDARD )
- float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
- reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
- #endif
- #endif`,PRe=`#ifdef USE_AOMAP
- uniform sampler2D aoMap;
- uniform float aoMapIntensity;
- #endif`,RRe=`#ifdef USE_BATCHING
- #if ! defined( GL_ANGLE_multi_draw )
- #define gl_DrawID _gl_DrawID
- uniform int _gl_DrawID;
- #endif
- uniform highp sampler2D batchingTexture;
- uniform highp usampler2D batchingIdTexture;
- mat4 getBatchingMatrix( const in float i ) {
- int size = textureSize( batchingTexture, 0 ).x;
- int j = int( i ) * 4;
- int x = j % size;
- int y = j / size;
- vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
- vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
- vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
- vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
- return mat4( v1, v2, v3, v4 );
- }
- float getIndirectIndex( const in int i ) {
- int size = textureSize( batchingIdTexture, 0 ).x;
- int x = i % size;
- int y = i / size;
- return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
- }
- #endif
- #ifdef USE_BATCHING_COLOR
- uniform sampler2D batchingColorTexture;
- vec3 getBatchingColor( const in float i ) {
- int size = textureSize( batchingColorTexture, 0 ).x;
- int j = int( i );
- int x = j % size;
- int y = j / size;
- return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
- }
- #endif`,DRe=`#ifdef USE_BATCHING
- mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
- #endif`,ORe=`vec3 transformed = vec3( position );
- #ifdef USE_ALPHAHASH
- vPosition = vec3( position );
- #endif`,LRe=`vec3 objectNormal = vec3( normal );
- #ifdef USE_TANGENT
- vec3 objectTangent = vec3( tangent.xyz );
- #endif`,IRe=`float G_BlinnPhong_Implicit( ) {
- return 0.25;
- }
- float D_BlinnPhong( const in float shininess, const in float dotNH ) {
- return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
- }
- vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( specularColor, 1.0, dotVH );
- float G = G_BlinnPhong_Implicit( );
- float D = D_BlinnPhong( shininess, dotNH );
- return F * ( G * D );
- } // validated`,FRe=`#ifdef USE_IRIDESCENCE
- const mat3 XYZ_TO_REC709 = mat3(
- 3.2404542, -0.9692660, 0.0556434,
- -1.5371385, 1.8760108, -0.2040259,
- -0.4985314, 0.0415560, 1.0572252
- );
- vec3 Fresnel0ToIor( vec3 fresnel0 ) {
- vec3 sqrtF0 = sqrt( fresnel0 );
- return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
- }
- vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
- return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
- }
- float IorToFresnel0( float transmittedIor, float incidentIor ) {
- return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
- }
- vec3 evalSensitivity( float OPD, vec3 shift ) {
- float phase = 2.0 * PI * OPD * 1.0e-9;
- vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
- vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
- vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
- vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
- xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
- xyz /= 1.0685e-7;
- vec3 rgb = XYZ_TO_REC709 * xyz;
- return rgb;
- }
- vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
- vec3 I;
- float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
- float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
- float cosTheta2Sq = 1.0 - sinTheta2Sq;
- if ( cosTheta2Sq < 0.0 ) {
- return vec3( 1.0 );
- }
- float cosTheta2 = sqrt( cosTheta2Sq );
- float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
- float R12 = F_Schlick( R0, 1.0, cosTheta1 );
- float T121 = 1.0 - R12;
- float phi12 = 0.0;
- if ( iridescenceIOR < outsideIOR ) phi12 = PI;
- float phi21 = PI - phi12;
- vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
- vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
- vec3 phi23 = vec3( 0.0 );
- if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
- if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
- if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
- float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
- vec3 phi = vec3( phi21 ) + phi23;
- vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
- vec3 r123 = sqrt( R123 );
- vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
- vec3 C0 = R12 + Rs;
- I = C0;
- vec3 Cm = Rs - T121;
- for ( int m = 1; m <= 2; ++ m ) {
- Cm *= r123;
- vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
- I += Cm * Sm;
- }
- return max( I, vec3( 0.0 ) );
- }
- #endif`,URe=`#ifdef USE_BUMPMAP
- uniform sampler2D bumpMap;
- uniform float bumpScale;
- vec2 dHdxy_fwd() {
- vec2 dSTdx = dFdx( vBumpMapUv );
- vec2 dSTdy = dFdy( vBumpMapUv );
- float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
- float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
- float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
- return vec2( dBx, dBy );
- }
- vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
- vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
- vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
- vec3 vN = surf_norm;
- vec3 R1 = cross( vSigmaY, vN );
- vec3 R2 = cross( vN, vSigmaX );
- float fDet = dot( vSigmaX, R1 ) * faceDirection;
- vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
- return normalize( abs( fDet ) * surf_norm - vGrad );
- }
- #endif`,zRe=`#if NUM_CLIPPING_PLANES > 0
- vec4 plane;
- #ifdef ALPHA_TO_COVERAGE
- float distanceToPlane, distanceGradient;
- float clipOpacity = 1.0;
- #pragma unroll_loop_start
- for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
- distanceGradient = fwidth( distanceToPlane ) / 2.0;
- clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
- if ( clipOpacity == 0.0 ) discard;
- }
- #pragma unroll_loop_end
- #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
- float unionClipOpacity = 1.0;
- #pragma unroll_loop_start
- for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
- distanceGradient = fwidth( distanceToPlane ) / 2.0;
- unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
- }
- #pragma unroll_loop_end
- clipOpacity *= 1.0 - unionClipOpacity;
- #endif
- diffuseColor.a *= clipOpacity;
- if ( diffuseColor.a == 0.0 ) discard;
- #else
- #pragma unroll_loop_start
- for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
- }
- #pragma unroll_loop_end
- #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
- bool clipped = true;
- #pragma unroll_loop_start
- for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
- }
- #pragma unroll_loop_end
- if ( clipped ) discard;
- #endif
- #endif
- #endif`,BRe=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
- #endif`,$Re=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- #endif`,HRe=`#if NUM_CLIPPING_PLANES > 0
- vClipPosition = - mvPosition.xyz;
- #endif`,VRe=`#if defined( USE_COLOR_ALPHA )
- diffuseColor *= vColor;
- #elif defined( USE_COLOR )
- diffuseColor.rgb *= vColor;
- #endif`,GRe=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR )
- varying vec3 vColor;
- #endif`,WRe=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
- varying vec3 vColor;
- #endif`,qRe=`#if defined( USE_COLOR_ALPHA )
- vColor = vec4( 1.0 );
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
- vColor = vec3( 1.0 );
- #endif
- #ifdef USE_COLOR
- vColor *= color;
- #endif
- #ifdef USE_INSTANCING_COLOR
- vColor.xyz *= instanceColor.xyz;
- #endif
- #ifdef USE_BATCHING_COLOR
- vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
- vColor.xyz *= batchingColor.xyz;
- #endif`,KRe=`#define PI 3.141592653589793
- #define PI2 6.283185307179586
- #define PI_HALF 1.5707963267948966
- #define RECIPROCAL_PI 0.3183098861837907
- #define RECIPROCAL_PI2 0.15915494309189535
- #define EPSILON 1e-6
- #ifndef saturate
- #define saturate( a ) clamp( a, 0.0, 1.0 )
- #endif
- #define whiteComplement( a ) ( 1.0 - saturate( a ) )
- float pow2( const in float x ) { return x*x; }
- vec3 pow2( const in vec3 x ) { return x*x; }
- float pow3( const in float x ) { return x*x*x; }
- float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
- float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
- float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
- highp float rand( const in vec2 uv ) {
- const highp float a = 12.9898, b = 78.233, c = 43758.5453;
- highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
- return fract( sin( sn ) * c );
- }
- #ifdef HIGH_PRECISION
- float precisionSafeLength( vec3 v ) { return length( v ); }
- #else
- float precisionSafeLength( vec3 v ) {
- float maxComponent = max3( abs( v ) );
- return length( v / maxComponent ) * maxComponent;
- }
- #endif
- struct IncidentLight {
- vec3 color;
- vec3 direction;
- bool visible;
- };
- struct ReflectedLight {
- vec3 directDiffuse;
- vec3 directSpecular;
- vec3 indirectDiffuse;
- vec3 indirectSpecular;
- };
- #ifdef USE_ALPHAHASH
- varying vec3 vPosition;
- #endif
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
- }
- vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
- }
- bool isPerspectiveMatrix( mat4 m ) {
- return m[ 2 ][ 3 ] == - 1.0;
- }
- vec2 equirectUv( in vec3 dir ) {
- float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
- float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
- return vec2( u, v );
- }
- vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
- return RECIPROCAL_PI * diffuseColor;
- }
- vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
- }
- float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
- } // validated`,XRe=`#ifdef ENVMAP_TYPE_CUBE_UV
- #define cubeUV_minMipLevel 4.0
- #define cubeUV_minTileSize 16.0
- float getFace( vec3 direction ) {
- vec3 absDirection = abs( direction );
- float face = - 1.0;
- if ( absDirection.x > absDirection.z ) {
- if ( absDirection.x > absDirection.y )
- face = direction.x > 0.0 ? 0.0 : 3.0;
- else
- face = direction.y > 0.0 ? 1.0 : 4.0;
- } else {
- if ( absDirection.z > absDirection.y )
- face = direction.z > 0.0 ? 2.0 : 5.0;
- else
- face = direction.y > 0.0 ? 1.0 : 4.0;
- }
- return face;
- }
- vec2 getUV( vec3 direction, float face ) {
- vec2 uv;
- if ( face == 0.0 ) {
- uv = vec2( direction.z, direction.y ) / abs( direction.x );
- } else if ( face == 1.0 ) {
- uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
- } else if ( face == 2.0 ) {
- uv = vec2( - direction.x, direction.y ) / abs( direction.z );
- } else if ( face == 3.0 ) {
- uv = vec2( - direction.z, direction.y ) / abs( direction.x );
- } else if ( face == 4.0 ) {
- uv = vec2( - direction.x, direction.z ) / abs( direction.y );
- } else {
- uv = vec2( direction.x, direction.y ) / abs( direction.z );
- }
- return 0.5 * ( uv + 1.0 );
- }
- vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
- float face = getFace( direction );
- float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
- mipInt = max( mipInt, cubeUV_minMipLevel );
- float faceSize = exp2( mipInt );
- highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
- if ( face > 2.0 ) {
- uv.y += faceSize;
- face -= 3.0;
- }
- uv.x += face * faceSize;
- uv.x += filterInt * 3.0 * cubeUV_minTileSize;
- uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
- uv.x *= CUBEUV_TEXEL_WIDTH;
- uv.y *= CUBEUV_TEXEL_HEIGHT;
- #ifdef texture2DGradEXT
- return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
- #else
- return texture2D( envMap, uv ).rgb;
- #endif
- }
- #define cubeUV_r0 1.0
- #define cubeUV_m0 - 2.0
- #define cubeUV_r1 0.8
- #define cubeUV_m1 - 1.0
- #define cubeUV_r4 0.4
- #define cubeUV_m4 2.0
- #define cubeUV_r5 0.305
- #define cubeUV_m5 3.0
- #define cubeUV_r6 0.21
- #define cubeUV_m6 4.0
- float roughnessToMip( float roughness ) {
- float mip = 0.0;
- if ( roughness >= cubeUV_r1 ) {
- mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
- } else if ( roughness >= cubeUV_r4 ) {
- mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
- } else if ( roughness >= cubeUV_r5 ) {
- mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
- } else if ( roughness >= cubeUV_r6 ) {
- mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
- } else {
- mip = - 2.0 * log2( 1.16 * roughness ); }
- return mip;
- }
- vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
- float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
- float mipF = fract( mip );
- float mipInt = floor( mip );
- vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
- if ( mipF == 0.0 ) {
- return vec4( color0, 1.0 );
- } else {
- vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
- return vec4( mix( color0, color1, mipF ), 1.0 );
- }
- }
- #endif`,YRe=`vec3 transformedNormal = objectNormal;
- #ifdef USE_TANGENT
- vec3 transformedTangent = objectTangent;
- #endif
- #ifdef USE_BATCHING
- mat3 bm = mat3( batchingMatrix );
- transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
- transformedNormal = bm * transformedNormal;
- #ifdef USE_TANGENT
- transformedTangent = bm * transformedTangent;
- #endif
- #endif
- #ifdef USE_INSTANCING
- mat3 im = mat3( instanceMatrix );
- transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
- transformedNormal = im * transformedNormal;
- #ifdef USE_TANGENT
- transformedTangent = im * transformedTangent;
- #endif
- #endif
- transformedNormal = normalMatrix * transformedNormal;
- #ifdef FLIP_SIDED
- transformedNormal = - transformedNormal;
- #endif
- #ifdef USE_TANGENT
- transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
- #ifdef FLIP_SIDED
- transformedTangent = - transformedTangent;
- #endif
- #endif`,QRe=`#ifdef USE_DISPLACEMENTMAP
- uniform sampler2D displacementMap;
- uniform float displacementScale;
- uniform float displacementBias;
- #endif`,ZRe=`#ifdef USE_DISPLACEMENTMAP
- transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
- #endif`,JRe=`#ifdef USE_EMISSIVEMAP
- vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
- #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
- emissiveColor = sRGBTransferEOTF( emissiveColor );
- #endif
- totalEmissiveRadiance *= emissiveColor.rgb;
- #endif`,eDe=`#ifdef USE_EMISSIVEMAP
- uniform sampler2D emissiveMap;
- #endif`,tDe="gl_FragColor = linearToOutputTexel( gl_FragColor );",nDe=`vec4 LinearTransferOETF( in vec4 value ) {
- return value;
- }
- vec4 sRGBTransferEOTF( in vec4 value ) {
- return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );
- }
- vec4 sRGBTransferOETF( in vec4 value ) {
- return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
- }`,rDe=`#ifdef USE_ENVMAP
- #ifdef ENV_WORLDPOS
- vec3 cameraToFrag;
- if ( isOrthographic ) {
- cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
- } else {
- cameraToFrag = normalize( vWorldPosition - cameraPosition );
- }
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- #ifdef ENVMAP_MODE_REFLECTION
- vec3 reflectVec = reflect( cameraToFrag, worldNormal );
- #else
- vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
- #endif
- #else
- vec3 reflectVec = vReflect;
- #endif
- #ifdef ENVMAP_TYPE_CUBE
- vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
- #else
- vec4 envColor = vec4( 0.0 );
- #endif
- #ifdef ENVMAP_BLENDING_MULTIPLY
- outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
- #elif defined( ENVMAP_BLENDING_MIX )
- outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
- #elif defined( ENVMAP_BLENDING_ADD )
- outgoingLight += envColor.xyz * specularStrength * reflectivity;
- #endif
- #endif`,iDe=`#ifdef USE_ENVMAP
- uniform float envMapIntensity;
- uniform float flipEnvMap;
- uniform mat3 envMapRotation;
- #ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #else
- uniform sampler2D envMap;
- #endif
- #endif`,aDe=`#ifdef USE_ENVMAP
- uniform float reflectivity;
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
- #define ENV_WORLDPOS
- #endif
- #ifdef ENV_WORLDPOS
- varying vec3 vWorldPosition;
- uniform float refractionRatio;
- #else
- varying vec3 vReflect;
- #endif
- #endif`,sDe=`#ifdef USE_ENVMAP
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
- #define ENV_WORLDPOS
- #endif
- #ifdef ENV_WORLDPOS
-
- varying vec3 vWorldPosition;
- #else
- varying vec3 vReflect;
- uniform float refractionRatio;
- #endif
- #endif`,oDe=`#ifdef USE_ENVMAP
- #ifdef ENV_WORLDPOS
- vWorldPosition = worldPosition.xyz;
- #else
- vec3 cameraToVertex;
- if ( isOrthographic ) {
- cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
- } else {
- cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
- }
- vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
- #ifdef ENVMAP_MODE_REFLECTION
- vReflect = reflect( cameraToVertex, worldNormal );
- #else
- vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
- #endif
- #endif
- #endif`,lDe=`#ifdef USE_FOG
- vFogDepth = - mvPosition.z;
- #endif`,cDe=`#ifdef USE_FOG
- varying float vFogDepth;
- #endif`,uDe=`#ifdef USE_FOG
- #ifdef FOG_EXP2
- float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
- #else
- float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
- #endif
- gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
- #endif`,dDe=`#ifdef USE_FOG
- uniform vec3 fogColor;
- varying float vFogDepth;
- #ifdef FOG_EXP2
- uniform float fogDensity;
- #else
- uniform float fogNear;
- uniform float fogFar;
- #endif
- #endif`,hDe=`#ifdef USE_GRADIENTMAP
- uniform sampler2D gradientMap;
- #endif
- vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
- float dotNL = dot( normal, lightDirection );
- vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
- #ifdef USE_GRADIENTMAP
- return vec3( texture2D( gradientMap, coord ).r );
- #else
- vec2 fw = fwidth( coord ) * 0.5;
- return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
- #endif
- }`,fDe=`#ifdef USE_LIGHTMAP
- uniform sampler2D lightMap;
- uniform float lightMapIntensity;
- #endif`,mDe=`LambertMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularStrength = specularStrength;`,pDe=`varying vec3 vViewPosition;
- struct LambertMaterial {
- vec3 diffuseColor;
- float specularStrength;
- };
- void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_Lambert
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,gDe=`uniform bool receiveShadow;
- uniform vec3 ambientLightColor;
- #if defined( USE_LIGHT_PROBES )
- uniform vec3 lightProbe[ 9 ];
- #endif
- vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
- float x = normal.x, y = normal.y, z = normal.z;
- vec3 result = shCoefficients[ 0 ] * 0.886227;
- result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
- result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
- result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
- result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
- result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
- result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
- result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
- result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
- return result;
- }
- vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
- return irradiance;
- }
- vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
- vec3 irradiance = ambientLightColor;
- return irradiance;
- }
- float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
- float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
- if ( cutoffDistance > 0.0 ) {
- distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
- }
- return distanceFalloff;
- }
- float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
- return smoothstep( coneCosine, penumbraCosine, angleCosine );
- }
- #if NUM_DIR_LIGHTS > 0
- struct DirectionalLight {
- vec3 direction;
- vec3 color;
- };
- uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
- void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
- light.color = directionalLight.color;
- light.direction = directionalLight.direction;
- light.visible = true;
- }
- #endif
- #if NUM_POINT_LIGHTS > 0
- struct PointLight {
- vec3 position;
- vec3 color;
- float distance;
- float decay;
- };
- uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
- void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
- vec3 lVector = pointLight.position - geometryPosition;
- light.direction = normalize( lVector );
- float lightDistance = length( lVector );
- light.color = pointLight.color;
- light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
- light.visible = ( light.color != vec3( 0.0 ) );
- }
- #endif
- #if NUM_SPOT_LIGHTS > 0
- struct SpotLight {
- vec3 position;
- vec3 direction;
- vec3 color;
- float distance;
- float decay;
- float coneCos;
- float penumbraCos;
- };
- uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
- void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
- vec3 lVector = spotLight.position - geometryPosition;
- light.direction = normalize( lVector );
- float angleCos = dot( light.direction, spotLight.direction );
- float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
- if ( spotAttenuation > 0.0 ) {
- float lightDistance = length( lVector );
- light.color = spotLight.color * spotAttenuation;
- light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
- light.visible = ( light.color != vec3( 0.0 ) );
- } else {
- light.color = vec3( 0.0 );
- light.visible = false;
- }
- }
- #endif
- #if NUM_RECT_AREA_LIGHTS > 0
- struct RectAreaLight {
- vec3 color;
- vec3 position;
- vec3 halfWidth;
- vec3 halfHeight;
- };
- uniform sampler2D ltc_1; uniform sampler2D ltc_2;
- uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
- #endif
- #if NUM_HEMI_LIGHTS > 0
- struct HemisphereLight {
- vec3 direction;
- vec3 skyColor;
- vec3 groundColor;
- };
- uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
- vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
- float dotNL = dot( normal, hemiLight.direction );
- float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
- vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
- return irradiance;
- }
- #endif`,xDe=`#ifdef USE_ENVMAP
- vec3 getIBLIrradiance( const in vec3 normal ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
- return PI * envMapColor.rgb * envMapIntensity;
- #else
- return vec3( 0.0 );
- #endif
- }
- vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 reflectVec = reflect( - viewDir, normal );
- reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );
- reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
- return envMapColor.rgb * envMapIntensity;
- #else
- return vec3( 0.0 );
- #endif
- }
- #ifdef USE_ANISOTROPY
- vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 bentNormal = cross( bitangent, viewDir );
- bentNormal = normalize( cross( bentNormal, bitangent ) );
- bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
- return getIBLRadiance( viewDir, bentNormal, roughness );
- #else
- return vec3( 0.0 );
- #endif
- }
- #endif
- #endif`,bDe=`ToonMaterial material;
- material.diffuseColor = diffuseColor.rgb;`,yDe=`varying vec3 vViewPosition;
- struct ToonMaterial {
- vec3 diffuseColor;
- };
- void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_Toon
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,vDe=`BlinnPhongMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularColor = specular;
- material.specularShininess = shininess;
- material.specularStrength = specularStrength;`,_De=`varying vec3 vViewPosition;
- struct BlinnPhongMaterial {
- vec3 diffuseColor;
- vec3 specularColor;
- float specularShininess;
- float specularStrength;
- };
- void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
- }
- void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_BlinnPhong
- #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,wDe=`PhysicalMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );
- material.metalness = metalnessFactor;
- vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
- float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
- material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
- material.roughness = min( material.roughness, 1.0 );
- #ifdef IOR
- material.ior = ior;
- #ifdef USE_SPECULAR
- float specularIntensityFactor = specularIntensity;
- vec3 specularColorFactor = specularColor;
- #ifdef USE_SPECULAR_COLORMAP
- specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
- #endif
- material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
- #else
- float specularIntensityFactor = 1.0;
- vec3 specularColorFactor = vec3( 1.0 );
- material.specularF90 = 1.0;
- #endif
- material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor;
- material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );
- #else
- material.specularColor = vec3( 0.04 );
- material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );
- material.specularF90 = 1.0;
- #endif
- #ifdef USE_CLEARCOAT
- material.clearcoat = clearcoat;
- material.clearcoatRoughness = clearcoatRoughness;
- material.clearcoatF0 = vec3( 0.04 );
- material.clearcoatF90 = 1.0;
- #ifdef USE_CLEARCOATMAP
- material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
- #endif
- material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
- material.clearcoatRoughness += geometryRoughness;
- material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
- #endif
- #ifdef USE_DISPERSION
- material.dispersion = dispersion;
- #endif
- #ifdef USE_IRIDESCENCE
- material.iridescence = iridescence;
- material.iridescenceIOR = iridescenceIOR;
- #ifdef USE_IRIDESCENCEMAP
- material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
- #else
- material.iridescenceThickness = iridescenceThicknessMaximum;
- #endif
- #endif
- #ifdef USE_SHEEN
- material.sheenColor = sheenColor;
- #ifdef USE_SHEEN_COLORMAP
- material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
- #endif
- material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 );
- #ifdef USE_SHEEN_ROUGHNESSMAP
- material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
- #endif
- #endif
- #ifdef USE_ANISOTROPY
- #ifdef USE_ANISOTROPYMAP
- mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
- vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
- vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
- #else
- vec2 anisotropyV = anisotropyVector;
- #endif
- material.anisotropy = length( anisotropyV );
- if( material.anisotropy == 0.0 ) {
- anisotropyV = vec2( 1.0, 0.0 );
- } else {
- anisotropyV /= material.anisotropy;
- material.anisotropy = saturate( material.anisotropy );
- }
- material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
- material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
- material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
- #endif`,SDe=`uniform sampler2D dfgLUT;
- struct PhysicalMaterial {
- vec3 diffuseColor;
- vec3 diffuseContribution;
- vec3 specularColor;
- vec3 specularColorBlended;
- float roughness;
- float metalness;
- float specularF90;
- float dispersion;
- #ifdef USE_CLEARCOAT
- float clearcoat;
- float clearcoatRoughness;
- vec3 clearcoatF0;
- float clearcoatF90;
- #endif
- #ifdef USE_IRIDESCENCE
- float iridescence;
- float iridescenceIOR;
- float iridescenceThickness;
- vec3 iridescenceFresnel;
- vec3 iridescenceF0;
- vec3 iridescenceFresnelDielectric;
- vec3 iridescenceFresnelMetallic;
- #endif
- #ifdef USE_SHEEN
- vec3 sheenColor;
- float sheenRoughness;
- #endif
- #ifdef IOR
- float ior;
- #endif
- #ifdef USE_TRANSMISSION
- float transmission;
- float transmissionAlpha;
- float thickness;
- float attenuationDistance;
- vec3 attenuationColor;
- #endif
- #ifdef USE_ANISOTROPY
- float anisotropy;
- float alphaT;
- vec3 anisotropyT;
- vec3 anisotropyB;
- #endif
- };
- vec3 clearcoatSpecularDirect = vec3( 0.0 );
- vec3 clearcoatSpecularIndirect = vec3( 0.0 );
- vec3 sheenSpecularDirect = vec3( 0.0 );
- vec3 sheenSpecularIndirect = vec3(0.0 );
- vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
- float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
- float x2 = x * x;
- float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
- return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
- }
- float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
- float a2 = pow2( alpha );
- float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
- float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
- return 0.5 / max( gv + gl, EPSILON );
- }
- float D_GGX( const in float alpha, const in float dotNH ) {
- float a2 = pow2( alpha );
- float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
- return RECIPROCAL_PI * a2 / pow2( denom );
- }
- #ifdef USE_ANISOTROPY
- float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
- float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
- float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
- float v = 0.5 / ( gv + gl );
- return v;
- }
- float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
- float a2 = alphaT * alphaB;
- highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
- highp float v2 = dot( v, v );
- float w2 = a2 / v2;
- return RECIPROCAL_PI * a2 * pow2 ( w2 );
- }
- #endif
- #ifdef USE_CLEARCOAT
- vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
- vec3 f0 = material.clearcoatF0;
- float f90 = material.clearcoatF90;
- float roughness = material.clearcoatRoughness;
- float alpha = pow2( roughness );
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( f0, f90, dotVH );
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
- float D = D_GGX( alpha, dotNH );
- return F * ( V * D );
- }
- #endif
- vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
- vec3 f0 = material.specularColorBlended;
- float f90 = material.specularF90;
- float roughness = material.roughness;
- float alpha = pow2( roughness );
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( f0, f90, dotVH );
- #ifdef USE_IRIDESCENCE
- F = mix( F, material.iridescenceFresnel, material.iridescence );
- #endif
- #ifdef USE_ANISOTROPY
- float dotTL = dot( material.anisotropyT, lightDir );
- float dotTV = dot( material.anisotropyT, viewDir );
- float dotTH = dot( material.anisotropyT, halfDir );
- float dotBL = dot( material.anisotropyB, lightDir );
- float dotBV = dot( material.anisotropyB, viewDir );
- float dotBH = dot( material.anisotropyB, halfDir );
- float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
- float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
- #else
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
- float D = D_GGX( alpha, dotNH );
- #endif
- return F * ( V * D );
- }
- vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
- const float LUT_SIZE = 64.0;
- const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
- const float LUT_BIAS = 0.5 / LUT_SIZE;
- float dotNV = saturate( dot( N, V ) );
- vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
- uv = uv * LUT_SCALE + LUT_BIAS;
- return uv;
- }
- float LTC_ClippedSphereFormFactor( const in vec3 f ) {
- float l = length( f );
- return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
- }
- vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
- float x = dot( v1, v2 );
- float y = abs( x );
- float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
- float b = 3.4175940 + ( 4.1616724 + y ) * y;
- float v = a / b;
- float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
- return cross( v1, v2 ) * theta_sintheta;
- }
- vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
- vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
- vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
- vec3 lightNormal = cross( v1, v2 );
- if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
- vec3 T1, T2;
- T1 = normalize( V - N * dot( V, N ) );
- T2 = - cross( N, T1 );
- mat3 mat = mInv * transpose( mat3( T1, T2, N ) );
- vec3 coords[ 4 ];
- coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
- coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
- coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
- coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
- coords[ 0 ] = normalize( coords[ 0 ] );
- coords[ 1 ] = normalize( coords[ 1 ] );
- coords[ 2 ] = normalize( coords[ 2 ] );
- coords[ 3 ] = normalize( coords[ 3 ] );
- vec3 vectorFormFactor = vec3( 0.0 );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
- float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
- return vec3( result );
- }
- #if defined( USE_SHEEN )
- float D_Charlie( float roughness, float dotNH ) {
- float alpha = pow2( roughness );
- float invAlpha = 1.0 / alpha;
- float cos2h = dotNH * dotNH;
- float sin2h = max( 1.0 - cos2h, 0.0078125 );
- return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
- }
- float V_Neubelt( float dotNV, float dotNL ) {
- return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
- }
- vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float D = D_Charlie( sheenRoughness, dotNH );
- float V = V_Neubelt( dotNV, dotNL );
- return sheenColor * ( D * V );
- }
- #endif
- float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
- float dotNV = saturate( dot( normal, viewDir ) );
- float r2 = roughness * roughness;
- float rInv = 1.0 / ( roughness + 0.1 );
- float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv;
- float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv;
- float DG = exp( a * dotNV + b );
- return saturate( DG );
- }
- vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
- float dotNV = saturate( dot( normal, viewDir ) );
- vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;
- return specularColor * fab.x + specularF90 * fab.y;
- }
- #ifdef USE_IRIDESCENCE
- void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
- #else
- void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
- #endif
- float dotNV = saturate( dot( normal, viewDir ) );
- vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;
- #ifdef USE_IRIDESCENCE
- vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
- #else
- vec3 Fr = specularColor;
- #endif
- vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
- float Ess = fab.x + fab.y;
- float Ems = 1.0 - Ess;
- vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
- singleScatter += FssEss;
- multiScatter += Fms * Ems;
- }
- vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
- vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg;
- vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg;
- vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y;
- vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y;
- float Ess_V = dfgV.x + dfgV.y;
- float Ess_L = dfgL.x + dfgL.y;
- float Ems_V = 1.0 - Ess_V;
- float Ems_L = 1.0 - Ess_L;
- vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619;
- vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON );
- float compensationFactor = Ems_V * Ems_L;
- vec3 multiScatter = Fms * compensationFactor;
- return singleScatter + multiScatter;
- }
- #if NUM_RECT_AREA_LIGHTS > 0
- void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 normal = geometryNormal;
- vec3 viewDir = geometryViewDir;
- vec3 position = geometryPosition;
- vec3 lightPos = rectAreaLight.position;
- vec3 halfWidth = rectAreaLight.halfWidth;
- vec3 halfHeight = rectAreaLight.halfHeight;
- vec3 lightColor = rectAreaLight.color;
- float roughness = material.roughness;
- vec3 rectCoords[ 4 ];
- rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
- rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
- rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
- vec2 uv = LTC_Uv( normal, viewDir, roughness );
- vec4 t1 = texture2D( ltc_1, uv );
- vec4 t2 = texture2D( ltc_2, uv );
- mat3 mInv = mat3(
- vec3( t1.x, 0, t1.y ),
- vec3( 0, 1, 0 ),
- vec3( t1.z, 0, t1.w )
- );
- vec3 fresnel = ( material.specularColorBlended * t2.x + ( vec3( 1.0 ) - material.specularColorBlended ) * t2.y );
- reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
- reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
- }
- #endif
- void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- #ifdef USE_CLEARCOAT
- float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
- vec3 ccIrradiance = dotNLcc * directLight.color;
- clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
- #endif
- #ifdef USE_SHEEN
-
- sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
-
- float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
- float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness );
-
- float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL );
-
- irradiance *= sheenEnergyComp;
-
- #endif
- reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution );
- }
- 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 ) {
- vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution );
- #ifdef USE_SHEEN
- float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
- float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;
- diffuse *= sheenEnergyComp;
- #endif
- reflectedLight.indirectDiffuse += diffuse;
- }
- void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
- #ifdef USE_CLEARCOAT
- clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
- #endif
- #ifdef USE_SHEEN
- sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI;
- #endif
- vec3 singleScatteringDielectric = vec3( 0.0 );
- vec3 multiScatteringDielectric = vec3( 0.0 );
- vec3 singleScatteringMetallic = vec3( 0.0 );
- vec3 multiScatteringMetallic = vec3( 0.0 );
- #ifdef USE_IRIDESCENCE
- computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric );
- computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic );
- #else
- computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric );
- computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic );
- #endif
- vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );
- vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );
- vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric;
- vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric );
- vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
- vec3 indirectSpecular = radiance * singleScattering;
- indirectSpecular += multiScattering * cosineWeightedIrradiance;
- vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance;
- #ifdef USE_SHEEN
- float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
- float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;
- indirectSpecular *= sheenEnergyComp;
- indirectDiffuse *= sheenEnergyComp;
- #endif
- reflectedLight.indirectSpecular += indirectSpecular;
- reflectedLight.indirectDiffuse += indirectDiffuse;
- }
- #define RE_Direct RE_Direct_Physical
- #define RE_Direct_RectArea RE_Direct_RectArea_Physical
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
- #define RE_IndirectSpecular RE_IndirectSpecular_Physical
- float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
- return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
- }`,MDe=`
- vec3 geometryPosition = - vViewPosition;
- vec3 geometryNormal = normal;
- vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
- vec3 geometryClearcoatNormal = vec3( 0.0 );
- #ifdef USE_CLEARCOAT
- geometryClearcoatNormal = clearcoatNormal;
- #endif
- #ifdef USE_IRIDESCENCE
- float dotNVi = saturate( dot( normal, geometryViewDir ) );
- if ( material.iridescenceThickness == 0.0 ) {
- material.iridescence = 0.0;
- } else {
- material.iridescence = saturate( material.iridescence );
- }
- if ( material.iridescence > 0.0 ) {
- material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
- material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );
- material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness );
- material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
- }
- #endif
- IncidentLight directLight;
- #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
- PointLight pointLight;
- #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
- PointLightShadow pointLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
- pointLight = pointLights[ i ];
- getPointLightInfo( pointLight, geometryPosition, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )
- pointLightShadow = pointLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
- SpotLight spotLight;
- vec4 spotColor;
- vec3 spotLightCoord;
- bool inSpotLightMap;
- #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
- SpotLightShadow spotLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
- spotLight = spotLights[ i ];
- getSpotLightInfo( spotLight, geometryPosition, directLight );
- #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
- #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
- #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
- #else
- #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
- #endif
- #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
- spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
- inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
- spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
- directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
- #endif
- #undef SPOT_LIGHT_MAP_INDEX
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- spotLightShadow = spotLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
- DirectionalLight directionalLight;
- #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
- DirectionalLightShadow directionalLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
- directionalLight = directionalLights[ i ];
- getDirectionalLightInfo( directionalLight, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
- directionalLightShadow = directionalLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
- RectAreaLight rectAreaLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
- rectAreaLight = rectAreaLights[ i ];
- RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if defined( RE_IndirectDiffuse )
- vec3 iblIrradiance = vec3( 0.0 );
- vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
- #if defined( USE_LIGHT_PROBES )
- irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
- #endif
- #if ( NUM_HEMI_LIGHTS > 0 )
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
- irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
- }
- #pragma unroll_loop_end
- #endif
- #endif
- #if defined( RE_IndirectSpecular )
- vec3 radiance = vec3( 0.0 );
- vec3 clearcoatRadiance = vec3( 0.0 );
- #endif`,NDe=`#if defined( RE_IndirectDiffuse )
- #ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
- irradiance += lightMapIrradiance;
- #endif
- #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
- iblIrradiance += getIBLIrradiance( geometryNormal );
- #endif
- #endif
- #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
- #ifdef USE_ANISOTROPY
- radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
- #else
- radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
- #endif
- #ifdef USE_CLEARCOAT
- clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
- #endif
- #endif`,EDe=`#if defined( RE_IndirectDiffuse )
- RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- #endif
- #if defined( RE_IndirectSpecular )
- RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- #endif`,ADe=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
- gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
- #endif`,TDe=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
- uniform float logDepthBufFC;
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,CDe=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,kDe=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
- vFragDepth = 1.0 + gl_Position.w;
- vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
- #endif`,jDe=`#ifdef USE_MAP
- vec4 sampledDiffuseColor = texture2D( map, vMapUv );
- #ifdef DECODE_VIDEO_TEXTURE
- sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
- #endif
- diffuseColor *= sampledDiffuseColor;
- #endif`,PDe=`#ifdef USE_MAP
- uniform sampler2D map;
- #endif`,RDe=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- #if defined( USE_POINTS_UV )
- vec2 uv = vUv;
- #else
- vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
- #endif
- #endif
- #ifdef USE_MAP
- diffuseColor *= texture2D( map, uv );
- #endif
- #ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, uv ).g;
- #endif`,DDe=`#if defined( USE_POINTS_UV )
- varying vec2 vUv;
- #else
- #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- uniform mat3 uvTransform;
- #endif
- #endif
- #ifdef USE_MAP
- uniform sampler2D map;
- #endif
- #ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,ODe=`float metalnessFactor = metalness;
- #ifdef USE_METALNESSMAP
- vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
- metalnessFactor *= texelMetalness.b;
- #endif`,LDe=`#ifdef USE_METALNESSMAP
- uniform sampler2D metalnessMap;
- #endif`,IDe=`#ifdef USE_INSTANCING_MORPH
- float morphTargetInfluences[ MORPHTARGETS_COUNT ];
- float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
- }
- #endif`,FDe=`#if defined( USE_MORPHCOLORS )
- vColor *= morphTargetBaseInfluence;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- #if defined( USE_COLOR_ALPHA )
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
- #elif defined( USE_COLOR )
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
- #endif
- }
- #endif`,UDe=`#ifdef USE_MORPHNORMALS
- objectNormal *= morphTargetBaseInfluence;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
- }
- #endif`,zDe=`#ifdef USE_MORPHTARGETS
- #ifndef USE_INSTANCING_MORPH
- uniform float morphTargetBaseInfluence;
- uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
- #endif
- uniform sampler2DArray morphTargetsTexture;
- uniform ivec2 morphTargetsTextureSize;
- vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
- int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
- int y = texelIndex / morphTargetsTextureSize.x;
- int x = texelIndex - y * morphTargetsTextureSize.x;
- ivec3 morphUV = ivec3( x, y, morphTargetIndex );
- return texelFetch( morphTargetsTexture, morphUV, 0 );
- }
- #endif`,BDe=`#ifdef USE_MORPHTARGETS
- transformed *= morphTargetBaseInfluence;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
- }
- #endif`,$De=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
- #ifdef FLAT_SHADED
- vec3 fdx = dFdx( vViewPosition );
- vec3 fdy = dFdy( vViewPosition );
- vec3 normal = normalize( cross( fdx, fdy ) );
- #else
- vec3 normal = normalize( vNormal );
- #ifdef DOUBLE_SIDED
- normal *= faceDirection;
- #endif
- #endif
- #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
- #ifdef USE_TANGENT
- mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
- #else
- mat3 tbn = getTangentFrame( - vViewPosition, normal,
- #if defined( USE_NORMALMAP )
- vNormalMapUv
- #elif defined( USE_CLEARCOAT_NORMALMAP )
- vClearcoatNormalMapUv
- #else
- vUv
- #endif
- );
- #endif
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
- tbn[0] *= faceDirection;
- tbn[1] *= faceDirection;
- #endif
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- #ifdef USE_TANGENT
- mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
- #else
- mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
- #endif
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
- tbn2[0] *= faceDirection;
- tbn2[1] *= faceDirection;
- #endif
- #endif
- vec3 nonPerturbedNormal = normal;`,HDe=`#ifdef USE_NORMALMAP_OBJECTSPACE
- normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
- #ifdef FLIP_SIDED
- normal = - normal;
- #endif
- #ifdef DOUBLE_SIDED
- normal = normal * faceDirection;
- #endif
- normal = normalize( normalMatrix * normal );
- #elif defined( USE_NORMALMAP_TANGENTSPACE )
- vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
- mapN.xy *= normalScale;
- normal = normalize( tbn * mapN );
- #elif defined( USE_BUMPMAP )
- normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
- #endif`,VDe=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,GDe=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,WDe=`#ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #ifdef USE_TANGENT
- vTangent = normalize( transformedTangent );
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
- #endif
- #endif`,qDe=`#ifdef USE_NORMALMAP
- uniform sampler2D normalMap;
- uniform vec2 normalScale;
- #endif
- #ifdef USE_NORMALMAP_OBJECTSPACE
- uniform mat3 normalMatrix;
- #endif
- #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
- mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
- vec3 q0 = dFdx( eye_pos.xyz );
- vec3 q1 = dFdy( eye_pos.xyz );
- vec2 st0 = dFdx( uv.st );
- vec2 st1 = dFdy( uv.st );
- vec3 N = surf_norm;
- vec3 q1perp = cross( q1, N );
- vec3 q0perp = cross( N, q0 );
- vec3 T = q1perp * st0.x + q0perp * st1.x;
- vec3 B = q1perp * st0.y + q0perp * st1.y;
- float det = max( dot( T, T ), dot( B, B ) );
- float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
- return mat3( T * scale, B * scale, N );
- }
- #endif`,KDe=`#ifdef USE_CLEARCOAT
- vec3 clearcoatNormal = nonPerturbedNormal;
- #endif`,XDe=`#ifdef USE_CLEARCOAT_NORMALMAP
- vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
- clearcoatMapN.xy *= clearcoatNormalScale;
- clearcoatNormal = normalize( tbn2 * clearcoatMapN );
- #endif`,YDe=`#ifdef USE_CLEARCOATMAP
- uniform sampler2D clearcoatMap;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- uniform sampler2D clearcoatNormalMap;
- uniform vec2 clearcoatNormalScale;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- uniform sampler2D clearcoatRoughnessMap;
- #endif`,QDe=`#ifdef USE_IRIDESCENCEMAP
- uniform sampler2D iridescenceMap;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform sampler2D iridescenceThicknessMap;
- #endif`,ZDe=`#ifdef OPAQUE
- diffuseColor.a = 1.0;
- #endif
- #ifdef USE_TRANSMISSION
- diffuseColor.a *= material.transmissionAlpha;
- #endif
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,JDe=`vec3 packNormalToRGB( const in vec3 normal ) {
- return normalize( normal ) * 0.5 + 0.5;
- }
- vec3 unpackRGBToNormal( const in vec3 rgb ) {
- return 2.0 * rgb.xyz - 1.0;
- }
- const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
- const float Inv255 = 1. / 255.;
- const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
- const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
- const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
- const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
- vec4 packDepthToRGBA( const in float v ) {
- if( v <= 0.0 )
- return vec4( 0., 0., 0., 0. );
- if( v >= 1.0 )
- return vec4( 1., 1., 1., 1. );
- float vuf;
- float af = modf( v * PackFactors.a, vuf );
- float bf = modf( vuf * ShiftRight8, vuf );
- float gf = modf( vuf * ShiftRight8, vuf );
- return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
- }
- vec3 packDepthToRGB( const in float v ) {
- if( v <= 0.0 )
- return vec3( 0., 0., 0. );
- if( v >= 1.0 )
- return vec3( 1., 1., 1. );
- float vuf;
- float bf = modf( v * PackFactors.b, vuf );
- float gf = modf( vuf * ShiftRight8, vuf );
- return vec3( vuf * Inv255, gf * PackUpscale, bf );
- }
- vec2 packDepthToRG( const in float v ) {
- if( v <= 0.0 )
- return vec2( 0., 0. );
- if( v >= 1.0 )
- return vec2( 1., 1. );
- float vuf;
- float gf = modf( v * 256., vuf );
- return vec2( vuf * Inv255, gf );
- }
- float unpackRGBAToDepth( const in vec4 v ) {
- return dot( v, UnpackFactors4 );
- }
- float unpackRGBToDepth( const in vec3 v ) {
- return dot( v, UnpackFactors3 );
- }
- float unpackRGToDepth( const in vec2 v ) {
- return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
- }
- vec4 pack2HalfToRGBA( const in vec2 v ) {
- vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
- return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
- }
- vec2 unpackRGBATo2Half( const in vec4 v ) {
- return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
- }
- float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
- return ( viewZ + near ) / ( near - far );
- }
- float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
- return depth * ( near - far ) - near;
- }
- float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
- return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
- }
- float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
- return ( near * far ) / ( ( far - near ) * depth - far );
- }`,eOe=`#ifdef PREMULTIPLIED_ALPHA
- gl_FragColor.rgb *= gl_FragColor.a;
- #endif`,tOe=`vec4 mvPosition = vec4( transformed, 1.0 );
- #ifdef USE_BATCHING
- mvPosition = batchingMatrix * mvPosition;
- #endif
- #ifdef USE_INSTANCING
- mvPosition = instanceMatrix * mvPosition;
- #endif
- mvPosition = modelViewMatrix * mvPosition;
- gl_Position = projectionMatrix * mvPosition;`,nOe=`#ifdef DITHERING
- gl_FragColor.rgb = dithering( gl_FragColor.rgb );
- #endif`,rOe=`#ifdef DITHERING
- vec3 dithering( vec3 color ) {
- float grid_position = rand( gl_FragCoord.xy );
- vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
- dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
- return color + dither_shift_RGB;
- }
- #endif`,iOe=`float roughnessFactor = roughness;
- #ifdef USE_ROUGHNESSMAP
- vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
- roughnessFactor *= texelRoughness.g;
- #endif`,aOe=`#ifdef USE_ROUGHNESSMAP
- uniform sampler2D roughnessMap;
- #endif`,sOe=`#if NUM_SPOT_LIGHT_COORDS > 0
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
- #endif
- #if NUM_SPOT_LIGHT_MAPS > 0
- uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
- #endif
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- #if defined( SHADOWMAP_TYPE_PCF )
- uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
- #else
- uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
- #endif
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
- struct DirectionalLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- #if defined( SHADOWMAP_TYPE_PCF )
- uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
- #else
- uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
- #endif
- struct SpotLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- #if defined( SHADOWMAP_TYPE_PCF )
- uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
- #elif defined( SHADOWMAP_TYPE_BASIC )
- uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
- #endif
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
- struct PointLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- float shadowCameraNear;
- float shadowCameraFar;
- };
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
- #endif
- #if defined( SHADOWMAP_TYPE_PCF )
- float interleavedGradientNoise( vec2 position ) {
- return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) );
- }
- vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) {
- const float goldenAngle = 2.399963229728653;
- float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) );
- float theta = float( sampleIndex ) * goldenAngle + phi;
- return vec2( cos( theta ), sin( theta ) ) * r;
- }
- #endif
- #if defined( SHADOWMAP_TYPE_PCF )
- float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
- float shadow = 1.0;
- shadowCoord.xyz /= shadowCoord.w;
- shadowCoord.z += shadowBias;
- bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
- bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
- if ( frustumTest ) {
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
- float radius = shadowRadius * texelSize.x;
- float phi = interleavedGradientNoise( gl_FragCoord.xy ) * 6.28318530718;
- shadow = (
- texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) +
- texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) +
- texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) +
- texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) +
- texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) )
- ) * 0.2;
- }
- return mix( 1.0, shadow, shadowIntensity );
- }
- #elif defined( SHADOWMAP_TYPE_VSM )
- float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
- float shadow = 1.0;
- shadowCoord.xyz /= shadowCoord.w;
- shadowCoord.z += shadowBias;
- bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
- bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
- if ( frustumTest ) {
- vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg;
- float mean = distribution.x;
- float variance = distribution.y * distribution.y;
- #ifdef USE_REVERSED_DEPTH_BUFFER
- float hard_shadow = step( mean, shadowCoord.z );
- #else
- float hard_shadow = step( shadowCoord.z, mean );
- #endif
- if ( hard_shadow == 1.0 ) {
- shadow = 1.0;
- } else {
- variance = max( variance, 0.0000001 );
- float d = shadowCoord.z - mean;
- float p_max = variance / ( variance + d * d );
- p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 );
- shadow = max( hard_shadow, p_max );
- }
- }
- return mix( 1.0, shadow, shadowIntensity );
- }
- #else
- float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
- float shadow = 1.0;
- shadowCoord.xyz /= shadowCoord.w;
- shadowCoord.z += shadowBias;
- bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
- bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
- if ( frustumTest ) {
- float depth = texture2D( shadowMap, shadowCoord.xy ).r;
- #ifdef USE_REVERSED_DEPTH_BUFFER
- shadow = step( depth, shadowCoord.z );
- #else
- shadow = step( shadowCoord.z, depth );
- #endif
- }
- return mix( 1.0, shadow, shadowIntensity );
- }
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- #if defined( SHADOWMAP_TYPE_PCF )
- float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
- float shadow = 1.0;
- vec3 lightToPosition = shadowCoord.xyz;
- vec3 bd3D = normalize( lightToPosition );
- vec3 absVec = abs( lightToPosition );
- float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );
- if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {
- float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );
- dp += shadowBias;
- float texelSize = shadowRadius / shadowMapSize.x;
- vec3 absDir = abs( bd3D );
- vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 );
- tangent = normalize( cross( bd3D, tangent ) );
- vec3 bitangent = cross( bd3D, tangent );
- float phi = interleavedGradientNoise( gl_FragCoord.xy ) * 6.28318530718;
- shadow = (
- texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 0, 5, phi ).x + bitangent * vogelDiskSample( 0, 5, phi ).y ) * texelSize, dp ) ) +
- texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 1, 5, phi ).x + bitangent * vogelDiskSample( 1, 5, phi ).y ) * texelSize, dp ) ) +
- texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 2, 5, phi ).x + bitangent * vogelDiskSample( 2, 5, phi ).y ) * texelSize, dp ) ) +
- texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 3, 5, phi ).x + bitangent * vogelDiskSample( 3, 5, phi ).y ) * texelSize, dp ) ) +
- texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 4, 5, phi ).x + bitangent * vogelDiskSample( 4, 5, phi ).y ) * texelSize, dp ) )
- ) * 0.2;
- }
- return mix( 1.0, shadow, shadowIntensity );
- }
- #elif defined( SHADOWMAP_TYPE_BASIC )
- float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
- float shadow = 1.0;
- vec3 lightToPosition = shadowCoord.xyz;
- vec3 bd3D = normalize( lightToPosition );
- vec3 absVec = abs( lightToPosition );
- float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );
- if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {
- float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );
- dp += shadowBias;
- float depth = textureCube( shadowMap, bd3D ).r;
- #ifdef USE_REVERSED_DEPTH_BUFFER
- shadow = step( depth, dp );
- #else
- shadow = step( dp, depth );
- #endif
- }
- return mix( 1.0, shadow, shadowIntensity );
- }
- #endif
- #endif
- #endif`,oOe=`#if NUM_SPOT_LIGHT_COORDS > 0
- uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
- #endif
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
- struct DirectionalLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- struct SpotLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
- struct PointLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- float shadowCameraNear;
- float shadowCameraFar;
- };
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
- #endif
- #endif`,lOe=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
- vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
- vec4 shadowWorldPosition;
- #endif
- #if defined( USE_SHADOWMAP )
- #if NUM_DIR_LIGHT_SHADOWS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
- vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
- vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif
- #endif
- #if NUM_SPOT_LIGHT_COORDS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
- shadowWorldPosition = worldPosition;
- #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
- #endif
- vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif`,cOe=`float getShadowMask() {
- float shadow = 1.0;
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- DirectionalLightShadow directionalLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
- directionalLight = directionalLightShadows[ i ];
- shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- SpotLightShadow spotLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
- spotLight = spotLightShadows[ i ];
- shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )
- PointLightShadow pointLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
- pointLight = pointLightShadows[ i ];
- shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #endif
- return shadow;
- }`,uOe=`#ifdef USE_SKINNING
- mat4 boneMatX = getBoneMatrix( skinIndex.x );
- mat4 boneMatY = getBoneMatrix( skinIndex.y );
- mat4 boneMatZ = getBoneMatrix( skinIndex.z );
- mat4 boneMatW = getBoneMatrix( skinIndex.w );
- #endif`,dOe=`#ifdef USE_SKINNING
- uniform mat4 bindMatrix;
- uniform mat4 bindMatrixInverse;
- uniform highp sampler2D boneTexture;
- mat4 getBoneMatrix( const in float i ) {
- int size = textureSize( boneTexture, 0 ).x;
- int j = int( i ) * 4;
- int x = j % size;
- int y = j / size;
- vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
- vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
- vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
- vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
- return mat4( v1, v2, v3, v4 );
- }
- #endif`,hOe=`#ifdef USE_SKINNING
- vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
- vec4 skinned = vec4( 0.0 );
- skinned += boneMatX * skinVertex * skinWeight.x;
- skinned += boneMatY * skinVertex * skinWeight.y;
- skinned += boneMatZ * skinVertex * skinWeight.z;
- skinned += boneMatW * skinVertex * skinWeight.w;
- transformed = ( bindMatrixInverse * skinned ).xyz;
- #endif`,fOe=`#ifdef USE_SKINNING
- mat4 skinMatrix = mat4( 0.0 );
- skinMatrix += skinWeight.x * boneMatX;
- skinMatrix += skinWeight.y * boneMatY;
- skinMatrix += skinWeight.z * boneMatZ;
- skinMatrix += skinWeight.w * boneMatW;
- skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
- objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
- #ifdef USE_TANGENT
- objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
- #endif
- #endif`,mOe=`float specularStrength;
- #ifdef USE_SPECULARMAP
- vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
- specularStrength = texelSpecular.r;
- #else
- specularStrength = 1.0;
- #endif`,pOe=`#ifdef USE_SPECULARMAP
- uniform sampler2D specularMap;
- #endif`,gOe=`#if defined( TONE_MAPPING )
- gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
- #endif`,xOe=`#ifndef saturate
- #define saturate( a ) clamp( a, 0.0, 1.0 )
- #endif
- uniform float toneMappingExposure;
- vec3 LinearToneMapping( vec3 color ) {
- return saturate( toneMappingExposure * color );
- }
- vec3 ReinhardToneMapping( vec3 color ) {
- color *= toneMappingExposure;
- return saturate( color / ( vec3( 1.0 ) + color ) );
- }
- vec3 CineonToneMapping( vec3 color ) {
- color *= toneMappingExposure;
- color = max( vec3( 0.0 ), color - 0.004 );
- return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
- }
- vec3 RRTAndODTFit( vec3 v ) {
- vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
- vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
- return a / b;
- }
- vec3 ACESFilmicToneMapping( vec3 color ) {
- const mat3 ACESInputMat = mat3(
- vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
- vec3( 0.04823, 0.01566, 0.83777 )
- );
- const mat3 ACESOutputMat = mat3(
- vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
- vec3( -0.07367, -0.00605, 1.07602 )
- );
- color *= toneMappingExposure / 0.6;
- color = ACESInputMat * color;
- color = RRTAndODTFit( color );
- color = ACESOutputMat * color;
- return saturate( color );
- }
- const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
- vec3( 1.6605, - 0.1246, - 0.0182 ),
- vec3( - 0.5876, 1.1329, - 0.1006 ),
- vec3( - 0.0728, - 0.0083, 1.1187 )
- );
- const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
- vec3( 0.6274, 0.0691, 0.0164 ),
- vec3( 0.3293, 0.9195, 0.0880 ),
- vec3( 0.0433, 0.0113, 0.8956 )
- );
- vec3 agxDefaultContrastApprox( vec3 x ) {
- vec3 x2 = x * x;
- vec3 x4 = x2 * x2;
- return + 15.5 * x4 * x2
- - 40.14 * x4 * x
- + 31.96 * x4
- - 6.868 * x2 * x
- + 0.4298 * x2
- + 0.1191 * x
- - 0.00232;
- }
- vec3 AgXToneMapping( vec3 color ) {
- const mat3 AgXInsetMatrix = mat3(
- vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
- vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
- vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
- );
- const mat3 AgXOutsetMatrix = mat3(
- vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
- vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
- vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
- );
- const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
- color *= toneMappingExposure;
- color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
- color = AgXInsetMatrix * color;
- color = max( color, 1e-10 ); color = log2( color );
- color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
- color = clamp( color, 0.0, 1.0 );
- color = agxDefaultContrastApprox( color );
- color = AgXOutsetMatrix * color;
- color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
- color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
- color = clamp( color, 0.0, 1.0 );
- return color;
- }
- vec3 NeutralToneMapping( vec3 color ) {
- const float StartCompression = 0.8 - 0.04;
- const float Desaturation = 0.15;
- color *= toneMappingExposure;
- float x = min( color.r, min( color.g, color.b ) );
- float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
- color -= offset;
- float peak = max( color.r, max( color.g, color.b ) );
- if ( peak < StartCompression ) return color;
- float d = 1. - StartCompression;
- float newPeak = 1. - d * d / ( peak + d - StartCompression );
- color *= newPeak / peak;
- float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
- return mix( color, vec3( newPeak ), g );
- }
- vec3 CustomToneMapping( vec3 color ) { return color; }`,bOe=`#ifdef USE_TRANSMISSION
- material.transmission = transmission;
- material.transmissionAlpha = 1.0;
- material.thickness = thickness;
- material.attenuationDistance = attenuationDistance;
- material.attenuationColor = attenuationColor;
- #ifdef USE_TRANSMISSIONMAP
- material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
- #endif
- #ifdef USE_THICKNESSMAP
- material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
- #endif
- vec3 pos = vWorldPosition;
- vec3 v = normalize( cameraPosition - pos );
- vec3 n = inverseTransformDirection( normal, viewMatrix );
- vec4 transmitted = getIBLVolumeRefraction(
- n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90,
- pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
- material.attenuationColor, material.attenuationDistance );
- material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
- totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
- #endif`,yOe=`#ifdef USE_TRANSMISSION
- uniform float transmission;
- uniform float thickness;
- uniform float attenuationDistance;
- uniform vec3 attenuationColor;
- #ifdef USE_TRANSMISSIONMAP
- uniform sampler2D transmissionMap;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform sampler2D thicknessMap;
- #endif
- uniform vec2 transmissionSamplerSize;
- uniform sampler2D transmissionSamplerMap;
- uniform mat4 modelMatrix;
- uniform mat4 projectionMatrix;
- varying vec3 vWorldPosition;
- float w0( float a ) {
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
- }
- float w1( float a ) {
- return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
- }
- float w2( float a ){
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
- }
- float w3( float a ) {
- return ( 1.0 / 6.0 ) * ( a * a * a );
- }
- float g0( float a ) {
- return w0( a ) + w1( a );
- }
- float g1( float a ) {
- return w2( a ) + w3( a );
- }
- float h0( float a ) {
- return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
- }
- float h1( float a ) {
- return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
- }
- vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
- uv = uv * texelSize.zw + 0.5;
- vec2 iuv = floor( uv );
- vec2 fuv = fract( uv );
- float g0x = g0( fuv.x );
- float g1x = g1( fuv.x );
- float h0x = h0( fuv.x );
- float h1x = h1( fuv.x );
- float h0y = h0( fuv.y );
- float h1y = h1( fuv.y );
- vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
- vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
- vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
- vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
- return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
- g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
- }
- vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
- vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
- vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
- vec2 fLodSizeInv = 1.0 / fLodSize;
- vec2 cLodSizeInv = 1.0 / cLodSize;
- vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
- vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
- return mix( fSample, cSample, fract( lod ) );
- }
- vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
- vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
- vec3 modelScale;
- modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
- modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
- modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
- return normalize( refractionVector ) * thickness * modelScale;
- }
- float applyIorToRoughness( const in float roughness, const in float ior ) {
- return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
- }
- vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
- float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
- return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
- }
- vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
- if ( isinf( attenuationDistance ) ) {
- return vec3( 1.0 );
- } else {
- vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
- vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
- }
- }
- vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
- const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
- const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
- const in vec3 attenuationColor, const in float attenuationDistance ) {
- vec4 transmittedLight;
- vec3 transmittance;
- #ifdef USE_DISPERSION
- float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
- vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
- for ( int i = 0; i < 3; i ++ ) {
- vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
- vec3 refractedRayExit = position + transmissionRay;
- vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
- vec2 refractionCoords = ndcPos.xy / ndcPos.w;
- refractionCoords += 1.0;
- refractionCoords /= 2.0;
- vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
- transmittedLight[ i ] = transmissionSample[ i ];
- transmittedLight.a += transmissionSample.a;
- transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
- }
- transmittedLight.a /= 3.0;
- #else
- vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
- vec3 refractedRayExit = position + transmissionRay;
- vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
- vec2 refractionCoords = ndcPos.xy / ndcPos.w;
- refractionCoords += 1.0;
- refractionCoords /= 2.0;
- transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
- transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
- #endif
- vec3 attenuatedColor = transmittance * transmittedLight.rgb;
- vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
- float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
- return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
- }
- #endif`,vOe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- varying vec2 vUv;
- #endif
- #ifdef USE_MAP
- varying vec2 vMapUv;
- #endif
- #ifdef USE_ALPHAMAP
- varying vec2 vAlphaMapUv;
- #endif
- #ifdef USE_LIGHTMAP
- varying vec2 vLightMapUv;
- #endif
- #ifdef USE_AOMAP
- varying vec2 vAoMapUv;
- #endif
- #ifdef USE_BUMPMAP
- varying vec2 vBumpMapUv;
- #endif
- #ifdef USE_NORMALMAP
- varying vec2 vNormalMapUv;
- #endif
- #ifdef USE_EMISSIVEMAP
- varying vec2 vEmissiveMapUv;
- #endif
- #ifdef USE_METALNESSMAP
- varying vec2 vMetalnessMapUv;
- #endif
- #ifdef USE_ROUGHNESSMAP
- varying vec2 vRoughnessMapUv;
- #endif
- #ifdef USE_ANISOTROPYMAP
- varying vec2 vAnisotropyMapUv;
- #endif
- #ifdef USE_CLEARCOATMAP
- varying vec2 vClearcoatMapUv;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- varying vec2 vClearcoatNormalMapUv;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- varying vec2 vClearcoatRoughnessMapUv;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- varying vec2 vIridescenceMapUv;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- varying vec2 vIridescenceThicknessMapUv;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- varying vec2 vSheenColorMapUv;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- varying vec2 vSheenRoughnessMapUv;
- #endif
- #ifdef USE_SPECULARMAP
- varying vec2 vSpecularMapUv;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- varying vec2 vSpecularColorMapUv;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- varying vec2 vSpecularIntensityMapUv;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- uniform mat3 transmissionMapTransform;
- varying vec2 vTransmissionMapUv;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform mat3 thicknessMapTransform;
- varying vec2 vThicknessMapUv;
- #endif`,_Oe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- varying vec2 vUv;
- #endif
- #ifdef USE_MAP
- uniform mat3 mapTransform;
- varying vec2 vMapUv;
- #endif
- #ifdef USE_ALPHAMAP
- uniform mat3 alphaMapTransform;
- varying vec2 vAlphaMapUv;
- #endif
- #ifdef USE_LIGHTMAP
- uniform mat3 lightMapTransform;
- varying vec2 vLightMapUv;
- #endif
- #ifdef USE_AOMAP
- uniform mat3 aoMapTransform;
- varying vec2 vAoMapUv;
- #endif
- #ifdef USE_BUMPMAP
- uniform mat3 bumpMapTransform;
- varying vec2 vBumpMapUv;
- #endif
- #ifdef USE_NORMALMAP
- uniform mat3 normalMapTransform;
- varying vec2 vNormalMapUv;
- #endif
- #ifdef USE_DISPLACEMENTMAP
- uniform mat3 displacementMapTransform;
- varying vec2 vDisplacementMapUv;
- #endif
- #ifdef USE_EMISSIVEMAP
- uniform mat3 emissiveMapTransform;
- varying vec2 vEmissiveMapUv;
- #endif
- #ifdef USE_METALNESSMAP
- uniform mat3 metalnessMapTransform;
- varying vec2 vMetalnessMapUv;
- #endif
- #ifdef USE_ROUGHNESSMAP
- uniform mat3 roughnessMapTransform;
- varying vec2 vRoughnessMapUv;
- #endif
- #ifdef USE_ANISOTROPYMAP
- uniform mat3 anisotropyMapTransform;
- varying vec2 vAnisotropyMapUv;
- #endif
- #ifdef USE_CLEARCOATMAP
- uniform mat3 clearcoatMapTransform;
- varying vec2 vClearcoatMapUv;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- uniform mat3 clearcoatNormalMapTransform;
- varying vec2 vClearcoatNormalMapUv;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- uniform mat3 clearcoatRoughnessMapTransform;
- varying vec2 vClearcoatRoughnessMapUv;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- uniform mat3 sheenColorMapTransform;
- varying vec2 vSheenColorMapUv;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- uniform mat3 sheenRoughnessMapTransform;
- varying vec2 vSheenRoughnessMapUv;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- uniform mat3 iridescenceMapTransform;
- varying vec2 vIridescenceMapUv;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform mat3 iridescenceThicknessMapTransform;
- varying vec2 vIridescenceThicknessMapUv;
- #endif
- #ifdef USE_SPECULARMAP
- uniform mat3 specularMapTransform;
- varying vec2 vSpecularMapUv;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- uniform mat3 specularColorMapTransform;
- varying vec2 vSpecularColorMapUv;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- uniform mat3 specularIntensityMapTransform;
- varying vec2 vSpecularIntensityMapUv;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- uniform mat3 transmissionMapTransform;
- varying vec2 vTransmissionMapUv;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform mat3 thicknessMapTransform;
- varying vec2 vThicknessMapUv;
- #endif`,wOe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- vUv = vec3( uv, 1 ).xy;
- #endif
- #ifdef USE_MAP
- vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ALPHAMAP
- vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_LIGHTMAP
- vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_AOMAP
- vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_BUMPMAP
- vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_NORMALMAP
- vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_DISPLACEMENTMAP
- vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_EMISSIVEMAP
- vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_METALNESSMAP
- vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ROUGHNESSMAP
- vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ANISOTROPYMAP
- vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOATMAP
- vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULARMAP
- vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_THICKNESSMAP
- vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
- #endif`,SOe=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
- vec4 worldPosition = vec4( transformed, 1.0 );
- #ifdef USE_BATCHING
- worldPosition = batchingMatrix * worldPosition;
- #endif
- #ifdef USE_INSTANCING
- worldPosition = instanceMatrix * worldPosition;
- #endif
- worldPosition = modelMatrix * worldPosition;
- #endif`;const MOe=`varying vec2 vUv;
- uniform mat3 uvTransform;
- void main() {
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- gl_Position = vec4( position.xy, 1.0, 1.0 );
- }`,NOe=`uniform sampler2D t2D;
- uniform float backgroundIntensity;
- varying vec2 vUv;
- void main() {
- vec4 texColor = texture2D( t2D, vUv );
- #ifdef DECODE_VIDEO_TEXTURE
- texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
- #endif
- texColor.rgb *= backgroundIntensity;
- gl_FragColor = texColor;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,EOe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,AOe=`#ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- uniform sampler2D envMap;
- #endif
- uniform float flipEnvMap;
- uniform float backgroundBlurriness;
- uniform float backgroundIntensity;
- uniform mat3 backgroundRotation;
- varying vec3 vWorldDirection;
- #include <cube_uv_reflection_fragment>
- void main() {
- #ifdef ENVMAP_TYPE_CUBE
- vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
- #else
- vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
- #endif
- texColor.rgb *= backgroundIntensity;
- gl_FragColor = texColor;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,TOe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,COe=`uniform samplerCube tCube;
- uniform float tFlip;
- uniform float opacity;
- varying vec3 vWorldDirection;
- void main() {
- vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
- gl_FragColor = texColor;
- gl_FragColor.a *= opacity;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,kOe=`#include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- varying vec2 vHighPrecisionZW;
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <skinbase_vertex>
- #include <morphinstance_vertex>
- #ifdef USE_DISPLACEMENTMAP
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vHighPrecisionZW = gl_Position.zw;
- }`,jOe=`#if DEPTH_PACKING == 3200
- uniform float opacity;
- #endif
- #include <common>
- #include <packing>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- varying vec2 vHighPrecisionZW;
- void main() {
- vec4 diffuseColor = vec4( 1.0 );
- #include <clipping_planes_fragment>
- #if DEPTH_PACKING == 3200
- diffuseColor.a = opacity;
- #endif
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <logdepthbuf_fragment>
- #ifdef USE_REVERSED_DEPTH_BUFFER
- float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
- #else
- float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
- #endif
- #if DEPTH_PACKING == 3200
- gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
- #elif DEPTH_PACKING == 3201
- gl_FragColor = packDepthToRGBA( fragCoordZ );
- #elif DEPTH_PACKING == 3202
- gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
- #elif DEPTH_PACKING == 3203
- gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
- #endif
- }`,POe=`#define DISTANCE
- varying vec3 vWorldPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <skinbase_vertex>
- #include <morphinstance_vertex>
- #ifdef USE_DISPLACEMENTMAP
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <worldpos_vertex>
- #include <clipping_planes_vertex>
- vWorldPosition = worldPosition.xyz;
- }`,ROe=`#define DISTANCE
- uniform vec3 referencePosition;
- uniform float nearDistance;
- uniform float farDistance;
- varying vec3 vWorldPosition;
- #include <common>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main () {
- vec4 diffuseColor = vec4( 1.0 );
- #include <clipping_planes_fragment>
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- float dist = length( vWorldPosition - referencePosition );
- dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
- dist = saturate( dist );
- gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );
- }`,DOe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }`,OOe=`uniform sampler2D tEquirect;
- varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vec3 direction = normalize( vWorldDirection );
- vec2 sampleUV = equirectUv( direction );
- gl_FragColor = texture2D( tEquirect, sampleUV );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,LOe=`uniform float scale;
- attribute float lineDistance;
- varying float vLineDistance;
- #include <common>
- #include <uv_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- vLineDistance = scale * lineDistance;
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }`,IOe=`uniform vec3 diffuse;
- uniform float opacity;
- uniform float dashSize;
- uniform float totalSize;
- varying float vLineDistance;
- #include <common>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- if ( mod( vLineDistance, totalSize ) > dashSize ) {
- discard;
- }
- vec3 outgoingLight = vec3( 0.0 );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }`,FOe=`#include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <fog_vertex>
- }`,UOe=`uniform vec3 diffuse;
- uniform float opacity;
- #ifndef FLAT_SHADED
- varying vec3 vNormal;
- #endif
- #include <common>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- #ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
- #else
- reflectedLight.indirectDiffuse += vec3( 1.0 );
- #endif
- #include <aomap_fragment>
- reflectedLight.indirectDiffuse *= diffuseColor.rgb;
- vec3 outgoingLight = reflectedLight.indirectDiffuse;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,zOe=`#define LAMBERT
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,BOe=`#define LAMBERT
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float opacity;
- #include <common>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_lambert_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_lambert_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,$Oe=`#define MATCAP
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <color_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- vViewPosition = - mvPosition.xyz;
- }`,HOe=`#define MATCAP
- uniform vec3 diffuse;
- uniform float opacity;
- uniform sampler2D matcap;
- varying vec3 vViewPosition;
- #include <common>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <normal_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- vec3 viewDir = normalize( vViewPosition );
- vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
- vec3 y = cross( viewDir, x );
- vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
- #ifdef USE_MATCAP
- vec4 matcapColor = texture2D( matcap, uv );
- #else
- vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
- #endif
- vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,VOe=`#define NORMAL
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- varying vec3 vViewPosition;
- #endif
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphinstance_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- vViewPosition = - mvPosition.xyz;
- #endif
- }`,GOe=`#define NORMAL
- uniform float opacity;
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- varying vec3 vViewPosition;
- #endif
- #include <uv_pars_fragment>
- #include <normal_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
- #include <clipping_planes_fragment>
- #include <logdepthbuf_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a );
- #ifdef OPAQUE
- gl_FragColor.a = 1.0;
- #endif
- }`,WOe=`#define PHONG
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphinstance_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,qOe=`#define PHONG
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform vec3 specular;
- uniform float shininess;
- uniform float opacity;
- #include <common>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_phong_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_phong_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,KOe=`#define STANDARD
- varying vec3 vViewPosition;
- #ifdef USE_TRANSMISSION
- varying vec3 vWorldPosition;
- #endif
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- #ifdef USE_TRANSMISSION
- vWorldPosition = worldPosition.xyz;
- #endif
- }`,XOe=`#define STANDARD
- #ifdef PHYSICAL
- #define IOR
- #define USE_SPECULAR
- #endif
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float roughness;
- uniform float metalness;
- uniform float opacity;
- #ifdef IOR
- uniform float ior;
- #endif
- #ifdef USE_SPECULAR
- uniform float specularIntensity;
- uniform vec3 specularColor;
- #ifdef USE_SPECULAR_COLORMAP
- uniform sampler2D specularColorMap;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- uniform sampler2D specularIntensityMap;
- #endif
- #endif
- #ifdef USE_CLEARCOAT
- uniform float clearcoat;
- uniform float clearcoatRoughness;
- #endif
- #ifdef USE_DISPERSION
- uniform float dispersion;
- #endif
- #ifdef USE_IRIDESCENCE
- uniform float iridescence;
- uniform float iridescenceIOR;
- uniform float iridescenceThicknessMinimum;
- uniform float iridescenceThicknessMaximum;
- #endif
- #ifdef USE_SHEEN
- uniform vec3 sheenColor;
- uniform float sheenRoughness;
- #ifdef USE_SHEEN_COLORMAP
- uniform sampler2D sheenColorMap;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- uniform sampler2D sheenRoughnessMap;
- #endif
- #endif
- #ifdef USE_ANISOTROPY
- uniform vec2 anisotropyVector;
- #ifdef USE_ANISOTROPYMAP
- uniform sampler2D anisotropyMap;
- #endif
- #endif
- varying vec3 vViewPosition;
- #include <common>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <iridescence_fragment>
- #include <cube_uv_reflection_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_physical_pars_fragment>
- #include <fog_pars_fragment>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_physical_pars_fragment>
- #include <transmission_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <clearcoat_pars_fragment>
- #include <iridescence_pars_fragment>
- #include <roughnessmap_pars_fragment>
- #include <metalnessmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <roughnessmap_fragment>
- #include <metalnessmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <clearcoat_normal_fragment_begin>
- #include <clearcoat_normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_physical_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
- vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
- #include <transmission_fragment>
- vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
- #ifdef USE_SHEEN
-
- outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect;
-
- #endif
- #ifdef USE_CLEARCOAT
- float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
- vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
- outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
- #endif
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,YOe=`#define TOON
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,QOe=`#define TOON
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float opacity;
- #include <common>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <gradientmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_toon_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_toon_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,ZOe=`uniform float size;
- uniform float scale;
- #include <common>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- #ifdef USE_POINTS_UV
- varying vec2 vUv;
- uniform mat3 uvTransform;
- #endif
- void main() {
- #ifdef USE_POINTS_UV
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- #endif
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <project_vertex>
- gl_PointSize = size;
- #ifdef USE_SIZEATTENUATION
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
- if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
- #endif
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <worldpos_vertex>
- #include <fog_vertex>
- }`,JOe=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <color_pars_fragment>
- #include <map_particle_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- #include <logdepthbuf_fragment>
- #include <map_particle_fragment>
- #include <color_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }`,e4e=`#include <common>
- #include <batching_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <shadowmap_pars_vertex>
- void main() {
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphinstance_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,t4e=`uniform vec3 color;
- uniform float opacity;
- #include <common>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <logdepthbuf_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <shadowmask_pars_fragment>
- void main() {
- #include <logdepthbuf_fragment>
- gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,n4e=`uniform float rotation;
- uniform vec2 center;
- #include <common>
- #include <uv_pars_vertex>
- #include <fog_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- vec4 mvPosition = modelViewMatrix[ 3 ];
- vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
- #ifndef USE_SIZEATTENUATION
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
- if ( isPerspective ) scale *= - mvPosition.z;
- #endif
- vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
- vec2 rotatedPosition;
- rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
- rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
- mvPosition.xy += rotatedPosition;
- gl_Position = projectionMatrix * mvPosition;
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }`,r4e=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,wn={alphahash_fragment:NRe,alphahash_pars_fragment:ERe,alphamap_fragment:ARe,alphamap_pars_fragment:TRe,alphatest_fragment:CRe,alphatest_pars_fragment:kRe,aomap_fragment:jRe,aomap_pars_fragment:PRe,batching_pars_vertex:RRe,batching_vertex:DRe,begin_vertex:ORe,beginnormal_vertex:LRe,bsdfs:IRe,iridescence_fragment:FRe,bumpmap_pars_fragment:URe,clipping_planes_fragment:zRe,clipping_planes_pars_fragment:BRe,clipping_planes_pars_vertex:$Re,clipping_planes_vertex:HRe,color_fragment:VRe,color_pars_fragment:GRe,color_pars_vertex:WRe,color_vertex:qRe,common:KRe,cube_uv_reflection_fragment:XRe,defaultnormal_vertex:YRe,displacementmap_pars_vertex:QRe,displacementmap_vertex:ZRe,emissivemap_fragment:JRe,emissivemap_pars_fragment:eDe,colorspace_fragment:tDe,colorspace_pars_fragment:nDe,envmap_fragment:rDe,envmap_common_pars_fragment:iDe,envmap_pars_fragment:aDe,envmap_pars_vertex:sDe,envmap_physical_pars_fragment:xDe,envmap_vertex:oDe,fog_vertex:lDe,fog_pars_vertex:cDe,fog_fragment:uDe,fog_pars_fragment:dDe,gradientmap_pars_fragment:hDe,lightmap_pars_fragment:fDe,lights_lambert_fragment:mDe,lights_lambert_pars_fragment:pDe,lights_pars_begin:gDe,lights_toon_fragment:bDe,lights_toon_pars_fragment:yDe,lights_phong_fragment:vDe,lights_phong_pars_fragment:_De,lights_physical_fragment:wDe,lights_physical_pars_fragment:SDe,lights_fragment_begin:MDe,lights_fragment_maps:NDe,lights_fragment_end:EDe,logdepthbuf_fragment:ADe,logdepthbuf_pars_fragment:TDe,logdepthbuf_pars_vertex:CDe,logdepthbuf_vertex:kDe,map_fragment:jDe,map_pars_fragment:PDe,map_particle_fragment:RDe,map_particle_pars_fragment:DDe,metalnessmap_fragment:ODe,metalnessmap_pars_fragment:LDe,morphinstance_vertex:IDe,morphcolor_vertex:FDe,morphnormal_vertex:UDe,morphtarget_pars_vertex:zDe,morphtarget_vertex:BDe,normal_fragment_begin:$De,normal_fragment_maps:HDe,normal_pars_fragment:VDe,normal_pars_vertex:GDe,normal_vertex:WDe,normalmap_pars_fragment:qDe,clearcoat_normal_fragment_begin:KDe,clearcoat_normal_fragment_maps:XDe,clearcoat_pars_fragment:YDe,iridescence_pars_fragment:QDe,opaque_fragment:ZDe,packing:JDe,premultiplied_alpha_fragment:eOe,project_vertex:tOe,dithering_fragment:nOe,dithering_pars_fragment:rOe,roughnessmap_fragment:iOe,roughnessmap_pars_fragment:aOe,shadowmap_pars_fragment:sOe,shadowmap_pars_vertex:oOe,shadowmap_vertex:lOe,shadowmask_pars_fragment:cOe,skinbase_vertex:uOe,skinning_pars_vertex:dOe,skinning_vertex:hOe,skinnormal_vertex:fOe,specularmap_fragment:mOe,specularmap_pars_fragment:pOe,tonemapping_fragment:gOe,tonemapping_pars_fragment:xOe,transmission_fragment:bOe,transmission_pars_fragment:yOe,uv_pars_fragment:vOe,uv_pars_vertex:_Oe,uv_vertex:wOe,worldpos_vertex:SOe,background_vert:MOe,background_frag:NOe,backgroundCube_vert:EOe,backgroundCube_frag:AOe,cube_vert:TOe,cube_frag:COe,depth_vert:kOe,depth_frag:jOe,distance_vert:POe,distance_frag:ROe,equirect_vert:DOe,equirect_frag:OOe,linedashed_vert:LOe,linedashed_frag:IOe,meshbasic_vert:FOe,meshbasic_frag:UOe,meshlambert_vert:zOe,meshlambert_frag:BOe,meshmatcap_vert:$Oe,meshmatcap_frag:HOe,meshnormal_vert:VOe,meshnormal_frag:GOe,meshphong_vert:WOe,meshphong_frag:qOe,meshphysical_vert:KOe,meshphysical_frag:XOe,meshtoon_vert:YOe,meshtoon_frag:QOe,points_vert:ZOe,points_frag:JOe,shadow_vert:e4e,shadow_frag:t4e,sprite_vert:n4e,sprite_frag:r4e},Ft={common:{diffuse:{value:new Rn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new En},alphaMap:{value:null},alphaMapTransform:{value:new En},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new En}},envmap:{envMap:{value:null},envMapRotation:{value:new En},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 En}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new En}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new En},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new En},normalScale:{value:new Mn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new En},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new En}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new En}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new En}},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 En},alphaTest:{value:0},uvTransform:{value:new En}},sprite:{diffuse:{value:new Rn(16777215)},opacity:{value:1},center:{value:new Mn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new En},alphaMap:{value:null},alphaMapTransform:{value:new En},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 En},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 En}},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 En},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new En},clearcoatNormalScale:{value:new Mn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new En},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new En},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new En},sheen:{value:0},sheenColor:{value:new Rn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new En},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new En},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new En},transmissionSamplerSize:{value:new Mn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new En},attenuationDistance:{value:0},attenuationColor:{value:new Rn(0)},specularColor:{value:new Rn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new En},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new En},anisotropyVector:{value:new Mn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new En}}]),vertexShader:wn.meshphysical_vert,fragmentShader:wn.meshphysical_frag};const Z_={r:0,b:0,g:0},Bh=new th,i4e=new mi;function a4e(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 E=M.isScene===!0?M.background:null;return E&&E.isTexture&&(E=(M.backgroundBlurriness>0?n:e).get(E)),E}function y(M){let E=!1;const A=b(M);A===null?v(l,c):A&&A.isColor&&(v(A,1),E=!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||E)&&(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,E){const A=b(E);A&&(A.isCubeTexture||A.mapping===cE)?(d===void 0&&(d=new hl(new lL(1,1,1),new ic({name:"BackgroundCubeMaterial",uniforms:jg(Ll.backgroundCube.uniforms),vertexShader:Ll.backgroundCube.vertexShader,fragmentShader:Ll.backgroundCube.fragmentShader,side:ws,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(k,T,D){this.matrixWorld.copyPosition(D.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),Bh.copy(E.backgroundRotation),Bh.x*=-1,Bh.y*=-1,Bh.z*=-1,A.isCubeTexture&&A.isRenderTargetTexture===!1&&(Bh.y*=-1,Bh.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=E.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=E.backgroundIntensity,d.material.uniforms.backgroundRotation.value.setFromMatrix4(i4e.makeRotationFromEuler(Bh)),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 uL(2,2),new ic({name:"BackgroundMaterial",uniforms:jg(Ll.background.uniforms),vertexShader:Ll.background.vertexShader,fragmentShader:Ll.background.fragmentShader,side:eh,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=E.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 v(M,E){M.getRGB(Z_,wee(t)),r.buffers.color.setClear(Z_.r,Z_.g,Z_.b,E,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,E=1){l.set(M),c=E,v(l,c)},getClearAlpha:function(){return c},setClearAlpha:function(M){c=M,v(l,c)},render:y,addToRenderList:x,dispose:S}}function s4e(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),r={},i=m(null);let a=i,o=!1;function l(R,U,O,q,j){let W=!1;const X=f(q,O,U);a!==X&&(a=X,u(a.object)),W=p(R,q,O,j),W&&b(R,q,O,j),j!==null&&e.update(j,t.ELEMENT_ARRAY_BUFFER),(W||o)&&(o=!1,E(R,U,O,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,O){const q=O.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 X=W[q];return X===void 0&&(X=m(c()),W[q]=X),X}function m(R){const U=[],O=[],q=[];for(let j=0;j<n;j++)U[j]=0,O[j]=0,q[j]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:U,enabledAttributes:O,attributeDivisors:q,object:R,attributes:{},index:null}}function p(R,U,O,q){const j=a.attributes,W=U.attributes;let X=0;const G=O.getAttributes();for(const Z in G)if(G[Z].location>=0){const ee=j[Z];let z=W[Z];if(z===void 0&&(Z==="instanceMatrix"&&R.instanceMatrix&&(z=R.instanceMatrix),Z==="instanceColor"&&R.instanceColor&&(z=R.instanceColor)),ee===void 0||ee.attribute!==z||z&&ee.data!==z.data)return!0;X++}return a.attributesNum!==X||a.index!==q}function b(R,U,O,q){const j={},W=U.attributes;let X=0;const G=O.getAttributes();for(const Z in G)if(G[Z].location>=0){let ee=W[Z];ee===void 0&&(Z==="instanceMatrix"&&R.instanceMatrix&&(ee=R.instanceMatrix),Z==="instanceColor"&&R.instanceColor&&(ee=R.instanceColor));const z={};z.attribute=ee,ee&&ee.data&&(z.data=ee.data),j[Z]=z,X++}a.attributes=j,a.attributesNum=X,a.index=q}function y(){const R=a.newAttributes;for(let U=0,O=R.length;U<O;U++)R[U]=0}function x(R){v(R,0)}function v(R,U){const O=a.newAttributes,q=a.enabledAttributes,j=a.attributeDivisors;O[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 O=0,q=U.length;O<q;O++)U[O]!==R[O]&&(t.disableVertexAttribArray(O),U[O]=0)}function M(R,U,O,q,j,W,X){X===!0?t.vertexAttribIPointer(R,U,O,j,W):t.vertexAttribPointer(R,U,O,q,j,W)}function E(R,U,O,q){y();const j=q.attributes,W=O.getAttributes(),X=U.defaultAttributeValues;for(const G in W){const Z=W[G];if(Z.location>=0){let te=j[G];if(te===void 0&&(G==="instanceMatrix"&&R.instanceMatrix&&(te=R.instanceMatrix),G==="instanceColor"&&R.instanceColor&&(te=R.instanceColor)),te!==void 0){const ee=te.normalized,z=te.itemSize,V=e.get(te);if(V===void 0)continue;const ne=V.buffer,ie=V.type,he=V.bytesPerElement,me=ie===t.INT||ie===t.UNSIGNED_INT||te.gpuType===Q4;if(te.isInterleavedBufferAttribute){const oe=te.data,Ae=oe.stride,ge=te.offset;if(oe.isInstancedInterleavedBuffer){for(let Ne=0;Ne<Z.locationSize;Ne++)v(Z.location+Ne,oe.meshPerAttribute);R.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=oe.meshPerAttribute*oe.count)}else for(let Ne=0;Ne<Z.locationSize;Ne++)x(Z.location+Ne);t.bindBuffer(t.ARRAY_BUFFER,ne);for(let Ne=0;Ne<Z.locationSize;Ne++)M(Z.location+Ne,z/Z.locationSize,ie,ee,Ae*he,(ge+z/Z.locationSize*Ne)*he,me)}else{if(te.isInstancedBufferAttribute){for(let oe=0;oe<Z.locationSize;oe++)v(Z.location+oe,te.meshPerAttribute);R.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=te.meshPerAttribute*te.count)}else for(let oe=0;oe<Z.locationSize;oe++)x(Z.location+oe);t.bindBuffer(t.ARRAY_BUFFER,ne);for(let oe=0;oe<Z.locationSize;oe++)M(Z.location+oe,z/Z.locationSize,ie,ee,z*he,z/Z.locationSize*oe*he,me)}}else if(X!==void 0){const ee=X[G];if(ee!==void 0)switch(ee.length){case 2:t.vertexAttrib2fv(Z.location,ee);break;case 3:t.vertexAttrib3fv(Z.location,ee);break;case 4:t.vertexAttrib4fv(Z.location,ee);break;default:t.vertexAttrib1fv(Z.location,ee)}}}}S()}function A(){D();for(const R in r){const U=r[R];for(const O in U){const q=U[O];for(const j in q)d(q[j].object),delete q[j];delete U[O]}delete r[R]}}function k(R){if(r[R.id]===void 0)return;const U=r[R.id];for(const O in U){const q=U[O];for(const j in q)d(q[j].object),delete q[j];delete U[O]}delete r[R.id]}function T(R){for(const U in r){const O=r[U];if(O[R.id]===void 0)continue;const q=O[R.id];for(const j in q)d(q[j].object),delete q[j];delete O[R.id]}}function D(){C(),o=!0,a!==i&&(a=i,u(a.object))}function C(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:l,reset:D,resetDefaultState:C,dispose:A,releaseStatesOfGeometry:k,releaseStatesOfProgram:T,initAttributes:y,enableAttribute:x,disableUnusedAttributes:S}}function o4e(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 y=0;y<f;y++)b+=d[y]*m[y];n.update(b,r,1)}}this.setMode=i,this.render=a,this.renderInstances=o,this.renderMultiDraw=l,this.renderMultiDrawInstances=c}function l4e(t,e,n,r){let i;function a(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const T=e.get("EXT_texture_filter_anisotropic");i=t.getParameter(T.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function o(T){return!(T!==nl&&r.convert(T)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT))}function l(T){const D=T===vu&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(T!==Hs&&r.convert(T)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&T!==$l&&!D)}function c(T){if(T==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";T="mediump"}return T==="mediump"&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let u=n.precision!==void 0?n.precision:"highp";const d=c(u);d!==u&&(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),y=t.getParameter(t.MAX_TEXTURE_SIZE),x=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),v=t.getParameter(t.MAX_VERTEX_ATTRIBS),S=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),M=t.getParameter(t.MAX_VARYING_VECTORS),E=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:y,maxCubemapSize:x,maxAttributes:v,maxVertexUniforms:S,maxVaryings:M,maxFragmentUniforms:E,maxSamples:A,samples:k}}function c4e(t){const e=this;let n=null,r=0,i=!1,a=!1;const o=new bd,l=new En,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,y=f.clipIntersection,x=f.clipShadows,v=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 E=v.clippingState||null;c.value=E,E=d(b,m,M,p);for(let A=0;A!==M;++A)E[A]=n[A];v.clippingState=E,this.numIntersection=y?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 y=f!==null?f.length:0;let x=null;if(y!==0){if(x=c.value,b!==!0||x===null){const v=p+y*4,S=m.matrixWorldInverse;l.getNormalMatrix(S),(x===null||x.length<v)&&(x=new Float32Array(v));for(let M=0,E=p;M!==y;++M,E+=4)o.copy(f[M]).applyMatrix4(S,l),o.normal.toArray(x,E),x[E+3]=o.constant}c.value=x,c.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,x}}function u4e(t){let e=new WeakMap;function n(o,l){return l===O3?o.mapping=Zf:l===L3&&(o.mapping=Tg),o}function r(o){if(o&&o.isTexture){const l=o.mapping;if(l===O3||l===L3)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 Nee(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 kd=4,ZV=[.125,.215,.35,.446,.526,.582],tf=20,d4e=256,Mb=new dL,JV=new Rn;let vk=null,_k=0,wk=0,Sk=!1;const h4e=new nt;let eG=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=h4e}=a;vk=this._renderer.getRenderTarget(),_k=this._renderer.getActiveCubeFace(),wk=this._renderer.getActiveMipmapLevel(),Sk=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=rG(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=nG(),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(vk,_k,wk),this._renderer.xr.enabled=Sk,e.scissorTest=!1,fp(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===Zf||e.mapping===Tg?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),vk=this._renderer.getRenderTarget(),_k=this._renderer.getActiveCubeFace(),wk=this._renderer.getActiveMipmapLevel(),Sk=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:vu,format:nl,colorSpace:kg,depthBuffer:!1},i=tG(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=tG(e,n,r);const{_lodMax:a}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=f4e(a)),this._blurMaterial=p4e(a,e,n),this._ggxMaterial=m4e(a,e,n)}return i}_compileMaterial(e){const n=new hl(new yl,e);this._renderer.compile(n,Mb)}_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(JV),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 lL,new oL({name:"PMREM.Background",side:ws,depthWrite:!1,depthTest:!1})));const y=this._backgroundBox,x=y.material;let v=!1;const S=e.background;S?S.isColor&&(x.color.copy(S),e.background=null,v=!0):(x.color.copy(JV),v=!0);for(let M=0;M<6;M++){const E=M%3;E===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)):E===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;fp(i,E*A,M>2?A:0,A,A),f.setRenderTarget(i),v&&f.render(y,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===Tg;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=rG()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=nG());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;fp(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(o,Mb)}_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,y=this._sizeLods[r],x=3*y*(r>b-kd?r-b+kd:0),v=4*(this._cubeSize-y);c.envMap.value=e.texture,c.roughness.value=p,c.mipInt.value=b-n,fp(a,x,v,3*y,2*y),i.setRenderTarget(a),i.render(l,Mb),c.envMap.value=a.texture,c.roughness.value=0,c.mipInt.value=b-r,fp(e,x,v,3*y,2*y),i.setRenderTarget(e),i.render(l,Mb)}_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*tf-1),y=a/b,x=isFinite(a)?1+Math.floor(d*y):tf;x>tf&&un(`sigmaRadians, ${a}, is too large and will clip, as it requested ${x} samples when the maximum is set to ${tf}`);const v=[];let S=0;for(let T=0;T<tf;++T){const D=T/y,C=Math.exp(-D*D/2);v.push(C),T===0?S+=C:T<x&&(S+=2*C)}for(let T=0;T<v.length;T++)v[T]=v[T]/S;m.envMap.value=e.texture,m.samples.value=x,m.weights.value=v,m.latitudinal.value=o==="latitudinal",l&&(m.poleAxis.value=l);const{_lodMax:M}=this;m.dTheta.value=b,m.mipInt.value=M-r;const E=this._sizeLods[i],A=3*E*(i>M-kd?i-M+kd:0),k=4*(this._cubeSize-E);fp(n,A,k,3*E,2*E),c.setRenderTarget(n),c.render(f,Mb)}};function f4e(t){const e=[],n=[],r=[];let i=t;const a=t-kd+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-kd?c=ZV[o-t+kd-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,y=3,x=2,v=1,S=new Float32Array(y*b*p),M=new Float32Array(x*b*p),E=new Float32Array(v*b*p);for(let k=0;k<p;k++){const T=k%3*2/3-1,D=k>2?0:-1,C=[T,D,0,T+2/3,D,0,T+2/3,D+1,0,T,D,0,T+2/3,D+1,0,T,D+1,0];S.set(C,y*b*k),M.set(m,x*b*k);const R=[k,k,k,k,k,k];E.set(R,v*b*k)}const A=new yl;A.setAttribute("position",new Co(S,y)),A.setAttribute("uv",new Co(M,x)),A.setAttribute("faceIndex",new Co(E,v)),r.push(new hl(A,null)),i>kd&&i--}return{lodMeshes:r,sizeLods:e,sigmas:n}}function tG(t,e,n){const r=new Kl(t,e,n);return r.texture.mapping=cE,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function fp(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function m4e(t,e,n){return new ic({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:d4e,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:dE(),fragmentShader:`
- precision highp float;
- precision highp int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- uniform float roughness;
- uniform float mipInt;
- #define ENVMAP_TYPE_CUBE_UV
- #include <cube_uv_reflection_fragment>
- #define PI 3.14159265359
- // Van der Corput radical inverse
- float radicalInverse_VdC(uint bits) {
- bits = (bits << 16u) | (bits >> 16u);
- bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
- bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
- bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
- bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
- return float(bits) * 2.3283064365386963e-10; // / 0x100000000
- }
- // Hammersley sequence
- vec2 hammersley(uint i, uint N) {
- return vec2(float(i) / float(N), radicalInverse_VdC(i));
- }
- // GGX VNDF importance sampling (Eric Heitz 2018)
- // "Sampling the GGX Distribution of Visible Normals"
- // https://jcgt.org/published/0007/04/01/
- vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
- float alpha = roughness * roughness;
- // Section 3.2: Transform view direction to hemisphere configuration
- vec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z));
- // Section 4.1: Orthonormal basis
- float lensq = Vh.x * Vh.x + Vh.y * Vh.y;
- vec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0);
- vec3 T2 = cross(Vh, T1);
- // Section 4.2: Parameterization of projected area
- float r = sqrt(Xi.x);
- float phi = 2.0 * PI * Xi.y;
- float t1 = r * cos(phi);
- float t2 = r * sin(phi);
- float s = 0.5 * (1.0 + Vh.z);
- t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
- // Section 4.3: Reprojection onto hemisphere
- vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh;
- // Section 3.4: Transform back to ellipsoid configuration
- return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
- }
- void main() {
- vec3 N = normalize(vOutputDirection);
- vec3 V = N; // Assume view direction equals normal for pre-filtering
- vec3 prefilteredColor = vec3(0.0);
- float totalWeight = 0.0;
- // For very low roughness, just sample the environment directly
- if (roughness < 0.001) {
- gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
- return;
- }
- // Tangent space basis for VNDF sampling
- vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
- vec3 tangent = normalize(cross(up, N));
- vec3 bitangent = cross(N, tangent);
- for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
- vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
- // For PMREM, V = N, so in tangent space V is always (0, 0, 1)
- vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
- // Transform H back to world space
- vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
- vec3 L = normalize(2.0 * dot(V, H) * H - V);
- float NdotL = max(dot(N, L), 0.0);
- if(NdotL > 0.0) {
- // Sample environment at fixed mip level
- // VNDF importance sampling handles the distribution filtering
- vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
- // Weight by NdotL for the split-sum approximation
- // VNDF PDF naturally accounts for the visible microfacet distribution
- prefilteredColor += sampleColor * NdotL;
- totalWeight += NdotL;
- }
- }
- if (totalWeight > 0.0) {
- prefilteredColor = prefilteredColor / totalWeight;
- }
- gl_FragColor = vec4(prefilteredColor, 1.0);
- }
- `,blending:su,depthTest:!1,depthWrite:!1})}function p4e(t,e,n){const r=new Float32Array(tf),i=new nt(0,1,0);return new ic({name:"SphericalGaussianBlur",defines:{n:tf,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:dE(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- uniform int samples;
- uniform float weights[ n ];
- uniform bool latitudinal;
- uniform float dTheta;
- uniform float mipInt;
- uniform vec3 poleAxis;
- #define ENVMAP_TYPE_CUBE_UV
- #include <cube_uv_reflection_fragment>
- vec3 getSample( float theta, vec3 axis ) {
- float cosTheta = cos( theta );
- // Rodrigues' axis-angle rotation
- vec3 sampleDirection = vOutputDirection * cosTheta
- + cross( axis, vOutputDirection ) * sin( theta )
- + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
- return bilinearCubeUV( envMap, sampleDirection, mipInt );
- }
- void main() {
- vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
- if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
- axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
- }
- axis = normalize( axis );
- gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
- gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
- for ( int i = 1; i < n; i++ ) {
- if ( i >= samples ) {
- break;
- }
- float theta = dTheta * float( i );
- gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
- gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
- }
- }
- `,blending:su,depthTest:!1,depthWrite:!1})}function nG(){return new ic({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:dE(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- #include <common>
- void main() {
- vec3 outputDirection = normalize( vOutputDirection );
- vec2 uv = equirectUv( outputDirection );
- gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
- }
- `,blending:su,depthTest:!1,depthWrite:!1})}function rG(){return new ic({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:dE(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- uniform float flipEnvMap;
- varying vec3 vOutputDirection;
- uniform samplerCube envMap;
- void main() {
- gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
- }
- `,blending:su,depthTest:!1,depthWrite:!1})}function dE(){return`
- precision mediump float;
- precision mediump int;
- attribute float faceIndex;
- varying vec3 vOutputDirection;
- // RH coordinate system; PMREM face-indexing convention
- vec3 getDirection( vec2 uv, float face ) {
- uv = 2.0 * uv - 1.0;
- vec3 direction = vec3( uv, 1.0 );
- if ( face == 0.0 ) {
- direction = direction.zyx; // ( 1, v, u ) pos x
- } else if ( face == 1.0 ) {
- direction = direction.xzy;
- direction.xz *= -1.0; // ( -u, 1, -v ) pos y
- } else if ( face == 2.0 ) {
- direction.x *= -1.0; // ( -u, v, 1 ) pos z
- } else if ( face == 3.0 ) {
- direction = direction.zyx;
- direction.xz *= -1.0; // ( -1, v, -u ) neg x
- } else if ( face == 4.0 ) {
- direction = direction.xzy;
- direction.xy *= -1.0; // ( -u, -1, v ) neg y
- } else if ( face == 5.0 ) {
- direction.z *= -1.0; // ( u, v, -1 ) neg z
- }
- return direction;
- }
- void main() {
- vOutputDirection = getDirection( uv, faceIndex );
- gl_Position = vec4( position, 1.0 );
- }
- `}function g4e(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,u=c===O3||c===L3,d=c===Zf||c===Tg;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 eG(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 eG(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 x4e(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&&X0("WebGLRenderer: "+r+" extension not supported."),i}}}function b4e(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 y=0;if(p!==null){const S=p.array;y=p.version;for(let M=0,E=S.length;M<E;M+=3){const A=S[M+0],k=S[M+1],T=S[M+2];m.push(A,k,k,T,T,A)}}else if(b!==void 0){const S=b.array;y=b.version;for(let M=0,E=S.length/3-1;M<E;M+=3){const A=M+0,k=M+1,T=M+2;m.push(A,k,k,T,T,A)}}else return;const x=new(cee(m)?yee:bee)(m,1);x.version=y;const v=a.get(f);v&&e.remove(v),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 y4e(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 v=0;v<b;v++)x+=p[v];n.update(x,r,1)}function f(m,p,b,y){if(b===0)return;const x=e.get("WEBGL_multi_draw");if(x===null)for(let v=0;v<m.length;v++)u(m[v]/o,p[v],y[v]);else{x.multiDrawElementsInstancedWEBGL(r,p,0,a,m,0,y,0,b);let v=0;for(let S=0;S<b;S++)v+=p[S]*y[S];n.update(v,r,1)}}this.setMode=i,this.setIndex=l,this.render=c,this.renderInstances=u,this.renderMultiDraw=d,this.renderMultiDrawInstances=f}function v4e(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 _4e(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,y=l.morphAttributes.normal!==void 0,x=l.morphAttributes.color!==void 0,v=l.morphAttributes.position||[],S=l.morphAttributes.normal||[],M=l.morphAttributes.color||[];let E=0;b===!0&&(E=1),y===!0&&(E=2),x===!0&&(E=3);let A=l.attributes.position.count*E,k=1;A>e.maxTextureSize&&(k=Math.ceil(A/e.maxTextureSize),A=e.maxTextureSize);const T=new Float32Array(A*k*4*f),D=new mee(T,A,k,f);D.type=$l,D.needsUpdate=!0;const C=E*4;for(let U=0;U<f;U++){const O=v[U],q=S[U],j=M[U],W=A*k*4*U;for(let X=0;X<O.count;X++){const G=X*C;b===!0&&(i.fromBufferAttribute(O,X),T[W+G+0]=i.x,T[W+G+1]=i.y,T[W+G+2]=i.z,T[W+G+3]=0),y===!0&&(i.fromBufferAttribute(q,X),T[W+G+4]=i.x,T[W+G+5]=i.y,T[W+G+6]=i.z,T[W+G+7]=0),x===!0&&(i.fromBufferAttribute(j,X),T[W+G+8]=i.x,T[W+G+9]=i.y,T[W+G+10]=i.z,T[W+G+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 y=l.morphTargetsRelative?1:1-b;c.getUniforms().setValue(t,"morphTargetBaseInfluence",y),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 w4e(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 S4e={[qJ]:"LINEAR_TONE_MAPPING",[KJ]:"REINHARD_TONE_MAPPING",[XJ]:"CINEON_TONE_MAPPING",[YJ]:"ACES_FILMIC_TONE_MAPPING",[ZJ]:"AGX_TONE_MAPPING",[JJ]:"NEUTRAL_TONE_MAPPING",[QJ]:"CUSTOM_TONE_MAPPING"};function M4e(t,e,n,r,i){const a=new Kl(e,n,{type:t,depthBuffer:r,stencilBuffer:i}),o=new Kl(e,n,{type:vu,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 fRe({uniforms:{tDiffuse:{value:null}},vertexShader:`
- precision highp float;
- uniform mat4 modelViewMatrix;
- uniform mat4 projectionMatrix;
- attribute vec3 position;
- attribute vec2 uv;
- varying vec2 vUv;
- void main() {
- vUv = uv;
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
- }`,fragmentShader:`
- precision highp float;
- uniform sampler2D tDiffuse;
- varying vec2 vUv;
- #include <tonemapping_pars_fragment>
- #include <colorspace_pars_fragment>
- void main() {
- gl_FragColor = texture2D( tDiffuse, vUv );
- #ifdef LINEAR_TONE_MAPPING
- gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );
- #elif defined( REINHARD_TONE_MAPPING )
- gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );
- #elif defined( CINEON_TONE_MAPPING )
- gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );
- #elif defined( ACES_FILMIC_TONE_MAPPING )
- gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );
- #elif defined( AGX_TONE_MAPPING )
- gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );
- #elif defined( NEUTRAL_TONE_MAPPING )
- gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );
- #elif defined( CUSTOM_TONE_MAPPING )
- gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );
- #endif
- #ifdef SRGB_TRANSFER
- gl_FragColor = sRGBTransferOETF( gl_FragColor );
- #endif
- }`,depthTest:!1,depthWrite:!1}),u=new hl(l,c),d=new dL(-1,1,1,-1,0,1);let f=null,m=null,p=!1,b,y=null,x=[],v=!1;this.setSize=function(S,M){a.setSize(S,M),o.setSize(S,M);for(let E=0;E<x.length;E++){const A=x[E];A.setSize&&A.setSize(S,M)}},this.setEffects=function(S){x=S,v=x.length>0&&x[0].isRenderPass===!0;const M=a.width,E=a.height;for(let A=0;A<x.length;A++){const k=x[A];k.setSize&&k.setSize(M,E)}},this.begin=function(S,M){if(p||S.toneMapping===ql&&x.length===0)return!1;if(y=M,M!==null){const E=M.width,A=M.height;(a.width!==E||a.height!==A)&&this.setSize(E,A)}return v===!1&&S.setRenderTarget(a),b=S.toneMapping,S.toneMapping=ql,!0},this.hasRenderPass=function(){return v},this.end=function(S,M){S.toneMapping=b,p=!0;let E=a,A=o;for(let k=0;k<x.length;k++){const T=x[k];if(T.enabled!==!1&&(T.render(S,A,E,M),T.needsSwap!==!1)){const D=E;E=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=S4e[m];k&&(c.defines[k]=""),c.needsUpdate=!0}c.uniforms.tDiffuse.value=E.texture,S.setRenderTarget(y),S.render(u,d),y=null,p=!1},this.isCompositing=function(){return p},this.dispose=function(){a.dispose(),o.dispose(),l.dispose(),c.dispose()}}const jee=new bl,yR=new Y0(1,1),Pee=new mee,Ree=new B3e,Dee=new Mee,iG=[],aG=[],sG=new Float32Array(16),oG=new Float32Array(9),lG=new Float32Array(4);function ux(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let a=iG[i];if(a===void 0&&(a=new Float32Array(i),iG[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 hE(t,e){let n=aG[e];n===void 0&&(n=new Int32Array(e),aG[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function N4e(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 A4e(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 T4e(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 C4e(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;lG.set(r),t.uniformMatrix2fv(this.addr,!1,lG),Ii(n,r)}}function k4e(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;oG.set(r),t.uniformMatrix3fv(this.addr,!1,oG),Ii(n,r)}}function j4e(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;sG.set(r),t.uniformMatrix4fv(this.addr,!1,sG),Ii(n,r)}}function P4e(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function R4e(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 D4e(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 O4e(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 L4e(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function I4e(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 F4e(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 U4e(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 z4e(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?(yR.compareFunction=n.isReversedDepthBuffer()?iL:rL,a=yR):a=jee,n.setTexture2D(e||a,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.setTexture3D(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.setTextureCube(e||Dee,i)}function H4e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||Pee,i)}function V4e(t){switch(t){case 5126:return N4e;case 35664:return E4e;case 35665:return A4e;case 35666:return T4e;case 35674:return C4e;case 35675:return k4e;case 35676:return j4e;case 5124:case 35670:return P4e;case 35667:case 35671:return R4e;case 35668:case 35672:return D4e;case 35669:case 35673:return O4e;case 5125:return L4e;case 36294:return I4e;case 36295:return F4e;case 36296:return U4e;case 35678:case 36198:case 36298:case 36306:case 35682:return z4e;case 35679:case 36299:case 36307:return B4e;case 35680:case 36300:case 36308:case 36293:return $4e;case 36289:case 36303:case 36311:case 36292:return H4e}}function G4e(t,e){t.uniform1fv(this.addr,e)}function W4e(t,e){const n=ux(e,this.size,2);t.uniform2fv(this.addr,n)}function q4e(t,e){const n=ux(e,this.size,3);t.uniform3fv(this.addr,n)}function K4e(t,e){const n=ux(e,this.size,4);t.uniform4fv(this.addr,n)}function X4e(t,e){const n=ux(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function Y4e(t,e){const n=ux(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function Q4e(t,e){const n=ux(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function Z4e(t,e){t.uniform1iv(this.addr,e)}function J4e(t,e){t.uniform2iv(this.addr,e)}function eLe(t,e){t.uniform3iv(this.addr,e)}function tLe(t,e){t.uniform4iv(this.addr,e)}function nLe(t,e){t.uniform1uiv(this.addr,e)}function rLe(t,e){t.uniform2uiv(this.addr,e)}function iLe(t,e){t.uniform3uiv(this.addr,e)}function aLe(t,e){t.uniform4uiv(this.addr,e)}function sLe(t,e,n){const r=this.cache,i=e.length,a=hE(n,i);Li(r,a)||(t.uniform1iv(this.addr,a),Ii(r,a));let o;this.type===t.SAMPLER_2D_SHADOW?o=yR:o=jee;for(let l=0;l!==i;++l)n.setTexture2D(e[l]||o,a[l])}function oLe(t,e,n){const r=this.cache,i=e.length,a=hE(n,i);Li(r,a)||(t.uniform1iv(this.addr,a),Ii(r,a));for(let o=0;o!==i;++o)n.setTexture3D(e[o]||Ree,a[o])}function lLe(t,e,n){const r=this.cache,i=e.length,a=hE(n,i);Li(r,a)||(t.uniform1iv(this.addr,a),Ii(r,a));for(let o=0;o!==i;++o)n.setTextureCube(e[o]||Dee,a[o])}function cLe(t,e,n){const r=this.cache,i=e.length,a=hE(n,i);Li(r,a)||(t.uniform1iv(this.addr,a),Ii(r,a));for(let o=0;o!==i;++o)n.setTexture2DArray(e[o]||Pee,a[o])}function uLe(t){switch(t){case 5126:return G4e;case 35664:return W4e;case 35665:return q4e;case 35666:return K4e;case 35674:return X4e;case 35675:return Y4e;case 35676:return Q4e;case 5124:case 35670:return Z4e;case 35667:case 35671:return J4e;case 35668:case 35672:return eLe;case 35669:case 35673:return tLe;case 5125:return nLe;case 36294:return rLe;case 36295:return iLe;case 36296:return aLe;case 35678:case 36198:case 36298:case 36306:case 35682:return sLe;case 35679:case 36299:case 36307:return oLe;case 35680:case 36300:case 36308:case 36293:return lLe;case 36289:case 36303:case 36311:case 36292:return cLe}}let dLe=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=V4e(n.type)}},hLe=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=uLe(n.type)}},fLe=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 Mk=/(\w+)(\])?(\[|\.)?/g;function cG(t,e){t.seq.push(e),t.map[e.id]=e}function mLe(t,e,n){const r=t.name,i=r.length;for(Mk.lastIndex=0;;){const a=Mk.exec(r),o=Mk.lastIndex;let l=a[1];const c=a[2]==="]",u=a[3];if(c&&(l=l|0),u===void 0||u==="["&&o+2===i){cG(n,u===void 0?new dLe(l,t,e):new hLe(l,t,e));break}else{let f=n.map[l];f===void 0&&(f=new fLe(l),cG(n,f)),n=f}}}let gw=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);mLe(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 uG(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const pLe=37297;let gLe=0;function xLe(t,e){const n=t.split(`
- `),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(`
- `)}const dG=new En;function bLe(t){Vn._getMatrix(dG,Vn.workingColorSpace,t);const e=`mat3( ${dG.elements.map(n=>n.toFixed(4))} )`;switch(Vn.getTransfer(t)){case zS:return[e,"LinearTransferOETF"];case lr:return[e,"sRGBTransferOETF"];default:return un("WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}function hG(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()+`
- `+a+`
- `+xLe(t.getShaderSource(e),l)}else return a}function yLe(t,e){const n=bLe(e);return[`vec4 ${t}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
- `)}const vLe={[qJ]:"Linear",[KJ]:"Reinhard",[XJ]:"Cineon",[YJ]:"ACESFilmic",[ZJ]:"AgX",[JJ]:"Neutral",[QJ]:"Custom"};function _Le(t,e){const n=vLe[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 J_=new nt;function wLe(){Vn.getLuminanceCoefficients(J_);const t=J_.x.toFixed(4),e=J_.y.toFixed(4),n=J_.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${t}, ${e}, ${n} );`," return dot( weights, rgb );","}"].join(`
- `)}function SLe(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Vb).join(`
- `)}function MLe(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
- `)}function NLe(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 fG(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 mG(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 vR(t){return t.replace(ELe,TLe)}const ALe=new Map;function TLe(t,e){let n=wn[e];if(n===void 0){const r=ALe.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 vR(n)}const CLe=/#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 pG(t){return t.replace(CLe,kLe)}function kLe(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 gG(t){let e=`precision ${t.precision} float;
- precision ${t.precision} int;
- precision ${t.precision} sampler2D;
- precision ${t.precision} samplerCube;
- precision ${t.precision} sampler3D;
- precision ${t.precision} sampler2DArray;
- precision ${t.precision} sampler2DShadow;
- precision ${t.precision} samplerCubeShadow;
- precision ${t.precision} sampler2DArrayShadow;
- precision ${t.precision} isampler2D;
- precision ${t.precision} isampler3D;
- precision ${t.precision} isamplerCube;
- precision ${t.precision} isampler2DArray;
- precision ${t.precision} usampler2D;
- precision ${t.precision} usampler3D;
- precision ${t.precision} usamplerCube;
- precision ${t.precision} usampler2DArray;
- `;return t.precision==="highp"?e+=`
- #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
- #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
- #define LOW_PRECISION`),e}const jLe={[lw]:"SHADOWMAP_TYPE_PCF",[$b]:"SHADOWMAP_TYPE_VSM"};function PLe(t){return jLe[t.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}const RLe={[Zf]:"ENVMAP_TYPE_CUBE",[Tg]:"ENVMAP_TYPE_CUBE",[cE]:"ENVMAP_TYPE_CUBE_UV"};function DLe(t){return t.envMap===!1?"ENVMAP_TYPE_CUBE":RLe[t.envMapMode]||"ENVMAP_TYPE_CUBE"}const OLe={[Tg]:"ENVMAP_MODE_REFRACTION"};function LLe(t){return t.envMap===!1?"ENVMAP_MODE_REFLECTION":OLe[t.envMapMode]||"ENVMAP_MODE_REFLECTION"}const ILe={[Y4]:"ENVMAP_BLENDING_MULTIPLY",[_3e]:"ENVMAP_BLENDING_MIX",[w3e]:"ENVMAP_BLENDING_ADD"};function FLe(t){return t.envMap===!1?"ENVMAP_BLENDING_NONE":ILe[t.combine]||"ENVMAP_BLENDING_NONE"}function ULe(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 zLe(t,e,n,r){const i=t.getContext(),a=n.defines;let o=n.vertexShader,l=n.fragmentShader;const c=PLe(n),u=DLe(n),d=LLe(n),f=FLe(n),m=ULe(n),p=SLe(n),b=MLe(a),y=i.createProgram();let x,v,S=n.glslVersion?"#version "+n.glslVersion+`
- `:"";n.isRawShaderMaterial?(x=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(Vb).join(`
- `),x.length>0&&(x+=`
- `),v=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(Vb).join(`
- `),v.length>0&&(v+=`
- `)):(x=[gG(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",`
- `].filter(Vb).join(`
- `),v=[gG(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?_Le("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",wn.colorspace_pars_fragment,yLe("linearToOutputTexel",n.outputColorSpace),wLe(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
- `].filter(Vb).join(`
- `)),o=vR(o),o=fG(o,n),o=mG(o,n),l=vR(l),l=fG(l,n),l=mG(l,n),o=pG(o),l=pG(l),n.isRawShaderMaterial!==!0&&(S=`#version 300 es
- `,x=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(`
- `)+`
- `+x,v=["#define varying in",n.glslVersion===MV?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===MV?"":"#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(`
- `)+`
- `+v);const M=S+x+o,E=S+v+l,A=uG(i,i.VERTEX_SHADER,M),k=uG(i,i.FRAGMENT_SHADER,E);i.attachShader(y,A),i.attachShader(y,k),n.index0AttributeName!==void 0?i.bindAttribLocation(y,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(y,0,"position"),i.linkProgram(y);function T(U){if(t.debug.checkShaderErrors){const O=i.getProgramInfoLog(y)||"",q=i.getShaderInfoLog(A)||"",j=i.getShaderInfoLog(k)||"",W=O.trim(),X=q.trim(),G=j.trim();let Z=!0,te=!0;if(i.getProgramParameter(y,i.LINK_STATUS)===!1)if(Z=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,y,A,k);else{const ee=hG(i,A,"vertex"),z=hG(i,k,"fragment");Kn("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(y,i.VALIDATE_STATUS)+`
- Material Name: `+U.name+`
- Material Type: `+U.type+`
- Program Info Log: `+W+`
- `+ee+`
- `+z)}else W!==""?un("WebGLProgram: Program Info Log:",W):(X===""||G==="")&&(te=!1);te&&(U.diagnostics={runnable:Z,programLog:W,vertexShader:{log:X,prefix:x},fragmentShader:{log:G,prefix:v}})}i.deleteShader(A),i.deleteShader(k),D=new gw(i,y),C=NLe(i,y)}let D;this.getUniforms=function(){return D===void 0&&T(this),D};let C;this.getAttributes=function(){return C===void 0&&T(this),C};let R=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return R===!1&&(R=i.getProgramParameter(y,pLe)),R},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(y),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=gLe++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=A,this.fragmentShader=k,this}let BLe=0,$Le=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 HLe(e),n.set(e,r)),r}},HLe=class{constructor(e){this.id=BLe++,this.code=e,this.usedTimes=0}};function VLe(t,e,n,r,i,a,o){const l=new gee,c=new $Le,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 y(C){return u.add(C),C===0?"uv":`uv${C}`}function x(C,R,U,O,q){const j=O.fog,W=q.geometry,X=C.isMeshStandardMaterial?O.environment:null,G=(C.isMeshStandardMaterial?n:e).get(C.envMap||X),Z=G&&G.mapping===cE?G.image.height:null,te=b[C.type];C.precision!==null&&(p=i.getMaxPrecision(C.precision),p!==C.precision&&un("WebGLProgram.getParameters:",C.precision,"not supported, using",p,"instead."));const ee=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,z=ee!==void 0?ee.length:0;let V=0;W.morphAttributes.position!==void 0&&(V=1),W.morphAttributes.normal!==void 0&&(V=2),W.morphAttributes.color!==void 0&&(V=3);let ne,ie,he,me;if(te){const kt=Ll[te];ne=kt.vertexShader,ie=kt.fragmentShader}else ne=C.vertexShader,ie=C.fragmentShader,c.update(C),he=c.getVertexShaderID(C),me=c.getFragmentShaderID(C);const oe=t.getRenderTarget(),Ae=t.state.buffers.depth.getReversed(),ge=q.isInstancedMesh===!0,Ne=q.isBatchedMesh===!0,_e=!!C.map,le=!!C.matcap,He=!!G,H=!!C.aoMap,J=!!C.lightMap,K=!!C.bumpMap,B=!!C.normalMap,I=!!C.displacementMap,ce=!!C.emissiveMap,Ee=!!C.metalnessMap,Ie=!!C.roughnessMap,ue=C.anisotropy>0,$=C.clearcoat>0,L=C.dispersion>0,Y=C.iridescence>0,pe=C.sheen>0,Se=C.transmission>0,ae=ue&&!!C.anisotropyMap,je=$&&!!C.clearcoatMap,De=$&&!!C.clearcoatNormalMap,Xe=$&&!!C.clearcoatRoughnessMap,et=Y&&!!C.iridescenceMap,Qe=Y&&!!C.iridescenceThicknessMap,se=pe&&!!C.sheenColorMap,ye=pe&&!!C.sheenRoughnessMap,ke=!!C.specularMap,Ue=!!C.specularColorMap,dt=!!C.specularIntensityMap,re=Se&&!!C.transmissionMap,Fe=Se&&!!C.thicknessMap,ve=!!C.gradientMap,$e=!!C.alphaMap,Le=C.alphaTest>0,Te=!!C.alphaHash,We=!!C.extensions;let it=ql;C.toneMapped&&(oe===null||oe.isXRRenderTarget===!0)&&(it=t.toneMapping);const Ot={shaderID:te,shaderType:C.type,shaderName:C.name,vertexShader:ne,fragmentShader:ie,defines:C.defines,customVertexShaderID:he,customFragmentShaderID:me,isRawShaderMaterial:C.isRawShaderMaterial===!0,glslVersion:C.glslVersion,precision:p,batching:Ne,batchingColor:Ne&&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:kg,alphaToCoverage:!!C.alphaToCoverage,map:_e,matcap:le,envMap:He,envMapMode:He&&G.mapping,envMapCubeUVHeight:Z,aoMap:H,lightMap:J,bumpMap:K,normalMap:B,displacementMap:I,emissiveMap:ce,normalMapObjectSpace:B&&C.normalMapType===N3e,normalMapTangentSpace:B&&C.normalMapType===lee,metalnessMap:Ee,roughnessMap:Ie,anisotropy:ue,anisotropyMap:ae,clearcoat:$,clearcoatMap:je,clearcoatNormalMap:De,clearcoatRoughnessMap:Xe,dispersion:L,iridescence:Y,iridescenceMap:et,iridescenceThicknessMap:Qe,sheen:pe,sheenColorMap:se,sheenRoughnessMap:ye,specularMap:ke,specularColorMap:Ue,specularIntensityMap:dt,transmission:Se,transmissionMap:re,thicknessMap:Fe,gradientMap:ve,opaque:C.transparent===!1&&C.blending===ag&&C.alphaToCoverage===!1,alphaMap:$e,alphaTest:Le,alphaHash:Te,combine:C.combine,mapUv:_e&&y(C.map.channel),aoMapUv:H&&y(C.aoMap.channel),lightMapUv:J&&y(C.lightMap.channel),bumpMapUv:K&&y(C.bumpMap.channel),normalMapUv:B&&y(C.normalMap.channel),displacementMapUv:I&&y(C.displacementMap.channel),emissiveMapUv:ce&&y(C.emissiveMap.channel),metalnessMapUv:Ee&&y(C.metalnessMap.channel),roughnessMapUv:Ie&&y(C.roughnessMap.channel),anisotropyMapUv:ae&&y(C.anisotropyMap.channel),clearcoatMapUv:je&&y(C.clearcoatMap.channel),clearcoatNormalMapUv:De&&y(C.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Xe&&y(C.clearcoatRoughnessMap.channel),iridescenceMapUv:et&&y(C.iridescenceMap.channel),iridescenceThicknessMapUv:Qe&&y(C.iridescenceThicknessMap.channel),sheenColorMapUv:se&&y(C.sheenColorMap.channel),sheenRoughnessMapUv:ye&&y(C.sheenRoughnessMap.channel),specularMapUv:ke&&y(C.specularMap.channel),specularColorMapUv:Ue&&y(C.specularColorMap.channel),specularIntensityMapUv:dt&&y(C.specularIntensityMap.channel),transmissionMapUv:re&&y(C.transmissionMap.channel),thicknessMapUv:Fe&&y(C.thicknessMap.channel),alphaMapUv:$e&&y(C.alphaMap.channel),vertexTangents:!!W.attributes.tangent&&(B||ue),vertexColors:C.vertexColors,vertexAlphas:C.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,pointsUvs:q.isPoints===!0&&!!W.attributes.uv&&(_e||$e),fog:!!j,useFog:C.fog===!0,fogExp2:!!j&&j.isFogExp2,flatShading:C.flatShading===!0&&C.wireframe===!1,sizeAttenuation:C.sizeAttenuation===!0,logarithmicDepthBuffer:m,reversedDepthBuffer:Ae,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:V,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:C.dithering,shadowMapEnabled:t.shadowMap.enabled&&U.length>0,shadowMapType:t.shadowMap.type,toneMapping:it,decodeVideoTexture:_e&&C.map.isVideoTexture===!0&&Vn.getTransfer(C.map.colorSpace)===lr,decodeVideoTextureEmissive:ce&&C.emissiveMap.isVideoTexture===!0&&Vn.getTransfer(C.emissiveMap.colorSpace)===lr,premultipliedAlpha:C.premultipliedAlpha,doubleSided:C.side===Il,flipSided:C.side===ws,useDepthPacking:C.depthPacking>=0,depthPacking:C.depthPacking||0,index0AttributeName:C.index0AttributeName,extensionClipCullDistance:We&&C.extensions.clipCullDistance===!0&&r.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(We&&C.extensions.multiDraw===!0||Ne)&&r.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:C.customProgramCacheKey()};return Ot.vertexUv1s=u.has(1),Ot.vertexUv2s=u.has(2),Ot.vertexUv3s=u.has(3),u.clear(),Ot}function v(C){const R=[];if(C.shaderID?R.push(C.shaderID):(R.push(C.customVertexShaderID),R.push(C.customFragmentShaderID)),C.defines!==void 0)for(const U in C.defines)R.push(U),R.push(C.defines[U]);return C.isRawShaderMaterial===!1&&(S(R,C),M(R,C),R.push(t.outputColorSpace)),R.push(C.customProgramCacheKey),R.join()}function S(C,R){C.push(R.precision),C.push(R.outputColorSpace),C.push(R.envMapMode),C.push(R.envMapCubeUVHeight),C.push(R.mapUv),C.push(R.alphaMapUv),C.push(R.lightMapUv),C.push(R.aoMapUv),C.push(R.bumpMapUv),C.push(R.normalMapUv),C.push(R.displacementMapUv),C.push(R.emissiveMapUv),C.push(R.metalnessMapUv),C.push(R.roughnessMapUv),C.push(R.anisotropyMapUv),C.push(R.clearcoatMapUv),C.push(R.clearcoatNormalMapUv),C.push(R.clearcoatRoughnessMapUv),C.push(R.iridescenceMapUv),C.push(R.iridescenceThicknessMapUv),C.push(R.sheenColorMapUv),C.push(R.sheenRoughnessMapUv),C.push(R.specularMapUv),C.push(R.specularColorMapUv),C.push(R.specularIntensityMapUv),C.push(R.transmissionMapUv),C.push(R.thicknessMapUv),C.push(R.combine),C.push(R.fogExp2),C.push(R.sizeAttenuation),C.push(R.morphTargetsCount),C.push(R.morphAttributeCount),C.push(R.numDirLights),C.push(R.numPointLights),C.push(R.numSpotLights),C.push(R.numSpotLightMaps),C.push(R.numHemiLights),C.push(R.numRectAreaLights),C.push(R.numDirLightShadows),C.push(R.numPointLightShadows),C.push(R.numSpotLightShadows),C.push(R.numSpotLightShadowsWithMaps),C.push(R.numLightProbes),C.push(R.shadowMapType),C.push(R.toneMapping),C.push(R.numClippingPlanes),C.push(R.numClipIntersection),C.push(R.depthPacking)}function M(C,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),C.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),C.push(l.mask)}function E(C){const R=b[C.type];let U;if(R){const O=Ll[R];U=eRe.clone(O.uniforms)}else U=C.uniforms;return U}function A(C,R){let U=f.get(R);return U!==void 0?++U.usedTimes:(U=new zLe(t,R,C,a),d.push(U),f.set(R,U)),U}function k(C){if(--C.usedTimes===0){const R=d.indexOf(C);d[R]=d[d.length-1],d.pop(),f.delete(C.cacheKey),C.destroy()}}function T(C){c.remove(C)}function D(){c.dispose()}return{getParameters:x,getProgramCacheKey:v,getUniforms:E,acquireProgram:A,releaseProgram:k,releaseShaderCache:T,programs:d,dispose:D}}function GLe(){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 WLe(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 xG(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 bG(){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,y,x){let v=t[e];return v===void 0?(v={id:f.id,object:f,geometry:m,material:p,groupOrder:b,renderOrder:f.renderOrder,z:y,group:x},t[e]=v):(v.id=f.id,v.object=f,v.geometry=m,v.material=p,v.groupOrder=b,v.renderOrder=f.renderOrder,v.z=y,v.group=x),e++,v}function l(f,m,p,b,y,x){const v=o(f,m,p,b,y,x);p.transmission>0?r.push(v):p.transparent===!0?i.push(v):n.push(v)}function c(f,m,p,b,y,x){const v=o(f,m,p,b,y,x);p.transmission>0?r.unshift(v):p.transparent===!0?i.unshift(v):n.unshift(v)}function u(f,m){n.length>1&&n.sort(f||WLe),r.length>1&&r.sort(m||xG),i.length>1&&i.sort(m||xG)}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 qLe(){let t=new WeakMap;function e(r,i){const a=t.get(r);let o;return a===void 0?(o=new bG,t.set(r,[o])):i>=a.length?(o=new bG,a.push(o)):o=a[i],o}function n(){t=new WeakMap}return{get:e,dispose: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={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 XLe(){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 YLe=0;function QLe(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 KLe,n=XLe(),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 C=0;C<9;C++)r.probe[C].set(0,0,0);let p=0,b=0,y=0,x=0,v=0,S=0,M=0,E=0,A=0,k=0,T=0;u.sort(QLe);for(let C=0,R=u.length;C<R;C++){const U=u[C],O=U.color,q=U.intensity,j=U.distance;let W=null;if(U.shadow&&U.shadow.map&&(U.shadow.map.texture.format===Cg?W=U.shadow.map.texture:W=U.shadow.map.depthTexture||U.shadow.map.texture),U.isAmbientLight)d+=O.r*q,f+=O.g*q,m+=O.b*q;else if(U.isLightProbe){for(let X=0;X<9;X++)r.probe[X].addScaledVector(U.sh.coefficients[X],q);T++}else if(U.isDirectionalLight){const X=e.get(U);if(X.color.copy(U.color).multiplyScalar(U.intensity),U.castShadow){const G=U.shadow,Z=n.get(U);Z.shadowIntensity=G.intensity,Z.shadowBias=G.bias,Z.shadowNormalBias=G.normalBias,Z.shadowRadius=G.radius,Z.shadowMapSize=G.mapSize,r.directionalShadow[p]=Z,r.directionalShadowMap[p]=W,r.directionalShadowMatrix[p]=U.shadow.matrix,S++}r.directional[p]=X,p++}else if(U.isSpotLight){const X=e.get(U);X.position.setFromMatrixPosition(U.matrixWorld),X.color.copy(O).multiplyScalar(q),X.distance=j,X.coneCos=Math.cos(U.angle),X.penumbraCos=Math.cos(U.angle*(1-U.penumbra)),X.decay=U.decay,r.spot[y]=X;const G=U.shadow;if(U.map&&(r.spotLightMap[A]=U.map,A++,G.updateMatrices(U),U.castShadow&&k++),r.spotLightMatrix[y]=G.matrix,U.castShadow){const Z=n.get(U);Z.shadowIntensity=G.intensity,Z.shadowBias=G.bias,Z.shadowNormalBias=G.normalBias,Z.shadowRadius=G.radius,Z.shadowMapSize=G.mapSize,r.spotShadow[y]=Z,r.spotShadowMap[y]=W,E++}y++}else if(U.isRectAreaLight){const X=e.get(U);X.color.copy(O).multiplyScalar(q),X.halfWidth.set(U.width*.5,0,0),X.halfHeight.set(0,U.height*.5,0),r.rectArea[x]=X,x++}else if(U.isPointLight){const X=e.get(U);if(X.color.copy(U.color).multiplyScalar(U.intensity),X.distance=U.distance,X.decay=U.decay,U.castShadow){const G=U.shadow,Z=n.get(U);Z.shadowIntensity=G.intensity,Z.shadowBias=G.bias,Z.shadowNormalBias=G.normalBias,Z.shadowRadius=G.radius,Z.shadowMapSize=G.mapSize,Z.shadowCameraNear=G.camera.near,Z.shadowCameraFar=G.camera.far,r.pointShadow[b]=Z,r.pointShadowMap[b]=W,r.pointShadowMatrix[b]=U.shadow.matrix,M++}r.point[b]=X,b++}else if(U.isHemisphereLight){const X=e.get(U);X.skyColor.copy(U.color).multiplyScalar(q),X.groundColor.copy(U.groundColor).multiplyScalar(q),r.hemi[v]=X,v++}}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!==y||D.rectAreaLength!==x||D.hemiLength!==v||D.numDirectionalShadows!==S||D.numPointShadows!==M||D.numSpotShadows!==E||D.numSpotMaps!==A||D.numLightProbes!==T)&&(r.directional.length=p,r.spot.length=y,r.rectArea.length=x,r.point.length=b,r.hemi.length=v,r.directionalShadow.length=S,r.directionalShadowMap.length=S,r.pointShadow.length=M,r.pointShadowMap.length=M,r.spotShadow.length=E,r.spotShadowMap.length=E,r.directionalShadowMatrix.length=S,r.pointShadowMatrix.length=M,r.spotLightMatrix.length=E+A-k,r.spotLightMap.length=A,r.numSpotLightShadowsWithMaps=k,r.numLightProbes=T,D.directionalLength=p,D.pointLength=b,D.spotLength=y,D.rectAreaLength=x,D.hemiLength=v,D.numDirectionalShadows=S,D.numPointShadows=M,D.numSpotShadows=E,D.numSpotMaps=A,D.numLightProbes=T,r.version=YLe++)}function c(u,d){let f=0,m=0,p=0,b=0,y=0;const x=d.matrixWorldInverse;for(let v=0,S=u.length;v<S;v++){const M=u[v];if(M.isDirectionalLight){const E=r.directional[f];E.direction.setFromMatrixPosition(M.matrixWorld),i.setFromMatrixPosition(M.target.matrixWorld),E.direction.sub(i),E.direction.transformDirection(x),f++}else if(M.isSpotLight){const E=r.spot[p];E.position.setFromMatrixPosition(M.matrixWorld),E.position.applyMatrix4(x),E.direction.setFromMatrixPosition(M.matrixWorld),i.setFromMatrixPosition(M.target.matrixWorld),E.direction.sub(i),E.direction.transformDirection(x),p++}else if(M.isRectAreaLight){const E=r.rectArea[b];E.position.setFromMatrixPosition(M.matrixWorld),E.position.applyMatrix4(x),o.identity(),a.copy(M.matrixWorld),a.premultiply(x),o.extractRotation(a),E.halfWidth.set(M.width*.5,0,0),E.halfHeight.set(0,M.height*.5,0),E.halfWidth.applyMatrix4(o),E.halfHeight.applyMatrix4(o),b++}else if(M.isPointLight){const E=r.point[m];E.position.setFromMatrixPosition(M.matrixWorld),E.position.applyMatrix4(x),m++}else if(M.isHemisphereLight){const E=r.hemi[y];E.direction.setFromMatrixPosition(M.matrixWorld),E.direction.transformDirection(x),y++}}}return{setup:l,setupView:c,state:r}}function yG(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 JLe(t){let e=new WeakMap;function n(i,a=0){const o=e.get(i);let l;return o===void 0?(l=new yG(t),e.set(i,[l])):a>=o.length?(l=new yG(t),o.push(l)):l=o[a],l}function r(){e=new WeakMap}return{get:n,dispose:r}}const eIe=`void main() {
- gl_Position = vec4( position, 1.0 );
- }`,tIe=`uniform sampler2D shadow_pass;
- uniform vec2 resolution;
- uniform float radius;
- void main() {
- const float samples = float( VSM_SAMPLES );
- float mean = 0.0;
- float squared_mean = 0.0;
- float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
- float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
- for ( float i = 0.0; i < samples; i ++ ) {
- float uvOffset = uvStart + i * uvStride;
- #ifdef HORIZONTAL_PASS
- vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg;
- mean += distribution.x;
- squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
- #else
- float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r;
- mean += depth;
- squared_mean += depth * depth;
- #endif
- }
- mean = mean / samples;
- squared_mean = squared_mean / samples;
- float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
- gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
- }`,nIe=[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)],rIe=[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)],vG=new mi,Nb=new nt,Nk=new nt;function iIe(t,e,n){let r=new cL;const i=new Mn,a=new Mn,o=new Mi,l=new pRe,c=new gRe,u={},d=n.maxTextureSize,f={[eh]:ws,[ws]:eh,[Il]:Il},m=new ic({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Mn},radius:{value:4}},vertexShader:eIe,fragmentShader:tIe}),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 y=new hl(b,m),x=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=lw;let v=this.type;this.render=function(k,T,D){if(x.enabled===!1||x.autoUpdate===!1&&x.needsUpdate===!1||k.length===0)return;k.type===n3e&&(un("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),k.type=lw);const C=t.getRenderTarget(),R=t.getActiveCubeFace(),U=t.getActiveMipmapLevel(),O=t.state;O.setBlending(su),O.buffers.depth.getReversed()===!0?O.buffers.color.setClear(0,0,0,0):O.buffers.color.setClear(1,1,1,1),O.buffers.depth.setTest(!0),O.setScissorTest(!1);const q=v!==this.type;q&&T.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 X=k[j],G=X.shadow;if(G===void 0){un("WebGLShadowMap:",X,"has no shadow.");continue}if(G.autoUpdate===!1&&G.needsUpdate===!1)continue;i.copy(G.mapSize);const Z=G.getFrameExtents();if(i.multiply(Z),a.copy(G.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(a.x=Math.floor(d/Z.x),i.x=a.x*Z.x,G.mapSize.x=a.x),i.y>d&&(a.y=Math.floor(d/Z.y),i.y=a.y*Z.y,G.mapSize.y=a.y)),G.map===null||q===!0){if(G.map!==null&&(G.map.depthTexture!==null&&(G.map.depthTexture.dispose(),G.map.depthTexture=null),G.map.dispose()),this.type===$b){if(X.isPointLight){un("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}G.map=new Kl(i.x,i.y,{format:Cg,type:vu,minFilter:Ua,magFilter:Ua,generateMipmaps:!1}),G.map.texture.name=X.name+".shadowMap",G.map.depthTexture=new Y0(i.x,i.y,$l),G.map.depthTexture.name=X.name+".shadowMapDepth",G.map.depthTexture.format=_u,G.map.depthTexture.compareFunction=null,G.map.depthTexture.minFilter=Na,G.map.depthTexture.magFilter=Na}else{X.isPointLight?(G.map=new Nee(i.x),G.map.depthTexture=new hRe(i.x,rc)):(G.map=new Kl(i.x,i.y),G.map.depthTexture=new Y0(i.x,i.y,rc)),G.map.depthTexture.name=X.name+".shadowMap",G.map.depthTexture.format=_u;const ee=t.state.buffers.depth.getReversed();this.type===lw?(G.map.depthTexture.compareFunction=ee?iL:rL,G.map.depthTexture.minFilter=Ua,G.map.depthTexture.magFilter=Ua):(G.map.depthTexture.compareFunction=null,G.map.depthTexture.minFilter=Na,G.map.depthTexture.magFilter=Na)}G.camera.updateProjectionMatrix()}const te=G.map.isWebGLCubeRenderTarget?6:1;for(let ee=0;ee<te;ee++){if(G.map.isWebGLCubeRenderTarget)t.setRenderTarget(G.map,ee),t.clear();else{ee===0&&(t.setRenderTarget(G.map),t.clear());const z=G.getViewport(ee);o.set(a.x*z.x,a.y*z.y,a.x*z.z,a.y*z.w),O.viewport(o)}if(X.isPointLight){const z=G.camera,V=G.matrix,ne=X.distance||z.far;ne!==z.far&&(z.far=ne,z.updateProjectionMatrix()),Nb.setFromMatrixPosition(X.matrixWorld),z.position.copy(Nb),Nk.copy(z.position),Nk.add(nIe[ee]),z.up.copy(rIe[ee]),z.lookAt(Nk),z.updateMatrixWorld(),V.makeTranslation(-Nb.x,-Nb.y,-Nb.z),vG.multiplyMatrices(z.projectionMatrix,z.matrixWorldInverse),G._frustum.setFromProjectionMatrix(vG,z.coordinateSystem,z.reversedDepth)}else G.updateMatrices(X);r=G.getFrustum(),E(T,D,G.camera,X,this.type)}G.isPointLightShadow!==!0&&this.type===$b&&S(G,D),G.needsUpdate=!1}v=this.type,x.needsUpdate=!1,t.setRenderTarget(C,R,U)};function S(k,T){const D=e.update(y);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:Cg,type:vu})),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(T,null,D,m,y,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(T,null,D,p,y,null)}function M(k,T,D,C){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&&T.clipShadows===!0&&Array.isArray(T.clippingPlanes)&&T.clippingPlanes.length!==0||T.displacementMap&&T.displacementScale!==0||T.alphaMap&&T.alphaTest>0||T.map&&T.alphaTest>0||T.alphaToCoverage===!0){const O=R.uuid,q=T.uuid;let j=u[O];j===void 0&&(j={},u[O]=j);let W=j[q];W===void 0&&(W=R.clone(),j[q]=W,T.addEventListener("dispose",A)),R=W}if(R.visible=T.visible,R.wireframe=T.wireframe,C===$b?R.side=T.shadowSide!==null?T.shadowSide:T.side:R.side=T.shadowSide!==null?T.shadowSide:f[T.side],R.alphaMap=T.alphaMap,R.alphaTest=T.alphaToCoverage===!0?.5:T.alphaTest,R.map=T.map,R.clipShadows=T.clipShadows,R.clippingPlanes=T.clippingPlanes,R.clipIntersection=T.clipIntersection,R.displacementMap=T.displacementMap,R.displacementScale=T.displacementScale,R.displacementBias=T.displacementBias,R.wireframeLinewidth=T.wireframeLinewidth,R.linewidth=T.linewidth,D.isPointLight===!0&&R.isMeshDistanceMaterial===!0){const O=t.properties.get(R);O.light=D}return R}function E(k,T,D,C,R){if(k.visible===!1)return;if(k.layers.test(T.layers)&&(k.isMesh||k.isLine||k.isPoints)&&(k.castShadow||k.receiveShadow&&R===$b)&&(!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 X=0,G=W.length;X<G;X++){const Z=W[X],te=j[Z.materialIndex];if(te&&te.visible){const ee=M(k,te,C,R);k.onBeforeShadow(t,k,T,D,q,ee,Z),t.renderBufferDirect(D,null,q,ee,k,Z),k.onAfterShadow(t,k,T,D,q,ee,Z)}}}else if(j.visible){const W=M(k,j,C,R);k.onBeforeShadow(t,k,T,D,q,W,null),t.renderBufferDirect(D,null,q,W,k,null),k.onAfterShadow(t,k,T,D,q,W,null)}}const O=k.children;for(let q=0,j=O.length;q<j;q++)E(O[q],T,D,C,R)}function A(k){k.target.removeEventListener("dispose",A);for(const D in u){const C=u[D],R=k.target.uuid;R in C&&(C[R].dispose(),delete C[R])}}}const aIe={[T3]:C3,[k3]:R3,[j3]:D3,[Ag]:P3,[C3]:T3,[R3]:k3,[D3]:j3,[P3]:Ag};function sIe(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,Te,We,it,Ot){Ot===!0&&(Le*=it,Te*=it,We*=it),Fe.set(Le,Te,We,it),$e.equals(Fe)===!1&&(t.clearColor(Le,Te,We,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(Te){if(Fe!==Te){const We=e.get("EXT_clip_control");Te?We.clipControlEXT(We.LOWER_LEFT_EXT,We.ZERO_TO_ONE_EXT):We.clipControlEXT(We.LOWER_LEFT_EXT,We.NEGATIVE_ONE_TO_ONE_EXT),Fe=Te;const it=Le;Le=null,this.setClear(it)}},getReversed:function(){return Fe},setTest:function(Te){Te?oe(t.DEPTH_TEST):Ae(t.DEPTH_TEST)},setMask:function(Te){ve!==Te&&!re&&(t.depthMask(Te),ve=Te)},setFunc:function(Te){if(Fe&&(Te=aIe[Te]),$e!==Te){switch(Te){case T3:t.depthFunc(t.NEVER);break;case C3:t.depthFunc(t.ALWAYS);break;case k3:t.depthFunc(t.LESS);break;case Ag:t.depthFunc(t.LEQUAL);break;case j3:t.depthFunc(t.EQUAL);break;case P3:t.depthFunc(t.GEQUAL);break;case R3:t.depthFunc(t.GREATER);break;case D3:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}$e=Te}},setLocked:function(Te){re=Te},setClear:function(Te){Le!==Te&&(Fe&&(Te=1-Te),t.clearDepth(Te),Le=Te)},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,Te=null,We=null,it=null,Ot=null;return{setTest:function(kt){re||(kt?oe(t.STENCIL_TEST):Ae(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){(Te!==kt||We!==on||it!==Ut)&&(t.stencilOp(kt,on,Ut),Te=kt,We=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,Te=null,We=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,y=!1,x=null,v=null,S=null,M=null,E=null,A=null,k=null,T=new Rn(0,0,0),D=0,C=!1,R=null,U=null,O=null,q=null,j=null;const W=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let X=!1,G=0;const Z=t.getParameter(t.VERSION);Z.indexOf("WebGL")!==-1?(G=parseFloat(/^WebGL (\d)/.exec(Z)[1]),X=G>=1):Z.indexOf("OpenGL ES")!==-1&&(G=parseFloat(/^OpenGL ES (\d)/.exec(Z)[1]),X=G>=2);let te=null,ee={};const z=t.getParameter(t.SCISSOR_BOX),V=t.getParameter(t.VIEWPORT),ne=new Mi().fromArray(z),ie=new Mi().fromArray(V);function he(re,Fe,ve,$e){const Le=new Uint8Array(4),Te=t.createTexture();t.bindTexture(re,Te),t.texParameteri(re,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(re,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let We=0;We<ve;We++)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+We,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Le);return Te}const me={};me[t.TEXTURE_2D]=he(t.TEXTURE_2D,t.TEXTURE_2D,1),me[t.TEXTURE_CUBE_MAP]=he(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),me[t.TEXTURE_2D_ARRAY]=he(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),me[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(Ag),K(!1),B(bV),oe(t.CULL_FACE),H(su);function oe(re){d[re]!==!0&&(t.enable(re),d[re]=!0)}function Ae(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 Ne(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 Te=0,We=Le.length;Te<We;Te++)ve[Te]=t.COLOR_ATTACHMENT0+Te;ve.length=Le.length,$e=!0}}else ve[0]!==t.BACK&&(ve[0]=t.BACK,$e=!0);$e&&t.drawBuffers(ve)}function _e(re){return b!==re?(t.useProgram(re),b=re,!0):!1}const le={[ef]:t.FUNC_ADD,[i3e]:t.FUNC_SUBTRACT,[a3e]:t.FUNC_REVERSE_SUBTRACT};le[s3e]=t.MIN,le[o3e]=t.MAX;const He={[l3e]:t.ZERO,[c3e]:t.ONE,[u3e]:t.SRC_COLOR,[E3]:t.SRC_ALPHA,[g3e]:t.SRC_ALPHA_SATURATE,[m3e]:t.DST_COLOR,[h3e]:t.DST_ALPHA,[d3e]:t.ONE_MINUS_SRC_COLOR,[A3]:t.ONE_MINUS_SRC_ALPHA,[p3e]:t.ONE_MINUS_DST_COLOR,[f3e]:t.ONE_MINUS_DST_ALPHA,[x3e]:t.CONSTANT_COLOR,[b3e]:t.ONE_MINUS_CONSTANT_COLOR,[y3e]:t.CONSTANT_ALPHA,[v3e]:t.ONE_MINUS_CONSTANT_ALPHA};function H(re,Fe,ve,$e,Le,Te,We,it,Ot,kt){if(re===su){y===!0&&(Ae(t.BLEND),y=!1);return}if(y===!1&&(oe(t.BLEND),y=!0),re!==r3e){if(re!==x||kt!==C){if((v!==ef||E!==ef)&&(t.blendEquation(t.FUNC_ADD),v=ef,E=ef),kt)switch(re){case ag:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case yV:t.blendFunc(t.ONE,t.ONE);break;case vV:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case _V: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 ag:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case yV:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case vV:Kn("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case _V:Kn("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Kn("WebGLState: Invalid blending: ",re);break}S=null,M=null,A=null,k=null,T.set(0,0,0),D=0,x=re,C=kt}return}Le=Le||Fe,Te=Te||ve,We=We||$e,(Fe!==v||Le!==E)&&(t.blendEquationSeparate(le[Fe],le[Le]),v=Fe,E=Le),(ve!==S||$e!==M||Te!==A||We!==k)&&(t.blendFuncSeparate(He[ve],He[$e],He[Te],He[We]),S=ve,M=$e,A=Te,k=We),(it.equals(T)===!1||Ot!==D)&&(t.blendColor(it.r,it.g,it.b,Ot),T.copy(it),D=Ot),x=re,C=!1}function J(re,Fe){re.side===Il?Ae(t.CULL_FACE):oe(t.CULL_FACE);let ve=re.side===ws;Fe&&(ve=!ve),K(ve),re.blending===ag&&re.transparent===!1?H(su):H(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):Ae(t.SAMPLE_ALPHA_TO_COVERAGE)}function K(re){R!==re&&(re?t.frontFace(t.CW):t.frontFace(t.CCW),R=re)}function B(re){re!==e3e?(oe(t.CULL_FACE),re!==U&&(re===bV?t.cullFace(t.BACK):re===t3e?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):Ae(t.CULL_FACE),U=re}function I(re){re!==O&&(X&&t.lineWidth(re),O=re)}function ce(re,Fe,ve){re?(oe(t.POLYGON_OFFSET_FILL),(q!==Fe||j!==ve)&&(t.polygonOffset(Fe,ve),q=Fe,j=ve)):Ae(t.POLYGON_OFFSET_FILL)}function Ee(re){re?oe(t.SCISSOR_TEST):Ae(t.SCISSOR_TEST)}function Ie(re){re===void 0&&(re=t.TEXTURE0+W-1),te!==re&&(t.activeTexture(re),te=re)}function ue(re,Fe,ve){ve===void 0&&(te===null?ve=t.TEXTURE0+W-1:ve=te);let $e=ee[ve];$e===void 0&&($e={type:void 0,texture:void 0},ee[ve]=$e),($e.type!==re||$e.texture!==Fe)&&(te!==ve&&(t.activeTexture(ve),te=ve),t.bindTexture(re,Fe||me[re]),$e.type=re,$e.texture=Fe)}function $(){const re=ee[te];re!==void 0&&re.type!==void 0&&(t.bindTexture(re.type,null),re.type=void 0,re.texture=void 0)}function L(){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 Se(){try{t.texSubImage3D(...arguments)}catch(re){Kn("WebGLState:",re)}}function ae(){try{t.compressedTexSubImage2D(...arguments)}catch(re){Kn("WebGLState:",re)}}function je(){try{t.compressedTexSubImage3D(...arguments)}catch(re){Kn("WebGLState:",re)}}function De(){try{t.texStorage2D(...arguments)}catch(re){Kn("WebGLState:",re)}}function Xe(){try{t.texStorage3D(...arguments)}catch(re){Kn("WebGLState:",re)}}function et(){try{t.texImage2D(...arguments)}catch(re){Kn("WebGLState:",re)}}function Qe(){try{t.texImage3D(...arguments)}catch(re){Kn("WebGLState:",re)}}function se(re){ne.equals(re)===!1&&(t.scissor(re.x,re.y,re.z,re.w),ne.copy(re))}function ye(re){ie.equals(re)===!1&&(t.viewport(re.x,re.y,re.z,re.w),ie.copy(re))}function ke(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={},te=null,ee={},f={},m=new WeakMap,p=[],b=null,y=!1,x=null,v=null,S=null,M=null,E=null,A=null,k=null,T=new Rn(0,0,0),D=0,C=!1,R=null,U=null,O=null,q=null,j=null,ne.set(0,0,t.canvas.width,t.canvas.height),ie.set(0,0,t.canvas.width,t.canvas.height),a.reset(),o.reset(),l.reset()}return{buffers:{color:a,depth:o,stencil:l},enable:oe,disable:Ae,bindFramebuffer:ge,drawBuffers:Ne,useProgram:_e,setBlending:H,setMaterial:J,setFlipSided:K,setCullFace:B,setLineWidth:I,setPolygonOffset:ce,setScissorTest:Ee,activeTexture:Ie,bindTexture:ue,unbindTexture:$,compressedTexImage2D:L,compressedTexImage3D:Y,texImage2D:et,texImage3D:Qe,updateUBOMapping:ke,uniformBlockBinding:Ue,texStorage2D:De,texStorage3D:Xe,texSubImage2D:pe,texSubImage3D:Se,compressedTexSubImage2D:ae,compressedTexSubImage3D:je,scissor:se,viewport:ye,reset:dt}}function oIe(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($,L){return p?new OffscreenCanvas($,L):$S("canvas")}function y($,L,Y){let pe=1;const Se=ue($);if((Se.width>Y||Se.height>Y)&&(pe=Y/Math.max(Se.width,Se.height)),pe<1)if(typeof HTMLImageElement<"u"&&$ instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&$ instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&$ instanceof ImageBitmap||typeof VideoFrame<"u"&&$ instanceof VideoFrame){const ae=Math.floor(pe*Se.width),je=Math.floor(pe*Se.height);f===void 0&&(f=b(ae,je));const De=L?b(ae,je):f;return De.width=ae,De.height=je,De.getContext("2d").drawImage($,0,0,ae,je),un("WebGLRenderer: Texture has been resized from ("+Se.width+"x"+Se.height+") to ("+ae+"x"+je+")."),De}else return"data"in $&&un("WebGLRenderer: Image in DataTexture is too big ("+Se.width+"x"+Se.height+")."),$;return $}function x($){return $.generateMipmaps}function v($){t.generateMipmap($)}function S($){return $.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:$.isWebGL3DRenderTarget?t.TEXTURE_3D:$.isWebGLArrayRenderTarget||$.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function M($,L,Y,pe,Se=!1){if($!==null){if(t[$]!==void 0)return t[$];un("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+$+"'")}let ae=L;if(L===t.RED&&(Y===t.FLOAT&&(ae=t.R32F),Y===t.HALF_FLOAT&&(ae=t.R16F),Y===t.UNSIGNED_BYTE&&(ae=t.R8)),L===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)),L===t.RG&&(Y===t.FLOAT&&(ae=t.RG32F),Y===t.HALF_FLOAT&&(ae=t.RG16F),Y===t.UNSIGNED_BYTE&&(ae=t.RG8)),L===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)),L===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)),L===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)),L===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)),L===t.RGBA){const je=Se?zS:Vn.getTransfer(pe);Y===t.FLOAT&&(ae=t.RGBA32F),Y===t.HALF_FLOAT&&(ae=t.RGBA16F),Y===t.UNSIGNED_BYTE&&(ae=je===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 E($,L){let Y;return $?L===null||L===rc||L===K0?Y=t.DEPTH24_STENCIL8:L===$l?Y=t.DEPTH32F_STENCIL8:L===q0&&(Y=t.DEPTH24_STENCIL8,un("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):L===null||L===rc||L===K0?Y=t.DEPTH_COMPONENT24:L===$l?Y=t.DEPTH_COMPONENT32F:L===q0&&(Y=t.DEPTH_COMPONENT16),Y}function A($,L){return x($)===!0||$.isFramebufferTexture&&$.minFilter!==Na&&$.minFilter!==Ua?Math.log2(Math.max(L.width,L.height))+1:$.mipmaps!==void 0&&$.mipmaps.length>0?$.mipmaps.length:$.isCompressedTexture&&Array.isArray($.image)?L.mipmaps.length:1}function k($){const L=$.target;L.removeEventListener("dispose",k),D(L),L.isVideoTexture&&d.delete(L)}function T($){const L=$.target;L.removeEventListener("dispose",T),R(L)}function D($){const L=r.get($);if(L.__webglInit===void 0)return;const Y=$.source,pe=m.get(Y);if(pe){const Se=pe[L.__cacheKey];Se.usedTimes--,Se.usedTimes===0&&C($),Object.keys(pe).length===0&&m.delete(Y)}r.remove($)}function C($){const L=r.get($);t.deleteTexture(L.__webglTexture);const Y=$.source,pe=m.get(Y);delete pe[L.__cacheKey],o.memory.textures--}function R($){const L=r.get($);if($.depthTexture&&($.depthTexture.dispose(),r.remove($.depthTexture)),$.isWebGLCubeRenderTarget)for(let pe=0;pe<6;pe++){if(Array.isArray(L.__webglFramebuffer[pe]))for(let Se=0;Se<L.__webglFramebuffer[pe].length;Se++)t.deleteFramebuffer(L.__webglFramebuffer[pe][Se]);else t.deleteFramebuffer(L.__webglFramebuffer[pe]);L.__webglDepthbuffer&&t.deleteRenderbuffer(L.__webglDepthbuffer[pe])}else{if(Array.isArray(L.__webglFramebuffer))for(let pe=0;pe<L.__webglFramebuffer.length;pe++)t.deleteFramebuffer(L.__webglFramebuffer[pe]);else t.deleteFramebuffer(L.__webglFramebuffer);if(L.__webglDepthbuffer&&t.deleteRenderbuffer(L.__webglDepthbuffer),L.__webglMultisampledFramebuffer&&t.deleteFramebuffer(L.__webglMultisampledFramebuffer),L.__webglColorRenderbuffer)for(let pe=0;pe<L.__webglColorRenderbuffer.length;pe++)L.__webglColorRenderbuffer[pe]&&t.deleteRenderbuffer(L.__webglColorRenderbuffer[pe]);L.__webglDepthRenderbuffer&&t.deleteRenderbuffer(L.__webglDepthRenderbuffer)}const Y=$.textures;for(let pe=0,Se=Y.length;pe<Se;pe++){const ae=r.get(Y[pe]);ae.__webglTexture&&(t.deleteTexture(ae.__webglTexture),o.memory.textures--),r.remove(Y[pe])}r.remove($)}let U=0;function O(){U=0}function q(){const $=U;return $>=i.maxTextures&&un("WebGLTextures: Trying to use "+$+" texture units while this GPU supports only "+i.maxTextures),U+=1,$}function j($){const L=[];return L.push($.wrapS),L.push($.wrapT),L.push($.wrapR||0),L.push($.magFilter),L.push($.minFilter),L.push($.anisotropy),L.push($.internalFormat),L.push($.format),L.push($.type),L.push($.generateMipmaps),L.push($.premultiplyAlpha),L.push($.flipY),L.push($.unpackAlignment),L.push($.colorSpace),L.join()}function W($,L){const Y=r.get($);if($.isVideoTexture&&Ee($),$.isRenderTargetTexture===!1&&$.isExternalTexture!==!0&&$.version>0&&Y.__version!==$.version){const pe=$.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{me(Y,$,L);return}}else $.isExternalTexture&&(Y.__webglTexture=$.sourceTexture?$.sourceTexture:null);n.bindTexture(t.TEXTURE_2D,Y.__webglTexture,t.TEXTURE0+L)}function X($,L){const Y=r.get($);if($.isRenderTargetTexture===!1&&$.version>0&&Y.__version!==$.version){me(Y,$,L);return}else $.isExternalTexture&&(Y.__webglTexture=$.sourceTexture?$.sourceTexture:null);n.bindTexture(t.TEXTURE_2D_ARRAY,Y.__webglTexture,t.TEXTURE0+L)}function G($,L){const Y=r.get($);if($.isRenderTargetTexture===!1&&$.version>0&&Y.__version!==$.version){me(Y,$,L);return}n.bindTexture(t.TEXTURE_3D,Y.__webglTexture,t.TEXTURE0+L)}function Z($,L){const Y=r.get($);if($.isCubeDepthTexture!==!0&&$.version>0&&Y.__version!==$.version){oe(Y,$,L);return}n.bindTexture(t.TEXTURE_CUBE_MAP,Y.__webglTexture,t.TEXTURE0+L)}const te={[I3]:t.REPEAT,[eu]:t.CLAMP_TO_EDGE,[F3]:t.MIRRORED_REPEAT},ee={[Na]:t.NEAREST,[S3e]:t.NEAREST_MIPMAP_NEAREST,[P_]:t.NEAREST_MIPMAP_LINEAR,[Ua]:t.LINEAR,[KC]:t.LINEAR_MIPMAP_NEAREST,[pf]:t.LINEAR_MIPMAP_LINEAR},z={[E3e]:t.NEVER,[j3e]:t.ALWAYS,[A3e]:t.LESS,[rL]:t.LEQUAL,[T3e]:t.EQUAL,[iL]:t.GEQUAL,[C3e]:t.GREATER,[k3e]:t.NOTEQUAL};function V($,L){if(L.type===$l&&e.has("OES_texture_float_linear")===!1&&(L.magFilter===Ua||L.magFilter===KC||L.magFilter===P_||L.magFilter===pf||L.minFilter===Ua||L.minFilter===KC||L.minFilter===P_||L.minFilter===pf)&&un("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri($,t.TEXTURE_WRAP_S,te[L.wrapS]),t.texParameteri($,t.TEXTURE_WRAP_T,te[L.wrapT]),($===t.TEXTURE_3D||$===t.TEXTURE_2D_ARRAY)&&t.texParameteri($,t.TEXTURE_WRAP_R,te[L.wrapR]),t.texParameteri($,t.TEXTURE_MAG_FILTER,ee[L.magFilter]),t.texParameteri($,t.TEXTURE_MIN_FILTER,ee[L.minFilter]),L.compareFunction&&(t.texParameteri($,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri($,t.TEXTURE_COMPARE_FUNC,z[L.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(L.magFilter===Na||L.minFilter!==P_&&L.minFilter!==pf||L.type===$l&&e.has("OES_texture_float_linear")===!1)return;if(L.anisotropy>1||r.get(L).__currentAnisotropy){const Y=e.get("EXT_texture_filter_anisotropic");t.texParameterf($,Y.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(L.anisotropy,i.getMaxAnisotropy())),r.get(L).__currentAnisotropy=L.anisotropy}}}function ne($,L){let Y=!1;$.__webglInit===void 0&&($.__webglInit=!0,L.addEventListener("dispose",k));const pe=L.source;let Se=m.get(pe);Se===void 0&&(Se={},m.set(pe,Se));const ae=j(L);if(ae!==$.__cacheKey){Se[ae]===void 0&&(Se[ae]={texture:t.createTexture(),usedTimes:0},o.memory.textures++,Y=!0),Se[ae].usedTimes++;const je=Se[$.__cacheKey];je!==void 0&&(Se[$.__cacheKey].usedTimes--,je.usedTimes===0&&C(L)),$.__cacheKey=ae,$.__webglTexture=Se[ae].texture}return Y}function ie($,L,Y){return Math.floor(Math.floor($/Y)/L)}function he($,L,Y,pe){const ae=$.updateRanges;if(ae.length===0)n.texSubImage2D(t.TEXTURE_2D,0,0,0,L.width,L.height,Y,pe,L.data);else{ae.sort((Qe,se)=>Qe.start-se.start);let je=0;for(let Qe=1;Qe<ae.length;Qe++){const se=ae[je],ye=ae[Qe],ke=se.start+se.count,Ue=ie(ye.start,L.width,4),dt=ie(se.start,L.width,4);ye.start<=ke+1&&Ue===dt&&ie(ye.start+ye.count-1,L.width,4)===Ue?se.count=Math.max(se.count,ye.start+ye.count-se.start):(++je,ae[je]=ye)}ae.length=je+1;const De=t.getParameter(t.UNPACK_ROW_LENGTH),Xe=t.getParameter(t.UNPACK_SKIP_PIXELS),et=t.getParameter(t.UNPACK_SKIP_ROWS);t.pixelStorei(t.UNPACK_ROW_LENGTH,L.width);for(let Qe=0,se=ae.length;Qe<se;Qe++){const ye=ae[Qe],ke=Math.floor(ye.start/4),Ue=Math.ceil(ye.count/4),dt=ke%L.width,re=Math.floor(ke/L.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,L.data)}$.clearUpdateRanges(),t.pixelStorei(t.UNPACK_ROW_LENGTH,De),t.pixelStorei(t.UNPACK_SKIP_PIXELS,Xe),t.pixelStorei(t.UNPACK_SKIP_ROWS,et)}}function me($,L,Y){let pe=t.TEXTURE_2D;(L.isDataArrayTexture||L.isCompressedArrayTexture)&&(pe=t.TEXTURE_2D_ARRAY),L.isData3DTexture&&(pe=t.TEXTURE_3D);const Se=ne($,L),ae=L.source;n.bindTexture(pe,$.__webglTexture,t.TEXTURE0+Y);const je=r.get(ae);if(ae.version!==je.__version||Se===!0){n.activeTexture(t.TEXTURE0+Y);const De=Vn.getPrimaries(Vn.workingColorSpace),Xe=L.colorSpace===Nd?null:Vn.getPrimaries(L.colorSpace),et=L.colorSpace===Nd||De===Xe?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,et);let Qe=y(L.image,!1,i.maxTextureSize);Qe=Ie(L,Qe);const se=a.convert(L.format,L.colorSpace),ye=a.convert(L.type);let ke=M(L.internalFormat,se,ye,L.colorSpace,L.isVideoTexture);V(pe,L);let Ue;const dt=L.mipmaps,re=L.isVideoTexture!==!0,Fe=je.__version===void 0||Se===!0,ve=ae.dataReady,$e=A(L,Qe);if(L.isDepthTexture)ke=E(L.format===gf,L.type),Fe&&(re?n.texStorage2D(t.TEXTURE_2D,1,ke,Qe.width,Qe.height):n.texImage2D(t.TEXTURE_2D,0,ke,Qe.width,Qe.height,0,se,ye,null));else if(L.isDataTexture)if(dt.length>0){re&&Fe&&n.texStorage2D(t.TEXTURE_2D,$e,ke,dt[0].width,dt[0].height);for(let Le=0,Te=dt.length;Le<Te;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,ke,Ue.width,Ue.height,0,se,ye,Ue.data);L.generateMipmaps=!1}else re?(Fe&&n.texStorage2D(t.TEXTURE_2D,$e,ke,Qe.width,Qe.height),ve&&he(L,Qe,se,ye)):n.texImage2D(t.TEXTURE_2D,0,ke,Qe.width,Qe.height,0,se,ye,Qe.data);else if(L.isCompressedTexture)if(L.isCompressedArrayTexture){re&&Fe&&n.texStorage3D(t.TEXTURE_2D_ARRAY,$e,ke,dt[0].width,dt[0].height,Qe.depth);for(let Le=0,Te=dt.length;Le<Te;Le++)if(Ue=dt[Le],L.format!==nl)if(se!==null)if(re){if(ve)if(L.layerUpdates.size>0){const We=QV(Ue.width,Ue.height,L.format,L.type);for(const it of L.layerUpdates){const Ot=Ue.data.subarray(it*We/Ue.data.BYTES_PER_ELEMENT,(it+1)*We/Ue.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Le,0,0,it,Ue.width,Ue.height,1,se,Ot)}L.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Le,0,0,0,Ue.width,Ue.height,Qe.depth,se,Ue.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,Le,ke,Ue.width,Ue.height,Qe.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,Qe.depth,se,ye,Ue.data):n.texImage3D(t.TEXTURE_2D_ARRAY,Le,ke,Ue.width,Ue.height,Qe.depth,0,se,ye,Ue.data)}else{re&&Fe&&n.texStorage2D(t.TEXTURE_2D,$e,ke,dt[0].width,dt[0].height);for(let Le=0,Te=dt.length;Le<Te;Le++)Ue=dt[Le],L.format!==nl?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,ke,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,ke,Ue.width,Ue.height,0,se,ye,Ue.data)}else if(L.isDataArrayTexture)if(re){if(Fe&&n.texStorage3D(t.TEXTURE_2D_ARRAY,$e,ke,Qe.width,Qe.height,Qe.depth),ve)if(L.layerUpdates.size>0){const Le=QV(Qe.width,Qe.height,L.format,L.type);for(const Te of L.layerUpdates){const We=Qe.data.subarray(Te*Le/Qe.data.BYTES_PER_ELEMENT,(Te+1)*Le/Qe.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,Te,Qe.width,Qe.height,1,se,ye,We)}L.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,Qe.width,Qe.height,Qe.depth,se,ye,Qe.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,ke,Qe.width,Qe.height,Qe.depth,0,se,ye,Qe.data);else if(L.isData3DTexture)re?(Fe&&n.texStorage3D(t.TEXTURE_3D,$e,ke,Qe.width,Qe.height,Qe.depth),ve&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,Qe.width,Qe.height,Qe.depth,se,ye,Qe.data)):n.texImage3D(t.TEXTURE_3D,0,ke,Qe.width,Qe.height,Qe.depth,0,se,ye,Qe.data);else if(L.isFramebufferTexture){if(Fe)if(re)n.texStorage2D(t.TEXTURE_2D,$e,ke,Qe.width,Qe.height);else{let Le=Qe.width,Te=Qe.height;for(let We=0;We<$e;We++)n.texImage2D(t.TEXTURE_2D,We,ke,Le,Te,0,se,ye,null),Le>>=1,Te>>=1}}else if(dt.length>0){if(re&&Fe){const Le=ue(dt[0]);n.texStorage2D(t.TEXTURE_2D,$e,ke,Le.width,Le.height)}for(let Le=0,Te=dt.length;Le<Te;Le++)Ue=dt[Le],re?ve&&n.texSubImage2D(t.TEXTURE_2D,Le,0,0,se,ye,Ue):n.texImage2D(t.TEXTURE_2D,Le,ke,se,ye,Ue);L.generateMipmaps=!1}else if(re){if(Fe){const Le=ue(Qe);n.texStorage2D(t.TEXTURE_2D,$e,ke,Le.width,Le.height)}ve&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,se,ye,Qe)}else n.texImage2D(t.TEXTURE_2D,0,ke,se,ye,Qe);x(L)&&v(pe),je.__version=ae.version,L.onUpdate&&L.onUpdate(L)}$.__version=L.version}function oe($,L,Y){if(L.image.length!==6)return;const pe=ne($,L),Se=L.source;n.bindTexture(t.TEXTURE_CUBE_MAP,$.__webglTexture,t.TEXTURE0+Y);const ae=r.get(Se);if(Se.version!==ae.__version||pe===!0){n.activeTexture(t.TEXTURE0+Y);const je=Vn.getPrimaries(Vn.workingColorSpace),De=L.colorSpace===Nd?null:Vn.getPrimaries(L.colorSpace),Xe=L.colorSpace===Nd||je===De?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Xe);const et=L.isCompressedTexture||L.image[0].isCompressedTexture,Qe=L.image[0]&&L.image[0].isDataTexture,se=[];for(let Te=0;Te<6;Te++)!et&&!Qe?se[Te]=y(L.image[Te],!0,i.maxCubemapSize):se[Te]=Qe?L.image[Te].image:L.image[Te],se[Te]=Ie(L,se[Te]);const ye=se[0],ke=a.convert(L.format,L.colorSpace),Ue=a.convert(L.type),dt=M(L.internalFormat,ke,Ue,L.colorSpace),re=L.isVideoTexture!==!0,Fe=ae.__version===void 0||pe===!0,ve=Se.dataReady;let $e=A(L,ye);V(t.TEXTURE_CUBE_MAP,L);let Le;if(et){re&&Fe&&n.texStorage2D(t.TEXTURE_CUBE_MAP,$e,dt,ye.width,ye.height);for(let Te=0;Te<6;Te++){Le=se[Te].mipmaps;for(let We=0;We<Le.length;We++){const it=Le[We];L.format!==nl?ke!==null?re?ve&&n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,We,0,0,it.width,it.height,ke,it.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,We,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+Te,We,0,0,it.width,it.height,ke,Ue,it.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,We,dt,it.width,it.height,0,ke,Ue,it.data)}}}else{if(Le=L.mipmaps,re&&Fe){Le.length>0&&$e++;const Te=ue(se[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,$e,dt,Te.width,Te.height)}for(let Te=0;Te<6;Te++)if(Qe){re?ve&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,0,0,0,se[Te].width,se[Te].height,ke,Ue,se[Te].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,0,dt,se[Te].width,se[Te].height,0,ke,Ue,se[Te].data);for(let We=0;We<Le.length;We++){const Ot=Le[We].image[Te].image;re?ve&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,We+1,0,0,Ot.width,Ot.height,ke,Ue,Ot.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,We+1,dt,Ot.width,Ot.height,0,ke,Ue,Ot.data)}}else{re?ve&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,0,0,0,ke,Ue,se[Te]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,0,dt,ke,Ue,se[Te]);for(let We=0;We<Le.length;We++){const it=Le[We];re?ve&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,We+1,0,0,ke,Ue,it.image[Te]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,We+1,dt,ke,Ue,it.image[Te])}}}x(L)&&v(t.TEXTURE_CUBE_MAP),ae.__version=Se.version,L.onUpdate&&L.onUpdate(L)}$.__version=L.version}function Ae($,L,Y,pe,Se,ae){const je=a.convert(Y.format,Y.colorSpace),De=a.convert(Y.type),Xe=M(Y.internalFormat,je,De,Y.colorSpace),et=r.get(L),Qe=r.get(Y);if(Qe.__renderTarget=L,!et.__hasExternalTextures){const se=Math.max(1,L.width>>ae),ye=Math.max(1,L.height>>ae);Se===t.TEXTURE_3D||Se===t.TEXTURE_2D_ARRAY?n.texImage3D(Se,ae,Xe,se,ye,L.depth,0,je,De,null):n.texImage2D(Se,ae,Xe,se,ye,0,je,De,null)}n.bindFramebuffer(t.FRAMEBUFFER,$),ce(L)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,pe,Se,Qe.__webglTexture,0,I(L)):(Se===t.TEXTURE_2D||Se>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&Se<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,pe,Se,Qe.__webglTexture,ae),n.bindFramebuffer(t.FRAMEBUFFER,null)}function ge($,L,Y){if(t.bindRenderbuffer(t.RENDERBUFFER,$),L.depthBuffer){const pe=L.depthTexture,Se=pe&&pe.isDepthTexture?pe.type:null,ae=E(L.stencilBuffer,Se),je=L.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;ce(L)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,I(L),ae,L.width,L.height):Y?t.renderbufferStorageMultisample(t.RENDERBUFFER,I(L),ae,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,ae,L.width,L.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,je,t.RENDERBUFFER,$)}else{const pe=L.textures;for(let Se=0;Se<pe.length;Se++){const ae=pe[Se],je=a.convert(ae.format,ae.colorSpace),De=a.convert(ae.type),Xe=M(ae.internalFormat,je,De,ae.colorSpace);ce(L)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,I(L),Xe,L.width,L.height):Y?t.renderbufferStorageMultisample(t.RENDERBUFFER,I(L),Xe,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,Xe,L.width,L.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function Ne($,L,Y){const pe=L.isWebGLCubeRenderTarget===!0;if(n.bindFramebuffer(t.FRAMEBUFFER,$),!(L.depthTexture&&L.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const Se=r.get(L.depthTexture);if(Se.__renderTarget=L,(!Se.__webglTexture||L.depthTexture.image.width!==L.width||L.depthTexture.image.height!==L.height)&&(L.depthTexture.image.width=L.width,L.depthTexture.image.height=L.height,L.depthTexture.needsUpdate=!0),pe){if(Se.__webglInit===void 0&&(Se.__webglInit=!0,L.depthTexture.addEventListener("dispose",k)),Se.__webglTexture===void 0){Se.__webglTexture=t.createTexture(),n.bindTexture(t.TEXTURE_CUBE_MAP,Se.__webglTexture),V(t.TEXTURE_CUBE_MAP,L.depthTexture);const et=a.convert(L.depthTexture.format),Qe=a.convert(L.depthTexture.type);let se;L.depthTexture.format===_u?se=t.DEPTH_COMPONENT24:L.depthTexture.format===gf&&(se=t.DEPTH24_STENCIL8);for(let ye=0;ye<6;ye++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,0,se,L.width,L.height,0,et,Qe,null)}}else W(L.depthTexture,0);const ae=Se.__webglTexture,je=I(L),De=pe?t.TEXTURE_CUBE_MAP_POSITIVE_X+Y:t.TEXTURE_2D,Xe=L.depthTexture.format===gf?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(L.depthTexture.format===_u)ce(L)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,Xe,De,ae,0,je):t.framebufferTexture2D(t.FRAMEBUFFER,Xe,De,ae,0);else if(L.depthTexture.format===gf)ce(L)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,Xe,De,ae,0,je):t.framebufferTexture2D(t.FRAMEBUFFER,Xe,De,ae,0);else throw new Error("Unknown depthTexture format")}function _e($){const L=r.get($),Y=$.isWebGLCubeRenderTarget===!0;if(L.__boundDepthTexture!==$.depthTexture){const pe=$.depthTexture;if(L.__depthDisposeCallback&&L.__depthDisposeCallback(),pe){const Se=()=>{delete L.__boundDepthTexture,delete L.__depthDisposeCallback,pe.removeEventListener("dispose",Se)};pe.addEventListener("dispose",Se),L.__depthDisposeCallback=Se}L.__boundDepthTexture=pe}if($.depthTexture&&!L.__autoAllocateDepthBuffer)if(Y)for(let pe=0;pe<6;pe++)Ne(L.__webglFramebuffer[pe],$,pe);else{const pe=$.texture.mipmaps;pe&&pe.length>0?Ne(L.__webglFramebuffer[0],$,0):Ne(L.__webglFramebuffer,$,0)}else if(Y){L.__webglDepthbuffer=[];for(let pe=0;pe<6;pe++)if(n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[pe]),L.__webglDepthbuffer[pe]===void 0)L.__webglDepthbuffer[pe]=t.createRenderbuffer(),ge(L.__webglDepthbuffer[pe],$,!1);else{const Se=$.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ae=L.__webglDepthbuffer[pe];t.bindRenderbuffer(t.RENDERBUFFER,ae),t.framebufferRenderbuffer(t.FRAMEBUFFER,Se,t.RENDERBUFFER,ae)}}else{const pe=$.texture.mipmaps;if(pe&&pe.length>0?n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[0]):n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer),L.__webglDepthbuffer===void 0)L.__webglDepthbuffer=t.createRenderbuffer(),ge(L.__webglDepthbuffer,$,!1);else{const Se=$.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ae=L.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,ae),t.framebufferRenderbuffer(t.FRAMEBUFFER,Se,t.RENDERBUFFER,ae)}}n.bindFramebuffer(t.FRAMEBUFFER,null)}function le($,L,Y){const pe=r.get($);L!==void 0&&Ae(pe.__webglFramebuffer,$,$.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),Y!==void 0&&_e($)}function He($){const L=$.texture,Y=r.get($),pe=r.get(L);$.addEventListener("dispose",T);const Se=$.textures,ae=$.isWebGLCubeRenderTarget===!0,je=Se.length>1;if(je||(pe.__webglTexture===void 0&&(pe.__webglTexture=t.createTexture()),pe.__version=L.version,o.memory.textures++),ae){Y.__webglFramebuffer=[];for(let De=0;De<6;De++)if(L.mipmaps&&L.mipmaps.length>0){Y.__webglFramebuffer[De]=[];for(let Xe=0;Xe<L.mipmaps.length;Xe++)Y.__webglFramebuffer[De][Xe]=t.createFramebuffer()}else Y.__webglFramebuffer[De]=t.createFramebuffer()}else{if(L.mipmaps&&L.mipmaps.length>0){Y.__webglFramebuffer=[];for(let De=0;De<L.mipmaps.length;De++)Y.__webglFramebuffer[De]=t.createFramebuffer()}else Y.__webglFramebuffer=t.createFramebuffer();if(je)for(let De=0,Xe=Se.length;De<Xe;De++){const et=r.get(Se[De]);et.__webglTexture===void 0&&(et.__webglTexture=t.createTexture(),o.memory.textures++)}if($.samples>0&&ce($)===!1){Y.__webglMultisampledFramebuffer=t.createFramebuffer(),Y.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,Y.__webglMultisampledFramebuffer);for(let De=0;De<Se.length;De++){const Xe=Se[De];Y.__webglColorRenderbuffer[De]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,Y.__webglColorRenderbuffer[De]);const et=a.convert(Xe.format,Xe.colorSpace),Qe=a.convert(Xe.type),se=M(Xe.internalFormat,et,Qe,Xe.colorSpace,$.isXRRenderTarget===!0),ye=I($);t.renderbufferStorageMultisample(t.RENDERBUFFER,ye,se,$.width,$.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+De,t.RENDERBUFFER,Y.__webglColorRenderbuffer[De])}t.bindRenderbuffer(t.RENDERBUFFER,null),$.depthBuffer&&(Y.__webglDepthRenderbuffer=t.createRenderbuffer(),ge(Y.__webglDepthRenderbuffer,$,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(ae){n.bindTexture(t.TEXTURE_CUBE_MAP,pe.__webglTexture),V(t.TEXTURE_CUBE_MAP,L);for(let De=0;De<6;De++)if(L.mipmaps&&L.mipmaps.length>0)for(let Xe=0;Xe<L.mipmaps.length;Xe++)Ae(Y.__webglFramebuffer[De][Xe],$,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+De,Xe);else Ae(Y.__webglFramebuffer[De],$,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+De,0);x(L)&&v(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(je){for(let De=0,Xe=Se.length;De<Xe;De++){const et=Se[De],Qe=r.get(et);let se=t.TEXTURE_2D;($.isWebGL3DRenderTarget||$.isWebGLArrayRenderTarget)&&(se=$.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(se,Qe.__webglTexture),V(se,et),Ae(Y.__webglFramebuffer,$,et,t.COLOR_ATTACHMENT0+De,se,0),x(et)&&v(se)}n.unbindTexture()}else{let De=t.TEXTURE_2D;if(($.isWebGL3DRenderTarget||$.isWebGLArrayRenderTarget)&&(De=$.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(De,pe.__webglTexture),V(De,L),L.mipmaps&&L.mipmaps.length>0)for(let Xe=0;Xe<L.mipmaps.length;Xe++)Ae(Y.__webglFramebuffer[Xe],$,L,t.COLOR_ATTACHMENT0,De,Xe);else Ae(Y.__webglFramebuffer,$,L,t.COLOR_ATTACHMENT0,De,0);x(L)&&v(De),n.unbindTexture()}$.depthBuffer&&_e($)}function H($){const L=$.textures;for(let Y=0,pe=L.length;Y<pe;Y++){const Se=L[Y];if(x(Se)){const ae=S($),je=r.get(Se).__webglTexture;n.bindTexture(ae,je),v(ae),n.unbindTexture()}}}const J=[],K=[];function B($){if($.samples>0){if(ce($)===!1){const L=$.textures,Y=$.width,pe=$.height;let Se=t.COLOR_BUFFER_BIT;const ae=$.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,je=r.get($),De=L.length>1;if(De)for(let et=0;et<L.length;et++)n.bindFramebuffer(t.FRAMEBUFFER,je.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+et,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,je.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+et,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,je.__webglMultisampledFramebuffer);const Xe=$.texture.mipmaps;Xe&&Xe.length>0?n.bindFramebuffer(t.DRAW_FRAMEBUFFER,je.__webglFramebuffer[0]):n.bindFramebuffer(t.DRAW_FRAMEBUFFER,je.__webglFramebuffer);for(let et=0;et<L.length;et++){if($.resolveDepthBuffer&&($.depthBuffer&&(Se|=t.DEPTH_BUFFER_BIT),$.stencilBuffer&&$.resolveStencilBuffer&&(Se|=t.STENCIL_BUFFER_BIT)),De){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,je.__webglColorRenderbuffer[et]);const Qe=r.get(L[et]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,Qe,0)}t.blitFramebuffer(0,0,Y,pe,0,0,Y,pe,Se,t.NEAREST),c===!0&&(J.length=0,K.length=0,J.push(t.COLOR_ATTACHMENT0+et),$.depthBuffer&&$.resolveDepthBuffer===!1&&(J.push(ae),K.push(ae),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,K)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,J))}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),De)for(let et=0;et<L.length;et++){n.bindFramebuffer(t.FRAMEBUFFER,je.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+et,t.RENDERBUFFER,je.__webglColorRenderbuffer[et]);const Qe=r.get(L[et]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,je.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+et,t.TEXTURE_2D,Qe,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,je.__webglMultisampledFramebuffer)}else if($.depthBuffer&&$.resolveDepthBuffer===!1&&c){const L=$.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[L])}}}function I($){return Math.min(i.maxSamples,$.samples)}function ce($){const L=r.get($);return $.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&L.__useRenderToTexture!==!1}function Ee($){const L=o.render.frame;d.get($)!==L&&(d.set($,L),$.update())}function Ie($,L){const Y=$.colorSpace,pe=$.format,Se=$.type;return $.isCompressedTexture===!0||$.isVideoTexture===!0||Y!==kg&&Y!==Nd&&(Vn.getTransfer(Y)===lr?(pe!==nl||Se!==Hs)&&un("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Kn("WebGLTextures: Unsupported texture color space:",Y)),L}function ue($){return typeof HTMLImageElement<"u"&&$ instanceof HTMLImageElement?(u.width=$.naturalWidth||$.width,u.height=$.naturalHeight||$.height):typeof VideoFrame<"u"&&$ instanceof VideoFrame?(u.width=$.displayWidth,u.height=$.displayHeight):(u.width=$.width,u.height=$.height),u}this.allocateTextureUnit=q,this.resetTextureUnits=O,this.setTexture2D=W,this.setTexture2DArray=X,this.setTexture3D=G,this.setTextureCube=Z,this.rebindTextures=le,this.setupRenderTarget=He,this.updateRenderTargetMipmap=H,this.updateMultisampleRenderTarget=B,this.setupDepthRenderbuffer=_e,this.setupFrameBufferTexture=Ae,this.useMultisampledRTT=ce,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function lIe(t,e){function n(r,i=Nd){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===J4)return t.UNSIGNED_SHORT_5_5_5_1;if(r===ree)return t.UNSIGNED_INT_5_9_9_9_REV;if(r===iee)return t.UNSIGNED_INT_10F_11F_11F_REV;if(r===tee)return t.BYTE;if(r===nee)return t.SHORT;if(r===q0)return t.UNSIGNED_SHORT;if(r===Q4)return t.INT;if(r===rc)return t.UNSIGNED_INT;if(r===$l)return t.FLOAT;if(r===vu)return t.HALF_FLOAT;if(r===aee)return t.ALPHA;if(r===see)return t.RGB;if(r===nl)return t.RGBA;if(r===_u)return t.DEPTH_COMPONENT;if(r===gf)return t.DEPTH_STENCIL;if(r===oee)return t.RED;if(r===eL)return t.RED_INTEGER;if(r===Cg)return t.RG;if(r===tL)return t.RG_INTEGER;if(r===nL)return t.RGBA_INTEGER;if(r===cw||r===uw||r===dw||r===hw)if(o===lr)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(r===cw)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===uw)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===dw)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===hw)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(r===cw)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===uw)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===dw)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===hw)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===U3||r===z3||r===B3||r===$3)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(r===U3)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===z3)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===B3)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===$3)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===H3||r===V3||r===G3||r===W3||r===q3||r===K3||r===X3)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(r===H3||r===V3)return o===lr?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(r===G3)return o===lr?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC;if(r===W3)return a.COMPRESSED_R11_EAC;if(r===q3)return a.COMPRESSED_SIGNED_R11_EAC;if(r===K3)return a.COMPRESSED_RG11_EAC;if(r===X3)return a.COMPRESSED_SIGNED_RG11_EAC}else return null;if(r===Y3||r===Q3||r===Z3||r===J3||r===eR||r===tR||r===nR||r===rR||r===iR||r===aR||r===sR||r===oR||r===lR||r===cR)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(r===Y3)return o===lr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===Q3)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===J3)return o===lr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===eR)return o===lr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===tR)return o===lr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===nR)return o===lr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===rR)return o===lr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===iR)return o===lr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===aR)return o===lr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===sR)return o===lr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===oR)return o===lr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===lR)return o===lr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===cR)return o===lr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===uR||r===dR||r===hR)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(r===uR)return o===lr?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===dR)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===hR)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===fR||r===mR||r===pR||r===gR)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(r===fR)return a.COMPRESSED_RED_RGTC1_EXT;if(r===mR)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===pR)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===gR)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===K0?t.UNSIGNED_INT_24_8:t[r]!==void 0?t[r]:null}return{convert:n}}const cIe=`
- void main() {
- gl_Position = vec4( position, 1.0 );
- }`,uIe=`
- uniform sampler2DArray depthColor;
- uniform float depthWidth;
- uniform float depthHeight;
- void main() {
- vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
- if ( coord.x >= 1.0 ) {
- gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
- } else {
- gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
- }
- }`;class dIe{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,n){if(this.texture===null){const r=new Aee(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:cIe,fragmentShader:uIe,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new hl(new uL(20,20),r)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}let hIe=class 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 y=typeof XRWebGLBinding<"u",x=new dIe,v={},S=n.getContextAttributes();let M=null,E=null;const A=[],k=[],T=new Mn;let D=null;const C=new So;C.viewport=new Mi;const R=new So;R.viewport=new Mi;const U=[C,R],O=new vRe;let q=null,j=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(me){let oe=A[me];return oe===void 0&&(oe=new gk,A[me]=oe),oe.getTargetRaySpace()},this.getControllerGrip=function(me){let oe=A[me];return oe===void 0&&(oe=new gk,A[me]=oe),oe.getGripSpace()},this.getHand=function(me){let oe=A[me];return oe===void 0&&(oe=new gk,A[me]=oe),oe.getHandSpace()};function W(me){const oe=k.indexOf(me.inputSource);if(oe===-1)return;const Ae=A[oe];Ae!==void 0&&(Ae.update(me.inputSource,me.frame,u||o),Ae.dispatchEvent({type:me.type,data:me.inputSource}))}function X(){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",X),i.removeEventListener("inputsourceschange",G);for(let me=0;me<A.length;me++){const oe=k[me];oe!==null&&(k[me]=null,A[me].disconnect(oe))}q=null,j=null,x.reset();for(const me in v)delete v[me];e.setRenderTarget(M),p=null,m=null,f=null,i=null,E=null,he.stop(),r.isPresenting=!1,e.setPixelRatio(D),e.setSize(T.width,T.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(me){a=me,r.isPresenting===!0&&un("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(me){l=me,r.isPresenting===!0&&un("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(me){u=me},this.getBaseLayer=function(){return m!==null?m:p},this.getBinding=function(){return f===null&&y&&(f=new XRWebGLBinding(i,n)),f},this.getFrame=function(){return b},this.getSession=function(){return i},this.setSession=async function(me){if(i=me,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",X),i.addEventListener("inputsourceschange",G),S.xrCompatible!==!0&&await n.makeXRCompatible(),D=e.getPixelRatio(),e.getSize(T),y&&"createProjectionLayer"in XRWebGLBinding.prototype){let Ae=null,ge=null,Ne=null;S.depth&&(Ne=S.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,Ae=S.stencil?gf:_u,ge=S.stencil?K0:rc);const _e={colorFormat:n.RGBA8,depthFormat:Ne,scaleFactor:a};f=this.getBinding(),m=f.createProjectionLayer(_e),i.updateRenderState({layers:[m]}),e.setPixelRatio(1),e.setSize(m.textureWidth,m.textureHeight,!1),E=new Kl(m.textureWidth,m.textureHeight,{format:nl,type:Hs,depthTexture:new Y0(m.textureWidth,m.textureHeight,ge,void 0,void 0,void 0,void 0,void 0,void 0,Ae),stencilBuffer:S.stencil,colorSpace:e.outputColorSpace,samples:S.antialias?4:0,resolveDepthBuffer:m.ignoreDepthValues===!1,resolveStencilBuffer:m.ignoreDepthValues===!1})}else{const Ae={antialias:S.antialias,alpha:!0,depth:S.depth,stencil:S.stencil,framebufferScaleFactor:a};p=new XRWebGLLayer(i,n,Ae),i.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),E=new Kl(p.framebufferWidth,p.framebufferHeight,{format:nl,type:Hs,colorSpace:e.outputColorSpace,stencilBuffer:S.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}E.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 G(me){for(let oe=0;oe<me.removed.length;oe++){const Ae=me.removed[oe],ge=k.indexOf(Ae);ge>=0&&(k[ge]=null,A[ge].disconnect(Ae))}for(let oe=0;oe<me.added.length;oe++){const Ae=me.added[oe];let ge=k.indexOf(Ae);if(ge===-1){for(let _e=0;_e<A.length;_e++)if(_e>=k.length){k.push(Ae),ge=_e;break}else if(k[_e]===null){k[_e]=Ae,ge=_e;break}if(ge===-1)break}const Ne=A[ge];Ne&&Ne.connect(Ae)}}const Z=new nt,te=new nt;function ee(me,oe,Ae){Z.setFromMatrixPosition(oe.matrixWorld),te.setFromMatrixPosition(Ae.matrixWorld);const ge=Z.distanceTo(te),Ne=oe.projectionMatrix.elements,_e=Ae.projectionMatrix.elements,le=Ne[14]/(Ne[10]-1),He=Ne[14]/(Ne[10]+1),H=(Ne[9]+1)/Ne[5],J=(Ne[9]-1)/Ne[5],K=(Ne[8]-1)/Ne[0],B=(_e[8]+1)/_e[0],I=le*K,ce=le*B,Ee=ge/(-K+B),Ie=Ee*-K;if(oe.matrixWorld.decompose(me.position,me.quaternion,me.scale),me.translateX(Ie),me.translateZ(Ee),me.matrixWorld.compose(me.position,me.quaternion,me.scale),me.matrixWorldInverse.copy(me.matrixWorld).invert(),Ne[10]===-1)me.projectionMatrix.copy(oe.projectionMatrix),me.projectionMatrixInverse.copy(oe.projectionMatrixInverse);else{const ue=le+Ee,$=He+Ee,L=I-Ie,Y=ce+(ge-Ie),pe=H*He/$*ue,Se=J*He/$*ue;me.projectionMatrix.makePerspective(L,Y,pe,Se,ue,$),me.projectionMatrixInverse.copy(me.projectionMatrix).invert()}}function z(me,oe){oe===null?me.matrixWorld.copy(me.matrix):me.matrixWorld.multiplyMatrices(oe.matrixWorld,me.matrix),me.matrixWorldInverse.copy(me.matrixWorld).invert()}this.updateCamera=function(me){if(i===null)return;let oe=me.near,Ae=me.far;x.texture!==null&&(x.depthNear>0&&(oe=x.depthNear),x.depthFar>0&&(Ae=x.depthFar)),O.near=R.near=C.near=oe,O.far=R.far=C.far=Ae,(q!==O.near||j!==O.far)&&(i.updateRenderState({depthNear:O.near,depthFar:O.far}),q=O.near,j=O.far),O.layers.mask=me.layers.mask|6,C.layers.mask=O.layers.mask&3,R.layers.mask=O.layers.mask&5;const ge=me.parent,Ne=O.cameras;z(O,ge);for(let _e=0;_e<Ne.length;_e++)z(Ne[_e],ge);Ne.length===2?ee(O,C,R):O.projectionMatrix.copy(C.projectionMatrix),V(me,O,ge)};function V(me,oe,Ae){Ae===null?me.matrix.copy(oe.matrixWorld):(me.matrix.copy(Ae.matrixWorld),me.matrix.invert(),me.matrix.multiply(oe.matrixWorld)),me.matrix.decompose(me.position,me.quaternion,me.scale),me.updateMatrixWorld(!0),me.projectionMatrix.copy(oe.projectionMatrix),me.projectionMatrixInverse.copy(oe.projectionMatrixInverse),me.isPerspectiveCamera&&(me.fov=xR*2*Math.atan(1/me.projectionMatrix.elements[5]),me.zoom=1)}this.getCamera=function(){return O},this.getFoveation=function(){if(!(m===null&&p===null))return c},this.setFoveation=function(me){c=me,m!==null&&(m.fixedFoveation=me),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=me)},this.hasDepthSensing=function(){return x.texture!==null},this.getDepthSensingMesh=function(){return x.getMesh(O)},this.getCameraTexture=function(me){return v[me]};let ne=null;function ie(me,oe){if(d=oe.getViewerPose(u||o),b=oe,d!==null){const Ae=d.views;p!==null&&(e.setRenderTargetFramebuffer(E,p.framebuffer),e.setRenderTarget(E));let ge=!1;Ae.length!==O.cameras.length&&(O.cameras.length=0,ge=!0);for(let He=0;He<Ae.length;He++){const H=Ae[He];let J=null;if(p!==null)J=p.getViewport(H);else{const B=f.getViewSubImage(m,H);J=B.viewport,He===0&&(e.setRenderTargetTextures(E,B.colorTexture,B.depthStencilTexture),e.setRenderTarget(E))}let K=U[He];K===void 0&&(K=new So,K.layers.enable(He),K.viewport=new Mi,U[He]=K),K.matrix.fromArray(H.transform.matrix),K.matrix.decompose(K.position,K.quaternion,K.scale),K.projectionMatrix.fromArray(H.projectionMatrix),K.projectionMatrixInverse.copy(K.projectionMatrix).invert(),K.viewport.set(J.x,J.y,J.width,J.height),He===0&&(O.matrix.copy(K.matrix),O.matrix.decompose(O.position,O.quaternion,O.scale)),ge===!0&&O.cameras.push(K)}const Ne=i.enabledFeatures;if(Ne&&Ne.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&y){f=r.getBinding();const He=f.getDepthInformation(Ae[0]);He&&He.isValid&&He.texture&&x.init(He,i.renderState)}if(Ne&&Ne.includes("camera-access")&&y){e.state.unbindTexture(),f=r.getBinding();for(let He=0;He<Ae.length;He++){const H=Ae[He].camera;if(H){let J=v[H];J||(J=new Aee,v[H]=J);const K=f.getCameraImage(H);J.sourceTexture=K}}}}for(let Ae=0;Ae<A.length;Ae++){const ge=k[Ae],Ne=A[Ae];ge!==null&&Ne!==void 0&&Ne.update(ge,oe,u||o)}ne&&ne(me,oe),oe.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:oe}),b=null}const he=new kee;he.setAnimationLoop(ie),this.setAnimationLoop=function(me){ne=me},this.dispose=function(){}}};const $h=new th,fIe=new mi;function mIe(t,e){function n(x,v){x.matrixAutoUpdate===!0&&x.updateMatrix(),v.value.copy(x.matrix)}function r(x,v){v.color.getRGB(x.fogColor.value,wee(t)),v.isFog?(x.fogNear.value=v.near,x.fogFar.value=v.far):v.isFogExp2&&(x.fogDensity.value=v.density)}function i(x,v,S,M,E){v.isMeshBasicMaterial||v.isMeshLambertMaterial?a(x,v):v.isMeshToonMaterial?(a(x,v),f(x,v)):v.isMeshPhongMaterial?(a(x,v),d(x,v)):v.isMeshStandardMaterial?(a(x,v),m(x,v),v.isMeshPhysicalMaterial&&p(x,v,E)):v.isMeshMatcapMaterial?(a(x,v),b(x,v)):v.isMeshDepthMaterial?a(x,v):v.isMeshDistanceMaterial?(a(x,v),y(x,v)):v.isMeshNormalMaterial?a(x,v):v.isLineBasicMaterial?(o(x,v),v.isLineDashedMaterial&&l(x,v)):v.isPointsMaterial?c(x,v,S,M):v.isSpriteMaterial?u(x,v):v.isShadowMaterial?(x.color.value.copy(v.color),x.opacity.value=v.opacity):v.isShaderMaterial&&(v.uniformsNeedUpdate=!1)}function a(x,v){x.opacity.value=v.opacity,v.color&&x.diffuse.value.copy(v.color),v.emissive&&x.emissive.value.copy(v.emissive).multiplyScalar(v.emissiveIntensity),v.map&&(x.map.value=v.map,n(v.map,x.mapTransform)),v.alphaMap&&(x.alphaMap.value=v.alphaMap,n(v.alphaMap,x.alphaMapTransform)),v.bumpMap&&(x.bumpMap.value=v.bumpMap,n(v.bumpMap,x.bumpMapTransform),x.bumpScale.value=v.bumpScale,v.side===ws&&(x.bumpScale.value*=-1)),v.normalMap&&(x.normalMap.value=v.normalMap,n(v.normalMap,x.normalMapTransform),x.normalScale.value.copy(v.normalScale),v.side===ws&&x.normalScale.value.negate()),v.displacementMap&&(x.displacementMap.value=v.displacementMap,n(v.displacementMap,x.displacementMapTransform),x.displacementScale.value=v.displacementScale,x.displacementBias.value=v.displacementBias),v.emissiveMap&&(x.emissiveMap.value=v.emissiveMap,n(v.emissiveMap,x.emissiveMapTransform)),v.specularMap&&(x.specularMap.value=v.specularMap,n(v.specularMap,x.specularMapTransform)),v.alphaTest>0&&(x.alphaTest.value=v.alphaTest);const S=e.get(v),M=S.envMap,E=S.envMapRotation;M&&(x.envMap.value=M,$h.copy(E),$h.x*=-1,$h.y*=-1,$h.z*=-1,M.isCubeTexture&&M.isRenderTargetTexture===!1&&($h.y*=-1,$h.z*=-1),x.envMapRotation.value.setFromMatrix4(fIe.makeRotationFromEuler($h)),x.flipEnvMap.value=M.isCubeTexture&&M.isRenderTargetTexture===!1?-1:1,x.reflectivity.value=v.reflectivity,x.ior.value=v.ior,x.refractionRatio.value=v.refractionRatio),v.lightMap&&(x.lightMap.value=v.lightMap,x.lightMapIntensity.value=v.lightMapIntensity,n(v.lightMap,x.lightMapTransform)),v.aoMap&&(x.aoMap.value=v.aoMap,x.aoMapIntensity.value=v.aoMapIntensity,n(v.aoMap,x.aoMapTransform))}function o(x,v){x.diffuse.value.copy(v.color),x.opacity.value=v.opacity,v.map&&(x.map.value=v.map,n(v.map,x.mapTransform))}function l(x,v){x.dashSize.value=v.dashSize,x.totalSize.value=v.dashSize+v.gapSize,x.scale.value=v.scale}function c(x,v,S,M){x.diffuse.value.copy(v.color),x.opacity.value=v.opacity,x.size.value=v.size*S,x.scale.value=M*.5,v.map&&(x.map.value=v.map,n(v.map,x.uvTransform)),v.alphaMap&&(x.alphaMap.value=v.alphaMap,n(v.alphaMap,x.alphaMapTransform)),v.alphaTest>0&&(x.alphaTest.value=v.alphaTest)}function u(x,v){x.diffuse.value.copy(v.color),x.opacity.value=v.opacity,x.rotation.value=v.rotation,v.map&&(x.map.value=v.map,n(v.map,x.mapTransform)),v.alphaMap&&(x.alphaMap.value=v.alphaMap,n(v.alphaMap,x.alphaMapTransform)),v.alphaTest>0&&(x.alphaTest.value=v.alphaTest)}function d(x,v){x.specular.value.copy(v.specular),x.shininess.value=Math.max(v.shininess,1e-4)}function f(x,v){v.gradientMap&&(x.gradientMap.value=v.gradientMap)}function m(x,v){x.metalness.value=v.metalness,v.metalnessMap&&(x.metalnessMap.value=v.metalnessMap,n(v.metalnessMap,x.metalnessMapTransform)),x.roughness.value=v.roughness,v.roughnessMap&&(x.roughnessMap.value=v.roughnessMap,n(v.roughnessMap,x.roughnessMapTransform)),v.envMap&&(x.envMapIntensity.value=v.envMapIntensity)}function p(x,v,S){x.ior.value=v.ior,v.sheen>0&&(x.sheenColor.value.copy(v.sheenColor).multiplyScalar(v.sheen),x.sheenRoughness.value=v.sheenRoughness,v.sheenColorMap&&(x.sheenColorMap.value=v.sheenColorMap,n(v.sheenColorMap,x.sheenColorMapTransform)),v.sheenRoughnessMap&&(x.sheenRoughnessMap.value=v.sheenRoughnessMap,n(v.sheenRoughnessMap,x.sheenRoughnessMapTransform))),v.clearcoat>0&&(x.clearcoat.value=v.clearcoat,x.clearcoatRoughness.value=v.clearcoatRoughness,v.clearcoatMap&&(x.clearcoatMap.value=v.clearcoatMap,n(v.clearcoatMap,x.clearcoatMapTransform)),v.clearcoatRoughnessMap&&(x.clearcoatRoughnessMap.value=v.clearcoatRoughnessMap,n(v.clearcoatRoughnessMap,x.clearcoatRoughnessMapTransform)),v.clearcoatNormalMap&&(x.clearcoatNormalMap.value=v.clearcoatNormalMap,n(v.clearcoatNormalMap,x.clearcoatNormalMapTransform),x.clearcoatNormalScale.value.copy(v.clearcoatNormalScale),v.side===ws&&x.clearcoatNormalScale.value.negate())),v.dispersion>0&&(x.dispersion.value=v.dispersion),v.iridescence>0&&(x.iridescence.value=v.iridescence,x.iridescenceIOR.value=v.iridescenceIOR,x.iridescenceThicknessMinimum.value=v.iridescenceThicknessRange[0],x.iridescenceThicknessMaximum.value=v.iridescenceThicknessRange[1],v.iridescenceMap&&(x.iridescenceMap.value=v.iridescenceMap,n(v.iridescenceMap,x.iridescenceMapTransform)),v.iridescenceThicknessMap&&(x.iridescenceThicknessMap.value=v.iridescenceThicknessMap,n(v.iridescenceThicknessMap,x.iridescenceThicknessMapTransform))),v.transmission>0&&(x.transmission.value=v.transmission,x.transmissionSamplerMap.value=S.texture,x.transmissionSamplerSize.value.set(S.width,S.height),v.transmissionMap&&(x.transmissionMap.value=v.transmissionMap,n(v.transmissionMap,x.transmissionMapTransform)),x.thickness.value=v.thickness,v.thicknessMap&&(x.thicknessMap.value=v.thicknessMap,n(v.thicknessMap,x.thicknessMapTransform)),x.attenuationDistance.value=v.attenuationDistance,x.attenuationColor.value.copy(v.attenuationColor)),v.anisotropy>0&&(x.anisotropyVector.value.set(v.anisotropy*Math.cos(v.anisotropyRotation),v.anisotropy*Math.sin(v.anisotropyRotation)),v.anisotropyMap&&(x.anisotropyMap.value=v.anisotropyMap,n(v.anisotropyMap,x.anisotropyMapTransform))),x.specularIntensity.value=v.specularIntensity,x.specularColor.value.copy(v.specularColor),v.specularColorMap&&(x.specularColorMap.value=v.specularColorMap,n(v.specularColorMap,x.specularColorMapTransform)),v.specularIntensityMap&&(x.specularIntensityMap.value=v.specularIntensityMap,n(v.specularIntensityMap,x.specularIntensityMapTransform))}function b(x,v){v.matcap&&(x.matcap.value=v.matcap)}function y(x,v){const S=e.get(v).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 pIe(t,e,n,r){let i={},a={},o=[];const l=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function c(S,M){const E=M.program;r.uniformBlockBinding(S,E)}function u(S,M){let E=i[S.id];E===void 0&&(b(S),E=d(S),i[S.id]=E,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 E=t.createBuffer(),A=S.__size,k=S.usage;return t.bindBuffer(t.UNIFORM_BUFFER,E),t.bufferData(t.UNIFORM_BUFFER,A,k),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,M,E),E}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],E=S.uniforms,A=S.__cache;t.bindBuffer(t.UNIFORM_BUFFER,M);for(let k=0,T=E.length;k<T;k++){const D=Array.isArray(E[k])?E[k]:[E[k]];for(let C=0,R=D.length;C<R;C++){const U=D[C];if(p(U,k,C,A)===!0){const O=U.__offset,q=Array.isArray(U.value)?U.value:[U.value];let j=0;for(let W=0;W<q.length;W++){const X=q[W],G=y(X);typeof X=="number"||typeof X=="boolean"?(U.__data[0]=X,t.bufferSubData(t.UNIFORM_BUFFER,O+j,U.__data)):X.isMatrix3?(U.__data[0]=X.elements[0],U.__data[1]=X.elements[1],U.__data[2]=X.elements[2],U.__data[3]=0,U.__data[4]=X.elements[3],U.__data[5]=X.elements[4],U.__data[6]=X.elements[5],U.__data[7]=0,U.__data[8]=X.elements[6],U.__data[9]=X.elements[7],U.__data[10]=X.elements[8],U.__data[11]=0):(X.toArray(U.__data,j),j+=G.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,O,U.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function p(S,M,E,A){const k=S.value,T=M+"_"+E;if(A[T]===void 0)return typeof k=="number"||typeof k=="boolean"?A[T]=k:A[T]=k.clone(),!0;{const D=A[T];if(typeof k=="number"||typeof k=="boolean"){if(D!==k)return A[T]=k,!0}else if(D.equals(k)===!1)return D.copy(k),!0}return!1}function b(S){const M=S.uniforms;let E=0;const A=16;for(let T=0,D=M.length;T<D;T++){const C=Array.isArray(M[T])?M[T]:[M[T]];for(let R=0,U=C.length;R<U;R++){const O=C[R],q=Array.isArray(O.value)?O.value:[O.value];for(let j=0,W=q.length;j<W;j++){const X=q[j],G=y(X),Z=E%A,te=Z%G.boundary,ee=Z+te;E+=te,ee!==0&&A-ee<G.storage&&(E+=A-ee),O.__data=new Float32Array(G.storage/Float32Array.BYTES_PER_ELEMENT),O.__offset=E,E+=G.storage}}}const k=E%A;return k>0&&(E+=A-k),S.__size=E,S.__cache={},this}function y(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 E=o.indexOf(M.__bindingPointIndex);o.splice(E,1),t.deleteBuffer(i[M.id]),delete i[M.id],delete a[M.id]}function v(){for(const S in i)t.deleteBuffer(i[S]);o=[],i={},a={}}return{bind:c,update:u,dispose:v}}const gIe=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 xIe(){return Tl===null&&(Tl=new sRe(gIe,16,16,Cg,vu),Tl.name="DFG_LUT",Tl.minFilter=Ua,Tl.magFilter=Ua,Tl.wrapS=eu,Tl.wrapT=eu,Tl.generateMipmaps=!1,Tl.needsUpdate=!0),Tl}let bIe=class{constructor(e={}){const{canvas:n=P3e(),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 y=p,x=new Set([nL,tL,eL]),v=new Set([Hs,rc,q0,K0,Z4,J4]),S=new Uint32Array(4),M=new Int32Array(4);let E=null,A=null;const k=[],T=[];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 C=this;let R=!1;this._outputColorSpace=vo;let U=0,O=0,q=null,j=-1,W=null;const X=new Mi,G=new Mi;let Z=null;const te=new Rn(0);let ee=0,z=n.width,V=n.height,ne=1,ie=null,he=null;const me=new Mi(0,0,z,V),oe=new Mi(0,0,z,V);let Ae=!1;const ge=new cL;let Ne=!1,_e=!1;const le=new mi,He=new nt,H=new Mi,J={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let K=!1;function B(){return q===null?ne:1}let I=r;function ce(de,Pe){return n.getContext(de,Pe)}try{const de={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${X4}`),n.addEventListener("webglcontextlost",it,!1),n.addEventListener("webglcontextrestored",Ot,!1),n.addEventListener("webglcontextcreationerror",kt,!1),I===null){const Pe="webgl2";if(I=ce(Pe,de),I===null)throw ce(Pe)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(de){throw Kn("WebGLRenderer: "+de.message),de}let Ee,Ie,ue,$,L,Y,pe,Se,ae,je,De,Xe,et,Qe,se,ye,ke,Ue,dt,re,Fe,ve,$e,Le;function Te(){Ee=new x4e(I),Ee.init(),ve=new lIe(I,Ee),Ie=new l4e(I,Ee,e,ve),ue=new sIe(I,Ee),Ie.reversedDepthBuffer&&m&&ue.buffers.depth.setReversed(!0),$=new v4e(I),L=new GLe,Y=new oIe(I,Ee,ue,L,Ie,ve,$),pe=new u4e(C),Se=new g4e(C),ae=new MRe(I),$e=new s4e(I,ae),je=new b4e(I,ae,$,$e),De=new w4e(I,je,ae,$),dt=new _4e(I,Ie,Y),ye=new c4e(L),Xe=new VLe(C,pe,Se,Ee,Ie,$e,ye),et=new mIe(C,L),Qe=new qLe,se=new JLe(Ee),Ue=new a4e(C,pe,Se,ue,De,b,c),ke=new iIe(C,De,Ie),Le=new pIe(I,$,Ie,ue),re=new o4e(I,Ee,$),Fe=new y4e(I,Ee,$),$.programs=Xe.programs,C.capabilities=Ie,C.extensions=Ee,C.properties=L,C.renderLists=Qe,C.shadowMap=ke,C.state=ue,C.info=$}Te(),y!==Hs&&(D=new M4e(y,n.width,n.height,i,a));const We=new hIe(C,I);this.xr=We,this.getContext=function(){return I},this.getContextAttributes=function(){return I.getContextAttributes()},this.forceContextLoss=function(){const de=Ee.get("WEBGL_lose_context");de&&de.loseContext()},this.forceContextRestore=function(){const de=Ee.get("WEBGL_lose_context");de&&de.restoreContext()},this.getPixelRatio=function(){return ne},this.setPixelRatio=function(de){de!==void 0&&(ne=de,this.setSize(z,V,!1))},this.getSize=function(de){return de.set(z,V)},this.setSize=function(de,Pe,Ge=!0){if(We.isPresenting){un("WebGLRenderer: Can't change size while VR device is presenting.");return}z=de,V=Pe,n.width=Math.floor(de*ne),n.height=Math.floor(Pe*ne),Ge===!0&&(n.style.width=de+"px",n.style.height=Pe+"px"),D!==null&&D.setSize(n.width,n.height),this.setViewport(0,0,de,Pe)},this.getDrawingBufferSize=function(de){return de.set(z*ne,V*ne).floor()},this.setDrawingBufferSize=function(de,Pe,Ge){z=de,V=Pe,ne=Ge,n.width=Math.floor(de*Ge),n.height=Math.floor(Pe*Ge),this.setViewport(0,0,de,Pe)},this.setEffects=function(de){if(y===Hs){console.error("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(de){for(let Pe=0;Pe<de.length;Pe++)if(de[Pe].isOutputPass===!0){console.warn("THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}D.setEffects(de||[])},this.getCurrentViewport=function(de){return de.copy(X)},this.getViewport=function(de){return de.copy(me)},this.setViewport=function(de,Pe,Ge,qe){de.isVector4?me.set(de.x,de.y,de.z,de.w):me.set(de,Pe,Ge,qe),ue.viewport(X.copy(me).multiplyScalar(ne).round())},this.getScissor=function(de){return de.copy(oe)},this.setScissor=function(de,Pe,Ge,qe){de.isVector4?oe.set(de.x,de.y,de.z,de.w):oe.set(de,Pe,Ge,qe),ue.scissor(G.copy(oe).multiplyScalar(ne).round())},this.getScissorTest=function(){return Ae},this.setScissorTest=function(de){ue.setScissorTest(Ae=de)},this.setOpaqueSort=function(de){ie=de},this.setTransparentSort=function(de){he=de},this.getClearColor=function(de){return de.copy(Ue.getClearColor())},this.setClearColor=function(){Ue.setClearColor(...arguments)},this.getClearAlpha=function(){return Ue.getClearAlpha()},this.setClearAlpha=function(){Ue.setClearAlpha(...arguments)},this.clear=function(de=!0,Pe=!0,Ge=!0){let qe=0;if(de){let Ve=!1;if(q!==null){const wt=q.texture.format;Ve=x.has(wt)}if(Ve){const wt=q.texture.type,Dt=v.has(wt),Nt=Ue.getClearColor(),St=Ue.getClearAlpha(),Mt=Nt.r,Oe=Nt.g,gt=Nt.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 qe|=I.COLOR_BUFFER_BIT}Pe&&(qe|=I.DEPTH_BUFFER_BIT),Ge&&(qe|=I.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),I.clear(qe)},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(),Qe.dispose(),se.dispose(),L.dispose(),pe.dispose(),Se.dispose(),De.dispose(),$e.dispose(),Le.dispose(),Xe.dispose(),We.dispose(),We.removeEventListener("sessionstart",Tt),We.removeEventListener("sessionend",Cn),Cr.stop()};function it(de){de.preventDefault(),EV("WebGLRenderer: Context Lost."),R=!0}function Ot(){EV("WebGLRenderer: Context Restored."),R=!1;const de=$.autoReset,Pe=ke.enabled,Ge=ke.autoUpdate,qe=ke.needsUpdate,Ve=ke.type;Te(),$.autoReset=de,ke.enabled=Pe,ke.autoUpdate=Ge,ke.needsUpdate=qe,ke.type=Ve}function kt(de){Kn("WebGLRenderer: A WebGL context could not be created. Reason: ",de.statusMessage)}function on(de){const Pe=de.target;Pe.removeEventListener("dispose",on),Ut(Pe)}function Ut(de){yn(de),L.remove(de)}function yn(de){const Pe=L.get(de).programs;Pe!==void 0&&(Pe.forEach(function(Ge){Xe.releaseProgram(Ge)}),de.isShaderMaterial&&Xe.releaseShaderCache(de))}this.renderBufferDirect=function(de,Pe,Ge,qe,Ve,wt){Pe===null&&(Pe=J);const Dt=Ve.isMesh&&Ve.matrixWorld.determinant()<0,Nt=lt(de,Pe,Ge,qe,Ve);ue.setMaterial(qe,Dt);let St=Ge.index,Mt=1;if(qe.wireframe===!0){if(St=je.getWireframeAttribute(Ge),St===void 0)return;Mt=2}const Oe=Ge.drawRange,gt=Ge.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 Qt=ct-Rt;if(Qt<0||Qt===1/0)return;$e.setup(Ve,qe,Nt,Ge,St);let Kt,be=re;if(St!==null&&(Kt=ae.get(St),be=Fe,be.setIndex(Kt)),Ve.isMesh)qe.wireframe===!0?(ue.setLineWidth(qe.wireframeLinewidth*B()),be.setMode(I.LINES)):be.setMode(I.TRIANGLES);else if(Ve.isLine){let ut=qe.linewidth;ut===void 0&&(ut=1),ue.setLineWidth(ut*B()),Ve.isLineSegments?be.setMode(I.LINES):Ve.isLineLoop?be.setMode(I.LINE_LOOP):be.setMode(I.LINE_STRIP)}else Ve.isPoints?be.setMode(I.POINTS):Ve.isSprite&&be.setMode(I.TRIANGLES);if(Ve.isBatchedMesh)if(Ve._multiDrawInstances!==null)X0("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),be.renderMultiDrawInstances(Ve._multiDrawStarts,Ve._multiDrawCounts,Ve._multiDrawCount,Ve._multiDrawInstances);else if(Ee.get("WEBGL_multi_draw"))be.renderMultiDraw(Ve._multiDrawStarts,Ve._multiDrawCounts,Ve._multiDrawCount);else{const ut=Ve._multiDrawStarts,It=Ve._multiDrawCounts,yt=Ve._multiDrawCount,Xt=St?ae.get(St).bytesPerElement:1,tr=L.get(qe).currentProgram.getUniforms();for(let cn=0;cn<yt;cn++)tr.setValue(I,"_gl_DrawID",cn),be.render(ut[cn]/Xt,It[cn])}else if(Ve.isInstancedMesh)be.renderInstances(Rt,Qt,Ve.count);else if(Ge.isInstancedBufferGeometry){const ut=Ge._maxInstanceCount!==void 0?Ge._maxInstanceCount:1/0,It=Math.min(Ge.instanceCount,ut);be.renderInstances(Rt,Qt,It)}else be.render(Rt,Qt)};function xt(de,Pe,Ge){de.transparent===!0&&de.side===Il&&de.forceSinglePass===!1?(de.side=ws,de.needsUpdate=!0,we(de,Pe,Ge),de.side=eh,de.needsUpdate=!0,we(de,Pe,Ge),de.side=Il):we(de,Pe,Ge)}this.compile=function(de,Pe,Ge=null){Ge===null&&(Ge=de),A=se.get(Ge),A.init(Pe),T.push(A),Ge.traverseVisible(function(Ve){Ve.isLight&&Ve.layers.test(Pe.layers)&&(A.pushLight(Ve),Ve.castShadow&&A.pushShadow(Ve))}),de!==Ge&&de.traverseVisible(function(Ve){Ve.isLight&&Ve.layers.test(Pe.layers)&&(A.pushLight(Ve),Ve.castShadow&&A.pushShadow(Ve))}),A.setupLights();const qe=new Set;return de.traverse(function(Ve){if(!(Ve.isMesh||Ve.isPoints||Ve.isLine||Ve.isSprite))return;const wt=Ve.material;if(wt)if(Array.isArray(wt))for(let Dt=0;Dt<wt.length;Dt++){const Nt=wt[Dt];xt(Nt,Ge,Ve),qe.add(Nt)}else xt(wt,Ge,Ve),qe.add(wt)}),A=T.pop(),qe},this.compileAsync=function(de,Pe,Ge=null){const qe=this.compile(de,Pe,Ge);return new Promise(Ve=>{function wt(){if(qe.forEach(function(Dt){L.get(Dt).currentProgram.isReady()&&qe.delete(Dt)}),qe.size===0){Ve(de);return}setTimeout(wt,10)}Ee.get("KHR_parallel_shader_compile")!==null?wt():setTimeout(wt,10)})};let Yt=null;function sn(de){Yt&&Yt(de)}function Tt(){Cr.stop()}function Cn(){Cr.start()}const Cr=new kee;Cr.setAnimationLoop(sn),typeof self<"u"&&Cr.setContext(self),this.setAnimationLoop=function(de){Yt=de,We.setAnimationLoop(de),de===null?Cr.stop():Cr.start()},We.addEventListener("sessionstart",Tt),We.addEventListener("sessionend",Cn),this.render=function(de,Pe){if(Pe!==void 0&&Pe.isCamera!==!0){Kn("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(R===!0)return;const Ge=We.enabled===!0&&We.isPresenting===!0,qe=D!==null&&(q===null||Ge)&&D.begin(C,q);if(de.matrixWorldAutoUpdate===!0&&de.updateMatrixWorld(),Pe.parent===null&&Pe.matrixWorldAutoUpdate===!0&&Pe.updateMatrixWorld(),We.enabled===!0&&We.isPresenting===!0&&(D===null||D.isCompositing()===!1)&&(We.cameraAutoUpdate===!0&&We.updateCamera(Pe),Pe=We.getCamera()),de.isScene===!0&&de.onBeforeRender(C,de,Pe,q),A=se.get(de,T.length),A.init(Pe),T.push(A),le.multiplyMatrices(Pe.projectionMatrix,Pe.matrixWorldInverse),ge.setFromProjectionMatrix(le,Hl,Pe.reversedDepth),_e=this.localClippingEnabled,Ne=ye.init(this.clippingPlanes,_e),E=Qe.get(de,k.length),E.init(),k.push(E),We.enabled===!0&&We.isPresenting===!0){const Dt=C.xr.getDepthSensingMesh();Dt!==null&&er(Dt,Pe,-1/0,C.sortObjects)}er(de,Pe,0,C.sortObjects),E.finish(),C.sortObjects===!0&&E.sort(ie,he),K=We.enabled===!1||We.isPresenting===!1||We.hasDepthSensing()===!1,K&&Ue.addToRenderList(E,de),this.info.render.frame++,Ne===!0&&ye.beginShadows();const Ve=A.state.shadowsArray;if(ke.render(Ve,de,Pe),Ne===!0&&ye.endShadows(),this.info.autoReset===!0&&this.info.reset(),(qe&&D.hasRenderPass())===!1){const Dt=E.opaque,Nt=E.transmissive;if(A.setupLights(),Pe.isArrayCamera){const St=Pe.cameras;if(Nt.length>0)for(let Mt=0,Oe=St.length;Mt<Oe;Mt++){const gt=St[Mt];yr(Dt,Nt,de,gt)}K&&Ue.render(de);for(let Mt=0,Oe=St.length;Mt<Oe;Mt++){const gt=St[Mt];Un(E,de,gt,gt.viewport)}}else Nt.length>0&&yr(Dt,Nt,de,Pe),K&&Ue.render(de),Un(E,de,Pe)}q!==null&&O===0&&(Y.updateMultisampleRenderTarget(q),Y.updateRenderTargetMipmap(q)),qe&&D.end(C),de.isScene===!0&&de.onAfterRender(C,de,Pe),$e.resetDefaultState(),j=-1,W=null,T.pop(),T.length>0?(A=T[T.length-1],Ne===!0&&ye.setGlobalState(C.clippingPlanes,A.state.camera)):A=null,k.pop(),k.length>0?E=k[k.length-1]:E=null};function er(de,Pe,Ge,qe){if(de.visible===!1)return;if(de.layers.test(Pe.layers)){if(de.isGroup)Ge=de.renderOrder;else if(de.isLOD)de.autoUpdate===!0&&de.update(Pe);else if(de.isLight)A.pushLight(de),de.castShadow&&A.pushShadow(de);else if(de.isSprite){if(!de.frustumCulled||ge.intersectsSprite(de)){qe&&H.setFromMatrixPosition(de.matrixWorld).applyMatrix4(le);const Dt=De.update(de),Nt=de.material;Nt.visible&&E.push(de,Dt,Nt,Ge,H.z,null)}}else if((de.isMesh||de.isLine||de.isPoints)&&(!de.frustumCulled||ge.intersectsObject(de))){const Dt=De.update(de),Nt=de.material;if(qe&&(de.boundingSphere!==void 0?(de.boundingSphere===null&&de.computeBoundingSphere(),H.copy(de.boundingSphere.center)):(Dt.boundingSphere===null&&Dt.computeBoundingSphere(),H.copy(Dt.boundingSphere.center)),H.applyMatrix4(de.matrixWorld).applyMatrix4(le)),Array.isArray(Nt)){const St=Dt.groups;for(let Mt=0,Oe=St.length;Mt<Oe;Mt++){const gt=St[Mt],Rt=Nt[gt.materialIndex];Rt&&Rt.visible&&E.push(de,Dt,Rt,Ge,H.z,gt)}}else Nt.visible&&E.push(de,Dt,Nt,Ge,H.z,null)}}const wt=de.children;for(let Dt=0,Nt=wt.length;Dt<Nt;Dt++)er(wt[Dt],Pe,Ge,qe)}function Un(de,Pe,Ge,qe){const{opaque:Ve,transmissive:wt,transparent:Dt}=de;A.setupLightsView(Ge),Ne===!0&&ye.setGlobalState(C.clippingPlanes,Ge),qe&&ue.viewport(X.copy(qe)),Ve.length>0&&Ci(Ve,Pe,Ge),wt.length>0&&Ci(wt,Pe,Ge),Dt.length>0&&Ci(Dt,Pe,Ge),ue.buffers.depth.setTest(!0),ue.buffers.depth.setMask(!0),ue.buffers.color.setMask(!0),ue.setPolygonOffset(!1)}function yr(de,Pe,Ge,qe){if((Ge.isScene===!0?Ge.overrideMaterial:null)!==null)return;if(A.state.transmissionRenderTarget[qe.id]===void 0){const Rt=Ee.has("EXT_color_buffer_half_float")||Ee.has("EXT_color_buffer_float");A.state.transmissionRenderTarget[qe.id]=new Kl(1,1,{generateMipmaps:!0,type:Rt?vu:Hs,minFilter:pf,samples:Ie.samples,stencilBuffer:a,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Vn.workingColorSpace})}const wt=A.state.transmissionRenderTarget[qe.id],Dt=qe.viewport||X;wt.setSize(Dt.z*C.transmissionResolutionScale,Dt.w*C.transmissionResolutionScale);const Nt=C.getRenderTarget(),St=C.getActiveCubeFace(),Mt=C.getActiveMipmapLevel();C.setRenderTarget(wt),C.getClearColor(te),ee=C.getClearAlpha(),ee<1&&C.setClearColor(16777215,.5),C.clear(),K&&Ue.render(Ge);const Oe=C.toneMapping;C.toneMapping=ql;const gt=qe.viewport;if(qe.viewport!==void 0&&(qe.viewport=void 0),A.setupLightsView(qe),Ne===!0&&ye.setGlobalState(C.clippingPlanes,qe),Ci(de,Ge,qe),Y.updateMultisampleRenderTarget(wt),Y.updateRenderTargetMipmap(wt),Ee.has("WEBGL_multisampled_render_to_texture")===!1){let Rt=!1;for(let ct=0,Qt=Pe.length;ct<Qt;ct++){const Kt=Pe[ct],{object:be,geometry:ut,material:It,group:yt}=Kt;if(It.side===Il&&be.layers.test(qe.layers)){const Xt=It.side;It.side=ws,It.needsUpdate=!0,gi(be,Ge,qe,ut,It,yt),It.side=Xt,It.needsUpdate=!0,Rt=!0}}Rt===!0&&(Y.updateMultisampleRenderTarget(wt),Y.updateRenderTargetMipmap(wt))}C.setRenderTarget(Nt,St,Mt),C.setClearColor(te,ee),gt!==void 0&&(qe.viewport=gt),C.toneMapping=Oe}function Ci(de,Pe,Ge){const qe=Pe.isScene===!0?Pe.overrideMaterial:null;for(let Ve=0,wt=de.length;Ve<wt;Ve++){const Dt=de[Ve],{object:Nt,geometry:St,group:Mt}=Dt;let Oe=Dt.material;Oe.allowOverride===!0&&qe!==null&&(Oe=qe),Nt.layers.test(Ge.layers)&&gi(Nt,Pe,Ge,St,Oe,Mt)}}function gi(de,Pe,Ge,qe,Ve,wt){de.onBeforeRender(C,Pe,Ge,qe,Ve,wt),de.modelViewMatrix.multiplyMatrices(Ge.matrixWorldInverse,de.matrixWorld),de.normalMatrix.getNormalMatrix(de.modelViewMatrix),Ve.onBeforeRender(C,Pe,Ge,qe,de,wt),Ve.transparent===!0&&Ve.side===Il&&Ve.forceSinglePass===!1?(Ve.side=ws,Ve.needsUpdate=!0,C.renderBufferDirect(Ge,Pe,qe,Ve,de,wt),Ve.side=eh,Ve.needsUpdate=!0,C.renderBufferDirect(Ge,Pe,qe,Ve,de,wt),Ve.side=Il):C.renderBufferDirect(Ge,Pe,qe,Ve,de,wt),de.onAfterRender(C,Pe,Ge,qe,Ve,wt)}function we(de,Pe,Ge){Pe.isScene!==!0&&(Pe=J);const qe=L.get(de),Ve=A.state.lights,wt=A.state.shadowsArray,Dt=Ve.state.version,Nt=Xe.getParameters(de,Ve.state,wt,Pe,Ge),St=Xe.getProgramCacheKey(Nt);let Mt=qe.programs;qe.environment=de.isMeshStandardMaterial?Pe.environment:null,qe.fog=Pe.fog,qe.envMap=(de.isMeshStandardMaterial?Se:pe).get(de.envMap||qe.environment),qe.envMapRotation=qe.environment!==null&&de.envMap===null?Pe.environmentRotation:de.envMapRotation,Mt===void 0&&(de.addEventListener("dispose",on),Mt=new Map,qe.programs=Mt);let Oe=Mt.get(St);if(Oe!==void 0){if(qe.currentProgram===Oe&&qe.lightsStateVersion===Dt)return Ze(de,Nt),Oe}else Nt.uniforms=Xe.getUniforms(de),de.onBeforeCompile(Nt,C),Oe=Xe.acquireProgram(Nt,St),Mt.set(St,Oe),qe.uniforms=Nt.uniforms;const gt=qe.uniforms;return(!de.isShaderMaterial&&!de.isRawShaderMaterial||de.clipping===!0)&&(gt.clippingPlanes=ye.uniform),Ze(de,Nt),qe.needsLights=Pt(de),qe.lightsStateVersion=Dt,qe.needsLights&&(gt.ambientLightColor.value=Ve.state.ambient,gt.lightProbe.value=Ve.state.probe,gt.directionalLights.value=Ve.state.directional,gt.directionalLightShadows.value=Ve.state.directionalShadow,gt.spotLights.value=Ve.state.spot,gt.spotLightShadows.value=Ve.state.spotShadow,gt.rectAreaLights.value=Ve.state.rectArea,gt.ltc_1.value=Ve.state.rectAreaLTC1,gt.ltc_2.value=Ve.state.rectAreaLTC2,gt.pointLights.value=Ve.state.point,gt.pointLightShadows.value=Ve.state.pointShadow,gt.hemisphereLights.value=Ve.state.hemi,gt.directionalShadowMap.value=Ve.state.directionalShadowMap,gt.directionalShadowMatrix.value=Ve.state.directionalShadowMatrix,gt.spotShadowMap.value=Ve.state.spotShadowMap,gt.spotLightMatrix.value=Ve.state.spotLightMatrix,gt.spotLightMap.value=Ve.state.spotLightMap,gt.pointShadowMap.value=Ve.state.pointShadowMap,gt.pointShadowMatrix.value=Ve.state.pointShadowMatrix),qe.currentProgram=Oe,qe.uniformsList=null,Oe}function Je(de){if(de.uniformsList===null){const Pe=de.currentProgram.getUniforms();de.uniformsList=gw.seqWithValue(Pe.seq,de.uniforms)}return de.uniformsList}function Ze(de,Pe){const Ge=L.get(de);Ge.outputColorSpace=Pe.outputColorSpace,Ge.batching=Pe.batching,Ge.batchingColor=Pe.batchingColor,Ge.instancing=Pe.instancing,Ge.instancingColor=Pe.instancingColor,Ge.instancingMorph=Pe.instancingMorph,Ge.skinning=Pe.skinning,Ge.morphTargets=Pe.morphTargets,Ge.morphNormals=Pe.morphNormals,Ge.morphColors=Pe.morphColors,Ge.morphTargetsCount=Pe.morphTargetsCount,Ge.numClippingPlanes=Pe.numClippingPlanes,Ge.numIntersection=Pe.numClipIntersection,Ge.vertexAlphas=Pe.vertexAlphas,Ge.vertexTangents=Pe.vertexTangents,Ge.toneMapping=Pe.toneMapping}function lt(de,Pe,Ge,qe,Ve){Pe.isScene!==!0&&(Pe=J),Y.resetTextureUnits();const wt=Pe.fog,Dt=qe.isMeshStandardMaterial?Pe.environment:null,Nt=q===null?C.outputColorSpace:q.isXRRenderTarget===!0?q.texture.colorSpace:kg,St=(qe.isMeshStandardMaterial?Se:pe).get(qe.envMap||Dt),Mt=qe.vertexColors===!0&&!!Ge.attributes.color&&Ge.attributes.color.itemSize===4,Oe=!!Ge.attributes.tangent&&(!!qe.normalMap||qe.anisotropy>0),gt=!!Ge.morphAttributes.position,Rt=!!Ge.morphAttributes.normal,ct=!!Ge.morphAttributes.color;let Qt=ql;qe.toneMapped&&(q===null||q.isXRRenderTarget===!0)&&(Qt=C.toneMapping);const Kt=Ge.morphAttributes.position||Ge.morphAttributes.normal||Ge.morphAttributes.color,be=Kt!==void 0?Kt.length:0,ut=L.get(qe),It=A.state.lights;if(Ne===!0&&(_e===!0||de!==W)){const Qn=de===W&&qe.id===j;ye.setState(qe,de,Qn)}let yt=!1;qe.version===ut.__version?(ut.needsLights&&ut.lightsStateVersion!==It.state.version||ut.outputColorSpace!==Nt||Ve.isBatchedMesh&&ut.batching===!1||!Ve.isBatchedMesh&&ut.batching===!0||Ve.isBatchedMesh&&ut.batchingColor===!0&&Ve.colorTexture===null||Ve.isBatchedMesh&&ut.batchingColor===!1&&Ve.colorTexture!==null||Ve.isInstancedMesh&&ut.instancing===!1||!Ve.isInstancedMesh&&ut.instancing===!0||Ve.isSkinnedMesh&&ut.skinning===!1||!Ve.isSkinnedMesh&&ut.skinning===!0||Ve.isInstancedMesh&&ut.instancingColor===!0&&Ve.instanceColor===null||Ve.isInstancedMesh&&ut.instancingColor===!1&&Ve.instanceColor!==null||Ve.isInstancedMesh&&ut.instancingMorph===!0&&Ve.morphTexture===null||Ve.isInstancedMesh&&ut.instancingMorph===!1&&Ve.morphTexture!==null||ut.envMap!==St||qe.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!==Qt||ut.morphTargetsCount!==be)&&(yt=!0):(yt=!0,ut.__version=qe.version);let Xt=ut.currentProgram;yt===!0&&(Xt=we(qe,Pe,Ve));let tr=!1,cn=!1,ki=!1;const $n=Xt.getUniforms(),ui=ut.uniforms;if(ue.useProgram(Xt.program)&&(tr=!0,cn=!0,ki=!0),qe.id!==j&&(j=qe.id,cn=!0),tr||W!==de){ue.buffers.depth.getReversed()&&de.reversedDepth!==!0&&(de._reversedDepth=!0,de.updateProjectionMatrix()),$n.setValue(I,"projectionMatrix",de.projectionMatrix),$n.setValue(I,"viewMatrix",de.matrixWorldInverse);const kr=$n.map.cameraPosition;kr!==void 0&&kr.setValue(I,He.setFromMatrixPosition(de.matrixWorld)),Ie.logarithmicDepthBuffer&&$n.setValue(I,"logDepthBufFC",2/(Math.log(de.far+1)/Math.LN2)),(qe.isMeshPhongMaterial||qe.isMeshToonMaterial||qe.isMeshLambertMaterial||qe.isMeshBasicMaterial||qe.isMeshStandardMaterial||qe.isShaderMaterial)&&$n.setValue(I,"isOrthographic",de.isOrthographicCamera===!0),W!==de&&(W=de,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)),Ve.isSkinnedMesh){$n.setOptional(I,Ve,"bindMatrix"),$n.setOptional(I,Ve,"bindMatrixInverse");const Qn=Ve.skeleton;Qn&&(Qn.boneTexture===null&&Qn.computeBoneTexture(),$n.setValue(I,"boneTexture",Qn.boneTexture,Y))}Ve.isBatchedMesh&&($n.setOptional(I,Ve,"batchingTexture"),$n.setValue(I,"batchingTexture",Ve._matricesTexture,Y),$n.setOptional(I,Ve,"batchingIdTexture"),$n.setValue(I,"batchingIdTexture",Ve._indirectTexture,Y),$n.setOptional(I,Ve,"batchingColorTexture"),Ve._colorsTexture!==null&&$n.setValue(I,"batchingColorTexture",Ve._colorsTexture,Y));const vr=Ge.morphAttributes;if((vr.position!==void 0||vr.normal!==void 0||vr.color!==void 0)&&dt.update(Ve,Ge,Xt),(cn||ut.receiveShadow!==Ve.receiveShadow)&&(ut.receiveShadow=Ve.receiveShadow,$n.setValue(I,"receiveShadow",Ve.receiveShadow)),qe.isMeshGouraudMaterial&&qe.envMap!==null&&(ui.envMap.value=St,ui.flipEnvMap.value=St.isCubeTexture&&St.isRenderTargetTexture===!1?-1:1),qe.isMeshStandardMaterial&&qe.envMap===null&&Pe.environment!==null&&(ui.envMapIntensity.value=Pe.environmentIntensity),ui.dfgLUT!==void 0&&(ui.dfgLUT.value=xIe()),cn&&($n.setValue(I,"toneMappingExposure",C.toneMappingExposure),ut.needsLights&&st(ui,ki),wt&&qe.fog===!0&&et.refreshFogUniforms(ui,wt),et.refreshMaterialUniforms(ui,qe,ne,V,A.state.transmissionRenderTarget[de.id]),gw.upload(I,Je(ut),ui,Y)),qe.isShaderMaterial&&qe.uniformsNeedUpdate===!0&&(gw.upload(I,Je(ut),ui,Y),qe.uniformsNeedUpdate=!1),qe.isSpriteMaterial&&$n.setValue(I,"center",Ve.center),$n.setValue(I,"modelViewMatrix",Ve.modelViewMatrix),$n.setValue(I,"normalMatrix",Ve.normalMatrix),$n.setValue(I,"modelMatrix",Ve.matrixWorld),qe.isShaderMaterial||qe.isRawShaderMaterial){const Qn=qe.uniformsGroups;for(let kr=0,to=Qn.length;kr<to;kr++){const jr=Qn[kr];Le.update(jr,Xt),Le.bind(jr,Xt)}}return Xt}function st(de,Pe){de.ambientLightColor.needsUpdate=Pe,de.lightProbe.needsUpdate=Pe,de.directionalLights.needsUpdate=Pe,de.directionalLightShadows.needsUpdate=Pe,de.pointLights.needsUpdate=Pe,de.pointLightShadows.needsUpdate=Pe,de.spotLights.needsUpdate=Pe,de.spotLightShadows.needsUpdate=Pe,de.rectAreaLights.needsUpdate=Pe,de.hemisphereLights.needsUpdate=Pe}function Pt(de){return de.isMeshLambertMaterial||de.isMeshToonMaterial||de.isMeshPhongMaterial||de.isMeshStandardMaterial||de.isShadowMaterial||de.isShaderMaterial&&de.lights===!0}this.getActiveCubeFace=function(){return U},this.getActiveMipmapLevel=function(){return O},this.getRenderTarget=function(){return q},this.setRenderTargetTextures=function(de,Pe,Ge){const qe=L.get(de);qe.__autoAllocateDepthBuffer=de.resolveDepthBuffer===!1,qe.__autoAllocateDepthBuffer===!1&&(qe.__useRenderToTexture=!1),L.get(de.texture).__webglTexture=Pe,L.get(de.depthTexture).__webglTexture=qe.__autoAllocateDepthBuffer?void 0:Ge,qe.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(de,Pe){const Ge=L.get(de);Ge.__webglFramebuffer=Pe,Ge.__useDefaultFramebuffer=Pe===void 0};const Bt=I.createFramebuffer();this.setRenderTarget=function(de,Pe=0,Ge=0){q=de,U=Pe,O=Ge;let qe=null,Ve=!1,wt=!1;if(de){const Nt=L.get(de);if(Nt.__useDefaultFramebuffer!==void 0){ue.bindFramebuffer(I.FRAMEBUFFER,Nt.__webglFramebuffer),X.copy(de.viewport),G.copy(de.scissor),Z=de.scissorTest,ue.viewport(X),ue.scissor(G),ue.setScissorTest(Z),j=-1;return}else if(Nt.__webglFramebuffer===void 0)Y.setupRenderTarget(de);else if(Nt.__hasExternalTextures)Y.rebindTextures(de,L.get(de.texture).__webglTexture,L.get(de.depthTexture).__webglTexture);else if(de.depthBuffer){const Oe=de.depthTexture;if(Nt.__boundDepthTexture!==Oe){if(Oe!==null&&L.has(Oe)&&(de.width!==Oe.image.width||de.height!==Oe.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");Y.setupDepthRenderbuffer(de)}}const St=de.texture;(St.isData3DTexture||St.isDataArrayTexture||St.isCompressedArrayTexture)&&(wt=!0);const Mt=L.get(de).__webglFramebuffer;de.isWebGLCubeRenderTarget?(Array.isArray(Mt[Pe])?qe=Mt[Pe][Ge]:qe=Mt[Pe],Ve=!0):de.samples>0&&Y.useMultisampledRTT(de)===!1?qe=L.get(de).__webglMultisampledFramebuffer:Array.isArray(Mt)?qe=Mt[Ge]:qe=Mt,X.copy(de.viewport),G.copy(de.scissor),Z=de.scissorTest}else X.copy(me).multiplyScalar(ne).floor(),G.copy(oe).multiplyScalar(ne).floor(),Z=Ae;if(Ge!==0&&(qe=Bt),ue.bindFramebuffer(I.FRAMEBUFFER,qe)&&ue.drawBuffers(de,qe),ue.viewport(X),ue.scissor(G),ue.setScissorTest(Z),Ve){const Nt=L.get(de.texture);I.framebufferTexture2D(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_CUBE_MAP_POSITIVE_X+Pe,Nt.__webglTexture,Ge)}else if(wt){const Nt=Pe;for(let St=0;St<de.textures.length;St++){const Mt=L.get(de.textures[St]);I.framebufferTextureLayer(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0+St,Mt.__webglTexture,Ge,Nt)}}else if(de!==null&&Ge!==0){const Nt=L.get(de.texture);I.framebufferTexture2D(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,Nt.__webglTexture,Ge)}j=-1},this.readRenderTargetPixels=function(de,Pe,Ge,qe,Ve,wt,Dt,Nt=0){if(!(de&&de.isWebGLRenderTarget)){Kn("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let St=L.get(de).__webglFramebuffer;if(de.isWebGLCubeRenderTarget&&Dt!==void 0&&(St=St[Dt]),St){ue.bindFramebuffer(I.FRAMEBUFFER,St);try{const Mt=de.textures[Nt],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}Pe>=0&&Pe<=de.width-qe&&Ge>=0&&Ge<=de.height-Ve&&(de.textures.length>1&&I.readBuffer(I.COLOR_ATTACHMENT0+Nt),I.readPixels(Pe,Ge,qe,Ve,ve.convert(Oe),ve.convert(gt),wt))}finally{const Mt=q!==null?L.get(q).__webglFramebuffer:null;ue.bindFramebuffer(I.FRAMEBUFFER,Mt)}}},this.readRenderTargetPixelsAsync=async function(de,Pe,Ge,qe,Ve,wt,Dt,Nt=0){if(!(de&&de.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let St=L.get(de).__webglFramebuffer;if(de.isWebGLCubeRenderTarget&&Dt!==void 0&&(St=St[Dt]),St)if(Pe>=0&&Pe<=de.width-qe&&Ge>=0&&Ge<=de.height-Ve){ue.bindFramebuffer(I.FRAMEBUFFER,St);const Mt=de.textures[Nt],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),de.textures.length>1&&I.readBuffer(I.COLOR_ATTACHMENT0+Nt),I.readPixels(Pe,Ge,qe,Ve,ve.convert(Oe),ve.convert(gt),0);const ct=q!==null?L.get(q).__webglFramebuffer:null;ue.bindFramebuffer(I.FRAMEBUFFER,ct);const Qt=I.fenceSync(I.SYNC_GPU_COMMANDS_COMPLETE,0);return I.flush(),await R3e(I,Qt,4),I.bindBuffer(I.PIXEL_PACK_BUFFER,Rt),I.getBufferSubData(I.PIXEL_PACK_BUFFER,0,wt),I.deleteBuffer(Rt),I.deleteSync(Qt),wt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(de,Pe=null,Ge=0){const qe=Math.pow(2,-Ge),Ve=Math.floor(de.image.width*qe),wt=Math.floor(de.image.height*qe),Dt=Pe!==null?Pe.x:0,Nt=Pe!==null?Pe.y:0;Y.setTexture2D(de,0),I.copyTexSubImage2D(I.TEXTURE_2D,Ge,0,0,Dt,Nt,Ve,wt),ue.unbindTexture()};const Vt=I.createFramebuffer(),Jt=I.createFramebuffer();this.copyTextureToTexture=function(de,Pe,Ge=null,qe=null,Ve=0,wt=null){wt===null&&(Ve!==0?(X0("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),wt=Ve,Ve=0):wt=0);let Dt,Nt,St,Mt,Oe,gt,Rt,ct,Qt;const Kt=de.isCompressedTexture?de.mipmaps[wt]:de.image;if(Ge!==null)Dt=Ge.max.x-Ge.min.x,Nt=Ge.max.y-Ge.min.y,St=Ge.isBox3?Ge.max.z-Ge.min.z:1,Mt=Ge.min.x,Oe=Ge.min.y,gt=Ge.isBox3?Ge.min.z:0;else{const vr=Math.pow(2,-Ve);Dt=Math.floor(Kt.width*vr),Nt=Math.floor(Kt.height*vr),de.isDataArrayTexture?St=Kt.depth:de.isData3DTexture?St=Math.floor(Kt.depth*vr):St=1,Mt=0,Oe=0,gt=0}qe!==null?(Rt=qe.x,ct=qe.y,Qt=qe.z):(Rt=0,ct=0,Qt=0);const be=ve.convert(Pe.format),ut=ve.convert(Pe.type);let It;Pe.isData3DTexture?(Y.setTexture3D(Pe,0),It=I.TEXTURE_3D):Pe.isDataArrayTexture||Pe.isCompressedArrayTexture?(Y.setTexture2DArray(Pe,0),It=I.TEXTURE_2D_ARRAY):(Y.setTexture2D(Pe,0),It=I.TEXTURE_2D),I.pixelStorei(I.UNPACK_FLIP_Y_WEBGL,Pe.flipY),I.pixelStorei(I.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Pe.premultiplyAlpha),I.pixelStorei(I.UNPACK_ALIGNMENT,Pe.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=de.isDataArrayTexture||de.isData3DTexture,ui=Pe.isDataArrayTexture||Pe.isData3DTexture;if(de.isDepthTexture){const vr=L.get(de),Qn=L.get(Pe),kr=L.get(vr.__renderTarget),to=L.get(Qn.__renderTarget);ue.bindFramebuffer(I.READ_FRAMEBUFFER,kr.__webglFramebuffer),ue.bindFramebuffer(I.DRAW_FRAMEBUFFER,to.__webglFramebuffer);for(let jr=0;jr<St;jr++)$n&&(I.framebufferTextureLayer(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,L.get(de).__webglTexture,Ve,gt+jr),I.framebufferTextureLayer(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,L.get(Pe).__webglTexture,wt,Qt+jr)),I.blitFramebuffer(Mt,Oe,Dt,Nt,Rt,ct,Dt,Nt,I.DEPTH_BUFFER_BIT,I.NEAREST);ue.bindFramebuffer(I.READ_FRAMEBUFFER,null),ue.bindFramebuffer(I.DRAW_FRAMEBUFFER,null)}else if(Ve!==0||de.isRenderTargetTexture||L.has(de)){const vr=L.get(de),Qn=L.get(Pe);ue.bindFramebuffer(I.READ_FRAMEBUFFER,Vt),ue.bindFramebuffer(I.DRAW_FRAMEBUFFER,Jt);for(let kr=0;kr<St;kr++)$n?I.framebufferTextureLayer(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,vr.__webglTexture,Ve,gt+kr):I.framebufferTexture2D(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,vr.__webglTexture,Ve),ui?I.framebufferTextureLayer(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,Qn.__webglTexture,wt,Qt+kr):I.framebufferTexture2D(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,Qn.__webglTexture,wt),Ve!==0?I.blitFramebuffer(Mt,Oe,Dt,Nt,Rt,ct,Dt,Nt,I.COLOR_BUFFER_BIT,I.NEAREST):ui?I.copyTexSubImage3D(It,wt,Rt,ct,Qt+kr,Mt,Oe,Dt,Nt):I.copyTexSubImage2D(It,wt,Rt,ct,Mt,Oe,Dt,Nt);ue.bindFramebuffer(I.READ_FRAMEBUFFER,null),ue.bindFramebuffer(I.DRAW_FRAMEBUFFER,null)}else ui?de.isDataTexture||de.isData3DTexture?I.texSubImage3D(It,wt,Rt,ct,Qt,Dt,Nt,St,be,ut,Kt.data):Pe.isCompressedArrayTexture?I.compressedTexSubImage3D(It,wt,Rt,ct,Qt,Dt,Nt,St,be,Kt.data):I.texSubImage3D(It,wt,Rt,ct,Qt,Dt,Nt,St,be,ut,Kt):de.isDataTexture?I.texSubImage2D(I.TEXTURE_2D,wt,Rt,ct,Dt,Nt,be,ut,Kt.data):de.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,Nt,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&&Pe.generateMipmaps&&I.generateMipmap(It),ue.unbindTexture()},this.initRenderTarget=function(de){L.get(de).__webglFramebuffer===void 0&&Y.setupRenderTarget(de)},this.initTexture=function(de){de.isCubeTexture?Y.setTextureCube(de,0):de.isData3DTexture?Y.setTexture3D(de,0):de.isDataArrayTexture||de.isCompressedArrayTexture?Y.setTexture2DArray(de,0):Y.setTexture2D(de,0),ue.unbindTexture()},this.resetState=function(){U=0,O=0,q=null,ue.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 _G={type:"change"},hL={type:"start"},Oee={type:"end"},e1=new sL,wG=new bd,yIe=Math.cos(70*O3e.DEG2RAD),Pi=new nt,ps=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 vIe extends wRe{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:ig.ROTATE,MIDDLE:ig.DOLLY,RIGHT:ig.PAN},this.touches={ONE:Xp.ROTATE,TWO:Xp.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 Jf,this._lastTargetPosition=new nt,this._quat=new Jf().setFromUnitVectors(e.up,new nt(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new YV,this._sphericalDelta=new YV,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=wIe.bind(this),this._onPointerDown=_Ie.bind(this),this._onPointerUp=SIe.bind(this),this._onContextMenu=kIe.bind(this),this._onMouseWheel=EIe.bind(this),this._onKeyDown=AIe.bind(this),this._onTouchStart=TIe.bind(this),this._onTouchMove=CIe.bind(this),this._onMouseDown=MIe.bind(this),this._onMouseMove=NIe.bind(this),this._interceptControlDown=jIe.bind(this),this._interceptControlUp=PIe.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(_G),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+=ps:r>Math.PI&&(r-=ps),i<-Math.PI?i+=ps:i>Math.PI&&(i-=ps),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):(e1.origin.copy(this.object.position),e1.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(e1.direction))<yIe?this.object.lookAt(this.target):(wG.setFromNormalAndCoplanarPoint(this.object.up,this.target),e1.intersectPlane(wG,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(_G),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?ps/60*this.autoRotateSpeed*e:ps/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(ps*this._rotateDelta.x/n.clientHeight),this._rotateUp(ps*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(ps*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(-ps*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(ps*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(-ps*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(ps*this._rotateDelta.x/n.clientHeight),this._rotateUp(ps*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 _Ie(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 wIe(t){this.enabled!==!1&&(t.pointerType==="touch"?this._onTouchMove(t):this._onMouseMove(t))}function SIe(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(Oee),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 MIe(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 ig.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(t),this.state=gr.DOLLY;break;case ig.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 ig.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(hL)}function NIe(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(hL),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(Oee))}function AIe(t){this.enabled!==!1&&this._handleKeyDown(t)}function TIe(t){switch(this._trackPointer(t),this._pointers.length){case 1:switch(this.touches.ONE){case Xp.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(t),this.state=gr.TOUCH_ROTATE;break;case Xp.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 Xp.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(t),this.state=gr.TOUCH_DOLLY_PAN;break;case Xp.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(hL)}function CIe(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 kIe(t){this.enabled!==!1&&t.preventDefault()}function jIe(t){t.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function PIe(t){t.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function RIe(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=SG(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 y=0;y<o[d].length;++y)p.push(o[d][y][m]);const b=SG(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 SG(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 y=d.getComponent(m,b);l.setComponent(m+f,b,y)}}else o.set(d.array,c);c+=d.count*n}return i!==void 0&&(l.gpuType=i),l}function t1(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 Ak={exports:{}};var MG;function DIe(){return MG||(MG=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 t1=="function"&&t1;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 y=r[u][1][b];return o(y||b)},p,p.exports,n,r,i,a)}return i[u].exports}for(var l=typeof t1=="function"&&t1,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,y,x=[],v=0,S=c.length,M=S,E=a.getTypeOf(c)!=="string";v<c.length;)M=S-v,f=E?(u=c[v++],d=v<S?c[v++]:0,v<S?c[v++]:0):(u=c.charCodeAt(v++),d=v<S?c.charCodeAt(v++):0,v<S?c.charCodeAt(v++):0),m=u>>2,p=(3&u)<<4|d>>4,b=1<M?(15&d)<<2|f>>6:64,y=2<M?63&f:64,x.push(l.charAt(m)+l.charAt(p)+l.charAt(b)+l.charAt(y));return x.join("")},i.decode=function(c){var u,d,f,m,p,b,y=0,x=0,v="data:";if(c.substr(0,v.length)===v)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);y<c.length;)u=l.indexOf(c.charAt(y++))<<2|(m=l.indexOf(c.charAt(y++)))>>4,d=(15&m)<<4|(p=l.indexOf(c.charAt(y++)))>>2,f=(3&p)<<6|(b=l.indexOf(c.charAt(y++))),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 y=m;y<b;y++)u=u>>>8^p[255&(u^d[y])];return-1^u})(0|c,l,l.length,0):(function(u,d,f,m){var p=o,b=m+f;u^=-1;for(var y=m;y<b;y++)u=u>>>8^p[255&(u^d.charCodeAt(y))];return-1^u})(0|c,l,l.length,0):0}},{"./utils":32}],5:[function(n,r,i){i.base64=!1,i.binary=!1,i.dir=!1,i.createFolders=!0,i.date=null,i.compression=null,i.compressionOptions=null,i.comment=null,i.unixPermissions=null,i.dosPermissions=null},{}],6:[function(n,r,i){var a=null;a=typeof Promise<"u"?Promise:n("lie"),r.exports={Promise:a}},{lie:37}],7:[function(n,r,i){var a=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",o=n("pako"),l=n("./utils"),c=n("./stream/GenericWorker"),u=a?"uint8array":"array";function d(f,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 y,x="";for(y=0;y<b;y++)x+=String.fromCharCode(255&p),p>>>=8;return x}function o(p,b,y,x,v,S){var M,E,A=p.file,k=p.compression,T=S!==u.utf8encode,D=l.transformTo("string",S(A.name)),C=l.transformTo("string",u.utf8encode(A.name)),R=A.comment,U=l.transformTo("string",S(R)),O=l.transformTo("string",u.utf8encode(R)),q=C.length!==A.name.length,j=O.length!==R.length,W="",X="",G="",Z=A.dir,te=A.date,ee={crc32:0,compressedSize:0,uncompressedSize:0};b&&!y||(ee.crc32=p.crc32,ee.compressedSize=p.compressedSize,ee.uncompressedSize=p.uncompressedSize);var z=0;b&&(z|=8),T||!q&&!j||(z|=2048);var V=0,ne=0;Z&&(V|=16),v==="UNIX"?(ne=798,V|=(function(he,me){var oe=he;return he||(oe=me?16893:33204),(65535&oe)<<16})(A.unixPermissions,Z)):(ne=20,V|=(function(he){return 63&(he||0)})(A.dosPermissions)),M=te.getUTCHours(),M<<=6,M|=te.getUTCMinutes(),M<<=5,M|=te.getUTCSeconds()/2,E=te.getUTCFullYear()-1980,E<<=4,E|=te.getUTCMonth()+1,E<<=5,E|=te.getUTCDate(),q&&(X=a(1,1)+a(d(D),4)+C,W+="up"+a(X.length,2)+X),j&&(G=a(1,1)+a(d(U),4)+O,W+="uc"+a(G.length,2)+G);var ie="";return ie+=`
- \0`,ie+=a(z,2),ie+=k.magic,ie+=a(M,2),ie+=a(E,2),ie+=a(ee.crc32,4),ie+=a(ee.compressedSize,4),ie+=a(ee.uncompressedSize,4),ie+=a(D.length,2),ie+=a(W.length,2),{fileRecord:f.LOCAL_FILE_HEADER+ie+D+W,dirRecord:f.CENTRAL_FILE_HEADER+a(ne,2)+ie+a(U.length,2)+"\0\0\0\0"+a(V,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,y,x){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=b,this.zipPlatform=y,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,y=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:y?(b+100*(y-x-1))/y: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 y=o(p,b,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:y.fileRecord,meta:{percent:0}})}else this.accumulate=!0},m.prototype.closedSource=function(p){this.accumulate=!1;var b=this.streamFiles&&!p.file.dir,y=o(p,b,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(y.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:y.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 y=this.bytesWritten-p,x=(function(v,S,M,E,A){var k=l.transformTo("string",A(E));return f.CENTRAL_DIRECTORY_END+"\0\0\0\0"+a(v,2)+a(v,2)+a(S,4)+a(M,4)+a(k.length,2)+k})(this.dirRecords.length,y,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(y){b.processChunk(y)}),p.on("end",function(){b.closedSource(b.previous.streamInfo),b._sources.length?b.prepareNextSource():b.end()}),p.on("error",function(y){b.error(y)}),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 y=0;y<b.length;y++)try{b[y].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 E=S||M,A=a[E];if(!A)throw new Error(E+" is not a valid compression method !");return A})(p.options.compression,c.compression),y=p.options.compressionOptions||c.compressionOptions||{},x=p.dir,v=p.date;p._compressWorker(b,y).withStreamInfo("file",{name:m,dir:x,date:v,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 y=m.decompressed.getContentWorker().pipe(new u);y.on("error",function(x){b(x)}).on("end",function(){y.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(y){var x=new c(p);return x.load(y),x}).then(function(y){var x=[o.Promise.resolve(y)],v=y.files;if(p.checkCRC32)for(var S=0;S<v.length;S++)x.push(f(v[S]));return o.Promise.all(x)}).then(function(y){for(var x=y.shift(),v=x.files,S=0;S<v.length;S++){var M=v[S],E=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=E)}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,T){var D,C=l.getTypeOf(k),R=l.extend(T||{},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=v(A)),R.createFolders&&(D=x(A))&&S.call(this,D,!0);var U=C==="string"&&R.binary===!1&&R.base64===!1;T&&T.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",C="string");var O=null;O=k instanceof f||k instanceof c?k:b.isNode&&b.isStream(k)?new y(A,k):l.prepareContent(A,k,R.binary,R.optimizedBinaryString,R.base64);var q=new m(A,O,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"),y=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):""},v=function(A){return A.slice(-1)!=="/"&&(A+="/"),A},S=function(A,k){return k=k!==void 0?k:d.createFolders,A=v(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 E={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(A){var k,T,D;for(k in this.files)D=this.files[k],(T=k.slice(this.root.length,k.length))&&k.slice(0,this.root.length)===this.root&&A(T,D)},filter:function(A){var k=[];return this.forEach(function(T,D){A(T,D)&&k.push(D)}),k},file:function(A,k,T){if(arguments.length!==1)return A=this.root+A,a.call(this,A,k,T),this;if(M(A)){var D=A;return this.filter(function(R,U){return!U.dir&&D.test(R)})}var C=this.files[this.root+A];return C&&!C.dir?C:null},folder:function(A){if(!A)return this;if(M(A))return this.filter(function(C,R){return R.dir&&A.test(C)});var k=this.root+A,T=S.call(this,k),D=this.clone();return D.root=T.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 T=this.filter(function(C,R){return R.name.slice(0,A.length)===A}),D=0;D<T.length;D++)delete this.files[T[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,T={};try{if((T=l.extend(A||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:o.utf8encode})).type=T.type.toLowerCase(),T.compression=T.compression.toUpperCase(),T.type==="binarystring"&&(T.type="string"),!T.type)throw new Error("No output type specified.");l.checkSupport(T.type),T.platform!=="darwin"&&T.platform!=="freebsd"&&T.platform!=="linux"&&T.platform!=="sunos"||(T.platform="UNIX"),T.platform==="win32"&&(T.platform="DOS");var D=T.comment||this.comment||"";k=p.generateWorker(this,T,D)}catch(C){(k=new c("error")).error(C)}return new u(k,T.type||"string",T.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=E},{"./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,y){return new d.Promise(function(x,v){var S=[],M=b._internalType,E=b._outputType,A=b._mimeType;b.on("data",function(k,T){S.push(k),y&&y(T)}).on("error",function(k){S=[],v(k)}).on("end",function(){try{var k=(function(T,D,C){switch(T){case"blob":return a.newBlob(a.transformTo("arraybuffer",D),C);case"base64":return c.encode(D);default:return a.transformTo(T,D)}})(E,(function(T,D){var C,R=0,U=null,O=0;for(C=0;C<D.length;C++)O+=D[C].length;switch(T){case"string":return D.join("");case"array":return Array.prototype.concat.apply([],D);case"uint8array":for(U=new Uint8Array(O),C=0;C<D.length;C++)U.set(D[C],R),R+=D[C].length;return U;case"nodebuffer":return Buffer.concat(D);default:throw new Error("concat : unsupported type '"+T+"'")}})(M,S),A);x(k)}catch(T){v(T)}S=[]}).resume()})}function p(b,y,x){var v=y;switch(y){case"blob":case"arraybuffer":v="uint8array";break;case"base64":v="string"}try{this._internalType=v,this._outputType=y,this._mimeType=x,a.checkSupport(v),this._worker=b.pipe(new o(v)),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,y){var x=this;return b==="data"?this._worker.on(b,function(v){y.call(x,v.data,v.meta)}):this._worker.on(b,function(){a.delay(y,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 y,x,v,S,M,E=b.length,A=0;for(S=0;S<E;S++)(64512&(x=b.charCodeAt(S)))==55296&&S+1<E&&(64512&(v=b.charCodeAt(S+1)))==56320&&(x=65536+(x-55296<<10)+(v-56320),S++),A+=x<128?1:x<2048?2:x<65536?3:4;for(y=o.uint8array?new Uint8Array(A):new Array(A),S=M=0;M<A;S++)(64512&(x=b.charCodeAt(S)))==55296&&S+1<E&&(64512&(v=b.charCodeAt(S+1)))==56320&&(x=65536+(x-55296<<10)+(v-56320),S++),x<128?y[M++]=x:(x<2048?y[M++]=192|x>>>6:(x<65536?y[M++]=224|x>>>12:(y[M++]=240|x>>>18,y[M++]=128|x>>>12&63),y[M++]=128|x>>>6&63),y[M++]=128|63&x);return y})(p)},i.utf8decode=function(p){return o.nodebuffer?a.transformTo("nodebuffer",p).toString("utf-8"):(function(b){var y,x,v,S,M=b.length,E=new Array(2*M);for(y=x=0;y<M;)if((v=b[y++])<128)E[x++]=v;else if(4<(S=u[v]))E[x++]=65533,y+=S-1;else{for(v&=S===2?31:S===3?15:7;1<S&&y<M;)v=v<<6|63&b[y++],S--;1<S?E[x++]=65533:v<65536?E[x++]=v:(v-=65536,E[x++]=55296|v>>10&1023,E[x++]=56320|1023&v)}return E.length!==x&&(E.subarray?E=E.subarray(0,x):E.length=x),a.applyFromCharCode(E)})(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 y=b;(b=new Uint8Array(y.length+this.leftOver.length)).set(this.leftOver,0),b.set(y,this.leftOver.length)}else b=this.leftOver.concat(b);this.leftOver=null}var x=(function(S,M){var E;for((M=M||S.length)>S.length&&(M=S.length),E=M-1;0<=E&&(192&S[E])==128;)E--;return E<0||E===0?M:E+u[S[E]]>M?E:M})(b),v=b;x!==b.length&&(o.uint8array?(v=b.subarray(0,x),this.leftOver=b.subarray(x,b.length)):(v=b.slice(0,x),this.leftOver=b.slice(x,b.length))),this.push({data:i.utf8decode(v),meta:p.meta})},f.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=f,a.inherits(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(y){return y}function d(y,x){for(var v=0;v<y.length;++v)x[v]=255&y.charCodeAt(v);return x}n("setimmediate"),i.newBlob=function(y,x){i.checkSupport("blob");try{return new Blob([y],{type:x})}catch{try{var v=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return v.append(y),v.getBlob(x)}catch{throw new Error("Bug : can't construct the Blob.")}}};var f={stringifyByChunk:function(y,x,v){var S=[],M=0,E=y.length;if(E<=v)return String.fromCharCode.apply(null,y);for(;M<E;)x==="array"||x==="nodebuffer"?S.push(String.fromCharCode.apply(null,y.slice(M,Math.min(M+v,E)))):S.push(String.fromCharCode.apply(null,y.subarray(M,Math.min(M+v,E)))),M+=v;return S.join("")},stringifyByChar:function(y){for(var x="",v=0;v<y.length;v++)x+=String.fromCharCode(y[v]);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(y){var x=65536,v=i.getTypeOf(y),S=!0;if(v==="uint8array"?S=f.applyCanBeUsed.uint8array:v==="nodebuffer"&&(S=f.applyCanBeUsed.nodebuffer),S)for(;1<x;)try{return f.stringifyByChunk(y,v,x)}catch{x=Math.floor(x/2)}return f.stringifyByChar(y)}function p(y,x){for(var v=0;v<y.length;v++)x[v]=y[v];return x}i.applyFromCharCode=m;var b={};b.string={string:u,array:function(y){return d(y,new Array(y.length))},arraybuffer:function(y){return b.string.uint8array(y).buffer},uint8array:function(y){return d(y,new Uint8Array(y.length))},nodebuffer:function(y){return d(y,l.allocBuffer(y.length))}},b.array={string:m,array:u,arraybuffer:function(y){return new Uint8Array(y).buffer},uint8array:function(y){return new Uint8Array(y)},nodebuffer:function(y){return l.newBufferFrom(y)}},b.arraybuffer={string:function(y){return m(new Uint8Array(y))},array:function(y){return p(new Uint8Array(y),new Array(y.byteLength))},arraybuffer:u,uint8array:function(y){return new Uint8Array(y)},nodebuffer:function(y){return l.newBufferFrom(new Uint8Array(y))}},b.uint8array={string:m,array:function(y){return p(y,new Array(y.length))},arraybuffer:function(y){return y.buffer},uint8array:u,nodebuffer:function(y){return l.newBufferFrom(y)}},b.nodebuffer={string:m,array:function(y){return p(y,new Array(y.length))},arraybuffer:function(y){return b.nodebuffer.uint8array(y).buffer},uint8array:function(y){return p(y,new Uint8Array(y.length))},nodebuffer:u},i.transformTo=function(y,x){if(x=x||"",!y)return x;i.checkSupport(y);var v=i.getTypeOf(x);return b[v][y](x)},i.resolve=function(y){for(var x=y.split("/"),v=[],S=0;S<x.length;S++){var M=x[S];M==="."||M===""&&S!==0&&S!==x.length-1||(M===".."?v.pop():v.push(M))}return v.join("/")},i.getTypeOf=function(y){return typeof y=="string"?"string":Object.prototype.toString.call(y)==="[object Array]"?"array":a.nodebuffer&&l.isBuffer(y)?"nodebuffer":a.uint8array&&y instanceof Uint8Array?"uint8array":a.arraybuffer&&y instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(y){if(!a[y.toLowerCase()])throw new Error(y+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(y){var x,v,S="";for(v=0;v<(y||"").length;v++)S+="\\x"+((x=y.charCodeAt(v))<16?"0":"")+x.toString(16).toUpperCase();return S},i.delay=function(y,x,v){setImmediate(function(){y.apply(v||null,x||[])})},i.inherits=function(y,x){function v(){}v.prototype=x.prototype,y.prototype=new v},i.extend=function(){var y,x,v={};for(y=0;y<arguments.length;y++)for(x in arguments[y])Object.prototype.hasOwnProperty.call(arguments[y],x)&&v[x]===void 0&&(v[x]=arguments[y][x]);return v},i.prepareContent=function(y,x,v,S,M){return c.Promise.resolve(x).then(function(E){return a.blob&&(E instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(E))!==-1)&&typeof FileReader<"u"?new c.Promise(function(A,k){var T=new FileReader;T.onload=function(D){A(D.target.result)},T.onerror=function(D){k(D.target.error)},T.readAsArrayBuffer(E)}):E}).then(function(E){var A=i.getTypeOf(E);return A?(A==="arraybuffer"?E=i.transformTo("uint8array",E):A==="string"&&(M?E=o.decode(E):v&&S!==!0&&(E=(function(k){return d(k,a.uint8array?new Uint8Array(k.length):new Array(k.length))})(E))),E):c.Promise.reject(new Error("Can't read the data of '"+y+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(n,r,i){var a=n("./reader/readerFor"),o=n("./utils"),l=n("./signature"),c=n("./zipEntry"),u=n("./support");function d(f){this.files=[],this.loadOptions=f}d.prototype={checkSignature:function(f){if(!this.reader.readAndCheckSignature(f)){this.reader.index-=4;var 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,y;if(p.skip(22),this.fileNameLength=p.readInt(2),y=p.readInt(2),this.fileName=p.readData(this.fileNameLength),p.skip(y),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((b=(function(x){for(var v in d)if(Object.prototype.hasOwnProperty.call(d,v)&&d[v].magic===x)return d[v];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+o.pretty(this.compressionMethod)+" unknown (inner file : "+o.transformTo("string",this.fileName)+")");this.decompressed=new l(this.compressedSize,this.uncompressedSize,this.crc32,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,y,x,v=p.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});p.index+4<v;)b=p.readInt(2),y=p.readInt(2),x=p.readData(y),this.extraFields[b]={id:b,length:y,value:x};p.setIndex(v)},handleUTF8:function(){var p=f.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=u.utf8decode(this.fileName),this.fileCommentStr=u.utf8decode(this.fileComment);else{var b=this.findExtraFieldUnicodePath();if(b!==null)this.fileNameStr=b;else{var y=o.transformTo(p,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(y)}var x=this.findExtraFieldUnicodeComment();if(x!==null)this.fileCommentStr=x;else{var v=o.transformTo(p,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(v)}}},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,y,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=y,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 y=null,x="string";try{if(!b)throw new Error("No output type specified.");var v=(x=b.toLowerCase())==="string"||x==="text";x!=="binarystring"&&x!=="text"||(x="string"),y=this._decompressWorker();var S=!this._dataBinary;S&&!v&&(y=y.pipe(new c.Utf8EncodeWorker)),!S&&v&&(y=y.pipe(new c.Utf8DecodeWorker))}catch(M){(y=new d("error")).error(M)}return new o(y,x,"")},async:function(b,y){return this.internalStream(b).accumulate(y)},nodeStream:function(b,y){return this.internalStream(b||"nodebuffer").toNodejsStream(y)},_compressWorker:function(b,y){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,y)},_decompressWorker:function(){return this._data instanceof u?this._data.getContentWorker():this._data instanceof d?this._data:new l(this._data)}};for(var f=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],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 y=a.document.createElement("script");y.onreadystatechange=function(){b(),y.onreadystatechange=null,y.parentNode.removeChild(y),y=null},a.document.documentElement.appendChild(y)}: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 y,x;l=!0;for(var v=p.length;v;){for(x=p,p=[],y=-1;++y<v;)x[y]();v=p.length}l=!1}r.exports=function(y){p.push(y)!==1||l||o()}}).call(this,typeof u_<"u"?u_:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(n,r,i){var a=n("immediate");function o(){}var l={},c=["REJECTED"],u=["FULFILLED"],d=["PENDING"];function f(v){if(typeof v!="function")throw new TypeError("resolver must be a function");this.state=d,this.queue=[],this.outcome=void 0,v!==o&&y(this,v)}function m(v,S,M){this.promise=v,typeof S=="function"&&(this.onFulfilled=S,this.callFulfilled=this.otherCallFulfilled),typeof M=="function"&&(this.onRejected=M,this.callRejected=this.otherCallRejected)}function p(v,S,M){a(function(){var E;try{E=S(M)}catch(A){return l.reject(v,A)}E===v?l.reject(v,new TypeError("Cannot resolve promise with itself")):l.resolve(v,E)})}function b(v){var S=v&&v.then;if(v&&(typeof v=="object"||typeof v=="function")&&typeof S=="function")return function(){S.apply(v,arguments)}}function y(v,S){var M=!1;function E(T){M||(M=!0,l.reject(v,T))}function A(T){M||(M=!0,l.resolve(v,T))}var k=x(function(){S(A,E)});k.status==="error"&&E(k.value)}function x(v,S){var M={};try{M.value=v(S),M.status="success"}catch(E){M.status="error",M.value=E}return M}(r.exports=f).prototype.finally=function(v){if(typeof v!="function")return this;var S=this.constructor;return this.then(function(M){return S.resolve(v()).then(function(){return M})},function(M){return S.resolve(v()).then(function(){throw M})})},f.prototype.catch=function(v){return this.then(null,v)},f.prototype.then=function(v,S){if(typeof v!="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?v:S,this.outcome):this.queue.push(new m(M,v,S)),M},m.prototype.callFulfilled=function(v){l.resolve(this.promise,v)},m.prototype.otherCallFulfilled=function(v){p(this.promise,this.onFulfilled,v)},m.prototype.callRejected=function(v){l.reject(this.promise,v)},m.prototype.otherCallRejected=function(v){p(this.promise,this.onRejected,v)},l.resolve=function(v,S){var M=x(b,S);if(M.status==="error")return l.reject(v,M.value);var E=M.value;if(E)y(v,E);else{v.state=u,v.outcome=S;for(var A=-1,k=v.queue.length;++A<k;)v.queue[A].callFulfilled(S)}return v},l.reject=function(v,S){v.state=c,v.outcome=S;for(var M=-1,E=v.queue.length;++M<E;)v.queue[M].callRejected(S);return v},f.resolve=function(v){return v instanceof this?v:l.resolve(new this(o),v)},f.reject=function(v){var S=new this(o);return l.reject(S,v)},f.all=function(v){var S=this;if(Object.prototype.toString.call(v)!=="[object Array]")return this.reject(new TypeError("must be an array"));var M=v.length,E=!1;if(!M)return this.resolve([]);for(var A=new Array(M),k=0,T=-1,D=new this(o);++T<M;)C(v[T],T);return D;function C(R,U){S.resolve(R).then(function(O){A[U]=O,++k!==M||E||(E=!0,l.resolve(D,A))},function(O){E||(E=!0,l.reject(D,O))})}},f.race=function(v){var S=this;if(Object.prototype.toString.call(v)!=="[object Array]")return this.reject(new TypeError("must be an array"));var M=v.length,E=!1;if(!M)return this.resolve([]);for(var A=-1,k=new this(o);++A<M;)T=v[A],S.resolve(T).then(function(D){E||(E=!0,l.resolve(k,D))},function(D){E||(E=!0,l.reject(k,D))});var T;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 y(v){if(!(this instanceof y))return new y(v);this.options=o.assign({level:m,method:b,chunkSize:16384,windowBits:15,memLevel:8,strategy:p,to:""},v||{});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 E;if(E=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,E))!==f)throw new Error(c[M]);this._dict_set=!0}}function x(v,S){var M=new y(S);if(M.push(v,!0),M.err)throw M.msg||c[M.err];return M.result}y.prototype.push=function(v,S){var M,E,A=this.strm,k=this.options.chunkSize;if(this.ended)return!1;E=S===~~S?S:S===!0?4:0,typeof v=="string"?A.input=l.string2buf(v):d.call(v)==="[object ArrayBuffer]"?A.input=new Uint8Array(v):A.input=v,A.next_in=0,A.avail_in=A.input.length;do{if(A.avail_out===0&&(A.output=new o.Buf8(k),A.next_out=0,A.avail_out=k),(M=a.deflate(A,E))!==1&&M!==f)return this.onEnd(M),!(this.ended=!0);A.avail_out!==0&&(A.avail_in!==0||E!==4&&E!==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 E===4?(M=a.deflateEnd(this.strm),this.onEnd(M),this.ended=!0,M===f):E!==2||(this.onEnd(f),!(A.avail_out=0))},y.prototype.onData=function(v){this.chunks.push(v)},y.prototype.onEnd=function(v){v===f&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=v,this.msg=this.strm.msg},i.Deflate=y,i.deflate=x,i.deflateRaw=function(v,S){return(S=S||{}).raw=!0,x(v,S)},i.gzip=function(v,S){return(S=S||{}).gzip=!0,x(v,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(y){if(!(this instanceof p))return new p(y);this.options=o.assign({chunkSize:16384,windowBits:0,to:""},y||{});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)||y&&y.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 v=a.inflateInit2(this.strm,x.windowBits);if(v!==c.Z_OK)throw new Error(u[v]);this.header=new f,a.inflateGetHeader(this.strm,this.header)}function b(y,x){var v=new p(x);if(v.push(y,!0),v.err)throw v.msg||u[v.err];return v.result}p.prototype.push=function(y,x){var v,S,M,E,A,k,T=this.strm,D=this.options.chunkSize,C=this.options.dictionary,R=!1;if(this.ended)return!1;S=x===~~x?x:x===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof y=="string"?T.input=l.binstring2buf(y):m.call(y)==="[object ArrayBuffer]"?T.input=new Uint8Array(y):T.input=y,T.next_in=0,T.avail_in=T.input.length;do{if(T.avail_out===0&&(T.output=new o.Buf8(D),T.next_out=0,T.avail_out=D),(v=a.inflate(T,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&C&&(k=typeof C=="string"?l.string2buf(C):m.call(C)==="[object ArrayBuffer]"?new Uint8Array(C):C,v=a.inflateSetDictionary(this.strm,k)),v===c.Z_BUF_ERROR&&R===!0&&(v=c.Z_OK,R=!1),v!==c.Z_STREAM_END&&v!==c.Z_OK)return this.onEnd(v),!(this.ended=!0);T.next_out&&(T.avail_out!==0&&v!==c.Z_STREAM_END&&(T.avail_in!==0||S!==c.Z_FINISH&&S!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(M=l.utf8border(T.output,T.next_out),E=T.next_out-M,A=l.buf2string(T.output,M),T.next_out=E,T.avail_out=D-E,E&&o.arraySet(T.output,T.output,M,E,0),this.onData(A)):this.onData(o.shrinkBuf(T.output,T.next_out)))),T.avail_in===0&&T.avail_out===0&&(R=!0)}while((0<T.avail_in||T.avail_out===0)&&v!==c.Z_STREAM_END);return v===c.Z_STREAM_END&&(S=c.Z_FINISH),S===c.Z_FINISH?(v=a.inflateEnd(this.strm),this.onEnd(v),this.ended=!0,v===c.Z_OK):S!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(T.avail_out=0))},p.prototype.onData=function(y){this.chunks.push(y)},p.prototype.onEnd=function(y){y===c.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=y,this.msg=this.strm.msg},i.Inflate=p,i.inflate=b,i.inflateRaw=function(y,x){return(x=x||{}).raw=!0,b(y,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,y,x,v=f.length,S=0;for(y=0;y<v;y++)(64512&(p=f.charCodeAt(y)))==55296&&y+1<v&&(64512&(b=f.charCodeAt(y+1)))==56320&&(p=65536+(p-55296<<10)+(b-56320),y++),S+=p<128?1:p<2048?2:p<65536?3:4;for(m=new a.Buf8(S),y=x=0;x<S;y++)(64512&(p=f.charCodeAt(y)))==55296&&y+1<v&&(64512&(b=f.charCodeAt(y+1)))==56320&&(p=65536+(p-55296<<10)+(b-56320),y++),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,y,x,v=m||f.length,S=new Array(2*v);for(p=b=0;p<v;)if((y=f[p++])<128)S[b++]=y;else if(4<(x=c[y]))S[b++]=65533,p+=x-1;else{for(y&=x===2?31:x===3?15:7;1<x&&p<v;)y=y<<6|63&f[p++],x--;1<x?S[b++]=65533:y<65536?S[b++]=y:(y-=65536,S[b++]=55296|y>>10&1023,S[b++]=56320|1023&y)}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,y=-1,x=4,v=2,S=8,M=9,E=286,A=30,k=19,T=2*E+1,D=15,C=3,R=258,U=R+C+1,O=42,q=113,j=1,W=2,X=3,G=4;function Z(H,J){return H.msg=d[J],J}function te(H){return(H<<1)-(4<H?9:0)}function ee(H){for(var J=H.length;0<=--J;)H[J]=0}function z(H){var J=H.state,K=J.pending;K>H.avail_out&&(K=H.avail_out),K!==0&&(o.arraySet(H.output,J.pending_buf,J.pending_out,K,H.next_out),H.next_out+=K,J.pending_out+=K,H.total_out+=K,H.avail_out-=K,J.pending-=K,J.pending===0&&(J.pending_out=0))}function V(H,J){l._tr_flush_block(H,0<=H.block_start?H.block_start:-1,H.strstart-H.block_start,J),H.block_start=H.strstart,z(H.strm)}function ne(H,J){H.pending_buf[H.pending++]=J}function ie(H,J){H.pending_buf[H.pending++]=J>>>8&255,H.pending_buf[H.pending++]=255&J}function he(H,J){var K,B,I=H.max_chain_length,ce=H.strstart,Ee=H.prev_length,Ie=H.nice_match,ue=H.strstart>H.w_size-U?H.strstart-(H.w_size-U):0,$=H.window,L=H.w_mask,Y=H.prev,pe=H.strstart+R,Se=$[ce+Ee-1],ae=$[ce+Ee];H.prev_length>=H.good_match&&(I>>=2),Ie>H.lookahead&&(Ie=H.lookahead);do if($[(K=J)+Ee]===ae&&$[K+Ee-1]===Se&&$[K]===$[ce]&&$[++K]===$[ce+1]){ce+=2,K++;do;while($[++ce]===$[++K]&&$[++ce]===$[++K]&&$[++ce]===$[++K]&&$[++ce]===$[++K]&&$[++ce]===$[++K]&&$[++ce]===$[++K]&&$[++ce]===$[++K]&&$[++ce]===$[++K]&&ce<pe);if(B=R-(pe-ce),ce=pe-R,Ee<B){if(H.match_start=J,Ie<=(Ee=B))break;Se=$[ce+Ee-1],ae=$[ce+Ee]}}while((J=Y[J&L])>ue&&--I!=0);return Ee<=H.lookahead?Ee:H.lookahead}function me(H){var J,K,B,I,ce,Ee,Ie,ue,$,L,Y=H.w_size;do{if(I=H.window_size-H.lookahead-H.strstart,H.strstart>=Y+(Y-U)){for(o.arraySet(H.window,H.window,Y,Y,0),H.match_start-=Y,H.strstart-=Y,H.block_start-=Y,J=K=H.hash_size;B=H.head[--J],H.head[J]=Y<=B?B-Y:0,--K;);for(J=K=Y;B=H.prev[--J],H.prev[J]=Y<=B?B-Y:0,--K;);I+=Y}if(H.strm.avail_in===0)break;if(Ee=H.strm,Ie=H.window,ue=H.strstart+H.lookahead,$=I,L=void 0,L=Ee.avail_in,$<L&&(L=$),K=L===0?0:(Ee.avail_in-=L,o.arraySet(Ie,Ee.input,Ee.next_in,L,ue),Ee.state.wrap===1?Ee.adler=c(Ee.adler,Ie,L,ue):Ee.state.wrap===2&&(Ee.adler=u(Ee.adler,Ie,L,ue)),Ee.next_in+=L,Ee.total_in+=L,L),H.lookahead+=K,H.lookahead+H.insert>=C)for(ce=H.strstart-H.insert,H.ins_h=H.window[ce],H.ins_h=(H.ins_h<<H.hash_shift^H.window[ce+1])&H.hash_mask;H.insert&&(H.ins_h=(H.ins_h<<H.hash_shift^H.window[ce+C-1])&H.hash_mask,H.prev[ce&H.w_mask]=H.head[H.ins_h],H.head[H.ins_h]=ce,ce++,H.insert--,!(H.lookahead+H.insert<C)););}while(H.lookahead<U&&H.strm.avail_in!==0)}function oe(H,J){for(var K,B;;){if(H.lookahead<U){if(me(H),H.lookahead<U&&J===f)return j;if(H.lookahead===0)break}if(K=0,H.lookahead>=C&&(H.ins_h=(H.ins_h<<H.hash_shift^H.window[H.strstart+C-1])&H.hash_mask,K=H.prev[H.strstart&H.w_mask]=H.head[H.ins_h],H.head[H.ins_h]=H.strstart),K!==0&&H.strstart-K<=H.w_size-U&&(H.match_length=he(H,K)),H.match_length>=C)if(B=l._tr_tally(H,H.strstart-H.match_start,H.match_length-C),H.lookahead-=H.match_length,H.match_length<=H.max_lazy_match&&H.lookahead>=C){for(H.match_length--;H.strstart++,H.ins_h=(H.ins_h<<H.hash_shift^H.window[H.strstart+C-1])&H.hash_mask,K=H.prev[H.strstart&H.w_mask]=H.head[H.ins_h],H.head[H.ins_h]=H.strstart,--H.match_length!=0;);H.strstart++}else H.strstart+=H.match_length,H.match_length=0,H.ins_h=H.window[H.strstart],H.ins_h=(H.ins_h<<H.hash_shift^H.window[H.strstart+1])&H.hash_mask;else B=l._tr_tally(H,0,H.window[H.strstart]),H.lookahead--,H.strstart++;if(B&&(V(H,!1),H.strm.avail_out===0))return j}return H.insert=H.strstart<C-1?H.strstart:C-1,J===m?(V(H,!0),H.strm.avail_out===0?X:G):H.last_lit&&(V(H,!1),H.strm.avail_out===0)?j:W}function Ae(H,J){for(var K,B,I;;){if(H.lookahead<U){if(me(H),H.lookahead<U&&J===f)return j;if(H.lookahead===0)break}if(K=0,H.lookahead>=C&&(H.ins_h=(H.ins_h<<H.hash_shift^H.window[H.strstart+C-1])&H.hash_mask,K=H.prev[H.strstart&H.w_mask]=H.head[H.ins_h],H.head[H.ins_h]=H.strstart),H.prev_length=H.match_length,H.prev_match=H.match_start,H.match_length=C-1,K!==0&&H.prev_length<H.max_lazy_match&&H.strstart-K<=H.w_size-U&&(H.match_length=he(H,K),H.match_length<=5&&(H.strategy===1||H.match_length===C&&4096<H.strstart-H.match_start)&&(H.match_length=C-1)),H.prev_length>=C&&H.match_length<=H.prev_length){for(I=H.strstart+H.lookahead-C,B=l._tr_tally(H,H.strstart-1-H.prev_match,H.prev_length-C),H.lookahead-=H.prev_length-1,H.prev_length-=2;++H.strstart<=I&&(H.ins_h=(H.ins_h<<H.hash_shift^H.window[H.strstart+C-1])&H.hash_mask,K=H.prev[H.strstart&H.w_mask]=H.head[H.ins_h],H.head[H.ins_h]=H.strstart),--H.prev_length!=0;);if(H.match_available=0,H.match_length=C-1,H.strstart++,B&&(V(H,!1),H.strm.avail_out===0))return j}else if(H.match_available){if((B=l._tr_tally(H,0,H.window[H.strstart-1]))&&V(H,!1),H.strstart++,H.lookahead--,H.strm.avail_out===0)return j}else H.match_available=1,H.strstart++,H.lookahead--}return H.match_available&&(B=l._tr_tally(H,0,H.window[H.strstart-1]),H.match_available=0),H.insert=H.strstart<C-1?H.strstart:C-1,J===m?(V(H,!0),H.strm.avail_out===0?X:G):H.last_lit&&(V(H,!1),H.strm.avail_out===0)?j:W}function ge(H,J,K,B,I){this.good_length=H,this.max_lazy=J,this.nice_length=K,this.max_chain=B,this.func=I}function Ne(){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*T),this.dyn_dtree=new o.Buf16(2*(2*A+1)),this.bl_tree=new o.Buf16(2*(2*k+1)),ee(this.dyn_ltree),ee(this.dyn_dtree),ee(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*E+1),ee(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new o.Buf16(2*E+1),ee(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 _e(H){var J;return H&&H.state?(H.total_in=H.total_out=0,H.data_type=v,(J=H.state).pending=0,J.pending_out=0,J.wrap<0&&(J.wrap=-J.wrap),J.status=J.wrap?O:q,H.adler=J.wrap===2?0:1,J.last_flush=f,l._tr_init(J),p):Z(H,b)}function le(H){var J=_e(H);return J===p&&(function(K){K.window_size=2*K.w_size,ee(K.head),K.max_lazy_match=a[K.level].max_lazy,K.good_match=a[K.level].good_length,K.nice_match=a[K.level].nice_length,K.max_chain_length=a[K.level].max_chain,K.strstart=0,K.block_start=0,K.lookahead=0,K.insert=0,K.match_length=K.prev_length=C-1,K.match_available=0,K.ins_h=0})(H.state),J}function He(H,J,K,B,I,ce){if(!H)return b;var Ee=1;if(J===y&&(J=6),B<0?(Ee=0,B=-B):15<B&&(Ee=2,B-=16),I<1||M<I||K!==S||B<8||15<B||J<0||9<J||ce<0||x<ce)return Z(H,b);B===8&&(B=9);var Ie=new Ne;return(H.state=Ie).strm=H,Ie.wrap=Ee,Ie.gzhead=null,Ie.w_bits=B,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+C-1)/C),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=J,Ie.strategy=ce,Ie.method=K,le(H)}a=[new ge(0,0,0,0,function(H,J){var K=65535;for(K>H.pending_buf_size-5&&(K=H.pending_buf_size-5);;){if(H.lookahead<=1){if(me(H),H.lookahead===0&&J===f)return j;if(H.lookahead===0)break}H.strstart+=H.lookahead,H.lookahead=0;var B=H.block_start+K;if((H.strstart===0||H.strstart>=B)&&(H.lookahead=H.strstart-B,H.strstart=B,V(H,!1),H.strm.avail_out===0)||H.strstart-H.block_start>=H.w_size-U&&(V(H,!1),H.strm.avail_out===0))return j}return H.insert=0,J===m?(V(H,!0),H.strm.avail_out===0?X:G):(H.strstart>H.block_start&&(V(H,!1),H.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,Ae),new ge(8,16,32,32,Ae),new ge(8,16,128,128,Ae),new ge(8,32,128,256,Ae),new ge(32,128,258,1024,Ae),new ge(32,258,258,4096,Ae)],i.deflateInit=function(H,J){return He(H,J,S,15,8,0)},i.deflateInit2=He,i.deflateReset=le,i.deflateResetKeep=_e,i.deflateSetHeader=function(H,J){return H&&H.state?H.state.wrap!==2?b:(H.state.gzhead=J,p):b},i.deflate=function(H,J){var K,B,I,ce;if(!H||!H.state||5<J||J<0)return H?Z(H,b):b;if(B=H.state,!H.output||!H.input&&H.avail_in!==0||B.status===666&&J!==m)return Z(H,H.avail_out===0?-5:b);if(B.strm=H,K=B.last_flush,B.last_flush=J,B.status===O)if(B.wrap===2)H.adler=0,ne(B,31),ne(B,139),ne(B,8),B.gzhead?(ne(B,(B.gzhead.text?1:0)+(B.gzhead.hcrc?2:0)+(B.gzhead.extra?4:0)+(B.gzhead.name?8:0)+(B.gzhead.comment?16:0)),ne(B,255&B.gzhead.time),ne(B,B.gzhead.time>>8&255),ne(B,B.gzhead.time>>16&255),ne(B,B.gzhead.time>>24&255),ne(B,B.level===9?2:2<=B.strategy||B.level<2?4:0),ne(B,255&B.gzhead.os),B.gzhead.extra&&B.gzhead.extra.length&&(ne(B,255&B.gzhead.extra.length),ne(B,B.gzhead.extra.length>>8&255)),B.gzhead.hcrc&&(H.adler=u(H.adler,B.pending_buf,B.pending,0)),B.gzindex=0,B.status=69):(ne(B,0),ne(B,0),ne(B,0),ne(B,0),ne(B,0),ne(B,B.level===9?2:2<=B.strategy||B.level<2?4:0),ne(B,3),B.status=q);else{var Ee=S+(B.w_bits-8<<4)<<8;Ee|=(2<=B.strategy||B.level<2?0:B.level<6?1:B.level===6?2:3)<<6,B.strstart!==0&&(Ee|=32),Ee+=31-Ee%31,B.status=q,ie(B,Ee),B.strstart!==0&&(ie(B,H.adler>>>16),ie(B,65535&H.adler)),H.adler=1}if(B.status===69)if(B.gzhead.extra){for(I=B.pending;B.gzindex<(65535&B.gzhead.extra.length)&&(B.pending!==B.pending_buf_size||(B.gzhead.hcrc&&B.pending>I&&(H.adler=u(H.adler,B.pending_buf,B.pending-I,I)),z(H),I=B.pending,B.pending!==B.pending_buf_size));)ne(B,255&B.gzhead.extra[B.gzindex]),B.gzindex++;B.gzhead.hcrc&&B.pending>I&&(H.adler=u(H.adler,B.pending_buf,B.pending-I,I)),B.gzindex===B.gzhead.extra.length&&(B.gzindex=0,B.status=73)}else B.status=73;if(B.status===73)if(B.gzhead.name){I=B.pending;do{if(B.pending===B.pending_buf_size&&(B.gzhead.hcrc&&B.pending>I&&(H.adler=u(H.adler,B.pending_buf,B.pending-I,I)),z(H),I=B.pending,B.pending===B.pending_buf_size)){ce=1;break}ce=B.gzindex<B.gzhead.name.length?255&B.gzhead.name.charCodeAt(B.gzindex++):0,ne(B,ce)}while(ce!==0);B.gzhead.hcrc&&B.pending>I&&(H.adler=u(H.adler,B.pending_buf,B.pending-I,I)),ce===0&&(B.gzindex=0,B.status=91)}else B.status=91;if(B.status===91)if(B.gzhead.comment){I=B.pending;do{if(B.pending===B.pending_buf_size&&(B.gzhead.hcrc&&B.pending>I&&(H.adler=u(H.adler,B.pending_buf,B.pending-I,I)),z(H),I=B.pending,B.pending===B.pending_buf_size)){ce=1;break}ce=B.gzindex<B.gzhead.comment.length?255&B.gzhead.comment.charCodeAt(B.gzindex++):0,ne(B,ce)}while(ce!==0);B.gzhead.hcrc&&B.pending>I&&(H.adler=u(H.adler,B.pending_buf,B.pending-I,I)),ce===0&&(B.status=103)}else B.status=103;if(B.status===103&&(B.gzhead.hcrc?(B.pending+2>B.pending_buf_size&&z(H),B.pending+2<=B.pending_buf_size&&(ne(B,255&H.adler),ne(B,H.adler>>8&255),H.adler=0,B.status=q)):B.status=q),B.pending!==0){if(z(H),H.avail_out===0)return B.last_flush=-1,p}else if(H.avail_in===0&&te(J)<=te(K)&&J!==m)return Z(H,-5);if(B.status===666&&H.avail_in!==0)return Z(H,-5);if(H.avail_in!==0||B.lookahead!==0||J!==f&&B.status!==666){var Ie=B.strategy===2?(function(ue,$){for(var L;;){if(ue.lookahead===0&&(me(ue),ue.lookahead===0)){if($===f)return j;break}if(ue.match_length=0,L=l._tr_tally(ue,0,ue.window[ue.strstart]),ue.lookahead--,ue.strstart++,L&&(V(ue,!1),ue.strm.avail_out===0))return j}return ue.insert=0,$===m?(V(ue,!0),ue.strm.avail_out===0?X:G):ue.last_lit&&(V(ue,!1),ue.strm.avail_out===0)?j:W})(B,J):B.strategy===3?(function(ue,$){for(var L,Y,pe,Se,ae=ue.window;;){if(ue.lookahead<=R){if(me(ue),ue.lookahead<=R&&$===f)return j;if(ue.lookahead===0)break}if(ue.match_length=0,ue.lookahead>=C&&0<ue.strstart&&(Y=ae[pe=ue.strstart-1])===ae[++pe]&&Y===ae[++pe]&&Y===ae[++pe]){Se=ue.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<Se);ue.match_length=R-(Se-pe),ue.match_length>ue.lookahead&&(ue.match_length=ue.lookahead)}if(ue.match_length>=C?(L=l._tr_tally(ue,1,ue.match_length-C),ue.lookahead-=ue.match_length,ue.strstart+=ue.match_length,ue.match_length=0):(L=l._tr_tally(ue,0,ue.window[ue.strstart]),ue.lookahead--,ue.strstart++),L&&(V(ue,!1),ue.strm.avail_out===0))return j}return ue.insert=0,$===m?(V(ue,!0),ue.strm.avail_out===0?X:G):ue.last_lit&&(V(ue,!1),ue.strm.avail_out===0)?j:W})(B,J):a[B.level].func(B,J);if(Ie!==X&&Ie!==G||(B.status=666),Ie===j||Ie===X)return H.avail_out===0&&(B.last_flush=-1),p;if(Ie===W&&(J===1?l._tr_align(B):J!==5&&(l._tr_stored_block(B,0,0,!1),J===3&&(ee(B.head),B.lookahead===0&&(B.strstart=0,B.block_start=0,B.insert=0))),z(H),H.avail_out===0))return B.last_flush=-1,p}return J!==m?p:B.wrap<=0?1:(B.wrap===2?(ne(B,255&H.adler),ne(B,H.adler>>8&255),ne(B,H.adler>>16&255),ne(B,H.adler>>24&255),ne(B,255&H.total_in),ne(B,H.total_in>>8&255),ne(B,H.total_in>>16&255),ne(B,H.total_in>>24&255)):(ie(B,H.adler>>>16),ie(B,65535&H.adler)),z(H),0<B.wrap&&(B.wrap=-B.wrap),B.pending!==0?p:1)},i.deflateEnd=function(H){var J;return H&&H.state?(J=H.state.status)!==O&&J!==69&&J!==73&&J!==91&&J!==103&&J!==q&&J!==666?Z(H,b):(H.state=null,J===q?Z(H,-3):p):b},i.deflateSetDictionary=function(H,J){var K,B,I,ce,Ee,Ie,ue,$,L=J.length;if(!H||!H.state||(ce=(K=H.state).wrap)===2||ce===1&&K.status!==O||K.lookahead)return b;for(ce===1&&(H.adler=c(H.adler,J,L,0)),K.wrap=0,L>=K.w_size&&(ce===0&&(ee(K.head),K.strstart=0,K.block_start=0,K.insert=0),$=new o.Buf8(K.w_size),o.arraySet($,J,L-K.w_size,K.w_size,0),J=$,L=K.w_size),Ee=H.avail_in,Ie=H.next_in,ue=H.input,H.avail_in=L,H.next_in=0,H.input=J,me(K);K.lookahead>=C;){for(B=K.strstart,I=K.lookahead-(C-1);K.ins_h=(K.ins_h<<K.hash_shift^K.window[B+C-1])&K.hash_mask,K.prev[B&K.w_mask]=K.head[K.ins_h],K.head[K.ins_h]=B,B++,--I;);K.strstart=B,K.lookahead=C-1,me(K)}return K.strstart+=K.lookahead,K.block_start=K.strstart,K.insert=K.lookahead,K.lookahead=0,K.match_length=K.prev_length=C-1,K.match_available=0,H.next_in=Ie,H.input=ue,H.avail_in=Ee,K.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,y,x,v,S,M,E,A,k,T,D,C,R,U,O,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,y=l.whave,x=l.wnext,v=l.window,S=l.hold,M=l.bits,E=l.lencode,A=l.distcode,k=(1<<l.lenbits)-1,T=(1<<l.distbits)-1;e:do{M<15&&(S+=j[c++]<<M,M+=8,S+=j[c++]<<M,M+=8),D=E[S&k];t:for(;;){if(S>>>=C=D>>>24,M-=C,(C=D>>>16&255)===0)W[d++]=65535&D;else{if(!(16&C)){if((64&C)==0){D=E[(65535&D)+(S&(1<<C)-1)];continue t}if(32&C){l.mode=12;break e}a.msg="invalid literal/length code",l.mode=30;break e}R=65535&D,(C&=15)&&(M<C&&(S+=j[c++]<<M,M+=8),R+=S&(1<<C)-1,S>>>=C,M-=C),M<15&&(S+=j[c++]<<M,M+=8,S+=j[c++]<<M,M+=8),D=A[S&T];n:for(;;){if(S>>>=C=D>>>24,M-=C,!(16&(C=D>>>16&255))){if((64&C)==0){D=A[(65535&D)+(S&(1<<C)-1)];continue n}a.msg="invalid distance code",l.mode=30;break e}if(U=65535&D,M<(C&=15)&&(S+=j[c++]<<M,(M+=8)<C&&(S+=j[c++]<<M,M+=8)),p<(U+=S&(1<<C)-1)){a.msg="invalid distance too far back",l.mode=30;break e}if(S>>>=C,M-=C,(C=d-f)<U){if(y<(C=U-C)&&l.sane){a.msg="invalid distance too far back",l.mode=30;break e}if(q=v,(O=0)===x){if(O+=b-C,C<R){for(R-=C;W[d++]=v[O++],--C;);O=d-U,q=W}}else if(x<C){if(O+=b+x-C,(C-=x)<R){for(R-=C;W[d++]=v[O++],--C;);if(O=0,x<R){for(R-=C=x;W[d++]=v[O++],--C;);O=d-U,q=W}}}else if(O+=x-C,C<R){for(R-=C;W[d++]=v[O++],--C;);O=d-U,q=W}for(;2<R;)W[d++]=q[O++],W[d++]=q[O++],W[d++]=q[O++],R-=3;R&&(W[d++]=q[O++],1<R&&(W[d++]=q[O++]))}else{for(O=d-U;W[d++]=W[O++],W[d++]=W[O++],W[d++]=W[O++],2<(R-=3););R&&(W[d++]=W[O++],1<R&&(W[d++]=W[O++]))}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,y=852,x=592;function v(O){return(O>>>24&255)+(O>>>8&65280)+((65280&O)<<8)+((255&O)<<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(O){var q;return O&&O.state?(q=O.state,O.total_in=O.total_out=q.total=0,O.msg="",q.wrap&&(O.adler=1&q.wrap),q.mode=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(y),q.distcode=q.distdyn=new a.Buf32(x),q.sane=1,q.back=-1,m):p}function E(O){var q;return O&&O.state?((q=O.state).wsize=0,q.whave=0,q.wnext=0,M(O)):p}function A(O,q){var j,W;return O&&O.state?(W=O.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,E(O))):p}function k(O,q){var j,W;return O?(W=new S,(O.state=W).window=null,(j=A(O,q))!==m&&(O.state=null),j):p}var T,D,C=!0;function R(O){if(C){var q;for(T=new a.Buf32(512),D=new a.Buf32(32),q=0;q<144;)O.lens[q++]=8;for(;q<256;)O.lens[q++]=9;for(;q<280;)O.lens[q++]=7;for(;q<288;)O.lens[q++]=8;for(u(d,O.lens,0,288,T,0,O.work,{bits:9}),q=0;q<32;)O.lens[q++]=5;u(f,O.lens,0,32,D,0,O.work,{bits:5}),C=!1}O.lencode=T,O.lenbits=9,O.distcode=D,O.distbits=5}function U(O,q,j,W){var X,G=O.state;return G.window===null&&(G.wsize=1<<G.wbits,G.wnext=0,G.whave=0,G.window=new a.Buf8(G.wsize)),W>=G.wsize?(a.arraySet(G.window,q,j-G.wsize,G.wsize,0),G.wnext=0,G.whave=G.wsize):(W<(X=G.wsize-G.wnext)&&(X=W),a.arraySet(G.window,q,j-W,X,G.wnext),(W-=X)?(a.arraySet(G.window,q,j-W,W,0),G.wnext=W,G.whave=G.wsize):(G.wnext+=X,G.wnext===G.wsize&&(G.wnext=0),G.whave<G.wsize&&(G.whave+=X))),0}i.inflateReset=E,i.inflateReset2=A,i.inflateResetKeep=M,i.inflateInit=function(O){return k(O,15)},i.inflateInit2=k,i.inflate=function(O,q){var j,W,X,G,Z,te,ee,z,V,ne,ie,he,me,oe,Ae,ge,Ne,_e,le,He,H,J,K,B,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(!O||!O.state||!O.output||!O.input&&O.avail_in!==0)return p;(j=O.state).mode===12&&(j.mode=13),Z=O.next_out,X=O.output,ee=O.avail_out,G=O.next_in,W=O.input,te=O.avail_in,z=j.hold,V=j.bits,ne=te,ie=ee,J=m;e:for(;;)switch(j.mode){case b:if(j.wrap===0){j.mode=13;break}for(;V<16;){if(te===0)break e;te--,z+=W[G++]<<V,V+=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),V=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){O.msg="incorrect header check",j.mode=30;break}if((15&z)!=8){O.msg="unknown compression method",j.mode=30;break}if(V-=4,H=8+(15&(z>>>=4)),j.wbits===0)j.wbits=H;else if(H>j.wbits){O.msg="invalid window size",j.mode=30;break}j.dmax=1<<H,O.adler=j.check=1,j.mode=512&z?10:12,V=z=0;break;case 2:for(;V<16;){if(te===0)break e;te--,z+=W[G++]<<V,V+=8}if(j.flags=z,(255&j.flags)!=8){O.msg="unknown compression method",j.mode=30;break}if(57344&j.flags){O.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)),V=z=0,j.mode=3;case 3:for(;V<32;){if(te===0)break e;te--,z+=W[G++]<<V,V+=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)),V=z=0,j.mode=4;case 4:for(;V<16;){if(te===0)break e;te--,z+=W[G++]<<V,V+=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)),V=z=0,j.mode=5;case 5:if(1024&j.flags){for(;V<16;){if(te===0)break e;te--,z+=W[G++]<<V,V+=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)),V=z=0}else j.head&&(j.head.extra=null);j.mode=6;case 6:if(1024&j.flags&&(te<(he=j.length)&&(he=te),he&&(j.head&&(H=j.head.extra_len-j.length,j.head.extra||(j.head.extra=new Array(j.head.extra_len)),a.arraySet(j.head.extra,W,G,he,H)),512&j.flags&&(j.check=l(j.check,W,he,G)),te-=he,G+=he,j.length-=he),j.length))break e;j.length=0,j.mode=7;case 7:if(2048&j.flags){if(te===0)break e;for(he=0;H=W[G+he++],j.head&&H&&j.length<65536&&(j.head.name+=String.fromCharCode(H)),H&&he<te;);if(512&j.flags&&(j.check=l(j.check,W,he,G)),te-=he,G+=he,H)break e}else j.head&&(j.head.name=null);j.length=0,j.mode=8;case 8:if(4096&j.flags){if(te===0)break e;for(he=0;H=W[G+he++],j.head&&H&&j.length<65536&&(j.head.comment+=String.fromCharCode(H)),H&&he<te;);if(512&j.flags&&(j.check=l(j.check,W,he,G)),te-=he,G+=he,H)break e}else j.head&&(j.head.comment=null);j.mode=9;case 9:if(512&j.flags){for(;V<16;){if(te===0)break e;te--,z+=W[G++]<<V,V+=8}if(z!==(65535&j.check)){O.msg="header crc mismatch",j.mode=30;break}V=z=0}j.head&&(j.head.hcrc=j.flags>>9&1,j.head.done=!0),O.adler=j.check=0,j.mode=12;break;case 10:for(;V<32;){if(te===0)break e;te--,z+=W[G++]<<V,V+=8}O.adler=j.check=v(z),V=z=0,j.mode=11;case 11:if(j.havedict===0)return O.next_out=Z,O.avail_out=ee,O.next_in=G,O.avail_in=te,j.hold=z,j.bits=V,2;O.adler=j.check=1,j.mode=12;case 12:if(q===5||q===6)break e;case 13:if(j.last){z>>>=7&V,V-=7&V,j.mode=27;break}for(;V<3;){if(te===0)break e;te--,z+=W[G++]<<V,V+=8}switch(j.last=1&z,V-=1,3&(z>>>=1)){case 0:j.mode=14;break;case 1:if(R(j),j.mode=20,q!==6)break;z>>>=2,V-=2;break e;case 2:j.mode=17;break;case 3:O.msg="invalid block type",j.mode=30}z>>>=2,V-=2;break;case 14:for(z>>>=7&V,V-=7&V;V<32;){if(te===0)break e;te--,z+=W[G++]<<V,V+=8}if((65535&z)!=(z>>>16^65535)){O.msg="invalid stored block lengths",j.mode=30;break}if(j.length=65535&z,V=z=0,j.mode=15,q===6)break e;case 15:j.mode=16;case 16:if(he=j.length){if(te<he&&(he=te),ee<he&&(he=ee),he===0)break e;a.arraySet(X,W,G,he,Z),te-=he,G+=he,ee-=he,Z+=he,j.length-=he;break}j.mode=12;break;case 17:for(;V<14;){if(te===0)break e;te--,z+=W[G++]<<V,V+=8}if(j.nlen=257+(31&z),z>>>=5,V-=5,j.ndist=1+(31&z),z>>>=5,V-=5,j.ncode=4+(15&z),z>>>=4,V-=4,286<j.nlen||30<j.ndist){O.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(;V<3;){if(te===0)break e;te--,z+=W[G++]<<V,V+=8}j.lens[Ee[j.have++]]=7&z,z>>>=3,V-=3}for(;j.have<19;)j.lens[Ee[j.have++]]=0;if(j.lencode=j.lendyn,j.lenbits=7,K={bits:j.lenbits},J=u(0,j.lens,0,19,j.lencode,0,j.work,K),j.lenbits=K.bits,J){O.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,Ne=65535&I,!((Ae=I>>>24)<=V);){if(te===0)break e;te--,z+=W[G++]<<V,V+=8}if(Ne<16)z>>>=Ae,V-=Ae,j.lens[j.have++]=Ne;else{if(Ne===16){for(B=Ae+2;V<B;){if(te===0)break e;te--,z+=W[G++]<<V,V+=8}if(z>>>=Ae,V-=Ae,j.have===0){O.msg="invalid bit length repeat",j.mode=30;break}H=j.lens[j.have-1],he=3+(3&z),z>>>=2,V-=2}else if(Ne===17){for(B=Ae+3;V<B;){if(te===0)break e;te--,z+=W[G++]<<V,V+=8}V-=Ae,H=0,he=3+(7&(z>>>=Ae)),z>>>=3,V-=3}else{for(B=Ae+7;V<B;){if(te===0)break e;te--,z+=W[G++]<<V,V+=8}V-=Ae,H=0,he=11+(127&(z>>>=Ae)),z>>>=7,V-=7}if(j.have+he>j.nlen+j.ndist){O.msg="invalid bit length repeat",j.mode=30;break}for(;he--;)j.lens[j.have++]=H}}if(j.mode===30)break;if(j.lens[256]===0){O.msg="invalid code -- missing end-of-block",j.mode=30;break}if(j.lenbits=9,K={bits:j.lenbits},J=u(d,j.lens,0,j.nlen,j.lencode,0,j.work,K),j.lenbits=K.bits,J){O.msg="invalid literal/lengths set",j.mode=30;break}if(j.distbits=6,j.distcode=j.distdyn,K={bits:j.distbits},J=u(f,j.lens,j.nlen,j.ndist,j.distcode,0,j.work,K),j.distbits=K.bits,J){O.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<=te&&258<=ee){O.next_out=Z,O.avail_out=ee,O.next_in=G,O.avail_in=te,j.hold=z,j.bits=V,c(O,ie),Z=O.next_out,X=O.output,ee=O.avail_out,G=O.next_in,W=O.input,te=O.avail_in,z=j.hold,V=j.bits,j.mode===12&&(j.back=-1);break}for(j.back=0;ge=(I=j.lencode[z&(1<<j.lenbits)-1])>>>16&255,Ne=65535&I,!((Ae=I>>>24)<=V);){if(te===0)break e;te--,z+=W[G++]<<V,V+=8}if(ge&&(240&ge)==0){for(_e=Ae,le=ge,He=Ne;ge=(I=j.lencode[He+((z&(1<<_e+le)-1)>>_e)])>>>16&255,Ne=65535&I,!(_e+(Ae=I>>>24)<=V);){if(te===0)break e;te--,z+=W[G++]<<V,V+=8}z>>>=_e,V-=_e,j.back+=_e}if(z>>>=Ae,V-=Ae,j.back+=Ae,j.length=Ne,ge===0){j.mode=26;break}if(32&ge){j.back=-1,j.mode=12;break}if(64&ge){O.msg="invalid literal/length code",j.mode=30;break}j.extra=15&ge,j.mode=22;case 22:if(j.extra){for(B=j.extra;V<B;){if(te===0)break e;te--,z+=W[G++]<<V,V+=8}j.length+=z&(1<<j.extra)-1,z>>>=j.extra,V-=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,Ne=65535&I,!((Ae=I>>>24)<=V);){if(te===0)break e;te--,z+=W[G++]<<V,V+=8}if((240&ge)==0){for(_e=Ae,le=ge,He=Ne;ge=(I=j.distcode[He+((z&(1<<_e+le)-1)>>_e)])>>>16&255,Ne=65535&I,!(_e+(Ae=I>>>24)<=V);){if(te===0)break e;te--,z+=W[G++]<<V,V+=8}z>>>=_e,V-=_e,j.back+=_e}if(z>>>=Ae,V-=Ae,j.back+=Ae,64&ge){O.msg="invalid distance code",j.mode=30;break}j.offset=Ne,j.extra=15&ge,j.mode=24;case 24:if(j.extra){for(B=j.extra;V<B;){if(te===0)break e;te--,z+=W[G++]<<V,V+=8}j.offset+=z&(1<<j.extra)-1,z>>>=j.extra,V-=j.extra,j.back+=j.extra}if(j.offset>j.dmax){O.msg="invalid distance too far back",j.mode=30;break}j.mode=25;case 25:if(ee===0)break e;if(he=ie-ee,j.offset>he){if((he=j.offset-he)>j.whave&&j.sane){O.msg="invalid distance too far back",j.mode=30;break}me=he>j.wnext?(he-=j.wnext,j.wsize-he):j.wnext-he,he>j.length&&(he=j.length),oe=j.window}else oe=X,me=Z-j.offset,he=j.length;for(ee<he&&(he=ee),ee-=he,j.length-=he;X[Z++]=oe[me++],--he;);j.length===0&&(j.mode=21);break;case 26:if(ee===0)break e;X[Z++]=j.length,ee--,j.mode=21;break;case 27:if(j.wrap){for(;V<32;){if(te===0)break e;te--,z|=W[G++]<<V,V+=8}if(ie-=ee,O.total_out+=ie,j.total+=ie,ie&&(O.adler=j.check=j.flags?l(j.check,X,ie,Z-ie):o(j.check,X,ie,Z-ie)),ie=ee,(j.flags?z:v(z))!==j.check){O.msg="incorrect data check",j.mode=30;break}V=z=0}j.mode=28;case 28:if(j.wrap&&j.flags){for(;V<32;){if(te===0)break e;te--,z+=W[G++]<<V,V+=8}if(z!==(4294967295&j.total)){O.msg="incorrect length check",j.mode=30;break}V=z=0}j.mode=29;case 29:J=1;break e;case 30:J=-3;break e;case 31:return-4;default:return p}return O.next_out=Z,O.avail_out=ee,O.next_in=G,O.avail_in=te,j.hold=z,j.bits=V,(j.wsize||ie!==O.avail_out&&j.mode<30&&(j.mode<27||q!==4))&&U(O,O.output,O.next_out,ie-O.avail_out)?(j.mode=31,-4):(ne-=O.avail_in,ie-=O.avail_out,O.total_in+=ne,O.total_out+=ie,j.total+=ie,j.wrap&&ie&&(O.adler=j.check=j.flags?l(j.check,X,ie,O.next_out-ie):o(j.check,X,ie,O.next_out-ie)),O.data_type=j.bits+(j.last?64:0)+(j.mode===12?128:0)+(j.mode===20||j.mode===15?256:0),(ne==0&&ie===0||q===4)&&J===m&&(J=-5),J)},i.inflateEnd=function(O){if(!O||!O.state)return p;var q=O.state;return q.window&&(q.window=null),O.state=null,m},i.inflateGetHeader=function(O,q){var j;return O&&O.state?(2&(j=O.state).wrap)==0?p:((j.head=q).done=!1,m):p},i.inflateSetDictionary=function(O,q){var j,W=q.length;return O&&O.state?(j=O.state).wrap!==0&&j.mode!==11?p:j.mode===11&&o(1,q,W,0)!==j.check?-3:U(O,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,y,x,v){var S,M,E,A,k,T,D,C,R,U=v.bits,O=0,q=0,j=0,W=0,X=0,G=0,Z=0,te=0,ee=0,z=0,V=null,ne=0,ie=new a.Buf16(16),he=new a.Buf16(16),me=null,oe=0;for(O=0;O<=15;O++)ie[O]=0;for(q=0;q<p;q++)ie[f[m+q]]++;for(X=U,W=15;1<=W&&ie[W]===0;W--);if(W<X&&(X=W),W===0)return b[y++]=20971520,b[y++]=20971520,v.bits=1,0;for(j=1;j<W&&ie[j]===0;j++);for(X<j&&(X=j),O=te=1;O<=15;O++)if(te<<=1,(te-=ie[O])<0)return-1;if(0<te&&(d===0||W!==1))return-1;for(he[1]=0,O=1;O<15;O++)he[O+1]=he[O]+ie[O];for(q=0;q<p;q++)f[m+q]!==0&&(x[he[f[m+q]]++]=q);if(T=d===0?(V=me=x,19):d===1?(V=o,ne-=257,me=l,oe-=257,256):(V=c,me=u,-1),O=j,k=y,Z=q=z=0,E=-1,A=(ee=1<<(G=X))-1,d===1&&852<ee||d===2&&592<ee)return 1;for(;;){for(D=O-Z,R=x[q]<T?(C=0,x[q]):x[q]>T?(C=me[oe+x[q]],V[ne+x[q]]):(C=96,0),S=1<<O-Z,j=M=1<<G;b[k+(z>>Z)+(M-=S)]=D<<24|C<<16|R|0,M!==0;);for(S=1<<O-1;z&S;)S>>=1;if(S!==0?(z&=S-1,z+=S):z=0,q++,--ie[O]==0){if(O===W)break;O=f[m+x[q]]}if(X<O&&(z&A)!==E){for(Z===0&&(Z=X),k+=j,te=1<<(G=O-Z);G+Z<W&&!((te-=ie[G+Z])<=0);)G++,te<<=1;if(ee+=1<<G,d===1&&852<ee||d===2&&592<ee)return 1;b[E=z&A]=X<<24|G<<16|k-y|0}}return z!==0&&(b[k+z]=O-Z<<24|64<<16|0),v.bits=X,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,y=2*m+1,x=15,v=16,S=7,M=256,E=16,A=17,k=18,T=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],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],C=[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 O=new Array(2*p);c(O);var q=new Array(512);c(q);var j=new Array(256);c(j);var W=new Array(d);c(W);var X,G,Z,te=new Array(p);function ee(I,ce,Ee,Ie,ue){this.static_tree=I,this.extra_bits=ce,this.extra_base=Ee,this.elems=Ie,this.max_length=ue,this.has_stree=I&&I.length}function z(I,ce){this.dyn_tree=I,this.max_code=0,this.stat_desc=ce}function V(I){return I<256?q[I]:q[256+(I>>>7)]}function ne(I,ce){I.pending_buf[I.pending++]=255&ce,I.pending_buf[I.pending++]=ce>>>8&255}function ie(I,ce,Ee){I.bi_valid>v-Ee?(I.bi_buf|=ce<<I.bi_valid&65535,ne(I,I.bi_buf),I.bi_buf=ce>>v-I.bi_valid,I.bi_valid+=Ee-v):(I.bi_buf|=ce<<I.bi_valid&65535,I.bi_valid+=Ee)}function he(I,ce,Ee){ie(I,Ee[2*ce],Ee[2*ce+1])}function me(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,ue,$=new Array(x+1),L=0;for(Ie=1;Ie<=x;Ie++)$[Ie]=L=L+Ee[Ie-1]<<1;for(ue=0;ue<=ce;ue++){var Y=I[2*ue+1];Y!==0&&(I[2*ue]=me($[Y]++,Y))}}function Ae(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?ne(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 Ne(I,ce,Ee,Ie){var ue=2*ce,$=2*Ee;return I[ue]<I[$]||I[ue]===I[$]&&Ie[ce]<=Ie[Ee]}function _e(I,ce,Ee){for(var Ie=I.heap[Ee],ue=Ee<<1;ue<=I.heap_len&&(ue<I.heap_len&&Ne(ce,I.heap[ue+1],I.heap[ue],I.depth)&&ue++,!Ne(ce,Ie,I.heap[ue],I.depth));)I.heap[Ee]=I.heap[ue],Ee=ue,ue<<=1;I.heap[Ee]=Ie}function le(I,ce,Ee){var Ie,ue,$,L,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],ue=I.pending_buf[I.l_buf+Y],Y++,Ie===0?he(I,ue,ce):(he(I,($=j[ue])+f+1,ce),(L=T[$])!==0&&ie(I,ue-=W[$],L),he(I,$=V(--Ie),Ee),(L=D[$])!==0&&ie(I,Ie-=te[$],L)),Y<I.last_lit;);he(I,M,ce)}function He(I,ce){var Ee,Ie,ue,$=ce.dyn_tree,L=ce.stat_desc.static_tree,Y=ce.stat_desc.has_stree,pe=ce.stat_desc.elems,Se=-1;for(I.heap_len=0,I.heap_max=y,Ee=0;Ee<pe;Ee++)$[2*Ee]!==0?(I.heap[++I.heap_len]=Se=Ee,I.depth[Ee]=0):$[2*Ee+1]=0;for(;I.heap_len<2;)$[2*(ue=I.heap[++I.heap_len]=Se<2?++Se:0)]=1,I.depth[ue]=0,I.opt_len--,Y&&(I.static_len-=L[2*ue+1]);for(ce.max_code=Se,Ee=I.heap_len>>1;1<=Ee;Ee--)_e(I,$,Ee);for(ue=pe;Ee=I.heap[1],I.heap[1]=I.heap[I.heap_len--],_e(I,$,1),Ie=I.heap[1],I.heap[--I.heap_max]=Ee,I.heap[--I.heap_max]=Ie,$[2*ue]=$[2*Ee]+$[2*Ie],I.depth[ue]=(I.depth[Ee]>=I.depth[Ie]?I.depth[Ee]:I.depth[Ie])+1,$[2*Ee+1]=$[2*Ie+1]=ue,I.heap[1]=ue++,_e(I,$,1),2<=I.heap_len;);I.heap[--I.heap_max]=I.heap[1],(function(ae,je){var De,Xe,et,Qe,se,ye,ke=je.dyn_tree,Ue=je.max_code,dt=je.stat_desc.static_tree,re=je.stat_desc.has_stree,Fe=je.stat_desc.extra_bits,ve=je.stat_desc.extra_base,$e=je.stat_desc.max_length,Le=0;for(Qe=0;Qe<=x;Qe++)ae.bl_count[Qe]=0;for(ke[2*ae.heap[ae.heap_max]+1]=0,De=ae.heap_max+1;De<y;De++)$e<(Qe=ke[2*ke[2*(Xe=ae.heap[De])+1]+1]+1)&&(Qe=$e,Le++),ke[2*Xe+1]=Qe,Ue<Xe||(ae.bl_count[Qe]++,se=0,ve<=Xe&&(se=Fe[Xe-ve]),ye=ke[2*Xe],ae.opt_len+=ye*(Qe+se),re&&(ae.static_len+=ye*(dt[2*Xe+1]+se)));if(Le!==0){do{for(Qe=$e-1;ae.bl_count[Qe]===0;)Qe--;ae.bl_count[Qe]--,ae.bl_count[Qe+1]+=2,ae.bl_count[$e]--,Le-=2}while(0<Le);for(Qe=$e;Qe!==0;Qe--)for(Xe=ae.bl_count[Qe];Xe!==0;)Ue<(et=ae.heap[--De])||(ke[2*et+1]!==Qe&&(ae.opt_len+=(Qe-ke[2*et+1])*ke[2*et],ke[2*et+1]=Qe),Xe--)}})(I,ce),oe($,Se,I.bl_count)}function H(I,ce,Ee){var Ie,ue,$=-1,L=ce[1],Y=0,pe=7,Se=4;for(L===0&&(pe=138,Se=3),ce[2*(Ee+1)+1]=65535,Ie=0;Ie<=Ee;Ie++)ue=L,L=ce[2*(Ie+1)+1],++Y<pe&&ue===L||(Y<Se?I.bl_tree[2*ue]+=Y:ue!==0?(ue!==$&&I.bl_tree[2*ue]++,I.bl_tree[2*E]++):Y<=10?I.bl_tree[2*A]++:I.bl_tree[2*k]++,$=ue,Se=(Y=0)===L?(pe=138,3):ue===L?(pe=6,3):(pe=7,4))}function J(I,ce,Ee){var Ie,ue,$=-1,L=ce[1],Y=0,pe=7,Se=4;for(L===0&&(pe=138,Se=3),Ie=0;Ie<=Ee;Ie++)if(ue=L,L=ce[2*(Ie+1)+1],!(++Y<pe&&ue===L)){if(Y<Se)for(;he(I,ue,I.bl_tree),--Y!=0;);else ue!==0?(ue!==$&&(he(I,ue,I.bl_tree),Y--),he(I,E,I.bl_tree),ie(I,Y-3,2)):Y<=10?(he(I,A,I.bl_tree),ie(I,Y-3,3)):(he(I,k,I.bl_tree),ie(I,Y-11,7));$=ue,Se=(Y=0)===L?(pe=138,3):ue===L?(pe=6,3):(pe=7,4)}}c(te);var K=!1;function B(I,ce,Ee,Ie){ie(I,(u<<1)+(Ie?1:0),3),(function(ue,$,L,Y){ge(ue),ne(ue,L),ne(ue,~L),a.arraySet(ue.pending_buf,ue.window,$,L,ue.pending),ue.pending+=L})(I,ce,Ee)}i._tr_init=function(I){K||((function(){var ce,Ee,Ie,ue,$,L=new Array(x+1);for(ue=Ie=0;ue<d-1;ue++)for(W[ue]=Ie,ce=0;ce<1<<T[ue];ce++)j[Ie++]=ue;for(j[Ie-1]=ue,ue=$=0;ue<16;ue++)for(te[ue]=$,ce=0;ce<1<<D[ue];ce++)q[$++]=ue;for($>>=7;ue<p;ue++)for(te[ue]=$<<7,ce=0;ce<1<<D[ue]-7;ce++)q[256+$++]=ue;for(Ee=0;Ee<=x;Ee++)L[Ee]=0;for(ce=0;ce<=143;)U[2*ce+1]=8,ce++,L[8]++;for(;ce<=255;)U[2*ce+1]=9,ce++,L[9]++;for(;ce<=279;)U[2*ce+1]=7,ce++,L[7]++;for(;ce<=287;)U[2*ce+1]=8,ce++,L[8]++;for(oe(U,m+1,L),ce=0;ce<p;ce++)O[2*ce+1]=5,O[2*ce]=me(ce,5);X=new ee(U,T,f+1,m,x),G=new ee(O,D,0,p,x),Z=new ee(new Array(0),C,0,b,S)})(),K=!0),I.l_desc=new z(I.dyn_ltree,X),I.d_desc=new z(I.dyn_dtree,G),I.bl_desc=new z(I.bl_tree,Z),I.bi_buf=0,I.bi_valid=0,Ae(I)},i._tr_stored_block=B,i._tr_flush_block=function(I,ce,Ee,Ie){var ue,$,L=0;0<I.level?(I.strm.data_type===2&&(I.strm.data_type=(function(Y){var pe,Se=4093624447;for(pe=0;pe<=31;pe++,Se>>>=1)if(1&Se&&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)),He(I,I.l_desc),He(I,I.d_desc),L=(function(Y){var pe;for(H(Y,Y.dyn_ltree,Y.l_desc.max_code),H(Y,Y.dyn_dtree,Y.d_desc.max_code),He(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),ue=I.opt_len+3+7>>>3,($=I.static_len+3+7>>>3)<=ue&&(ue=$)):ue=$=Ee+5,Ee+4<=ue&&ce!==-1?B(I,ce,Ee,Ie):I.strategy===4||$===ue?(ie(I,2+(Ie?1:0),3),le(I,U,O)):(ie(I,4+(Ie?1:0),3),(function(Y,pe,Se,ae){var je;for(ie(Y,pe-257,5),ie(Y,Se-1,5),ie(Y,ae-4,4),je=0;je<ae;je++)ie(Y,Y.bl_tree[2*R[je]+1],3);J(Y,Y.dyn_ltree,pe-1),J(Y,Y.dyn_dtree,Se-1)})(I,I.l_desc.max_code+1,I.d_desc.max_code+1,L+1),le(I,I.dyn_ltree,I.dyn_dtree)),Ae(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*V(ce)]++),I.last_lit===I.lit_bufsize-1},i._tr_align=function(I){ie(I,2,3),he(I,M,U),(function(ce){ce.bi_valid===16?(ne(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,y=o.document,x=Object.getPrototypeOf&&Object.getPrototypeOf(o);x=x&&x.setTimeout?x:o,c={}.toString.call(o.process)==="[object process]"?function(E){process.nextTick(function(){S(E)})}:(function(){if(o.postMessage&&!o.importScripts){var E=!0,A=o.onmessage;return o.onmessage=function(){E=!1},o.postMessage("","*"),o.onmessage=A,E}})()?(f="setImmediate$"+Math.random()+"$",o.addEventListener?o.addEventListener("message",M,!1):o.attachEvent("onmessage",M),function(E){o.postMessage(f+E,"*")}):o.MessageChannel?((d=new MessageChannel).port1.onmessage=function(E){S(E.data)},function(E){d.port2.postMessage(E)}):y&&"onreadystatechange"in y.createElement("script")?(u=y.documentElement,function(E){var A=y.createElement("script");A.onreadystatechange=function(){S(E),A.onreadystatechange=null,u.removeChild(A),A=null},u.appendChild(A)}):function(E){setTimeout(S,0,E)},x.setImmediate=function(E){typeof E!="function"&&(E=new Function(""+E));for(var A=new Array(arguments.length-1),k=0;k<A.length;k++)A[k]=arguments[k+1];var T={callback:E,args:A};return p[m]=T,c(m),m++},x.clearImmediate=v}function v(E){delete p[E]}function S(E){if(b)setTimeout(S,0,E);else{var A=p[E];if(A){b=!0;try{(function(k){var T=k.callback,D=k.args;switch(D.length){case 0:T();break;case 1:T(D[0]);break;case 2:T(D[0],D[1]);break;case 3:T(D[0],D[1],D[2]);break;default:T.apply(l,D)}})(A)}finally{v(E),b=!1}}}}function M(E){E.source===o&&typeof E.data=="string"&&E.data.indexOf(f)===0&&S(+E.data.slice(f.length))}})(typeof self>"u"?a===void 0?this:a:self)}).call(this,typeof u_<"u"?u_:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(Ak)),Ak.exports}var OIe=DIe();const LIe=ml(OIe);function IIe(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 NG=IIe;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 FIe(t){const e=await LIe.loadAsync(t),n=new Map,r=[],i=new DOMParser;async function a(p){const b=p.startsWith("/")?p.slice(1):p,y=e.files[b];if(!y)return null;const x=await y.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"),y=i.parseFromString(p,"application/xml").getElementsByTagName("object");for(let x=0;x<y.length;x++){const v=y[x],S=v.getAttribute("id");if(!S)continue;const M=Array.from(v.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 E=v.getElementsByTagName("part");for(let A=0;A<E.length;A++){const k=E[A],T=k.getAttribute("id");if(!T)continue;const D=Array.from(k.children).filter(C=>C.tagName==="metadata"&&C.getAttribute("key")==="extruder");if(D.length>0){const C=D[0].getAttribute("value");C&&l.set(`${S}:${T}`,Math.max(0,parseInt(C,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 y=await EG(b,0);y.length>0&&n.set("1",{id:"1",meshes:y,defaultExtruder:0})}}return{objects:n,buildItems:r}}const d=await a(u);if(!d)return{objects:n,buildItems:r};const f=d.getElementsByTagName("object");for(let p=0;p<f.length;p++){const b=f[p],y=b.getAttribute("id");if(!y)continue;let x=o.get(y)??-1;if(x<0){const E=b.getAttribute("p:extruder")||b.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","extruder")||"1";x=Math.max(0,parseInt(E,10)-1)}const v=[],S=b.getElementsByTagName("mesh");for(let E=0;E<S.length;E++){const A=S[E],k=[],T=[],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 C=A.getElementsByTagName("triangle");for(let R=0;R<C.length;R++){const U=C[R];T.push(parseInt(U.getAttribute("v1")||"0"),parseInt(U.getAttribute("v2")||"0"),parseInt(U.getAttribute("v3")||"0"))}k.length>0&&T.length>0&&v.push({vertices:k,triangles:T,extruder:x})}const M=b.getElementsByTagName("component");for(let E=0;E<M.length;E++){const A=M[E],k=A.getAttribute("p:path")||A.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","path"),T=A.getAttribute("objectid");if(k){const D=await a(k);if(D){const C=T?`${y}:${T}`:null,R=C?l.get(C)??x:x,U=await EG(D,R),O=A.getAttribute("transform"),q=NG(O);for(const j of U)if(O){const W=[];for(let X=0;X<j.vertices.length;X+=3){const G=new nt(j.vertices[X],j.vertices[X+1],j.vertices[X+2]);G.applyMatrix4(q),W.push(G.x,G.y,G.z)}v.push({vertices:W,triangles:j.triangles,extruder:j.extruder})}else v.push(j)}}}v.length>0&&n.set(y,{id:y,meshes:v,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 y=p[b],x=y.getAttribute("objectid");if(!x)continue;const v=NG(y.getAttribute("transform"));r.push({objectId:x,transform:v})}}return{objects:n,buildItems:r}}function AG(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 UIe({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 y=i.current,x=y.clientWidth,v=y.clientHeight,S=new aRe;S.background=new Rn(1710618),o.current=S;const M=new So(45,x/v,.1,1e4);M.position.set(150,150,150),l.current=M;const E=new bIe({antialias:!0});E.setSize(x,v),E.setPixelRatio(window.devicePixelRatio),y.appendChild(E.domElement),a.current=E;const A=new vIe(M,E.domElement);A.enableDamping=!0,A.dampingFactor=.05,c.current=A;const k=new yRe(16777215,.6);S.add(k);const T=new XV(16777215,.8);T.position.set(100,100,100),S.add(T);const D=new XV(16777215,.4);D.position.set(-100,50,-100),S.add(D);const C=Math.max(e.x,e.y),R=Math.ceil(C/16),U=new _Re(C,R,4473924,3355443);S.add(U);const O=new uL(e.x,e.y),q=new oL({color:44610,transparent:!0,opacity:.15,side:Il}),j=new hl(O,q);j.rotation.x=-Math.PI/2,j.position.y=-.5,S.add(j);let W;const X=()=>{W=requestAnimationFrame(X),A.update(),E.render(S,M)};X(),fetch(t).then(Z=>{if(!Z.ok)throw new Error("Failed to load file");return Z.arrayBuffer()}).then(FIe).then(({objects:Z,buildItems:te})=>{if(Z.size===0)throw new Error("No meshes found in 3MF file");const ee=Ne=>{const le=n?.[Ne]||"#00ae42",He=new Rn(le);return new mRe({color:He,shininess:30,flatShading:!1})},z=new Hb,V=new Map;if(te.length>0)for(const Ne of te){const _e=Z.get(Ne.objectId);if(_e)for(const le of _e.meshes){const He=Ne.extruder??le.extruder,H=[];for(let K=0;K<le.vertices.length;K+=3){const B=new nt(le.vertices[K],le.vertices[K+1],le.vertices[K+2]);B.applyMatrix4(Ne.transform),H.push(B.x,B.y,B.z)}const J=AG({vertices:H,triangles:le.triangles});V.has(He)||V.set(He,[]),V.get(He).push(J)}}else for(const Ne of Z.values())for(const _e of Ne.meshes){const le=_e.extruder,He=AG(_e);V.has(le)||V.set(le,[]),V.get(le).push(He)}for(const[Ne,_e]of V){if(_e.length===0)continue;const le=_e.length===1?_e[0]:RIe(_e,!1);if(le){const He=ee(Ne),H=new hl(le,He);z.add(H)}if(_e.length>1)for(const He of _e)He.dispose()}const ne=new em().setFromObject(z),ie=ne.getCenter(new nt);z.position.y=-ne.min.y,te.length===0&&(z.position.x=-ie.x,z.position.z=-ie.z),S.add(z);const he=new em().setFromObject(z),me=he.getCenter(new nt),oe=he.getSize(new nt),ge=Math.max(oe.x,oe.y,oe.z)*1.8;M.position.set(me.x+ge*.7,me.y+ge*.5,me.z+ge*.7),A.target.copy(me),A.update(),d(!1)}).catch(Z=>{m(Z.message),d(!1)});const G=()=>{if(!y)return;const Z=y.clientWidth,te=y.clientHeight;M.aspect=Z/te,M.updateProjectionMatrix(),E.setSize(Z,te)};return window.addEventListener("resize",G),()=>{window.removeEventListener("resize",G),cancelAnimationFrame(W),A.dispose(),E.dispose(),y.removeChild(E.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=y=>{l.current&&l.current.position.multiplyScalar(y)};return s.jsxs("div",{className:`relative ${r}`,children:[s.jsx("div",{ref:i,className:"w-full h-full min-h-[400px]"}),u&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:s.jsx(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(VD,{className:"w-4 h-4"})}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>b(1.25),children:s.jsx(GD,{className:"w-4 h-4"})}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:p,children:s.jsx(cm,{className:"w-4 h-4"})})]})]})}const fE="159",mp={ROTATE:0,DOLLY:1,PAN:2},pp={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},zIe=0,TG=1,BIe=2,Lee=1,$Ie=2,Vc=3,nh=0,Ss=1,Yc=2,$d=0,og=1,CG=2,kG=3,jG=4,HIe=5,nf=100,VIe=101,GIe=102,PG=103,RG=104,WIe=200,qIe=201,KIe=202,XIe=203,_R=204,wR=205,YIe=206,QIe=207,ZIe=208,JIe=209,eFe=210,tFe=211,nFe=212,rFe=213,iFe=214,aFe=0,sFe=1,oFe=2,GS=3,lFe=4,cFe=5,uFe=6,dFe=7,fL=0,hFe=1,fFe=2,Hd=0,mFe=1,pFe=2,gFe=3,xFe=4,bFe=5,Iee=300,Pg=301,Rg=302,SR=303,MR=304,mE=306,NR=1e3,el=1001,ER=1002,ya=1003,DG=1004,Tk=1005,Mo=1006,yFe=1007,Q0=1008,Vd=1009,vFe=1010,_Fe=1011,mL=1012,Fee=1013,jd=1014,tu=1015,Z0=1016,Uee=1017,zee=1018,Af=1020,wFe=1021,No=1023,SFe=1024,MFe=1025,Tf=1026,Dg=1027,NFe=1028,Bee=1029,EFe=1030,$ee=1031,Hee=1033,Ck=33776,kk=33777,jk=33778,Pk=33779,OG=35840,LG=35841,IG=35842,FG=35843,Vee=36196,UG=37492,zG=37496,BG=37808,$G=37809,HG=37810,VG=37811,GG=37812,WG=37813,qG=37814,KG=37815,XG=37816,YG=37817,QG=37818,ZG=37819,JG=37820,e7=37821,Rk=36492,t7=36494,n7=36495,AFe=36283,r7=36284,i7=36285,a7=36286,Gee=3e3,Cf=3001,TFe=3200,CFe=3201,Wee=0,kFe=1,Eo="",va="srgb",wu="srgb-linear",pL="display-p3",pE="display-p3-linear",WS="linear",Dr="srgb",qS="rec709",KS="p3",gp=7680,s7=519,jFe=512,PFe=513,RFe=514,qee=515,DFe=516,OFe=517,LFe=518,IFe=519,AR=35044,o7="300 es",TR=1035,Vl=2e3,J0=2001;class fm{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 l7=1234567;const i0=Math.PI/180,ey=180/Math.PI;function lu(){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 _a(t,e,n){return Math.max(e,Math.min(n,t))}function gL(t,e){return(t%e+e)%e}function FFe(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)}function UFe(t,e,n){return t!==e?(n-t)/(e-t):0}function a0(t,e,n){return(1-n)*t+n*e}function zFe(t,e,n,r){return a0(t,e,1-Math.exp(-n*r))}function BFe(t,e=1){return e-Math.abs(gL(t,e*2)-e)}function $Fe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*(3-2*t))}function HFe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*t*(t*(t*6-15)+10))}function VFe(t,e){return t+Math.floor(Math.random()*(e-t+1))}function GFe(t,e){return t+Math.random()*(e-t)}function WFe(t){return t*(.5-Math.random())}function qFe(t){t!==void 0&&(l7=t);let e=l7+=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 KFe(t){return t*i0}function XFe(t){return t*ey}function CR(t){return(t&t-1)===0&&t!==0}function YFe(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function XS(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function QFe(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 Kee={DEG2RAD:i0,RAD2DEG:ey,generateUUID:lu,clamp:_a,euclideanModulo:gL,mapLinear:FFe,inverseLerp:UFe,lerp:a0,damp:zFe,pingpong:BFe,smoothstep:$Fe,smootherstep:HFe,randInt:VFe,randFloat:GFe,randFloatSpread:WFe,seededRandom:qFe,degToRad:KFe,radToDeg:XFe,isPowerOfTwo:CR,ceilPowerOfTwo:YFe,floorPowerOfTwo:XS,setQuaternionFromProperEuler:QFe,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(_a(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],y=i[0],x=i[3],v=i[6],S=i[1],M=i[4],E=i[7],A=i[2],k=i[5],T=i[8];return a[0]=o*y+l*S+c*A,a[3]=o*x+l*M+c*k,a[6]=o*v+l*E+c*T,a[1]=u*y+d*S+f*A,a[4]=u*x+d*M+f*k,a[7]=u*v+d*E+f*T,a[2]=m*y+p*S+b*A,a[5]=m*x+p*M+b*k,a[8]=m*v+p*E+b*T,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8];return n*o*d-n*l*u-r*a*d+r*l*c+i*a*u-i*o*c}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=d*o-l*u,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 y=1/b;return e[0]=f*y,e[1]=(i*u-d*r)*y,e[2]=(l*r-i*o)*y,e[3]=m*y,e[4]=(d*n-i*c)*y,e[5]=(i*a-l*n)*y,e[6]=p*y,e[7]=(r*c-u*n)*y,e[8]=(o*n-r*a)*y,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,i,a,o,l){const c=Math.cos(a),u=Math.sin(a);return this.set(r*c,r*u,-r*(c*o+u*l)+o+e,-i*u,i*c,-i*(-u*o+c*l)+l+n,0,0,1),this}scale(e,n){return this.premultiply(Dk.makeScale(e,n)),this}rotate(e){return this.premultiply(Dk.makeRotation(-e)),this}translate(e,n){return this.premultiply(Dk.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 Dk=new An;function Xee(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function YS(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function ZFe(){const t=YS("canvas");return t.style.display="block",t}const c7={};function s0(t){t in c7||(c7[t]=!0,console.warn(t))}const u7=new An().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),d7=new An().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),n1={[wu]:{transfer:WS,primaries:qS,toReference:t=>t,fromReference:t=>t},[va]:{transfer:Dr,primaries:qS,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[pE]:{transfer:WS,primaries:KS,toReference:t=>t.applyMatrix3(d7),fromReference:t=>t.applyMatrix3(u7)},[pL]:{transfer:Dr,primaries:KS,toReference:t=>t.convertSRGBToLinear().applyMatrix3(d7),fromReference:t=>t.applyMatrix3(u7).convertLinearToSRGB()}},JFe=new Set([wu,pE]),pr={enabled:!0,_workingColorSpace:wu,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(!JFe.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=n1[e].toReference,i=n1[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 n1[t].primaries},getTransfer:function(t){return t===Eo?WS:n1[t].transfer}};function lg(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function Ok(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let xp;class Yee{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{xp===void 0&&(xp=YS("canvas")),xp.width=e.width,xp.height=e.height;const r=xp.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=xp}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=YS("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]=lg(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(lg(n[r]/255)*255):n[r]=lg(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 e5e=0;class Qee{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:e5e++}),this.uuid=lu(),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(Lk(i[o].image)):a.push(Lk(i[o]))}else a=Lk(i);r.url=a}return n||(e.images[this.uuid]=r),r}}function Lk(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?Yee.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 t5e=0;class Ms extends fm{constructor(e=Ms.DEFAULT_IMAGE,n=Ms.DEFAULT_MAPPING,r=el,i=el,a=Mo,o=Q0,l=No,c=Vd,u=Ms.DEFAULT_ANISOTROPY,d=Eo){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:t5e++}),this.uuid=lu(),this.name="",this.source=new Qee(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:(s0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=d===Cf?va:Eo),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!==Iee)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case NR:e.x=e.x-Math.floor(e.x);break;case el: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 NR:e.y=e.y-Math.floor(e.y);break;case el: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 s0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===va?Cf:Gee}set encoding(e){s0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===Cf?va:Eo}}Ms.DEFAULT_IMAGE=null;Ms.DEFAULT_MAPPING=Iee;Ms.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],y=c[2],x=c[6],v=c[10];if(Math.abs(d-m)<.01&&Math.abs(f-y)<.01&&Math.abs(b-x)<.01){if(Math.abs(d+m)<.1&&Math.abs(f+y)<.1&&Math.abs(b+x)<.1&&Math.abs(u+p+v-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const M=(u+1)/2,E=(p+1)/2,A=(v+1)/2,k=(d+m)/4,T=(f+y)/4,D=(b+x)/4;return M>E&&M>A?M<.01?(r=0,i=.707106781,a=.707106781):(r=Math.sqrt(M),i=k/r,a=T/r):E>A?E<.01?(r=.707106781,i=0,a=.707106781):(i=Math.sqrt(E),r=k/i,a=D/i):A<.01?(r=.707106781,i=.707106781,a=0):(a=Math.sqrt(A),r=T/a,i=D/a),this.set(r,i,a,n),this}let S=Math.sqrt((x-b)*(x-b)+(f-y)*(f-y)+(m-d)*(m-d));return Math.abs(S)<.001&&(S=1),this.x=(x-b)/S,this.y=(f-y)/S,this.z=(m-d)/S,this.w=Math.acos((u+p+v-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this.w=Math.max(e.w,Math.min(n.w,this.w)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this.w=Math.max(e,Math.min(n,this.w)),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this.w+=(e.w-this.w)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this.w=e.w+(n.w-e.w)*r,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this.w=e[n+3],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e[n+3]=this.w,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this.w=e.getW(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class n5e extends fm{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&&(s0("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),r.colorSpace=r.encoding===Cf?va:Eo),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Mo,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},r),this.texture=new Ms(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 Qee(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 tm extends n5e{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}}class Zee extends Ms{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=ya,this.minFilter=ya,this.wrapR=el,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class r5e extends Ms{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=ya,this.minFilter=ya,this.wrapR=el,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class nm{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],y=a[o+3];if(l===0){e[n+0]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f;return}if(l===1){e[n+0]=m,e[n+1]=p,e[n+2]=b,e[n+3]=y;return}if(f!==y||c!==m||u!==p||d!==b){let x=1-l;const v=c*m+u*p+d*b+f*y,S=v>=0?1:-1,M=1-v*v;if(M>Number.EPSILON){const A=Math.sqrt(M),k=Math.atan2(A,v*S);x=Math.sin(x*k)/A,l=Math.sin(l*k)/A}const E=l*S;if(c=c*x+m*E,u=u*x+p*E,d=d*x+b*E,f=f*x+y*E,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(_a(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(h7.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(h7.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 Ik.copy(this).projectOnVector(e),this.sub(Ik)}reflect(e){return this.sub(Ik.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(_a(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 Ik=new Be,h7=new nm;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(qo.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(qo.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=qo.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,qo):qo.fromBufferAttribute(a,o),qo.applyMatrix4(e.matrixWorld),this.expandByPoint(qo);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),r1.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),r1.copy(r.boundingBox)),r1.applyMatrix4(e.matrixWorld),this.union(r1)}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,qo),qo.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),i1.subVectors(this.max,Eb),bp.subVectors(e.a,Eb),yp.subVectors(e.b,Eb),vp.subVectors(e.c,Eb),sd.subVectors(yp,bp),od.subVectors(vp,yp),Hh.subVectors(bp,vp);let n=[0,-sd.z,sd.y,0,-od.z,od.y,0,-Hh.z,Hh.y,sd.z,0,-sd.x,od.z,0,-od.x,Hh.z,0,-Hh.x,-sd.y,sd.x,0,-od.y,od.x,0,-Hh.y,Hh.x,0];return!Fk(n,bp,yp,vp,i1)||(n=[1,0,0,0,1,0,0,0,1],!Fk(n,bp,yp,vp,i1))?!1:(a1.crossVectors(sd,od),n=[a1.x,a1.y,a1.z],Fk(n,bp,yp,vp,i1))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,qo).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(qo).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],qo=new Be,r1=new ko,bp=new Be,yp=new Be,vp=new Be,sd=new Be,od=new Be,Hh=new Be,Eb=new Be,i1=new Be,a1=new Be,Vh=new Be;function Fk(t,e,n,r,i){for(let a=0,o=t.length-3;a<=o;a+=3){Vh.fromArray(t,a);const l=i.x*Math.abs(Vh.x)+i.y*Math.abs(Vh.y)+i.z*Math.abs(Vh.z),c=e.dot(Vh),u=n.dot(Vh),d=r.dot(Vh);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>l)return!1}return!0}const i5e=new ko,Ab=new Be,Uk=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):i5e.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;Ab.subVectors(e,this.center);const n=Ab.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(Ab,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):(Uk.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Ab.copy(e.center).add(Uk)),this.expandByPoint(Ab.copy(e.center).sub(Uk))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Lc=new Be,zk=new Be,s1=new Be,ld=new Be,Bk=new Be,o1=new Be,$k=new Be;class xL{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){zk.copy(e).add(n).multiplyScalar(.5),s1.copy(n).sub(e).normalize(),ld.copy(this.origin).sub(zk);const a=e.distanceTo(n)*.5,o=-this.direction.dot(s1),l=ld.dot(this.direction),c=-ld.dot(s1),u=ld.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 y=1/d;f*=y,m*=y,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(zk).addScaledVector(s1,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){Bk.subVectors(n,e),o1.subVectors(r,e),$k.crossVectors(Bk,o1);let o=this.direction.dot($k),l;if(o>0){if(i)return null;l=1}else if(o<0)l=-1,o=-o;else return null;ld.subVectors(this.origin,e);const c=l*this.direction.dot(o1.crossVectors(ld,o1));if(c<0)return null;const u=l*this.direction.dot(Bk.cross(ld));if(u<0||c+u>o)return null;const d=-l*ld.dot($k);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,y,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,y,x)}set(e,n,r,i,a,o,l,c,u,d,f,m,p,b,y,x){const v=this.elements;return v[0]=e,v[4]=n,v[8]=r,v[12]=i,v[1]=a,v[5]=o,v[9]=l,v[13]=c,v[2]=u,v[6]=d,v[10]=f,v[14]=m,v[3]=p,v[7]=b,v[11]=y,v[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/_p.setFromMatrixColumn(e,0).length(),a=1/_p.setFromMatrixColumn(e,1).length(),o=1/_p.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,y=l*f;n[0]=c*d,n[4]=-c*f,n[8]=u,n[1]=p+b*u,n[5]=m-y*u,n[9]=-l*c,n[2]=y-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,y=u*f;n[0]=m+y*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]=y+m*l,n[10]=o*c}else if(e.order==="ZXY"){const m=c*d,p=c*f,b=u*d,y=u*f;n[0]=m-y*l,n[4]=-o*f,n[8]=b+p*l,n[1]=p+b*l,n[5]=o*d,n[9]=y-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,y=l*f;n[0]=c*d,n[4]=b*u-p,n[8]=m*u+y,n[1]=c*f,n[5]=y*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,y=l*u;n[0]=c*d,n[4]=y-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-y*f}else if(e.order==="XZY"){const m=o*c,p=o*u,b=l*c,y=l*u;n[0]=c*d,n[4]=-f,n[8]=u*d,n[1]=m*f+y,n[5]=o*d,n[9]=p*f-b,n[2]=b*f-p,n[6]=l*d,n[10]=y*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(a5e,e,s5e)}lookAt(e,n,r){const i=this.elements;return Fs.subVectors(e,n),Fs.lengthSq()===0&&(Fs.z=1),Fs.normalize(),cd.crossVectors(r,Fs),cd.lengthSq()===0&&(Math.abs(r.z)===1?Fs.x+=1e-4:Fs.z+=1e-4,Fs.normalize(),cd.crossVectors(r,Fs)),cd.normalize(),l1.crossVectors(Fs,cd),i[0]=cd.x,i[4]=l1.x,i[8]=Fs.x,i[1]=cd.y,i[5]=l1.y,i[9]=Fs.y,i[2]=cd.z,i[6]=l1.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],y=r[6],x=r[10],v=r[14],S=r[3],M=r[7],E=r[11],A=r[15],k=i[0],T=i[4],D=i[8],C=i[12],R=i[1],U=i[5],O=i[9],q=i[13],j=i[2],W=i[6],X=i[10],G=i[14],Z=i[3],te=i[7],ee=i[11],z=i[15];return a[0]=o*k+l*R+c*j+u*Z,a[4]=o*T+l*U+c*W+u*te,a[8]=o*D+l*O+c*X+u*ee,a[12]=o*C+l*q+c*G+u*z,a[1]=d*k+f*R+m*j+p*Z,a[5]=d*T+f*U+m*W+p*te,a[9]=d*D+f*O+m*X+p*ee,a[13]=d*C+f*q+m*G+p*z,a[2]=b*k+y*R+x*j+v*Z,a[6]=b*T+y*U+x*W+v*te,a[10]=b*D+y*O+x*X+v*ee,a[14]=b*C+y*q+x*G+v*z,a[3]=S*k+M*R+E*j+A*Z,a[7]=S*T+M*U+E*W+A*te,a[11]=S*D+M*O+E*X+A*ee,a[15]=S*C+M*q+E*G+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],y=e[7],x=e[11],v=e[15];return b*(+a*c*f-i*u*f-a*l*m+r*u*m+i*l*p-r*c*p)+y*(+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)+v*(-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],y=e[13],x=e[14],v=e[15],S=f*x*u-y*m*u+y*c*p-l*x*p-f*c*v+l*m*v,M=b*m*u-d*x*u-b*c*p+o*x*p+d*c*v-o*m*v,E=d*y*u-b*f*u+b*l*p-o*y*p-d*l*v+o*f*v,A=b*f*c-d*y*c-b*l*m+o*y*m+d*l*x-o*f*x,k=n*S+r*M+i*E+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 T=1/k;return e[0]=S*T,e[1]=(y*m*a-f*x*a-y*i*p+r*x*p+f*i*v-r*m*v)*T,e[2]=(l*x*a-y*c*a+y*i*u-r*x*u-l*i*v+r*c*v)*T,e[3]=(f*c*a-l*m*a-f*i*u+r*m*u+l*i*p-r*c*p)*T,e[4]=M*T,e[5]=(d*x*a-b*m*a+b*i*p-n*x*p-d*i*v+n*m*v)*T,e[6]=(b*c*a-o*x*a-b*i*u+n*x*u+o*i*v-n*c*v)*T,e[7]=(o*m*a-d*c*a+d*i*u-n*m*u-o*i*p+n*c*p)*T,e[8]=E*T,e[9]=(b*f*a-d*y*a-b*r*p+n*y*p+d*r*v-n*f*v)*T,e[10]=(o*y*a-b*l*a+b*r*u-n*y*u-o*r*v+n*l*v)*T,e[11]=(d*l*a-o*f*a-d*r*u+n*f*u+o*r*p-n*l*p)*T,e[12]=A*T,e[13]=(d*y*i-b*f*i+b*r*m-n*y*m-d*r*x+n*f*x)*T,e[14]=(b*l*i-o*y*i-b*r*c+n*y*c+o*r*x-n*l*x)*T,e[15]=(o*f*i-d*l*i+d*r*c-n*f*c-o*r*m+n*l*m)*T,this}scale(e){const n=this.elements,r=e.x,i=e.y,a=e.z;return n[0]*=r,n[4]*=i,n[8]*=a,n[1]*=r,n[5]*=i,n[9]*=a,n[2]*=r,n[6]*=i,n[10]*=a,n[3]*=r,n[7]*=i,n[11]*=a,this}getMaxScaleOnAxis(){const e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,r,i))}makeTranslation(e,n,r){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,n,0,0,1,r,0,0,0,1),this}makeRotationX(e){const n=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,n,-r,0,0,r,n,0,0,0,0,1),this}makeRotationY(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,0,r,0,0,1,0,0,-r,0,n,0,0,0,0,1),this}makeRotationZ(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,0,r,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){const r=Math.cos(n),i=Math.sin(n),a=1-r,o=e.x,l=e.y,c=e.z,u=a*o,d=a*l;return this.set(u*o+r,u*l-i*c,u*c+i*l,0,u*l+i*c,d*l+r,d*c-i*o,0,u*c-i*l,d*c+i*o,a*c*c+r,0,0,0,0,1),this}makeScale(e,n,r){return this.set(e,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,n,r,i,a,o){return this.set(1,r,a,0,e,1,o,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,a=n._x,o=n._y,l=n._z,c=n._w,u=a+a,d=o+o,f=l+l,m=a*u,p=a*d,b=a*f,y=o*d,x=o*f,v=l*f,S=c*u,M=c*d,E=c*f,A=r.x,k=r.y,T=r.z;return i[0]=(1-(y+v))*A,i[1]=(p+E)*A,i[2]=(b-M)*A,i[3]=0,i[4]=(p-E)*k,i[5]=(1-(m+v))*k,i[6]=(x+S)*k,i[7]=0,i[8]=(b+M)*T,i[9]=(x-S)*T,i[10]=(1-(m+y))*T,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,n,r){const i=this.elements;let a=_p.set(i[0],i[1],i[2]).length();const o=_p.set(i[4],i[5],i[6]).length(),l=_p.set(i[8],i[9],i[10]).length();this.determinant()<0&&(a=-a),e.x=i[12],e.y=i[13],e.z=i[14],Ko.copy(this);const u=1/a,d=1/o,f=1/l;return Ko.elements[0]*=u,Ko.elements[1]*=u,Ko.elements[2]*=u,Ko.elements[4]*=d,Ko.elements[5]*=d,Ko.elements[6]*=d,Ko.elements[8]*=f,Ko.elements[9]*=f,Ko.elements[10]*=f,n.setFromRotationMatrix(Ko),r.x=a,r.y=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===J0)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,y;if(l===Vl)b=(o+a)*f,y=-2*f;else if(l===J0)b=a*f,y=-1*f;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+l);return c[0]=2*u,c[4]=0,c[8]=0,c[12]=-m,c[1]=0,c[5]=2*d,c[9]=0,c[13]=-p,c[2]=0,c[6]=0,c[10]=y,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 _p=new Be,Ko=new Tr,a5e=new Be(0,0,0),s5e=new Be(1,1,1),cd=new Be,l1=new Be,Fs=new Be,f7=new Tr,m7=new nm;class Gy{constructor(e=0,n=0,r=0,i=Gy.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(_a(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(-_a(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(_a(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(-_a(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(_a(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(-_a(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 f7.makeRotationFromQuaternion(e),this.setFromRotationMatrix(f7,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return m7.setFromEuler(this),this.setFromQuaternion(m7,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}}Gy.DEFAULT_ORDER="XYZ";class Jee{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 o5e=0;const p7=new Be,wp=new nm,Ic=new Tr,c1=new Be,Tb=new Be,l5e=new Be,c5e=new nm,g7=new Be(1,0,0),x7=new Be(0,1,0),b7=new Be(0,0,1),u5e={type:"added"},d5e={type:"removed"};class es extends fm{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:o5e++}),this.uuid=lu(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=es.DEFAULT_UP.clone();const e=new Be,n=new Gy,r=new nm,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 Jee,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 wp.setFromAxisAngle(e,n),this.quaternion.multiply(wp),this}rotateOnWorldAxis(e,n){return wp.setFromAxisAngle(e,n),this.quaternion.premultiply(wp),this}rotateX(e){return this.rotateOnAxis(g7,e)}rotateY(e){return this.rotateOnAxis(x7,e)}rotateZ(e){return this.rotateOnAxis(b7,e)}translateOnAxis(e,n){return p7.copy(e).applyQuaternion(this.quaternion),this.position.add(p7.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(g7,e)}translateY(e){return this.translateOnAxis(x7,e)}translateZ(e){return this.translateOnAxis(b7,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?c1.copy(e):c1.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),Tb.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ic.lookAt(Tb,c1,this.up):Ic.lookAt(c1,Tb,this.up),this.quaternion.setFromRotationMatrix(Ic),i&&(Ic.extractRotation(i.matrixWorld),wp.setFromRotationMatrix(Ic),this.quaternion.premultiply(wp.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(u5e)):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(d5e)),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(Tb,e,l5e),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Tb,c5e,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 Xo=new Be,Fc=new Be,Hk=new Be,Uc=new Be,Sp=new Be,Mp=new Be,y7=new Be,Vk=new Be,Gk=new Be,Wk=new Be;let u1=!1;class Yo{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),Xo.subVectors(e,n),i.cross(Xo);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){Xo.subVectors(i,n),Fc.subVectors(r,n),Hk.subVectors(e,n);const o=Xo.dot(Xo),l=Xo.dot(Fc),c=Xo.dot(Hk),u=Fc.dot(Fc),d=Fc.dot(Hk),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 u1===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),u1=!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 Xo.subVectors(r,n),Fc.subVectors(e,n),Xo.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 Xo.subVectors(this.c,this.b),Fc.subVectors(this.a,this.b),Xo.cross(Fc).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Yo.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return Yo.getBarycoord(e,this.a,this.b,this.c,n)}getUV(e,n,r,i,a){return u1===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),u1=!0),Yo.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}getInterpolation(e,n,r,i,a){return Yo.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}containsPoint(e){return Yo.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Yo.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;Sp.subVectors(i,r),Mp.subVectors(a,r),Vk.subVectors(e,r);const c=Sp.dot(Vk),u=Mp.dot(Vk);if(c<=0&&u<=0)return n.copy(r);Gk.subVectors(e,i);const d=Sp.dot(Gk),f=Mp.dot(Gk);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(Sp,o);Wk.subVectors(e,a);const p=Sp.dot(Wk),b=Mp.dot(Wk);if(b>=0&&p<=b)return n.copy(a);const y=p*u-c*b;if(y<=0&&u>=0&&b<=0)return l=u/(u-b),n.copy(r).addScaledVector(Mp,l);const x=d*b-p*f;if(x<=0&&f-d>=0&&p-b>=0)return y7.subVectors(a,i),l=(f-d)/(f-d+(p-b)),n.copy(i).addScaledVector(y7,l);const v=1/(x+y+m);return o=y*v,l=m*v,n.copy(r).addScaledVector(Sp,o).addScaledVector(Mp,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const ete={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},ud={h:0,s:0,l:0},d1={h:0,s:0,l:0};function qk(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=va){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=gL(e,1),n=_a(n,0,1),r=_a(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=qk(o,a,e+1/3),this.g=qk(o,a,e),this.b=qk(o,a,e-1/3)}return pr.toWorkingColorSpace(this,i),this}setStyle(e,n=va){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=va){const r=ete[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=lg(e.r),this.g=lg(e.g),this.b=lg(e.b),this}copyLinearToSRGB(e){return this.r=Ok(e.r),this.g=Ok(e.g),this.b=Ok(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=va){return pr.fromWorkingColorSpace(Ra.copy(this),e),Math.round(_a(Ra.r*255,0,255))*65536+Math.round(_a(Ra.g*255,0,255))*256+Math.round(_a(Ra.b*255,0,255))}getHexString(e=va){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=va){pr.fromWorkingColorSpace(Ra.copy(this),e);const n=Ra.r,r=Ra.g,i=Ra.b;return e!==va?`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(ud),this.setHSL(ud.h+e,ud.s+n,ud.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(ud),e.getHSL(d1);const r=a0(ud.h,d1.h,n),i=a0(ud.s,d1.s,n),a=a0(ud.l,d1.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=ete;let h5e=0;class dx extends fm{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:h5e++}),this.uuid=lu(),this.name="",this.type="Material",this.blending=og,this.side=nh,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=_R,this.blendDst=wR,this.blendEquation=nf,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new rn(0,0,0),this.blendAlpha=0,this.depthFunc=GS,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=s7,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=gp,this.stencilZFail=gp,this.stencilZPass=gp,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!==og&&(r.blending=this.blending),this.side!==nh&&(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!==_R&&(r.blendSrc=this.blendSrc),this.blendDst!==wR&&(r.blendDst=this.blendDst),this.blendEquation!==nf&&(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!==GS&&(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!==s7&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==gp&&(r.stencilFail=this.stencilFail),this.stencilZFail!==gp&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==gp&&(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 tte extends dx{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=fL,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,h1=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=AR,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=tu,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++)h1.fromBufferAttribute(this,n),h1.applyMatrix3(e),this.setXY(n,h1.x,h1.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!==AR&&(e.usage=this.usage),e}}class nte extends Xs{constructor(e,n,r){super(new Uint16Array(e),n,r)}}class rte 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 f5e=0;const mo=new Tr,Kk=new es,Np=new Be,Us=new ko,Cb=new ko,qi=new Be;class Ha extends fm{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:f5e++}),this.uuid=lu(),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(Xee(e)?rte:nte)(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 Kk.lookAt(e),Kk.updateMatrix(),this.applyMatrix4(Kk.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Np).negate(),this.translate(Np.x,Np.y,Np.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];Cb.setFromBufferAttribute(l),this.morphTargetsRelative?(qi.addVectors(Us.min,Cb.min),Us.expandByPoint(qi),qi.addVectors(Us.max,Cb.max),Us.expandByPoint(qi)):(Us.expandByPoint(Cb.min),Us.expandByPoint(Cb.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&&(Np.fromBufferAttribute(e,u),qi.add(Np)),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,y=new mn,x=new mn,v=new Be,S=new Be;function M(R,U,O){f.fromArray(i,R*3),m.fromArray(i,U*3),p.fromArray(i,O*3),b.fromArray(o,R*2),y.fromArray(o,U*2),x.fromArray(o,O*2),m.sub(f),p.sub(f),y.sub(b),x.sub(b);const q=1/(y.x*x.y-x.x*y.y);isFinite(q)&&(v.copy(m).multiplyScalar(x.y).addScaledVector(p,-y.y).multiplyScalar(q),S.copy(p).multiplyScalar(y.x).addScaledVector(m,-x.x).multiplyScalar(q),u[R].add(v),u[U].add(v),u[O].add(v),d[R].add(S),d[U].add(S),d[O].add(S))}let E=this.groups;E.length===0&&(E=[{start:0,count:r.length}]);for(let R=0,U=E.length;R<U;++R){const O=E[R],q=O.start,j=O.count;for(let W=q,X=q+j;W<X;W+=3)M(r[W+0],r[W+1],r[W+2])}const A=new Be,k=new Be,T=new Be,D=new Be;function C(R){T.fromArray(a,R*3),D.copy(T);const U=u[R];A.copy(U),A.sub(T.multiplyScalar(T.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=E.length;R<U;++R){const O=E[R],q=O.start,j=O.count;for(let W=q,X=q+j;W<X;W+=3)C(r[W+0]),C(r[W+1]),C(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),y=e.getX(m+1),x=e.getX(m+2);i.fromBufferAttribute(n,b),a.fromBufferAttribute(n,y),o.fromBufferAttribute(n,x),d.subVectors(o,a),f.subVectors(i,a),d.cross(f),l.fromBufferAttribute(r,b),c.fromBufferAttribute(r,y),u.fromBufferAttribute(r,x),l.add(d),c.add(d),u.add(d),r.setXYZ(b,l.x,l.y,l.z),r.setXYZ(y,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 y=0,x=c.length;y<x;y++){l.isInterleavedBufferAttribute?p=c[y]*l.data.stride+l.offset:p=c[y]*d;for(let v=0;v<d;v++)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 v7=new Tr,Gh=new xL,f1=new Xl,_7=new Be,Ep=new Be,Ap=new Be,Tp=new Be,Xk=new Be,m1=new Be,p1=new mn,g1=new mn,x1=new mn,w7=new Be,S7=new Be,M7=new Be,b1=new Be,y1=new Be;class rl extends es{constructor(e=new Ha,n=new tte){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){m1.set(0,0,0);for(let c=0,u=a.length;c<u;c++){const d=l[c],f=a[c];d!==0&&(Xk.fromBufferAttribute(f,e),o?m1.addScaledVector(Xk,d):m1.addScaledVector(Xk.sub(n),d))}n.add(m1)}return n}raycast(e,n){const r=this.geometry,i=this.material,a=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),f1.copy(r.boundingSphere),f1.applyMatrix4(a),Gh.copy(e.ray).recast(e.near),!(f1.containsPoint(Gh.origin)===!1&&(Gh.intersectSphere(f1,_7)===null||Gh.origin.distanceToSquared(_7)>(e.far-e.near)**2))&&(v7.copy(a).invert(),Gh.copy(e.ray).applyMatrix4(v7),!(r.boundingBox!==null&&Gh.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,Gh)))}_computeIntersections(e,n,r){let i;const a=this.geometry,o=this.material,l=a.index,c=a.attributes.position,u=a.attributes.uv,d=a.attributes.uv1,f=a.attributes.normal,m=a.groups,p=a.drawRange;if(l!==null)if(Array.isArray(o))for(let b=0,y=m.length;b<y;b++){const x=m[b],v=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 E=S,A=M;E<A;E+=3){const k=l.getX(E),T=l.getX(E+1),D=l.getX(E+2);i=v1(this,v,e,r,u,d,f,k,T,D),i&&(i.faceIndex=Math.floor(E/3),i.face.materialIndex=x.materialIndex,n.push(i))}}else{const b=Math.max(0,p.start),y=Math.min(l.count,p.start+p.count);for(let x=b,v=y;x<v;x+=3){const S=l.getX(x),M=l.getX(x+1),E=l.getX(x+2);i=v1(this,o,e,r,u,d,f,S,M,E),i&&(i.faceIndex=Math.floor(x/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(o))for(let b=0,y=m.length;b<y;b++){const x=m[b],v=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 E=S,A=M;E<A;E+=3){const k=E,T=E+1,D=E+2;i=v1(this,v,e,r,u,d,f,k,T,D),i&&(i.faceIndex=Math.floor(E/3),i.face.materialIndex=x.materialIndex,n.push(i))}}else{const b=Math.max(0,p.start),y=Math.min(c.count,p.start+p.count);for(let x=b,v=y;x<v;x+=3){const S=x,M=x+1,E=x+2;i=v1(this,o,e,r,u,d,f,S,M,E),i&&(i.faceIndex=Math.floor(x/3),n.push(i))}}}}function m5e(t,e,n,r,i,a,o,l){let c;if(e.side===Ss?c=r.intersectTriangle(o,a,i,!0,l):c=r.intersectTriangle(i,a,o,e.side===nh,l),c===null)return null;y1.copy(l),y1.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(y1);return u<n.near||u>n.far?null:{distance:u,point:y1.clone(),object:t}}function v1(t,e,n,r,i,a,o,l,c,u){t.getVertexPosition(l,Ep),t.getVertexPosition(c,Ap),t.getVertexPosition(u,Tp);const d=m5e(t,e,n,r,Ep,Ap,Tp,b1);if(d){i&&(p1.fromBufferAttribute(i,l),g1.fromBufferAttribute(i,c),x1.fromBufferAttribute(i,u),d.uv=Yo.getInterpolation(b1,Ep,Ap,Tp,p1,g1,x1,new mn)),a&&(p1.fromBufferAttribute(a,l),g1.fromBufferAttribute(a,c),x1.fromBufferAttribute(a,u),d.uv1=Yo.getInterpolation(b1,Ep,Ap,Tp,p1,g1,x1,new mn),d.uv2=d.uv1),o&&(w7.fromBufferAttribute(o,l),S7.fromBufferAttribute(o,c),M7.fromBufferAttribute(o,u),d.normal=Yo.getInterpolation(b1,Ep,Ap,Tp,w7,S7,M7,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};Yo.getNormal(Ep,Ap,Tp,f.normal),d.face=f}return d}class Wy 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(y,x,v,S,M,E,A,k,T,D,C){const R=E/T,U=A/D,O=E/2,q=A/2,j=k/2,W=T+1,X=D+1;let G=0,Z=0;const te=new Be;for(let ee=0;ee<X;ee++){const z=ee*U-q;for(let V=0;V<W;V++){const ne=V*R-O;te[y]=ne*S,te[x]=z*M,te[v]=j,u.push(te.x,te.y,te.z),te[y]=0,te[x]=0,te[v]=k>0?1:-1,d.push(te.x,te.y,te.z),f.push(V/T),f.push(1-ee/D),G+=1}}for(let ee=0;ee<D;ee++)for(let z=0;z<T;z++){const V=m+z+W*ee,ne=m+z+W*(ee+1),ie=m+(z+1)+W*(ee+1),he=m+(z+1)+W*ee;c.push(V,ne,he),c.push(ne,ie,he),Z+=6}l.addGroup(p,Z,C),p+=Z,m+=G}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Wy(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Og(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=Og(t[n]);for(const i in r)e[i]=r[i]}return e}function p5e(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function ite(t){return t.getRenderTarget()===null?t.outputColorSpace:pr.workingColorSpace}const bL={clone:Og,merge:Ka};var g5e=`void main() {
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
- }`,x5e=`void main() {
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
- }`;class rh extends dx{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=g5e,this.fragmentShader=x5e,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=Og(e.uniforms),this.uniformsGroups=p5e(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 ate 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 ate{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=ey*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(i0*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return ey*2*Math.atan(Math.tan(i0*.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(i0*.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 Cp=-90,kp=1;class b5e extends es{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new zs(Cp,kp,e,n);i.layers=this.layers,this.add(i);const a=new zs(Cp,kp,e,n);a.layers=this.layers,this.add(a);const o=new zs(Cp,kp,e,n);o.layers=this.layers,this.add(o);const l=new zs(Cp,kp,e,n);l.layers=this.layers,this.add(l);const c=new zs(Cp,kp,e,n);c.layers=this.layers,this.add(c);const u=new zs(Cp,kp,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===J0)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 y=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(n,a),e.setRenderTarget(r,1,i),e.render(n,o),e.setRenderTarget(r,2,i),e.render(n,l),e.setRenderTarget(r,3,i),e.render(n,c),e.setRenderTarget(r,4,i),e.render(n,u),r.texture.generateMipmaps=y,e.setRenderTarget(r,5,i),e.render(n,d),e.setRenderTarget(f,m,p),e.xr.enabled=b,r.texture.needsPMREMUpdate=!0}}class ste extends Ms{constructor(e,n,r,i,a,o,l,c,u,d){e=e!==void 0?e:[],n=n!==void 0?n:Pg,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 y5e extends tm{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&&(s0("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===Cf?va:Eo),this.texture=new ste(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:`
- varying vec3 vWorldDirection;
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
- }
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }
- `,fragmentShader:`
- uniform sampler2D tEquirect;
- varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vec3 direction = normalize( vWorldDirection );
- vec2 sampleUV = equirectUv( direction );
- gl_FragColor = texture2D( tEquirect, sampleUV );
- }
- `},i=new Wy(5,5,5),a=new rh({name:"CubemapFromEquirect",uniforms:Og(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:Ss,blending:$d});a.uniforms.tEquirect.value=n;const o=new rl(i,a),l=n.minFilter;return n.minFilter===Q0&&(n.minFilter=Mo),new b5e(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 Yk=new Be,v5e=new Be,_5e=new An;class yd{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=Yk.subVectors(r,n).cross(v5e.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(Yk),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||_5e.getNormalMatrix(e),i=this.coplanarPoint(Yk).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 Wh=new Xl,_1=new Be;class gE{constructor(e=new yd,n=new yd,r=new yd,i=new yd,a=new yd,o=new yd){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],y=i[10],x=i[11],v=i[12],S=i[13],M=i[14],E=i[15];if(r[0].setComponents(c-a,m-u,x-p,E-v).normalize(),r[1].setComponents(c+a,m+u,x+p,E+v).normalize(),r[2].setComponents(c+o,m+d,x+b,E+S).normalize(),r[3].setComponents(c-o,m-d,x-b,E-S).normalize(),r[4].setComponents(c-l,m-f,x-y,E-M).normalize(),n===Vl)r[5].setComponents(c+l,m+f,x+y,E+M).normalize();else if(n===J0)r[5].setComponents(l,f,y,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(),Wh.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Wh.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Wh)}intersectsSprite(e){return Wh.center.set(0,0,0),Wh.radius=.7071067811865476,Wh.applyMatrix4(e.matrixWorld),this.intersectsSphere(Wh)}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(_1.x=i.normal.x>0?e.max.x:e.min.x,_1.y=i.normal.y>0?e.max.y:e.min.y,_1.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(_1)<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 ote(){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 w5e(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 y;if(f instanceof Float32Array)y=t.FLOAT;else if(f instanceof Uint16Array)if(u.isFloat16BufferAttribute)if(n)y=t.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else y=t.UNSIGNED_SHORT;else if(f instanceof Int16Array)y=t.SHORT;else if(f instanceof Uint32Array)y=t.UNSIGNED_INT;else if(f instanceof Int32Array)y=t.INT;else if(f instanceof Int8Array)y=t.BYTE;else if(f instanceof Uint8Array)y=t.UNSIGNED_BYTE;else if(f instanceof Uint8ClampedArray)y=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+f);return{buffer:b,type:y,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 y=0,x=b.length;y<x;y++){const v=b[y];n?t.bufferSubData(f,v.start*m.BYTES_PER_ELEMENT,m,v.start,v.count):t.bufferSubData(f,v.start*m.BYTES_PER_ELEMENT,m.subarray(v.start,v.start+v.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 yL 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=[],y=[],x=[];for(let v=0;v<d;v++){const S=v*m-o;for(let M=0;M<u;M++){const E=M*f-a;b.push(E,-S,0),y.push(0,0,1),x.push(M/l),x.push(1-v/c)}}for(let v=0;v<c;v++)for(let S=0;S<l;S++){const M=S+u*v,E=S+u*(v+1),A=S+1+u*(v+1),k=S+1+u*v;p.push(M,E,k),p.push(E,A,k)}this.setIndex(p),this.setAttribute("position",new pi(b,3)),this.setAttribute("normal",new pi(y,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 yL(e.width,e.height,e.widthSegments,e.heightSegments)}}var S5e=`#ifdef USE_ALPHAHASH
- if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
- #endif`,M5e=`#ifdef USE_ALPHAHASH
- const float ALPHA_HASH_SCALE = 0.05;
- float hash2D( vec2 value ) {
- return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
- }
- float hash3D( vec3 value ) {
- return hash2D( vec2( hash2D( value.xy ), value.z ) );
- }
- float getAlphaHashThreshold( vec3 position ) {
- float maxDeriv = max(
- length( dFdx( position.xyz ) ),
- length( dFdy( position.xyz ) )
- );
- float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
- vec2 pixScales = vec2(
- exp2( floor( log2( pixScale ) ) ),
- exp2( ceil( log2( pixScale ) ) )
- );
- vec2 alpha = vec2(
- hash3D( floor( pixScales.x * position.xyz ) ),
- hash3D( floor( pixScales.y * position.xyz ) )
- );
- float lerpFactor = fract( log2( pixScale ) );
- float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
- float a = min( lerpFactor, 1.0 - lerpFactor );
- vec3 cases = vec3(
- x * x / ( 2.0 * a * ( 1.0 - a ) ),
- ( x - 0.5 * a ) / ( 1.0 - a ),
- 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
- );
- float threshold = ( x < ( 1.0 - a ) )
- ? ( ( x < a ) ? cases.x : cases.y )
- : cases.z;
- return clamp( threshold , 1.0e-6, 1.0 );
- }
- #endif`,N5e=`#ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
- #endif`,E5e=`#ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,A5e=`#ifdef USE_ALPHATEST
- if ( diffuseColor.a < alphaTest ) discard;
- #endif`,T5e=`#ifdef USE_ALPHATEST
- uniform float alphaTest;
- #endif`,C5e=`#ifdef USE_AOMAP
- float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
- reflectedLight.indirectDiffuse *= ambientOcclusion;
- #if defined( USE_CLEARCOAT )
- clearcoatSpecularIndirect *= ambientOcclusion;
- #endif
- #if defined( USE_SHEEN )
- sheenSpecularIndirect *= ambientOcclusion;
- #endif
- #if defined( USE_ENVMAP ) && defined( STANDARD )
- float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
- reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
- #endif
- #endif`,k5e=`#ifdef USE_AOMAP
- uniform sampler2D aoMap;
- uniform float aoMapIntensity;
- #endif`,j5e=`#ifdef USE_BATCHING
- attribute float batchId;
- uniform highp sampler2D batchingTexture;
- mat4 getBatchingMatrix( const in float i ) {
- int size = textureSize( batchingTexture, 0 ).x;
- int j = int( i ) * 4;
- int x = j % size;
- int y = j / size;
- vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
- vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
- vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
- vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
- return mat4( v1, v2, v3, v4 );
- }
- #endif`,P5e=`#ifdef USE_BATCHING
- mat4 batchingMatrix = getBatchingMatrix( batchId );
- #endif`,R5e=`vec3 transformed = vec3( position );
- #ifdef USE_ALPHAHASH
- vPosition = vec3( position );
- #endif`,D5e=`vec3 objectNormal = vec3( normal );
- #ifdef USE_TANGENT
- vec3 objectTangent = vec3( tangent.xyz );
- #endif`,O5e=`float G_BlinnPhong_Implicit( ) {
- return 0.25;
- }
- float D_BlinnPhong( const in float shininess, const in float dotNH ) {
- return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
- }
- vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( specularColor, 1.0, dotVH );
- float G = G_BlinnPhong_Implicit( );
- float D = D_BlinnPhong( shininess, dotNH );
- return F * ( G * D );
- } // validated`,L5e=`#ifdef USE_IRIDESCENCE
- const mat3 XYZ_TO_REC709 = mat3(
- 3.2404542, -0.9692660, 0.0556434,
- -1.5371385, 1.8760108, -0.2040259,
- -0.4985314, 0.0415560, 1.0572252
- );
- vec3 Fresnel0ToIor( vec3 fresnel0 ) {
- vec3 sqrtF0 = sqrt( fresnel0 );
- return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
- }
- vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
- return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
- }
- float IorToFresnel0( float transmittedIor, float incidentIor ) {
- return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
- }
- vec3 evalSensitivity( float OPD, vec3 shift ) {
- float phase = 2.0 * PI * OPD * 1.0e-9;
- vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
- vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
- vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
- vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
- xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
- xyz /= 1.0685e-7;
- vec3 rgb = XYZ_TO_REC709 * xyz;
- return rgb;
- }
- vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
- vec3 I;
- float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
- float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
- float cosTheta2Sq = 1.0 - sinTheta2Sq;
- if ( cosTheta2Sq < 0.0 ) {
- return vec3( 1.0 );
- }
- float cosTheta2 = sqrt( cosTheta2Sq );
- float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
- float R12 = F_Schlick( R0, 1.0, cosTheta1 );
- float T121 = 1.0 - R12;
- float phi12 = 0.0;
- if ( iridescenceIOR < outsideIOR ) phi12 = PI;
- float phi21 = PI - phi12;
- vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
- vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
- vec3 phi23 = vec3( 0.0 );
- if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
- if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
- if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
- float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
- vec3 phi = vec3( phi21 ) + phi23;
- vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
- vec3 r123 = sqrt( R123 );
- vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
- vec3 C0 = R12 + Rs;
- I = C0;
- vec3 Cm = Rs - T121;
- for ( int m = 1; m <= 2; ++ m ) {
- Cm *= r123;
- vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
- I += Cm * Sm;
- }
- return max( I, vec3( 0.0 ) );
- }
- #endif`,I5e=`#ifdef USE_BUMPMAP
- uniform sampler2D bumpMap;
- uniform float bumpScale;
- vec2 dHdxy_fwd() {
- vec2 dSTdx = dFdx( vBumpMapUv );
- vec2 dSTdy = dFdy( vBumpMapUv );
- float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
- float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
- float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
- return vec2( dBx, dBy );
- }
- vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
- vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
- vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
- vec3 vN = surf_norm;
- vec3 R1 = cross( vSigmaY, vN );
- vec3 R2 = cross( vN, vSigmaX );
- float fDet = dot( vSigmaX, R1 ) * faceDirection;
- vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
- return normalize( abs( fDet ) * surf_norm - vGrad );
- }
- #endif`,F5e=`#if NUM_CLIPPING_PLANES > 0
- vec4 plane;
- #pragma unroll_loop_start
- for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
- }
- #pragma unroll_loop_end
- #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
- bool clipped = true;
- #pragma unroll_loop_start
- for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
- }
- #pragma unroll_loop_end
- if ( clipped ) discard;
- #endif
- #endif`,U5e=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
- #endif`,z5e=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- #endif`,B5e=`#if NUM_CLIPPING_PLANES > 0
- vClipPosition = - mvPosition.xyz;
- #endif`,$5e=`#if defined( USE_COLOR_ALPHA )
- diffuseColor *= vColor;
- #elif defined( USE_COLOR )
- diffuseColor.rgb *= vColor;
- #endif`,H5e=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR )
- varying vec3 vColor;
- #endif`,V5e=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
- varying vec3 vColor;
- #endif`,G5e=`#if defined( USE_COLOR_ALPHA )
- vColor = vec4( 1.0 );
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
- vColor = vec3( 1.0 );
- #endif
- #ifdef USE_COLOR
- vColor *= color;
- #endif
- #ifdef USE_INSTANCING_COLOR
- vColor.xyz *= instanceColor.xyz;
- #endif`,W5e=`#define PI 3.141592653589793
- #define PI2 6.283185307179586
- #define PI_HALF 1.5707963267948966
- #define RECIPROCAL_PI 0.3183098861837907
- #define RECIPROCAL_PI2 0.15915494309189535
- #define EPSILON 1e-6
- #ifndef saturate
- #define saturate( a ) clamp( a, 0.0, 1.0 )
- #endif
- #define whiteComplement( a ) ( 1.0 - saturate( a ) )
- float pow2( const in float x ) { return x*x; }
- vec3 pow2( const in vec3 x ) { return x*x; }
- float pow3( const in float x ) { return x*x*x; }
- float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
- float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
- float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
- highp float rand( const in vec2 uv ) {
- const highp float a = 12.9898, b = 78.233, c = 43758.5453;
- highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
- return fract( sin( sn ) * c );
- }
- #ifdef HIGH_PRECISION
- float precisionSafeLength( vec3 v ) { return length( v ); }
- #else
- float precisionSafeLength( vec3 v ) {
- float maxComponent = max3( abs( v ) );
- return length( v / maxComponent ) * maxComponent;
- }
- #endif
- struct IncidentLight {
- vec3 color;
- vec3 direction;
- bool visible;
- };
- struct ReflectedLight {
- vec3 directDiffuse;
- vec3 directSpecular;
- vec3 indirectDiffuse;
- vec3 indirectSpecular;
- };
- #ifdef USE_ALPHAHASH
- varying vec3 vPosition;
- #endif
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
- }
- vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
- }
- mat3 transposeMat3( const in mat3 m ) {
- mat3 tmp;
- tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
- tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
- tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
- return tmp;
- }
- float luminance( const in vec3 rgb ) {
- const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );
- return dot( weights, rgb );
- }
- bool isPerspectiveMatrix( mat4 m ) {
- return m[ 2 ][ 3 ] == - 1.0;
- }
- vec2 equirectUv( in vec3 dir ) {
- float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
- float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
- return vec2( u, v );
- }
- vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
- return RECIPROCAL_PI * diffuseColor;
- }
- vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
- }
- float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
- } // validated`,q5e=`#ifdef ENVMAP_TYPE_CUBE_UV
- #define cubeUV_minMipLevel 4.0
- #define cubeUV_minTileSize 16.0
- float getFace( vec3 direction ) {
- vec3 absDirection = abs( direction );
- float face = - 1.0;
- if ( absDirection.x > absDirection.z ) {
- if ( absDirection.x > absDirection.y )
- face = direction.x > 0.0 ? 0.0 : 3.0;
- else
- face = direction.y > 0.0 ? 1.0 : 4.0;
- } else {
- if ( absDirection.z > absDirection.y )
- face = direction.z > 0.0 ? 2.0 : 5.0;
- else
- face = direction.y > 0.0 ? 1.0 : 4.0;
- }
- return face;
- }
- vec2 getUV( vec3 direction, float face ) {
- vec2 uv;
- if ( face == 0.0 ) {
- uv = vec2( direction.z, direction.y ) / abs( direction.x );
- } else if ( face == 1.0 ) {
- uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
- } else if ( face == 2.0 ) {
- uv = vec2( - direction.x, direction.y ) / abs( direction.z );
- } else if ( face == 3.0 ) {
- uv = vec2( - direction.z, direction.y ) / abs( direction.x );
- } else if ( face == 4.0 ) {
- uv = vec2( - direction.x, direction.z ) / abs( direction.y );
- } else {
- uv = vec2( direction.x, direction.y ) / abs( direction.z );
- }
- return 0.5 * ( uv + 1.0 );
- }
- vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
- float face = getFace( direction );
- float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
- mipInt = max( mipInt, cubeUV_minMipLevel );
- float faceSize = exp2( mipInt );
- highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
- if ( face > 2.0 ) {
- uv.y += faceSize;
- face -= 3.0;
- }
- uv.x += face * faceSize;
- uv.x += filterInt * 3.0 * cubeUV_minTileSize;
- uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
- uv.x *= CUBEUV_TEXEL_WIDTH;
- uv.y *= CUBEUV_TEXEL_HEIGHT;
- #ifdef texture2DGradEXT
- return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
- #else
- return texture2D( envMap, uv ).rgb;
- #endif
- }
- #define cubeUV_r0 1.0
- #define cubeUV_v0 0.339
- #define cubeUV_m0 - 2.0
- #define cubeUV_r1 0.8
- #define cubeUV_v1 0.276
- #define cubeUV_m1 - 1.0
- #define cubeUV_r4 0.4
- #define cubeUV_v4 0.046
- #define cubeUV_m4 2.0
- #define cubeUV_r5 0.305
- #define cubeUV_v5 0.016
- #define cubeUV_m5 3.0
- #define cubeUV_r6 0.21
- #define cubeUV_v6 0.0038
- #define cubeUV_m6 4.0
- float roughnessToMip( float roughness ) {
- float mip = 0.0;
- if ( roughness >= cubeUV_r1 ) {
- mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
- } else if ( roughness >= cubeUV_r4 ) {
- mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
- } else if ( roughness >= cubeUV_r5 ) {
- mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
- } else if ( roughness >= cubeUV_r6 ) {
- mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
- } else {
- mip = - 2.0 * log2( 1.16 * roughness ); }
- return mip;
- }
- vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
- float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
- float mipF = fract( mip );
- float mipInt = floor( mip );
- vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
- if ( mipF == 0.0 ) {
- return vec4( color0, 1.0 );
- } else {
- vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
- return vec4( mix( color0, color1, mipF ), 1.0 );
- }
- }
- #endif`,K5e=`vec3 transformedNormal = objectNormal;
- #ifdef USE_TANGENT
- vec3 transformedTangent = objectTangent;
- #endif
- #ifdef USE_BATCHING
- mat3 bm = mat3( batchingMatrix );
- transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
- transformedNormal = bm * transformedNormal;
- #ifdef USE_TANGENT
- transformedTangent = bm * transformedTangent;
- #endif
- #endif
- #ifdef USE_INSTANCING
- mat3 im = mat3( instanceMatrix );
- transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
- transformedNormal = im * transformedNormal;
- #ifdef USE_TANGENT
- transformedTangent = im * transformedTangent;
- #endif
- #endif
- transformedNormal = normalMatrix * transformedNormal;
- #ifdef FLIP_SIDED
- transformedNormal = - transformedNormal;
- #endif
- #ifdef USE_TANGENT
- transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
- #ifdef FLIP_SIDED
- transformedTangent = - transformedTangent;
- #endif
- #endif`,X5e=`#ifdef USE_DISPLACEMENTMAP
- uniform sampler2D displacementMap;
- uniform float displacementScale;
- uniform float displacementBias;
- #endif`,Y5e=`#ifdef USE_DISPLACEMENTMAP
- transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
- #endif`,Q5e=`#ifdef USE_EMISSIVEMAP
- vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
- totalEmissiveRadiance *= emissiveColor.rgb;
- #endif`,Z5e=`#ifdef USE_EMISSIVEMAP
- uniform sampler2D emissiveMap;
- #endif`,J5e="gl_FragColor = linearToOutputTexel( gl_FragColor );",eUe=`
- const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(
- vec3( 0.8224621, 0.177538, 0.0 ),
- vec3( 0.0331941, 0.9668058, 0.0 ),
- vec3( 0.0170827, 0.0723974, 0.9105199 )
- );
- const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(
- vec3( 1.2249401, - 0.2249404, 0.0 ),
- vec3( - 0.0420569, 1.0420571, 0.0 ),
- vec3( - 0.0196376, - 0.0786361, 1.0982735 )
- );
- vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {
- return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );
- }
- vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {
- return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );
- }
- vec4 LinearTransferOETF( in vec4 value ) {
- return value;
- }
- vec4 sRGBTransferOETF( in vec4 value ) {
- return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
- }
- vec4 LinearToLinear( in vec4 value ) {
- return value;
- }
- vec4 LinearTosRGB( in vec4 value ) {
- return sRGBTransferOETF( value );
- }`,tUe=`#ifdef USE_ENVMAP
- #ifdef ENV_WORLDPOS
- vec3 cameraToFrag;
- if ( isOrthographic ) {
- cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
- } else {
- cameraToFrag = normalize( vWorldPosition - cameraPosition );
- }
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- #ifdef ENVMAP_MODE_REFLECTION
- vec3 reflectVec = reflect( cameraToFrag, worldNormal );
- #else
- vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
- #endif
- #else
- vec3 reflectVec = vReflect;
- #endif
- #ifdef ENVMAP_TYPE_CUBE
- vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
- #else
- vec4 envColor = vec4( 0.0 );
- #endif
- #ifdef ENVMAP_BLENDING_MULTIPLY
- outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
- #elif defined( ENVMAP_BLENDING_MIX )
- outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
- #elif defined( ENVMAP_BLENDING_ADD )
- outgoingLight += envColor.xyz * specularStrength * reflectivity;
- #endif
- #endif`,nUe=`#ifdef USE_ENVMAP
- uniform float envMapIntensity;
- uniform float flipEnvMap;
- #ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #else
- uniform sampler2D envMap;
- #endif
-
- #endif`,rUe=`#ifdef USE_ENVMAP
- uniform float reflectivity;
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
- #define ENV_WORLDPOS
- #endif
- #ifdef ENV_WORLDPOS
- varying vec3 vWorldPosition;
- uniform float refractionRatio;
- #else
- varying vec3 vReflect;
- #endif
- #endif`,iUe=`#ifdef USE_ENVMAP
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
- #define ENV_WORLDPOS
- #endif
- #ifdef ENV_WORLDPOS
-
- varying vec3 vWorldPosition;
- #else
- varying vec3 vReflect;
- uniform float refractionRatio;
- #endif
- #endif`,aUe=`#ifdef USE_ENVMAP
- #ifdef ENV_WORLDPOS
- vWorldPosition = worldPosition.xyz;
- #else
- vec3 cameraToVertex;
- if ( isOrthographic ) {
- cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
- } else {
- cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
- }
- vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
- #ifdef ENVMAP_MODE_REFLECTION
- vReflect = reflect( cameraToVertex, worldNormal );
- #else
- vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
- #endif
- #endif
- #endif`,sUe=`#ifdef USE_FOG
- vFogDepth = - mvPosition.z;
- #endif`,oUe=`#ifdef USE_FOG
- varying float vFogDepth;
- #endif`,lUe=`#ifdef USE_FOG
- #ifdef FOG_EXP2
- float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
- #else
- float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
- #endif
- gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
- #endif`,cUe=`#ifdef USE_FOG
- uniform vec3 fogColor;
- varying float vFogDepth;
- #ifdef FOG_EXP2
- uniform float fogDensity;
- #else
- uniform float fogNear;
- uniform float fogFar;
- #endif
- #endif`,uUe=`#ifdef USE_GRADIENTMAP
- uniform sampler2D gradientMap;
- #endif
- vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
- float dotNL = dot( normal, lightDirection );
- vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
- #ifdef USE_GRADIENTMAP
- return vec3( texture2D( gradientMap, coord ).r );
- #else
- vec2 fw = fwidth( coord ) * 0.5;
- return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
- #endif
- }`,dUe=`#ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
- reflectedLight.indirectDiffuse += lightMapIrradiance;
- #endif`,hUe=`#ifdef USE_LIGHTMAP
- uniform sampler2D lightMap;
- uniform float lightMapIntensity;
- #endif`,fUe=`LambertMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularStrength = specularStrength;`,mUe=`varying vec3 vViewPosition;
- struct LambertMaterial {
- vec3 diffuseColor;
- float specularStrength;
- };
- void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_Lambert
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,pUe=`uniform bool receiveShadow;
- uniform vec3 ambientLightColor;
- #if defined( USE_LIGHT_PROBES )
- uniform vec3 lightProbe[ 9 ];
- #endif
- vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
- float x = normal.x, y = normal.y, z = normal.z;
- vec3 result = shCoefficients[ 0 ] * 0.886227;
- result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
- result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
- result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
- result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
- result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
- result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
- result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
- result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
- return result;
- }
- vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
- return irradiance;
- }
- vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
- vec3 irradiance = ambientLightColor;
- return irradiance;
- }
- float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
- #if defined ( LEGACY_LIGHTS )
- if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
- return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );
- }
- return 1.0;
- #else
- float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
- if ( cutoffDistance > 0.0 ) {
- distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
- }
- return distanceFalloff;
- #endif
- }
- float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
- return smoothstep( coneCosine, penumbraCosine, angleCosine );
- }
- #if NUM_DIR_LIGHTS > 0
- struct DirectionalLight {
- vec3 direction;
- vec3 color;
- };
- uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
- void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
- light.color = directionalLight.color;
- light.direction = directionalLight.direction;
- light.visible = true;
- }
- #endif
- #if NUM_POINT_LIGHTS > 0
- struct PointLight {
- vec3 position;
- vec3 color;
- float distance;
- float decay;
- };
- uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
- void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
- vec3 lVector = pointLight.position - geometryPosition;
- light.direction = normalize( lVector );
- float lightDistance = length( lVector );
- light.color = pointLight.color;
- light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
- light.visible = ( light.color != vec3( 0.0 ) );
- }
- #endif
- #if NUM_SPOT_LIGHTS > 0
- struct SpotLight {
- vec3 position;
- vec3 direction;
- vec3 color;
- float distance;
- float decay;
- float coneCos;
- float penumbraCos;
- };
- uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
- void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
- vec3 lVector = spotLight.position - geometryPosition;
- light.direction = normalize( lVector );
- float angleCos = dot( light.direction, spotLight.direction );
- float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
- if ( spotAttenuation > 0.0 ) {
- float lightDistance = length( lVector );
- light.color = spotLight.color * spotAttenuation;
- light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
- light.visible = ( light.color != vec3( 0.0 ) );
- } else {
- light.color = vec3( 0.0 );
- light.visible = false;
- }
- }
- #endif
- #if NUM_RECT_AREA_LIGHTS > 0
- struct RectAreaLight {
- vec3 color;
- vec3 position;
- vec3 halfWidth;
- vec3 halfHeight;
- };
- uniform sampler2D ltc_1; uniform sampler2D ltc_2;
- uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
- #endif
- #if NUM_HEMI_LIGHTS > 0
- struct HemisphereLight {
- vec3 direction;
- vec3 skyColor;
- vec3 groundColor;
- };
- uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
- vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
- float dotNL = dot( normal, hemiLight.direction );
- float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
- vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
- return irradiance;
- }
- #endif`,gUe=`#ifdef USE_ENVMAP
- vec3 getIBLIrradiance( const in vec3 normal ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );
- return PI * envMapColor.rgb * envMapIntensity;
- #else
- return vec3( 0.0 );
- #endif
- }
- vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 reflectVec = reflect( - viewDir, normal );
- reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
- reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
- return envMapColor.rgb * envMapIntensity;
- #else
- return vec3( 0.0 );
- #endif
- }
- #ifdef USE_ANISOTROPY
- vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 bentNormal = cross( bitangent, viewDir );
- bentNormal = normalize( cross( bentNormal, bitangent ) );
- bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
- return getIBLRadiance( viewDir, bentNormal, roughness );
- #else
- return vec3( 0.0 );
- #endif
- }
- #endif
- #endif`,xUe=`ToonMaterial material;
- material.diffuseColor = diffuseColor.rgb;`,bUe=`varying vec3 vViewPosition;
- struct ToonMaterial {
- vec3 diffuseColor;
- };
- void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_Toon
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,yUe=`BlinnPhongMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularColor = specular;
- material.specularShininess = shininess;
- material.specularStrength = specularStrength;`,vUe=`varying vec3 vViewPosition;
- struct BlinnPhongMaterial {
- vec3 diffuseColor;
- vec3 specularColor;
- float specularShininess;
- float specularStrength;
- };
- void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
- }
- void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_BlinnPhong
- #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,_Ue=`PhysicalMaterial material;
- material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
- vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
- float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
- material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
- material.roughness = min( material.roughness, 1.0 );
- #ifdef IOR
- material.ior = ior;
- #ifdef USE_SPECULAR
- float specularIntensityFactor = specularIntensity;
- vec3 specularColorFactor = specularColor;
- #ifdef USE_SPECULAR_COLORMAP
- specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
- #endif
- material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
- #else
- float specularIntensityFactor = 1.0;
- vec3 specularColorFactor = vec3( 1.0 );
- material.specularF90 = 1.0;
- #endif
- material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
- #else
- material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
- material.specularF90 = 1.0;
- #endif
- #ifdef USE_CLEARCOAT
- material.clearcoat = clearcoat;
- material.clearcoatRoughness = clearcoatRoughness;
- material.clearcoatF0 = vec3( 0.04 );
- material.clearcoatF90 = 1.0;
- #ifdef USE_CLEARCOATMAP
- material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
- #endif
- material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
- material.clearcoatRoughness += geometryRoughness;
- material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
- #endif
- #ifdef USE_IRIDESCENCE
- material.iridescence = iridescence;
- material.iridescenceIOR = iridescenceIOR;
- #ifdef USE_IRIDESCENCEMAP
- material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
- #else
- material.iridescenceThickness = iridescenceThicknessMaximum;
- #endif
- #endif
- #ifdef USE_SHEEN
- material.sheenColor = sheenColor;
- #ifdef USE_SHEEN_COLORMAP
- material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
- #endif
- material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
- #ifdef USE_SHEEN_ROUGHNESSMAP
- material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
- #endif
- #endif
- #ifdef USE_ANISOTROPY
- #ifdef USE_ANISOTROPYMAP
- mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
- vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
- vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
- #else
- vec2 anisotropyV = anisotropyVector;
- #endif
- material.anisotropy = length( anisotropyV );
- if( material.anisotropy == 0.0 ) {
- anisotropyV = vec2( 1.0, 0.0 );
- } else {
- anisotropyV /= material.anisotropy;
- material.anisotropy = saturate( material.anisotropy );
- }
- material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
- material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
- material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
- #endif`,wUe=`struct PhysicalMaterial {
- vec3 diffuseColor;
- float roughness;
- vec3 specularColor;
- float specularF90;
- #ifdef USE_CLEARCOAT
- float clearcoat;
- float clearcoatRoughness;
- vec3 clearcoatF0;
- float clearcoatF90;
- #endif
- #ifdef USE_IRIDESCENCE
- float iridescence;
- float iridescenceIOR;
- float iridescenceThickness;
- vec3 iridescenceFresnel;
- vec3 iridescenceF0;
- #endif
- #ifdef USE_SHEEN
- vec3 sheenColor;
- float sheenRoughness;
- #endif
- #ifdef IOR
- float ior;
- #endif
- #ifdef USE_TRANSMISSION
- float transmission;
- float transmissionAlpha;
- float thickness;
- float attenuationDistance;
- vec3 attenuationColor;
- #endif
- #ifdef USE_ANISOTROPY
- float anisotropy;
- float alphaT;
- vec3 anisotropyT;
- vec3 anisotropyB;
- #endif
- };
- vec3 clearcoatSpecularDirect = vec3( 0.0 );
- vec3 clearcoatSpecularIndirect = vec3( 0.0 );
- vec3 sheenSpecularDirect = vec3( 0.0 );
- vec3 sheenSpecularIndirect = vec3(0.0 );
- vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
- float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
- float x2 = x * x;
- float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
- return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
- }
- float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
- float a2 = pow2( alpha );
- float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
- float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
- return 0.5 / max( gv + gl, EPSILON );
- }
- float D_GGX( const in float alpha, const in float dotNH ) {
- float a2 = pow2( alpha );
- float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
- return RECIPROCAL_PI * a2 / pow2( denom );
- }
- #ifdef USE_ANISOTROPY
- float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
- float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
- float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
- float v = 0.5 / ( gv + gl );
- return saturate(v);
- }
- float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
- float a2 = alphaT * alphaB;
- highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
- highp float v2 = dot( v, v );
- float w2 = a2 / v2;
- return RECIPROCAL_PI * a2 * pow2 ( w2 );
- }
- #endif
- #ifdef USE_CLEARCOAT
- vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
- vec3 f0 = material.clearcoatF0;
- float f90 = material.clearcoatF90;
- float roughness = material.clearcoatRoughness;
- float alpha = pow2( roughness );
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( f0, f90, dotVH );
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
- float D = D_GGX( alpha, dotNH );
- return F * ( V * D );
- }
- #endif
- vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
- vec3 f0 = material.specularColor;
- float f90 = material.specularF90;
- float roughness = material.roughness;
- float alpha = pow2( roughness );
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( f0, f90, dotVH );
- #ifdef USE_IRIDESCENCE
- F = mix( F, material.iridescenceFresnel, material.iridescence );
- #endif
- #ifdef USE_ANISOTROPY
- float dotTL = dot( material.anisotropyT, lightDir );
- float dotTV = dot( material.anisotropyT, viewDir );
- float dotTH = dot( material.anisotropyT, halfDir );
- float dotBL = dot( material.anisotropyB, lightDir );
- float dotBV = dot( material.anisotropyB, viewDir );
- float dotBH = dot( material.anisotropyB, halfDir );
- float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
- float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
- #else
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
- float D = D_GGX( alpha, dotNH );
- #endif
- return F * ( V * D );
- }
- vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
- const float LUT_SIZE = 64.0;
- const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
- const float LUT_BIAS = 0.5 / LUT_SIZE;
- float dotNV = saturate( dot( N, V ) );
- vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
- uv = uv * LUT_SCALE + LUT_BIAS;
- return uv;
- }
- float LTC_ClippedSphereFormFactor( const in vec3 f ) {
- float l = length( f );
- return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
- }
- vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
- float x = dot( v1, v2 );
- float y = abs( x );
- float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
- float b = 3.4175940 + ( 4.1616724 + y ) * y;
- float v = a / b;
- float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
- return cross( v1, v2 ) * theta_sintheta;
- }
- vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
- vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
- vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
- vec3 lightNormal = cross( v1, v2 );
- if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
- vec3 T1, T2;
- T1 = normalize( V - N * dot( V, N ) );
- T2 = - cross( N, T1 );
- mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
- vec3 coords[ 4 ];
- coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
- coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
- coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
- coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
- coords[ 0 ] = normalize( coords[ 0 ] );
- coords[ 1 ] = normalize( coords[ 1 ] );
- coords[ 2 ] = normalize( coords[ 2 ] );
- coords[ 3 ] = normalize( coords[ 3 ] );
- vec3 vectorFormFactor = vec3( 0.0 );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
- float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
- return vec3( result );
- }
- #if defined( USE_SHEEN )
- float D_Charlie( float roughness, float dotNH ) {
- float alpha = pow2( roughness );
- float invAlpha = 1.0 / alpha;
- float cos2h = dotNH * dotNH;
- float sin2h = max( 1.0 - cos2h, 0.0078125 );
- return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
- }
- float V_Neubelt( float dotNV, float dotNL ) {
- return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
- }
- vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float D = D_Charlie( sheenRoughness, dotNH );
- float V = V_Neubelt( dotNV, dotNL );
- return sheenColor * ( D * V );
- }
- #endif
- float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
- float dotNV = saturate( dot( normal, viewDir ) );
- float r2 = roughness * roughness;
- float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
- float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
- float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
- return saturate( DG * RECIPROCAL_PI );
- }
- vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
- float dotNV = saturate( dot( normal, viewDir ) );
- const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
- const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
- vec4 r = roughness * c0 + c1;
- float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
- vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
- return fab;
- }
- vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
- vec2 fab = DFGApprox( normal, viewDir, roughness );
- return specularColor * fab.x + specularF90 * fab.y;
- }
- #ifdef USE_IRIDESCENCE
- void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
- #else
- void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
- #endif
- vec2 fab = DFGApprox( normal, viewDir, roughness );
- #ifdef USE_IRIDESCENCE
- vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
- #else
- vec3 Fr = specularColor;
- #endif
- vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
- float Ess = fab.x + fab.y;
- float Ems = 1.0 - Ess;
- vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
- singleScatter += FssEss;
- multiScatter += Fms * Ems;
- }
- #if NUM_RECT_AREA_LIGHTS > 0
- void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 normal = geometryNormal;
- vec3 viewDir = geometryViewDir;
- vec3 position = geometryPosition;
- vec3 lightPos = rectAreaLight.position;
- vec3 halfWidth = rectAreaLight.halfWidth;
- vec3 halfHeight = rectAreaLight.halfHeight;
- vec3 lightColor = rectAreaLight.color;
- float roughness = material.roughness;
- vec3 rectCoords[ 4 ];
- rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
- rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
- rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
- vec2 uv = LTC_Uv( normal, viewDir, roughness );
- vec4 t1 = texture2D( ltc_1, uv );
- vec4 t2 = texture2D( ltc_2, uv );
- mat3 mInv = mat3(
- vec3( t1.x, 0, t1.y ),
- vec3( 0, 1, 0 ),
- vec3( t1.z, 0, t1.w )
- );
- vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
- reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
- reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
- }
- #endif
- void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- #ifdef USE_CLEARCOAT
- float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
- vec3 ccIrradiance = dotNLcc * directLight.color;
- clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
- #endif
- #ifdef USE_SHEEN
- sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
- #endif
- reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
- #ifdef USE_CLEARCOAT
- clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
- #endif
- #ifdef USE_SHEEN
- sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
- #endif
- vec3 singleScattering = vec3( 0.0 );
- vec3 multiScattering = vec3( 0.0 );
- vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
- #ifdef USE_IRIDESCENCE
- computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
- #else
- computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
- #endif
- vec3 totalScattering = singleScattering + multiScattering;
- vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
- reflectedLight.indirectSpecular += radiance * singleScattering;
- reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
- reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
- }
- #define RE_Direct RE_Direct_Physical
- #define RE_Direct_RectArea RE_Direct_RectArea_Physical
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
- #define RE_IndirectSpecular RE_IndirectSpecular_Physical
- float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
- return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
- }`,SUe=`
- vec3 geometryPosition = - vViewPosition;
- vec3 geometryNormal = normal;
- vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
- vec3 geometryClearcoatNormal = vec3( 0.0 );
- #ifdef USE_CLEARCOAT
- geometryClearcoatNormal = clearcoatNormal;
- #endif
- #ifdef USE_IRIDESCENCE
- float dotNVi = saturate( dot( normal, geometryViewDir ) );
- if ( material.iridescenceThickness == 0.0 ) {
- material.iridescence = 0.0;
- } else {
- material.iridescence = saturate( material.iridescence );
- }
- if ( material.iridescence > 0.0 ) {
- material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
- material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
- }
- #endif
- IncidentLight directLight;
- #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
- PointLight pointLight;
- #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
- PointLightShadow pointLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
- pointLight = pointLights[ i ];
- getPointLightInfo( pointLight, geometryPosition, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
- pointLightShadow = pointLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
- SpotLight spotLight;
- vec4 spotColor;
- vec3 spotLightCoord;
- bool inSpotLightMap;
- #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
- SpotLightShadow spotLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
- spotLight = spotLights[ i ];
- getSpotLightInfo( spotLight, geometryPosition, directLight );
- #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
- #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
- #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
- #else
- #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
- #endif
- #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
- spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
- inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
- spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
- directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
- #endif
- #undef SPOT_LIGHT_MAP_INDEX
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- spotLightShadow = spotLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
- DirectionalLight directionalLight;
- #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
- DirectionalLightShadow directionalLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
- directionalLight = directionalLights[ i ];
- getDirectionalLightInfo( directionalLight, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
- directionalLightShadow = directionalLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
- RectAreaLight rectAreaLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
- rectAreaLight = rectAreaLights[ i ];
- RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if defined( RE_IndirectDiffuse )
- vec3 iblIrradiance = vec3( 0.0 );
- vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
- #if defined( USE_LIGHT_PROBES )
- irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
- #endif
- #if ( NUM_HEMI_LIGHTS > 0 )
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
- irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
- }
- #pragma unroll_loop_end
- #endif
- #endif
- #if defined( RE_IndirectSpecular )
- vec3 radiance = vec3( 0.0 );
- vec3 clearcoatRadiance = vec3( 0.0 );
- #endif`,MUe=`#if defined( RE_IndirectDiffuse )
- #ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
- irradiance += lightMapIrradiance;
- #endif
- #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
- iblIrradiance += getIBLIrradiance( geometryNormal );
- #endif
- #endif
- #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
- #ifdef USE_ANISOTROPY
- radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
- #else
- radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
- #endif
- #ifdef USE_CLEARCOAT
- clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
- #endif
- #endif`,NUe=`#if defined( RE_IndirectDiffuse )
- RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- #endif
- #if defined( RE_IndirectSpecular )
- RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- #endif`,EUe=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
- gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
- #endif`,AUe=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
- uniform float logDepthBufFC;
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,TUe=`#ifdef USE_LOGDEPTHBUF
- #ifdef USE_LOGDEPTHBUF_EXT
- varying float vFragDepth;
- varying float vIsPerspective;
- #else
- uniform float logDepthBufFC;
- #endif
- #endif`,CUe=`#ifdef USE_LOGDEPTHBUF
- #ifdef USE_LOGDEPTHBUF_EXT
- vFragDepth = 1.0 + gl_Position.w;
- vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
- #else
- if ( isPerspectiveMatrix( projectionMatrix ) ) {
- gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
- gl_Position.z *= gl_Position.w;
- }
- #endif
- #endif`,kUe=`#ifdef USE_MAP
- vec4 sampledDiffuseColor = texture2D( map, vMapUv );
- #ifdef DECODE_VIDEO_TEXTURE
- sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );
-
- #endif
- diffuseColor *= sampledDiffuseColor;
- #endif`,jUe=`#ifdef USE_MAP
- uniform sampler2D map;
- #endif`,PUe=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- #if defined( USE_POINTS_UV )
- vec2 uv = vUv;
- #else
- vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
- #endif
- #endif
- #ifdef USE_MAP
- diffuseColor *= texture2D( map, uv );
- #endif
- #ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, uv ).g;
- #endif`,RUe=`#if defined( USE_POINTS_UV )
- varying vec2 vUv;
- #else
- #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- uniform mat3 uvTransform;
- #endif
- #endif
- #ifdef USE_MAP
- uniform sampler2D map;
- #endif
- #ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,DUe=`float metalnessFactor = metalness;
- #ifdef USE_METALNESSMAP
- vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
- metalnessFactor *= texelMetalness.b;
- #endif`,OUe=`#ifdef USE_METALNESSMAP
- uniform sampler2D metalnessMap;
- #endif`,LUe=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
- vColor *= morphTargetBaseInfluence;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- #if defined( USE_COLOR_ALPHA )
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
- #elif defined( USE_COLOR )
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
- #endif
- }
- #endif`,IUe=`#ifdef USE_MORPHNORMALS
- objectNormal *= morphTargetBaseInfluence;
- #ifdef MORPHTARGETS_TEXTURE
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
- }
- #else
- objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
- objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
- objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
- objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
- #endif
- #endif`,FUe=`#ifdef USE_MORPHTARGETS
- uniform float morphTargetBaseInfluence;
- #ifdef MORPHTARGETS_TEXTURE
- uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
- uniform sampler2DArray morphTargetsTexture;
- uniform ivec2 morphTargetsTextureSize;
- vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
- int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
- int y = texelIndex / morphTargetsTextureSize.x;
- int x = texelIndex - y * morphTargetsTextureSize.x;
- ivec3 morphUV = ivec3( x, y, morphTargetIndex );
- return texelFetch( morphTargetsTexture, morphUV, 0 );
- }
- #else
- #ifndef USE_MORPHNORMALS
- uniform float morphTargetInfluences[ 8 ];
- #else
- uniform float morphTargetInfluences[ 4 ];
- #endif
- #endif
- #endif`,UUe=`#ifdef USE_MORPHTARGETS
- transformed *= morphTargetBaseInfluence;
- #ifdef MORPHTARGETS_TEXTURE
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
- }
- #else
- transformed += morphTarget0 * morphTargetInfluences[ 0 ];
- transformed += morphTarget1 * morphTargetInfluences[ 1 ];
- transformed += morphTarget2 * morphTargetInfluences[ 2 ];
- transformed += morphTarget3 * morphTargetInfluences[ 3 ];
- #ifndef USE_MORPHNORMALS
- transformed += morphTarget4 * morphTargetInfluences[ 4 ];
- transformed += morphTarget5 * morphTargetInfluences[ 5 ];
- transformed += morphTarget6 * morphTargetInfluences[ 6 ];
- transformed += morphTarget7 * morphTargetInfluences[ 7 ];
- #endif
- #endif
- #endif`,zUe=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
- #ifdef FLAT_SHADED
- vec3 fdx = dFdx( vViewPosition );
- vec3 fdy = dFdy( vViewPosition );
- vec3 normal = normalize( cross( fdx, fdy ) );
- #else
- vec3 normal = normalize( vNormal );
- #ifdef DOUBLE_SIDED
- normal *= faceDirection;
- #endif
- #endif
- #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
- #ifdef USE_TANGENT
- mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
- #else
- mat3 tbn = getTangentFrame( - vViewPosition, normal,
- #if defined( USE_NORMALMAP )
- vNormalMapUv
- #elif defined( USE_CLEARCOAT_NORMALMAP )
- vClearcoatNormalMapUv
- #else
- vUv
- #endif
- );
- #endif
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
- tbn[0] *= faceDirection;
- tbn[1] *= faceDirection;
- #endif
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- #ifdef USE_TANGENT
- mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
- #else
- mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
- #endif
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
- tbn2[0] *= faceDirection;
- tbn2[1] *= faceDirection;
- #endif
- #endif
- vec3 nonPerturbedNormal = normal;`,BUe=`#ifdef USE_NORMALMAP_OBJECTSPACE
- normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
- #ifdef FLIP_SIDED
- normal = - normal;
- #endif
- #ifdef DOUBLE_SIDED
- normal = normal * faceDirection;
- #endif
- normal = normalize( normalMatrix * normal );
- #elif defined( USE_NORMALMAP_TANGENTSPACE )
- vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
- mapN.xy *= normalScale;
- normal = normalize( tbn * mapN );
- #elif defined( USE_BUMPMAP )
- normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
- #endif`,$Ue=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,HUe=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,VUe=`#ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #ifdef USE_TANGENT
- vTangent = normalize( transformedTangent );
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
- #endif
- #endif`,GUe=`#ifdef USE_NORMALMAP
- uniform sampler2D normalMap;
- uniform vec2 normalScale;
- #endif
- #ifdef USE_NORMALMAP_OBJECTSPACE
- uniform mat3 normalMatrix;
- #endif
- #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
- mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
- vec3 q0 = dFdx( eye_pos.xyz );
- vec3 q1 = dFdy( eye_pos.xyz );
- vec2 st0 = dFdx( uv.st );
- vec2 st1 = dFdy( uv.st );
- vec3 N = surf_norm;
- vec3 q1perp = cross( q1, N );
- vec3 q0perp = cross( N, q0 );
- vec3 T = q1perp * st0.x + q0perp * st1.x;
- vec3 B = q1perp * st0.y + q0perp * st1.y;
- float det = max( dot( T, T ), dot( B, B ) );
- float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
- return mat3( T * scale, B * scale, N );
- }
- #endif`,WUe=`#ifdef USE_CLEARCOAT
- vec3 clearcoatNormal = nonPerturbedNormal;
- #endif`,qUe=`#ifdef USE_CLEARCOAT_NORMALMAP
- vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
- clearcoatMapN.xy *= clearcoatNormalScale;
- clearcoatNormal = normalize( tbn2 * clearcoatMapN );
- #endif`,KUe=`#ifdef USE_CLEARCOATMAP
- uniform sampler2D clearcoatMap;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- uniform sampler2D clearcoatNormalMap;
- uniform vec2 clearcoatNormalScale;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- uniform sampler2D clearcoatRoughnessMap;
- #endif`,XUe=`#ifdef USE_IRIDESCENCEMAP
- uniform sampler2D iridescenceMap;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform sampler2D iridescenceThicknessMap;
- #endif`,YUe=`#ifdef OPAQUE
- diffuseColor.a = 1.0;
- #endif
- #ifdef USE_TRANSMISSION
- diffuseColor.a *= material.transmissionAlpha;
- #endif
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,QUe=`vec3 packNormalToRGB( const in vec3 normal ) {
- return normalize( normal ) * 0.5 + 0.5;
- }
- vec3 unpackRGBToNormal( const in vec3 rgb ) {
- return 2.0 * rgb.xyz - 1.0;
- }
- const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
- const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
- const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
- const float ShiftRight8 = 1. / 256.;
- vec4 packDepthToRGBA( const in float v ) {
- vec4 r = vec4( fract( v * PackFactors ), v );
- r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;
- }
- float unpackRGBAToDepth( const in vec4 v ) {
- return dot( v, UnpackFactors );
- }
- vec2 packDepthToRG( in highp float v ) {
- return packDepthToRGBA( v ).yx;
- }
- float unpackRGToDepth( const in highp vec2 v ) {
- return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );
- }
- vec4 pack2HalfToRGBA( vec2 v ) {
- vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
- return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
- }
- vec2 unpackRGBATo2Half( vec4 v ) {
- return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
- }
- float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
- return ( viewZ + near ) / ( near - far );
- }
- float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
- return depth * ( near - far ) - near;
- }
- float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
- return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
- }
- float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
- return ( near * far ) / ( ( far - near ) * depth - far );
- }`,ZUe=`#ifdef PREMULTIPLIED_ALPHA
- gl_FragColor.rgb *= gl_FragColor.a;
- #endif`,JUe=`vec4 mvPosition = vec4( transformed, 1.0 );
- #ifdef USE_BATCHING
- mvPosition = batchingMatrix * mvPosition;
- #endif
- #ifdef USE_INSTANCING
- mvPosition = instanceMatrix * mvPosition;
- #endif
- mvPosition = modelViewMatrix * mvPosition;
- gl_Position = projectionMatrix * mvPosition;`,eze=`#ifdef DITHERING
- gl_FragColor.rgb = dithering( gl_FragColor.rgb );
- #endif`,tze=`#ifdef DITHERING
- vec3 dithering( vec3 color ) {
- float grid_position = rand( gl_FragCoord.xy );
- vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
- dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
- return color + dither_shift_RGB;
- }
- #endif`,nze=`float roughnessFactor = roughness;
- #ifdef USE_ROUGHNESSMAP
- vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
- roughnessFactor *= texelRoughness.g;
- #endif`,rze=`#ifdef USE_ROUGHNESSMAP
- uniform sampler2D roughnessMap;
- #endif`,ize=`#if NUM_SPOT_LIGHT_COORDS > 0
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
- #endif
- #if NUM_SPOT_LIGHT_MAPS > 0
- uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
- #endif
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
- struct DirectionalLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
- struct SpotLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
- struct PointLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- float shadowCameraNear;
- float shadowCameraFar;
- };
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
- #endif
- float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
- return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
- }
- vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
- return unpackRGBATo2Half( texture2D( shadow, uv ) );
- }
- float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
- float occlusion = 1.0;
- vec2 distribution = texture2DDistribution( shadow, uv );
- float hard_shadow = step( compare , distribution.x );
- if (hard_shadow != 1.0 ) {
- float distance = compare - distribution.x ;
- float variance = max( 0.00000, distribution.y * distribution.y );
- float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
- }
- return occlusion;
- }
- float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
- float shadow = 1.0;
- shadowCoord.xyz /= shadowCoord.w;
- shadowCoord.z += shadowBias;
- bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
- bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
- if ( frustumTest ) {
- #if defined( SHADOWMAP_TYPE_PCF )
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
- float dx0 = - texelSize.x * shadowRadius;
- float dy0 = - texelSize.y * shadowRadius;
- float dx1 = + texelSize.x * shadowRadius;
- float dy1 = + texelSize.y * shadowRadius;
- float dx2 = dx0 / 2.0;
- float dy2 = dy0 / 2.0;
- float dx3 = dx1 / 2.0;
- float dy3 = dy1 / 2.0;
- shadow = (
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
- ) * ( 1.0 / 17.0 );
- #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
- float dx = texelSize.x;
- float dy = texelSize.y;
- vec2 uv = shadowCoord.xy;
- vec2 f = fract( uv * shadowMapSize + 0.5 );
- uv -= f * texelSize;
- shadow = (
- texture2DCompare( shadowMap, uv, shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
- f.x ) +
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
- f.x ) +
- mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
- f.y ) +
- mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
- f.y ) +
- mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
- f.x ),
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
- f.x ),
- f.y )
- ) * ( 1.0 / 9.0 );
- #elif defined( SHADOWMAP_TYPE_VSM )
- shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
- #else
- shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
- #endif
- }
- return shadow;
- }
- vec2 cubeToUV( vec3 v, float texelSizeY ) {
- vec3 absV = abs( v );
- float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
- absV *= scaleToCube;
- v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
- vec2 planar = v.xy;
- float almostATexel = 1.5 * texelSizeY;
- float almostOne = 1.0 - almostATexel;
- if ( absV.z >= almostOne ) {
- if ( v.z > 0.0 )
- planar.x = 4.0 - v.x;
- } else if ( absV.x >= almostOne ) {
- float signX = sign( v.x );
- planar.x = v.z * signX + 2.0 * signX;
- } else if ( absV.y >= almostOne ) {
- float signY = sign( v.y );
- planar.x = v.x + 2.0 * signY + 2.0;
- planar.y = v.z * signY - 2.0;
- }
- return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
- }
- float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
- vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
- vec3 lightToPosition = shadowCoord.xyz;
- float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
- vec3 bd3D = normalize( lightToPosition );
- #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
- vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
- return (
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
- ) * ( 1.0 / 9.0 );
- #else
- return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
- #endif
- }
- #endif`,aze=`#if NUM_SPOT_LIGHT_COORDS > 0
- uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
- #endif
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
- struct DirectionalLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- struct SpotLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
- struct PointLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- float shadowCameraNear;
- float shadowCameraFar;
- };
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
- #endif
- #endif`,sze=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
- vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
- vec4 shadowWorldPosition;
- #endif
- #if defined( USE_SHADOWMAP )
- #if NUM_DIR_LIGHT_SHADOWS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
- vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
- vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif
- #endif
- #if NUM_SPOT_LIGHT_COORDS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
- shadowWorldPosition = worldPosition;
- #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
- #endif
- vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif`,oze=`float getShadowMask() {
- float shadow = 1.0;
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- DirectionalLightShadow directionalLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
- directionalLight = directionalLightShadows[ i ];
- shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- SpotLightShadow spotLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
- spotLight = spotLightShadows[ i ];
- shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- PointLightShadow pointLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
- pointLight = pointLightShadows[ i ];
- shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #endif
- return shadow;
- }`,lze=`#ifdef USE_SKINNING
- mat4 boneMatX = getBoneMatrix( skinIndex.x );
- mat4 boneMatY = getBoneMatrix( skinIndex.y );
- mat4 boneMatZ = getBoneMatrix( skinIndex.z );
- mat4 boneMatW = getBoneMatrix( skinIndex.w );
- #endif`,cze=`#ifdef USE_SKINNING
- uniform mat4 bindMatrix;
- uniform mat4 bindMatrixInverse;
- uniform highp sampler2D boneTexture;
- mat4 getBoneMatrix( const in float i ) {
- int size = textureSize( boneTexture, 0 ).x;
- int j = int( i ) * 4;
- int x = j % size;
- int y = j / size;
- vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
- vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
- vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
- vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
- return mat4( v1, v2, v3, v4 );
- }
- #endif`,uze=`#ifdef USE_SKINNING
- vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
- vec4 skinned = vec4( 0.0 );
- skinned += boneMatX * skinVertex * skinWeight.x;
- skinned += boneMatY * skinVertex * skinWeight.y;
- skinned += boneMatZ * skinVertex * skinWeight.z;
- skinned += boneMatW * skinVertex * skinWeight.w;
- transformed = ( bindMatrixInverse * skinned ).xyz;
- #endif`,dze=`#ifdef USE_SKINNING
- mat4 skinMatrix = mat4( 0.0 );
- skinMatrix += skinWeight.x * boneMatX;
- skinMatrix += skinWeight.y * boneMatY;
- skinMatrix += skinWeight.z * boneMatZ;
- skinMatrix += skinWeight.w * boneMatW;
- skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
- objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
- #ifdef USE_TANGENT
- objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
- #endif
- #endif`,hze=`float specularStrength;
- #ifdef USE_SPECULARMAP
- vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
- specularStrength = texelSpecular.r;
- #else
- specularStrength = 1.0;
- #endif`,fze=`#ifdef USE_SPECULARMAP
- uniform sampler2D specularMap;
- #endif`,mze=`#if defined( TONE_MAPPING )
- gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
- #endif`,pze=`#ifndef saturate
- #define saturate( a ) clamp( a, 0.0, 1.0 )
- #endif
- uniform float toneMappingExposure;
- vec3 LinearToneMapping( vec3 color ) {
- return saturate( toneMappingExposure * color );
- }
- vec3 ReinhardToneMapping( vec3 color ) {
- color *= toneMappingExposure;
- return saturate( color / ( vec3( 1.0 ) + color ) );
- }
- vec3 OptimizedCineonToneMapping( vec3 color ) {
- color *= toneMappingExposure;
- color = max( vec3( 0.0 ), color - 0.004 );
- return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
- }
- vec3 RRTAndODTFit( vec3 v ) {
- vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
- vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
- return a / b;
- }
- vec3 ACESFilmicToneMapping( vec3 color ) {
- const mat3 ACESInputMat = mat3(
- vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
- vec3( 0.04823, 0.01566, 0.83777 )
- );
- const mat3 ACESOutputMat = mat3(
- vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
- vec3( -0.07367, -0.00605, 1.07602 )
- );
- color *= toneMappingExposure / 0.6;
- color = ACESInputMat * color;
- color = RRTAndODTFit( color );
- color = ACESOutputMat * color;
- return saturate( color );
- }
- vec3 CustomToneMapping( vec3 color ) { return color; }`,gze=`#ifdef USE_TRANSMISSION
- material.transmission = transmission;
- material.transmissionAlpha = 1.0;
- material.thickness = thickness;
- material.attenuationDistance = attenuationDistance;
- material.attenuationColor = attenuationColor;
- #ifdef USE_TRANSMISSIONMAP
- material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
- #endif
- #ifdef USE_THICKNESSMAP
- material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
- #endif
- vec3 pos = vWorldPosition;
- vec3 v = normalize( cameraPosition - pos );
- vec3 n = inverseTransformDirection( normal, viewMatrix );
- vec4 transmitted = getIBLVolumeRefraction(
- n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
- pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,
- material.attenuationColor, material.attenuationDistance );
- material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
- totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
- #endif`,xze=`#ifdef USE_TRANSMISSION
- uniform float transmission;
- uniform float thickness;
- uniform float attenuationDistance;
- uniform vec3 attenuationColor;
- #ifdef USE_TRANSMISSIONMAP
- uniform sampler2D transmissionMap;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform sampler2D thicknessMap;
- #endif
- uniform vec2 transmissionSamplerSize;
- uniform sampler2D transmissionSamplerMap;
- uniform mat4 modelMatrix;
- uniform mat4 projectionMatrix;
- varying vec3 vWorldPosition;
- float w0( float a ) {
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
- }
- float w1( float a ) {
- return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
- }
- float w2( float a ){
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
- }
- float w3( float a ) {
- return ( 1.0 / 6.0 ) * ( a * a * a );
- }
- float g0( float a ) {
- return w0( a ) + w1( a );
- }
- float g1( float a ) {
- return w2( a ) + w3( a );
- }
- float h0( float a ) {
- return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
- }
- float h1( float a ) {
- return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
- }
- vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
- uv = uv * texelSize.zw + 0.5;
- vec2 iuv = floor( uv );
- vec2 fuv = fract( uv );
- float g0x = g0( fuv.x );
- float g1x = g1( fuv.x );
- float h0x = h0( fuv.x );
- float h1x = h1( fuv.x );
- float h0y = h0( fuv.y );
- float h1y = h1( fuv.y );
- vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
- vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
- vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
- vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
- return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
- g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
- }
- vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
- vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
- vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
- vec2 fLodSizeInv = 1.0 / fLodSize;
- vec2 cLodSizeInv = 1.0 / cLodSize;
- vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
- vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
- return mix( fSample, cSample, fract( lod ) );
- }
- vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
- vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
- vec3 modelScale;
- modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
- modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
- modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
- return normalize( refractionVector ) * thickness * modelScale;
- }
- float applyIorToRoughness( const in float roughness, const in float ior ) {
- return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
- }
- vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
- float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
- return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
- }
- vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
- if ( isinf( attenuationDistance ) ) {
- return vec3( 1.0 );
- } else {
- vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
- vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
- }
- }
- vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
- const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
- const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,
- const in vec3 attenuationColor, const in float attenuationDistance ) {
- vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
- vec3 refractedRayExit = position + transmissionRay;
- vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
- vec2 refractionCoords = ndcPos.xy / ndcPos.w;
- refractionCoords += 1.0;
- refractionCoords /= 2.0;
- vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
- vec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
- vec3 attenuatedColor = transmittance * transmittedLight.rgb;
- vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
- float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
- return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
- }
- #endif`,bze=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- varying vec2 vUv;
- #endif
- #ifdef USE_MAP
- varying vec2 vMapUv;
- #endif
- #ifdef USE_ALPHAMAP
- varying vec2 vAlphaMapUv;
- #endif
- #ifdef USE_LIGHTMAP
- varying vec2 vLightMapUv;
- #endif
- #ifdef USE_AOMAP
- varying vec2 vAoMapUv;
- #endif
- #ifdef USE_BUMPMAP
- varying vec2 vBumpMapUv;
- #endif
- #ifdef USE_NORMALMAP
- varying vec2 vNormalMapUv;
- #endif
- #ifdef USE_EMISSIVEMAP
- varying vec2 vEmissiveMapUv;
- #endif
- #ifdef USE_METALNESSMAP
- varying vec2 vMetalnessMapUv;
- #endif
- #ifdef USE_ROUGHNESSMAP
- varying vec2 vRoughnessMapUv;
- #endif
- #ifdef USE_ANISOTROPYMAP
- varying vec2 vAnisotropyMapUv;
- #endif
- #ifdef USE_CLEARCOATMAP
- varying vec2 vClearcoatMapUv;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- varying vec2 vClearcoatNormalMapUv;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- varying vec2 vClearcoatRoughnessMapUv;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- varying vec2 vIridescenceMapUv;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- varying vec2 vIridescenceThicknessMapUv;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- varying vec2 vSheenColorMapUv;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- varying vec2 vSheenRoughnessMapUv;
- #endif
- #ifdef USE_SPECULARMAP
- varying vec2 vSpecularMapUv;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- varying vec2 vSpecularColorMapUv;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- varying vec2 vSpecularIntensityMapUv;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- uniform mat3 transmissionMapTransform;
- varying vec2 vTransmissionMapUv;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform mat3 thicknessMapTransform;
- varying vec2 vThicknessMapUv;
- #endif`,yze=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- varying vec2 vUv;
- #endif
- #ifdef USE_MAP
- uniform mat3 mapTransform;
- varying vec2 vMapUv;
- #endif
- #ifdef USE_ALPHAMAP
- uniform mat3 alphaMapTransform;
- varying vec2 vAlphaMapUv;
- #endif
- #ifdef USE_LIGHTMAP
- uniform mat3 lightMapTransform;
- varying vec2 vLightMapUv;
- #endif
- #ifdef USE_AOMAP
- uniform mat3 aoMapTransform;
- varying vec2 vAoMapUv;
- #endif
- #ifdef USE_BUMPMAP
- uniform mat3 bumpMapTransform;
- varying vec2 vBumpMapUv;
- #endif
- #ifdef USE_NORMALMAP
- uniform mat3 normalMapTransform;
- varying vec2 vNormalMapUv;
- #endif
- #ifdef USE_DISPLACEMENTMAP
- uniform mat3 displacementMapTransform;
- varying vec2 vDisplacementMapUv;
- #endif
- #ifdef USE_EMISSIVEMAP
- uniform mat3 emissiveMapTransform;
- varying vec2 vEmissiveMapUv;
- #endif
- #ifdef USE_METALNESSMAP
- uniform mat3 metalnessMapTransform;
- varying vec2 vMetalnessMapUv;
- #endif
- #ifdef USE_ROUGHNESSMAP
- uniform mat3 roughnessMapTransform;
- varying vec2 vRoughnessMapUv;
- #endif
- #ifdef USE_ANISOTROPYMAP
- uniform mat3 anisotropyMapTransform;
- varying vec2 vAnisotropyMapUv;
- #endif
- #ifdef USE_CLEARCOATMAP
- uniform mat3 clearcoatMapTransform;
- varying vec2 vClearcoatMapUv;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- uniform mat3 clearcoatNormalMapTransform;
- varying vec2 vClearcoatNormalMapUv;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- uniform mat3 clearcoatRoughnessMapTransform;
- varying vec2 vClearcoatRoughnessMapUv;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- uniform mat3 sheenColorMapTransform;
- varying vec2 vSheenColorMapUv;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- uniform mat3 sheenRoughnessMapTransform;
- varying vec2 vSheenRoughnessMapUv;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- uniform mat3 iridescenceMapTransform;
- varying vec2 vIridescenceMapUv;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform mat3 iridescenceThicknessMapTransform;
- varying vec2 vIridescenceThicknessMapUv;
- #endif
- #ifdef USE_SPECULARMAP
- uniform mat3 specularMapTransform;
- varying vec2 vSpecularMapUv;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- uniform mat3 specularColorMapTransform;
- varying vec2 vSpecularColorMapUv;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- uniform mat3 specularIntensityMapTransform;
- varying vec2 vSpecularIntensityMapUv;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- uniform mat3 transmissionMapTransform;
- varying vec2 vTransmissionMapUv;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform mat3 thicknessMapTransform;
- varying vec2 vThicknessMapUv;
- #endif`,vze=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- vUv = vec3( uv, 1 ).xy;
- #endif
- #ifdef USE_MAP
- vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ALPHAMAP
- vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_LIGHTMAP
- vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_AOMAP
- vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_BUMPMAP
- vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_NORMALMAP
- vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_DISPLACEMENTMAP
- vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_EMISSIVEMAP
- vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_METALNESSMAP
- vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ROUGHNESSMAP
- vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ANISOTROPYMAP
- vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOATMAP
- vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULARMAP
- vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_THICKNESSMAP
- vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
- #endif`,_ze=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
- vec4 worldPosition = vec4( transformed, 1.0 );
- #ifdef USE_BATCHING
- worldPosition = batchingMatrix * worldPosition;
- #endif
- #ifdef USE_INSTANCING
- worldPosition = instanceMatrix * worldPosition;
- #endif
- worldPosition = modelMatrix * worldPosition;
- #endif`;const wze=`varying vec2 vUv;
- uniform mat3 uvTransform;
- void main() {
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- gl_Position = vec4( position.xy, 1.0, 1.0 );
- }`,Sze=`uniform sampler2D t2D;
- uniform float backgroundIntensity;
- varying vec2 vUv;
- void main() {
- vec4 texColor = texture2D( t2D, vUv );
- #ifdef DECODE_VIDEO_TEXTURE
- texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
- #endif
- texColor.rgb *= backgroundIntensity;
- gl_FragColor = texColor;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,Mze=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,Nze=`#ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- uniform sampler2D envMap;
- #endif
- uniform float flipEnvMap;
- uniform float backgroundBlurriness;
- uniform float backgroundIntensity;
- varying vec3 vWorldDirection;
- #include <cube_uv_reflection_fragment>
- void main() {
- #ifdef ENVMAP_TYPE_CUBE
- vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );
- #else
- vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
- #endif
- texColor.rgb *= backgroundIntensity;
- gl_FragColor = texColor;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,Eze=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,Aze=`uniform samplerCube tCube;
- uniform float tFlip;
- uniform float opacity;
- varying vec3 vWorldDirection;
- void main() {
- vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
- gl_FragColor = texColor;
- gl_FragColor.a *= opacity;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,Tze=`#include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- varying vec2 vHighPrecisionZW;
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <skinbase_vertex>
- #ifdef USE_DISPLACEMENTMAP
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vHighPrecisionZW = gl_Position.zw;
- }`,Cze=`#if DEPTH_PACKING == 3200
- uniform float opacity;
- #endif
- #include <common>
- #include <packing>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- varying vec2 vHighPrecisionZW;
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( 1.0 );
- #if DEPTH_PACKING == 3200
- diffuseColor.a = opacity;
- #endif
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <logdepthbuf_fragment>
- float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
- #if DEPTH_PACKING == 3200
- gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
- #elif DEPTH_PACKING == 3201
- gl_FragColor = packDepthToRGBA( fragCoordZ );
- #endif
- }`,kze=`#define DISTANCE
- varying vec3 vWorldPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <skinbase_vertex>
- #ifdef USE_DISPLACEMENTMAP
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <worldpos_vertex>
- #include <clipping_planes_vertex>
- vWorldPosition = worldPosition.xyz;
- }`,jze=`#define DISTANCE
- uniform vec3 referencePosition;
- uniform float nearDistance;
- uniform float farDistance;
- varying vec3 vWorldPosition;
- #include <common>
- #include <packing>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main () {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( 1.0 );
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- float dist = length( vWorldPosition - referencePosition );
- dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
- dist = saturate( dist );
- gl_FragColor = packDepthToRGBA( dist );
- }`,Pze=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }`,Rze=`uniform sampler2D tEquirect;
- varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vec3 direction = normalize( vWorldDirection );
- vec2 sampleUV = equirectUv( direction );
- gl_FragColor = texture2D( tEquirect, sampleUV );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,Dze=`uniform float scale;
- attribute float lineDistance;
- varying float vLineDistance;
- #include <common>
- #include <uv_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- vLineDistance = scale * lineDistance;
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }`,Oze=`uniform vec3 diffuse;
- uniform float opacity;
- uniform float dashSize;
- uniform float totalSize;
- varying float vLineDistance;
- #include <common>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- if ( mod( vLineDistance, totalSize ) > dashSize ) {
- discard;
- }
- vec3 outgoingLight = vec3( 0.0 );
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }`,Lze=`#include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <fog_vertex>
- }`,Ize=`uniform vec3 diffuse;
- uniform float opacity;
- #ifndef FLAT_SHADED
- varying vec3 vNormal;
- #endif
- #include <common>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- #ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
- #else
- reflectedLight.indirectDiffuse += vec3( 1.0 );
- #endif
- #include <aomap_fragment>
- reflectedLight.indirectDiffuse *= diffuseColor.rgb;
- vec3 outgoingLight = reflectedLight.indirectDiffuse;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,Fze=`#define LAMBERT
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,Uze=`#define LAMBERT
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_lambert_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_lambert_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,zze=`#define MATCAP
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <color_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- vViewPosition = - mvPosition.xyz;
- }`,Bze=`#define MATCAP
- uniform vec3 diffuse;
- uniform float opacity;
- uniform sampler2D matcap;
- varying vec3 vViewPosition;
- #include <common>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <normal_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- vec3 viewDir = normalize( vViewPosition );
- vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
- vec3 y = cross( viewDir, x );
- vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
- #ifdef USE_MATCAP
- vec4 matcapColor = texture2D( matcap, uv );
- #else
- vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
- #endif
- vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,$ze=`#define NORMAL
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- varying vec3 vViewPosition;
- #endif
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- vViewPosition = - mvPosition.xyz;
- #endif
- }`,Hze=`#define NORMAL
- uniform float opacity;
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- varying vec3 vViewPosition;
- #endif
- #include <packing>
- #include <uv_pars_fragment>
- #include <normal_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- #include <logdepthbuf_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- gl_FragColor = vec4( packNormalToRGB( normal ), opacity );
- #ifdef OPAQUE
- gl_FragColor.a = 1.0;
- #endif
- }`,Vze=`#define PHONG
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,Gze=`#define PHONG
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform vec3 specular;
- uniform float shininess;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_phong_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_phong_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,Wze=`#define STANDARD
- varying vec3 vViewPosition;
- #ifdef USE_TRANSMISSION
- varying vec3 vWorldPosition;
- #endif
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- #ifdef USE_TRANSMISSION
- vWorldPosition = worldPosition.xyz;
- #endif
- }`,qze=`#define STANDARD
- #ifdef PHYSICAL
- #define IOR
- #define USE_SPECULAR
- #endif
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float roughness;
- uniform float metalness;
- uniform float opacity;
- #ifdef IOR
- uniform float ior;
- #endif
- #ifdef USE_SPECULAR
- uniform float specularIntensity;
- uniform vec3 specularColor;
- #ifdef USE_SPECULAR_COLORMAP
- uniform sampler2D specularColorMap;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- uniform sampler2D specularIntensityMap;
- #endif
- #endif
- #ifdef USE_CLEARCOAT
- uniform float clearcoat;
- uniform float clearcoatRoughness;
- #endif
- #ifdef USE_IRIDESCENCE
- uniform float iridescence;
- uniform float iridescenceIOR;
- uniform float iridescenceThicknessMinimum;
- uniform float iridescenceThicknessMaximum;
- #endif
- #ifdef USE_SHEEN
- uniform vec3 sheenColor;
- uniform float sheenRoughness;
- #ifdef USE_SHEEN_COLORMAP
- uniform sampler2D sheenColorMap;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- uniform sampler2D sheenRoughnessMap;
- #endif
- #endif
- #ifdef USE_ANISOTROPY
- uniform vec2 anisotropyVector;
- #ifdef USE_ANISOTROPYMAP
- uniform sampler2D anisotropyMap;
- #endif
- #endif
- varying vec3 vViewPosition;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <iridescence_fragment>
- #include <cube_uv_reflection_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_physical_pars_fragment>
- #include <fog_pars_fragment>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_physical_pars_fragment>
- #include <transmission_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <clearcoat_pars_fragment>
- #include <iridescence_pars_fragment>
- #include <roughnessmap_pars_fragment>
- #include <metalnessmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <roughnessmap_fragment>
- #include <metalnessmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <clearcoat_normal_fragment_begin>
- #include <clearcoat_normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_physical_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
- vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
- #include <transmission_fragment>
- vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
- #ifdef USE_SHEEN
- float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
- outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
- #endif
- #ifdef USE_CLEARCOAT
- float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
- vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
- outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
- #endif
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,Kze=`#define TOON
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,Xze=`#define TOON
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <gradientmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_toon_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_toon_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,Yze=`uniform float size;
- uniform float scale;
- #include <common>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- #ifdef USE_POINTS_UV
- varying vec2 vUv;
- uniform mat3 uvTransform;
- #endif
- void main() {
- #ifdef USE_POINTS_UV
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- #endif
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <project_vertex>
- gl_PointSize = size;
- #ifdef USE_SIZEATTENUATION
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
- if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
- #endif
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <worldpos_vertex>
- #include <fog_vertex>
- }`,Qze=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <color_pars_fragment>
- #include <map_particle_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_particle_fragment>
- #include <color_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }`,Zze=`#include <common>
- #include <batching_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <shadowmap_pars_vertex>
- void main() {
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,Jze=`uniform vec3 color;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <logdepthbuf_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <shadowmask_pars_fragment>
- void main() {
- #include <logdepthbuf_fragment>
- gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,eBe=`uniform float rotation;
- uniform vec2 center;
- #include <common>
- #include <uv_pars_vertex>
- #include <fog_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
- vec2 scale;
- scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
- scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
- #ifndef USE_SIZEATTENUATION
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
- if ( isPerspective ) scale *= - mvPosition.z;
- #endif
- vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
- vec2 rotatedPosition;
- rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
- rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
- mvPosition.xy += rotatedPosition;
- gl_Position = projectionMatrix * mvPosition;
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }`,tBe=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,Sn={alphahash_fragment:S5e,alphahash_pars_fragment:M5e,alphamap_fragment:N5e,alphamap_pars_fragment:E5e,alphatest_fragment:A5e,alphatest_pars_fragment:T5e,aomap_fragment:C5e,aomap_pars_fragment:k5e,batching_pars_vertex:j5e,batching_vertex:P5e,begin_vertex:R5e,beginnormal_vertex:D5e,bsdfs:O5e,iridescence_fragment:L5e,bumpmap_pars_fragment:I5e,clipping_planes_fragment:F5e,clipping_planes_pars_fragment:U5e,clipping_planes_pars_vertex:z5e,clipping_planes_vertex:B5e,color_fragment:$5e,color_pars_fragment:H5e,color_pars_vertex:V5e,color_vertex:G5e,common:W5e,cube_uv_reflection_fragment:q5e,defaultnormal_vertex:K5e,displacementmap_pars_vertex:X5e,displacementmap_vertex:Y5e,emissivemap_fragment:Q5e,emissivemap_pars_fragment:Z5e,colorspace_fragment:J5e,colorspace_pars_fragment:eUe,envmap_fragment:tUe,envmap_common_pars_fragment:nUe,envmap_pars_fragment:rUe,envmap_pars_vertex:iUe,envmap_physical_pars_fragment:gUe,envmap_vertex:aUe,fog_vertex:sUe,fog_pars_vertex:oUe,fog_fragment:lUe,fog_pars_fragment:cUe,gradientmap_pars_fragment:uUe,lightmap_fragment:dUe,lightmap_pars_fragment:hUe,lights_lambert_fragment:fUe,lights_lambert_pars_fragment:mUe,lights_pars_begin:pUe,lights_toon_fragment:xUe,lights_toon_pars_fragment:bUe,lights_phong_fragment:yUe,lights_phong_pars_fragment:vUe,lights_physical_fragment:_Ue,lights_physical_pars_fragment:wUe,lights_fragment_begin:SUe,lights_fragment_maps:MUe,lights_fragment_end:NUe,logdepthbuf_fragment:EUe,logdepthbuf_pars_fragment:AUe,logdepthbuf_pars_vertex:TUe,logdepthbuf_vertex:CUe,map_fragment:kUe,map_pars_fragment:jUe,map_particle_fragment:PUe,map_particle_pars_fragment:RUe,metalnessmap_fragment:DUe,metalnessmap_pars_fragment:OUe,morphcolor_vertex:LUe,morphnormal_vertex:IUe,morphtarget_pars_vertex:FUe,morphtarget_vertex:UUe,normal_fragment_begin:zUe,normal_fragment_maps:BUe,normal_pars_fragment:$Ue,normal_pars_vertex:HUe,normal_vertex:VUe,normalmap_pars_fragment:GUe,clearcoat_normal_fragment_begin:WUe,clearcoat_normal_fragment_maps:qUe,clearcoat_pars_fragment:KUe,iridescence_pars_fragment:XUe,opaque_fragment:YUe,packing:QUe,premultiplied_alpha_fragment:ZUe,project_vertex:JUe,dithering_fragment:eze,dithering_pars_fragment:tze,roughnessmap_fragment:nze,roughnessmap_pars_fragment:rze,shadowmap_pars_fragment:ize,shadowmap_pars_vertex:aze,shadowmap_vertex:sze,shadowmask_pars_fragment:oze,skinbase_vertex:lze,skinning_pars_vertex:cze,skinning_vertex:uze,skinnormal_vertex:dze,specularmap_fragment:hze,specularmap_pars_fragment:fze,tonemapping_fragment:mze,tonemapping_pars_fragment:pze,transmission_fragment:gze,transmission_pars_fragment:xze,uv_pars_fragment:bze,uv_pars_vertex:yze,uv_vertex:vze,worldpos_vertex:_ze,background_vert:wze,background_frag:Sze,backgroundCube_vert:Mze,backgroundCube_frag:Nze,cube_vert:Eze,cube_frag:Aze,depth_vert:Tze,depth_frag:Cze,distanceRGBA_vert:kze,distanceRGBA_frag:jze,equirect_vert:Pze,equirect_frag:Rze,linedashed_vert:Dze,linedashed_frag:Oze,meshbasic_vert:Lze,meshbasic_frag:Ize,meshlambert_vert:Fze,meshlambert_frag:Uze,meshmatcap_vert:zze,meshmatcap_frag:Bze,meshnormal_vert:$ze,meshnormal_frag:Hze,meshphong_vert:Vze,meshphong_frag:Gze,meshphysical_vert:Wze,meshphysical_frag:qze,meshtoon_vert:Kze,meshtoon_frag:Xze,points_vert:Yze,points_frag:Qze,shadow_vert:Zze,shadow_frag:Jze,sprite_vert:eBe,sprite_frag:tBe},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}}},xs={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}};xs.physical={uniforms:Ka([xs.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 w1={r:0,b:0,g:0};function nBe(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,v){let S=!1,M=v.isScene===!0?v.background:null;M&&M.isTexture&&(M=(v.backgroundBlurriness>0?n:e).get(M)),M===null?y(l,c):M&&M.isColor&&(y(M,1),S=!0);const E=t.xr.getEnvironmentBlendMode();E==="additive"?r.buffers.color.setClear(0,0,0,1,o):E==="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===mE)?(d===void 0&&(d=new rl(new Wy(1,1,1),new rh({name:"BackgroundCubeMaterial",uniforms:Og(xs.backgroundCube.uniforms),vertexShader:xs.backgroundCube.vertexShader,fragmentShader:xs.backgroundCube.fragmentShader,side:Ss,depthTest:!1,depthWrite:!1,fog:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(A,k,T){this.matrixWorld.copyPosition(T.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),d.material.uniforms.envMap.value=M,d.material.uniforms.flipEnvMap.value=M.isCubeTexture&&M.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=v.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=v.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 rl(new yL(2,2),new rh({name:"BackgroundMaterial",uniforms:Og(xs.background.uniforms),vertexShader:xs.background.vertexShader,fragmentShader:xs.background.fragmentShader,side:nh,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=v.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 y(x,v){x.getRGB(w1,ite(t)),r.buffers.color.setClear(w1.r,w1.g,w1.b,v,o)}return{getClearColor:function(){return l},setClearColor:function(x,v=1){l.set(x),c=v,y(l,c)},getClearAlpha:function(){return c},setClearAlpha:function(x){c=x,y(l,c)},render:b}}function rBe(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,X,G,Z){let te=!1;if(o){const ee=y(G,X,W);u!==ee&&(u=ee,p(u.object)),te=v(j,G,X,Z),te&&S(j,G,X,Z)}else{const ee=W.wireframe===!0;(u.geometry!==G.id||u.program!==X.id||u.wireframe!==ee)&&(u.geometry=G.id,u.program=X.id,u.wireframe=ee,te=!0)}Z!==null&&n.update(Z,t.ELEMENT_ARRAY_BUFFER),(te||d)&&(d=!1,D(j,W,X,G),Z!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n.get(Z).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 y(j,W,X){const G=X.wireframe===!0;let Z=l[j.id];Z===void 0&&(Z={},l[j.id]=Z);let te=Z[W.id];te===void 0&&(te={},Z[W.id]=te);let ee=te[G];return ee===void 0&&(ee=x(m()),te[G]=ee),ee}function x(j){const W=[],X=[],G=[];for(let Z=0;Z<i;Z++)W[Z]=0,X[Z]=0,G[Z]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:W,enabledAttributes:X,attributeDivisors:G,object:j,attributes:{},index:null}}function v(j,W,X,G){const Z=u.attributes,te=W.attributes;let ee=0;const z=X.getAttributes();for(const V in z)if(z[V].location>=0){const ie=Z[V];let he=te[V];if(he===void 0&&(V==="instanceMatrix"&&j.instanceMatrix&&(he=j.instanceMatrix),V==="instanceColor"&&j.instanceColor&&(he=j.instanceColor)),ie===void 0||ie.attribute!==he||he&&ie.data!==he.data)return!0;ee++}return u.attributesNum!==ee||u.index!==G}function S(j,W,X,G){const Z={},te=W.attributes;let ee=0;const z=X.getAttributes();for(const V in z)if(z[V].location>=0){let ie=te[V];ie===void 0&&(V==="instanceMatrix"&&j.instanceMatrix&&(ie=j.instanceMatrix),V==="instanceColor"&&j.instanceColor&&(ie=j.instanceColor));const he={};he.attribute=ie,ie&&ie.data&&(he.data=ie.data),Z[V]=he,ee++}u.attributes=Z,u.attributesNum=ee,u.index=G}function M(){const j=u.newAttributes;for(let W=0,X=j.length;W<X;W++)j[W]=0}function E(j){A(j,0)}function A(j,W){const X=u.newAttributes,G=u.enabledAttributes,Z=u.attributeDivisors;X[j]=1,G[j]===0&&(t.enableVertexAttribArray(j),G[j]=1),Z[j]!==W&&((r.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](j,W),Z[j]=W)}function k(){const j=u.newAttributes,W=u.enabledAttributes;for(let X=0,G=W.length;X<G;X++)W[X]!==j[X]&&(t.disableVertexAttribArray(X),W[X]=0)}function T(j,W,X,G,Z,te,ee){ee===!0?t.vertexAttribIPointer(j,W,X,Z,te):t.vertexAttribPointer(j,W,X,G,Z,te)}function D(j,W,X,G){if(r.isWebGL2===!1&&(j.isInstancedMesh||G.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;M();const Z=G.attributes,te=X.getAttributes(),ee=W.defaultAttributeValues;for(const z in te){const V=te[z];if(V.location>=0){let ne=Z[z];if(ne===void 0&&(z==="instanceMatrix"&&j.instanceMatrix&&(ne=j.instanceMatrix),z==="instanceColor"&&j.instanceColor&&(ne=j.instanceColor)),ne!==void 0){const ie=ne.normalized,he=ne.itemSize,me=n.get(ne);if(me===void 0)continue;const oe=me.buffer,Ae=me.type,ge=me.bytesPerElement,Ne=r.isWebGL2===!0&&(Ae===t.INT||Ae===t.UNSIGNED_INT||ne.gpuType===Fee);if(ne.isInterleavedBufferAttribute){const _e=ne.data,le=_e.stride,He=ne.offset;if(_e.isInstancedInterleavedBuffer){for(let H=0;H<V.locationSize;H++)A(V.location+H,_e.meshPerAttribute);j.isInstancedMesh!==!0&&G._maxInstanceCount===void 0&&(G._maxInstanceCount=_e.meshPerAttribute*_e.count)}else for(let H=0;H<V.locationSize;H++)E(V.location+H);t.bindBuffer(t.ARRAY_BUFFER,oe);for(let H=0;H<V.locationSize;H++)T(V.location+H,he/V.locationSize,Ae,ie,le*ge,(He+he/V.locationSize*H)*ge,Ne)}else{if(ne.isInstancedBufferAttribute){for(let _e=0;_e<V.locationSize;_e++)A(V.location+_e,ne.meshPerAttribute);j.isInstancedMesh!==!0&&G._maxInstanceCount===void 0&&(G._maxInstanceCount=ne.meshPerAttribute*ne.count)}else for(let _e=0;_e<V.locationSize;_e++)E(V.location+_e);t.bindBuffer(t.ARRAY_BUFFER,oe);for(let _e=0;_e<V.locationSize;_e++)T(V.location+_e,he/V.locationSize,Ae,ie,he*ge,he/V.locationSize*_e*ge,Ne)}}else if(ee!==void 0){const ie=ee[z];if(ie!==void 0)switch(ie.length){case 2:t.vertexAttrib2fv(V.location,ie);break;case 3:t.vertexAttrib3fv(V.location,ie);break;case 4:t.vertexAttrib4fv(V.location,ie);break;default:t.vertexAttrib1fv(V.location,ie)}}}}k()}function C(){O();for(const j in l){const W=l[j];for(const X in W){const G=W[X];for(const Z in G)b(G[Z].object),delete G[Z];delete W[X]}delete l[j]}}function R(j){if(l[j.id]===void 0)return;const W=l[j.id];for(const X in W){const G=W[X];for(const Z in G)b(G[Z].object),delete G[Z];delete W[X]}delete l[j.id]}function U(j){for(const W in l){const X=l[W];if(X[j.id]===void 0)continue;const G=X[j.id];for(const Z in G)b(G[Z].object),delete G[Z];delete X[j.id]}}function O(){q(),d=!0,u!==c&&(u=c,p(u.object))}function q(){c.geometry=null,c.program=null,c.wireframe=!1}return{setup:f,reset:O,resetDefaultState:q,dispose:C,releaseStatesOfGeometry:R,releaseStatesOfProgram:U,initAttributes:M,enableAttribute:E,disableUnusedAttributes:k}}function iBe(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 y=0;y<m;y++)b+=f[y];n.update(b,a,1)}}this.setMode=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=u}function aBe(t,e,n){let r;function i(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const T=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(T.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(T){if(T==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";T="mediump"}return T==="mediump"&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const o=typeof WebGL2RenderingContext<"u"&&t.constructor.name==="WebGL2RenderingContext";let l=n.precision!==void 0?n.precision:"highp";const c=a(l);c!==l&&(console.warn("THREE.WebGLRenderer:",l,"not supported, using",c,"instead."),l=c);const u=o||e.has("WEBGL_draw_buffers"),d=n.logarithmicDepthBuffer===!0,f=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),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),y=t.getParameter(t.MAX_VERTEX_ATTRIBS),x=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),v=t.getParameter(t.MAX_VARYING_VECTORS),S=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),M=m>0,E=o||e.has("OES_texture_float"),A=M&&E,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:y,maxVertexUniforms:x,maxVaryings:v,maxFragmentUniforms:S,vertexTextures:M,floatFragmentTextures:E,floatVertexTextures:A,maxSamples:k}}function sBe(t){const e=this;let n=null,r=0,i=!1,a=!1;const o=new yd,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,y=f.clipIntersection,x=f.clipShadows,v=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 E=v.clippingState||null;c.value=E,E=d(b,m,M,p);for(let A=0;A!==M;++A)E[A]=n[A];v.clippingState=E,this.numIntersection=y?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 y=f!==null?f.length:0;let x=null;if(y!==0){if(x=c.value,b!==!0||x===null){const v=p+y*4,S=m.matrixWorldInverse;l.getNormalMatrix(S),(x===null||x.length<v)&&(x=new Float32Array(v));for(let M=0,E=p;M!==y;++M,E+=4)o.copy(f[M]).applyMatrix4(S,l),o.normal.toArray(x,E),x[E+3]=o.constant}c.value=x,c.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,x}}function oBe(t){let e=new WeakMap;function n(o,l){return l===SR?o.mapping=Pg:l===MR&&(o.mapping=Rg),o}function r(o){if(o&&o.isTexture){const l=o.mapping;if(l===SR||l===MR)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 y5e(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 lBe extends ate{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 Yp=4,N7=[.125,.215,.35,.446,.526,.582],rf=20,Qk=new lBe,E7=new rn;let Zk=null,Jk=0,ej=0;const Jh=(1+Math.sqrt(5))/2,jp=1/Jh,A7=[new Be(1,1,1),new Be(-1,1,1),new Be(1,1,-1),new Be(-1,1,-1),new Be(0,Jh,jp),new Be(0,Jh,-jp),new Be(jp,0,Jh),new Be(-jp,0,Jh),new Be(Jh,jp,0),new Be(-Jh,jp,0)];class T7{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(),Jk=this._renderer.getActiveCubeFace(),ej=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=j7(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=k7(),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,Jk,ej),e.scissorTest=!1,S1(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===Pg||e.mapping===Rg?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(),Jk=this._renderer.getActiveCubeFace(),ej=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:No,colorSpace:wu,depthBuffer:!1},i=C7(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=C7(e,n,r);const{_lodMax:a}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=cBe(a)),this._blurMaterial=uBe(a,e,n)}return i}_compileMaterial(e){const n=new rl(this._lodPlanes[0],e);this._renderer.compile(n,Qk)}_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=Hd,d.autoClear=!1;const p=new tte({name:"PMREM.Background",side:Ss,depthWrite:!1,depthTest:!1}),b=new rl(new Wy,p);let y=!1;const x=e.background;x?x.isColor&&(p.color.copy(x),e.background=null,y=!0):(p.color.copy(E7),y=!0);for(let v=0;v<6;v++){const S=v%3;S===0?(l.up.set(0,c[v],0),l.lookAt(u[v],0,0)):S===1?(l.up.set(0,0,c[v]),l.lookAt(0,u[v],0)):(l.up.set(0,c[v],0),l.lookAt(0,0,u[v]));const M=this._cubeSize;S1(i,S*M,v>2?M:0,M,M),d.setRenderTarget(i),y&&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===Pg||e.mapping===Rg;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=j7()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=k7());const a=i?this._cubemapMaterial:this._equirectMaterial,o=new rl(this._lodPlanes[0],a),l=a.uniforms;l.envMap.value=e;const c=this._cubeSize;S1(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(o,Qk)}_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=A7[(i-1)%A7.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 rl(this._lodPlanes[i],u),m=u.uniforms,p=this._sizeLods[r]-1,b=isFinite(a)?Math.PI/(2*p):2*Math.PI/(2*rf-1),y=a/b,x=isFinite(a)?1+Math.floor(d*y):rf;x>rf&&console.warn(`sigmaRadians, ${a}, is too large and will clip, as it requested ${x} samples when the maximum is set to ${rf}`);const v=[];let S=0;for(let T=0;T<rf;++T){const D=T/y,C=Math.exp(-D*D/2);v.push(C),T===0?S+=C:T<x&&(S+=2*C)}for(let T=0;T<v.length;T++)v[T]=v[T]/S;m.envMap.value=e.texture,m.samples.value=x,m.weights.value=v,m.latitudinal.value=o==="latitudinal",l&&(m.poleAxis.value=l);const{_lodMax:M}=this;m.dTheta.value=b,m.mipInt.value=M-r;const E=this._sizeLods[i],A=3*E*(i>M-Yp?i-M+Yp:0),k=4*(this._cubeSize-E);S1(n,A,k,3*E,2*E),c.setRenderTarget(n),c.render(f,Qk)}}function cBe(t){const e=[],n=[],r=[];let i=t;const a=t-Yp+1+N7.length;for(let o=0;o<a;o++){const l=Math.pow(2,i);n.push(l);let c=1/l;o>t-Yp?c=N7[o-t+Yp-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,y=3,x=2,v=1,S=new Float32Array(y*b*p),M=new Float32Array(x*b*p),E=new Float32Array(v*b*p);for(let k=0;k<p;k++){const T=k%3*2/3-1,D=k>2?0:-1,C=[T,D,0,T+2/3,D,0,T+2/3,D+1,0,T,D,0,T+2/3,D+1,0,T,D+1,0];S.set(C,y*b*k),M.set(m,x*b*k);const R=[k,k,k,k,k,k];E.set(R,v*b*k)}const A=new Ha;A.setAttribute("position",new Xs(S,y)),A.setAttribute("uv",new Xs(M,x)),A.setAttribute("faceIndex",new Xs(E,v)),e.push(A),i>Yp&&i--}return{lodPlanes:e,sizeLods:n,sigmas:r}}function C7(t,e,n){const r=new tm(t,e,n);return r.texture.mapping=mE,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function S1(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function uBe(t,e,n){const r=new Float32Array(rf),i=new Be(0,1,0);return new rh({name:"SphericalGaussianBlur",defines:{n:rf,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:vL(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- uniform int samples;
- uniform float weights[ n ];
- uniform bool latitudinal;
- uniform float dTheta;
- uniform float mipInt;
- uniform vec3 poleAxis;
- #define ENVMAP_TYPE_CUBE_UV
- #include <cube_uv_reflection_fragment>
- vec3 getSample( float theta, vec3 axis ) {
- float cosTheta = cos( theta );
- // Rodrigues' axis-angle rotation
- vec3 sampleDirection = vOutputDirection * cosTheta
- + cross( axis, vOutputDirection ) * sin( theta )
- + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
- return bilinearCubeUV( envMap, sampleDirection, mipInt );
- }
- void main() {
- vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
- if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
- axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
- }
- axis = normalize( axis );
- gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
- gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
- for ( int i = 1; i < n; i++ ) {
- if ( i >= samples ) {
- break;
- }
- float theta = dTheta * float( i );
- gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
- gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
- }
- }
- `,blending:$d,depthTest:!1,depthWrite:!1})}function k7(){return new rh({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:vL(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- #include <common>
- void main() {
- vec3 outputDirection = normalize( vOutputDirection );
- vec2 uv = equirectUv( outputDirection );
- gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
- }
- `,blending:$d,depthTest:!1,depthWrite:!1})}function j7(){return new rh({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:vL(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- uniform float flipEnvMap;
- varying vec3 vOutputDirection;
- uniform samplerCube envMap;
- void main() {
- gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
- }
- `,blending:$d,depthTest:!1,depthWrite:!1})}function vL(){return`
- precision mediump float;
- precision mediump int;
- attribute float faceIndex;
- varying vec3 vOutputDirection;
- // RH coordinate system; PMREM face-indexing convention
- vec3 getDirection( vec2 uv, float face ) {
- uv = 2.0 * uv - 1.0;
- vec3 direction = vec3( uv, 1.0 );
- if ( face == 0.0 ) {
- direction = direction.zyx; // ( 1, v, u ) pos x
- } else if ( face == 1.0 ) {
- direction = direction.xzy;
- direction.xz *= -1.0; // ( -u, 1, -v ) pos y
- } else if ( face == 2.0 ) {
- direction.x *= -1.0; // ( -u, v, 1 ) pos z
- } else if ( face == 3.0 ) {
- direction = direction.zyx;
- direction.xz *= -1.0; // ( -1, v, -u ) neg x
- } else if ( face == 4.0 ) {
- direction = direction.xzy;
- direction.xy *= -1.0; // ( -u, -1, v ) neg y
- } else if ( face == 5.0 ) {
- direction.z *= -1.0; // ( u, v, -1 ) neg z
- }
- return direction;
- }
- void main() {
- vOutputDirection = getDirection( uv, faceIndex );
- gl_Position = vec4( position, 1.0 );
- }
- `}function dBe(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,u=c===SR||c===MR,d=c===Pg||c===Rg;if(u||d)if(l.isRenderTargetTexture&&l.needsPMREMUpdate===!0){l.needsPMREMUpdate=!1;let f=e.get(l);return n===null&&(n=new T7(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 T7(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 hBe(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 fBe(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 y=m.morphAttributes[b];for(let x=0,v=y.length;x<v;x++)e.remove(y[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 y=p[b];for(let x=0,v=y.length;x<v;x++)e.update(y[x],t.ARRAY_BUFFER)}}function u(f){const m=[],p=f.index,b=f.attributes.position;let y=0;if(p!==null){const S=p.array;y=p.version;for(let M=0,E=S.length;M<E;M+=3){const A=S[M+0],k=S[M+1],T=S[M+2];m.push(A,k,k,T,T,A)}}else if(b!==void 0){const S=b.array;y=b.version;for(let M=0,E=S.length/3-1;M<E;M+=3){const A=M+0,k=M+1,T=M+2;m.push(A,k,k,T,T,A)}}else return;const x=new(Xee(m)?rte:nte)(m,1);x.version=y;const v=a.get(f);v&&e.remove(v),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 mBe(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,y){if(y===0)return;let x,v;if(i)x=t,v="drawElementsInstanced";else if(x=e.get("ANGLE_instanced_arrays"),v="drawElementsInstancedANGLE",x===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}x[v](a,b,l,p*c,y),n.update(b,a,y)}function m(p,b,y){if(y===0)return;const x=e.get("WEBGL_multi_draw");if(x===null)for(let v=0;v<y;v++)this.render(p[v]/c,b[v]);else{x.multiDrawElementsWEBGL(a,b,0,l,p,0,y);let v=0;for(let S=0;S<y;S++)v+=b[S];n.update(v,a,1)}}this.setMode=o,this.setIndex=u,this.render=d,this.renderInstances=f,this.renderMultiDraw=m}function pBe(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 gBe(t,e){return t[0]-e[0]}function xBe(t,e){return Math.abs(e[1])-Math.abs(t[1])}function bBe(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,y=b!==void 0?b.length:0;let x=a.get(d);if(x===void 0||x.count!==y){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,E=d.morphAttributes.normal!==void 0,A=d.morphAttributes.color!==void 0,k=d.morphAttributes.position||[],T=d.morphAttributes.normal||[],D=d.morphAttributes.color||[];let C=0;M===!0&&(C=1),E===!0&&(C=2),A===!0&&(C=3);let R=d.attributes.position.count*C,U=1;R>e.maxTextureSize&&(U=Math.ceil(R/e.maxTextureSize),R=e.maxTextureSize);const O=new Float32Array(R*U*4*y),q=new Zee(O,R,U,y);q.type=tu,q.needsUpdate=!0;const j=C*4;for(let X=0;X<y;X++){const G=k[X],Z=T[X],te=D[X],ee=R*U*4*X;for(let z=0;z<G.count;z++){const V=z*j;M===!0&&(o.fromBufferAttribute(G,z),O[ee+V+0]=o.x,O[ee+V+1]=o.y,O[ee+V+2]=o.z,O[ee+V+3]=0),E===!0&&(o.fromBufferAttribute(Z,z),O[ee+V+4]=o.x,O[ee+V+5]=o.y,O[ee+V+6]=o.z,O[ee+V+7]=0),A===!0&&(o.fromBufferAttribute(te,z),O[ee+V+8]=o.x,O[ee+V+9]=o.y,O[ee+V+10]=o.z,O[ee+V+11]=te.itemSize===4?o.w:1)}}x={count:y,texture:q,size:new mn(R,U)},a.set(d,x),d.addEventListener("dispose",W)}let v=0;for(let M=0;M<m.length;M++)v+=m[M];const S=d.morphTargetsRelative?1:1-v;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 y=r[d.id];if(y===void 0||y.length!==b){y=[];for(let E=0;E<b;E++)y[E]=[E,0];r[d.id]=y}for(let E=0;E<b;E++){const A=y[E];A[0]=E,A[1]=m[E]}y.sort(xBe);for(let E=0;E<8;E++)E<b&&y[E][1]?(l[E][0]=y[E][0],l[E][1]=y[E][1]):(l[E][0]=Number.MAX_SAFE_INTEGER,l[E][1]=0);l.sort(gBe);const x=d.morphAttributes.position,v=d.morphAttributes.normal;let S=0;for(let E=0;E<8;E++){const A=l[E],k=A[0],T=A[1];k!==Number.MAX_SAFE_INTEGER&&T?(x&&d.getAttribute("morphTarget"+E)!==x[k]&&d.setAttribute("morphTarget"+E,x[k]),v&&d.getAttribute("morphNormal"+E)!==v[k]&&d.setAttribute("morphNormal"+E,v[k]),i[E]=T,S+=T):(x&&d.hasAttribute("morphTarget"+E)===!0&&d.deleteAttribute("morphTarget"+E),v&&d.hasAttribute("morphNormal"+E)===!0&&d.deleteAttribute("morphNormal"+E),i[E]=0)}const M=d.morphTargetsRelative?1:1-S;f.getUniforms().setValue(t,"morphTargetBaseInfluence",M),f.getUniforms().setValue(t,"morphTargetInfluences",i)}}return{update:c}}function yBe(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 lte extends Ms{constructor(e,n,r,i,a,o,l,c,u,d){if(d=d!==void 0?d:Tf,d!==Tf&&d!==Dg)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&d===Tf&&(r=jd),r===void 0&&d===Dg&&(r=Af),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:ya,this.minFilter=c!==void 0?c:ya,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 cte=new Ms,ute=new lte(1,1);ute.compareFunction=qee;const dte=new Zee,hte=new r5e,fte=new ste,P7=[],R7=[],D7=new Float32Array(16),O7=new Float32Array(9),L7=new Float32Array(4);function hx(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let a=P7[i];if(a===void 0&&(a=new Float32Array(i),P7[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 xE(t,e){let n=R7[e];n===void 0&&(n=new Int32Array(e),R7[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function vBe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function _Be(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 wBe(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 SBe(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 MBe(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;L7.set(r),t.uniformMatrix2fv(this.addr,!1,L7),Ui(n,r)}}function NBe(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;O7.set(r),t.uniformMatrix3fv(this.addr,!1,O7),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;D7.set(r),t.uniformMatrix4fv(this.addr,!1,D7),Ui(n,r)}}function ABe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function TBe(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 CBe(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 kBe(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 jBe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function PBe(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 RBe(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 DBe(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 OBe(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?ute:cte;n.setTexture2D(e||a,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.setTexture3D(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.setTextureCube(e||fte,i)}function FBe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||dte,i)}function UBe(t){switch(t){case 5126:return vBe;case 35664:return _Be;case 35665:return wBe;case 35666:return SBe;case 35674:return MBe;case 35675:return NBe;case 35676:return EBe;case 5124:case 35670:return ABe;case 35667:case 35671:return TBe;case 35668:case 35672:return CBe;case 35669:case 35673:return kBe;case 5125:return jBe;case 36294:return PBe;case 36295:return RBe;case 36296:return DBe;case 35678:case 36198:case 36298:case 36306:case 35682:return OBe;case 35679:case 36299:case 36307:return LBe;case 35680:case 36300:case 36308:case 36293:return IBe;case 36289:case 36303:case 36311:case 36292:return FBe}}function zBe(t,e){t.uniform1fv(this.addr,e)}function BBe(t,e){const n=hx(e,this.size,2);t.uniform2fv(this.addr,n)}function $Be(t,e){const n=hx(e,this.size,3);t.uniform3fv(this.addr,n)}function HBe(t,e){const n=hx(e,this.size,4);t.uniform4fv(this.addr,n)}function VBe(t,e){const n=hx(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function GBe(t,e){const n=hx(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function WBe(t,e){const n=hx(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function qBe(t,e){t.uniform1iv(this.addr,e)}function KBe(t,e){t.uniform2iv(this.addr,e)}function XBe(t,e){t.uniform3iv(this.addr,e)}function YBe(t,e){t.uniform4iv(this.addr,e)}function QBe(t,e){t.uniform1uiv(this.addr,e)}function ZBe(t,e){t.uniform2uiv(this.addr,e)}function JBe(t,e){t.uniform3uiv(this.addr,e)}function e8e(t,e){t.uniform4uiv(this.addr,e)}function t8e(t,e,n){const r=this.cache,i=e.length,a=xE(n,i);Fi(r,a)||(t.uniform1iv(this.addr,a),Ui(r,a));for(let o=0;o!==i;++o)n.setTexture2D(e[o]||cte,a[o])}function n8e(t,e,n){const r=this.cache,i=e.length,a=xE(n,i);Fi(r,a)||(t.uniform1iv(this.addr,a),Ui(r,a));for(let o=0;o!==i;++o)n.setTexture3D(e[o]||hte,a[o])}function r8e(t,e,n){const r=this.cache,i=e.length,a=xE(n,i);Fi(r,a)||(t.uniform1iv(this.addr,a),Ui(r,a));for(let o=0;o!==i;++o)n.setTextureCube(e[o]||fte,a[o])}function i8e(t,e,n){const r=this.cache,i=e.length,a=xE(n,i);Fi(r,a)||(t.uniform1iv(this.addr,a),Ui(r,a));for(let o=0;o!==i;++o)n.setTexture2DArray(e[o]||dte,a[o])}function a8e(t){switch(t){case 5126:return zBe;case 35664:return BBe;case 35665:return $Be;case 35666:return HBe;case 35674:return VBe;case 35675:return GBe;case 35676:return WBe;case 5124:case 35670:return qBe;case 35667:case 35671:return KBe;case 35668:case 35672:return XBe;case 35669:case 35673:return YBe;case 5125:return QBe;case 36294:return ZBe;case 36295:return JBe;case 36296:return e8e;case 35678:case 36198:case 36298:case 36306:case 35682:return t8e;case 35679:case 36299:case 36307:return n8e;case 35680:case 36300:case 36308:case 36293:return r8e;case 36289:case 36303:case 36311:case 36292:return i8e}}class s8e{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=UBe(n.type)}}class o8e{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=a8e(n.type)}}class l8e{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 tj=/(\w+)(\])?(\[|\.)?/g;function I7(t,e){t.seq.push(e),t.map[e.id]=e}function c8e(t,e,n){const r=t.name,i=r.length;for(tj.lastIndex=0;;){const a=tj.exec(r),o=tj.lastIndex;let l=a[1];const c=a[2]==="]",u=a[3];if(c&&(l=l|0),u===void 0||u==="["&&o+2===i){I7(n,u===void 0?new s8e(l,t,e):new o8e(l,t,e));break}else{let f=n.map[l];f===void 0&&(f=new l8e(l),I7(n,f)),n=f}}}class xw{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);c8e(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 F7(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const u8e=37297;let d8e=0;function h8e(t,e){const n=t.split(`
- `),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(`
- `)}function f8e(t){const e=pr.getPrimaries(pr.workingColorSpace),n=pr.getPrimaries(t);let r;switch(e===n?r="":e===KS&&n===qS?r="LinearDisplayP3ToLinearSRGB":e===qS&&n===KS&&(r="LinearSRGBToLinearDisplayP3"),t){case wu:case pE:return[r,"LinearTransferOETF"];case va:case pL:return[r,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",t),[r,"LinearTransferOETF"]}}function U7(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()+`
- `+i+`
- `+h8e(t.getShaderSource(e),o)}else return i}function m8e(t,e){const n=f8e(e);return`vec4 ${t}( vec4 value ) { return ${n[0]}( ${n[1]}( value ) ); }`}function p8e(t,e){let n;switch(e){case mFe:n="Linear";break;case pFe:n="Reinhard";break;case gFe:n="OptimizedCineon";break;case xFe:n="ACESFilmic";break;case bFe:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function g8e(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(Gb).join(`
- `)}function x8e(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
- `)}function b8e(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 Gb(t){return t!==""}function z7(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 B7(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const y8e=/^[ \t]*#include +<([\w\d./]+)>/gm;function kR(t){return t.replace(y8e,_8e)}const v8e=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function _8e(t,e){let n=Sn[e];if(n===void 0){const r=v8e.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 kR(n)}const w8e=/#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 $7(t){return t.replace(w8e,S8e)}function S8e(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 H7(t){let e="precision "+t.precision+` float;
- precision `+t.precision+" int;";return t.precision==="highp"?e+=`
- #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
- #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
- #define LOW_PRECISION`),e}function M8e(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===Lee?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===$Ie?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===Vc&&(e="SHADOWMAP_TYPE_VSM"),e}function N8e(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case Pg:case Rg:e="ENVMAP_TYPE_CUBE";break;case mE:e="ENVMAP_TYPE_CUBE_UV";break}return e}function E8e(t){let e="ENVMAP_MODE_REFLECTION";return t.envMap&&t.envMapMode===Rg&&(e="ENVMAP_MODE_REFRACTION"),e}function A8e(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case fL:e="ENVMAP_BLENDING_MULTIPLY";break;case hFe:e="ENVMAP_BLENDING_MIX";break;case fFe:e="ENVMAP_BLENDING_ADD";break}return e}function T8e(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 C8e(t,e,n,r){const i=t.getContext(),a=n.defines;let o=n.vertexShader,l=n.fragmentShader;const c=M8e(n),u=N8e(n),d=E8e(n),f=A8e(n),m=T8e(n),p=n.isWebGL2?"":g8e(n),b=x8e(a),y=i.createProgram();let x,v,S=n.glslVersion?"#version "+n.glslVersion+`
- `:"";n.isRawShaderMaterial?(x=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(Gb).join(`
- `),x.length>0&&(x+=`
- `),v=[p,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(Gb).join(`
- `),v.length>0&&(v+=`
- `)):(x=[H7(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",`
- `].filter(Gb).join(`
- `),v=[p,H7(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!==Hd?"#define TONE_MAPPING":"",n.toneMapping!==Hd?Sn.tonemapping_pars_fragment:"",n.toneMapping!==Hd?p8e("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Sn.colorspace_pars_fragment,m8e("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
- `].filter(Gb).join(`
- `)),o=kR(o),o=z7(o,n),o=B7(o,n),l=kR(l),l=z7(l,n),l=B7(l,n),o=$7(o),l=$7(l),n.isWebGL2&&n.isRawShaderMaterial!==!0&&(S=`#version 300 es
- `,x=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
- `)+`
- `+x,v=["precision mediump sampler2DArray;","#define varying in",n.glslVersion===o7?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===o7?"":"#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(`
- `)+`
- `+v);const M=S+x+o,E=S+v+l,A=F7(i,i.VERTEX_SHADER,M),k=F7(i,i.FRAGMENT_SHADER,E);i.attachShader(y,A),i.attachShader(y,k),n.index0AttributeName!==void 0?i.bindAttribLocation(y,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(y,0,"position"),i.linkProgram(y);function T(U){if(t.debug.checkShaderErrors){const O=i.getProgramInfoLog(y).trim(),q=i.getShaderInfoLog(A).trim(),j=i.getShaderInfoLog(k).trim();let W=!0,X=!0;if(i.getProgramParameter(y,i.LINK_STATUS)===!1)if(W=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,y,A,k);else{const G=U7(i,A,"vertex"),Z=U7(i,k,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(y,i.VALIDATE_STATUS)+`
- Program Info Log: `+O+`
- `+G+`
- `+Z)}else O!==""?console.warn("THREE.WebGLProgram: Program Info Log:",O):(q===""||j==="")&&(X=!1);X&&(U.diagnostics={runnable:W,programLog:O,vertexShader:{log:q,prefix:x},fragmentShader:{log:j,prefix:v}})}i.deleteShader(A),i.deleteShader(k),D=new xw(i,y),C=b8e(i,y)}let D;this.getUniforms=function(){return D===void 0&&T(this),D};let C;this.getAttributes=function(){return C===void 0&&T(this),C};let R=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return R===!1&&(R=i.getProgramParameter(y,u8e)),R},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(y),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=d8e++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=A,this.fragmentShader=k,this}let k8e=0;class j8e{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 P8e(e),n.set(e,r)),r}}class P8e{constructor(e){this.id=k8e++,this.code=e,this.usedTimes=0}}function R8e(t,e,n,r,i,a,o){const l=new Jee,c=new j8e,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 y(C){return C===0?"uv":`uv${C}`}function x(C,R,U,O,q){const j=O.fog,W=q.geometry,X=C.isMeshStandardMaterial?O.environment:null,G=(C.isMeshStandardMaterial?n:e).get(C.envMap||X),Z=G&&G.mapping===mE?G.image.height:null,te=b[C.type];C.precision!==null&&(p=i.getMaxPrecision(C.precision),p!==C.precision&&console.warn("THREE.WebGLProgram.getParameters:",C.precision,"not supported, using",p,"instead."));const ee=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,z=ee!==void 0?ee.length:0;let V=0;W.morphAttributes.position!==void 0&&(V=1),W.morphAttributes.normal!==void 0&&(V=2),W.morphAttributes.color!==void 0&&(V=3);let ne,ie,he,me;if(te){const on=xs[te];ne=on.vertexShader,ie=on.fragmentShader}else ne=C.vertexShader,ie=C.fragmentShader,c.update(C),he=c.getVertexShaderID(C),me=c.getFragmentShaderID(C);const oe=t.getRenderTarget(),Ae=q.isInstancedMesh===!0,ge=q.isBatchedMesh===!0,Ne=!!C.map,_e=!!C.matcap,le=!!G,He=!!C.aoMap,H=!!C.lightMap,J=!!C.bumpMap,K=!!C.normalMap,B=!!C.displacementMap,I=!!C.emissiveMap,ce=!!C.metalnessMap,Ee=!!C.roughnessMap,Ie=C.anisotropy>0,ue=C.clearcoat>0,$=C.iridescence>0,L=C.sheen>0,Y=C.transmission>0,pe=Ie&&!!C.anisotropyMap,Se=ue&&!!C.clearcoatMap,ae=ue&&!!C.clearcoatNormalMap,je=ue&&!!C.clearcoatRoughnessMap,De=$&&!!C.iridescenceMap,Xe=$&&!!C.iridescenceThicknessMap,et=L&&!!C.sheenColorMap,Qe=L&&!!C.sheenRoughnessMap,se=!!C.specularMap,ye=!!C.specularColorMap,ke=!!C.specularIntensityMap,Ue=Y&&!!C.transmissionMap,dt=Y&&!!C.thicknessMap,re=!!C.gradientMap,Fe=!!C.alphaMap,ve=C.alphaTest>0,$e=!!C.alphaHash,Le=!!C.extensions,Te=!!W.attributes.uv1,We=!!W.attributes.uv2,it=!!W.attributes.uv3;let Ot=Hd;return C.toneMapped&&(oe===null||oe.isXRRenderTarget===!0)&&(Ot=t.toneMapping),{isWebGL2:d,shaderID:te,shaderType:C.type,shaderName:C.name,vertexShader:ne,fragmentShader:ie,defines:C.defines,customVertexShaderID:he,customFragmentShaderID:me,isRawShaderMaterial:C.isRawShaderMaterial===!0,glslVersion:C.glslVersion,precision:p,batching:ge,instancing:Ae,instancingColor:Ae&&q.instanceColor!==null,supportsVertexTextures:m,outputColorSpace:oe===null?t.outputColorSpace:oe.isXRRenderTarget===!0?oe.texture.colorSpace:wu,map:Ne,matcap:_e,envMap:le,envMapMode:le&&G.mapping,envMapCubeUVHeight:Z,aoMap:He,lightMap:H,bumpMap:J,normalMap:K,displacementMap:m&&B,emissiveMap:I,normalMapObjectSpace:K&&C.normalMapType===kFe,normalMapTangentSpace:K&&C.normalMapType===Wee,metalnessMap:ce,roughnessMap:Ee,anisotropy:Ie,anisotropyMap:pe,clearcoat:ue,clearcoatMap:Se,clearcoatNormalMap:ae,clearcoatRoughnessMap:je,iridescence:$,iridescenceMap:De,iridescenceThicknessMap:Xe,sheen:L,sheenColorMap:et,sheenRoughnessMap:Qe,specularMap:se,specularColorMap:ye,specularIntensityMap:ke,transmission:Y,transmissionMap:Ue,thicknessMap:dt,gradientMap:re,opaque:C.transparent===!1&&C.blending===og,alphaMap:Fe,alphaTest:ve,alphaHash:$e,combine:C.combine,mapUv:Ne&&y(C.map.channel),aoMapUv:He&&y(C.aoMap.channel),lightMapUv:H&&y(C.lightMap.channel),bumpMapUv:J&&y(C.bumpMap.channel),normalMapUv:K&&y(C.normalMap.channel),displacementMapUv:B&&y(C.displacementMap.channel),emissiveMapUv:I&&y(C.emissiveMap.channel),metalnessMapUv:ce&&y(C.metalnessMap.channel),roughnessMapUv:Ee&&y(C.roughnessMap.channel),anisotropyMapUv:pe&&y(C.anisotropyMap.channel),clearcoatMapUv:Se&&y(C.clearcoatMap.channel),clearcoatNormalMapUv:ae&&y(C.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:je&&y(C.clearcoatRoughnessMap.channel),iridescenceMapUv:De&&y(C.iridescenceMap.channel),iridescenceThicknessMapUv:Xe&&y(C.iridescenceThicknessMap.channel),sheenColorMapUv:et&&y(C.sheenColorMap.channel),sheenRoughnessMapUv:Qe&&y(C.sheenRoughnessMap.channel),specularMapUv:se&&y(C.specularMap.channel),specularColorMapUv:ye&&y(C.specularColorMap.channel),specularIntensityMapUv:ke&&y(C.specularIntensityMap.channel),transmissionMapUv:Ue&&y(C.transmissionMap.channel),thicknessMapUv:dt&&y(C.thicknessMap.channel),alphaMapUv:Fe&&y(C.alphaMap.channel),vertexTangents:!!W.attributes.tangent&&(K||Ie),vertexColors:C.vertexColors,vertexAlphas:C.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,vertexUv1s:Te,vertexUv2s:We,vertexUv3s:it,pointsUvs:q.isPoints===!0&&!!W.attributes.uv&&(Ne||Fe),fog:!!j,useFog:C.fog===!0,fogExp2:j&&j.isFogExp2,flatShading:C.flatShading===!0,sizeAttenuation:C.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:V,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:C.dithering,shadowMapEnabled:t.shadowMap.enabled&&U.length>0,shadowMapType:t.shadowMap.type,toneMapping:Ot,useLegacyLights:t._useLegacyLights,decodeVideoTexture:Ne&&C.map.isVideoTexture===!0&&pr.getTransfer(C.map.colorSpace)===Dr,premultipliedAlpha:C.premultipliedAlpha,doubleSided:C.side===Yc,flipSided:C.side===Ss,useDepthPacking:C.depthPacking>=0,depthPacking:C.depthPacking||0,index0AttributeName:C.index0AttributeName,extensionDerivatives:Le&&C.extensions.derivatives===!0,extensionFragDepth:Le&&C.extensions.fragDepth===!0,extensionDrawBuffers:Le&&C.extensions.drawBuffers===!0,extensionShaderTextureLOD:Le&&C.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:C.customProgramCacheKey()}}function v(C){const R=[];if(C.shaderID?R.push(C.shaderID):(R.push(C.customVertexShaderID),R.push(C.customFragmentShaderID)),C.defines!==void 0)for(const U in C.defines)R.push(U),R.push(C.defines[U]);return C.isRawShaderMaterial===!1&&(S(R,C),M(R,C),R.push(t.outputColorSpace)),R.push(C.customProgramCacheKey),R.join()}function S(C,R){C.push(R.precision),C.push(R.outputColorSpace),C.push(R.envMapMode),C.push(R.envMapCubeUVHeight),C.push(R.mapUv),C.push(R.alphaMapUv),C.push(R.lightMapUv),C.push(R.aoMapUv),C.push(R.bumpMapUv),C.push(R.normalMapUv),C.push(R.displacementMapUv),C.push(R.emissiveMapUv),C.push(R.metalnessMapUv),C.push(R.roughnessMapUv),C.push(R.anisotropyMapUv),C.push(R.clearcoatMapUv),C.push(R.clearcoatNormalMapUv),C.push(R.clearcoatRoughnessMapUv),C.push(R.iridescenceMapUv),C.push(R.iridescenceThicknessMapUv),C.push(R.sheenColorMapUv),C.push(R.sheenRoughnessMapUv),C.push(R.specularMapUv),C.push(R.specularColorMapUv),C.push(R.specularIntensityMapUv),C.push(R.transmissionMapUv),C.push(R.thicknessMapUv),C.push(R.combine),C.push(R.fogExp2),C.push(R.sizeAttenuation),C.push(R.morphTargetsCount),C.push(R.morphAttributeCount),C.push(R.numDirLights),C.push(R.numPointLights),C.push(R.numSpotLights),C.push(R.numSpotLightMaps),C.push(R.numHemiLights),C.push(R.numRectAreaLights),C.push(R.numDirLightShadows),C.push(R.numPointLightShadows),C.push(R.numSpotLightShadows),C.push(R.numSpotLightShadowsWithMaps),C.push(R.numLightProbes),C.push(R.shadowMapType),C.push(R.toneMapping),C.push(R.numClippingPlanes),C.push(R.numClipIntersection),C.push(R.depthPacking)}function M(C,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),C.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),C.push(l.mask)}function E(C){const R=b[C.type];let U;if(R){const O=xs[R];U=bL.clone(O.uniforms)}else U=C.uniforms;return U}function A(C,R){let U;for(let O=0,q=u.length;O<q;O++){const j=u[O];if(j.cacheKey===R){U=j,++U.usedTimes;break}}return U===void 0&&(U=new C8e(t,R,C,a),u.push(U)),U}function k(C){if(--C.usedTimes===0){const R=u.indexOf(C);u[R]=u[u.length-1],u.pop(),C.destroy()}}function T(C){c.remove(C)}function D(){c.dispose()}return{getParameters:x,getProgramCacheKey:v,getUniforms:E,acquireProgram:A,releaseProgram:k,releaseShaderCache:T,programs:u,dispose:D}}function D8e(){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 O8e(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 V7(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 G7(){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,y,x){let v=t[e];return v===void 0?(v={id:f.id,object:f,geometry:m,material:p,groupOrder:b,renderOrder:f.renderOrder,z:y,group:x},t[e]=v):(v.id=f.id,v.object=f,v.geometry=m,v.material=p,v.groupOrder=b,v.renderOrder=f.renderOrder,v.z=y,v.group=x),e++,v}function l(f,m,p,b,y,x){const v=o(f,m,p,b,y,x);p.transmission>0?r.push(v):p.transparent===!0?i.push(v):n.push(v)}function c(f,m,p,b,y,x){const v=o(f,m,p,b,y,x);p.transmission>0?r.unshift(v):p.transparent===!0?i.unshift(v):n.unshift(v)}function u(f,m){n.length>1&&n.sort(f||O8e),r.length>1&&r.sort(m||V7),i.length>1&&i.sort(m||V7)}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 L8e(){let t=new WeakMap;function e(r,i){const a=t.get(r);let o;return a===void 0?(o=new G7,t.set(r,[o])):i>=a.length?(o=new G7,a.push(o)):o=a[i],o}function n(){t=new WeakMap}return{get:e,dispose: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={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 F8e(){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 U8e=0;function z8e(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function B8e(t,e){const n=new I8e,r=F8e(),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 O=0;O<9;O++)i.probe[O].set(0,0,0);let y=0,x=0,v=0,S=0,M=0,E=0,A=0,k=0,T=0,D=0,C=0;d.sort(z8e);const R=f===!0?Math.PI:1;for(let O=0,q=d.length;O<q;O++){const j=d[O],W=j.color,X=j.intensity,G=j.distance,Z=j.shadow&&j.shadow.map?j.shadow.map.texture:null;if(j.isAmbientLight)m+=W.r*X*R,p+=W.g*X*R,b+=W.b*X*R;else if(j.isLightProbe){for(let te=0;te<9;te++)i.probe[te].addScaledVector(j.sh.coefficients[te],X);C++}else if(j.isDirectionalLight){const te=n.get(j);if(te.color.copy(j.color).multiplyScalar(j.intensity*R),j.castShadow){const ee=j.shadow,z=r.get(j);z.shadowBias=ee.bias,z.shadowNormalBias=ee.normalBias,z.shadowRadius=ee.radius,z.shadowMapSize=ee.mapSize,i.directionalShadow[y]=z,i.directionalShadowMap[y]=Z,i.directionalShadowMatrix[y]=j.shadow.matrix,E++}i.directional[y]=te,y++}else if(j.isSpotLight){const te=n.get(j);te.position.setFromMatrixPosition(j.matrixWorld),te.color.copy(W).multiplyScalar(X*R),te.distance=G,te.coneCos=Math.cos(j.angle),te.penumbraCos=Math.cos(j.angle*(1-j.penumbra)),te.decay=j.decay,i.spot[v]=te;const ee=j.shadow;if(j.map&&(i.spotLightMap[T]=j.map,T++,ee.updateMatrices(j),j.castShadow&&D++),i.spotLightMatrix[v]=ee.matrix,j.castShadow){const z=r.get(j);z.shadowBias=ee.bias,z.shadowNormalBias=ee.normalBias,z.shadowRadius=ee.radius,z.shadowMapSize=ee.mapSize,i.spotShadow[v]=z,i.spotShadowMap[v]=Z,k++}v++}else if(j.isRectAreaLight){const te=n.get(j);te.color.copy(W).multiplyScalar(X),te.halfWidth.set(j.width*.5,0,0),te.halfHeight.set(0,j.height*.5,0),i.rectArea[S]=te,S++}else if(j.isPointLight){const te=n.get(j);if(te.color.copy(j.color).multiplyScalar(j.intensity*R),te.distance=j.distance,te.decay=j.decay,j.castShadow){const ee=j.shadow,z=r.get(j);z.shadowBias=ee.bias,z.shadowNormalBias=ee.normalBias,z.shadowRadius=ee.radius,z.shadowMapSize=ee.mapSize,z.shadowCameraNear=ee.camera.near,z.shadowCameraFar=ee.camera.far,i.pointShadow[x]=z,i.pointShadowMap[x]=Z,i.pointShadowMatrix[x]=j.shadow.matrix,A++}i.point[x]=te,x++}else if(j.isHemisphereLight){const te=n.get(j);te.skyColor.copy(j.color).multiplyScalar(X*R),te.groundColor.copy(j.groundColor).multiplyScalar(X*R),i.hemi[M]=te,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!==y||U.pointLength!==x||U.spotLength!==v||U.rectAreaLength!==S||U.hemiLength!==M||U.numDirectionalShadows!==E||U.numPointShadows!==A||U.numSpotShadows!==k||U.numSpotMaps!==T||U.numLightProbes!==C)&&(i.directional.length=y,i.spot.length=v,i.rectArea.length=S,i.point.length=x,i.hemi.length=M,i.directionalShadow.length=E,i.directionalShadowMap.length=E,i.pointShadow.length=A,i.pointShadowMap.length=A,i.spotShadow.length=k,i.spotShadowMap.length=k,i.directionalShadowMatrix.length=E,i.pointShadowMatrix.length=A,i.spotLightMatrix.length=k+T-D,i.spotLightMap.length=T,i.numSpotLightShadowsWithMaps=D,i.numLightProbes=C,U.directionalLength=y,U.pointLength=x,U.spotLength=v,U.rectAreaLength=S,U.hemiLength=M,U.numDirectionalShadows=E,U.numPointShadows=A,U.numSpotShadows=k,U.numSpotMaps=T,U.numLightProbes=C,i.version=U8e++)}function u(d,f){let m=0,p=0,b=0,y=0,x=0;const v=f.matrixWorldInverse;for(let S=0,M=d.length;S<M;S++){const E=d[S];if(E.isDirectionalLight){const A=i.directional[m];A.direction.setFromMatrixPosition(E.matrixWorld),a.setFromMatrixPosition(E.target.matrixWorld),A.direction.sub(a),A.direction.transformDirection(v),m++}else if(E.isSpotLight){const A=i.spot[b];A.position.setFromMatrixPosition(E.matrixWorld),A.position.applyMatrix4(v),A.direction.setFromMatrixPosition(E.matrixWorld),a.setFromMatrixPosition(E.target.matrixWorld),A.direction.sub(a),A.direction.transformDirection(v),b++}else if(E.isRectAreaLight){const A=i.rectArea[y];A.position.setFromMatrixPosition(E.matrixWorld),A.position.applyMatrix4(v),l.identity(),o.copy(E.matrixWorld),o.premultiply(v),l.extractRotation(o),A.halfWidth.set(E.width*.5,0,0),A.halfHeight.set(0,E.height*.5,0),A.halfWidth.applyMatrix4(l),A.halfHeight.applyMatrix4(l),y++}else if(E.isPointLight){const A=i.point[p];A.position.setFromMatrixPosition(E.matrixWorld),A.position.applyMatrix4(v),p++}else if(E.isHemisphereLight){const A=i.hemi[x];A.direction.setFromMatrixPosition(E.matrixWorld),A.direction.transformDirection(v),x++}}}return{setup:c,setupView:u,state:i}}function W7(t,e){const n=new B8e(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 $8e(t,e){let n=new WeakMap;function r(a,o=0){const l=n.get(a);let c;return l===void 0?(c=new W7(t,e),n.set(a,[c])):o>=l.length?(c=new W7(t,e),l.push(c)):c=l[o],c}function i(){n=new WeakMap}return{get:r,dispose:i}}class H8e extends dx{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=TFe,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 V8e extends dx{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 G8e=`void main() {
- gl_Position = vec4( position, 1.0 );
- }`,W8e=`uniform sampler2D shadow_pass;
- uniform vec2 resolution;
- uniform float radius;
- #include <packing>
- void main() {
- const float samples = float( VSM_SAMPLES );
- float mean = 0.0;
- float squared_mean = 0.0;
- float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
- float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
- for ( float i = 0.0; i < samples; i ++ ) {
- float uvOffset = uvStart + i * uvStride;
- #ifdef HORIZONTAL_PASS
- vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
- mean += distribution.x;
- squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
- #else
- float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
- mean += depth;
- squared_mean += depth * depth;
- #endif
- }
- mean = mean / samples;
- squared_mean = squared_mean / samples;
- float std_dev = sqrt( squared_mean - mean * mean );
- gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
- }`;function q8e(t,e,n){let r=new gE;const i=new mn,a=new mn,o=new xr,l=new H8e({depthPacking:CFe}),c=new V8e,u={},d=n.maxTextureSize,f={[nh]:Ss,[Ss]:nh,[Yc]:Yc},m=new rh({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new mn},radius:{value:4}},vertexShader:G8e,fragmentShader:W8e}),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 y=new rl(b,m),x=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Lee;let v=this.type;this.render=function(A,k,T){if(x.enabled===!1||x.autoUpdate===!1&&x.needsUpdate===!1||A.length===0)return;const D=t.getRenderTarget(),C=t.getActiveCubeFace(),R=t.getActiveMipmapLevel(),U=t.state;U.setBlending($d),U.buffers.color.setClear(1,1,1,1),U.buffers.depth.setTest(!0),U.setScissorTest(!1);const O=v!==Vc&&this.type===Vc,q=v===Vc&&this.type!==Vc;for(let j=0,W=A.length;j<W;j++){const X=A[j],G=X.shadow;if(G===void 0){console.warn("THREE.WebGLShadowMap:",X,"has no shadow.");continue}if(G.autoUpdate===!1&&G.needsUpdate===!1)continue;i.copy(G.mapSize);const Z=G.getFrameExtents();if(i.multiply(Z),a.copy(G.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(a.x=Math.floor(d/Z.x),i.x=a.x*Z.x,G.mapSize.x=a.x),i.y>d&&(a.y=Math.floor(d/Z.y),i.y=a.y*Z.y,G.mapSize.y=a.y)),G.map===null||O===!0||q===!0){const ee=this.type!==Vc?{minFilter:ya,magFilter:ya}:{};G.map!==null&&G.map.dispose(),G.map=new tm(i.x,i.y,ee),G.map.texture.name=X.name+".shadowMap",G.camera.updateProjectionMatrix()}t.setRenderTarget(G.map),t.clear();const te=G.getViewportCount();for(let ee=0;ee<te;ee++){const z=G.getViewport(ee);o.set(a.x*z.x,a.y*z.y,a.x*z.z,a.y*z.w),U.viewport(o),G.updateMatrices(X,ee),r=G.getFrustum(),E(k,T,G.camera,X,this.type)}G.isPointLightShadow!==!0&&this.type===Vc&&S(G,T),G.needsUpdate=!1}v=this.type,x.needsUpdate=!1,t.setRenderTarget(D,C,R)};function S(A,k){const T=e.update(y);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 tm(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,T,m,y,null),p.uniforms.shadow_pass.value=A.mapPass.texture,p.uniforms.resolution.value=A.mapSize,p.uniforms.radius.value=A.radius,t.setRenderTarget(A.map),t.clear(),t.renderBufferDirect(k,null,T,p,y,null)}function M(A,k,T,D){let C=null;const R=T.isPointLight===!0?A.customDistanceMaterial:A.customDepthMaterial;if(R!==void 0)C=R;else if(C=T.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=C.uuid,O=k.uuid;let q=u[U];q===void 0&&(q={},u[U]=q);let j=q[O];j===void 0&&(j=C.clone(),q[O]=j),C=j}if(C.visible=k.visible,C.wireframe=k.wireframe,D===Vc?C.side=k.shadowSide!==null?k.shadowSide:k.side:C.side=k.shadowSide!==null?k.shadowSide:f[k.side],C.alphaMap=k.alphaMap,C.alphaTest=k.alphaTest,C.map=k.map,C.clipShadows=k.clipShadows,C.clippingPlanes=k.clippingPlanes,C.clipIntersection=k.clipIntersection,C.displacementMap=k.displacementMap,C.displacementScale=k.displacementScale,C.displacementBias=k.displacementBias,C.wireframeLinewidth=k.wireframeLinewidth,C.linewidth=k.linewidth,T.isPointLight===!0&&C.isMeshDistanceMaterial===!0){const U=t.properties.get(C);U.light=T}return C}function E(A,k,T,D,C){if(A.visible===!1)return;if(A.layers.test(k.layers)&&(A.isMesh||A.isLine||A.isPoints)&&(A.castShadow||A.receiveShadow&&C===Vc)&&(!A.frustumCulled||r.intersectsObject(A))){A.modelViewMatrix.multiplyMatrices(T.matrixWorldInverse,A.matrixWorld);const O=e.update(A),q=A.material;if(Array.isArray(q)){const j=O.groups;for(let W=0,X=j.length;W<X;W++){const G=j[W],Z=q[G.materialIndex];if(Z&&Z.visible){const te=M(A,Z,D,C);A.onBeforeShadow(t,A,k,T,O,te,G),t.renderBufferDirect(T,null,O,te,A,G),A.onAfterShadow(t,A,k,T,O,te,G)}}}else if(q.visible){const j=M(A,q,D,C);A.onBeforeShadow(t,A,k,T,O,j,null),t.renderBufferDirect(T,null,O,j,A,null),A.onAfterShadow(t,A,k,T,O,j,null)}}const U=A.children;for(let O=0,q=U.length;O<q;O++)E(U[O],k,T,D,C)}}function K8e(t,e,n){const r=n.isWebGL2;function i(){let ve=!1;const $e=new xr;let Le=null;const Te=new xr(0,0,0,0);return{setMask:function(We){Le!==We&&!ve&&(t.colorMask(We,We,We,We),Le=We)},setLocked:function(We){ve=We},setClear:function(We,it,Ot,kt,on){on===!0&&(We*=kt,it*=kt,Ot*=kt),$e.set(We,it,Ot,kt),Te.equals($e)===!1&&(t.clearColor(We,it,Ot,kt),Te.copy($e))},reset:function(){ve=!1,Le=null,Te.set(-1,0,0,0)}}}function a(){let ve=!1,$e=null,Le=null,Te=null;return{setTest:function(We){We?ge(t.DEPTH_TEST):Ne(t.DEPTH_TEST)},setMask:function(We){$e!==We&&!ve&&(t.depthMask(We),$e=We)},setFunc:function(We){if(Le!==We){switch(We){case aFe:t.depthFunc(t.NEVER);break;case sFe:t.depthFunc(t.ALWAYS);break;case oFe:t.depthFunc(t.LESS);break;case GS:t.depthFunc(t.LEQUAL);break;case lFe:t.depthFunc(t.EQUAL);break;case cFe:t.depthFunc(t.GEQUAL);break;case uFe:t.depthFunc(t.GREATER);break;case dFe:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}Le=We}},setLocked:function(We){ve=We},setClear:function(We){Te!==We&&(t.clearDepth(We),Te=We)},reset:function(){ve=!1,$e=null,Le=null,Te=null}}}function o(){let ve=!1,$e=null,Le=null,Te=null,We=null,it=null,Ot=null,kt=null,on=null;return{setTest:function(Ut){ve||(Ut?ge(t.STENCIL_TEST):Ne(t.STENCIL_TEST))},setMask:function(Ut){$e!==Ut&&!ve&&(t.stencilMask(Ut),$e=Ut)},setFunc:function(Ut,yn,xt){(Le!==Ut||Te!==yn||We!==xt)&&(t.stencilFunc(Ut,yn,xt),Le=Ut,Te=yn,We=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,Te=null,We=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,y=[],x=null,v=!1,S=null,M=null,E=null,A=null,k=null,T=null,D=null,C=new rn(0,0,0),R=0,U=!1,O=null,q=null,j=null,W=null,X=null;const G=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let Z=!1,te=0;const ee=t.getParameter(t.VERSION);ee.indexOf("WebGL")!==-1?(te=parseFloat(/^WebGL (\d)/.exec(ee)[1]),Z=te>=1):ee.indexOf("OpenGL ES")!==-1&&(te=parseFloat(/^OpenGL ES (\d)/.exec(ee)[1]),Z=te>=2);let z=null,V={};const ne=t.getParameter(t.SCISSOR_BOX),ie=t.getParameter(t.VIEWPORT),he=new xr().fromArray(ne),me=new xr().fromArray(ie);function oe(ve,$e,Le,Te){const We=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,Te,0,t.RGBA,t.UNSIGNED_BYTE,We):t.texImage2D($e+Ot,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,We);return it}const Ae={};Ae[t.TEXTURE_2D]=oe(t.TEXTURE_2D,t.TEXTURE_2D,1),Ae[t.TEXTURE_CUBE_MAP]=oe(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),r&&(Ae[t.TEXTURE_2D_ARRAY]=oe(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),Ae[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(GS),I(!1),ce(TG),ge(t.CULL_FACE),K($d);function ge(ve){m[ve]!==!0&&(t.enable(ve),m[ve]=!0)}function Ne(ve){m[ve]!==!1&&(t.disable(ve),m[ve]=!1)}function _e(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 le(ve,$e){let Le=y,Te=!1;if(ve)if(Le=b.get($e),Le===void 0&&(Le=[],b.set($e,Le)),ve.isWebGLMultipleRenderTargets){const We=ve.texture;if(Le.length!==We.length||Le[0]!==t.COLOR_ATTACHMENT0){for(let it=0,Ot=We.length;it<Ot;it++)Le[it]=t.COLOR_ATTACHMENT0+it;Le.length=We.length,Te=!0}}else Le[0]!==t.COLOR_ATTACHMENT0&&(Le[0]=t.COLOR_ATTACHMENT0,Te=!0);else Le[0]!==t.BACK&&(Le[0]=t.BACK,Te=!0);Te&&(n.isWebGL2?t.drawBuffers(Le):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(Le))}function He(ve){return x!==ve?(t.useProgram(ve),x=ve,!0):!1}const H={[nf]:t.FUNC_ADD,[VIe]:t.FUNC_SUBTRACT,[GIe]:t.FUNC_REVERSE_SUBTRACT};if(r)H[PG]=t.MIN,H[RG]=t.MAX;else{const ve=e.get("EXT_blend_minmax");ve!==null&&(H[PG]=ve.MIN_EXT,H[RG]=ve.MAX_EXT)}const J={[WIe]:t.ZERO,[qIe]:t.ONE,[KIe]:t.SRC_COLOR,[_R]:t.SRC_ALPHA,[eFe]:t.SRC_ALPHA_SATURATE,[ZIe]:t.DST_COLOR,[YIe]:t.DST_ALPHA,[XIe]:t.ONE_MINUS_SRC_COLOR,[wR]:t.ONE_MINUS_SRC_ALPHA,[JIe]:t.ONE_MINUS_DST_COLOR,[QIe]:t.ONE_MINUS_DST_ALPHA,[tFe]:t.CONSTANT_COLOR,[nFe]:t.ONE_MINUS_CONSTANT_COLOR,[rFe]:t.CONSTANT_ALPHA,[iFe]:t.ONE_MINUS_CONSTANT_ALPHA};function K(ve,$e,Le,Te,We,it,Ot,kt,on,Ut){if(ve===$d){v===!0&&(Ne(t.BLEND),v=!1);return}if(v===!1&&(ge(t.BLEND),v=!0),ve!==HIe){if(ve!==S||Ut!==U){if((M!==nf||k!==nf)&&(t.blendEquation(t.FUNC_ADD),M=nf,k=nf),Ut)switch(ve){case og:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case CG:t.blendFunc(t.ONE,t.ONE);break;case kG:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case jG: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 og:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case CG:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case kG:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case jG:t.blendFunc(t.ZERO,t.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",ve);break}E=null,A=null,T=null,D=null,C.set(0,0,0),R=0,S=ve,U=Ut}return}We=We||$e,it=it||Le,Ot=Ot||Te,($e!==M||We!==k)&&(t.blendEquationSeparate(H[$e],H[We]),M=$e,k=We),(Le!==E||Te!==A||it!==T||Ot!==D)&&(t.blendFuncSeparate(J[Le],J[Te],J[it],J[Ot]),E=Le,A=Te,T=it,D=Ot),(kt.equals(C)===!1||on!==R)&&(t.blendColor(kt.r,kt.g,kt.b,on),C.copy(kt),R=on),S=ve,U=!1}function B(ve,$e){ve.side===Yc?Ne(t.CULL_FACE):ge(t.CULL_FACE);let Le=ve.side===Ss;$e&&(Le=!Le),I(Le),ve.blending===og&&ve.transparent===!1?K($d):K(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 Te=ve.stencilWrite;u.setTest(Te),Te&&(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):Ne(t.SAMPLE_ALPHA_TO_COVERAGE)}function I(ve){O!==ve&&(ve?t.frontFace(t.CW):t.frontFace(t.CCW),O=ve)}function ce(ve){ve!==zIe?(ge(t.CULL_FACE),ve!==q&&(ve===TG?t.cullFace(t.BACK):ve===BIe?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):Ne(t.CULL_FACE),q=ve}function Ee(ve){ve!==j&&(Z&&t.lineWidth(ve),j=ve)}function Ie(ve,$e,Le){ve?(ge(t.POLYGON_OFFSET_FILL),(W!==$e||X!==Le)&&(t.polygonOffset($e,Le),W=$e,X=Le)):Ne(t.POLYGON_OFFSET_FILL)}function ue(ve){ve?ge(t.SCISSOR_TEST):Ne(t.SCISSOR_TEST)}function $(ve){ve===void 0&&(ve=t.TEXTURE0+G-1),z!==ve&&(t.activeTexture(ve),z=ve)}function L(ve,$e,Le){Le===void 0&&(z===null?Le=t.TEXTURE0+G-1:Le=z);let Te=V[Le];Te===void 0&&(Te={type:void 0,texture:void 0},V[Le]=Te),(Te.type!==ve||Te.texture!==$e)&&(z!==Le&&(t.activeTexture(Le),z=Le),t.bindTexture(ve,$e||Ae[ve]),Te.type=ve,Te.texture=$e)}function Y(){const ve=V[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 Se(){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 je(){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 Xe(){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 Qe(){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 ke(ve){he.equals(ve)===!1&&(t.scissor(ve.x,ve.y,ve.z,ve.w),he.copy(ve))}function Ue(ve){me.equals(ve)===!1&&(t.viewport(ve.x,ve.y,ve.z,ve.w),me.copy(ve))}function dt(ve,$e){let Le=f.get($e);Le===void 0&&(Le=new WeakMap,f.set($e,Le));let Te=Le.get(ve);Te===void 0&&(Te=t.getUniformBlockIndex($e,ve.name),Le.set(ve,Te))}function re(ve,$e){const Te=f.get($e).get(ve);d.get($e)!==Te&&(t.uniformBlockBinding($e,Te,ve.__bindingPointIndex),d.set($e,Te))}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,V={},p={},b=new WeakMap,y=[],x=null,v=!1,S=null,M=null,E=null,A=null,k=null,T=null,D=null,C=new rn(0,0,0),R=0,U=!1,O=null,q=null,j=null,W=null,X=null,he.set(0,0,t.canvas.width,t.canvas.height),me.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:Ne,bindFramebuffer:_e,drawBuffers:le,useProgram:He,setBlending:K,setMaterial:B,setFlipSided:I,setCullFace:ce,setLineWidth:Ee,setPolygonOffset:Ie,setScissorTest:ue,activeTexture:$,bindTexture:L,unbindTexture:Y,compressedTexImage2D:pe,compressedTexImage3D:Se,texImage2D:se,texImage3D:ye,updateUBOMapping:dt,uniformBlockBinding:re,texStorage2D:et,texStorage3D:Qe,texSubImage2D:ae,texSubImage3D:je,compressedTexSubImage2D:De,compressedTexSubImage3D:Xe,scissor:ke,viewport:Ue,reset:Fe}}function X8e(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 y;const x=new WeakMap;let v=!1;try{v=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function S($,L){return v?new OffscreenCanvas($,L):YS("canvas")}function M($,L,Y,pe){let Se=1;if(($.width>pe||$.height>pe)&&(Se=pe/Math.max($.width,$.height)),Se<1||L===!0)if(typeof HTMLImageElement<"u"&&$ instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&$ instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&$ instanceof ImageBitmap){const ae=L?XS:Math.floor,je=ae(Se*$.width),De=ae(Se*$.height);y===void 0&&(y=S(je,De));const Xe=Y?S(je,De):y;return Xe.width=je,Xe.height=De,Xe.getContext("2d").drawImage($,0,0,je,De),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+$.width+"x"+$.height+") to ("+je+"x"+De+")."),Xe}else return"data"in $&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+$.width+"x"+$.height+")."),$;return $}function E($){return CR($.width)&&CR($.height)}function A($){return l?!1:$.wrapS!==el||$.wrapT!==el||$.minFilter!==ya&&$.minFilter!==Mo}function k($,L){return $.generateMipmaps&&L&&$.minFilter!==ya&&$.minFilter!==Mo}function T($){t.generateMipmap($)}function D($,L,Y,pe,Se=!1){if(l===!1)return L;if($!==null){if(t[$]!==void 0)return t[$];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+$+"'")}let ae=L;if(L===t.RED&&(Y===t.FLOAT&&(ae=t.R32F),Y===t.HALF_FLOAT&&(ae=t.R16F),Y===t.UNSIGNED_BYTE&&(ae=t.R8)),L===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)),L===t.RG&&(Y===t.FLOAT&&(ae=t.RG32F),Y===t.HALF_FLOAT&&(ae=t.RG16F),Y===t.UNSIGNED_BYTE&&(ae=t.RG8)),L===t.RGBA){const je=Se?WS:pr.getTransfer(pe);Y===t.FLOAT&&(ae=t.RGBA32F),Y===t.HALF_FLOAT&&(ae=t.RGBA16F),Y===t.UNSIGNED_BYTE&&(ae=je===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 C($,L,Y){return k($,Y)===!0||$.isFramebufferTexture&&$.minFilter!==ya&&$.minFilter!==Mo?Math.log2(Math.max(L.width,L.height))+1:$.mipmaps!==void 0&&$.mipmaps.length>0?$.mipmaps.length:$.isCompressedTexture&&Array.isArray($.image)?L.mipmaps.length:1}function R($){return $===ya||$===DG||$===Tk?t.NEAREST:t.LINEAR}function U($){const L=$.target;L.removeEventListener("dispose",U),q(L),L.isVideoTexture&&b.delete(L)}function O($){const L=$.target;L.removeEventListener("dispose",O),W(L)}function q($){const L=r.get($);if(L.__webglInit===void 0)return;const Y=$.source,pe=x.get(Y);if(pe){const Se=pe[L.__cacheKey];Se.usedTimes--,Se.usedTimes===0&&j($),Object.keys(pe).length===0&&x.delete(Y)}r.remove($)}function j($){const L=r.get($);t.deleteTexture(L.__webglTexture);const Y=$.source,pe=x.get(Y);delete pe[L.__cacheKey],o.memory.textures--}function W($){const L=$.texture,Y=r.get($),pe=r.get(L);if(pe.__webglTexture!==void 0&&(t.deleteTexture(pe.__webglTexture),o.memory.textures--),$.depthTexture&&$.depthTexture.dispose(),$.isWebGLCubeRenderTarget)for(let Se=0;Se<6;Se++){if(Array.isArray(Y.__webglFramebuffer[Se]))for(let ae=0;ae<Y.__webglFramebuffer[Se].length;ae++)t.deleteFramebuffer(Y.__webglFramebuffer[Se][ae]);else t.deleteFramebuffer(Y.__webglFramebuffer[Se]);Y.__webglDepthbuffer&&t.deleteRenderbuffer(Y.__webglDepthbuffer[Se])}else{if(Array.isArray(Y.__webglFramebuffer))for(let Se=0;Se<Y.__webglFramebuffer.length;Se++)t.deleteFramebuffer(Y.__webglFramebuffer[Se]);else t.deleteFramebuffer(Y.__webglFramebuffer);if(Y.__webglDepthbuffer&&t.deleteRenderbuffer(Y.__webglDepthbuffer),Y.__webglMultisampledFramebuffer&&t.deleteFramebuffer(Y.__webglMultisampledFramebuffer),Y.__webglColorRenderbuffer)for(let Se=0;Se<Y.__webglColorRenderbuffer.length;Se++)Y.__webglColorRenderbuffer[Se]&&t.deleteRenderbuffer(Y.__webglColorRenderbuffer[Se]);Y.__webglDepthRenderbuffer&&t.deleteRenderbuffer(Y.__webglDepthRenderbuffer)}if($.isWebGLMultipleRenderTargets)for(let Se=0,ae=L.length;Se<ae;Se++){const je=r.get(L[Se]);je.__webglTexture&&(t.deleteTexture(je.__webglTexture),o.memory.textures--),r.remove(L[Se])}r.remove(L),r.remove($)}let X=0;function G(){X=0}function Z(){const $=X;return $>=c&&console.warn("THREE.WebGLTextures: Trying to use "+$+" texture units while this GPU supports only "+c),X+=1,$}function te($){const L=[];return L.push($.wrapS),L.push($.wrapT),L.push($.wrapR||0),L.push($.magFilter),L.push($.minFilter),L.push($.anisotropy),L.push($.internalFormat),L.push($.format),L.push($.type),L.push($.generateMipmaps),L.push($.premultiplyAlpha),L.push($.flipY),L.push($.unpackAlignment),L.push($.colorSpace),L.join()}function ee($,L){const Y=r.get($);if($.isVideoTexture&&Ie($),$.isRenderTargetTexture===!1&&$.version>0&&Y.__version!==$.version){const pe=$.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,$,L);return}}n.bindTexture(t.TEXTURE_2D,Y.__webglTexture,t.TEXTURE0+L)}function z($,L){const Y=r.get($);if($.version>0&&Y.__version!==$.version){ge(Y,$,L);return}n.bindTexture(t.TEXTURE_2D_ARRAY,Y.__webglTexture,t.TEXTURE0+L)}function V($,L){const Y=r.get($);if($.version>0&&Y.__version!==$.version){ge(Y,$,L);return}n.bindTexture(t.TEXTURE_3D,Y.__webglTexture,t.TEXTURE0+L)}function ne($,L){const Y=r.get($);if($.version>0&&Y.__version!==$.version){Ne(Y,$,L);return}n.bindTexture(t.TEXTURE_CUBE_MAP,Y.__webglTexture,t.TEXTURE0+L)}const ie={[NR]:t.REPEAT,[el]:t.CLAMP_TO_EDGE,[ER]:t.MIRRORED_REPEAT},he={[ya]:t.NEAREST,[DG]:t.NEAREST_MIPMAP_NEAREST,[Tk]:t.NEAREST_MIPMAP_LINEAR,[Mo]:t.LINEAR,[yFe]:t.LINEAR_MIPMAP_NEAREST,[Q0]:t.LINEAR_MIPMAP_LINEAR},me={[jFe]:t.NEVER,[IFe]:t.ALWAYS,[PFe]:t.LESS,[qee]:t.LEQUAL,[RFe]:t.EQUAL,[LFe]:t.GEQUAL,[DFe]:t.GREATER,[OFe]:t.NOTEQUAL};function oe($,L,Y){if(Y?(t.texParameteri($,t.TEXTURE_WRAP_S,ie[L.wrapS]),t.texParameteri($,t.TEXTURE_WRAP_T,ie[L.wrapT]),($===t.TEXTURE_3D||$===t.TEXTURE_2D_ARRAY)&&t.texParameteri($,t.TEXTURE_WRAP_R,ie[L.wrapR]),t.texParameteri($,t.TEXTURE_MAG_FILTER,he[L.magFilter]),t.texParameteri($,t.TEXTURE_MIN_FILTER,he[L.minFilter])):(t.texParameteri($,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri($,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),($===t.TEXTURE_3D||$===t.TEXTURE_2D_ARRAY)&&t.texParameteri($,t.TEXTURE_WRAP_R,t.CLAMP_TO_EDGE),(L.wrapS!==el||L.wrapT!==el)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),t.texParameteri($,t.TEXTURE_MAG_FILTER,R(L.magFilter)),t.texParameteri($,t.TEXTURE_MIN_FILTER,R(L.minFilter)),L.minFilter!==ya&&L.minFilter!==Mo&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),L.compareFunction&&(t.texParameteri($,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri($,t.TEXTURE_COMPARE_FUNC,me[L.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const pe=e.get("EXT_texture_filter_anisotropic");if(L.magFilter===ya||L.minFilter!==Tk&&L.minFilter!==Q0||L.type===tu&&e.has("OES_texture_float_linear")===!1||l===!1&&L.type===Z0&&e.has("OES_texture_half_float_linear")===!1)return;(L.anisotropy>1||r.get(L).__currentAnisotropy)&&(t.texParameterf($,pe.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(L.anisotropy,i.getMaxAnisotropy())),r.get(L).__currentAnisotropy=L.anisotropy)}}function Ae($,L){let Y=!1;$.__webglInit===void 0&&($.__webglInit=!0,L.addEventListener("dispose",U));const pe=L.source;let Se=x.get(pe);Se===void 0&&(Se={},x.set(pe,Se));const ae=te(L);if(ae!==$.__cacheKey){Se[ae]===void 0&&(Se[ae]={texture:t.createTexture(),usedTimes:0},o.memory.textures++,Y=!0),Se[ae].usedTimes++;const je=Se[$.__cacheKey];je!==void 0&&(Se[$.__cacheKey].usedTimes--,je.usedTimes===0&&j(L)),$.__cacheKey=ae,$.__webglTexture=Se[ae].texture}return Y}function ge($,L,Y){let pe=t.TEXTURE_2D;(L.isDataArrayTexture||L.isCompressedArrayTexture)&&(pe=t.TEXTURE_2D_ARRAY),L.isData3DTexture&&(pe=t.TEXTURE_3D);const Se=Ae($,L),ae=L.source;n.bindTexture(pe,$.__webglTexture,t.TEXTURE0+Y);const je=r.get(ae);if(ae.version!==je.__version||Se===!0){n.activeTexture(t.TEXTURE0+Y);const De=pr.getPrimaries(pr.workingColorSpace),Xe=L.colorSpace===Eo?null:pr.getPrimaries(L.colorSpace),et=L.colorSpace===Eo||De===Xe?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,et);const Qe=A(L)&&E(L.image)===!1;let se=M(L.image,Qe,!1,d);se=ue(L,se);const ye=E(se)||l,ke=a.convert(L.format,L.colorSpace);let Ue=a.convert(L.type),dt=D(L.internalFormat,ke,Ue,L.colorSpace,L.isVideoTexture);oe(pe,L,ye);let re;const Fe=L.mipmaps,ve=l&&L.isVideoTexture!==!0&&dt!==Vee,$e=je.__version===void 0||Se===!0,Le=C(L,se,ye);if(L.isDepthTexture)dt=t.DEPTH_COMPONENT,l?L.type===tu?dt=t.DEPTH_COMPONENT32F:L.type===jd?dt=t.DEPTH_COMPONENT24:L.type===Af?dt=t.DEPTH24_STENCIL8:dt=t.DEPTH_COMPONENT16:L.type===tu&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),L.format===Tf&&dt===t.DEPTH_COMPONENT&&L.type!==mL&&L.type!==jd&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),L.type=jd,Ue=a.convert(L.type)),L.format===Dg&&dt===t.DEPTH_COMPONENT&&(dt=t.DEPTH_STENCIL,L.type!==Af&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),L.type=Af,Ue=a.convert(L.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,ke,Ue,null));else if(L.isDataTexture)if(Fe.length>0&&ye){ve&&$e&&n.texStorage2D(t.TEXTURE_2D,Le,dt,Fe[0].width,Fe[0].height);for(let Te=0,We=Fe.length;Te<We;Te++)re=Fe[Te],ve?n.texSubImage2D(t.TEXTURE_2D,Te,0,0,re.width,re.height,ke,Ue,re.data):n.texImage2D(t.TEXTURE_2D,Te,dt,re.width,re.height,0,ke,Ue,re.data);L.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,ke,Ue,se.data)):n.texImage2D(t.TEXTURE_2D,0,dt,se.width,se.height,0,ke,Ue,se.data);else if(L.isCompressedTexture)if(L.isCompressedArrayTexture){ve&&$e&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Le,dt,Fe[0].width,Fe[0].height,se.depth);for(let Te=0,We=Fe.length;Te<We;Te++)re=Fe[Te],L.format!==No?ke!==null?ve?n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Te,0,0,0,re.width,re.height,se.depth,ke,re.data,0,0):n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,Te,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,Te,0,0,0,re.width,re.height,se.depth,ke,Ue,re.data):n.texImage3D(t.TEXTURE_2D_ARRAY,Te,dt,re.width,re.height,se.depth,0,ke,Ue,re.data)}else{ve&&$e&&n.texStorage2D(t.TEXTURE_2D,Le,dt,Fe[0].width,Fe[0].height);for(let Te=0,We=Fe.length;Te<We;Te++)re=Fe[Te],L.format!==No?ke!==null?ve?n.compressedTexSubImage2D(t.TEXTURE_2D,Te,0,0,re.width,re.height,ke,re.data):n.compressedTexImage2D(t.TEXTURE_2D,Te,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,Te,0,0,re.width,re.height,ke,Ue,re.data):n.texImage2D(t.TEXTURE_2D,Te,dt,re.width,re.height,0,ke,Ue,re.data)}else if(L.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,ke,Ue,se.data)):n.texImage3D(t.TEXTURE_2D_ARRAY,0,dt,se.width,se.height,se.depth,0,ke,Ue,se.data);else if(L.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,ke,Ue,se.data)):n.texImage3D(t.TEXTURE_3D,0,dt,se.width,se.height,se.depth,0,ke,Ue,se.data);else if(L.isFramebufferTexture){if($e)if(ve)n.texStorage2D(t.TEXTURE_2D,Le,dt,se.width,se.height);else{let Te=se.width,We=se.height;for(let it=0;it<Le;it++)n.texImage2D(t.TEXTURE_2D,it,dt,Te,We,0,ke,Ue,null),Te>>=1,We>>=1}}else if(Fe.length>0&&ye){ve&&$e&&n.texStorage2D(t.TEXTURE_2D,Le,dt,Fe[0].width,Fe[0].height);for(let Te=0,We=Fe.length;Te<We;Te++)re=Fe[Te],ve?n.texSubImage2D(t.TEXTURE_2D,Te,0,0,ke,Ue,re):n.texImage2D(t.TEXTURE_2D,Te,dt,ke,Ue,re);L.generateMipmaps=!1}else ve?($e&&n.texStorage2D(t.TEXTURE_2D,Le,dt,se.width,se.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,ke,Ue,se)):n.texImage2D(t.TEXTURE_2D,0,dt,ke,Ue,se);k(L,ye)&&T(pe),je.__version=ae.version,L.onUpdate&&L.onUpdate(L)}$.__version=L.version}function Ne($,L,Y){if(L.image.length!==6)return;const pe=Ae($,L),Se=L.source;n.bindTexture(t.TEXTURE_CUBE_MAP,$.__webglTexture,t.TEXTURE0+Y);const ae=r.get(Se);if(Se.version!==ae.__version||pe===!0){n.activeTexture(t.TEXTURE0+Y);const je=pr.getPrimaries(pr.workingColorSpace),De=L.colorSpace===Eo?null:pr.getPrimaries(L.colorSpace),Xe=L.colorSpace===Eo||je===De?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Xe);const et=L.isCompressedTexture||L.image[0].isCompressedTexture,Qe=L.image[0]&&L.image[0].isDataTexture,se=[];for(let Te=0;Te<6;Te++)!et&&!Qe?se[Te]=M(L.image[Te],!1,!0,u):se[Te]=Qe?L.image[Te].image:L.image[Te],se[Te]=ue(L,se[Te]);const ye=se[0],ke=E(ye)||l,Ue=a.convert(L.format,L.colorSpace),dt=a.convert(L.type),re=D(L.internalFormat,Ue,dt,L.colorSpace),Fe=l&&L.isVideoTexture!==!0,ve=ae.__version===void 0||pe===!0;let $e=C(L,ye,ke);oe(t.TEXTURE_CUBE_MAP,L,ke);let Le;if(et){Fe&&ve&&n.texStorage2D(t.TEXTURE_CUBE_MAP,$e,re,ye.width,ye.height);for(let Te=0;Te<6;Te++){Le=se[Te].mipmaps;for(let We=0;We<Le.length;We++){const it=Le[We];L.format!==No?Ue!==null?Fe?n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,We,0,0,it.width,it.height,Ue,it.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,We,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+Te,We,0,0,it.width,it.height,Ue,dt,it.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,We,re,it.width,it.height,0,Ue,dt,it.data)}}}else{Le=L.mipmaps,Fe&&ve&&(Le.length>0&&$e++,n.texStorage2D(t.TEXTURE_CUBE_MAP,$e,re,se[0].width,se[0].height));for(let Te=0;Te<6;Te++)if(Qe){Fe?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,0,0,0,se[Te].width,se[Te].height,Ue,dt,se[Te].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,0,re,se[Te].width,se[Te].height,0,Ue,dt,se[Te].data);for(let We=0;We<Le.length;We++){const Ot=Le[We].image[Te].image;Fe?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,We+1,0,0,Ot.width,Ot.height,Ue,dt,Ot.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,We+1,re,Ot.width,Ot.height,0,Ue,dt,Ot.data)}}else{Fe?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,0,0,0,Ue,dt,se[Te]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,0,re,Ue,dt,se[Te]);for(let We=0;We<Le.length;We++){const it=Le[We];Fe?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,We+1,0,0,Ue,dt,it.image[Te]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,We+1,re,Ue,dt,it.image[Te])}}}k(L,ke)&&T(t.TEXTURE_CUBE_MAP),ae.__version=Se.version,L.onUpdate&&L.onUpdate(L)}$.__version=L.version}function _e($,L,Y,pe,Se,ae){const je=a.convert(Y.format,Y.colorSpace),De=a.convert(Y.type),Xe=D(Y.internalFormat,je,De,Y.colorSpace);if(!r.get(L).__hasExternalTextures){const Qe=Math.max(1,L.width>>ae),se=Math.max(1,L.height>>ae);Se===t.TEXTURE_3D||Se===t.TEXTURE_2D_ARRAY?n.texImage3D(Se,ae,Xe,Qe,se,L.depth,0,je,De,null):n.texImage2D(Se,ae,Xe,Qe,se,0,je,De,null)}n.bindFramebuffer(t.FRAMEBUFFER,$),Ee(L)?m.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,pe,Se,r.get(Y).__webglTexture,0,ce(L)):(Se===t.TEXTURE_2D||Se>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&Se<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,pe,Se,r.get(Y).__webglTexture,ae),n.bindFramebuffer(t.FRAMEBUFFER,null)}function le($,L,Y){if(t.bindRenderbuffer(t.RENDERBUFFER,$),L.depthBuffer&&!L.stencilBuffer){let pe=l===!0?t.DEPTH_COMPONENT24:t.DEPTH_COMPONENT16;if(Y||Ee(L)){const Se=L.depthTexture;Se&&Se.isDepthTexture&&(Se.type===tu?pe=t.DEPTH_COMPONENT32F:Se.type===jd&&(pe=t.DEPTH_COMPONENT24));const ae=ce(L);Ee(L)?m.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ae,pe,L.width,L.height):t.renderbufferStorageMultisample(t.RENDERBUFFER,ae,pe,L.width,L.height)}else t.renderbufferStorage(t.RENDERBUFFER,pe,L.width,L.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,$)}else if(L.depthBuffer&&L.stencilBuffer){const pe=ce(L);Y&&Ee(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,pe,t.DEPTH24_STENCIL8,L.width,L.height):Ee(L)?m.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,pe,t.DEPTH24_STENCIL8,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,L.width,L.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,$)}else{const pe=L.isWebGLMultipleRenderTargets===!0?L.texture:[L.texture];for(let Se=0;Se<pe.length;Se++){const ae=pe[Se],je=a.convert(ae.format,ae.colorSpace),De=a.convert(ae.type),Xe=D(ae.internalFormat,je,De,ae.colorSpace),et=ce(L);Y&&Ee(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,et,Xe,L.width,L.height):Ee(L)?m.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,et,Xe,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,Xe,L.width,L.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function He($,L){if(L&&L.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,$),!(L.depthTexture&&L.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(L.depthTexture).__webglTexture||L.depthTexture.image.width!==L.width||L.depthTexture.image.height!==L.height)&&(L.depthTexture.image.width=L.width,L.depthTexture.image.height=L.height,L.depthTexture.needsUpdate=!0),ee(L.depthTexture,0);const pe=r.get(L.depthTexture).__webglTexture,Se=ce(L);if(L.depthTexture.format===Tf)Ee(L)?m.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,pe,0,Se):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,pe,0);else if(L.depthTexture.format===Dg)Ee(L)?m.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,pe,0,Se):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,pe,0);else throw new Error("Unknown depthTexture format")}function H($){const L=r.get($),Y=$.isWebGLCubeRenderTarget===!0;if($.depthTexture&&!L.__autoAllocateDepthBuffer){if(Y)throw new Error("target.depthTexture not supported in Cube render targets");He(L.__webglFramebuffer,$)}else if(Y){L.__webglDepthbuffer=[];for(let pe=0;pe<6;pe++)n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[pe]),L.__webglDepthbuffer[pe]=t.createRenderbuffer(),le(L.__webglDepthbuffer[pe],$,!1)}else n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer),L.__webglDepthbuffer=t.createRenderbuffer(),le(L.__webglDepthbuffer,$,!1);n.bindFramebuffer(t.FRAMEBUFFER,null)}function J($,L,Y){const pe=r.get($);L!==void 0&&_e(pe.__webglFramebuffer,$,$.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),Y!==void 0&&H($)}function K($){const L=$.texture,Y=r.get($),pe=r.get(L);$.addEventListener("dispose",O),$.isWebGLMultipleRenderTargets!==!0&&(pe.__webglTexture===void 0&&(pe.__webglTexture=t.createTexture()),pe.__version=L.version,o.memory.textures++);const Se=$.isWebGLCubeRenderTarget===!0,ae=$.isWebGLMultipleRenderTargets===!0,je=E($)||l;if(Se){Y.__webglFramebuffer=[];for(let De=0;De<6;De++)if(l&&L.mipmaps&&L.mipmaps.length>0){Y.__webglFramebuffer[De]=[];for(let Xe=0;Xe<L.mipmaps.length;Xe++)Y.__webglFramebuffer[De][Xe]=t.createFramebuffer()}else Y.__webglFramebuffer[De]=t.createFramebuffer()}else{if(l&&L.mipmaps&&L.mipmaps.length>0){Y.__webglFramebuffer=[];for(let De=0;De<L.mipmaps.length;De++)Y.__webglFramebuffer[De]=t.createFramebuffer()}else Y.__webglFramebuffer=t.createFramebuffer();if(ae)if(i.drawBuffers){const De=$.texture;for(let Xe=0,et=De.length;Xe<et;Xe++){const Qe=r.get(De[Xe]);Qe.__webglTexture===void 0&&(Qe.__webglTexture=t.createTexture(),o.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(l&&$.samples>0&&Ee($)===!1){const De=ae?L:[L];Y.__webglMultisampledFramebuffer=t.createFramebuffer(),Y.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,Y.__webglMultisampledFramebuffer);for(let Xe=0;Xe<De.length;Xe++){const et=De[Xe];Y.__webglColorRenderbuffer[Xe]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,Y.__webglColorRenderbuffer[Xe]);const Qe=a.convert(et.format,et.colorSpace),se=a.convert(et.type),ye=D(et.internalFormat,Qe,se,et.colorSpace,$.isXRRenderTarget===!0),ke=ce($);t.renderbufferStorageMultisample(t.RENDERBUFFER,ke,ye,$.width,$.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Xe,t.RENDERBUFFER,Y.__webglColorRenderbuffer[Xe])}t.bindRenderbuffer(t.RENDERBUFFER,null),$.depthBuffer&&(Y.__webglDepthRenderbuffer=t.createRenderbuffer(),le(Y.__webglDepthRenderbuffer,$,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(Se){n.bindTexture(t.TEXTURE_CUBE_MAP,pe.__webglTexture),oe(t.TEXTURE_CUBE_MAP,L,je);for(let De=0;De<6;De++)if(l&&L.mipmaps&&L.mipmaps.length>0)for(let Xe=0;Xe<L.mipmaps.length;Xe++)_e(Y.__webglFramebuffer[De][Xe],$,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+De,Xe);else _e(Y.__webglFramebuffer[De],$,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+De,0);k(L,je)&&T(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(ae){const De=$.texture;for(let Xe=0,et=De.length;Xe<et;Xe++){const Qe=De[Xe],se=r.get(Qe);n.bindTexture(t.TEXTURE_2D,se.__webglTexture),oe(t.TEXTURE_2D,Qe,je),_e(Y.__webglFramebuffer,$,Qe,t.COLOR_ATTACHMENT0+Xe,t.TEXTURE_2D,0),k(Qe,je)&&T(t.TEXTURE_2D)}n.unbindTexture()}else{let De=t.TEXTURE_2D;if(($.isWebGL3DRenderTarget||$.isWebGLArrayRenderTarget)&&(l?De=$.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,L,je),l&&L.mipmaps&&L.mipmaps.length>0)for(let Xe=0;Xe<L.mipmaps.length;Xe++)_e(Y.__webglFramebuffer[Xe],$,L,t.COLOR_ATTACHMENT0,De,Xe);else _e(Y.__webglFramebuffer,$,L,t.COLOR_ATTACHMENT0,De,0);k(L,je)&&T(De),n.unbindTexture()}$.depthBuffer&&H($)}function B($){const L=E($)||l,Y=$.isWebGLMultipleRenderTargets===!0?$.texture:[$.texture];for(let pe=0,Se=Y.length;pe<Se;pe++){const ae=Y[pe];if(k(ae,L)){const je=$.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,De=r.get(ae).__webglTexture;n.bindTexture(je,De),T(je),n.unbindTexture()}}}function I($){if(l&&$.samples>0&&Ee($)===!1){const L=$.isWebGLMultipleRenderTargets?$.texture:[$.texture],Y=$.width,pe=$.height;let Se=t.COLOR_BUFFER_BIT;const ae=[],je=$.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,De=r.get($),Xe=$.isWebGLMultipleRenderTargets===!0;if(Xe)for(let et=0;et<L.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<L.length;et++){ae.push(t.COLOR_ATTACHMENT0+et),$.depthBuffer&&ae.push(je);const Qe=De.__ignoreDepthValues!==void 0?De.__ignoreDepthValues:!1;if(Qe===!1&&($.depthBuffer&&(Se|=t.DEPTH_BUFFER_BIT),$.stencilBuffer&&(Se|=t.STENCIL_BUFFER_BIT)),Xe&&t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,De.__webglColorRenderbuffer[et]),Qe===!0&&(t.invalidateFramebuffer(t.READ_FRAMEBUFFER,[je]),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[je])),Xe){const se=r.get(L[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,Se,t.NEAREST),p&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,ae)}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Xe)for(let et=0;et<L.length;et++){n.bindFramebuffer(t.FRAMEBUFFER,De.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+et,t.RENDERBUFFER,De.__webglColorRenderbuffer[et]);const Qe=r.get(L[et]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,De.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+et,t.TEXTURE_2D,Qe,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,De.__webglMultisampledFramebuffer)}}function ce($){return Math.min(f,$.samples)}function Ee($){const L=r.get($);return l&&$.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&L.__useRenderToTexture!==!1}function Ie($){const L=o.render.frame;b.get($)!==L&&(b.set($,L),$.update())}function ue($,L){const Y=$.colorSpace,pe=$.format,Se=$.type;return $.isCompressedTexture===!0||$.isVideoTexture===!0||$.format===TR||Y!==wu&&Y!==Eo&&(pr.getTransfer(Y)===Dr?l===!1?e.has("EXT_sRGB")===!0&&pe===No?($.format=TR,$.minFilter=Mo,$.generateMipmaps=!1):L=Yee.sRGBToLinear(L):(pe!==No||Se!==Vd)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",Y)),L}this.allocateTextureUnit=Z,this.resetTextureUnits=G,this.setTexture2D=ee,this.setTexture2DArray=z,this.setTexture3D=V,this.setTextureCube=ne,this.rebindTextures=J,this.setupRenderTarget=K,this.updateRenderTargetMipmap=B,this.updateMultisampleRenderTarget=I,this.setupDepthRenderbuffer=H,this.setupFrameBufferTexture=_e,this.useMultisampledRTT=Ee}function Y8e(t,e,n){const r=n.isWebGL2;function i(a,o=Eo){let l;const c=pr.getTransfer(o);if(a===Vd)return t.UNSIGNED_BYTE;if(a===Uee)return t.UNSIGNED_SHORT_4_4_4_4;if(a===zee)return t.UNSIGNED_SHORT_5_5_5_1;if(a===vFe)return t.BYTE;if(a===_Fe)return t.SHORT;if(a===mL)return t.UNSIGNED_SHORT;if(a===Fee)return t.INT;if(a===jd)return t.UNSIGNED_INT;if(a===tu)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===wFe)return t.ALPHA;if(a===No)return t.RGBA;if(a===SFe)return t.LUMINANCE;if(a===MFe)return t.LUMINANCE_ALPHA;if(a===Tf)return t.DEPTH_COMPONENT;if(a===Dg)return t.DEPTH_STENCIL;if(a===TR)return l=e.get("EXT_sRGB"),l!==null?l.SRGB_ALPHA_EXT:null;if(a===NFe)return t.RED;if(a===Bee)return t.RED_INTEGER;if(a===EFe)return t.RG;if(a===$ee)return t.RG_INTEGER;if(a===Hee)return t.RGBA_INTEGER;if(a===Ck||a===kk||a===jk||a===Pk)if(c===Dr)if(l=e.get("WEBGL_compressed_texture_s3tc_srgb"),l!==null){if(a===Ck)return l.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(a===kk)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(a===jk)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(a===Pk)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(l=e.get("WEBGL_compressed_texture_s3tc"),l!==null){if(a===Ck)return l.COMPRESSED_RGB_S3TC_DXT1_EXT;if(a===kk)return l.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(a===jk)return l.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(a===Pk)return l.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(a===OG||a===LG||a===IG||a===FG)if(l=e.get("WEBGL_compressed_texture_pvrtc"),l!==null){if(a===OG)return l.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(a===LG)return l.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(a===IG)return l.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(a===FG)return l.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(a===Vee)return l=e.get("WEBGL_compressed_texture_etc1"),l!==null?l.COMPRESSED_RGB_ETC1_WEBGL:null;if(a===UG||a===zG)if(l=e.get("WEBGL_compressed_texture_etc"),l!==null){if(a===UG)return c===Dr?l.COMPRESSED_SRGB8_ETC2:l.COMPRESSED_RGB8_ETC2;if(a===zG)return c===Dr?l.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:l.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(a===BG||a===$G||a===HG||a===VG||a===GG||a===WG||a===qG||a===KG||a===XG||a===YG||a===QG||a===ZG||a===JG||a===e7)if(l=e.get("WEBGL_compressed_texture_astc"),l!==null){if(a===BG)return c===Dr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:l.COMPRESSED_RGBA_ASTC_4x4_KHR;if(a===$G)return c===Dr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:l.COMPRESSED_RGBA_ASTC_5x4_KHR;if(a===HG)return c===Dr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:l.COMPRESSED_RGBA_ASTC_5x5_KHR;if(a===VG)return c===Dr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:l.COMPRESSED_RGBA_ASTC_6x5_KHR;if(a===GG)return c===Dr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:l.COMPRESSED_RGBA_ASTC_6x6_KHR;if(a===WG)return c===Dr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:l.COMPRESSED_RGBA_ASTC_8x5_KHR;if(a===qG)return c===Dr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:l.COMPRESSED_RGBA_ASTC_8x6_KHR;if(a===KG)return c===Dr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:l.COMPRESSED_RGBA_ASTC_8x8_KHR;if(a===XG)return c===Dr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:l.COMPRESSED_RGBA_ASTC_10x5_KHR;if(a===YG)return c===Dr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:l.COMPRESSED_RGBA_ASTC_10x6_KHR;if(a===QG)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===JG)return c===Dr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:l.COMPRESSED_RGBA_ASTC_12x10_KHR;if(a===e7)return c===Dr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:l.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(a===Rk||a===t7||a===n7)if(l=e.get("EXT_texture_compression_bptc"),l!==null){if(a===Rk)return c===Dr?l.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:l.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(a===t7)return l.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(a===n7)return l.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(a===AFe||a===r7||a===i7||a===a7)if(l=e.get("EXT_texture_compression_rgtc"),l!==null){if(a===Rk)return l.COMPRESSED_RED_RGTC1_EXT;if(a===r7)return l.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(a===i7)return l.COMPRESSED_RED_GREEN_RGTC2_EXT;if(a===a7)return l.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return a===Af?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 Q8e extends zs{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Wb extends es{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Z8e={type:"move"};class nj{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Wb,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 Wb,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 Wb,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 y of e.hand.values()){const x=n.getJointPose(y,r),v=this._getHandJoint(u,y);x!==null&&(v.matrix.fromArray(x.transform.matrix),v.matrix.decompose(v.position,v.rotation,v.scale),v.matrixWorldNeedsUpdate=!0,v.jointRadius=x.radius),v.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 Wb;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}}class J8e extends fm{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 y=n.getContextAttributes();let x=null,v=null;const S=[],M=[],E=new mn;let A=null;const k=new zs;k.layers.enable(1),k.viewport=new xr;const T=new zs;T.layers.enable(2),T.viewport=new xr;const D=[k,T],C=new Q8e;C.layers.enable(1),C.layers.enable(2);let R=null,U=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(ne){let ie=S[ne];return ie===void 0&&(ie=new nj,S[ne]=ie),ie.getTargetRaySpace()},this.getControllerGrip=function(ne){let ie=S[ne];return ie===void 0&&(ie=new nj,S[ne]=ie),ie.getGripSpace()},this.getHand=function(ne){let ie=S[ne];return ie===void 0&&(ie=new nj,S[ne]=ie),ie.getHandSpace()};function O(ne){const ie=M.indexOf(ne.inputSource);if(ie===-1)return;const he=S[ie];he!==void 0&&(he.update(ne.inputSource,ne.frame,u||o),he.dispatchEvent({type:ne.type,data:ne.inputSource}))}function q(){i.removeEventListener("select",O),i.removeEventListener("selectstart",O),i.removeEventListener("selectend",O),i.removeEventListener("squeeze",O),i.removeEventListener("squeezestart",O),i.removeEventListener("squeezeend",O),i.removeEventListener("end",q),i.removeEventListener("inputsourceschange",j);for(let ne=0;ne<S.length;ne++){const ie=M[ne];ie!==null&&(M[ne]=null,S[ne].disconnect(ie))}R=null,U=null,e.setRenderTarget(x),p=null,m=null,f=null,i=null,v=null,V.stop(),r.isPresenting=!1,e.setPixelRatio(A),e.setSize(E.width,E.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ne){a=ne,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ne){l=ne,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(ne){u=ne},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(ne){if(i=ne,i!==null){if(x=e.getRenderTarget(),i.addEventListener("select",O),i.addEventListener("selectstart",O),i.addEventListener("selectend",O),i.addEventListener("squeeze",O),i.addEventListener("squeezestart",O),i.addEventListener("squeezeend",O),i.addEventListener("end",q),i.addEventListener("inputsourceschange",j),y.xrCompatible!==!0&&await n.makeXRCompatible(),A=e.getPixelRatio(),e.getSize(E),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const ie={antialias:i.renderState.layers===void 0?y.antialias:!0,alpha:!0,depth:y.depth,stencil:y.stencil,framebufferScaleFactor:a};p=new XRWebGLLayer(i,n,ie),i.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),v=new tm(p.framebufferWidth,p.framebufferHeight,{format:No,type:Vd,colorSpace:e.outputColorSpace,stencilBuffer:y.stencil})}else{let ie=null,he=null,me=null;y.depth&&(me=y.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,ie=y.stencil?Dg:Tf,he=y.stencil?Af:jd);const oe={colorFormat:n.RGBA8,depthFormat:me,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),v=new tm(m.textureWidth,m.textureHeight,{format:No,type:Vd,depthTexture:new lte(m.textureWidth,m.textureHeight,he,void 0,void 0,void 0,void 0,void 0,void 0,ie),stencilBuffer:y.stencil,colorSpace:e.outputColorSpace,samples:y.antialias?4:0});const Ae=e.properties.get(v);Ae.__ignoreDepthValues=m.ignoreDepthValues}v.isXRRenderTarget=!0,this.setFoveation(c),u=null,o=await i.requestReferenceSpace(l),V.setContext(i),V.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode};function j(ne){for(let ie=0;ie<ne.removed.length;ie++){const he=ne.removed[ie],me=M.indexOf(he);me>=0&&(M[me]=null,S[me].disconnect(he))}for(let ie=0;ie<ne.added.length;ie++){const he=ne.added[ie];let me=M.indexOf(he);if(me===-1){for(let Ae=0;Ae<S.length;Ae++)if(Ae>=M.length){M.push(he),me=Ae;break}else if(M[Ae]===null){M[Ae]=he,me=Ae;break}if(me===-1)break}const oe=S[me];oe&&oe.connect(he)}}const W=new Be,X=new Be;function G(ne,ie,he){W.setFromMatrixPosition(ie.matrixWorld),X.setFromMatrixPosition(he.matrixWorld);const me=W.distanceTo(X),oe=ie.projectionMatrix.elements,Ae=he.projectionMatrix.elements,ge=oe[14]/(oe[10]-1),Ne=oe[14]/(oe[10]+1),_e=(oe[9]+1)/oe[5],le=(oe[9]-1)/oe[5],He=(oe[8]-1)/oe[0],H=(Ae[8]+1)/Ae[0],J=ge*He,K=ge*H,B=me/(-He+H),I=B*-He;ie.matrixWorld.decompose(ne.position,ne.quaternion,ne.scale),ne.translateX(I),ne.translateZ(B),ne.matrixWorld.compose(ne.position,ne.quaternion,ne.scale),ne.matrixWorldInverse.copy(ne.matrixWorld).invert();const ce=ge+B,Ee=Ne+B,Ie=J-I,ue=K+(me-I),$=_e*Ne/Ee*ce,L=le*Ne/Ee*ce;ne.projectionMatrix.makePerspective(Ie,ue,$,L,ce,Ee),ne.projectionMatrixInverse.copy(ne.projectionMatrix).invert()}function Z(ne,ie){ie===null?ne.matrixWorld.copy(ne.matrix):ne.matrixWorld.multiplyMatrices(ie.matrixWorld,ne.matrix),ne.matrixWorldInverse.copy(ne.matrixWorld).invert()}this.updateCamera=function(ne){if(i===null)return;C.near=T.near=k.near=ne.near,C.far=T.far=k.far=ne.far,(R!==C.near||U!==C.far)&&(i.updateRenderState({depthNear:C.near,depthFar:C.far}),R=C.near,U=C.far);const ie=ne.parent,he=C.cameras;Z(C,ie);for(let me=0;me<he.length;me++)Z(he[me],ie);he.length===2?G(C,k,T):C.projectionMatrix.copy(k.projectionMatrix),te(ne,C,ie)};function te(ne,ie,he){he===null?ne.matrix.copy(ie.matrixWorld):(ne.matrix.copy(he.matrixWorld),ne.matrix.invert(),ne.matrix.multiply(ie.matrixWorld)),ne.matrix.decompose(ne.position,ne.quaternion,ne.scale),ne.updateMatrixWorld(!0),ne.projectionMatrix.copy(ie.projectionMatrix),ne.projectionMatrixInverse.copy(ie.projectionMatrixInverse),ne.isPerspectiveCamera&&(ne.fov=ey*2*Math.atan(1/ne.projectionMatrix.elements[5]),ne.zoom=1)}this.getCamera=function(){return C},this.getFoveation=function(){if(!(m===null&&p===null))return c},this.setFoveation=function(ne){c=ne,m!==null&&(m.fixedFoveation=ne),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=ne)};let ee=null;function z(ne,ie){if(d=ie.getViewerPose(u||o),b=ie,d!==null){const he=d.views;p!==null&&(e.setRenderTargetFramebuffer(v,p.framebuffer),e.setRenderTarget(v));let me=!1;he.length!==C.cameras.length&&(C.cameras.length=0,me=!0);for(let oe=0;oe<he.length;oe++){const Ae=he[oe];let ge=null;if(p!==null)ge=p.getViewport(Ae);else{const _e=f.getViewSubImage(m,Ae);ge=_e.viewport,oe===0&&(e.setRenderTargetTextures(v,_e.colorTexture,m.ignoreDepthValues?void 0:_e.depthStencilTexture),e.setRenderTarget(v))}let Ne=D[oe];Ne===void 0&&(Ne=new zs,Ne.layers.enable(oe),Ne.viewport=new xr,D[oe]=Ne),Ne.matrix.fromArray(Ae.transform.matrix),Ne.matrix.decompose(Ne.position,Ne.quaternion,Ne.scale),Ne.projectionMatrix.fromArray(Ae.projectionMatrix),Ne.projectionMatrixInverse.copy(Ne.projectionMatrix).invert(),Ne.viewport.set(ge.x,ge.y,ge.width,ge.height),oe===0&&(C.matrix.copy(Ne.matrix),C.matrix.decompose(C.position,C.quaternion,C.scale)),me===!0&&C.cameras.push(Ne)}}for(let he=0;he<S.length;he++){const me=M[he],oe=S[he];me!==null&&oe!==void 0&&oe.update(me,ie,u||o)}ee&&ee(ne,ie),ie.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:ie}),b=null}const V=new ote;V.setAnimationLoop(z),this.setAnimationLoop=function(ne){ee=ne},this.dispose=function(){}}}function e6e(t,e){function n(x,v){x.matrixAutoUpdate===!0&&x.updateMatrix(),v.value.copy(x.matrix)}function r(x,v){v.color.getRGB(x.fogColor.value,ite(t)),v.isFog?(x.fogNear.value=v.near,x.fogFar.value=v.far):v.isFogExp2&&(x.fogDensity.value=v.density)}function i(x,v,S,M,E){v.isMeshBasicMaterial||v.isMeshLambertMaterial?a(x,v):v.isMeshToonMaterial?(a(x,v),f(x,v)):v.isMeshPhongMaterial?(a(x,v),d(x,v)):v.isMeshStandardMaterial?(a(x,v),m(x,v),v.isMeshPhysicalMaterial&&p(x,v,E)):v.isMeshMatcapMaterial?(a(x,v),b(x,v)):v.isMeshDepthMaterial?a(x,v):v.isMeshDistanceMaterial?(a(x,v),y(x,v)):v.isMeshNormalMaterial?a(x,v):v.isLineBasicMaterial?(o(x,v),v.isLineDashedMaterial&&l(x,v)):v.isPointsMaterial?c(x,v,S,M):v.isSpriteMaterial?u(x,v):v.isShadowMaterial?(x.color.value.copy(v.color),x.opacity.value=v.opacity):v.isShaderMaterial&&(v.uniformsNeedUpdate=!1)}function a(x,v){x.opacity.value=v.opacity,v.color&&x.diffuse.value.copy(v.color),v.emissive&&x.emissive.value.copy(v.emissive).multiplyScalar(v.emissiveIntensity),v.map&&(x.map.value=v.map,n(v.map,x.mapTransform)),v.alphaMap&&(x.alphaMap.value=v.alphaMap,n(v.alphaMap,x.alphaMapTransform)),v.bumpMap&&(x.bumpMap.value=v.bumpMap,n(v.bumpMap,x.bumpMapTransform),x.bumpScale.value=v.bumpScale,v.side===Ss&&(x.bumpScale.value*=-1)),v.normalMap&&(x.normalMap.value=v.normalMap,n(v.normalMap,x.normalMapTransform),x.normalScale.value.copy(v.normalScale),v.side===Ss&&x.normalScale.value.negate()),v.displacementMap&&(x.displacementMap.value=v.displacementMap,n(v.displacementMap,x.displacementMapTransform),x.displacementScale.value=v.displacementScale,x.displacementBias.value=v.displacementBias),v.emissiveMap&&(x.emissiveMap.value=v.emissiveMap,n(v.emissiveMap,x.emissiveMapTransform)),v.specularMap&&(x.specularMap.value=v.specularMap,n(v.specularMap,x.specularMapTransform)),v.alphaTest>0&&(x.alphaTest.value=v.alphaTest);const S=e.get(v).envMap;if(S&&(x.envMap.value=S,x.flipEnvMap.value=S.isCubeTexture&&S.isRenderTargetTexture===!1?-1:1,x.reflectivity.value=v.reflectivity,x.ior.value=v.ior,x.refractionRatio.value=v.refractionRatio),v.lightMap){x.lightMap.value=v.lightMap;const M=t._useLegacyLights===!0?Math.PI:1;x.lightMapIntensity.value=v.lightMapIntensity*M,n(v.lightMap,x.lightMapTransform)}v.aoMap&&(x.aoMap.value=v.aoMap,x.aoMapIntensity.value=v.aoMapIntensity,n(v.aoMap,x.aoMapTransform))}function o(x,v){x.diffuse.value.copy(v.color),x.opacity.value=v.opacity,v.map&&(x.map.value=v.map,n(v.map,x.mapTransform))}function l(x,v){x.dashSize.value=v.dashSize,x.totalSize.value=v.dashSize+v.gapSize,x.scale.value=v.scale}function c(x,v,S,M){x.diffuse.value.copy(v.color),x.opacity.value=v.opacity,x.size.value=v.size*S,x.scale.value=M*.5,v.map&&(x.map.value=v.map,n(v.map,x.uvTransform)),v.alphaMap&&(x.alphaMap.value=v.alphaMap,n(v.alphaMap,x.alphaMapTransform)),v.alphaTest>0&&(x.alphaTest.value=v.alphaTest)}function u(x,v){x.diffuse.value.copy(v.color),x.opacity.value=v.opacity,x.rotation.value=v.rotation,v.map&&(x.map.value=v.map,n(v.map,x.mapTransform)),v.alphaMap&&(x.alphaMap.value=v.alphaMap,n(v.alphaMap,x.alphaMapTransform)),v.alphaTest>0&&(x.alphaTest.value=v.alphaTest)}function d(x,v){x.specular.value.copy(v.specular),x.shininess.value=Math.max(v.shininess,1e-4)}function f(x,v){v.gradientMap&&(x.gradientMap.value=v.gradientMap)}function m(x,v){x.metalness.value=v.metalness,v.metalnessMap&&(x.metalnessMap.value=v.metalnessMap,n(v.metalnessMap,x.metalnessMapTransform)),x.roughness.value=v.roughness,v.roughnessMap&&(x.roughnessMap.value=v.roughnessMap,n(v.roughnessMap,x.roughnessMapTransform)),e.get(v).envMap&&(x.envMapIntensity.value=v.envMapIntensity)}function p(x,v,S){x.ior.value=v.ior,v.sheen>0&&(x.sheenColor.value.copy(v.sheenColor).multiplyScalar(v.sheen),x.sheenRoughness.value=v.sheenRoughness,v.sheenColorMap&&(x.sheenColorMap.value=v.sheenColorMap,n(v.sheenColorMap,x.sheenColorMapTransform)),v.sheenRoughnessMap&&(x.sheenRoughnessMap.value=v.sheenRoughnessMap,n(v.sheenRoughnessMap,x.sheenRoughnessMapTransform))),v.clearcoat>0&&(x.clearcoat.value=v.clearcoat,x.clearcoatRoughness.value=v.clearcoatRoughness,v.clearcoatMap&&(x.clearcoatMap.value=v.clearcoatMap,n(v.clearcoatMap,x.clearcoatMapTransform)),v.clearcoatRoughnessMap&&(x.clearcoatRoughnessMap.value=v.clearcoatRoughnessMap,n(v.clearcoatRoughnessMap,x.clearcoatRoughnessMapTransform)),v.clearcoatNormalMap&&(x.clearcoatNormalMap.value=v.clearcoatNormalMap,n(v.clearcoatNormalMap,x.clearcoatNormalMapTransform),x.clearcoatNormalScale.value.copy(v.clearcoatNormalScale),v.side===Ss&&x.clearcoatNormalScale.value.negate())),v.iridescence>0&&(x.iridescence.value=v.iridescence,x.iridescenceIOR.value=v.iridescenceIOR,x.iridescenceThicknessMinimum.value=v.iridescenceThicknessRange[0],x.iridescenceThicknessMaximum.value=v.iridescenceThicknessRange[1],v.iridescenceMap&&(x.iridescenceMap.value=v.iridescenceMap,n(v.iridescenceMap,x.iridescenceMapTransform)),v.iridescenceThicknessMap&&(x.iridescenceThicknessMap.value=v.iridescenceThicknessMap,n(v.iridescenceThicknessMap,x.iridescenceThicknessMapTransform))),v.transmission>0&&(x.transmission.value=v.transmission,x.transmissionSamplerMap.value=S.texture,x.transmissionSamplerSize.value.set(S.width,S.height),v.transmissionMap&&(x.transmissionMap.value=v.transmissionMap,n(v.transmissionMap,x.transmissionMapTransform)),x.thickness.value=v.thickness,v.thicknessMap&&(x.thicknessMap.value=v.thicknessMap,n(v.thicknessMap,x.thicknessMapTransform)),x.attenuationDistance.value=v.attenuationDistance,x.attenuationColor.value.copy(v.attenuationColor)),v.anisotropy>0&&(x.anisotropyVector.value.set(v.anisotropy*Math.cos(v.anisotropyRotation),v.anisotropy*Math.sin(v.anisotropyRotation)),v.anisotropyMap&&(x.anisotropyMap.value=v.anisotropyMap,n(v.anisotropyMap,x.anisotropyMapTransform))),x.specularIntensity.value=v.specularIntensity,x.specularColor.value.copy(v.specularColor),v.specularColorMap&&(x.specularColorMap.value=v.specularColorMap,n(v.specularColorMap,x.specularColorMapTransform)),v.specularIntensityMap&&(x.specularIntensityMap.value=v.specularIntensityMap,n(v.specularIntensityMap,x.specularIntensityMapTransform))}function b(x,v){v.matcap&&(x.matcap.value=v.matcap)}function y(x,v){const S=e.get(v).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 t6e(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 E=M.program;r.uniformBlockBinding(S,E)}function u(S,M){let E=i[S.id];E===void 0&&(b(S),E=d(S),i[S.id]=E,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 E=t.createBuffer(),A=S.__size,k=S.usage;return t.bindBuffer(t.UNIFORM_BUFFER,E),t.bufferData(t.UNIFORM_BUFFER,A,k),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,M,E),E}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],E=S.uniforms,A=S.__cache;t.bindBuffer(t.UNIFORM_BUFFER,M);for(let k=0,T=E.length;k<T;k++){const D=E[k];if(p(D,k,A)===!0){const C=D.__offset,R=Array.isArray(D.value)?D.value:[D.value];let U=0;for(let O=0;O<R.length;O++){const q=R[O],j=y(q);typeof q=="number"?(D.__data[0]=q,t.bufferSubData(t.UNIFORM_BUFFER,C+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,C,D.__data)}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function p(S,M,E){const A=S.value;if(E[M]===void 0){if(typeof A=="number")E[M]=A;else{const k=Array.isArray(A)?A:[A],T=[];for(let D=0;D<k.length;D++)T.push(k[D].clone());E[M]=T}return!0}else if(typeof A=="number"){if(E[M]!==A)return E[M]=A,!0}else{const k=Array.isArray(E[M])?E[M]:[E[M]],T=Array.isArray(A)?A:[A];for(let D=0;D<k.length;D++){const C=k[D];if(C.equals(T[D])===!1)return C.copy(T[D]),!0}}return!1}function b(S){const M=S.uniforms;let E=0;const A=16;let k=0;for(let T=0,D=M.length;T<D;T++){const C=M[T],R={boundary:0,storage:0},U=Array.isArray(C.value)?C.value:[C.value];for(let O=0,q=U.length;O<q;O++){const j=U[O],W=y(j);R.boundary+=W.boundary,R.storage+=W.storage}if(C.__data=new Float32Array(R.storage/Float32Array.BYTES_PER_ELEMENT),C.__offset=E,T>0){k=E%A;const O=A-k;k!==0&&O-R.boundary<0&&(E+=A-k,C.__offset=E)}E+=R.storage}return k=E%A,k>0&&(E+=A-k),S.__size=E,S.__cache={},this}function y(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 E=o.indexOf(M.__bindingPointIndex);o.splice(E,1),t.deleteBuffer(i[M.id]),delete i[M.id],delete a[M.id]}function v(){for(const S in i)t.deleteBuffer(i[S]);o=[],i={},a={}}return{bind:c,update:u,dispose:v}}class jR{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 y=null,x=null;const v=[],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=va,this._useLegacyLights=!1,this.toneMapping=Hd,this.toneMappingExposure=1;const M=this;let E=!1,A=0,k=0,T=null,D=-1,C=null;const R=new xr,U=new xr;let O=null;const q=new rn(0);let j=0,W=n.width,X=n.height,G=1,Z=null,te=null;const ee=new xr(0,0,W,X),z=new xr(0,0,W,X);let V=!1;const ne=new gE;let ie=!1,he=!1,me=null;const oe=new Tr,Ae=new mn,ge=new Be,Ne={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function _e(){return T===null?G:1}let le=r;function He(we,Je){for(let Ze=0;Ze<we.length;Ze++){const lt=we[Ze],st=n.getContext(lt,Je);if(st!==null)return st}return null}try{const we={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${fE}`),n.addEventListener("webglcontextlost",Fe,!1),n.addEventListener("webglcontextrestored",ve,!1),n.addEventListener("webglcontextcreationerror",$e,!1),le===null){const Je=["webgl2","webgl","experimental-webgl"];if(M.isWebGL1Renderer===!0&&Je.shift(),le=He(Je,we),le===null)throw He(Je)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&le instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),le.getShaderPrecisionFormat===void 0&&(le.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(we){throw console.error("THREE.WebGLRenderer: "+we.message),we}let H,J,K,B,I,ce,Ee,Ie,ue,$,L,Y,pe,Se,ae,je,De,Xe,et,Qe,se,ye,ke,Ue;function dt(){H=new hBe(le),J=new aBe(le,H,e),H.init(J),ye=new Y8e(le,H,J),K=new K8e(le,H,J),B=new pBe(le),I=new D8e,ce=new X8e(le,H,K,I,J,ye,B),Ee=new oBe(M),Ie=new dBe(M),ue=new w5e(le,J),ke=new rBe(le,H,ue,J),$=new fBe(le,ue,B,ke),L=new yBe(le,$,ue,B),et=new bBe(le,J,ce),je=new sBe(I),Y=new R8e(M,Ee,Ie,H,J,ke,je),pe=new e6e(M,I),Se=new L8e,ae=new $8e(H,J),Xe=new nBe(M,Ee,Ie,K,L,m,c),De=new q8e(M,L,J),Ue=new t6e(le,B,J,K),Qe=new iBe(le,H,B,J),se=new mBe(le,H,B,J),B.programs=Y.programs,M.capabilities=J,M.extensions=H,M.properties=I,M.renderLists=Se,M.shadowMap=De,M.state=K,M.info=B}dt();const re=new J8e(M,le);this.xr=re,this.getContext=function(){return le},this.getContextAttributes=function(){return le.getContextAttributes()},this.forceContextLoss=function(){const we=H.get("WEBGL_lose_context");we&&we.loseContext()},this.forceContextRestore=function(){const we=H.get("WEBGL_lose_context");we&&we.restoreContext()},this.getPixelRatio=function(){return G},this.setPixelRatio=function(we){we!==void 0&&(G=we,this.setSize(W,X,!1))},this.getSize=function(we){return we.set(W,X)},this.setSize=function(we,Je,Ze=!0){if(re.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}W=we,X=Je,n.width=Math.floor(we*G),n.height=Math.floor(Je*G),Ze===!0&&(n.style.width=we+"px",n.style.height=Je+"px"),this.setViewport(0,0,we,Je)},this.getDrawingBufferSize=function(we){return we.set(W*G,X*G).floor()},this.setDrawingBufferSize=function(we,Je,Ze){W=we,X=Je,G=Ze,n.width=Math.floor(we*Ze),n.height=Math.floor(Je*Ze),this.setViewport(0,0,we,Je)},this.getCurrentViewport=function(we){return we.copy(R)},this.getViewport=function(we){return we.copy(ee)},this.setViewport=function(we,Je,Ze,lt){we.isVector4?ee.set(we.x,we.y,we.z,we.w):ee.set(we,Je,Ze,lt),K.viewport(R.copy(ee).multiplyScalar(G).floor())},this.getScissor=function(we){return we.copy(z)},this.setScissor=function(we,Je,Ze,lt){we.isVector4?z.set(we.x,we.y,we.z,we.w):z.set(we,Je,Ze,lt),K.scissor(U.copy(z).multiplyScalar(G).floor())},this.getScissorTest=function(){return V},this.setScissorTest=function(we){K.setScissorTest(V=we)},this.setOpaqueSort=function(we){Z=we},this.setTransparentSort=function(we){te=we},this.getClearColor=function(we){return we.copy(Xe.getClearColor())},this.setClearColor=function(){Xe.setClearColor.apply(Xe,arguments)},this.getClearAlpha=function(){return Xe.getClearAlpha()},this.setClearAlpha=function(){Xe.setClearAlpha.apply(Xe,arguments)},this.clear=function(we=!0,Je=!0,Ze=!0){let lt=0;if(we){let st=!1;if(T!==null){const Pt=T.texture.format;st=Pt===Hee||Pt===$ee||Pt===Bee}if(st){const Pt=T.texture.type,Bt=Pt===Vd||Pt===jd||Pt===mL||Pt===Af||Pt===Uee||Pt===zee,Vt=Xe.getClearColor(),Jt=Xe.getClearAlpha(),de=Vt.r,Pe=Vt.g,Ge=Vt.b;Bt?(p[0]=de,p[1]=Pe,p[2]=Ge,p[3]=Jt,le.clearBufferuiv(le.COLOR,0,p)):(b[0]=de,b[1]=Pe,b[2]=Ge,b[3]=Jt,le.clearBufferiv(le.COLOR,0,b))}else lt|=le.COLOR_BUFFER_BIT}Je&&(lt|=le.DEPTH_BUFFER_BIT),Ze&&(lt|=le.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),le.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),Se.dispose(),ae.dispose(),I.dispose(),Ee.dispose(),Ie.dispose(),L.dispose(),ke.dispose(),Ue.dispose(),Y.dispose(),re.dispose(),re.removeEventListener("sessionstart",on),re.removeEventListener("sessionend",Ut),me&&(me.dispose(),me=null),yn.stop()};function Fe(we){we.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),E=!0}function ve(){console.log("THREE.WebGLRenderer: Context Restored."),E=!1;const we=B.autoReset,Je=De.enabled,Ze=De.autoUpdate,lt=De.needsUpdate,st=De.type;dt(),B.autoReset=we,De.enabled=Je,De.autoUpdate=Ze,De.needsUpdate=lt,De.type=st}function $e(we){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",we.statusMessage)}function Le(we){const Je=we.target;Je.removeEventListener("dispose",Le),Te(Je)}function Te(we){We(we),I.remove(we)}function We(we){const Je=I.get(we).programs;Je!==void 0&&(Je.forEach(function(Ze){Y.releaseProgram(Ze)}),we.isShaderMaterial&&Y.releaseShaderCache(we))}this.renderBufferDirect=function(we,Je,Ze,lt,st,Pt){Je===null&&(Je=Ne);const Bt=st.isMesh&&st.matrixWorld.determinant()<0,Vt=yr(we,Je,Ze,lt,st);K.setMaterial(lt,Bt);let Jt=Ze.index,de=1;if(lt.wireframe===!0){if(Jt=$.getWireframeAttribute(Ze),Jt===void 0)return;de=2}const Pe=Ze.drawRange,Ge=Ze.attributes.position;let qe=Pe.start*de,Ve=(Pe.start+Pe.count)*de;Pt!==null&&(qe=Math.max(qe,Pt.start*de),Ve=Math.min(Ve,(Pt.start+Pt.count)*de)),Jt!==null?(qe=Math.max(qe,0),Ve=Math.min(Ve,Jt.count)):Ge!=null&&(qe=Math.max(qe,0),Ve=Math.min(Ve,Ge.count));const wt=Ve-qe;if(wt<0||wt===1/0)return;ke.setup(st,lt,Vt,Ze,Jt);let Dt,Nt=Qe;if(Jt!==null&&(Dt=ue.get(Jt),Nt=se,Nt.setIndex(Dt)),st.isMesh)lt.wireframe===!0?(K.setLineWidth(lt.wireframeLinewidth*_e()),Nt.setMode(le.LINES)):Nt.setMode(le.TRIANGLES);else if(st.isLine){let St=lt.linewidth;St===void 0&&(St=1),K.setLineWidth(St*_e()),st.isLineSegments?Nt.setMode(le.LINES):st.isLineLoop?Nt.setMode(le.LINE_LOOP):Nt.setMode(le.LINE_STRIP)}else st.isPoints?Nt.setMode(le.POINTS):st.isSprite&&Nt.setMode(le.TRIANGLES);if(st.isBatchedMesh)Nt.renderMultiDraw(st._multiDrawStarts,st._multiDrawCounts,st._multiDrawCount);else if(st.isInstancedMesh)Nt.renderInstances(qe,wt,st.count);else if(Ze.isInstancedBufferGeometry){const St=Ze._maxInstanceCount!==void 0?Ze._maxInstanceCount:1/0,Mt=Math.min(Ze.instanceCount,St);Nt.renderInstances(qe,wt,Mt)}else Nt.render(qe,wt)};function it(we,Je,Ze){we.transparent===!0&&we.side===Yc&&we.forceSinglePass===!1?(we.side=Ss,we.needsUpdate=!0,Cr(we,Je,Ze),we.side=nh,we.needsUpdate=!0,Cr(we,Je,Ze),we.side=Yc):Cr(we,Je,Ze)}this.compile=function(we,Je,Ze=null){Ze===null&&(Ze=we),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))}),we!==Ze&&we.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 we.traverse(function(st){const Pt=st.material;if(Pt)if(Array.isArray(Pt))for(let Bt=0;Bt<Pt.length;Bt++){const Vt=Pt[Bt];it(Vt,Ze,st),lt.add(Vt)}else it(Pt,Ze,st),lt.add(Pt)}),S.pop(),x=null,lt},this.compileAsync=function(we,Je,Ze=null){const lt=this.compile(we,Je,Ze);return new Promise(st=>{function Pt(){if(lt.forEach(function(Bt){I.get(Bt).currentProgram.isReady()&<.delete(Bt)}),lt.size===0){st(we);return}setTimeout(Pt,10)}H.get("KHR_parallel_shader_compile")!==null?Pt():setTimeout(Pt,10)})};let Ot=null;function kt(we){Ot&&Ot(we)}function on(){yn.stop()}function Ut(){yn.start()}const yn=new ote;yn.setAnimationLoop(kt),typeof self<"u"&&yn.setContext(self),this.setAnimationLoop=function(we){Ot=we,re.setAnimationLoop(we),we===null?yn.stop():yn.start()},re.addEventListener("sessionstart",on),re.addEventListener("sessionend",Ut),this.render=function(we,Je){if(Je!==void 0&&Je.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(E===!0)return;we.matrixWorldAutoUpdate===!0&&we.updateMatrixWorld(),Je.parent===null&&Je.matrixWorldAutoUpdate===!0&&Je.updateMatrixWorld(),re.enabled===!0&&re.isPresenting===!0&&(re.cameraAutoUpdate===!0&&re.updateCamera(Je),Je=re.getCamera()),we.isScene===!0&&we.onBeforeRender(M,we,Je,T),x=ae.get(we,S.length),x.init(),S.push(x),oe.multiplyMatrices(Je.projectionMatrix,Je.matrixWorldInverse),ne.setFromProjectionMatrix(oe),he=this.localClippingEnabled,ie=je.init(this.clippingPlanes,he),y=Se.get(we,v.length),y.init(),v.push(y),xt(we,Je,0,M.sortObjects),y.finish(),M.sortObjects===!0&&y.sort(Z,te),this.info.render.frame++,ie===!0&&je.beginShadows();const Ze=x.state.shadowsArray;if(De.render(Ze,we,Je),ie===!0&&je.endShadows(),this.info.autoReset===!0&&this.info.reset(),Xe.render(y,we),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(y,we,Bt,Bt.viewport)}}else Yt(y,we,Je);T!==null&&(ce.updateMultisampleRenderTarget(T),ce.updateRenderTargetMipmap(T)),we.isScene===!0&&we.onAfterRender(M,we,Je),ke.resetDefaultState(),D=-1,C=null,S.pop(),S.length>0?x=S[S.length-1]:x=null,v.pop(),v.length>0?y=v[v.length-1]:y=null};function xt(we,Je,Ze,lt){if(we.visible===!1)return;if(we.layers.test(Je.layers)){if(we.isGroup)Ze=we.renderOrder;else if(we.isLOD)we.autoUpdate===!0&&we.update(Je);else if(we.isLight)x.pushLight(we),we.castShadow&&x.pushShadow(we);else if(we.isSprite){if(!we.frustumCulled||ne.intersectsSprite(we)){lt&&ge.setFromMatrixPosition(we.matrixWorld).applyMatrix4(oe);const Bt=L.update(we),Vt=we.material;Vt.visible&&y.push(we,Bt,Vt,Ze,ge.z,null)}}else if((we.isMesh||we.isLine||we.isPoints)&&(!we.frustumCulled||ne.intersectsObject(we))){const Bt=L.update(we),Vt=we.material;if(lt&&(we.boundingSphere!==void 0?(we.boundingSphere===null&&we.computeBoundingSphere(),ge.copy(we.boundingSphere.center)):(Bt.boundingSphere===null&&Bt.computeBoundingSphere(),ge.copy(Bt.boundingSphere.center)),ge.applyMatrix4(we.matrixWorld).applyMatrix4(oe)),Array.isArray(Vt)){const Jt=Bt.groups;for(let de=0,Pe=Jt.length;de<Pe;de++){const Ge=Jt[de],qe=Vt[Ge.materialIndex];qe&&qe.visible&&y.push(we,Bt,qe,Ze,ge.z,Ge)}}else Vt.visible&&y.push(we,Bt,Vt,Ze,ge.z,null)}}const Pt=we.children;for(let Bt=0,Vt=Pt.length;Bt<Vt;Bt++)xt(Pt[Bt],Je,Ze,lt)}function Yt(we,Je,Ze,lt){const st=we.opaque,Pt=we.transmissive,Bt=we.transparent;x.setupLightsView(Ze),ie===!0&&je.setGlobalState(M.clippingPlanes,Ze),Pt.length>0&&sn(st,Pt,Je,Ze),lt&&K.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),K.buffers.depth.setTest(!0),K.buffers.depth.setMask(!0),K.buffers.color.setMask(!0),K.setPolygonOffset(!1)}function sn(we,Je,Ze,lt){if((Ze.isScene===!0?Ze.overrideMaterial:null)!==null)return;const Pt=J.isWebGL2;me===null&&(me=new tm(1,1,{generateMipmaps:!0,type:H.has("EXT_color_buffer_half_float")?Z0:Vd,minFilter:Q0,samples:Pt?4:0})),M.getDrawingBufferSize(Ae),Pt?me.setSize(Ae.x,Ae.y):me.setSize(XS(Ae.x),XS(Ae.y));const Bt=M.getRenderTarget();M.setRenderTarget(me),M.getClearColor(q),j=M.getClearAlpha(),j<1&&M.setClearColor(16777215,.5),M.clear();const Vt=M.toneMapping;M.toneMapping=Hd,Tt(we,Ze,lt),ce.updateMultisampleRenderTarget(me),ce.updateRenderTargetMipmap(me);let Jt=!1;for(let de=0,Pe=Je.length;de<Pe;de++){const Ge=Je[de],qe=Ge.object,Ve=Ge.geometry,wt=Ge.material,Dt=Ge.group;if(wt.side===Yc&&qe.layers.test(lt.layers)){const Nt=wt.side;wt.side=Ss,wt.needsUpdate=!0,Cn(qe,Ze,lt,Ve,wt,Dt),wt.side=Nt,wt.needsUpdate=!0,Jt=!0}}Jt===!0&&(ce.updateMultisampleRenderTarget(me),ce.updateRenderTargetMipmap(me)),M.setRenderTarget(Bt),M.setClearColor(q,j),M.toneMapping=Vt}function Tt(we,Je,Ze){const lt=Je.isScene===!0?Je.overrideMaterial:null;for(let st=0,Pt=we.length;st<Pt;st++){const Bt=we[st],Vt=Bt.object,Jt=Bt.geometry,de=lt===null?Bt.material:lt,Pe=Bt.group;Vt.layers.test(Ze.layers)&&Cn(Vt,Je,Ze,Jt,de,Pe)}}function Cn(we,Je,Ze,lt,st,Pt){we.onBeforeRender(M,Je,Ze,lt,st,Pt),we.modelViewMatrix.multiplyMatrices(Ze.matrixWorldInverse,we.matrixWorld),we.normalMatrix.getNormalMatrix(we.modelViewMatrix),st.onBeforeRender(M,Je,Ze,lt,we,Pt),st.transparent===!0&&st.side===Yc&&st.forceSinglePass===!1?(st.side=Ss,st.needsUpdate=!0,M.renderBufferDirect(Ze,Je,lt,st,we,Pt),st.side=nh,st.needsUpdate=!0,M.renderBufferDirect(Ze,Je,lt,st,we,Pt),st.side=Yc):M.renderBufferDirect(Ze,Je,lt,st,we,Pt),we.onAfterRender(M,Je,Ze,lt,st,Pt)}function Cr(we,Je,Ze){Je.isScene!==!0&&(Je=Ne);const lt=I.get(we),st=x.state.lights,Pt=x.state.shadowsArray,Bt=st.state.version,Vt=Y.getParameters(we,st.state,Pt,Je,Ze),Jt=Y.getProgramCacheKey(Vt);let de=lt.programs;lt.environment=we.isMeshStandardMaterial?Je.environment:null,lt.fog=Je.fog,lt.envMap=(we.isMeshStandardMaterial?Ie:Ee).get(we.envMap||lt.environment),de===void 0&&(we.addEventListener("dispose",Le),de=new Map,lt.programs=de);let Pe=de.get(Jt);if(Pe!==void 0){if(lt.currentProgram===Pe&<.lightsStateVersion===Bt)return Un(we,Vt),Pe}else Vt.uniforms=Y.getUniforms(we),we.onBuild(Ze,Vt,M),we.onBeforeCompile(Vt,M),Pe=Y.acquireProgram(Vt,Jt),de.set(Jt,Pe),lt.uniforms=Vt.uniforms;const Ge=lt.uniforms;return(!we.isShaderMaterial&&!we.isRawShaderMaterial||we.clipping===!0)&&(Ge.clippingPlanes=je.uniform),Un(we,Vt),lt.needsLights=gi(we),lt.lightsStateVersion=Bt,lt.needsLights&&(Ge.ambientLightColor.value=st.state.ambient,Ge.lightProbe.value=st.state.probe,Ge.directionalLights.value=st.state.directional,Ge.directionalLightShadows.value=st.state.directionalShadow,Ge.spotLights.value=st.state.spot,Ge.spotLightShadows.value=st.state.spotShadow,Ge.rectAreaLights.value=st.state.rectArea,Ge.ltc_1.value=st.state.rectAreaLTC1,Ge.ltc_2.value=st.state.rectAreaLTC2,Ge.pointLights.value=st.state.point,Ge.pointLightShadows.value=st.state.pointShadow,Ge.hemisphereLights.value=st.state.hemi,Ge.directionalShadowMap.value=st.state.directionalShadowMap,Ge.directionalShadowMatrix.value=st.state.directionalShadowMatrix,Ge.spotShadowMap.value=st.state.spotShadowMap,Ge.spotLightMatrix.value=st.state.spotLightMatrix,Ge.spotLightMap.value=st.state.spotLightMap,Ge.pointShadowMap.value=st.state.pointShadowMap,Ge.pointShadowMatrix.value=st.state.pointShadowMatrix),lt.currentProgram=Pe,lt.uniformsList=null,Pe}function er(we){if(we.uniformsList===null){const Je=we.currentProgram.getUniforms();we.uniformsList=xw.seqWithValue(Je.seq,we.uniforms)}return we.uniformsList}function Un(we,Je){const Ze=I.get(we);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(we,Je,Ze,lt,st){Je.isScene!==!0&&(Je=Ne),ce.resetTextureUnits();const Pt=Je.fog,Bt=lt.isMeshStandardMaterial?Je.environment:null,Vt=T===null?M.outputColorSpace:T.isXRRenderTarget===!0?T.texture.colorSpace:wu,Jt=(lt.isMeshStandardMaterial?Ie:Ee).get(lt.envMap||Bt),de=lt.vertexColors===!0&&!!Ze.attributes.color&&Ze.attributes.color.itemSize===4,Pe=!!Ze.attributes.tangent&&(!!lt.normalMap||lt.anisotropy>0),Ge=!!Ze.morphAttributes.position,qe=!!Ze.morphAttributes.normal,Ve=!!Ze.morphAttributes.color;let wt=Hd;lt.toneMapped&&(T===null||T.isXRRenderTarget===!0)&&(wt=M.toneMapping);const Dt=Ze.morphAttributes.position||Ze.morphAttributes.normal||Ze.morphAttributes.color,Nt=Dt!==void 0?Dt.length:0,St=I.get(lt),Mt=x.state.lights;if(ie===!0&&(he===!0||we!==C)){const It=we===C&<.id===D;je.setState(lt,we,It)}let Oe=!1;lt.version===St.__version?(St.needsLights&&St.lightsStateVersion!==Mt.state.version||St.outputColorSpace!==Vt||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!==je.numPlanes||St.numIntersection!==je.numIntersection)||St.vertexAlphas!==de||St.vertexTangents!==Pe||St.morphTargets!==Ge||St.morphNormals!==qe||St.morphColors!==Ve||St.toneMapping!==wt||J.isWebGL2===!0&&St.morphTargetsCount!==Nt)&&(Oe=!0):(Oe=!0,St.__version=lt.version);let gt=St.currentProgram;Oe===!0&&(gt=Cr(lt,Je,st));let Rt=!1,ct=!1,Qt=!1;const Kt=gt.getUniforms(),be=St.uniforms;if(K.useProgram(gt.program)&&(Rt=!0,ct=!0,Qt=!0),lt.id!==D&&(D=lt.id,ct=!0),Rt||C!==we){Kt.setValue(le,"projectionMatrix",we.projectionMatrix),Kt.setValue(le,"viewMatrix",we.matrixWorldInverse);const It=Kt.map.cameraPosition;It!==void 0&&It.setValue(le,ge.setFromMatrixPosition(we.matrixWorld)),J.logarithmicDepthBuffer&&Kt.setValue(le,"logDepthBufFC",2/(Math.log(we.far+1)/Math.LN2)),(lt.isMeshPhongMaterial||lt.isMeshToonMaterial||lt.isMeshLambertMaterial||lt.isMeshBasicMaterial||lt.isMeshStandardMaterial||lt.isShaderMaterial)&&Kt.setValue(le,"isOrthographic",we.isOrthographicCamera===!0),C!==we&&(C=we,ct=!0,Qt=!0)}if(st.isSkinnedMesh){Kt.setOptional(le,st,"bindMatrix"),Kt.setOptional(le,st,"bindMatrixInverse");const It=st.skeleton;It&&(J.floatVertexTextures?(It.boneTexture===null&&It.computeBoneTexture(),Kt.setValue(le,"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(le,st,"batchingTexture"),Kt.setValue(le,"batchingTexture",st._matricesTexture,ce));const ut=Ze.morphAttributes;if((ut.position!==void 0||ut.normal!==void 0||ut.color!==void 0&&J.isWebGL2===!0)&&et.update(st,Ze,gt),(ct||St.receiveShadow!==st.receiveShadow)&&(St.receiveShadow=st.receiveShadow,Kt.setValue(le,"receiveShadow",st.receiveShadow)),lt.isMeshGouraudMaterial&<.envMap!==null&&(be.envMap.value=Jt,be.flipEnvMap.value=Jt.isCubeTexture&&Jt.isRenderTargetTexture===!1?-1:1),ct&&(Kt.setValue(le,"toneMappingExposure",M.toneMappingExposure),St.needsLights&&Ci(be,Qt),Pt&<.fog===!0&&pe.refreshFogUniforms(be,Pt),pe.refreshMaterialUniforms(be,lt,G,X,me),xw.upload(le,er(St),be,ce)),lt.isShaderMaterial&<.uniformsNeedUpdate===!0&&(xw.upload(le,er(St),be,ce),lt.uniformsNeedUpdate=!1),lt.isSpriteMaterial&&Kt.setValue(le,"center",st.center),Kt.setValue(le,"modelViewMatrix",st.modelViewMatrix),Kt.setValue(le,"normalMatrix",st.normalMatrix),Kt.setValue(le,"modelMatrix",st.matrixWorld),lt.isShaderMaterial||lt.isRawShaderMaterial){const It=lt.uniformsGroups;for(let yt=0,Xt=It.length;yt<Xt;yt++)if(J.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(we,Je){we.ambientLightColor.needsUpdate=Je,we.lightProbe.needsUpdate=Je,we.directionalLights.needsUpdate=Je,we.directionalLightShadows.needsUpdate=Je,we.pointLights.needsUpdate=Je,we.pointLightShadows.needsUpdate=Je,we.spotLights.needsUpdate=Je,we.spotLightShadows.needsUpdate=Je,we.rectAreaLights.needsUpdate=Je,we.hemisphereLights.needsUpdate=Je}function gi(we){return we.isMeshLambertMaterial||we.isMeshToonMaterial||we.isMeshPhongMaterial||we.isMeshStandardMaterial||we.isShadowMaterial||we.isShaderMaterial&&we.lights===!0}this.getActiveCubeFace=function(){return A},this.getActiveMipmapLevel=function(){return k},this.getRenderTarget=function(){return T},this.setRenderTargetTextures=function(we,Je,Ze){I.get(we.texture).__webglTexture=Je,I.get(we.depthTexture).__webglTexture=Ze;const lt=I.get(we);lt.__hasExternalTextures=!0,lt.__hasExternalTextures&&(lt.__autoAllocateDepthBuffer=Ze===void 0,lt.__autoAllocateDepthBuffer||H.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(we,Je){const Ze=I.get(we);Ze.__webglFramebuffer=Je,Ze.__useDefaultFramebuffer=Je===void 0},this.setRenderTarget=function(we,Je=0,Ze=0){T=we,A=Je,k=Ze;let lt=!0,st=null,Pt=!1,Bt=!1;if(we){const Jt=I.get(we);Jt.__useDefaultFramebuffer!==void 0?(K.bindFramebuffer(le.FRAMEBUFFER,null),lt=!1):Jt.__webglFramebuffer===void 0?ce.setupRenderTarget(we):Jt.__hasExternalTextures&&ce.rebindTextures(we,I.get(we.texture).__webglTexture,I.get(we.depthTexture).__webglTexture);const de=we.texture;(de.isData3DTexture||de.isDataArrayTexture||de.isCompressedArrayTexture)&&(Bt=!0);const Pe=I.get(we).__webglFramebuffer;we.isWebGLCubeRenderTarget?(Array.isArray(Pe[Je])?st=Pe[Je][Ze]:st=Pe[Je],Pt=!0):J.isWebGL2&&we.samples>0&&ce.useMultisampledRTT(we)===!1?st=I.get(we).__webglMultisampledFramebuffer:Array.isArray(Pe)?st=Pe[Ze]:st=Pe,R.copy(we.viewport),U.copy(we.scissor),O=we.scissorTest}else R.copy(ee).multiplyScalar(G).floor(),U.copy(z).multiplyScalar(G).floor(),O=V;if(K.bindFramebuffer(le.FRAMEBUFFER,st)&&J.drawBuffers&<&&K.drawBuffers(we,st),K.viewport(R),K.scissor(U),K.setScissorTest(O),Pt){const Jt=I.get(we.texture);le.framebufferTexture2D(le.FRAMEBUFFER,le.COLOR_ATTACHMENT0,le.TEXTURE_CUBE_MAP_POSITIVE_X+Je,Jt.__webglTexture,Ze)}else if(Bt){const Jt=I.get(we.texture),de=Je||0;le.framebufferTextureLayer(le.FRAMEBUFFER,le.COLOR_ATTACHMENT0,Jt.__webglTexture,Ze||0,de)}D=-1},this.readRenderTargetPixels=function(we,Je,Ze,lt,st,Pt,Bt){if(!(we&&we.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Vt=I.get(we).__webglFramebuffer;if(we.isWebGLCubeRenderTarget&&Bt!==void 0&&(Vt=Vt[Bt]),Vt){K.bindFramebuffer(le.FRAMEBUFFER,Vt);try{const Jt=we.texture,de=Jt.format,Pe=Jt.type;if(de!==No&&ye.convert(de)!==le.getParameter(le.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const Ge=Pe===Z0&&(H.has("EXT_color_buffer_half_float")||J.isWebGL2&&H.has("EXT_color_buffer_float"));if(Pe!==Vd&&ye.convert(Pe)!==le.getParameter(le.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Pe===tu&&(J.isWebGL2||H.has("OES_texture_float")||H.has("WEBGL_color_buffer_float")))&&!Ge){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Je>=0&&Je<=we.width-lt&&Ze>=0&&Ze<=we.height-st&&le.readPixels(Je,Ze,lt,st,ye.convert(de),ye.convert(Pe),Pt)}finally{const Jt=T!==null?I.get(T).__webglFramebuffer:null;K.bindFramebuffer(le.FRAMEBUFFER,Jt)}}},this.copyFramebufferToTexture=function(we,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),le.copyTexSubImage2D(le.TEXTURE_2D,Ze,0,0,we.x,we.y,st,Pt),K.unbindTexture()},this.copyTextureToTexture=function(we,Je,Ze,lt=0){const st=Je.image.width,Pt=Je.image.height,Bt=ye.convert(Ze.format),Vt=ye.convert(Ze.type);ce.setTexture2D(Ze,0),le.pixelStorei(le.UNPACK_FLIP_Y_WEBGL,Ze.flipY),le.pixelStorei(le.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Ze.premultiplyAlpha),le.pixelStorei(le.UNPACK_ALIGNMENT,Ze.unpackAlignment),Je.isDataTexture?le.texSubImage2D(le.TEXTURE_2D,lt,we.x,we.y,st,Pt,Bt,Vt,Je.image.data):Je.isCompressedTexture?le.compressedTexSubImage2D(le.TEXTURE_2D,lt,we.x,we.y,Je.mipmaps[0].width,Je.mipmaps[0].height,Bt,Je.mipmaps[0].data):le.texSubImage2D(le.TEXTURE_2D,lt,we.x,we.y,Bt,Vt,Je.image),lt===0&&Ze.generateMipmaps&&le.generateMipmap(le.TEXTURE_2D),K.unbindTexture()},this.copyTextureToTexture3D=function(we,Je,Ze,lt,st=0){if(M.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const Pt=we.max.x-we.min.x+1,Bt=we.max.y-we.min.y+1,Vt=we.max.z-we.min.z+1,Jt=ye.convert(lt.format),de=ye.convert(lt.type);let Pe;if(lt.isData3DTexture)ce.setTexture3D(lt,0),Pe=le.TEXTURE_3D;else if(lt.isDataArrayTexture)ce.setTexture2DArray(lt,0),Pe=le.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}le.pixelStorei(le.UNPACK_FLIP_Y_WEBGL,lt.flipY),le.pixelStorei(le.UNPACK_PREMULTIPLY_ALPHA_WEBGL,lt.premultiplyAlpha),le.pixelStorei(le.UNPACK_ALIGNMENT,lt.unpackAlignment);const Ge=le.getParameter(le.UNPACK_ROW_LENGTH),qe=le.getParameter(le.UNPACK_IMAGE_HEIGHT),Ve=le.getParameter(le.UNPACK_SKIP_PIXELS),wt=le.getParameter(le.UNPACK_SKIP_ROWS),Dt=le.getParameter(le.UNPACK_SKIP_IMAGES),Nt=Ze.isCompressedTexture?Ze.mipmaps[0]:Ze.image;le.pixelStorei(le.UNPACK_ROW_LENGTH,Nt.width),le.pixelStorei(le.UNPACK_IMAGE_HEIGHT,Nt.height),le.pixelStorei(le.UNPACK_SKIP_PIXELS,we.min.x),le.pixelStorei(le.UNPACK_SKIP_ROWS,we.min.y),le.pixelStorei(le.UNPACK_SKIP_IMAGES,we.min.z),Ze.isDataTexture||Ze.isData3DTexture?le.texSubImage3D(Pe,st,Je.x,Je.y,Je.z,Pt,Bt,Vt,Jt,de,Nt.data):Ze.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),le.compressedTexSubImage3D(Pe,st,Je.x,Je.y,Je.z,Pt,Bt,Vt,Jt,Nt.data)):le.texSubImage3D(Pe,st,Je.x,Je.y,Je.z,Pt,Bt,Vt,Jt,de,Nt),le.pixelStorei(le.UNPACK_ROW_LENGTH,Ge),le.pixelStorei(le.UNPACK_IMAGE_HEIGHT,qe),le.pixelStorei(le.UNPACK_SKIP_PIXELS,Ve),le.pixelStorei(le.UNPACK_SKIP_ROWS,wt),le.pixelStorei(le.UNPACK_SKIP_IMAGES,Dt),st===0&<.generateMipmaps&&le.generateMipmap(Pe),K.unbindTexture()},this.initTexture=function(we){we.isCubeTexture?ce.setTextureCube(we,0):we.isData3DTexture?ce.setTexture3D(we,0):we.isDataArrayTexture||we.isCompressedArrayTexture?ce.setTexture2DArray(we,0):ce.setTexture2D(we,0),K.unbindTexture()},this.resetState=function(){A=0,k=0,T=null,K.reset(),ke.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===pL?"display-p3":"srgb",n.unpackColorSpace=pr.workingColorSpace===pE?"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===va?Cf:Gee}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===Cf?va:wu}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 n6e extends jR{}n6e.prototype.isWebGL1Renderer=!0;class _L{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 _L(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class r6e 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 i6e{constructor(e,n){this.isInterleavedBuffer=!0,this.array=e,this.stride=n,this.count=e!==void 0?e.length/n:0,this.usage=AR,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=lu()}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=lu()),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=lu()),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 Pd{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 Pd(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 a6e extends Ms{constructor(e=null,n=1,r=1,i,a,o,l,c,u=ya,d=ya,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 s6e(t,e){return t.z-e.z}function o6e(t,e){return e.z-t.z}class l6e{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 Pp="batchId",dd=new Tr,q7=new Tr,c6e=new Tr,K7=new Tr,rj=new gE,M1=new ko,qh=new Xl,kb=new Be,ij=new l6e,Da=new rl,N1=[];function u6e(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 d6e extends rl{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 a6e(n,e,e,No,tu);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(Pp,new Xs(o,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(Pp))throw new Error(`BatchedMesh: Geometry cannot use attribute "${Pp}"`);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===Pp)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,dd),this.getBoundingBoxAt(i,M1).applyMatrix4(dd),n.union(M1))}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,dd),this.getBoundingSphereAt(i,qh).applyMatrix4(dd),n.union(qh))}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 y=this._geometryCount;this._geometryCount++,c6e.toArray(b,y*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(Pp);for(let v=0;v<i.vertexCount;v++)x.setX(i.vertexStart+v,y);return x.needsUpdate=!0,this.setGeometryAt(y,e),y}setGeometryAt(e,n){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(n);const r=this.geometry,i=r.getIndex()!==null,a=r.getIndex(),o=n.getIndex(),l=this._reservedRanges[e];if(i&&o.count>l.indexCount||n.attributes.position.count>l.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const c=l.vertexStart,u=l.vertexCount;for(const p in r.attributes){if(p===Pp)continue;const b=n.getAttribute(p),y=r.getAttribute(p);u6e(b,y,c);const x=b.itemSize;for(let v=b.count,S=u;v<S;v++){const M=c+v;for(let E=0;E<x;E++)y.setComponent(M,E,0)}y.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,y=l.indexCount;b<y;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(kb.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,M1),M1.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)),kb.fromBufferAttribute(c,p),d=Math.max(d,a.center.distanceToSquared(kb))}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,N1);for(let f=0,m=N1.length;f<m;f++){const p=N1[f];p.object=this,p.batchId=u,n.push(p)}N1.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&&(K7.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse).multiply(this.matrixWorld),rj.setFromProjectionMatrix(K7,e.isWebGPURenderer?J0:Vl));let p=0;if(this.sortObjects){q7.copy(this.matrixWorld).invert(),kb.setFromMatrixPosition(r.matrixWorld).applyMatrix4(q7);for(let x=0,v=c.length;x<v;x++)if(c[x]){this.getMatrixAt(x,dd),this.getBoundingSphereAt(x,qh).applyMatrix4(dd);let S=!1;if(m&&(S=!rj.intersectsSphere(qh)),!S){const M=kb.distanceTo(qh.center);ij.push(f[x],M)}}const b=ij.list,y=this.customSort;y===null?b.sort(a.transparent?o6e:s6e):y.call(this,b,r);for(let x=0,v=b.length;x<v;x++){const S=b[x];u[p]=S.start*l,d[p]=S.count,p++}ij.reset()}else for(let b=0,y=c.length;b<y;b++)if(c[b]){let x=!1;if(m&&(this.getMatrixAt(b,dd),this.getBoundingSphereAt(b,qh).applyMatrix4(dd),x=!rj.intersectsSphere(qh)),!x){const v=f[b];u[p]=v.start*l,d[p]=v.count,p++}}this._multiDrawCount=p,this._visibilityChanged=!1}onBeforeShadow(e,n,r,i,a,o){this.onBeforeRender(e,null,i,a,o)}}class qy extends dx{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 X7=new Be,Y7=new Be,Q7=new Tr,aj=new xL,E1=new Xl;class h6e extends es{constructor(e=new Ha,n=new qy){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++)X7.fromBufferAttribute(n,i-1),Y7.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=X7.distanceTo(Y7);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;Q7.copy(i).invert(),aj.copy(e.ray).applyMatrix4(Q7);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 v=Math.max(0,o.start),S=Math.min(b.count,o.start+o.count);for(let M=v,E=S-1;M<E;M+=p){const A=b.getX(M),k=b.getX(M+1);if(u.fromBufferAttribute(x,A),d.fromBufferAttribute(x,k),aj.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 v=Math.max(0,o.start),S=Math.min(x.count,o.start+o.count);for(let M=v,E=S-1;M<E;M+=p){if(u.fromBufferAttribute(x,M),d.fromBufferAttribute(x,M+1),aj.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,J7=new Be;class bE extends h6e{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),J7.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+Z7.distanceTo(J7);e.setAttribute("lineDistance",new pi(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class f6e 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,y=m+p;b<y;b+=3)for(let x=0;x<3;x++){const v=l.getX(b+x),S=l.getX(b+(x+1)%3);i.fromBufferAttribute(o,v),a.fromBufferAttribute(o,S),e9(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),e9(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 e9(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 m6e extends dx{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=Wee,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=fL,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 p6e extends qy{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 mte 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 sj=new Tr,t9=new Be,n9=new Be;class g6e{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 gE,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;t9.setFromMatrixPosition(e.matrixWorld),n.position.copy(t9),n9.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(n9),n.updateMatrixWorld(),sj.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(sj),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(sj)}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 r9=new Tr,jb=new Be,oj=new Be;class x6e extends g6e{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()),jb.setFromMatrixPosition(e.matrixWorld),r.position.copy(jb),oj.copy(r.position),oj.add(this._cubeDirections[n]),r.up.copy(this._cubeUps[n]),r.lookAt(oj),r.updateMatrixWorld(),i.makeTranslation(-jb.x,-jb.y,-jb.z),r9.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(r9)}}class b6e extends mte{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 x6e}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 y6e extends mte{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}}class v6e 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 PR extends i6e{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 i9{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(_a(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const a9=new Be,A1=new Be;class _6e{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){a9.subVectors(e,this.start),A1.subVectors(this.end,this.start);const r=A1.dot(A1);let a=A1.dot(a9)/r;return n&&(a=_a(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 w6e extends bE{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 qy({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:fE}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=fE);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 S6e 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 RR(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 M6e={isPrimitive:!0,match:t=>typeof t=="string",fromHexString:RR,toHexString:RR},ty={isPrimitive:!0,match:t=>typeof t=="number",fromHexString:t=>parseInt(t.substring(1),16),toHexString:t=>"#"+t.toString(16).padStart(6,0)},N6e={isPrimitive:!1,match:t=>Array.isArray(t),fromHexString(t,e,n=1){const r=ty.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 ty.toHexString(i)}},E6e={isPrimitive:!1,match:t=>Object(t)===t,fromHexString(t,e,n=1){const r=ty.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 ty.toHexString(i)}},A6e=[M6e,ty,N6e,E6e];function T6e(t){return A6e.find(e=>e.match(t))}class C6e 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=T6e(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=RR(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 lj 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 k6e 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",y)},b=S=>{if(o){const M=S.clientX-l,E=S.clientY-c;Math.abs(E)>m?(S.preventDefault(),this.$input.blur(),o=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(M)>m&&y()}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},y=()=>{this._setDraggingStyle(!1,"vertical"),this._callOnFinishChange(),window.removeEventListener("mousemove",b),window.removeEventListener("mouseup",y)},x=()=>{this._inputFocused=!0},v=()=>{this._inputFocused=!1,this.updateDisplay(),this._callOnFinishChange()};this.$input.addEventListener("input",n),this.$input.addEventListener("keydown",i),this.$input.addEventListener("wheel",a,{passive:!1}),this.$input.addEventListener("mousedown",p),this.$input.addEventListener("focus",x),this.$input.addEventListener("blur",v)}_initSlider(){this._hasSlider=!0,this.$slider=document.createElement("div"),this.$slider.classList.add("slider"),this.$fill=document.createElement("div"),this.$fill.classList.add("fill"),this.$slider.appendChild(this.$fill),this.$widget.insertBefore(this.$slider,this.$input),this.domElement.classList.add("hasSlider");const e=(v,S,M,E,A)=>(v-S)/(M-S)*(A-E)+E,n=v=>{const S=this.$slider.getBoundingClientRect();let M=e(v,S.left,S.right,this._min,this._max);this._snapClampSetValue(M)},r=v=>{this._setDraggingStyle(!0),n(v.clientX),window.addEventListener("mousemove",i),window.addEventListener("mouseup",a)},i=v=>{n(v.clientX)},a=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",a)};let o=!1,l,c;const u=v=>{v.preventDefault(),this._setDraggingStyle(!0),n(v.touches[0].clientX),o=!1},d=v=>{v.touches.length>1||(this._hasScrollBar?(l=v.touches[0].clientX,c=v.touches[0].clientY,o=!0):u(v),window.addEventListener("touchmove",f,{passive:!1}),window.addEventListener("touchend",m))},f=v=>{if(o){const S=v.touches[0].clientX-l,M=v.touches[0].clientY-c;Math.abs(S)>Math.abs(M)?u(v):(window.removeEventListener("touchmove",f),window.removeEventListener("touchend",m))}else v.preventDefault(),n(v.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 y;const x=v=>{if(Math.abs(v.deltaX)<Math.abs(v.deltaY)&&this._hasScrollBar)return;v.preventDefault();const M=this._normalizeMouseWheel(v)*this._step;this._snapClampSetValue(this.getValue()+M),this.$input.value=this.getValue(),clearTimeout(y),y=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 j6e 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 P6e 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 R6e=`.lil-gui {
- font-family: var(--font-family);
- font-size: var(--font-size);
- line-height: 1;
- font-weight: normal;
- font-style: normal;
- text-align: left;
- color: var(--text-color);
- user-select: none;
- -webkit-user-select: none;
- touch-action: manipulation;
- --background-color: #1f1f1f;
- --text-color: #ebebeb;
- --title-background-color: #111111;
- --title-text-color: #ebebeb;
- --widget-color: #424242;
- --hover-color: #4f4f4f;
- --focus-color: #595959;
- --number-color: #2cc9ff;
- --string-color: #a2db3c;
- --font-size: 11px;
- --input-font-size: 11px;
- --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
- --font-family-mono: Menlo, Monaco, Consolas, "Droid Sans Mono", monospace;
- --padding: 4px;
- --spacing: 4px;
- --widget-height: 20px;
- --title-height: calc(var(--widget-height) + var(--spacing) * 1.25);
- --name-width: 45%;
- --slider-knob-width: 2px;
- --slider-input-width: 27%;
- --color-input-width: 27%;
- --slider-input-min-width: 45px;
- --color-input-min-width: 45px;
- --folder-indent: 7px;
- --widget-padding: 0 0 0 3px;
- --widget-border-radius: 2px;
- --checkbox-size: calc(0.75 * var(--widget-height));
- --scrollbar-width: 5px;
- }
- .lil-gui, .lil-gui * {
- box-sizing: border-box;
- margin: 0;
- padding: 0;
- }
- .lil-gui.root {
- width: var(--width, 245px);
- display: flex;
- flex-direction: column;
- background: var(--background-color);
- }
- .lil-gui.root > .title {
- background: var(--title-background-color);
- color: var(--title-text-color);
- }
- .lil-gui.root > .children {
- overflow-x: hidden;
- overflow-y: auto;
- }
- .lil-gui.root > .children::-webkit-scrollbar {
- width: var(--scrollbar-width);
- height: var(--scrollbar-width);
- background: var(--background-color);
- }
- .lil-gui.root > .children::-webkit-scrollbar-thumb {
- border-radius: var(--scrollbar-width);
- background: var(--focus-color);
- }
- @media (pointer: coarse) {
- .lil-gui.allow-touch-styles, .lil-gui.allow-touch-styles .lil-gui {
- --widget-height: 28px;
- --padding: 6px;
- --spacing: 6px;
- --font-size: 13px;
- --input-font-size: 16px;
- --folder-indent: 10px;
- --scrollbar-width: 7px;
- --slider-input-min-width: 50px;
- --color-input-min-width: 65px;
- }
- }
- .lil-gui.force-touch-styles, .lil-gui.force-touch-styles .lil-gui {
- --widget-height: 28px;
- --padding: 6px;
- --spacing: 6px;
- --font-size: 13px;
- --input-font-size: 16px;
- --folder-indent: 10px;
- --scrollbar-width: 7px;
- --slider-input-min-width: 50px;
- --color-input-min-width: 65px;
- }
- .lil-gui.autoPlace {
- max-height: 100%;
- position: fixed;
- top: 0;
- right: 15px;
- z-index: 1001;
- }
- .lil-gui .controller {
- display: flex;
- align-items: center;
- padding: 0 var(--padding);
- margin: var(--spacing) 0;
- }
- .lil-gui .controller.disabled {
- opacity: 0.5;
- }
- .lil-gui .controller.disabled, .lil-gui .controller.disabled * {
- pointer-events: none !important;
- }
- .lil-gui .controller > .name {
- min-width: var(--name-width);
- flex-shrink: 0;
- white-space: pre;
- padding-right: var(--spacing);
- line-height: var(--widget-height);
- }
- .lil-gui .controller .widget {
- position: relative;
- display: flex;
- align-items: center;
- width: 100%;
- min-height: var(--widget-height);
- }
- .lil-gui .controller.string input {
- color: var(--string-color);
- }
- .lil-gui .controller.boolean {
- cursor: pointer;
- }
- .lil-gui .controller.color .display {
- width: 100%;
- height: var(--widget-height);
- border-radius: var(--widget-border-radius);
- position: relative;
- }
- @media (hover: hover) {
- .lil-gui .controller.color .display:hover:before {
- content: " ";
- display: block;
- position: absolute;
- border-radius: var(--widget-border-radius);
- border: 1px solid #fff9;
- top: 0;
- right: 0;
- bottom: 0;
- left: 0;
- }
- }
- .lil-gui .controller.color input[type=color] {
- opacity: 0;
- width: 100%;
- height: 100%;
- cursor: pointer;
- }
- .lil-gui .controller.color input[type=text] {
- margin-left: var(--spacing);
- font-family: var(--font-family-mono);
- min-width: var(--color-input-min-width);
- width: var(--color-input-width);
- flex-shrink: 0;
- }
- .lil-gui .controller.option select {
- opacity: 0;
- position: absolute;
- width: 100%;
- max-width: 100%;
- }
- .lil-gui .controller.option .display {
- position: relative;
- pointer-events: none;
- border-radius: var(--widget-border-radius);
- height: var(--widget-height);
- line-height: var(--widget-height);
- max-width: 100%;
- overflow: hidden;
- word-break: break-all;
- padding-left: 0.55em;
- padding-right: 1.75em;
- background: var(--widget-color);
- }
- @media (hover: hover) {
- .lil-gui .controller.option .display.focus {
- background: var(--focus-color);
- }
- }
- .lil-gui .controller.option .display.active {
- background: var(--focus-color);
- }
- .lil-gui .controller.option .display:after {
- font-family: "lil-gui";
- content: "↕";
- position: absolute;
- top: 0;
- right: 0;
- bottom: 0;
- padding-right: 0.375em;
- }
- .lil-gui .controller.option .widget,
- .lil-gui .controller.option select {
- cursor: pointer;
- }
- @media (hover: hover) {
- .lil-gui .controller.option .widget:hover .display {
- background: var(--hover-color);
- }
- }
- .lil-gui .controller.number input {
- color: var(--number-color);
- }
- .lil-gui .controller.number.hasSlider input {
- margin-left: var(--spacing);
- width: var(--slider-input-width);
- min-width: var(--slider-input-min-width);
- flex-shrink: 0;
- }
- .lil-gui .controller.number .slider {
- width: 100%;
- height: var(--widget-height);
- background: var(--widget-color);
- border-radius: var(--widget-border-radius);
- padding-right: var(--slider-knob-width);
- overflow: hidden;
- cursor: ew-resize;
- touch-action: pan-y;
- }
- @media (hover: hover) {
- .lil-gui .controller.number .slider:hover {
- background: var(--hover-color);
- }
- }
- .lil-gui .controller.number .slider.active {
- background: var(--focus-color);
- }
- .lil-gui .controller.number .slider.active .fill {
- opacity: 0.95;
- }
- .lil-gui .controller.number .fill {
- height: 100%;
- border-right: var(--slider-knob-width) solid var(--number-color);
- box-sizing: content-box;
- }
- .lil-gui-dragging .lil-gui {
- --hover-color: var(--widget-color);
- }
- .lil-gui-dragging * {
- cursor: ew-resize !important;
- }
- .lil-gui-dragging.lil-gui-vertical * {
- cursor: ns-resize !important;
- }
- .lil-gui .title {
- height: var(--title-height);
- line-height: calc(var(--title-height) - 4px);
- font-weight: 600;
- padding: 0 var(--padding);
- -webkit-tap-highlight-color: transparent;
- cursor: pointer;
- outline: none;
- text-decoration-skip: objects;
- }
- .lil-gui .title:before {
- font-family: "lil-gui";
- content: "▾";
- padding-right: 2px;
- display: inline-block;
- }
- .lil-gui .title:active {
- background: var(--title-background-color);
- opacity: 0.75;
- }
- @media (hover: hover) {
- body:not(.lil-gui-dragging) .lil-gui .title:hover {
- background: var(--title-background-color);
- opacity: 0.85;
- }
- .lil-gui .title:focus {
- text-decoration: underline var(--focus-color);
- }
- }
- .lil-gui.root > .title:focus {
- text-decoration: none !important;
- }
- .lil-gui.closed > .title:before {
- content: "▸";
- }
- .lil-gui.closed > .children {
- transform: translateY(-7px);
- opacity: 0;
- }
- .lil-gui.closed:not(.transition) > .children {
- display: none;
- }
- .lil-gui.transition > .children {
- transition-duration: 300ms;
- transition-property: height, opacity, transform;
- transition-timing-function: cubic-bezier(0.2, 0.6, 0.35, 1);
- overflow: hidden;
- pointer-events: none;
- }
- .lil-gui .children:empty:before {
- content: "Empty";
- padding: 0 var(--padding);
- margin: var(--spacing) 0;
- display: block;
- height: var(--widget-height);
- font-style: italic;
- line-height: var(--widget-height);
- opacity: 0.5;
- }
- .lil-gui.root > .children > .lil-gui > .title {
- border: 0 solid var(--widget-color);
- border-width: 1px 0;
- transition: border-color 300ms;
- }
- .lil-gui.root > .children > .lil-gui.closed > .title {
- border-bottom-color: transparent;
- }
- .lil-gui + .controller {
- border-top: 1px solid var(--widget-color);
- margin-top: 0;
- padding-top: var(--spacing);
- }
- .lil-gui .lil-gui .lil-gui > .title {
- border: none;
- }
- .lil-gui .lil-gui .lil-gui > .children {
- border: none;
- margin-left: var(--folder-indent);
- border-left: 2px solid var(--widget-color);
- }
- .lil-gui .lil-gui .controller {
- border: none;
- }
- .lil-gui label, .lil-gui input, .lil-gui button {
- -webkit-tap-highlight-color: transparent;
- }
- .lil-gui input {
- border: 0;
- outline: none;
- font-family: var(--font-family);
- font-size: var(--input-font-size);
- border-radius: var(--widget-border-radius);
- height: var(--widget-height);
- background: var(--widget-color);
- color: var(--text-color);
- width: 100%;
- }
- @media (hover: hover) {
- .lil-gui input:hover {
- background: var(--hover-color);
- }
- .lil-gui input:active {
- background: var(--focus-color);
- }
- }
- .lil-gui input:disabled {
- opacity: 1;
- }
- .lil-gui input[type=text],
- .lil-gui input[type=number] {
- padding: var(--widget-padding);
- -moz-appearance: textfield;
- }
- .lil-gui input[type=text]:focus,
- .lil-gui input[type=number]:focus {
- background: var(--focus-color);
- }
- .lil-gui input[type=checkbox] {
- appearance: none;
- width: var(--checkbox-size);
- height: var(--checkbox-size);
- border-radius: var(--widget-border-radius);
- text-align: center;
- cursor: pointer;
- }
- .lil-gui input[type=checkbox]:checked:before {
- font-family: "lil-gui";
- content: "✓";
- font-size: var(--checkbox-size);
- line-height: var(--checkbox-size);
- }
- @media (hover: hover) {
- .lil-gui input[type=checkbox]:focus {
- box-shadow: inset 0 0 0 1px var(--focus-color);
- }
- }
- .lil-gui button {
- outline: none;
- cursor: pointer;
- font-family: var(--font-family);
- font-size: var(--font-size);
- color: var(--text-color);
- width: 100%;
- height: var(--widget-height);
- text-transform: none;
- background: var(--widget-color);
- border-radius: var(--widget-border-radius);
- border: none;
- }
- @media (hover: hover) {
- .lil-gui button:hover {
- background: var(--hover-color);
- }
- .lil-gui button:focus {
- box-shadow: inset 0 0 0 1px var(--focus-color);
- }
- }
- .lil-gui button:active {
- background: var(--focus-color);
- }
- @font-face {
- font-family: "lil-gui";
- src: url("data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAAUsAAsAAAAACJwAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAAH4AAADAImwmYE9TLzIAAAGIAAAAPwAAAGBKqH5SY21hcAAAAcgAAAD0AAACrukyyJBnbHlmAAACvAAAAF8AAACEIZpWH2hlYWQAAAMcAAAAJwAAADZfcj2zaGhlYQAAA0QAAAAYAAAAJAC5AHhobXR4AAADXAAAABAAAABMAZAAAGxvY2EAAANsAAAAFAAAACgCEgIybWF4cAAAA4AAAAAeAAAAIAEfABJuYW1lAAADoAAAASIAAAIK9SUU/XBvc3QAAATEAAAAZgAAAJCTcMc2eJxVjbEOgjAURU+hFRBK1dGRL+ALnAiToyMLEzFpnPz/eAshwSa97517c/MwwJmeB9kwPl+0cf5+uGPZXsqPu4nvZabcSZldZ6kfyWnomFY/eScKqZNWupKJO6kXN3K9uCVoL7iInPr1X5baXs3tjuMqCtzEuagm/AAlzQgPAAB4nGNgYRBlnMDAysDAYM/gBiT5oLQBAwuDJAMDEwMrMwNWEJDmmsJwgCFeXZghBcjlZMgFCzOiKOIFAB71Bb8AeJy1kjFuwkAQRZ+DwRAwBtNQRUGKQ8OdKCAWUhAgKLhIuAsVSpWz5Bbkj3dEgYiUIszqWdpZe+Z7/wB1oCYmIoboiwiLT2WjKl/jscrHfGg/pKdMkyklC5Zs2LEfHYpjcRoPzme9MWWmk3dWbK9ObkWkikOetJ554fWyoEsmdSlt+uR0pCJR34b6t/TVg1SY3sYvdf8vuiKrpyaDXDISiegp17p7579Gp3p++y7HPAiY9pmTibljrr85qSidtlg4+l25GLCaS8e6rRxNBmsnERunKbaOObRz7N72ju5vdAjYpBXHgJylOAVsMseDAPEP8LYoUHicY2BiAAEfhiAGJgZWBgZ7RnFRdnVJELCQlBSRlATJMoLV2DK4glSYs6ubq5vbKrJLSbGrgEmovDuDJVhe3VzcXFwNLCOILB/C4IuQ1xTn5FPilBTj5FPmBAB4WwoqAHicY2BkYGAA4sk1sR/j+W2+MnAzpDBgAyEMQUCSg4EJxAEAwUgFHgB4nGNgZGBgSGFggJMhDIwMqEAYAByHATJ4nGNgAIIUNEwmAABl3AGReJxjYAACIQYlBiMGJ3wQAEcQBEV4nGNgZGBgEGZgY2BiAAEQyQWEDAz/wXwGAAsPATIAAHicXdBNSsNAHAXwl35iA0UQXYnMShfS9GPZA7T7LgIu03SSpkwzYTIt1BN4Ak/gKTyAeCxfw39jZkjymzcvAwmAW/wgwHUEGDb36+jQQ3GXGot79L24jxCP4gHzF/EIr4jEIe7wxhOC3g2TMYy4Q7+Lu/SHuEd/ivt4wJd4wPxbPEKMX3GI5+DJFGaSn4qNzk8mcbKSR6xdXdhSzaOZJGtdapd4vVPbi6rP+cL7TGXOHtXKll4bY1Xl7EGnPtp7Xy2n00zyKLVHfkHBa4IcJ2oD3cgggWvt/V/FbDrUlEUJhTn/0azVWbNTNr0Ens8de1tceK9xZmfB1CPjOmPH4kitmvOubcNpmVTN3oFJyjzCvnmrwhJTzqzVj9jiSX911FjeAAB4nG3HMRKCMBBA0f0giiKi4DU8k0V2GWbIZDOh4PoWWvq6J5V8If9NVNQcaDhyouXMhY4rPTcG7jwYmXhKq8Wz+p762aNaeYXom2n3m2dLTVgsrCgFJ7OTmIkYbwIbC6vIB7WmFfAAAA==") format("woff");
- }`;function D6e(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 s9=!1;class QS{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"),!s9&&l&&(D6e(R6e),s9=!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 j6e(this,e,n,r);const o=e[n];switch(typeof o){case"number":return new k6e(this,e,n,r,i,a);case"boolean":return new S6e(this,e,n);case"string":return new P6e(this,e,n);case"function":return new lj(this,e,n)}console.error(`gui.add failed
- property:`,n,`
- object:`,e,`
- value:`,o)}addColor(e,n,r=1){return new C6e(this,e,n,r)}addFolder(e){const n=new QS({parent:this,title:e});return this.root._closeFolders&&n.close(),n}load(e,n=!0){return e.controllers&&this.controllers.forEach(r=>{r instanceof lj||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 lj)){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 cj(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 wL{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 wL(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 SL{constructor(e,n,r,i){this.src=e,this.gcode=n,this.params=r,this.comment=i}}class o9 extends SL{constructor(e,n,r,i){super(e,n,r,i),this.params=r}}class hd extends SL{constructor(e,n,r,i){super(e,n,void 0,r),this.toolIndex=i}}class l9{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 l9(-1,[],0),this.layers=[],this.curZ=0,this.maxZ=0,this.metadata={thumbnails:{}},this.tolerance=0,this.tolerance=e??this.tolerance}parseGCode(e){const n=Array.isArray(e)?e:e.split(`
- `);this.lines=this.lines.concat(n);const r=this.lines2commands(n);this.groupIntoLayers(r);const i=this.parseMetadata(r.filter((a=>a.comment))).thumbnails;for(const[a,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 o9(e,c,u,o);case"t0":return new hd(e,c,o,0);case"t1":return new hd(e,c,o,1);case"t2":return new hd(e,c,o,2);case"t3":return new hd(e,c,o,3);case"t4":return new hd(e,c,o,4);case"t5":return new hd(e,c,o,5);case"t6":return new hd(e,c,o,6);case"t7":return new hd(e,c,o,7);default:return new SL(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 o9){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 l9(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=wL.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 c9={type:"change"},uj={type:"start"},u9={type:"end"},T1=new xL,d9=new yd,O6e=Math.cos(70*Kee.DEG2RAD);class L6e extends fm{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:mp.ROTATE,MIDDLE:mp.DOLLY,RIGHT:mp.PAN},this.touches={ONE:pp.ROTATE,TWO:pp.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(J){J.addEventListener("keydown",_e),this._domElementKeyEvents=J},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",_e),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(c9),r.update(),a=i.NONE},this.update=(function(){const J=new Be,K=new nm().setFromUnitVectors(e.up,new Be(0,1,0)),B=K.clone().invert(),I=new Be,ce=new nm,Ee=new Be,Ie=2*Math.PI;return function(ue=null){const $=r.object.position;J.copy($).sub(r.target),J.applyQuaternion(K),l.setFromVector3(J),r.autoRotate&&a===i.NONE&&R((function(Se){return Se!==null?2*Math.PI/60*r.autoRotateSpeed*Se:2*Math.PI/60/60*r.autoRotateSpeed})(ue)),r.enableDamping?(l.theta+=c.theta*r.dampingFactor,l.phi+=c.phi*r.dampingFactor):(l.theta+=c.theta,l.phi+=c.phi);let L=r.minAzimuthAngle,Y=r.maxAzimuthAngle;isFinite(L)&&isFinite(Y)&&(L<-Math.PI?L+=Ie:L>Math.PI&&(L-=Ie),Y<-Math.PI?Y+=Ie:Y>Math.PI&&(Y-=Ie),l.theta=L<=Y?Math.max(L,Math.min(Y,l.theta)):l.theta>(L+Y)/2?Math.max(L,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=Z(l.radius):l.radius=Z(l.radius*u),J.setFromSpherical(l),J.applyQuaternion(B),$.copy(r.target).add(J),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 Se=null;if(r.object.isPerspectiveCamera){const ae=J.length();Se=Z(ae*u);const je=ae-Se;r.object.position.addScaledVector(E,je),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 je=new Be(A.x,A.y,0);je.unproject(r.object),r.object.position.sub(je).add(ae),r.object.updateMatrixWorld(),Se=J.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),r.zoomToCursor=!1;Se!==null&&(this.screenSpacePanning?r.target.set(0,0,-1).transformDirection(r.object.matrix).multiplyScalar(Se).add(r.object.position):(T1.origin.copy(r.object.position),T1.direction.set(0,0,-1).transformDirection(r.object.matrix),Math.abs(r.object.up.dot(T1.direction))<O6e?e.lookAt(r.target):(d9.setFromNormalAndCoplanarPoint(r.object.up,r.target),T1.intersectPlane(d9,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(c9),I.copy(r.object.position),ce.copy(r.object.quaternion),Ee.copy(r.target),!0)}})(),this.dispose=function(){r.domElement.removeEventListener("contextmenu",le),r.domElement.removeEventListener("pointerdown",oe),r.domElement.removeEventListener("pointercancel",ge),r.domElement.removeEventListener("wheel",Ne),r.domElement.removeEventListener("pointermove",Ae),r.domElement.removeEventListener("pointerup",ge),r._domElementKeyEvents!==null&&(r._domElementKeyEvents.removeEventListener("keydown",_e),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 i9,c=new i9;let u=1;const d=new Be,f=new mn,m=new mn,p=new mn,b=new mn,y=new mn,x=new mn,v=new mn,S=new mn,M=new mn,E=new Be,A=new mn;let k=!1;const T=[],D={};function C(){return Math.pow(.95,r.zoomSpeed)}function R(J){c.theta-=J}function U(J){c.phi-=J}const O=(function(){const J=new Be;return function(K,B){J.setFromMatrixColumn(B,0),J.multiplyScalar(-K),d.add(J)}})(),q=(function(){const J=new Be;return function(K,B){r.screenSpacePanning===!0?J.setFromMatrixColumn(B,1):(J.setFromMatrixColumn(B,0),J.crossVectors(r.object.up,J)),J.multiplyScalar(K),d.add(J)}})(),j=(function(){const J=new Be;return function(K,B){const I=r.domElement;if(r.object.isPerspectiveCamera){const ce=r.object.position;J.copy(ce).sub(r.target);let Ee=J.length();Ee*=Math.tan(r.object.fov/2*Math.PI/180),O(2*K*Ee/I.clientHeight,r.object.matrix),q(2*B*Ee/I.clientHeight,r.object.matrix)}else r.object.isOrthographicCamera?(O(K*(r.object.right-r.object.left)/r.object.zoom/I.clientWidth,r.object.matrix),q(B*(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(J){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u/=J:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function X(J){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u*=J:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function G(J){if(!r.zoomToCursor)return;k=!0;const K=r.domElement.getBoundingClientRect(),B=J.clientX-K.left,I=J.clientY-K.top,ce=K.width,Ee=K.height;A.x=B/ce*2-1,A.y=-I/Ee*2+1,E.set(A.x,A.y,1).unproject(r.object).sub(r.object.position).normalize()}function Z(J){return Math.max(r.minDistance,Math.min(r.maxDistance,J))}function te(J){f.set(J.clientX,J.clientY)}function ee(J){b.set(J.clientX,J.clientY)}function z(){if(T.length===1)f.set(T[0].pageX,T[0].pageY);else{const J=.5*(T[0].pageX+T[1].pageX),K=.5*(T[0].pageY+T[1].pageY);f.set(J,K)}}function V(){if(T.length===1)b.set(T[0].pageX,T[0].pageY);else{const J=.5*(T[0].pageX+T[1].pageX),K=.5*(T[0].pageY+T[1].pageY);b.set(J,K)}}function ne(){const J=T[0].pageX-T[1].pageX,K=T[0].pageY-T[1].pageY,B=Math.sqrt(J*J+K*K);v.set(0,B)}function ie(J){if(T.length==1)m.set(J.pageX,J.pageY);else{const B=H(J),I=.5*(J.pageX+B.x),ce=.5*(J.pageY+B.y);m.set(I,ce)}p.subVectors(m,f).multiplyScalar(r.rotateSpeed);const K=r.domElement;R(2*Math.PI*p.x/K.clientHeight),U(2*Math.PI*p.y/K.clientHeight),f.copy(m)}function he(J){if(T.length===1)y.set(J.pageX,J.pageY);else{const K=H(J),B=.5*(J.pageX+K.x),I=.5*(J.pageY+K.y);y.set(B,I)}x.subVectors(y,b).multiplyScalar(r.panSpeed),j(x.x,x.y),b.copy(y)}function me(J){const K=H(J),B=J.pageX-K.x,I=J.pageY-K.y,ce=Math.sqrt(B*B+I*I);S.set(0,ce),M.set(0,Math.pow(S.y/v.y,r.zoomSpeed)),W(M.y),v.copy(S)}function oe(J){r.enabled!==!1&&(T.length===0&&(r.domElement.setPointerCapture(J.pointerId),r.domElement.addEventListener("pointermove",Ae),r.domElement.addEventListener("pointerup",ge)),(function(K){T.push(K)})(J),J.pointerType==="touch"?(function(K){switch(He(K),T.length){case 1:switch(r.touches.ONE){case pp.ROTATE:if(r.enableRotate===!1)return;z(),a=i.TOUCH_ROTATE;break;case pp.PAN:if(r.enablePan===!1)return;V(),a=i.TOUCH_PAN;break;default:a=i.NONE}break;case 2:switch(r.touches.TWO){case pp.DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;r.enableZoom&&ne(),r.enablePan&&V(),a=i.TOUCH_DOLLY_PAN;break;case pp.DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;r.enableZoom&&ne(),r.enableRotate&&z(),a=i.TOUCH_DOLLY_ROTATE;break;default:a=i.NONE}break;default:a=i.NONE}a!==i.NONE&&r.dispatchEvent(uj)})(J):(function(K){let B;switch(K.button){case 0:B=r.mouseButtons.LEFT;break;case 1:B=r.mouseButtons.MIDDLE;break;case 2:B=r.mouseButtons.RIGHT;break;default:B=-1}switch(B){case mp.DOLLY:if(r.enableZoom===!1)return;(function(I){G(I),v.set(I.clientX,I.clientY)})(K),a=i.DOLLY;break;case mp.ROTATE:if(K.ctrlKey||K.metaKey||K.shiftKey){if(r.enablePan===!1)return;ee(K),a=i.PAN}else{if(r.enableRotate===!1)return;te(K),a=i.ROTATE}break;case mp.PAN:if(K.ctrlKey||K.metaKey||K.shiftKey){if(r.enableRotate===!1)return;te(K),a=i.ROTATE}else{if(r.enablePan===!1)return;ee(K),a=i.PAN}break;default:a=i.NONE}a!==i.NONE&&r.dispatchEvent(uj)})(J))}function Ae(J){r.enabled!==!1&&(J.pointerType==="touch"?(function(K){switch(He(K),a){case i.TOUCH_ROTATE:if(r.enableRotate===!1)return;ie(K),r.update();break;case i.TOUCH_PAN:if(r.enablePan===!1)return;he(K),r.update();break;case i.TOUCH_DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;(function(B){r.enableZoom&&me(B),r.enablePan&&he(B)})(K),r.update();break;case i.TOUCH_DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;(function(B){r.enableZoom&&me(B),r.enableRotate&&ie(B)})(K),r.update();break;default:a=i.NONE}})(J):(function(K){switch(a){case i.ROTATE:if(r.enableRotate===!1)return;(function(B){m.set(B.clientX,B.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()})(K);break;case i.DOLLY:if(r.enableZoom===!1)return;(function(B){S.set(B.clientX,B.clientY),M.subVectors(S,v),M.y>0?W(C()):M.y<0&&X(C()),v.copy(S),r.update()})(K);break;case i.PAN:if(r.enablePan===!1)return;(function(B){y.set(B.clientX,B.clientY),x.subVectors(y,b).multiplyScalar(r.panSpeed),j(x.x,x.y),b.copy(y),r.update()})(K)}})(J))}function ge(J){(function(K){delete D[K.pointerId];for(let B=0;B<T.length;B++)if(T[B].pointerId==K.pointerId)return void T.splice(B,1)})(J),T.length===0&&(r.domElement.releasePointerCapture(J.pointerId),r.domElement.removeEventListener("pointermove",Ae),r.domElement.removeEventListener("pointerup",ge)),r.dispatchEvent(u9),a=i.NONE}function Ne(J){r.enabled!==!1&&r.enableZoom!==!1&&a===i.NONE&&(J.preventDefault(),r.dispatchEvent(uj),(function(K){G(K),K.deltaY<0?X(C()):K.deltaY>0&&W(C()),r.update()})(J),r.dispatchEvent(u9))}function _e(J){r.enabled!==!1&&r.enablePan!==!1&&(function(K){let B=!1;switch(K.code){case r.keys.UP:K.ctrlKey||K.metaKey||K.shiftKey?U(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):j(0,r.keyPanSpeed),B=!0;break;case r.keys.BOTTOM:K.ctrlKey||K.metaKey||K.shiftKey?U(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):j(0,-r.keyPanSpeed),B=!0;break;case r.keys.LEFT:K.ctrlKey||K.metaKey||K.shiftKey?R(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):j(r.keyPanSpeed,0),B=!0;break;case r.keys.RIGHT:K.ctrlKey||K.metaKey||K.shiftKey?R(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):j(-r.keyPanSpeed,0),B=!0}B&&(K.preventDefault(),r.update())})(J)}function le(J){r.enabled!==!1&&J.preventDefault()}function He(J){let K=D[J.pointerId];K===void 0&&(K=new mn,D[J.pointerId]=K),K.set(J.pageX,J.pageY)}function H(J){const K=J.pointerId===T[0].pointerId?T[1]:T[0];return D[K.pointerId]}r.domElement.addEventListener("contextmenu",le),r.domElement.addEventListener("pointerdown",oe),r.domElement.addEventListener("pointercancel",ge),r.domElement.addEventListener("wheel",Ne,{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}},xs.line={uniforms:bL.merge([Lt.common,Lt.fog,Lt.line]),vertexShader:`
- #include <common>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- uniform float linewidth;
- uniform vec2 resolution;
- attribute vec3 instanceStart;
- attribute vec3 instanceEnd;
- attribute vec3 instanceColorStart;
- attribute vec3 instanceColorEnd;
- #ifdef WORLD_UNITS
- varying vec4 worldPos;
- varying vec3 worldStart;
- varying vec3 worldEnd;
- #ifdef USE_DASH
- varying vec2 vUv;
- #endif
- #else
- varying vec2 vUv;
- #endif
- #ifdef USE_DASH
- uniform float dashScale;
- attribute float instanceDistanceStart;
- attribute float instanceDistanceEnd;
- varying float vLineDistance;
- #endif
- void trimSegment( const in vec4 start, inout vec4 end ) {
- // trim end segment so it terminates between the camera plane and the near plane
- // conservative estimate of the near plane
- float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
- float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
- float nearEstimate = - 0.5 * b / a;
- float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );
- end.xyz = mix( start.xyz, end.xyz, alpha );
- }
- void main() {
- #ifdef USE_COLOR
- vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
- #endif
- #ifdef USE_DASH
- vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
- vUv = uv;
- #endif
- float aspect = resolution.x / resolution.y;
- // camera space
- vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
- vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
- #ifdef WORLD_UNITS
- worldStart = start.xyz;
- worldEnd = end.xyz;
- #else
- vUv = uv;
- #endif
- // special case for perspective projection, and segments that terminate either in, or behind, the camera plane
- // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
- // but we need to perform ndc-space calculations in the shader, so we must address this issue directly
- // perhaps there is a more elegant solution -- WestLangley
- bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
- if ( perspective ) {
- if ( start.z < 0.0 && end.z >= 0.0 ) {
- trimSegment( start, end );
- } else if ( end.z < 0.0 && start.z >= 0.0 ) {
- trimSegment( end, start );
- }
- }
- // clip space
- vec4 clipStart = projectionMatrix * start;
- vec4 clipEnd = projectionMatrix * end;
- // ndc space
- vec3 ndcStart = clipStart.xyz / clipStart.w;
- vec3 ndcEnd = clipEnd.xyz / clipEnd.w;
- // direction
- vec2 dir = ndcEnd.xy - ndcStart.xy;
- // account for clip-space aspect ratio
- dir.x *= aspect;
- dir = normalize( dir );
- #ifdef WORLD_UNITS
- // get the offset direction as perpendicular to the view vector
- vec3 worldDir = normalize( end.xyz - start.xyz );
- vec3 offset;
- if ( position.y < 0.5 ) {
- offset = normalize( cross( start.xyz, worldDir ) );
- } else {
- offset = normalize( cross( end.xyz, worldDir ) );
- }
- // sign flip
- if ( position.x < 0.0 ) offset *= - 1.0;
- float forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) );
- // don't extend the line if we're rendering dashes because we
- // won't be rendering the endcaps
- #ifndef USE_DASH
- // extend the line bounds to encompass endcaps
- start.xyz += - worldDir * linewidth * 0.5;
- end.xyz += worldDir * linewidth * 0.5;
- // shift the position of the quad so it hugs the forward edge of the line
- offset.xy -= dir * forwardOffset;
- offset.z += 0.5;
- #endif
- // endcaps
- if ( position.y > 1.0 || position.y < 0.0 ) {
- offset.xy += dir * 2.0 * forwardOffset;
- }
- // adjust for linewidth
- offset *= linewidth * 0.5;
- // set the world position
- worldPos = ( position.y < 0.5 ) ? start : end;
- worldPos.xyz += offset;
- // project the worldpos
- vec4 clip = projectionMatrix * worldPos;
- // shift the depth of the projected points so the line
- // segments overlap neatly
- vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
- clip.z = clipPose.z * clip.w;
- #else
- vec2 offset = vec2( dir.y, - dir.x );
- // undo aspect ratio adjustment
- dir.x /= aspect;
- offset.x /= aspect;
- // sign flip
- if ( position.x < 0.0 ) offset *= - 1.0;
- // endcaps
- if ( position.y < 0.0 ) {
- offset += - dir;
- } else if ( position.y > 1.0 ) {
- offset += dir;
- }
- // adjust for linewidth
- offset *= linewidth;
- // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
- offset /= resolution.y;
- // select end
- vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
- // back to clip space
- offset *= clip.w;
- clip.xy += offset;
- #endif
- gl_Position = clip;
- vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }
- `,fragmentShader:`
- uniform vec3 diffuse;
- uniform float opacity;
- uniform float linewidth;
- #ifdef USE_DASH
- uniform float dashOffset;
- uniform float dashSize;
- uniform float gapSize;
- #endif
- varying float vLineDistance;
- #ifdef WORLD_UNITS
- varying vec4 worldPos;
- varying vec3 worldStart;
- varying vec3 worldEnd;
- #ifdef USE_DASH
- varying vec2 vUv;
- #endif
- #else
- varying vec2 vUv;
- #endif
- #include <common>
- #include <color_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
- float mua;
- float mub;
- vec3 p13 = p1 - p3;
- vec3 p43 = p4 - p3;
- vec3 p21 = p2 - p1;
- float d1343 = dot( p13, p43 );
- float d4321 = dot( p43, p21 );
- float d1321 = dot( p13, p21 );
- float d4343 = dot( p43, p43 );
- float d2121 = dot( p21, p21 );
- float denom = d2121 * d4343 - d4321 * d4321;
- float numer = d1343 * d4321 - d1321 * d4343;
- mua = numer / denom;
- mua = clamp( mua, 0.0, 1.0 );
- mub = ( d1343 + d4321 * ( mua ) ) / d4343;
- mub = clamp( mub, 0.0, 1.0 );
- return vec2( mua, mub );
- }
- void main() {
- #include <clipping_planes_fragment>
- #ifdef USE_DASH
- if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
- if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
- #endif
- float alpha = opacity;
- #ifdef WORLD_UNITS
- // Find the closest points on the view ray and the line segment
- vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
- vec3 lineDir = worldEnd - worldStart;
- vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );
- vec3 p1 = worldStart + lineDir * params.x;
- vec3 p2 = rayEnd * params.y;
- vec3 delta = p1 - p2;
- float len = length( delta );
- float norm = len / linewidth;
- #ifndef USE_DASH
- #ifdef USE_ALPHA_TO_COVERAGE
- float dnorm = fwidth( norm );
- alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
- #else
- if ( norm > 0.5 ) {
- discard;
- }
- #endif
- #endif
- #else
- #ifdef USE_ALPHA_TO_COVERAGE
- // artifacts appear on some hardware if a derivative is taken within a conditional
- float a = vUv.x;
- float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
- float len2 = a * a + b * b;
- float dlen = fwidth( len2 );
- if ( abs( vUv.y ) > 1.0 ) {
- alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );
- }
- #else
- if ( abs( vUv.y ) > 1.0 ) {
- float a = vUv.x;
- float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
- float len2 = a * a + b * b;
- if ( len2 > 1.0 ) discard;
- }
- #endif
- #endif
- vec4 diffuseColor = vec4( diffuse, alpha );
- #include <logdepthbuf_fragment>
- #include <color_fragment>
- gl_FragColor = vec4( diffuseColor.rgb, alpha );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }
- `};class pte extends rh{constructor(e){super({type:"LineMaterial",uniforms:bL.clone(xs.line.uniforms),vertexShader:xs.line.vertexShader,fragmentShader:xs.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 h9=new ko,C1=new Be;class gte extends v6e{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 PR(n,6,1);return this.setAttribute("instanceStart",new Pd(r,3,0)),this.setAttribute("instanceEnd",new Pd(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 PR(n,6,1);return this.setAttribute("instanceColorStart",new Pd(r,3,0)),this.setAttribute("instanceColorEnd",new Pd(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 f6e(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),h9.setFromBufferAttribute(n),this.boundingBox.union(h9))}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++)C1.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(C1)),C1.fromBufferAttribute(n,a),i=Math.max(i,r.distanceToSquared(C1));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 f9=new Be,m9=new Be,fa=new xr,ma=new xr,Cl=new xr,dj=new Be,hj=new Tr,pa=new _6e,p9=new Be,k1=new ko,j1=new Xl,kl=new xr;let jl,af;function g9(t,e,n){return kl.set(0,0,-e,1).applyMatrix4(t.projectionMatrix),kl.multiplyScalar(1/kl.w),kl.x=af/n.width,kl.y=af/n.height,kl.applyMatrix4(t.projectionMatrixInverse),kl.multiplyScalar(1/kl.w),Math.abs(Math.max(kl.x,kl.y))}class I6e extends rl{constructor(e=new gte,n=new pte({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)f9.fromBufferAttribute(n,o),m9.fromBufferAttribute(r,o),i[l]=l===0?0:i[l-1],i[l+1]=i[l]+f9.distanceTo(m9);const a=new PR(i,2,1);return e.setAttribute("instanceDistanceStart",new Pd(a,1,0)),e.setAttribute("instanceDistanceEnd",new Pd(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;af=c.linewidth+a,l.boundingSphere===null&&l.computeBoundingSphere(),j1.copy(l.boundingSphere).applyMatrix4(o),r?u=.5*af:u=g9(i,Math.max(i.near,j1.distanceToPoint(jl.origin)),c.resolution),j1.radius+=u,jl.intersectsSphere(j1)!==!1&&(l.boundingBox===null&&l.computeBoundingBox(),k1.copy(l.boundingBox).applyMatrix4(o),r?d=.5*af:d=g9(i,Math.max(i.near,k1.distanceToPoint(jl.origin)),c.resolution),k1.expandByScalar(d),jl.intersectsBox(k1)!==!1&&(r?(function(f,m){const p=f.matrixWorld,b=f.geometry,y=b.attributes.instanceStart,x=b.attributes.instanceEnd;for(let v=0,S=Math.min(b.instanceCount,y.count);v<S;v++){pa.start.fromBufferAttribute(y,v),pa.end.fromBufferAttribute(x,v),pa.applyMatrix4(p);const M=new Be,E=new Be;jl.distanceSqToSegment(pa.start,pa.end,E,M),E.distanceTo(M)<.5*af&&m.push({point:E,pointOnLine:M,distance:jl.origin.distanceTo(E),object:f,face:null,faceIndex:v,uv:null,uv1:null})}})(this,n):(function(f,m,p){const b=m.projectionMatrix,y=f.material.resolution,x=f.matrixWorld,v=f.geometry,S=v.attributes.instanceStart,M=v.attributes.instanceEnd,E=Math.min(v.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*=y.x/2,Cl.y*=y.y/2,Cl.z=0,dj.copy(Cl),hj.multiplyMatrices(m.matrixWorldInverse,x);for(let k=0,T=E;k<T;k++){if(fa.fromBufferAttribute(S,k),ma.fromBufferAttribute(M,k),fa.w=1,ma.w=1,fa.applyMatrix4(hj),ma.applyMatrix4(hj),fa.z>A&&ma.z>A)continue;if(fa.z>A){const O=fa.z-ma.z,q=(fa.z-A)/O;fa.lerp(ma,q)}else if(ma.z>A){const O=ma.z-fa.z,q=(ma.z-A)/O;ma.lerp(fa,q)}fa.applyMatrix4(b),ma.applyMatrix4(b),fa.multiplyScalar(1/fa.w),ma.multiplyScalar(1/ma.w),fa.x*=y.x/2,fa.y*=y.y/2,ma.x*=y.x/2,ma.y*=y.y/2,pa.start.copy(fa),pa.start.z=0,pa.end.copy(ma),pa.end.z=0;const D=pa.closestPointToPointParameter(dj,!0);pa.at(D,p9);const C=Kee.lerp(fa.z,ma.z,D),R=C>=-1&&C<=1,U=dj.distanceTo(p9)<.5*af;if(R&&U){pa.start.fromBufferAttribute(S,k),pa.end.fromBufferAttribute(M,k),pa.start.applyMatrix4(x),pa.end.applyMatrix4(x);const O=new Be,q=new Be;jl.distanceSqToSegment(pa.start,pa.end,q,O),p.push({point:q,pointOnLine:O,distance:jl.origin.distanceTo(q),object:f,face:null,faceIndex:k,uv:null,uv1:null})}}})(this,i,n)))}}class F6e extends bE{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 qy({vertexColors:!0,toneMapped:!1}))}}function U6e(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 bE(i,new p6e({color:new rn(r),dashSize:3,gapSize:1}));return a.computeLineDistances(),a}var o0=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 o0.Panel("FPS","#0ff","#002")),c=n(new o0.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var u=n(new o0.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}};o0.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,y=document.createElement("canvas");y.width=l,y.height=c,y.style.cssText="width:80px;height:48px";var x=y.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:y,update:function(v,S){r=Math.min(r,v),i=Math.max(i,v),x.fillStyle=n,x.globalAlpha=1,x.fillRect(0,0,l,m),x.fillStyle=e,x.fillText(a(v)+" "+t+" ("+a(r)+"-"+a(i)+")",u,d),x.drawImage(y,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-v/S)*b))}}};var z6e=o0;class x9{constructor(e,n){this.openFolders=[],this.watchedObject=e,this.options=n,this.gui=new QS,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 QS,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 B6e 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,y,x]=(function(v){const S=e[v],M=new Be,E=new Be,A=new Be,k=new Be;M.copy(S).sub(e[v-1]||S).normalize().add((e[v+1]||S).clone().sub(S).normalize()).normalize();let T=Number.MAX_VALUE;const D=Math.abs(M.x),C=Math.abs(M.y),R=Math.abs(M.z);return D<=T&&(T=D,E.set(1,0,0)),C<=T&&(T=C,E.set(0,1,0)),R<=T&&E.set(0,0,1),k.crossVectors(M,E).normalize(),E.crossVectors(M,k),A.crossVectors(M,E),[S,E,A]})(p);for(let v=0;v<=i;v++){const S=v/i*Math.PI*2,M=Math.sin(S),E=-Math.cos(S);o.x=E*y.x+M*x.x,o.y=E*y.y+M*x.y,o.z=E*y.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 y=(i+1)*(p-1)+(b-1),x=(i+1)*p+(b-1),v=(i+1)*p+b,S=(i+1)*(p-1)+b;f.push(y,x,S),f.push(x,v,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 l0{static get initial(){const e=new l0;return Object.assign(e,{x:0,y:0,z:0,r:0,e:0,i:0,j:0,t:0}),e}}const fj={h:0,s:0,l:0};class cg{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=l0.initial,this.beyondFirstMove=!1,this.disposables=[],this._extrusionColor=cg.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 r6e,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 z6e: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"+fE),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 jR({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 jR({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 _L(this._backgroundColor,m,f),this.resize(),this.controls=new L6e(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?cg.defaultExtrusionColor:this._extrusionColor instanceof rn?this._extrusionColor:(e=this._extrusionColor[this.state.t])!==null&&e!==void 0?e:cg.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 w6e(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 y6e(13421772,.3*Math.PI),n=new b6e(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 Wb;return n.name=e,n.quaternion.setFromEuler(new Gy(-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=l0.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 cj(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 y=((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)&&(y&&this.renderExtrusion||!y&&this.renderTravel)&&(m.gcode=="g2"||m.gcode=="g3"||m.gcode=="g02"||m.gcode=="g03"?this.addArcSegment(f,this.state,b,y,m.gcode=="g2"||m.gcode=="g02"):this.addLineSegment(f,this.state,b,y))}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(fj),a=new rn().setHSL(fj.h,fj.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 F6e(this.buildVolume.x,10,this.buildVolume.y,10));const e=U6e(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=l0.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,y=r.j;if(p){const W=d-l,X=f-c,G=Math.sqrt(Math.pow(W/2,2)+Math.pow(X/2,2));p=Math.max(p,G);const Z=Math.pow(W,2)+Math.pow(X,2),te=Math.pow(p,2)-Z/4;let ee=Math.sqrt(te/Z);(a&&p<0||!a&&p>0)&&(ee=-ee),b=W/2+X*ee,y=X/2-W*ee}const x=l==d&&c==f,v=l+b,S=c+y,M=Math.sqrt(b*b+y*y),E=Math.atan2(-y,-b),A=Math.atan2(f-S,d-v);let k;x?k=2*Math.PI:(k=a?E-A:A-E,k<0&&(k+=2*Math.PI));let T=M*k/1.8;this.inches&&(T*=25),T<1&&(T=1);let D=k/T;D*=a?-1:1;const C=[];C.push({x:l,y:c,z:u});const R=(u-m)/T;let U=l,O=c,q=u,j=E;for(let W=0;W<T-1;W++)j+=D,U=v+M*Math.cos(j),O=S+M*Math.sin(j),q+=R,C.push({x:U,y:O,z:q});C.push({x:r.x,y:r.y,z:r.z});for(let W=0;W<C.length-1;W++)o.push(C[W].x,C[W].y,C[W].z,C[W+1].x,C[W+1].y,C[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 qy({color:n});this.disposables.push(a);const o=new bE(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 B6e(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 gte;this.disposables.push(i);const a=new pte({color:n,linewidth:this.lineWidth/(1e3*window.devicePixelRatio)});this.disposables.push(a),i.setPositions(e);const o=new I6e(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=>cj(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 m6e({color:e,wireframe:this._wireframe});this.disposables.push(i);const a=r.reduce(((l,c)=>3*c.attributes.position.count+l),0),o=new d6e(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 cj(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(`
- `),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 x9(this):typeof this.devMode=="object"&&(this.devGui=new x9(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())}}cg.defaultExtrusionColor=new rn("hotpink");function $6e({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,y]=w.useState(0),[x,v]=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 T=n&&n.length>1,D=n?.[0]||"#00ae42",C=new cg({canvas:A,buildVolume:e,backgroundColor:1710618,extrusionColor:T?n:D,disableGradient:!0,lineHeight:.2,lineWidth:2,renderTravel:!1,renderExtrusion:!0});a.current=C,fetch(t).then(async U=>{if(!U.ok)throw U.status===404&&(await U.json().catch(()=>({}))).detail?.includes("sliced")?(p(!0),new Error("not_sliced")):new Error("Failed to load G-code");return U.text()}).then(U=>{const O=new Set,q=/^(\s*)T(\d+)(\s*;.*)?$/gim;let j;for(;(j=q.exec(U))!==null;){const ee=parseInt(j[2],10);ee<=15&&O.add(ee)}const W=new Map,X=Array.from(O).sort((ee,z)=>ee-z);X.forEach((ee,z)=>{W.set(ee,z%8)});const G=[];X.forEach((ee,z)=>{const V=n?.[ee]||"#00ae42";G[z%8]=V});const Z=U.split(`
- `).map(ee=>{const z=ee.match(/^(\s*)T(\d+)(\s*;.*)?$/i);if(z){const V=parseInt(z[2],10);if(V>15)return`; FILTERED: ${ee.trim()}`;const ne=W.get(V)??0;return`${z[1]}T${ne}${z[3]||""}`}return ee}).join(`
- `);G.length>0&&(C.extrusionColor=G),C.processGCode(Z);const te=C.layers?.length||0;v(te),y(te),C.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));y(k),o.current&&cancelAnimationFrame(o.current),o.current=requestAnimationFrame(()=>{a.current&&(a.current.endLayer=k,a.current.render())})},[x]),E=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(Wde,{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(ll,{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(Ff,{className:"w-4 h-4"})}),s.jsx("input",{type:"range",min:1,max:x,value:b,onChange:E,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(Qs,{className:"w-4 h-4"})}),s.jsxs("span",{className:"text-sm text-bambu-gray min-w-[80px] text-right",children:[b," / ",x]})]})})]})}function xte({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(()=>{fe.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}${fe.getArchiveForSlicer(t,d)}`;Xc(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(Ht,{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(vde,{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(UIe,{url:a.has_source?fe.getSource3mfDownloadUrl(t):fe.getArchiveDownload(t),buildVolume:a.build_volume,filamentColors:a.filament_colors,className:"w-full h-full"}):r==="gcode"&&a?s.jsx($6e,{gcodeUrl:fe.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 b9={"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 H6e(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 Lg(t){const e=t.replace("#","").toLowerCase().substring(0,6);return b9[e]?b9[e]:H6e(t)}function JS(t){return t?`#${t.replace("#","").substring(0,6)}`:"#808080"}function ta(t){return t?t.replace("#","").toLowerCase().substring(0,6):""}function ih(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 bte(t,e,n,r){const i=String.fromCharCode(65+(t>=128?t-128:t));return n?`HT-${i}`:`AMS-${i} Slot ${e+1}`}function yte(t,e,n){return t*4+e}function V6e(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 G6e(){const t=new Date;return t.setMinutes(t.getMinutes()+1),t.toISOString().slice(0,16)}function y9(t){if(!t)return!1;const e=Date.now()+4320*60*60*1e3;return new Date(t).getTime()>e}function ML(t){const e=[];if(t?.ams?.forEach(n=>{const r=n.tray.length===1;n.tray.forEach(i=>{if(i.tray_type){const a=JS(i.tray_color);e.push({type:i.tray_type,color:a,colorName:Lg(a),amsId:n.id,trayId:i.id,isHt:r,isExternal:!1,label:bte(n.id,i.id,r),globalTrayId:yte(n.id,i.id)})}})}),t?.vt_tray?.tray_type){const n=JS(t.vt_tray.tray_color);e.push({type:t.vt_tray.tray_type,color:n,colorName:Lg(n),amsId:-1,trayId:0,isHt:!1,isExternal:!0,label:"External",globalTrayId:254})}return e}function v9(t,e){if(!t?.filaments||t.filaments.length===0)return;const n=ML(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()&&ih(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 W6e(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=JS(i.tray_color);e.push({type:i.tray_type,color:a,colorName:Lg(a),amsId:n.id,trayId:i.id,isHt:r,isExternal:!1,label:bte(n.id,i.id,r),globalTrayId:yte(n.id,i.id)})}})}),t?.vt_tray?.tray_type){const n=JS(t.vt_tray.tray_color);e.push({type:t.vt_tray.tray_type,color:n,colorName:Lg(n),amsId:-1,trayId:0,isHt:!1,isExternal:!0,label:"External",globalTrayId:254})}return e},[t])}function vte(t,e,n){const r=W6e(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],E=r.find(A=>A.globalTrayId===M);if(E){const A=E.type?.toUpperCase()===u.type?.toUpperCase(),k=ta(E.color)===ta(u.color)||ih(E.color,u.color);let T;return A&&k?T="match":A?T="type_only":T="mismatch",{...u,loaded:E,hasFilament:!0,typeMatch:A,colorMatch:k,status:T,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()&&ih(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 y=!!b,x=y,v=!!f||!!m;let S;return f||m?S="match":p?S="type_only":S="mismatch",{...u,loaded:b,hasFilament:y,typeMatch:x,colorMatch:v,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 q6e(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 y=n[d],x=e.find(v=>v.globalTrayId===y);if(x){const v=x.type?.toUpperCase()===u.type?.toUpperCase(),S=ta(x.color)===ta(u.color)||ih(x.color,u.color);v&&S?r++:v?i++:a++;continue}}const f=e.find(y=>!o.has(y.globalTrayId)&&y.type?.toUpperCase()===u.type?.toUpperCase()&&ta(y.color)===ta(u.color)),m=f?void 0:e.find(y=>!o.has(y.globalTrayId)&&y.type?.toUpperCase()===u.type?.toUpperCase()&&ih(y.color,u.color)),p=f||m?void 0:e.find(y=>!o.has(y.globalTrayId)&&y.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 K6e(t,e,n){if(!t?.filaments||t.filaments.length===0)return;const r=ML(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()&&ih(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 _9={useDefault:!0,manualMappings:{},autoConfigured:!1};function X6e(t,e,n,r,i,a){const o=xue({queries:t.map(b=>({queryKey:["printer-status",b],queryFn:()=>fe.getPrinterStatus(b),enabled:t.length>0,staleTime:5e3}))}),l=w.useMemo(()=>t.map((b,y)=>{const x=o[y],v=x?.data,M=e?.find(R=>R.id===b)?.name||`Printer ${b}`,E=ML(v),A=i[b]||_9,k=v9(n,v),T=A.useDefault?r:A.manualMappings,D=K6e(n,v,T),C=q6e(n?.filaments,E,T);return{printerId:b,printerName:M,status:v,isLoading:x?.isLoading??!1,loadedFilaments:E,autoMapping:k,finalMapping:D,matchStatus:C.status,exactMatches:C.exactMatches,typeOnlyMatches:C.typeOnlyMatches,missingTypes:C.missingTypes,totalSlots:C.totalSlots,config:A}}),[t,o,e,n,i,r]),c=o.some(b=>b.isLoading),u=(b,y)=>{a(x=>({...x,[b]:{...x[b]||_9,...y}}))},d=b=>{const y=l.find(S=>S.printerId===b);if(!y||!y.status||!n?.filaments)return;const x=v9(n,y.status);if(!x)return;const v={};x.forEach((S,M)=>{S!==-1&&(v[M+1]=S)}),u(b,{useDefault:!1,manualMappings:v,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 Y6e({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 fe.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(y=>y.globalTrayId===f),p=!0;else{const y=new Set(Object.values(t.config.manualMappings)),x=t.loadedFilaments.find(M=>!y.has(M.globalTrayId)&&M.type?.toUpperCase()===u.type?.toUpperCase()&&ta(M.color)===ta(u.color)),v=x?void 0:t.loadedFilaments.find(M=>!y.has(M.globalTrayId)&&M.type?.toUpperCase()===u.type?.toUpperCase()&&ih(M.color,u.color)),S=x||v?void 0:t.loadedFilaments.find(M=>!y.has(M.globalTrayId)&&M.type?.toUpperCase()===u.type?.toUpperCase());m=x??v??S}let b="mismatch";if(m){const y=m.type?.toUpperCase()===u.type?.toUpperCase(),x=ta(m.color)===ta(u.color)||ih(m.color,u.color);y&&x?b="match":y&&(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} - ${Lg(u.color)}`,children:s.jsx(mP,{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(ts,{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 Q6e({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(E=>E!==M)):n([...e,M]):n([M])},p=()=>{n(d.map(M=>M.id))},b=()=>{n([])},y=(M,E,A)=>{A.stopPropagation(),!(!c||!u)&&(E?c(M):u(M,{useDefault:!0,manualMappings:{},autoConfigured:!1}))},x=M=>e.includes(M),v=e.length,S=M=>o?.find(E=>E.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:v===0?"Select printers":`${v} printer${v!==1?"s":""} selected`}),s.jsxs("div",{className:"flex gap-2",children:[v<d.length&&s.jsx("button",{type:"button",onClick:p,className:"text-bambu-green hover:text-bambu-green/80 transition-colors",children:"Select all"}),v>0&&s.jsx("button",{type:"button",onClick:b,className:"text-bambu-gray hover:text-white transition-colors",children:"Clear"})]})]}),d.map(M=>{const E=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 ${E?"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 ${E?"bg-bambu-green/20":"bg-bambu-dark-tertiary"}`,children:s.jsx(Wr,{className:`w-5 h-5 ${E?"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 ${E?"bg-bambu-green border-bambu-green":"border-bambu-gray/50"}`,children:E&&s.jsx(ts,{className:"w-3 h-3 text-white"})})]}),E&&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:T=>T.stopPropagation(),children:[s.jsx("input",{type:"checkbox",checked:k,onChange:T=>y(M.id,T.target.checked,T),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:T=>{T.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(Cme,{className:"w-3 h-3"}),"Auto"]})]}),k&&s.jsx(Y6e,{printerResult:A,filamentReqs:l.filaments,onUpdateConfig:T=>u(M.id,T)})]})]},M.id)}),v===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(ll,{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(ll,{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?` • ${V6e(i.print_time_seconds)}`:""]})]}),n===i.index&&s.jsx(ts,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]},i.index))})]})}function J6e({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:()=>fe.getPrinterStatus(t),enabled:!!t}),{loadedFilaments:f,filamentComparison:m,hasTypeMismatch:p,hasColorMismatch:b}=vte(e,d,n);if(!(e?.filaments&&e.filaments.length>0)||!d)return null;const x=p?"#f97316":b?"#facc15":"#00ae42",v=(M,E)=>{if(M>0)if(E===""){const A={...n};delete A[M],r(A)}else r({...n,[M]:parseInt(E,10)})},S=async()=>{l(!0);try{await fe.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(mP,{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(hu,{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,E)=>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} - ${Lg(M.color)}`,children:s.jsx(mP,{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=>v(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(ts,{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"})})]},E)),p&&s.jsx("p",{className:"text-xs text-orange-400 mt-2",children:"Required filament type not found in printer."})]})]})}const e$e=[{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 t$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(hN,{className:"w-4 h-4"}),s.jsx("span",{children:"Print Options"}),r?s.jsx(hu,{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:e$e.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 n$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(mK,{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:G6e(),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(Su,{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 Rp={bed_levelling:!0,flow_cali:!1,vibration_cali:!0,layer_inspect:!1,timelapse:!1},r$e={scheduleType:"asap",scheduledTime:"",requirePreviousSuccess:!1,autoOffAfter:!1};function ah({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,y]=w.useState(()=>t==="edit-queue-item"&&i?{bed_levelling:i.bed_levelling??Rp.bed_levelling,flow_cali:i.flow_cali??Rp.flow_cali,vibration_cali:i.vibration_cali??Rp.vibration_cali,layer_inspect:i.layer_inspect??Rp.layer_inspect,timelapse:i.timelapse??Rp.timelapse}:Rp),[x,v]=w.useState(()=>{if(t==="edit-queue-item"&&i){let $="asap";i.manual_start?$="manual":i.scheduled_time&&!y9(i.scheduled_time)&&($="scheduled");let L="";return i.scheduled_time&&!y9(i.scheduled_time)&&(L=new Date(i.scheduled_time).toISOString().slice(0,16)),{scheduleType:$,scheduledTime:L,requirePreviousSuccess:i.require_previous_success,autoOffAfter:i.auto_off_after}}return r$e}),[S,M]=w.useState(()=>{if(t==="edit-queue-item"&&i?.ams_mapping&&Array.isArray(i.ams_mapping)){const $={};return i.ams_mapping.forEach((L,Y)=>{L!==-1&&($[Y+1]=L)}),$}return{}}),[E,A]=w.useState({}),[k]=w.useState(()=>t==="edit-queue-item"&&i?.printer_id?[i.printer_id]:[]),[T]=w.useState(()=>t==="edit-queue-item"&&i?i.plate_id:null),[D,C]=w.useState(!1),[R,U]=w.useState({current:0,total:0}),[O,q]=w.useState(new Set),j=d.length,W=d.length>0?d[0]:null,{data:X}=ft({queryKey:["settings"],queryFn:fe.getSettings}),{data:G,isLoading:Z}=ft({queryKey:["printers"],queryFn:fe.getPrinters}),{data:te,isError:ee}=ft({queryKey:["archive-plates",e],queryFn:()=>fe.getArchivePlates(e),enabled:!!e&&!u,retry:!1}),{data:z}=ft({queryKey:["library-file-plates",n],queryFn:()=>fe.getLibraryFilePlates(n),enabled:u&&!!n}),V=u?z:te,{data:ne,isError:ie}=ft({queryKey:["archive-filaments",e,m],queryFn:()=>fe.getArchiveFilamentRequirements(e,m??void 0),enabled:!!e&&!u&&(m!==null||!V?.is_multi_plate),retry:!1}),{data:he}=ft({queryKey:["library-file-filaments",n,m],queryFn:()=>fe.getLibraryFileFilamentRequirements(n,m??void 0),enabled:u&&!!n&&(m!==null||!V?.is_multi_plate)}),me=!u&&(ee||ie),oe=u?he:ne,{data:Ae}=ft({queryKey:["printer-status",W],queryFn:()=>fe.getPrinterStatus(W),enabled:!!W}),{amsMapping:ge}=vte(oe,Ae,S),Ne=X6e(d,G,oe,S,E,A);w.useEffect(()=>{V?.plates?.length===1&&!m&&p(V.plates[0].index)},[V,m]),w.useEffect(()=>{if(t==="edit-queue-item")return;const $=G?.filter(L=>L.is_active)||[];$.length===1&&d.length===0&&f([$[0].id])},[t,G,d.length]),w.useEffect(()=>{t==="edit-queue-item"?(JSON.stringify(d.sort())!==JSON.stringify(k.sort())||m!==T)&&(M({}),A({}),q(new Set)):(M({}),A({}),q(new Set))},[t,d,m,k,T]),w.useEffect(()=>{if(!X?.per_printer_mapping_expanded||d.length<=1)return;const $=d.filter(L=>{if(O.has(L))return!1;const Y=Ne.printerResults.find(pe=>pe.printerId===L);return Y&&Y.status&&!Y.isLoading});$.length>0&&(q(L=>{const Y=new Set(L);return $.forEach(pe=>Y.add(pe)),Y}),$.forEach(L=>{Ne.autoConfigurePrinter(L)}))},[X?.per_printer_mapping_expanded,d,O,Ne]),w.useEffect(()=>{const $=L=>{L.key==="Escape"&&!D&&a()};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[a,D]);const _e=V?.is_multi_plate??!1,le=V?.plates??[],He=pt({mutationFn:$=>fe.addToQueue($)}),H=pt({mutationFn:$=>fe.updateQueueItem(i.id,$),onSuccess:()=>{l.invalidateQueries({queryKey:["queue"]}),c("Queue item updated"),o?.(),a()},onError:$=>{c($.message||"Failed to update queue item","error")}}),J=async $=>{if($?.preventDefault(),d.length===0){c("Please select at least one printer","error");return}C(!0),U({current:0,total:d.length});const L={success:0,failed:0,errors:[]},Y=Se=>{if(d.length>1){const ae=E[Se];if(ae&&!ae.useDefault)return Ne.getFinalMapping(Se)}return ge},pe=Se=>({printer_id:Se,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(Se),plate_id:m,scheduled_time:x.scheduleType==="scheduled"&&x.scheduledTime?new Date(x.scheduledTime).toISOString():void 0,...b});for(let Se=0;Se<d.length;Se++){const ae=d[Se];U({current:Se+1,total:d.length});try{if(t==="reprint"){const je=Y(ae);u?await fe.printLibraryFile(n,ae,{ams_mapping:je,...b}):await fe.reprintArchive(e,ae,{plate_id:m??void 0,ams_mapping:je,...b})}else if(t==="edit-queue-item"&&Se===0){const je=Y(ae),De={printer_id:ae,require_previous_success:x.requirePreviousSuccess,auto_off_after:x.autoOffAfter,manual_start:x.scheduleType==="manual",ams_mapping:je,plate_id:m,scheduled_time:x.scheduleType==="scheduled"&&x.scheduledTime?new Date(x.scheduledTime).toISOString():null,...b};await H.mutateAsync(De)}else await He.mutateAsync(pe(ae));L.success++}catch(je){L.failed++;const De=G?.find(Xe=>Xe.id===ae)?.name||`Printer ${ae}`;L.errors.push(`${De}: ${je.message}`)}}if(C(!1),L.failed===0){const Se=t==="reprint"?"sent to":t==="edit-queue-item"?"updated/queued for":"queued for";L.success===1?c(t==="edit-queue-item"?"Queue item updated":`Print ${Se} printer`):c(`Print ${Se} ${L.success} printers`),l.invalidateQueries({queryKey:["queue"]}),o?.(),a()}else L.success===0?c(`Failed: ${L.errors[0]}`,"error"):(c(`${L.success} succeeded, ${L.failed} failed`,"error"),l.invalidateQueries({queryKey:["queue"]}))},K=D||H.isPending,B=w.useMemo(()=>!(K||d.length===0||!u&&_e&&!m),[d.length,_e,m,K,u]),ce=(()=>{const $=d.length;return t==="reprint"?{title:u?"Print":"Re-print",icon:Wr,submitText:$>1?`Print to ${$} Printers`:"Print",submitIcon:Wr,loadingText:R.total>1?`Sending ${R.current}/${R.total}...`:"Sending..."}:t==="add-to-queue"?{title:"Schedule Print",icon:si,submitText:$>1?`Queue to ${$} Printers`:"Add to Queue",submitIcon:si,loadingText:R.total>1?`Adding ${R.current}/${R.total}...`:"Adding..."}:{title:"Edit Queue Item",icon:sa,submitText:"Save",submitIcon:sa,loadingText:R.total>1?`Saving ${R.current}/${R.total}...`:"Saving..."}})(),Ee=ce.icon,Ie=ce.submitIcon,ue=W&&(u||(_e?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(Et,{className:"w-full max-w-lg max-h-[90vh] overflow-y-auto",onClick:$=>$.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(Ht,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:J,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:le,isMultiPlate:_e,selectedPlate:m,onSelect:p}),s.jsx(Q6e,{printers:G||[],selectedPrinterIds:d,onMultiSelect:f,isLoading:Z,allowMultiple:!0,showInactive:t==="edit-queue-item",printerMappingResults:Ne.printerResults,filamentReqs:oe,onAutoConfigurePrinter:Ne.autoConfigurePrinter,onUpdatePrinterConfig:Ne.updatePrinterConfig}),me&&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."})]}),ue&&!me&&d.length===1&&s.jsx(J6e,{printerId:W,filamentReqs:oe,manualMappings:S,onManualMappingChange:M,defaultExpanded:X?.per_printer_mapping_expanded??!1}),(t==="reprint"||j>0)&&s.jsx(t$e,{options:b,onChange:y}),t!=="reprint"&&s.jsx(n$e,{options:x,onChange:v}),H.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:H.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:!B,className:"flex-1",children:K?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 i$e({onClose:t,initialFiles:e}){const n=ln(),{showToast:r}=Yn(),i=w.useRef(null),[a,o]=w.useState(()=>e?.filter(T=>T.name.endsWith(".3mf")).map(T=>({file:T,status:"pending"}))||[]),[l,c]=w.useState(!1),[u,d]=w.useState(),[f,m]=w.useState(null);w.useEffect(()=>{const T=D=>{D.key==="Escape"&&t()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[t]);const{data:p}=ft({queryKey:["printers"],queryFn:fe.getPrinters}),b=pt({mutationFn:T=>fe.uploadArchivesBulk(T,u),onSuccess:T=>{m(T),n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["archiveStats"]}),o(D=>D.map(C=>{const R=T.results.find(O=>O.filename===C.file.name),U=T.errors.find(O=>O.filename===C.file.name);return R?{...C,status:"success",archiveId:R.id}:U?{...C,status:"error",error:U.error}:C})),T.failed===0?r(`${T.uploaded} file${T.uploaded!==1?"s":""} uploaded`):T.uploaded===0?r(`Failed to upload ${T.failed} file${T.failed!==1?"s":""}`,"error"):r(`${T.uploaded} uploaded, ${T.failed} failed`,"warning")},onError:()=>{o(T=>T.map(D=>({...D,status:"error",error:"Upload failed"}))),r("Upload failed","error")}}),y=w.useCallback(T=>{T.preventDefault(),c(!0)},[]),x=w.useCallback(T=>{T.preventDefault(),c(!1)},[]),v=w.useCallback(T=>{T.preventDefault(),c(!1);const D=Array.from(T.dataTransfer.files).filter(C=>C.name.endsWith(".3mf"));D.length>0&&o(C=>[...C,...D.map(R=>({file:R,status:"pending"}))])},[]),S=w.useCallback(T=>{const D=Array.from(T.target.files||[]).filter(C=>C.name.endsWith(".3mf"));D.length>0&&o(C=>[...C,...D.map(R=>({file:R,status:"pending"}))]),i.current&&(i.current.value="")},[]),M=w.useCallback(T=>{o(D=>D.filter((C,R)=>R!==T))},[]),E=()=>{if(a.length===0)return;const T=a.filter(D=>D.status==="pending");T.length!==0&&(o(D=>D.map(C=>C.status==="pending"?{...C,status:"uploading"}:C)),b.mutate(T.map(D=>D.file)))},A=a.filter(T=>T.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(Et,{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(Ht,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"p-4",children:s.jsxs("div",{className:`border-2 border-dashed rounded-lg p-8 text-center transition-colors ${l?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,onDragOver:y,onDragLeave:x,onDrop:v,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:T=>d(T.target.value?Number(T.target.value):void 0),disabled:k,children:[s.jsx("option",{value:"",children:"No printer"}),p?.map(T=>s.jsx("option",{value:T.id,children:T.name},T.id))]})]}),a.length>0&&s.jsx("div",{className:"px-4 pb-4 max-h-60 overflow-y-auto",children:s.jsx("div",{className:"space-y-2",children:a.map((T,D)=>s.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[s.jsx(rN,{className:"w-5 h-5 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"flex-1 text-white text-sm truncate",children:T.file.name}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:[(T.file.size/(1024*1024)).toFixed(1)," MB"]}),T.status==="pending"&&s.jsx("button",{onClick:()=>M(D),className:"text-bambu-gray hover:text-red-400 transition-colors",disabled:k,children:s.jsx(Ht,{className:"w-4 h-4"})}),T.status==="uploading"&&s.jsx(mt,{className:"w-4 h-4 text-bambu-green animate-spin"}),T.status==="success"&&s.jsx(Hn,{className:"w-4 h-4 text-bambu-green"}),T.status==="error"&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-xs text-red-400",children:T.error}),s.jsx(aa,{className:"w-4 h-4 text-red-400"})]})]},`${T.file.name}-${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:E,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 a$e=["Adhesion failure","Spaghetti / Detached","Layer shift","Clogged nozzle","Filament runout","Warping","Stringing","Under-extrusion","Power failure","User cancelled","Other"],s$e=[{value:"completed",label:"Completed"},{value:"failed",label:"Failed"},{value:"aborted",label:"Cancelled"},{value:"printing",label:"Printing"}];function _te({archive:t,onClose:e,existingTags:n=[]}){w.useEffect(()=>{const oe=Ae=>{Ae.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,y]=w.useState(t.failure_reason||""),[x,v]=w.useState(t.status),[S,M]=w.useState(t.quantity??1),[E,A]=w.useState(t.photos||[]),[k,T]=w.useState(t.external_url||""),[D,C]=w.useState(!1),[R,U]=w.useState(!1),O=w.useRef(null),q=w.useRef(null),j=w.useRef(null),{data:W}=ft({queryKey:["printers"],queryFn:fe.getPrinters}),{data:X}=ft({queryKey:["projects"],queryFn:()=>fe.getProjects()}),{data:G}=ft({queryKey:["archives"],queryFn:()=>fe.getArchives(void 0,1e3,0),enabled:n.length===0}),Z=n.length>0?n:[...new Set(G?.flatMap(oe=>oe.tags?.split(",").map(Ae=>Ae.trim())||[]).filter(Boolean)||[])].sort(),te=m.split(",").map(oe=>oe.trim()).filter(Boolean),ee=Z.filter(oe=>!te.includes(oe)),z=oe=>{if(!te.includes(oe)){const Ae=[...te,oe].join(", ");p(Ae)}j.current!==null&&clearTimeout(j.current),O.current?.focus()},V=oe=>{const Ae=te.filter(ge=>ge!==oe).join(", ");p(Ae)},ne=pt({mutationFn:oe=>fe.updateArchive(t.id,oe),onSuccess:()=>{r.invalidateQueries({queryKey:["archives"]}),r.invalidateQueries({queryKey:["projects"]}),e()}}),ie=async oe=>{const Ae=oe.target.files?.[0];if(Ae){C(!0);try{const ge=await fe.uploadArchivePhoto(t.id,Ae);A(ge.photos),r.invalidateQueries({queryKey:["archives"]})}catch(ge){console.error("Failed to upload photo:",ge)}finally{C(!1),q.current&&(q.current.value="")}}},he=async oe=>{try{const Ae=await fe.deleteArchivePhoto(t.id,oe);A(Ae.photos||[]),r.invalidateQueries({queryKey:["archives"]})}catch(Ae){console.error("Failed to delete photo:",Ae)}},me=oe=>{oe.preventDefault();const Ae={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&&(Ae.status=x),x==="failed"||x==="aborted"?Ae.failure_reason=b||void 0:(t.status==="failed"||t.status==="aborted")&&(Ae.failure_reason=null),ne.mutate(Ae)};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(Ht,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:me,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"}),X?.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(yhe,{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(Yg,{className:"w-4 h-4 inline mr-1"}),"External Link"]}),s.jsx("input",{type:"url",value:k,onChange:oe=>T(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"}),te.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:te.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(xg,{className:"w-3 h-3"}),oe,s.jsx("button",{type:"button",onClick:()=>V(oe),className:"ml-0.5 text-bambu-gray hover:text-white",children:s.jsx(Ht,{className:"w-3 h-3"})})]},oe))}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{ref:O,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:te.length>0?"Add more tags...":"Add tags..."}),R&&ee.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:ee.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=>{v(oe.target.value),oe.target.value==="completed"&&y("")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:s$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=>y(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..."}),a$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(mg,{className:"w-4 h-4 inline mr-1"}),"Photos of Printed Result"]}),s.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[E.map(oe=>s.jsxs("div",{className:"relative group",children:[s.jsx("img",{src:fe.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:ie,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:ne.isPending,className:"flex-1",children:[s.jsx(ys,{className:"w-4 h-4"}),ne.isPending?"Saving...":"Save"]})]})]})]})})}function wte({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()},v=M=>{M.key==="Escape"&&r()},S=()=>{r()};return document.addEventListener("mousedown",x),document.addEventListener("keydown",v),document.addEventListener("scroll",S,!0),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",v),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(),v=window.innerWidth,S=window.innerHeight,M=8;let E=t,A=e;t+x.width>v-M&&(E=Math.max(M,v-x.width-M)),E<M&&(E=M),e+x.height>S-M&&(A=Math.max(M,S-x.height-M)),A<M&&(A=M);const k=180,T=v-E-x.width,D=E;f(T<k&&D>k),u({x:E,y:A,visible:!0})}},[t,e]);const b=(x,v)=>{l.current&&(clearTimeout(l.current),l.current=null);const S=v.getBoundingClientRect(),M=window.innerHeight,E=300,T=M-S.top-8<E&&S.top>E;p(D=>({...D,[x]:T?"bottom":"top"})),o(x)},y=()=>{l.current=window.setTimeout(()=>{o(null)},150)};return s.jsx("div",{ref:i,className:"fixed z-50 min-w-[180px] max-w-[280px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1",style:{left:c.x,top:c.y,visibility:c.visible?"visible":"hidden"},children:n.map((x,v)=>{if(x.divider)return s.jsx("div",{className:"my-1 border-t border-bambu-dark-tertiary"},v);const S=x.submenu&&x.submenu.length>0;return s.jsxs("div",{className:"relative",onMouseEnter:M=>S&&b(v,M.currentTarget),onMouseLeave:()=>S&&y(),children:[s.jsxs("button",{onMouseEnter:M=>S&&b(v,M.currentTarget.parentElement),onClick:()=>{S?o(a===v?null:v):x.disabled||(x.onClick(),r())},disabled:x.disabled,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${x.disabled?"text-bambu-gray cursor-not-allowed":x.danger?"text-red-400 hover:bg-red-400/10":"text-white hover:bg-bambu-dark-tertiary"} ${S&&a===v?"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(Qs,{className:"w-4 h-4 text-bambu-gray"})]}),S&&a===v&&s.jsx("div",{className:`absolute min-w-[160px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 overflow-hidden max-h-[300px] overflow-y-auto z-[60] ${d?"right-full mr-1":"left-full ml-1"} ${m[v]==="bottom"?"bottom-0":"top-0"}`,onMouseEnter:()=>{l.current&&(clearTimeout(l.current),l.current=null)},onMouseLeave:()=>y(),children:x.submenu.map((M,E)=>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]},E))})]},v)})})}function o$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 y=x=>{x.key==="Escape"&&n()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[n]);const f=pt({mutationFn:async()=>{const y=Array.from(l);let x=0;for(const v of t)try{const S=await fe.getArchive(v),M=S.tags?S.tags.split(",").map(A=>A.trim()).filter(Boolean):[];let E;u==="add"?E=[...new Set([...M,...y])]:E=M.filter(A=>!l.has(A)),await fe.updateArchive(v,{tags:E.join(", ")}),x++}catch(S){throw console.error(`Failed to update archive ${v}:`,S),new Error(`Failed on archive ${v}: ${S instanceof Error?S.message:"Unknown error"}`)}return{count:x,mode:u,tags:y}},onSuccess:({count:y,mode:x,tags:v})=>{r.invalidateQueries({queryKey:["archives"]}),i(`${x==="add"?"Added":"Removed"} ${v.length} tag${v.length!==1?"s":""} ${x==="add"?"to":"from"} ${y} archive${y!==1?"s":""}`),n()},onError:y=>{i(y.message||"Failed to update tags","error")}}),m=y=>{c(x=>{const v=new Set(x);return v.has(y)?v.delete(y):v.add(y),v})},p=()=>{a.trim()&&!l.has(a.trim())&&(c(y=>new Set([...y,a.trim()])),o(""))},b=y=>{y.key==="Enter"&&(y.preventDefault(),p())};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(Et,{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(xg,{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(Ht,{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:y=>o(y.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(y=>s.jsx("button",{onClick:()=>m(y),className:`px-2 py-1 rounded text-sm transition-colors ${l.has(y)?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray-light hover:bg-bambu-dark"}`,children:y},y))})]}),l.size>0&&s.jsxs("div",{children:[s.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Tags to ",u==="add"?"add":"remove",":"]}),s.jsx("div",{className:"flex flex-wrap gap-2",children:Array.from(l).map(y=>s.jsxs("span",{className:`px-2 py-1 rounded text-sm flex items-center gap-1 ${u==="add"?"bg-green-500/20 text-green-400":"bg-red-500/20 text-red-400"}`,children:[y,s.jsx("button",{onClick:()=>m(y),className:"hover:opacity-70",children:s.jsx(Ht,{className:"w-3 h-3"})})]},y))})]})]}),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(xg,{className:"w-4 h-4"}),u==="add"?"Add Tags":"Remove Tags"]})})]})]})})})}function l$e({selectedIds:t,onClose:e}){const n=ln(),{showToast:r}=Yn(),{data:i,isLoading:a}=ft({queryKey:["projects"],queryFn:()=>fe.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 fe.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 fe.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(Et,{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(Ht,{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 c$e(t,e){return new Date(t,e+1,0).getDate()}function u$e(t,e){return new Date(t,e,1).getDay()}const d$e=["January","February","March","April","May","June","July","August","September","October","November","December"],h$e=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function f$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 T=Si(k.completed_at||k.created_at)||new Date,D=`${T.getFullYear()}-${String(T.getMonth()+1).padStart(2,"0")}-${String(T.getDate()).padStart(2,"0")}`,C=A.get(D)||[];C.push(k),A.set(D,C)}),A},[t]),p=c$e(o,i),b=u$e(o,i),y=()=>{i===0?(a(11),l(o-1)):a(i-1)},x=()=>{i===11?(a(0),l(o+1)):a(i+1)},v=()=>{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)||[]:[],E=A=>{A!==c&&f(null),u(A)};return s.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[s.jsxs("div",{className:"flex-1",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("button",{onClick:y,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(Ff,{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:[d$e[i]," ",o]}),s.jsx("button",{onClick:v,className:"px-2 py-1 text-xs bg-bambu-dark-tertiary hover:bg-bambu-green/20 text-bambu-gray hover:text-white rounded transition-colors",children:"Today"})]}),s.jsx("button",{onClick:x,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(Qs,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:h$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 T=`${o}-${String(i+1).padStart(2,"0")}-${String(A).padStart(2,"0")}`,D=m.get(T)||[],C=D.length>0,R=A===r.getDate()&&i===r.getMonth()&&o===r.getFullYear(),U=T===c,O=D.filter(j=>j.status==="completed").length,q=D.filter(j=>j.status==="failed").length;return s.jsxs("button",{onClick:()=>E(U?null:T),className:`aspect-square rounded-lg p-1 flex flex-col items-center justify-center transition-colors relative ${U?"bg-bambu-green text-white":R?"bg-bambu-green/20 text-white ring-2 ring-bambu-green":C?"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}),C&&s.jsxs("div",{className:"absolute bottom-1 left-1/2 -translate-x-1/2 flex items-center gap-1",children:[s.jsx("div",{className:`w-2 h-2 rounded-full ${q>0&&O===0?"bg-red-400":q>0?"bg-yellow-400":"bg-green-400"}`}),s.jsx("span",{className:"text-xs font-medium",children: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:fe.getArchiveThumbnail(A.id),alt:"",className:"w-12 h-12 rounded object-cover"}):s.jsx("div",{className:"w-12 h-12 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:s.jsx("span",{className:"text-xs text-bambu-gray",children:"3MF"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm text-white truncate",children:A.print_name||A.filename}),s.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[s.jsx("span",{className:A.status==="failed"?"text-red-400":"text-green-400",children:A.status==="failed"?"Failed":"Completed"}),A.filament_color&&s.jsx("div",{className:"flex gap-0.5",children:A.filament_color.split(",").map((T,D)=>s.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:T}},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 Ste({archiveId:t,archiveName:e,onClose:n}){const r=fe.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(Ht,{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 Mte({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(y=>Math.max(0,y-1)),b.key==="ArrowRight"&&o(y=>Math.min(n.length-1,y+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=fe.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(Ht,{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(Ff,{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(Qs,{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:fe.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 xa(t){this.content=t}xa.prototype={constructor:xa,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 xa(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 xa(n)},addToStart:function(t,e){return new xa([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new xa(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 xa(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=xa.from(t),t.size?new xa(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=xa.from(t),t.size?new xa(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=xa.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}};xa.from=function(t){if(t instanceof xa)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new xa(e)};function Nte(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=Nte(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 Nte(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Ete(this,e,n,r)}findIndex(e){if(e==0)return P1(0,e);if(e==this.size)return P1(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?P1(n+1,a):P1(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 mj={index:0,offset:0};function P1(t,e){return mj.index=t,mj.offset=e,mj}function eM(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(!eM(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!eM(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let wr=class DR{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&&eM(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 DR.none;if(e instanceof DR)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};wr.none=[];class tM 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=Tte(this.content,e+this.openStart,n);return r&&new $t(r,this.openStart,this.openEnd)}removeBetween(e,n){return new $t(Ate(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 Ate(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(Ate(a.content,e-i-1,n-i-1)))}function Tte(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=Tte(o.content,e-a-1,n,o);return l&&t.replaceChild(i,o.copy(l))}function m$e(t,e,n){if(n.openStart>t.depth)throw new tM("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new tM("Inconsistent open depths");return Cte(t,e,n,0)}function Cte(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=Cte(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 jf(o,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=p$e(n,t);return jf(a,jte(t,o,l,e,r))}else return jf(a,nM(t,e,r))}function kte(t,e){if(!e.type.compatibleContent(t.type))throw new tM("Cannot join "+e.type.name+" onto "+t.type.name)}function OR(t,e,n){let r=t.node(n);return kte(r,e.node(n)),r}function kf(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 c0(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&&(kf(t.nodeAfter,r),a++));for(let l=a;l<o;l++)kf(i.child(l),r);e&&e.depth==n&&e.textOffset&&kf(e.nodeBefore,r)}function jf(t,e){return t.type.checkContent(e),t.copy(e)}function jte(t,e,n,r,i){let a=t.depth>i&&OR(t,e,i+1),o=r.depth>i&&OR(n,r,i+1),l=[];return c0(null,t,i,l),a&&o&&e.index(i)==n.index(i)?(kte(a,o),kf(jf(a,jte(t,e,n,r,i+1)),l)):(a&&kf(jf(a,nM(t,e,i+1)),l),c0(e,n,i,l),o&&kf(jf(o,nM(n,r,i+1)),l)),c0(r,null,i,l),new At(l)}function nM(t,e,n){let r=[];if(c0(null,t,n,r),t.depth>n){let i=OR(t,e,n+1);kf(jf(i,nM(t,e,n+1)),r)}return c0(e,null,n,r),new At(r)}function p$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 ny{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 rM(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 ny(n,r,a)}static resolveCached(e,n){let r=w9.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 w9.set(e,r=new g$e);let i=r.elts[r.i]=ny.resolve(e,n);return r.i=(r.i+1)%x$e,i}}class g$e{constructor(){this.elts=[],this.i=0}}const x$e=12,w9=new WeakMap;class rM{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 b$e=Object.create(null);let Gd=class LR{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&&eM(this.attrs,n||e.defaultAttrs||b$e)&&wr.sameSet(this.marks,r||wr.none)}copy(e=null){return e==this.content?this:new LR(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new LR(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 m$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 ny.resolveCached(this,e)}resolveNoCache(e){return ny.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()+")"),Pte(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}};Gd.prototype.text=void 0;class iM extends Gd{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):Pte(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 iM(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new iM(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 Pte(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class rm{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new y$e(e,n);if(r.next==null)return rm.empty;let i=Rte(r);r.next&&r.err("Unexpected trailing text");let a=E$e(N$e(i));return A$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(`
- `)}}rm.empty=new rm(!0);class y$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 Rte(t){let e=[];do e.push(v$e(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function v$e(t){let e=[];do e.push(_$e(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function _$e(t){let e=M$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=w$e(t,e);else break;return e}function S9(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function w$e(t,e){let n=S9(t),r=n;return t.eat(",")&&(t.next!="}"?r=S9(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function S$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 M$e(t){if(t.eat("(")){let e=Rte(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=S$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 N$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 Dte(t,e){return e-t}function M9(t,e){let n=[];return r(e),n.sort(Dte);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(M9(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]);M9(t,c).forEach(d=>{u||i.push([l,u=[]]),u.indexOf(d)==-1&&u.push(d)})})});let a=e[r.join(",")]=new rm(r.indexOf(t.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(Dte);a.next.push({type:i[o][0],next:e[l.join(",")]||n(l)})}return a}}function A$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 Ote(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 Lte(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 Ite(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 Fte(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new C$e(t,r,e[r]);return n}let N9=class Ute{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=Fte(e,r.attrs),this.defaultAttrs=Ote(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==rm.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:Lte(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Gd(this,this.computeAttrs(e),At.from(n),wr.setFrom(r))}createChecked(e=null,n,r){return n=At.from(n),this.checkContent(n),new Gd(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 Gd(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){Ite(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 Ute(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 T$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 C$e{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?T$e(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class yE{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=Fte(e,i.attrs),this.excluded=null;let a=Ote(this.attrs);this.instance=a?new wr(this,a):null}create(e=null){return!e&&this.instance?this.instance:new wr(this,Lte(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((a,o)=>r[a]=new yE(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){Ite(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class zte{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=xa.from(e.nodes),n.marks=xa.from(e.marks||{}),this.nodes=N9.compile(this.spec.nodes,this),this.marks=yE.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]=rm.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=>Gd.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 N9){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 iM(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 k$e(t){return t.tag!=null}function j$e(t){return t.style!=null}let u0=class IR{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(k$e(i))this.tags.push(i);else if(j$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 T9(this,n,!1);return r.addAll(e,wr.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new T9(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(D$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=C9(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=C9(o)),o.node||o.ignore||o.mark||(o.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new IR(e,IR.schemaRules(e)))}};const Bte={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},P$e={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},$te={ol:!0,ul:!0},ry=1,FR=2,d0=4;function A9(t,e,n){return e!=null?(e?ry:0)|(e==="full"?FR:0):t&&t.whitespace=="pre"?ry|FR:n&~d0}class R1{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&d0?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&ry)){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&&!Bte.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class T9{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=A9(null,n.preserveWhitespace,0)|(r?d0:0);i?a=new R1(i.type,i.attrs,wr.none,!0,n.topMatch||i.type.contentMatch,o):r?a=new R1(null,null,wr.none,!0,null,o):a=new R1(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&FR?"full":this.localPreserveWS||(i.options&ry)>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,`
- `);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;$te.hasOwnProperty(o)&&this.parser.normalizeLists&&R$e(e);let c=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(c?c.ignore:P$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(Bte.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(`
- `),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):k9(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=A9(e,a,o.options);o.options&d0&&o.content.length==0&&(l|=d0);let c=wr.none;return r=r.filter(u=>(o.type?o.type.allowsMarkType(u.type):k9(u.type,e))?(c=u.addToSet(c),!1):!0),this.nodes.push(new R1(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|=ry)}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 R$e(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&$te.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function D$e(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function C9(t){let e={};for(let n in t)e[n]=t[n];return e}function k9(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 mm{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=pj(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}=bw(pj(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&&bw(pj(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return bw(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new mm(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=j9(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return j9(e.marks)}}function j9(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function pj(t){return t.document||window.document}const P9=new WeakMap;function O$e(t){let e=P9.get(t);return e===void 0&&P9.set(t,e=L$e(t)),e}function L$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 bw(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=O$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}=bw(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 Hte=65535,Vte=Math.pow(2,16);function I$e(t,e){return t+e*Vte}function R9(t){return t&Hte}function F$e(t){return(t-(t&Hte))/Vte}const Gte=1,Wte=2,yw=4,qte=8;class UR{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&qte)>0}get deletedBefore(){return(this.delInfo&(Gte|yw))>0}get deletedAfter(){return(this.delInfo&(Wte|yw))>0}get deletedAcross(){return(this.delInfo&yw)>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=R9(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+F$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:I$e(l/3,e-c),y=e==c?Wte:e==f?Gte:yw;return(n<0?e!=c:e!=f)&&(y|=qte),new UR(p,y,b)}i+=d-u}return r?e+i:new UR(e+i,0,null)}touches(e,n){let r=0,i=R9(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 iy{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 iy(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 iy;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 UR(e,i,null)}}const gj=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=gj[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 gj)throw new RangeError("Duplicate use of step JSON ID "+e);return gj[e]=n,n.prototype.jsonID=e,n}}class Ei{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new Ei(e,null)}static fail(e){return new Ei(null,e)}static fromReplace(e,n,r,i){try{return Ei.ok(e.replace(n,r,i))}catch(a){if(a instanceof tM)return Ei.fail(a.message);throw a}}}function NL(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let a=t.child(i);a.content.size&&(a=a.copy(NL(a.content,e,a))),a.isInline&&(a=e(a,n,i)),r.push(a)}return At.fromArray(r)}class Rd 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(NL(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 Ei.fromReplace(e,this.from,this.to,a)}invert(){return new il(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Rd(n.pos,r.pos,this.mark)}merge(e){return e instanceof Rd&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Rd(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Rd(n.from,n.to,e.markFromJSON(n.mark))}}Va.jsonID("addMark",Rd);class il 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(NL(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return Ei.fromReplace(e,this.from,this.to,r)}invert(){return new Rd(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new il(n.pos,r.pos,this.mark)}merge(e){return e instanceof il&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new il(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 il(n.from,n.to,e.markFromJSON(n.mark))}}Va.jsonID("removeMark",il);class Dd extends Va{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Ei.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Ei.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 Dd(this.pos,n.marks[i]);return new Dd(this.pos,this.mark)}}return new im(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Dd(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 Dd(n.pos,e.markFromJSON(n.mark))}}Va.jsonID("addNodeMark",Dd);class im extends Va{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Ei.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return Ei.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 Dd(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new im(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 im(n.pos,e.markFromJSON(n.mark))}}Va.jsonID("removeNodeMark",im);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&&zR(e,this.from,this.to)?Ei.fail("Structure replace would overwrite content"):Ei.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&&(zR(e,this.from,this.gapFrom)||zR(e,this.gapTo,this.to)))return Ei.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return Ei.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?Ei.fromReplace(e,this.from,this.to,r):Ei.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 zR(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 U$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 y=0;y<f.length;y++)f[y].isInSet(b)||(o&&o.to==m&&o.mark.eq(f[y])?o.to=p:i.push(o=new il(m,p,f[y])));l&&l.to==m?l.to=p:a.push(l=new Rd(m,p,r))}}),i.forEach(c=>t.step(c)),a.forEach(c=>t.step(c))}function z$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 yE){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 il(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 il(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 B$e(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function fx(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||!B$e(o,l,c))break;l&&(i=1),c<o.childCount&&(a=1)}return null}function $$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,y=!1;b>n;b--)y||r.index(b)>0?(y=!0,d=At.from(r.node(b).copy(d)),f++):c--;let m=At.empty,p=0;for(let b=a,y=!1;b>n;b--)y||i.after(b+1)<i.end(b)?(y=!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 AL(t,e,n=null,r=t){let i=H$e(t,e),a=i&&V$e(r,e);return a?i.map(D9).concat({type:e,attrs:n}).concat(a.map(D9)):null}function D9(t){return{type:t,attrs:null}}function H$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 V$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 G$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 W$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)&&q$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&&Xte(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&&Kte(t,o,l,a),!1}})}function Kte(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 Xte(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(`
- `))}})}function q$e(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function K$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 cu(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 y=r&&r[d]||f;if(!f.canReplace(m+1,f.childCount)||!y.type.validContent(p))return!1}let l=i.indexAfter(a),c=r&&r[0];return i.node(a).canReplaceWith(l,l,c?c.type:i.node(a+1).type)}function X$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 gh(t,e){let n=t.resolve(e),r=n.index();return Yte(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Y$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 Yte(t,e){return!!(t&&e&&!t.isLeaf&&Y$e(t,e))}function vE(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&&Yte(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 Q$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);Xte(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);Kte(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 Qte(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 _E(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 J$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 J$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=xj(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=xj(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=xj(e,n);if(i.childCount<=1&&n>0){let a=e.size-n<=n+i.size;this.unplaced=new $t(qb(e,n-1,1),n-1,a?n-1:r)}else this.unplaced=new $t(qb(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:a}){for(;this.depth>n;)this.closeFrontierNode();if(a)for(let y=0;y<a.length;y++)this.openFrontierNode(a[y]);let o=this.unplaced,l=r?r.content:o.content,c=o.openStart-e,u=0,d=[],{match:f,type:m}=this.frontier[n];if(i){for(let y=0;y<i.childCount;y++)d.push(i.child(y));f=f.matchFragment(i)}let p=l.size+e-(o.content.size-o.openEnd);for(;u<l.childCount;){let y=l.child(u),x=f.matchType(y.type);if(!x)break;u++,(u>1||c==0||y.content.size)&&(f=x,d.push(Jte(y.mark(m.allowedMarks(y.marks)),u==1?c:0,u==l.childCount?p:-1)))}let b=u==l.childCount;b||(p=-1),this.placed=Kb(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 y=0,x=l;y<p;y++){let v=x.lastChild;this.frontier.push({type:v.type,match:v.contentMatchAt(v.childCount)}),x=v.content}this.unplaced=b?e==0?$t.empty:new $t(qb(o.content,e-1,1),e-1,p<0?o.openEnd:e-1):new $t(qb(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||!bj(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=bj(e,n,i,r,a);if(o){for(let l=n-1;l>=0;l--){let{match:c,type:u}=this.frontier[l],d=bj(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=Kb(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=Kb(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=Kb(this.placed,this.frontier.length,n))}}function qb(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(qb(t.firstChild.content,e-1,n)))}function Kb(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Kb(t.lastChild.content,e-1,n)))}function xj(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function Jte(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,Jte(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 bj(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&&!eHe(n,a.content,o)?l:null}function eHe(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function tHe(t){return t.spec.defining||t.spec.definingForContent}function nHe(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=tne(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=tHe(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 y=0;y<o.length;y++){let x=o[(y+c)%o.length],v=!0;x<0&&(v=!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),v?a.after(x):n,new $t(ene(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 ene(t,e,n,r,i){if(e<n){let a=t.firstChild;t=t.replaceChild(0,a.copy(ene(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 rHe(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 iHe(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),a=tne(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 tne(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 ug 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 Ei.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 Ei.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 ug(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 ug(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 ug(n.pos,n.attr,n.value)}}Va.jsonID("attr",ug);class ay 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 Ei.ok(r)}getMap(){return Vs.empty}invert(e){return new ay(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 ay(n.attr,n.value)}}Va.jsonID("docAttr",ay);let Ig=class extends Error{};Ig=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Ig.prototype=Object.create(Error.prototype);Ig.prototype.constructor=Ig;Ig.prototype.name="TransformError";class nne{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new iy}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Ig(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=_E(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 nHe(this,e,n,r),this}replaceRangeWith(e,n,r){return rHe(this,e,n,r),this}deleteRange(e,n){return iHe(this,e,n),this}lift(e,n){return $$e(this,e,n),this}join(e,n=1){return Q$e(this,e,n),this}wrap(e,n){return G$e(this,e,n),this}setBlockType(e,n=e,r,i=null){return W$e(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return K$e(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new ug(e,n,r)),this}setDocAttribute(e,n){return this.step(new ay(e,n)),this}addNodeMark(e,n){return this.step(new Dd(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 im(e,n));else{let i=r.marks,a,o=[];for(;a=n.isInSet(i);)o.push(new im(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 X$e(this,e,n,r),this}addMark(e,n,r){return U$e(this,e,n,r),this}removeMark(e,n,r){return z$e(this,e,n,r),this}clearIncompatible(e,n,r){return EL(this,e,n,r),this}}const yj=Object.create(null);class Nn{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new aHe(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&&I9(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),I9(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new fn(e):$p(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?$p(e.node(0),e.node(a),e.before(a+1),e.index(a),n,r):$p(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 $p(e,e,0,0,1)||new Ys(e)}static atEnd(e){return $p(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=yj[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 yj)throw new RangeError("Duplicate use of selection JSON ID "+e);return yj[e]=n,n.prototype.jsonID=e,n}getBookmark(){return fn.between(this.$anchor,this.$head).getBookmark()}}Nn.prototype.visible=!0;class aHe{constructor(e,n){this.$from=e,this.$to=n}}let O9=!1;function L9(t){!O9&&!t.parent.inlineContent&&(O9=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class fn extends Nn{constructor(e,n=e){L9(e),L9(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 Nn.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 wE(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=Nn.findFrom(n,r,!0)||Nn.findFrom(n,-r,!0);if(a)n=a.$head;else return Nn.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(Nn.findFrom(e,-r,!0)||Nn.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new fn(e,n)}}Nn.jsonID("text",fn);class wE{constructor(e,n){this.anchor=e,this.head=n}map(e){return new wE(e.map(this.anchor),e.map(this.head))}resolve(e){return fn.between(e.resolve(this.anchor),e.resolve(this.head))}}class nn extends Nn{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?Nn.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 TL(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;Nn.jsonID("node",nn);class TL{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new wE(r,r):new TL(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&nn.isSelectable(r)?new nn(n):Nn.near(n)}}class Ys extends Nn{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=Nn.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 sHe}}Nn.jsonID("all",Ys);const sHe={map(){return this},resolve(t){return new Ys(t)}};function $p(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=$p(t,l,n+i,i<0?l.childCount:0,i,a);if(c)return c}n+=l.nodeSize*i}return null}function I9(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(Nn.near(t.doc.resolve(o),n))}const F9=1,D1=2,U9=4;class oHe extends nne{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|F9)&~D1,this.storedMarks=null,this}get selectionSet(){return(this.updated&F9)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=D1,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&D1)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~D1,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(Nn.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|=U9,this}get scrolledIntoView(){return(this.updated&U9)>0}}function z9(t,e){return!e||!t?t:t.bind(e)}class Xb{constructor(e,n,r){this.name=e,this.init=z9(n.init,r),this.apply=z9(n.apply,r)}}const lHe=[new Xb("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Xb("selection",{init(t,e){return t.selection||Nn.atStart(e.doc)},apply(t){return t.selection}}),new Xb("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Xb("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class vj{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=lHe.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 Xb(r.key,r.spec.state,r))})}}class Qp{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 Qp(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 oHe(this)}static create(e){let n=new vj(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Qp(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 vj(this.schema,e.plugins),r=n.fields,i=new Qp(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 vj(e.schema,e.plugins),a=new Qp(i);return i.fields.forEach(o=>{if(o.name=="doc")a.doc=Gd.fromJSON(e.schema,n.doc);else if(o.name=="selection")a.selection=Nn.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 rne(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=rne(i,e,{})),n[r]=i}return n}class Yr{constructor(e){this.spec=e,this.props={},e.props&&rne(e.props,this,this.props),this.key=e.key?e.key.key:ine("plugin")}getState(e){return e[this.key]}}const _j=Object.create(null);function ine(t){return t in _j?t+"$"+ ++_j[t]:(_j[t]=0,t+"$")}class Vi{constructor(e="key"){this.key=ine(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const CL=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function ane(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const sne=(t,e,n)=>{let r=ane(t,n);if(!r)return!1;let i=kL(r);if(!i){let o=r.blockRange(),l=o&&fx(o);return l==null?!1:(e&&e(t.tr.lift(o,l).scrollIntoView()),!0)}let a=i.nodeBefore;if(pne(t,i,e,-1))return!0;if(r.parent.content.size==0&&(Fg(a,"end")||nn.isSelectable(a)))for(let o=r.depth;;o--){let l=_E(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(Fg(a,"end")?Nn.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},cHe=(t,e,n)=>{let r=ane(t,n);if(!r)return!1;let i=kL(r);return i?one(t,i,e):!1},uHe=(t,e,n)=>{let r=cne(t,n);if(!r)return!1;let i=jL(r);return i?one(t,i,e):!1};function one(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=_E(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 Fg(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 lne=(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=kL(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 kL(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 cne(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const une=(t,e,n)=>{let r=cne(t,n);if(!r)return!1;let i=jL(r);if(!i)return!1;let a=i.nodeAfter;if(pne(t,i,e,1))return!0;if(r.parent.content.size==0&&(Fg(a,"start")||nn.isSelectable(a))){let o=_E(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(Fg(a,"start")?Nn.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},dne=(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=jL(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 jL(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 dHe=(t,e)=>{let n=t.selection,r=n instanceof nn,i;if(r){if(n.node.isTextblock||!gh(t.doc,n.from))return!1;i=n.from}else if(i=vE(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},hHe=(t,e)=>{let n=t.selection,r;if(n instanceof nn){if(n.node.isTextblock||!gh(t.doc,n.to))return!1;r=n.to}else if(r=vE(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},fHe=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),a=i&&fx(i);return a==null?!1:(e&&e(t.tr.lift(i,a).scrollIntoView()),!0)},hne=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
- `).scrollIntoView()),!0)};function PL(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 mHe=(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=PL(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(Nn.near(c.doc.resolve(l),1)),e(c.scrollIntoView())}return!0},fne=(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=PL(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},mne=(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(cu(t.doc,a))return e&&e(t.tr.split(a).scrollIntoView()),!0}let r=n.blockRange(),i=r&&fx(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function pHe(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof nn&&e.selection.node.isBlock)return!r.parentOffset||!cu(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=PL(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=cu(d.doc,f,a.length,a);if(m||(a[0]=l?{type:l}:null,m=cu(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 gHe=pHe(),xHe=(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 bHe(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||gh(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function pne(t,e,n,r){let i=e.nodeBefore,a=e.nodeAfter,o,l,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&bHe(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 v=o.length-1;v>=0;v--)b=At.from(o[v].create(null,b));b=At.from(i.copy(b));let y=t.tr.step(new ra(e.pos-1,p,e.pos,p,new $t(b,1,0),o.length,!0)),x=y.doc.resolve(p+2*o.length);x.nodeAfter&&x.nodeAfter.type==i.type&&gh(y.doc,x.pos)&&y.join(x.pos),n(y.scrollIntoView())}return!0}let d=a.type.spec.isolating||r>0&&c?null:Nn.findFrom(e,1),f=d&&d.$from.blockRange(d.$to),m=f&&fx(f);if(m!=null&&m>=e.depth)return n&&n(t.tr.lift(f,m).scrollIntoView()),!0;if(u&&Fg(a,"start",!0)&&Fg(i,"end")){let p=i,b=[];for(;b.push(p),!p.isTextblock;)p=p.lastChild;let y=a,x=1;for(;!y.isTextblock;y=y.firstChild)x++;if(p.canReplace(p.childCount,p.childCount,y.content)){if(n){let v=At.empty;for(let M=b.length-1;M>=0;M--)v=At.from(b[M].copy(v));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(v,b.length,0),0,!0));n(S.scrollIntoView())}return!0}}return!1}function gne(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 yHe=gne(-1),vHe=gne(1);function _He(t,e=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),l=o&&AL(o,t,e);return l?(r&&r(n.tr.wrap(o,l).scrollIntoView()),!0):!1}}function B9(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 RL(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}RL(CL,sne,lne);RL(CL,une,dne);RL(hne,fne,mne,gHe);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function wHe(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 SHe(l,o,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function SHe(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 rM(c,c,e.depth),e.endIndex<e.parent.childCount&&(e=new rM(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=AL(a,n,r,e);return l?(t&&MHe(t,e,l,i,n),!0):!1}function MHe(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&&cu(t.doc,c,l)&&(t.split(c,l),c+=2*l),c+=u.child(d).nodeSize;return t}function NHe(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):AHe(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 rM(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));const l=fx(r);if(l==null)return!1;i.lift(r,l);let c=i.doc.resolve(i.mapping.map(a,-1)-1);return gh(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos),e(i.scrollIntoView()),!0}function AHe(t,e,n){let r=t.tr,i=n.parent;for(let p=n.end,b=n.endIndex-1,y=n.startIndex;b>y;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 THe(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 wa=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Ug=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let BR=null;const Wc=function(t,e,n){let r=BR||(BR=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},CHe=function(){BR=null},am=function(t,e,n,r){return n&&($9(t,e,n,r,-1)||$9(t,e,n,r,1))},kHe=/^(img|br|input|textarea|hr)$/i;function $9(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||Ky(t)||kHe.test(t.nodeName)||t.contentEditable=="false")return!1;e=wa(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 jHe(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&&!Ky(t))e=wa(t),t=t.parentNode;else return null}}function PHe(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&&!Ky(t))e=wa(t)+1,t=t.parentNode;else return null}}function RHe(t,e,n){for(let r=e==0,i=e==Ao(t);r||i;){if(t==n)return!0;let a=wa(t);if(t=t.parentNode,!t)return!1;r=r&&a==0,i=i&&a==Ao(t)}}function Ky(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 SE=function(t){return t.focusNode&&am(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function sf(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function DHe(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function OHe(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,H9=typeof document<"u"?document:null,xh=ac&&ac.userAgent||"",$R=/Edge\/(\d+)/.exec(xh),xne=/MSIE \d/.exec(xh),HR=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(xh),Ns=!!(xne||HR||$R),Wd=xne?document.documentMode:HR?+HR[1]:$R?+$R[1]:0,jo=!Ns&&/gecko\/(\d+)/i.test(xh);jo&&+(/Firefox\/(\d+)/.exec(xh)||[0,0])[1];const VR=!Ns&&/Chrome\/(\d+)/.exec(xh),na=!!VR,bne=VR?+VR[1]:0,Ta=!Ns&&!!ac&&/Apple Computer/.test(ac.vendor),zg=Ta&&(/Mobile\/\w+/.test(xh)||!!ac&&ac.maxTouchPoints>2),_o=zg||(ac?/Mac/.test(ac.platform):!1),yne=ac?/Win/.test(ac.platform):!1,nu=/Android \d/.test(xh),Xy=!!H9&&"webkitFontSmoothing"in H9.documentElement.style,LHe=Xy?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function IHe(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 FHe(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 V9(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=Ug(o);continue}let l=o,c=l==a.body,u=c?IHe(a):FHe(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 y=l.scrollLeft-p,x=l.scrollTop-b;e={left:e.left-y,top:e.top-x,right:e.right-y,bottom:e.bottom-x}}let m=c?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(m))break;o=m=="absolute"?o.offsetParent:Ug(o)}}function UHe(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:vne(t.dom)}}function vne(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Ug(r));return e}function zHe({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;_ne(n,r==0?0:r-e)}function _ne(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 Dp=null;function BHe(t){if(t.setActive)return t.setActive();if(Dp)return t.focus(Dp);let e=vne(t);t.focus(Dp==null?{get preventScroll(){return Dp={preventScroll:!0},!0}}:void 0),Dp||(Dp=!1,_ne(e,0))}function wne(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=Wc(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 y=b.left>e.left?b.left-e.left:b.right<e.left?e.left-b.right:0;if(y<r){n=d,r=y,i=y&&n.nodeType==3?{left:b.right<e.left?b.right:b.left,top:e.top}:e,d.nodeType==1&&y&&(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?$He(n,i):!n||r&&n.nodeType==1?{node:t,offset:a}:wne(n,i)}function $He(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=pd(r,1);if(o.top!=o.bottom&&DL(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 DL(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function HHe(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function VHe(t,e,n){let{node:r,offset:i}=wne(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 GHe(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 Sne(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(DL(e,u))return Sne(o,e,u)}}if((a=(a+1)%r)==i)break}return t}function WHe(t,e){let n=t.dom.ownerDocument,r,i=0,a=OHe(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(!DL(e,u)||(o=Sne(t.dom,e,u),!o))return null}if(Ta)for(let u=o;r&&u;u=Ug(u))u.draggable&&(r=void 0);if(o=HHe(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;Xy&&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=GHe(t,r,i,e))}l==null&&(l=VHe(t,o,e));let c=t.docView.nearestDesc(o,!0);return{pos:l,inside:c?c.posAtStart-c.border:-1}}function G9(t){return t.top<t.bottom||t.left<t.right}function pd(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(G9(r))return r}return Array.prototype.find.call(n,G9)||t.getBoundingClientRect()}const qHe=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Mne(t,e,n){let{node:r,offset:i,atom:a}=t.docView.domFromPos(e,n<0?-1:1),o=Xy||jo;if(r.nodeType==3)if(o&&(qHe.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let c=pd(Wc(r,i,i),n);if(jo&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let u=pd(Wc(r,i-1,i-1),-1);if(u.top==c.top){let d=pd(Wc(r,i,i+1),-1);if(d.top!=c.top)return Pb(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++,Pb(pd(Wc(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 wj(c.getBoundingClientRect(),!1)}if(a==null&&i<Ao(r)){let c=r.childNodes[i];if(c.nodeType==1)return wj(c.getBoundingClientRect(),!0)}return wj(r.getBoundingClientRect(),n>=0)}if(a==null&&i&&(n<0||i==Ao(r))){let c=r.childNodes[i-1],u=c.nodeType==3?Wc(c,Ao(c)-(o?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(u)return Pb(pd(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?Wc(c,0,o?0:1):c.nodeType==1?c:null:null;if(u)return Pb(pd(u,-1),!0)}return Pb(pd(r.nodeType==3?Wc(r):r,-n),n>=0)}function Pb(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 wj(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 Nne(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 KHe(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return Nne(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=Mne(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=Wc(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 XHe=/[\u0590-\u08ac]/;function YHe(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?!XHe.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?a:o:Nne(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:y}=t.domSelectionRange(),x=b&&!p.contains(b.nodeType==1?b:b.parentNode)||c==b&&u==y;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 W9=null,q9=null,K9=!1;function QHe(t,e,n){return W9==e&&q9==n?K9:(W9=e,q9=n,K9=n=="up"||n=="down"?KHe(t,e,n):YHe(t,e,n))}const Po=0,X9=1,xf=2,sc=3;class Yy{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>wa(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 Ane){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?wa(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?wa(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=wa(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=wa(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 y=this.children[p],x=b+y.size;if(a>b&&o<x)return y.setSelection(e-b-y.border,n-b-y.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]==`
- `),f&&b==p.nodeValue.length)for(let y=p,x;y;y=y.parentNode){if(x=y.nextSibling){x.nodeName=="BR"&&(l=c={node:x.parentNode,offset:wa(x)+1});break}let v=y.pmViewDesc;if(v&&v.node&&v.node.isBlock)break}}else{let y=p.childNodes[b-1];f=y&&(y.nodeName=="BR"||y.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)&&am(l.node,l.offset,d.anchorNode,d.anchorOffset)&&am(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?xf:X9,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?xf:sc}r=o}this.dirty=xf}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?xf:X9;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 Yy{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 Yy{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 sm extends Yy{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=mm.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new sm(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=sm.create(this.parent,this.mark,!0,r),a=this.children,o=this.size;n<o&&(a=WR(a,n,o,r)),e>0&&(a=WR(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 qd extends Yy{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}=mm.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=kne(d,r,n),u?c=new JHe(e,n,r,i,d,f||null,m,u,a,o+1):n.isText?new ME(e,n,r,i,d,m,a):new qd(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)&&aM(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 tVe(this,o&&o.node,e);iVe(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==xf)&&(o&&this.protectLocalComposition(e,o),Tne(this.contentDOM,this.children,e),zg&&aVe(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=sVe(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=WR(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(aM(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Cne(this.dom,this.nodeDOM,GR(this.outerDeco,this.node,n),GR(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 Y9(t,e,n,r,i){kne(r,e,t);let a=new qd(void 0,t,e,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}class ME extends qd{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 ME(this.parent,i,this.outerDeco,this.innerDeco,a,a,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=sc)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Ane extends Yy{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 JHe extends qd{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 Tne(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=Q9(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(l,r);if(o instanceof sm){let c=r?r.previousSibling:t.lastChild;Tne(o.contentDOM,o.children,n),r=c?c.nextSibling:t.firstChild}}for(;r;)r=Q9(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const h0=function(t){t&&(this.nodeName=t)};h0.prototype=Object.create(null);const bf=[new h0];function GR(t,e,n){if(t.length==0)return bf;let r=n?bf[0]:new h0,i=[r];for(let a=0;a<t.length;a++){let o=t[a].type.attrs;if(o){o.nodeName&&i.push(r=new h0(o.nodeName));for(let l in o){let c=o[l];c!=null&&(n&&i.length==1&&i.push(r=new h0(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 Cne(t,e,n,r){if(n==bf&&r==bf)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=bf[0]),i=c}eVe(i,l||bf[0],o)}return i}function eVe(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 kne(t,e,n){return Cne(t,t,bf,GR(e,n,t.nodeType!=1))}function aM(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 Q9(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class tVe{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=nVe(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=sm.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=xf),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 qd){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&&aM(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=xf,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)||!aM(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=qd.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=qd.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 sm;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof ME)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((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 Ane(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 nVe(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 sm)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 rVe(t,e){return t.type.side-e.type.side}function iVe(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(rVe);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 v=0;v<l.length;v++)l[v].to<x&&(x=l[v].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 y=m.isInline&&!m.isLeaf?l.filter(x=>!x.inline):l.slice();r(m,y,e.forChild(a,m),p),a=b}}function aVe(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 sVe(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 WR(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 OL(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(SE(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&&RHe(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=LL(t,d,l,f)}return u}function jne(t){return t.editable?t.hasFocus():Rne(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function uu(t,e=!1){let n=t.state.selection;if(Pne(t,n),!!jne(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&na){let r=t.domSelectionRange(),i=t.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&am(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)lVe(t);else{let{anchor:r,head:i}=n,a,o;Z9&&!(n instanceof fn)&&(n.$from.parent.inlineContent||(a=J9(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=J9(t,n.to))),t.docView.setSelection(r,i,t,e),Z9&&(a&&eW(a),o&&eW(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&oVe(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const Z9=Ta||na&&bne<63;function J9(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 Sj(i);if((!i||i.contentEditable=="false")&&(!a||a.contentEditable=="false")){if(i)return Sj(i);if(a)return Sj(a)}}function Sj(t){return t.contentEditable="true",Ta&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function eW(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function oVe(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(()=>{(!jne(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function lVe(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,wa(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Ns&&Wd<=11&&(n.disabled=!0,n.disabled=!1)}function Pne(t,e){if(e instanceof nn){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(tW(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else tW(t)}function tW(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function LL(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||fn.between(e,n,r)}function nW(t){return t.editable&&!t.hasFocus()?!1:Rne(t)}function Rne(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 cVe(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return am(e.node,e.offset,n.anchorNode,n.anchorOffset)}function qR(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&&Nn.findFrom(a,e)}function vd(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function rW(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 vd(t,new fn(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=qR(t.state,e);return i&&i instanceof nn?vd(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)?vd(t,new nn(e<0?t.state.doc.resolve(i.pos-a.nodeSize):i)):Xy?vd(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 vd(t,new fn(e>0?r.$to:r.$from));{let i=qR(t.state,e);return i?vd(t,i):!1}}}function sM(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function f0(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Op(t,e){return e<0?uVe(t):dVe(t)}function uVe(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<sM(n)&&f0(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(f0(l,-1))i=n,a=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(Dne(n))break;{let l=n.previousSibling;for(;l&&f0(l,-1);)i=n.parentNode,a=wa(l),l=l.previousSibling;if(l)n=l,r=sM(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?KR(t,n,r):i&&KR(t,i,a)}function dVe(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=sM(n),a,o;for(;;)if(r<i){if(n.nodeType!=1)break;let l=n.childNodes[r];if(f0(l,1))a=n,o=++r;else break}else{if(Dne(n))break;{let l=n.nextSibling;for(;l&&f0(l,1);)a=l.parentNode,o=wa(l)+1,l=l.nextSibling;if(l)n=l,r=0,i=sM(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}a&&KR(t,a,o)}function Dne(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function hVe(t,e){for(;t&&e==t.childNodes.length&&!Ky(t);)e=wa(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 fVe(t,e){for(;t&&!e&&!Ky(t);)e=wa(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 KR(t,e,n){if(e.nodeType!=3){let a,o;(o=hVe(e,n))?(e=o,n=0):(a=fVe(e,n))&&(e=a,n=a.nodeValue.length)}let r=t.domSelection();if(!r)return;if(SE(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&&uu(t)},50)}function iW(t,e){let n=t.state.doc.resolve(e);if(!(na||yne)&&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 aW(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=qR(t.state,e);if(o&&o instanceof nn)return vd(t,o)}if(!i.parent.inlineContent){let o=e<0?i:a,l=r instanceof Ys?Nn.near(o,e):Nn.findFrom(o,e);return l?vd(t,l):!1}return!1}function sW(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 oW(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function mVe(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;oW(t,r,"true"),setTimeout(()=>oW(t,r,"false"),20)}return!1}function pVe(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function gVe(t,e){let n=e.keyCode,r=pVe(e);if(n==8||_o&&n==72&&r=="c")return sW(t,-1)||Op(t,-1);if(n==46&&!e.shiftKey||_o&&n==68&&r=="c")return sW(t,1)||Op(t,1);if(n==13||n==27)return!0;if(n==37||_o&&n==66&&r=="c"){let i=n==37?iW(t,t.state.selection.from)=="ltr"?-1:1:-1;return rW(t,i,r)||Op(t,i)}else if(n==39||_o&&n==70&&r=="c"){let i=n==39?iW(t,t.state.selection.from)=="ltr"?1:-1:1;return rW(t,i,r)||Op(t,i)}else{if(n==38||_o&&n==80&&r=="c")return aW(t,-1,r)||Op(t,-1);if(n==40||_o&&n==78&&r=="c")return mVe(t)||aW(t,1,r)||Op(t,1);if(r==(_o?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function IL(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")||mm.fromSchema(t.state.schema),l=zne(),c=l.createElement("div");c.appendChild(o.serializeFragment(r,{document:l}));let u=c.firstChild,d,f=0;for(;u&&u.nodeType==1&&(d=Une[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,`
- `);return{dom:c,text:m,slice:e}}function One(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,`
- `))),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=mm.fromSchema(p);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(y=>{let x=o.appendChild(document.createElement("p"));y&&x.appendChild(b.serializeNode(p.text(y,m)))})}}else t.someProp("transformPastedHTML",f=>{n=f(n,t)}),o=vVe(n),Xy&&_Ve(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")||u0.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||d),context:i,ruleFromNode(m){return m.nodeName=="BR"&&!m.nextSibling&&m.parentNode&&!xVe.test(m.parentNode.nodeName)?{ignore:!0}:null}})),d)l=wVe(lW(l,+d[1],+d[2]),d[4]);else if(l=$t.maxOpen(bVe(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=lW(l,f,m)}return t.someProp("transformPasted",f=>{l=f(l,t,c)}),l}const xVe=/^(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 bVe(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&&Ine(c,a,l,o[o.length-1],0))o[o.length-1]=u;else{o.length&&(o[o.length-1]=Fne(o[o.length-1],a.length));let d=Lne(l,c);o.push(d),i=i.matchType(d.type),a=c}}),o)return At.from(o)}return t}function Lne(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,At.from(t));return t}function Ine(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let a=Ine(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(Lne(n,t,i+1))))}}function Fne(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,Fne(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(At.empty,!0);return t.copy(n.append(r))}function XR(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=XR(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 lW(t,e,n){return e<t.openStart&&(t=new $t(XR(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new $t(XR(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const Une={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 cW=null;function zne(){return cW||(cW=document.implementation.createHTMLDocument("title"))}let Mj=null;function yVe(t){let e=window.trustedTypes;return e?(Mj||(Mj=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),Mj.createHTML(t)):t}function vVe(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=zne().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&Une[r[1].toLowerCase()])&&(t=i.map(a=>"<"+a+">").join("")+t+i.map(a=>"</"+a+">").reverse().join("")),n.innerHTML=yVe(t),i)for(let a=0;a<i.length;a++)n=n.querySelector(i[a])||n;return n}function _Ve(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 wVe(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 is={},as={},SVe={touchstart:!0,touchmove:!0};class MVe{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 NVe(t){for(let e in is){let n=is[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{AVe(t,r)&&!FL(t,r)&&(t.editable||!(r.type in as))&&n(t,r)},SVe[e]?{passive:!0}:void 0)}Ta&&t.dom.addEventListener("input",()=>null),YR(t)}function Od(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 YR(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>FL(t,r))})}function FL(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function AVe(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 TVe(t,e){!FL(t,e)&&is[e.type]&&(t.editable||!(e.type in as))&&is[e.type](t,e)}as.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!$ne(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(nu&&na&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),zg&&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,sf(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||gVe(t,n)?n.preventDefault():Od(t,"key")};as.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};as.keypress=(t,e)=>{let n=e;if($ne(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 NE(t){return{left:t.clientX,top:t.clientY}}function CVe(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function UL(t,e,n,r,i){if(r==-1)return!1;let a=t.state.doc.resolve(r);for(let 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 dg(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 kVe(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&nn.isSelectable(r)?(dg(t,new nn(n)),!0):!1}function jVe(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?(dg(t,nn.create(t.state.doc,i)),!0):!1}function PVe(t,e,n,r,i){return UL(t,"handleClickOn",e,n,r)||t.someProp("handleClick",a=>a(t,e,r))||(i?jVe(t,n):kVe(t,n))}function RVe(t,e,n,r){return UL(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function DVe(t,e,n,r){return UL(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||OVe(t,n,r)}function OVe(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(dg(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)dg(t,fn.create(r,l+1,l+1+o.content.size));else if(nn.isSelectable(o))dg(t,nn.create(r,l));else continue;return!0}}function zL(t){return oM(t)}const Bne=_o?"metaKey":"ctrlKey";is.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=zL(t),i=Date.now(),a="singleClick";i-t.input.lastClick.time<500&&CVe(n,t.input.lastClick)&&!n[Bne]&&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(NE(n));o&&(a=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new LVe(t,o,n,!!r)):(a=="doubleClick"?RVe:DVe)(t,o.pos,o.inside,n)?n.preventDefault():Od(t,"pointer"))};class LVe{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[Bne],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)),Od(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>uu(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(NE(e))),this.updateAllowDefault(e),this.allowDefault||!n?Od(this.view,"pointer"):PVe(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)?(dg(this.view,Nn.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Od(this.view,"pointer")}move(e){this.updateAllowDefault(e),Od(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}is.touchstart=t=>{t.input.lastTouch=Date.now(),zL(t),Od(t,"pointer")};is.touchmove=t=>{t.input.lastTouch=Date.now(),Od(t,"pointer")};is.contextmenu=t=>zL(t);function $ne(t,e){return t.composing?!0:Ta&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const IVe=nu?5e3:-1;as.compositionstart=as.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&&yne&&FVe(t)))t.markCursor=t.state.storedMarks||n.marks(),oM(t,!0),t.markCursor=null;else if(oM(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}Hne(t,IVe)};function FVe(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"}as.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++,Hne(t,20))};function Hne(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>oM(t),e))}function Vne(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=zVe());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function UVe(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=jHe(e.focusNode,e.focusOffset),r=PHe(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 zVe(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function oM(t,e=!1){if(!(nu&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Vne(t),e||t.docView&&t.docView.dirty){let n=OL(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 BVe(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 sy=Ns&&Wd<15||zg&&LHe<604;is.copy=as.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let a=sy?null:n.clipboardData,o=r.content(),{dom:l,text:c}=IL(t,o);a?(n.preventDefault(),a.clearData(),a.setData("text/html",l.innerHTML),a.setData("text/plain",c)):BVe(t,l),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function $Ve(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function HVe(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?oy(t,r.value,null,i,e):oy(t,r.textContent,r.innerHTML,i,e)},50)}function oy(t,e,n,r,i){let a=One(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=$Ve(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 Gne(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," "):""}as.paste=(t,e)=>{let n=e;if(t.composing&&!nu)return;let r=sy?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&oy(t,Gne(r),r.getData("text/html"),i,n)?n.preventDefault():HVe(t,n)};class Wne{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const VVe=_o?"altKey":"ctrlKey";function qne(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[VVe]}is.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(NE(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}=IL(t,l);(!n.dataTransfer.files.length||!na||bne>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(sy?"Text":"text/html",c.innerHTML),n.dataTransfer.effectAllowed="copyMove",sy||n.dataTransfer.setData("text/plain",u),t.dragging=new Wne(d,qne(t,n),o)};is.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};as.dragover=as.dragenter=(t,e)=>e.preventDefault();as.drop=(t,e)=>{try{GVe(t,e,t.dragging)}finally{t.dragging=null}};function GVe(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(NE(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=One(t,Gne(e.dataTransfer),sy?null:e.dataTransfer.getData("text/html"),!1,i);let o=!!(n&&qne(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?Qte(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,y,x,v)=>p=v),c.setSelection(LL(t,m,c.doc.resolve(p)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))}is.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())&&uu(t)},20))};is.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)};is.beforeinput=(t,e)=>{if(na&&nu&&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,sf(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 as)is[t]=as[t];function ly(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 lM{constructor(e,n){this.toDOM=e,this.spec=n||Pf,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 Za(a-r,a-r,this)}valid(){return!0}eq(e){return this==e||e instanceof lM&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&ly(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Kd{constructor(e,n){this.attrs=e,this.spec=n||Pf}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 Za(a,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Kd&&ly(this.attrs,e.attrs)&&ly(this.spec,e.spec)}static is(e){return e.type instanceof Kd}destroy(){}}class BL{constructor(e,n){this.attrs=e,this.spec=n||Pf}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 Za(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 BL&&ly(this.attrs,e.attrs)&&ly(this.spec,e.spec)}destroy(){}}class Za{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Za(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 Za(e,e,new lM(n,r))}static inline(e,n,r,i){return new Za(e,n,new Kd(r,i))}static node(e,n,r,i){return new Za(e,n,new BL(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Kd}get widget(){return this.type instanceof lM}}const Hp=[],Pf={};class Vr{constructor(e,n){this.local=e.length?e:Hp,this.children=n.length?n:Hp}static create(e,n){return n.length?cM(n,e,0,Pf):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||Pf)}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?WVe(this.children,o||[],e,n,r,i,a):o?new Vr(o.sort(Rf),Hp):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=Xne(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,cM(d,l,u+1,Pf)),a+=3}});let o=Kne(a?Yne(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(Rf):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 Kd){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(Rf),Hp);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 $L(this.localsInner(e))}localsInner(e){if(this==La)return Hp;if(e.inlineContent||!this.local.some(Kd.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Kd||n.push(this.local[r]);return n}forEachSet(e){e(this)}}Vr.empty=new Vr([],[]);Vr.removeOverlap=$L;const La=Vr.empty;class Ed{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,Pf));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?$L(r?n:n.sort(Rf)):Hp}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 WVe(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,y)=>{let x=y-b-(p-m);for(let v=0;v<l.length;v+=3){let S=l[v+1];if(S<0||m>S+d-f)continue;let M=l[v]+d-f;p>=M?l[v+1]=m<=M?-2:-1:m>=d&&x&&(l[v]+=x,l[v+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:y}=r.content.findIndex(f),x=r.maybeChild(b);if(x&&y==f&&y+x.nodeSize==p){let v=l[u+2].mapInner(n,x,d+1,t[u]+a+1,o);v!=La?(l[u]=f,l[u+1]=p,l[u+2]=v):(l[u+1]=-2,c=!0)}else c=!0}if(c){let u=qVe(l,t,e,n,i,a,o),d=cM(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(Rf),l)}function Kne(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 Za(i.from+e,i.to+e,i.type))}return n}function qVe(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 Xne(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 Yne(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function cM(t,e,n,r){let i=[],a=!1;e.forEach((l,c)=>{let u=Xne(t,l,c+n);if(u){a=!0;let d=cM(u,l,n+c+1,r);d!=La&&i.push(c,c+l.nodeSize,d)}});let o=Kne(a?Yne(t):t,-n).sort(Rf);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 Rf(t,e){return t.from-e.from||t.to-e.to}function $L(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),uW(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),uW(e,i,r.copy(a.from,r.to)));break}}}return e}function uW(t,e,n){for(;e<t.length&&Rf(n,t[e])>0;)e++;t.splice(e,0,n)}function Nj(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 KVe={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},XVe=Ns&&Wd<=11;class YVe{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 QVe{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new YVe,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]);Ns&&Wd<=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()}),XVe&&(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,KVe)),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(nW(this.view)){if(this.suppressingSelectionUpdates)return uu(this.view);if(Ns&&Wd<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&am(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=Ug(a))n.add(a);for(let a=e.anchorNode;a;a=Ug(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)&&nW(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||eGe(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&&SE(r)&&(u=OL(e))&&u.eq(Nn.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,uu(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,tGe(e,c)),this.handleDOMChange(a,o,l,c),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||uu(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(Ns&&Wd<=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?wa(i)+1:0,l=r.localPosFromDOM(e.target,o,-1),c=a&&a.parentNode==e.target?wa(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 dW=new WeakMap,hW=!1;function ZVe(t){if(!dW.has(t)&&(dW.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=jo,hW)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."),hW=!0}}function fW(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,a=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return am(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function JVe(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return fW(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?fW(t,n):null}function eGe(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 tGe(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 nGe(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}],SE(c)||u.push({node:c.focusNode,offset:c.focusOffset})),na&&t.input.lastKeyCode===8)for(let x=a;x>i;x--){let v=r.childNodes[x-1],S=v.pmViewDesc;if(v.nodeName=="BR"&&!S){a=x;break}if(!S||S.size)break}let f=t.state.doc,m=t.someProp("domParser")||u0.fromSchema(t.state.schema),p=f.resolve(o),b=null,y=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:rGe,context:p});if(u&&u[0].pos!=null){let x=u[0].pos,v=u[1]&&u[1].pos;v==null&&(v=x),b={anchor:x+o,head:v+o}}return{doc:y,sel:b,from:o,to:l}}function rGe(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 iGe=/^(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 aGe(t,e,n,r,i){let a=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let T=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,D=OL(t,T);if(D&&!t.state.selection.eq(D)){if(na&&nu&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",R=>R(t,sf(13,"Enter"))))return;let C=t.state.tr.setSelection(D);T=="pointer"?C.setMeta("pointer",!0):T=="key"&&C.scrollIntoView(),a&&C.setMeta("composition",a),t.dispatch(C)}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=nGe(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=lGe(f.content,u.doc.content,u.from,m,p);if(b&&t.input.domChangeCount++,(zg&&t.input.lastIOSEnter>Date.now()-225||nu)&&i.some(T=>T.nodeType==1&&!iGe.test(T.nodeName))&&(!b||b.endA>=b.endB)&&t.someProp("handleKeyDown",T=>T(t,sf(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 T=mW(t,t.state.doc,u.sel);if(T&&!T.eq(t.state.selection)){let D=t.state.tr.setSelection(T);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)),Ns&&Wd<=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 y=u.doc.resolveNoCache(b.start-u.from),x=u.doc.resolveNoCache(b.endB-u.from),v=d.resolve(b.start),S=y.sameParent(x)&&y.parent.inlineContent&&v.end()>=b.endA;if((zg&&t.input.lastIOSEnter>Date.now()-225&&(!S||i.some(T=>T.nodeName=="DIV"||T.nodeName=="P"))||!S&&y.pos<u.doc.content.size&&(!y.sameParent(x)||!y.parent.inlineContent)&&y.pos<x.pos&&!/\S/.test(u.doc.textBetween(y.pos,x.pos,"","")))&&t.someProp("handleKeyDown",T=>T(t,sf(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>b.start&&oGe(d,b.start,b.endA,y,x)&&t.someProp("handleKeyDown",T=>T(t,sf(8,"Backspace")))){nu&&na&&t.domObserver.suppressSelectionUpdates();return}na&&b.endB==b.start&&(t.input.lastChromeDelete=Date.now()),nu&&!S&&y.start()!=x.start()&&x.parentOffset==0&&y.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(T){return T(t,sf(13,"Enter"))})},20));let M=b.start,E=b.endA,A=T=>{let D=T||t.state.tr.replace(M,E,u.doc.slice(b.start-u.from,b.endB-u.from));if(u.sel){let C=mW(t,D.doc,u.sel);C&&!(na&&t.composing&&C.empty&&(b.start!=b.endB||t.input.lastChromeDelete<Date.now()-100)&&(C.head==M||C.head==D.mapping.map(E)-1)||Ns&&C.empty&&C.head==M)&&D.setSelection(C)}return a&&D.setMeta("composition",a),D.scrollIntoView()},k;if(S)if(y.pos==x.pos){Ns&&Wd<=11&&y.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>uu(t),20));let T=A(t.state.tr.delete(M,E)),D=d.resolve(b.start).marksAcross(d.resolve(b.endA));D&&T.ensureMarks(D),t.dispatch(T)}else if(b.endA==b.endB&&(k=sGe(y.parent.content.cut(y.parentOffset,x.parentOffset),v.parent.content.cut(v.parentOffset,b.endA-v.start())))){let T=A(t.state.tr);k.type=="add"?T.addMark(M,E,k.mark):T.removeMark(M,E,k.mark),t.dispatch(T)}else if(y.parent.child(y.index()).isText&&y.index()==x.index()-(x.textOffset?0:1)){let T=y.parent.textBetween(y.parentOffset,x.parentOffset),D=()=>A(t.state.tr.insertText(T,M,E));t.someProp("handleTextInput",C=>C(t,M,E,T,D))||t.dispatch(D())}else t.dispatch(A());else t.dispatch(A())}function mW(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:LL(t,e.resolve(n.anchor),e.resolve(n.head))}function sGe(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 oGe(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 lGe(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&&pW(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&&pW(t.textBetween(a-1,a+1))&&(a+=c?1:-1),o=a+(o-l),l=a}return{start:a,endA:o,endB:l}}function pW(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 Qne{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 MVe,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(vW),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=bW(this),xW(this),this.nodeViews=yW(this),this.docView=Y9(this.state.doc,gW(this),Nj(this),this.dom,this),this.domObserver=new QVe(this,(r,i,a,o)=>aGe(this,r,i,a,o)),this.domObserver.start(),NVe(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&&YR(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(vW),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&&(Vne(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=yW(this);uGe(p,this.nodeViews)&&(this.nodeViews=p,a=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&YR(this),this.editable=bW(this),xW(this);let c=Nj(this),u=gW(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&&UHe(this);if(o){this.domObserver.stop();let p=f&&(Ns||na)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&cGe(i.selection,e.selection);if(f){let b=na?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=UVe(this)),(a||!this.docView.update(e.doc,u,c,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=Y9(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())&&cVe(this))?uu(this,p):(Pne(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&&zHe(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&&V9(this,n.getBoundingClientRect(),e)}else V9(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 Wne(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(Ns){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&&BHe(this.dom),uu(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 WHe(this,e)}coordsAtPos(e,n=1){return Mne(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 QHe(this,n||this.state,e)}pasteHTML(e,n){return oy(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return oy(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return IL(this,e)}destroy(){this.docView&&(EVe(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Nj(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,CHe())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return TVe(this,e)}domSelectionRange(){let e=this.domSelection();return e?Ta&&this.root.nodeType===11&&DHe(this.dom.ownerDocument)==this.dom&&JVe(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}Qne.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function gW(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"),[Za.node(0,t.state.doc.content.size,e)]}function xW(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:Za.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function bW(t){return!t.someProp("editable",e=>e(t.state)===!1)}function cGe(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 yW(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 uGe(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 vW(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 sh={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:"'"},uM={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},dGe=typeof navigator<"u"&&/Mac/.test(navigator.platform),hGe=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Sa=0;Sa<10;Sa++)sh[48+Sa]=sh[96+Sa]=String(Sa);for(var Sa=1;Sa<=24;Sa++)sh[Sa+111]="F"+Sa;for(var Sa=65;Sa<=90;Sa++)sh[Sa]=String.fromCharCode(Sa+32),uM[Sa]=String.fromCharCode(Sa);for(var Aj in sh)uM.hasOwnProperty(Aj)||(uM[Aj]=sh[Aj]);function fGe(t){var e=dGe&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||hGe&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?uM:sh)[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 mGe=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),pGe=typeof navigator<"u"&&/Win/.test(navigator.platform);function gGe(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))mGe?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 xGe(t){let e=Object.create(null);for(let n in t)e[gGe(n)]=t[n];return e}function Tj(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 bGe(t){return new Yr({props:{handleKeyDown:Zne(t)}})}function Zne(t){let e=xGe(t);return function(n,r){let i=fGe(r),a,o=e[Tj(i,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[Tj(i,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(pGe&&r.ctrlKey&&r.altKey)&&(a=sh[r.keyCode])&&a!=i){let l=e[Tj(a,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var yGe=Object.defineProperty,HL=(t,e)=>{for(var n in e)yGe(t,n,{get:e[n],enumerable:!0})};function EE(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 AE=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 y=this.buildProps(c,e),x=m(...b)(y);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:EE({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}},Jne={};HL(Jne,{blur:()=>vGe,clearContent:()=>_Ge,clearNodes:()=>wGe,command:()=>SGe,createParagraphNear:()=>MGe,cut:()=>NGe,deleteCurrentNode:()=>EGe,deleteNode:()=>AGe,deleteRange:()=>TGe,deleteSelection:()=>CGe,enter:()=>kGe,exitCode:()=>jGe,extendMarkRange:()=>PGe,first:()=>RGe,focus:()=>OGe,forEach:()=>LGe,insertContent:()=>IGe,insertContentAt:()=>zGe,joinBackward:()=>HGe,joinDown:()=>$Ge,joinForward:()=>VGe,joinItemBackward:()=>GGe,joinItemForward:()=>WGe,joinTextblockBackward:()=>qGe,joinTextblockForward:()=>KGe,joinUp:()=>BGe,keyboardShortcut:()=>YGe,lift:()=>QGe,liftEmptyBlock:()=>ZGe,liftListItem:()=>JGe,newlineInCode:()=>e7e,resetAttributes:()=>t7e,scrollIntoView:()=>n7e,selectAll:()=>r7e,selectNodeBackward:()=>i7e,selectNodeForward:()=>a7e,selectParentNode:()=>s7e,selectTextblockEnd:()=>o7e,selectTextblockStart:()=>l7e,setContent:()=>c7e,setMark:()=>C7e,setMeta:()=>k7e,setNode:()=>j7e,setNodeSelection:()=>P7e,setTextDirection:()=>R7e,setTextSelection:()=>D7e,sinkListItem:()=>O7e,splitBlock:()=>L7e,splitListItem:()=>I7e,toggleList:()=>F7e,toggleMark:()=>U7e,toggleNode:()=>z7e,toggleWrap:()=>B7e,undoInputRule:()=>$7e,unsetAllMarks:()=>H7e,unsetMark:()=>V7e,unsetTextDirection:()=>G7e,updateAttributes:()=>W7e,wrapIn:()=>q7e,wrapInList:()=>K7e});var vGe=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),_Ge=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),wGe=()=>({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=fx(p);if(l.type.isTextblock){const{defaultType:y}=f.parent.contentMatchAt(f.index());e.setNodeMarkup(p.start,y)}(b||b===0)&&e.lift(p,b)})}),!0},SGe=t=>e=>t(e),MGe=()=>({state:t,dispatch:e})=>fne(t,e),NGe=(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 AGe=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},TGe=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},CGe=()=>({state:t,dispatch:e})=>CL(t,e),kGe=()=>({commands:t})=>t.keyboardShortcut("Enter"),jGe=()=>({state:t,dispatch:e})=>mHe(t,e);function VL(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function dM(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:VL(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function ere(t,e,n={}){return t.find(r=>r.type===e&&dM(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function _W(t,e,n={}){return!!ere(t,e,n)}function GL(t,e,n){var r;if(!t||!e)return;let i=t.parent.childAfter(t.parentOffset);if((!i.node||!i.node.marks.some(d=>d.type===e))&&(i=t.parent.childBefore(t.parentOffset)),!i.node||!i.node.marks.some(d=>d.type===e)||(n=n||((r=i.node.marks[0])==null?void 0:r.attrs),!ere([...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&&_W([...t.parent.child(o-1).marks],e,n);)o-=1,l-=t.parent.child(o).nodeSize;for(;c<t.parent.childCount&&_W([...t.parent.child(c).marks],e,n);)u+=t.parent.child(c).nodeSize,c+=1;return{from:l,to:u}}function Cu(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 PGe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const a=Cu(t,r.schema),{doc:o,selection:l}=n,{$from:c,from:u,to:d}=l;if(i){const f=GL(c,a,e);if(f&&f.from<=u&&f.to>=d){const m=fn.create(o,f.from,f.to);n.setSelection(m)}}return!0},RGe=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 tre(t){return t instanceof fn}function yf(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function nre(t,e=null){if(!e)return null;const n=Nn.atStart(t),r=Nn.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,yf(0,i,a),yf(t.content.size,i,a)):fn.create(t,yf(e,i,a),yf(e,i,a))}function wW(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function hM(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function DGe(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var OGe=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:a})=>{e={scrollIntoView:!0,...e};const o=()=>{(hM()||wW())&&r.dom.focus(),DGe()&&!hM()&&!wW()&&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&&!tre(n.state.selection))return o(),!0;const l=nre(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},LGe=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),IGe=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),rre=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&&rre(r)}return t};function O1(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 rre(n)}function cy(t,e,n){if(t instanceof Gd||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),cy("",e,n)}if(i){if(n.errorOnInvalidContent){let o=!1,l="";const c=new zte({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?u0.fromSchema(c).parseSlice(O1(t),n.parseOptions):u0.fromSchema(c).parse(O1(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const a=u0.fromSchema(e);return n.slice?a.parseSlice(O1(t),n.parseOptions).content:a.parse(O1(t),n.parseOptions)}return cy("",e,n)}function FGe(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(Nn.near(t.doc.resolve(o),n))}var UGe=t=>!("type"in t),zGe=(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{cy(e,a.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(x){c(x)}try{l=cy(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((UGe(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 y;if(m){if(Array.isArray(e))y=e.map(x=>x.text||"").join("");else if(e instanceof At){let x="";e.forEach(v=>{v.text&&(x+=v.text)}),y=x}else typeof e=="object"&&e&&e.text?y=e.text:y=e;r.insertText(y,d,f)}else{y=l;const x=r.doc.resolve(d),v=x.node(),S=x.parentOffset===0,M=v.isText||v.isTextblock,E=v.content.size>0;S&&M&&E&&(d=Math.max(0,d-1)),r.replaceWith(d,f,y)}n.updateSelection&&FGe(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:y}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:y})}return!0},BGe=()=>({state:t,dispatch:e})=>dHe(t,e),$Ge=()=>({state:t,dispatch:e})=>hHe(t,e),HGe=()=>({state:t,dispatch:e})=>sne(t,e),VGe=()=>({state:t,dispatch:e})=>une(t,e),GGe=()=>({state:t,dispatch:e,tr:n})=>{try{const r=vE(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,tr:n})=>{try{const r=vE(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},qGe=()=>({state:t,dispatch:e})=>cHe(t,e),KGe=()=>({state:t,dispatch:e})=>uHe(t,e);function ire(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function XGe(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))hM()||ire()?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 YGe=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const a=XGe(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 oh(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=>dM(f.node.attrs,n,{strict:!1}));return a?!!u.length:u.reduce((f,m)=>f+m.to-m.from,0)>=c}var QGe=(t,e={})=>({state:n,dispatch:r})=>{const i=Ti(t,n.schema);return oh(n,i,e)?fHe(n,r):!1},ZGe=()=>({state:t,dispatch:e})=>mne(t,e),JGe=t=>({state:e,dispatch:n})=>{const r=Ti(t,e.schema);return NHe(r)(e,n)},e7e=()=>({state:t,dispatch:e})=>hne(t,e);function TE(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function SW(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 t7e=(t,e)=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null;const l=TE(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(a=Ti(t,r.schema)),l==="mark"&&(o=Cu(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,SW(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(SW(m.attrs,e))))})})}),c},n7e=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),r7e=()=>({tr:t,dispatch:e})=>{if(e){const n=new Ys(t.doc);t.setSelection(n)}return!0},i7e=()=>({state:t,dispatch:e})=>lne(t,e),a7e=()=>({state:t,dispatch:e})=>dne(t,e),s7e=()=>({state:t,dispatch:e})=>xHe(t,e),o7e=()=>({state:t,dispatch:e})=>vHe(t,e),l7e=()=>({state:t,dispatch:e})=>yHe(t,e);function QR(t,e,n={},r={}){return cy(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var c7e=(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=QR(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 are(t,e){const n=Cu(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 sre(t,e){const n=new nne(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function u7e(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 d7e(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,a)=>{n(i)&&r.push({node:i,pos:a})}),r}function h7e(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 CE(t){return e=>h7e(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 WL(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=en(e,"addExtensions",n);return r?[e,...WL(r())]:e}).flat(10)}function qL(t,e){const n=mm.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function ore(t){return typeof t=="function"}function or(t,e=void 0,...n){return ore(t)?e?t.bind(e)(...n):t(...n):t}function f7e(t={}){return Object.keys(t).length===0&&t.constructor===Object}function Bg(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 lre(t){const e=[],{nodeExtensions:n,markExtensions:r}=Bg(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 uy(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 m7e(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function MW(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):m7e(n.getAttribute(o.name));return l==null?a:{...a,[o.name]:l}},{});return{...r,...i}}}}function NW(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&f7e(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 p7e(t,e){var n;const r=lre(t),{nodeExtensions:i,markExtensions:a}=Bg(t),o=(n=i.find(u=>en(u,"topNode")))==null?void 0:n.name,l=Object.fromEntries(i.map(u=>{const d=r.filter(v=>v.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:e},m=t.reduce((v,S)=>{const M=en(S,"extendNodeSchema",f);return{...v,...M?M(u):{}}},{}),p=NW({...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(v=>MW(v,d)));const y=en(u,"renderHTML",f);y&&(p.toDOM=v=>y({node:v,HTMLAttributes:uy(v,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,v)=>{const S=en(v,"extendMarkSchema",f);return{...x,...S?S(u):{}}},{}),p=NW({...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=>MW(x,d)));const y=en(u,"renderHTML",f);return y&&(p.toDOM=x=>y({mark:x,HTMLAttributes:uy(x,d)})),[u.name,p]}));return new zte({topNode:o,nodes:l,marks:c})}function g7e(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function fM(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 cre(t){const e=fM(WL(t)),n=g7e(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 ure(t,e,n){const{from:r,to:i}=e,{blockSeparator:a=`
- `,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 x7e(t,e){const n={from:0,to:t.content.size};return ure(t,n,e)}function dre(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function b7e(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 hre(t,e){const n=TE(typeof e=="string"?e:e.name,t.schema);return n==="node"?b7e(t,e):n==="mark"?are(t,e):{}}function y7e(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 v7e(t){const e=y7e(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 fre(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}})})}),v7e(r)}function KL(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const a=n.resolve(t),o=GL(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 _7e=(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 L1(t,e){return e.nodes[t]||e.marks[t]||null}function vw(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 w7e=(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?Cu(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(f=>a?a.name===f.type.name:!0).find(f=>dM(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,(y,x)=>{if(!y.isText&&!y.marks.length)return;const v=Math.max(p,x),S=Math.min(b,x+y.nodeSize),M=S-v;o+=M,l.push(...y.marks.map(E=>({mark:E,from:v,to:S})))})}),o===0)return!1;const c=l.filter(f=>a?a.name===f.mark.type.name:!0).filter(f=>dM(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 S7e(t,e,n={}){if(!e)return oh(t,null,n)||ZR(t,null,n);const r=TE(e,t.schema);return r==="node"?oh(t,e,n):r==="mark"?ZR(t,e,n):!1}var M7e=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const a=CE(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)},N7e=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function AW(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function TW(t,e){const{nodeExtensions:n}=Bg(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 kE(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&&(kE(a,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function mre(t){return t instanceof nn}var pre=class gre{constructor(e){this.position=e}static fromJSON(e){return new gre(e.position)}toJSON(){return{position:this.position}}};function E7e(t,e){const n=e.mapping.mapResult(t.position);return{position:new pre(n.pos),mapResult:n}}function A7e(t){return new pre(t)}function T7e(t,e,n){var r;const{selection:i}=e;let a=null;if(tre(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(y=>y.type.excludes(n));u=p&&b}return!u}),u})}var C7e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:a}=n,{empty:o,ranges:l}=a,c=Cu(t,r.schema);if(i)if(o){const u=are(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),y=Math.min(p+m.nodeSize,f);m.marks.find(v=>v.type===c)?m.marks.forEach(v=>{c===v.type&&n.addMark(b,y,c.create({...v.attrs,...e}))}):n.addMark(b,y,c.create(e))})});return T7e(r,n,c)},k7e=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),j7e=(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})=>B9(a,{...o,...e})(n)?!0:l.clearNodes()).command(({state:l})=>B9(a,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},P7e=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=yf(t,0,r.content.size),a=nn.create(r,i);e.setSelection(a)}return!0},R7e=(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},D7e=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=yf(i,o,l),u=yf(a,o,l),d=fn.create(r,c,u);e.setSelection(d)}return!0},O7e=t=>({state:e,dispatch:n})=>{const r=Ti(t,e.schema);return THe(r)(e,n)};function CW(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 L7e=({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=vw(u,l.node().type.name,l.node().attrs);if(a instanceof nn&&a.node.isBlock)return!l.parentOffset||!cu(o,l.pos)?!1:(r&&(t&&CW(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:u7e(l.node(-1).contentMatchAt(l.indexAfter(-1)));let p=f&&m?[{type:m,attrs:d}]:void 0,b=cu(e.doc,e.mapping.map(l.pos),1,p);if(!p&&!b&&cu(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 y=e.mapping.map(l.before()),x=e.doc.resolve(y);l.node(-1).canReplaceWith(x.index(),x.index()+1,m)&&e.setNodeMarkup(e.mapping.map(l.before()),m)}t&&CW(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return b},I7e=(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 v=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)v=At.from(c.node(D).copy(v));const M=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,E={...vw(m,c.node().type.name,c.node().attrs),...e},A=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(E))||void 0;v=v.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(v,4-S,0));let T=-1;n.doc.nodesBetween(k,n.doc.content.size,(D,C)=>{if(T>-1)return!1;D.isTextblock&&D.content.size===0&&(T=C+1)}),T>-1&&n.setSelection(fn.near(n.doc.resolve(T))),n.scrollIntoView()}return!0}const p=u.pos===c.end()?f.contentMatchAt(0).defaultType:null,b={...vw(m,f.type.name,f.attrs),...e},y={...vw(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:y}]:[{type:l,attrs:b}];if(!cu(n.doc,c.pos,2))return!1;if(i){const{selection:v,storedMarks:S}=r,{splittableMarks:M}=a.extensionManager,E=S||v.$to.parentOffset&&v.$from.marks();if(n.split(c.pos,2,x).scrollIntoView(),!E||!i)return!0;const A=E.filter(k=>M.includes(k.type.name));n.ensureMarks(A)}return!0},Cj=(t,e)=>{const n=CE(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&&gh(t.doc,n.pos)&&t.join(n.pos),!0},kj=(t,e)=>{const n=CE(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&&gh(t.doc,r)&&t.join(r),!0},F7e=(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:y,storedMarks:x}=o,{$from:v,$to:S}=y,M=v.blockRange(S),E=x||y.$to.parentOffset&&y.$from.marks();if(!M)return!1;const A=CE(k=>TW(k.type.name,f))(y);if(M.depth>=1&&A&&M.depth-A.depth<=1){if(A.node.type===p)return u.liftListItem(b);if(TW(A.node.type.name,f)&&p.validContent(A.node.content)&&l)return c().command(()=>(a.setNodeMarkup(A.pos,p),!0)).command(()=>Cj(a,p)).command(()=>kj(a,p)).run()}return!n||!E||!l?c().command(()=>d().wrapInList(p,r)?!0:u.clearNodes()).wrapInList(p,r).command(()=>Cj(a,p)).command(()=>kj(a,p)).run():c().command(()=>{const k=d().wrapInList(p,r),T=E.filter(D=>m.includes(D.type.name));return a.ensureMarks(T),k?!0:u.clearNodes()}).wrapInList(p,r).command(()=>Cj(a,p)).command(()=>kj(a,p)).run()},U7e=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:a=!1}=n,o=Cu(t,r.schema);return ZR(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:a}):i.setMark(o,e)},z7e=(t,e,n={})=>({state:r,commands:i})=>{const a=Ti(t,r.schema),o=Ti(e,r.schema),l=oh(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})},B7e=(t,e={})=>({state:n,commands:r})=>{const i=Ti(t,n.schema);return oh(n,i,e)?r.lift(i):r.wrapIn(i,e)},$7e=()=>({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},H7e=()=>({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},V7e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var a;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=n,c=Cu(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,y=GL(u,c,b);y&&(m=y.from,p=y.to),n.removeMark(m,p,c)}else f.forEach(m=>{n.removeMark(m.$from.pos,m.$to.pos,c)});return n.removeStoredMark(c),!0},G7e=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},W7e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null;const l=TE(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(a=Ti(t,r.schema)),l==="mark"&&(o=Cu(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,y;n.selection.empty?r.doc.nodesBetween(d,f,(x,v)=>{a&&a===x.type&&(c=!0,b=Math.max(v,d),y=Math.min(v+x.nodeSize,f),m=v,p=x)}):r.doc.nodesBetween(d,f,(x,v)=>{v<d&&a&&a===x.type&&(c=!0,b=Math.max(v,d),y=Math.min(v+x.nodeSize,f),m=v,p=x),v>=d&&v<=f&&(a&&a===x.type&&(c=!0,i&&n.setNodeMarkup(v,void 0,{...x.attrs,...e})),o&&x.marks.length&&x.marks.forEach(S=>{if(o===S.type&&(c=!0,i)){const M=Math.max(v,d),E=Math.min(v+x.nodeSize,f);n.addMark(M,E,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,y,o.create({...x.attrs,...e}))}))}),c},q7e=(t,e={})=>({state:n,dispatch:r})=>{const i=Ti(t,n.schema);return _He(i,e)(n,r)},K7e=(t,e={})=>({state:n,dispatch:r})=>{const i=Ti(t,n.schema);return wHe(i,e)(n,r)},X7e=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={}}},jE=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},Y7e=(t,e)=>{if(VL(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 I1(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=w7e(u)+a;return o.forEach(m=>{if(d)return;const p=Y7e(f,m.find);if(!p)return;const b=c.state.tr,y=EE({state:c.state,transaction:b}),x={from:r-(p[0].length-a.length),to:i},{commands:v,chain:S,can:M}=new AE({editor:n,state:y});m.handler({state:y,range:x,match:p,commands:v,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 Q7e(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=qL(At.from(d),o.schema);const{from:f}=c,m=f+d.length;I1({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 I1({editor:e,from:a,to:o,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:a}=i.state.selection;a&&I1({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?I1({editor:e,from:o.pos,to:o.pos,text:`
- `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function Z7e(t){return Object.prototype.toString.call(t).slice(8,-1)}function F1(t){return Z7e(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function xre(t,e){const n={...t};return F1(t)&&F1(e)&&Object.keys(e).forEach(r=>{F1(e[r])&&F1(t[r])?n[r]=xre(t[r],e[r]):n[r]=e[r]}),n}var XL=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:()=>xre(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}},bh=class bre extends XL{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new bre(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 J7e(t){return typeof t=="number"}var e9e=class{constructor(t){this.find=t.find,this.handler=t.handler}},t9e=(t,e,n)=>{if(VL(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 n9e(t){const{editor:e,state:n,from:r,to:i,rule:a,pasteEvent:o,dropEvent:l}=t,{commands:c,chain:u,can:d}=new AE({editor:e,state:n}),f=[];return n.doc.nodesBetween(r,i,(p,b)=>{var y,x,v,S,M;if((x=(y=p.type)==null?void 0:y.spec)!=null&&x.code||!(p.isText||p.isTextblock||p.isInline))return;const E=(M=(S=(v=p.content)==null?void 0:v.size)!=null?S:p.nodeSize)!=null?M:0,A=Math.max(r,b),k=Math.min(i,b+E);if(A>=k)return;const T=p.isText?p.text||"":p.textBetween(A-b,k-b,void 0,"");t9e(T,a.find,o).forEach(C=>{if(C.index===void 0)return;const R=A+C.index+1,U=R+C[0].length,O={from:n.tr.mapping.map(R),to:n.tr.mapping.map(U)},q=a.handler({state:n,range:O,match:C,commands:c,chain:u,can:d,pasteEvent:o,dropEvent:l});f.push(q)})}),f.every(p=>p!==null)}var U1=null,r9e=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function i9e(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 y=d.tr,x=EE({state:d,transaction:y});if(!(!n9e({editor:e,state:x,from:Math.max(f-1,0),to:m.b-1,rule:p,pasteEvent:b,dropEvent:l})||!y.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,y}};return n.map(d=>new Yr({view(f){const m=b=>{var y;r=(y=f.dom.parentElement)!=null&&y.contains(b.target)?f.dom.parentElement:null,r&&(U1=e)},p=()=>{U1&&(U1=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=U1;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],y=b.getMeta("uiEvent")==="paste"&&!i,x=b.getMeta("uiEvent")==="drop"&&!a,v=b.getMeta("applyPasteRules"),S=!!v;if(!y&&!x&&!S)return;if(S){let{text:A}=v;typeof A=="string"?A=A:A=qL(At.from(A),p.schema);const{from:k}=v,T=k+A.length,D=r9e(A);return c({rule:d,state:p,from:k,to:{b:T},pasteEvt:D})}const M=m.doc.content.findDiffStart(p.doc.content),E=m.doc.content.findDiffEnd(p.doc.content);if(!(!J7e(M)||!E||M===E.b))return c({rule:d,state:p,from:M,to:E,pasteEvt:o})}}))}var PE=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=cre(t),this.schema=p7e(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:L1(e.name,this.schema)},r=en(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return fM([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:L1(r.name,this.schema)},a=[],o=en(r,"addKeyboardShortcuts",i);let l={};if(r.type==="mark"&&en(r,"exitable",i)&&(l.ArrowRight=()=>bh.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=bGe(l);a.push(c);const u=en(r,"addInputRules",i);if(AW(r,t.options.enableInputRules)&&u){const m=u();if(m&&m.length){const p=Q7e({editor:t,rules:m}),b=Array.isArray(p)?p:[p];a.push(...b)}}const d=en(r,"addPasteRules",i);if(AW(r,t.options.enablePasteRules)&&d){const m=d();if(m&&m.length){const p=i9e({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 lre(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=Bg(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=uy(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 fM([...this.extensions].reverse()).reduceRight((r,i)=>{const a={name:i.name,options:i.options,storage:this.editor.extensionStorage[i.name],editor:e,type:L1(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}=Bg(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:Cu(n.name,this.schema)},a=en(n,"addMarkView",i);if(!a)return[];const o=(l,c,u)=>{const d=uy(l,r);return a()({mark:l,view:c,inline:u,editor:t,extension:n,HTMLAttributes:d,updateAttributes:f=>{y9e(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:L1(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)})}};PE.resolve=cre;PE.sort=fM;PE.flatten=WL;var a9e={};HL(a9e,{ClipboardTextSerializer:()=>vre,Commands:()=>_re,Delete:()=>wre,Drop:()=>Sre,Editable:()=>Mre,FocusEvents:()=>Ere,Keymap:()=>Are,Paste:()=>Tre,Tabindex:()=>Cre,TextDirection:()=>kre,focusEventsPluginKey:()=>Nre});var br=class yre extends XL{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new yre(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},vre=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=dre(n);return ure(r,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),_re=br.create({name:"commands",addCommands(){return{...Jne}}}),wre=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=sre(t.before,[t,...e]);fre(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,y)=>{const x=y+b.nodeSize-2,v=p.oldRange.from<=y&&x<=p.oldRange.to;this.editor.emit("delete",{type:"node",node:b,from:y,to:x,newFrom:d.mapping.map(y),newTo:d.mapping.map(x),deletedRange:p.oldRange,newRange:p.newRange,partial:!v,editor:this.editor,transaction:t,combinedTransform:d})})});const m=d.mapping;d.steps.forEach((p,b)=>{var y,x;if(p instanceof il){const v=m.slice(b).map(p.from,-1),S=m.slice(b).map(p.to),M=m.invert().map(v,-1),E=m.invert().map(S),A=(y=d.doc.nodeAt(v-1))==null?void 0:y.marks.some(T=>T.eq(p.mark)),k=(x=d.doc.nodeAt(S))==null?void 0:x.marks.some(T=>T.eq(p.mark));this.editor.emit("delete",{type:"mark",mark:p.mark,from:p.from,to:p.to,deletedRange:{from:M,to:E},newRange:{from:v,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()}}),Sre=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})}}})]}}),Mre=br.create({name:"editable",addProseMirrorPlugins(){return[new Yr({key:new Vi("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Nre=new Vi("focusEvents"),Ere=br.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Yr({key:Nre,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}}}})]}}),Are=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,y=b.parent.type.spec.isolating,x=f.pos-f.parentOffset,v=y&&b.parent.childCount===1?x===f.pos:Nn.atStart(u).from===m;return!d||!p.type.isTextblock||p.textContent.length||!v||v&&f.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},a={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return hM()||ire()?a:i},addProseMirrorPlugins(){return[new Yr({key:new Vi("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(y=>y.getMeta("composition")))return;const r=t.some(y=>y.docChanged)&&!e.doc.eq(n.doc),i=t.some(y=>y.getMeta("preventClearDocument"));if(!r||i)return;const{empty:a,from:o,to:l}=e.selection,c=Nn.atStart(e.doc).from,u=Nn.atEnd(e.doc).to;if(a||!(o===c&&l===u)||!kE(n.doc))return;const m=n.tr,p=EE({state:n,transaction:m}),{commands:b}=new AE({editor:this.editor,state:p});if(b.clearNodes(),!!m.steps.length)return m}})]}}),Tre=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})}}})]}}),Cre=br.create({name:"tabindex",addProseMirrorPlugins(){return[new Yr({key:new Vi("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),kre=br.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=Bg(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}:{}}}})]}}),s9e=class Yb{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 Yb(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 Yb(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 Yb(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 Yb(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)}},o9e=`.ProseMirror {
- position: relative;
- }
- .ProseMirror {
- word-wrap: break-word;
- white-space: pre-wrap;
- white-space: break-spaces;
- -webkit-font-variant-ligatures: none;
- font-variant-ligatures: none;
- font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
- }
- .ProseMirror [contenteditable="false"] {
- white-space: normal;
- }
- .ProseMirror [contenteditable="false"] [contenteditable="true"] {
- white-space: pre-wrap;
- }
- .ProseMirror pre {
- white-space: pre-wrap;
- }
- img.ProseMirror-separator {
- display: inline !important;
- border: none !important;
- margin: 0 !important;
- width: 0 !important;
- height: 0 !important;
- }
- .ProseMirror-gapcursor {
- display: none;
- pointer-events: none;
- position: absolute;
- margin: 0;
- }
- .ProseMirror-gapcursor:after {
- content: "";
- display: block;
- position: absolute;
- top: -2px;
- width: 20px;
- border-top: 1px solid black;
- animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
- }
- @keyframes ProseMirror-cursor-blink {
- to {
- visibility: hidden;
- }
- }
- .ProseMirror-hideselection *::selection {
- background: transparent;
- }
- .ProseMirror-hideselection *::-moz-selection {
- background: transparent;
- }
- .ProseMirror-hideselection * {
- caret-color: transparent;
- }
- .ProseMirror-focused .ProseMirror-gapcursor {
- display: block;
- }`;function l9e(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 c9e=class extends X7e{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:A7e},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=nre(e,this.options.autofocus);this.editorState=Qp.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=l9e(o9e,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=ore(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?[Mre,vre.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),_re,Ere,Are,Cre,Sre,Tre,wre,kre.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 PE(r,this)}createCommandManager(){this.commandManager=new AE({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=QR(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=QR(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 Qne(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 hre(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return S7e(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return qL(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
- `,textSerializers:n={}}=t||{};return x7e(this.state.doc,{blockSeparator:e,textSerializers:{...dre(this.schema),...n}})}get isEmpty(){return kE(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 s9e(e,this)}get $doc(){return this.$pos(0)}};function $g(t){return new jE({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(KL(n.from,n.to,e.doc).filter(p=>p.mark.type.excluded.find(y=>y===t.type&&y!==p.mark.type)).filter(p=>p.to>u).length)return null;d<n.to&&a.delete(d,n.to),u>n.from&&a.delete(n.from+c,u);const m=n.from+c+o.length;a.addMark(n.from+c,m,t.type.create(i||{})),a.removeStoredMark(t.type)}},undoable:t.undoable})}function jre(t){return new jE({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 JR(t){return new jE({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 Hg(t){return new jE({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&&AL(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 y=b.filter(x=>p.includes(x.type.name));o.ensureMarks(y)}}if(t.keepAttributes){const f=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(f,a).run()}const d=o.doc.resolve(n.from-1).nodeBefore;d&&d.type===t.type&&gh(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,d))&&o.join(n.from-1)},undoable:t.undoable})}var u9e=t=>"touches"in t,d9e=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,u9e(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 h9e(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 f9e={};HL(f9e,{createAtomBlockMarkdownSpec:()=>m9e,createBlockMarkdownSpec:()=>p9e,createInlineMarkdownSpec:()=>b9e,parseAttributes:()=>YL,parseIndentedBlocks:()=>eD,renderNestedMarkdownContent:()=>ZL,serializeAttributes:()=>QL});function YL(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 QL(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 m9e(t){const{nodeName:e,name:n,parseAttributes:r=YL,serializeAttributes:i=QL,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 y=b[1]||"",x=r(y);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 p9e(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=YL,serializeAttributes:a=QL,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 y=r(f);p=typeof y=="string"?[{type:"text",text:y}]:y}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 y=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),x=f.match(y);if(!x)return;const[v,S=""]=x,M=i(S);let E=1;const A=v.length;let k="";const T=/^:::([\w-]*)(\s.*)?/gm,D=f.slice(A);for(T.lastIndex=0;;){const C=T.exec(D);if(C===null)break;const R=C.index,U=C[1];if(!((b=C[2])!=null&&b.endsWith(":::"))){if(U)E+=1;else if(E-=1,E===0){const O=D.slice(0,R);k=O.trim();const q=f.slice(0,A+R+C[0].length);let j=[];if(k)if(l==="block")for(j=p.blockTokens(O),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),y=b?` {${b}}`:"",x=m.renderChildren(f.content||[],`
- `);return`:::${u}${y}
- ${x}
- :::`}}}function g9e(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 x9e(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function b9e(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=g9e,serializeAttributes:a=x9e,defaultAttributes:o={},selfClosing:l=!1,allowedAttributes:c}=t,u=n||e,d=m=>{if(!c)return m;const p={};return c.forEach(b=>{const y=typeof b=="string"?b:b.name,x=typeof b=="string"?void 0:b.skipIfDefault;if(y in m){const v=m[y];if(x!==void 0&&v===x)return;p[y]=v}}),p},f=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(m,p)=>{const b={...o,...m.attributes};if(l)return p.createNode(e,b);const y=r?r(m):m.content||"";return y?p.createNode(e,b,[p.createTextNode(y)]):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),y=b?.index;return y!==void 0?y:-1},tokenize(m,p,b){const y=l?new RegExp(`^\\[${f}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${f}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${f}\\]`),x=m.match(y);if(!x)return;let v="",S="";if(l){const[,E]=x;S=E}else{const[,E,A]=x;S=E,v=A||""}const M=i(S.trim());return{type:e,raw:x[0],content:v.trim(),attributes:M}}},renderMarkdown:m=>{let p="";r?p=r(m):m.content&&m.content.length>0&&(p=m.content.filter(v=>v.type==="text").map(v=>v.text).join(""));const b=d(m.attrs||{}),y=a(b),x=y?` ${y}`:"";return l?`[${u}${x}]`:`[${u}${x}]${p}[/${u}]`}}}function eD(t,e,n){var r,i,a,o;const l=t.split(`
- `),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}
- `;continue}else return}const b=e.extractItemData(p),{indentLevel:y,mainContent:x}=b;u=`${u}${m}
- `;const v=[x];for(d+=1;d<l.length;){const A=l[d];if(A.trim()===""){const T=l.slice(d+1).findIndex(R=>R.trim()!=="");if(T===-1)break;if((((i=(r=l[d+1+T].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:i.length)||0)>y){v.push(A),u=`${u}${A}
- `,d+=1;continue}else break}if((((o=(a=A.match(/^(\s*)/))==null?void 0:a[1])==null?void 0:o.length)||0)>y)v.push(A),u=`${u}${A}
- `,d+=1;else break}let S;const M=v.slice(1);if(M.length>0){const A=M.map(k=>k.slice(y+f)).join(`
- `);A.trim()&&(e.customNestedParser?S=e.customNestedParser(A):S=n.blockTokens(A))}const E=e.createToken(b,S);c.push(E)}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(`
- `).map(m=>m?e.indent(m):"").join(`
- `);c.push(f)}}),c.join(`
- `)}function y9e(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 Pre extends XL{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new Pre(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function om(t){return new e9e({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(KL(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:v9e,getOwnPropertySymbols:_9e}=Object,{hasOwnProperty:w9e}=Object.prototype;function jj(t,e){return function(r,i,a){return t(r,i,a)&&e(r,i,a)}}function z1(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 S9e(t){return t?.[Symbol.toStringTag]}function kW(t){return v9e(t).concat(_9e(t))}const M9e=Object.hasOwn||((t,e)=>w9e.call(t,e));function pm(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const N9e="__v",E9e="__o",A9e="_owner",{getOwnPropertyDescriptor:jW,keys:PW}=Object;function T9e(t,e){return t.byteLength===e.byteLength&&mM(new Uint8Array(t),new Uint8Array(e))}function C9e(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 k9e(t,e){return t.byteLength===e.byteLength&&mM(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function j9e(t,e){return pm(t.getTime(),e.getTime())}function P9e(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function R9e(t,e){return t===e}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.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 D9e=pm;function O9e(t,e,n){const r=PW(t);let i=r.length;if(PW(e).length!==i)return!1;for(;i-- >0;)if(!Rre(t,e,n,r[i]))return!1;return!0}function Rb(t,e,n){const r=kW(t);let i=r.length;if(kW(e).length!==i)return!1;let a,o,l;for(;i-- >0;)if(a=r[i],!Rre(t,e,n,a)||(o=jW(t,a),l=jW(e,a),(o||l)&&(!o||!l||o.configurable!==l.configurable||o.enumerable!==l.enumerable||o.writable!==l.writable)))return!1;return!0}function L9e(t,e){return pm(t.valueOf(),e.valueOf())}function I9e(t,e){return t.source===e.source&&t.flags===e.flags}function DW(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 mM(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 F9e(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 Rre(t,e,n,r){return(r===A9e||r===E9e||r===N9e)&&(t.$$typeof||e.$$typeof)?!0:M9e(e,r)&&n.equals(t[r],e[r],r,r,t,e,n)}const U9e="[object ArrayBuffer]",z9e="[object Arguments]",B9e="[object Boolean]",$9e="[object DataView]",H9e="[object Date]",V9e="[object Error]",G9e="[object Map]",W9e="[object Number]",q9e="[object Object]",K9e="[object RegExp]",X9e="[object Set]",Y9e="[object String]",Q9e={"[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]",J9e=Object.prototype.toString;function eWe({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,v,S){if(x===v)return!0;if(x==null||v==null)return!1;const M=typeof x;if(M!==typeof v)return!1;if(M!=="object")return M==="number"?l(x,v,S):M==="function"?a(x,v,S):!1;const E=x.constructor;if(E!==v.constructor)return!1;if(E===Object)return c(x,v,S);if(Array.isArray(x))return e(x,v,S);if(E===Date)return r(x,v,S);if(E===RegExp)return d(x,v,S);if(E===Map)return o(x,v,S);if(E===Set)return f(x,v,S);const A=J9e.call(x);if(A===H9e)return r(x,v,S);if(A===K9e)return d(x,v,S);if(A===G9e)return o(x,v,S);if(A===X9e)return f(x,v,S);if(A===q9e)return typeof x.then!="function"&&typeof v.then!="function"&&c(x,v,S);if(A===Z9e)return p(x,v,S);if(A===V9e)return i(x,v,S);if(A===z9e)return c(x,v,S);if(Q9e[A])return m(x,v,S);if(A===U9e)return t(x,v,S);if(A===$9e)return n(x,v,S);if(A===B9e||A===W9e||A===Y9e)return u(x,v,S);if(b){let k=b[A];if(!k){const T=S9e(x);T&&(k=b[T])}if(k)return k(x,v,S)}return!1}}function tWe({circular:t,createCustomConfig:e,strict:n}){let r={areArrayBuffersEqual:T9e,areArraysEqual:n?Rb:C9e,areDataViewsEqual:k9e,areDatesEqual:j9e,areErrorsEqual:P9e,areFunctionsEqual:R9e,areMapsEqual:n?jj(RW,Rb):RW,areNumbersEqual:D9e,areObjectsEqual:n?Rb:O9e,arePrimitiveWrappersEqual:L9e,areRegExpsEqual:I9e,areSetsEqual:n?jj(DW,Rb):DW,areTypedArraysEqual:n?jj(mM,Rb):mM,areUrlsEqual:F9e,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),t){const i=z1(r.areArraysEqual),a=z1(r.areMapsEqual),o=z1(r.areObjectsEqual),l=z1(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:i,areMapsEqual:a,areObjectsEqual:o,areSetsEqual:l})}return r}function nWe(t){return function(e,n,r,i,a,o,l){return t(e,n,l)}}function rWe({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 iWe=yh();yh({strict:!0});yh({circular:!0});yh({circular:!0,strict:!0});yh({createInternalComparator:()=>pm});yh({strict:!0,createInternalComparator:()=>pm});yh({circular:!0,createInternalComparator:()=>pm});yh({circular:!0,createInternalComparator:()=>pm,strict:!0});function yh(t={}){const{circular:e=!1,createInternalComparator:n,createState:r,strict:i=!1}=t,a=tWe(t),o=eWe(a),l=n?n(o):nWe(o);return rWe({circular:e,comparator:o,createState:r,equals:l,strict:i})}var aWe=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},sWe=({contentComponent:t})=>{const e=_D.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return s.jsx(s.Fragment,{children:Object.values(e)})};function oWe(){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]:$ce.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 lWe=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=oWe(),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:aWe(e,this.editorContentRef),...n}),t?.contentComponent&&s.jsx(sWe,{contentComponent:t.contentComponent})]})}},cWe=w.forwardRef((t,e)=>{const n=Ur.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return Ur.createElement(lWe,{key:n,innerRef:e,...t})}),uWe=Ur.memo(cWe),dWe=typeof window<"u"?w.useLayoutEffect:w.useEffect,hWe=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 fWe(t){var e;const[n]=w.useState(()=>new hWe(t.editor)),r=fX.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:iWe);return dWe(()=>n.watch(t.editor),[t.editor,n]),w.useDebugValue(r),r}var mWe=!1,tD=typeof window>"u",pWe=tD||!!(typeof window<"u"&&window.next),gWe=class Dre{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?tD||pWe?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 c9e(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?Dre.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 xWe(t={},e=[]){const n=w.useRef(t);n.current=t;const[r]=w.useState(()=>new gWe(n)),i=_D.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return w.useDebugValue(i),w.useEffect(r.onRender(e)),fWe({editor:i,selector:({transactionNumber:a})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&a===0?0:a+1}),i}var bWe=w.createContext({editor:null});bWe.Consumer;var yWe=w.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),vWe=()=>w.useContext(yWe);Ur.forwardRef((t,e)=>{const{onDragStart:n}=vWe(),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 pM=(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]},_We=/^\s*>\s$/,wWe=As.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return pM("blockquote",{...li(this.options.HTMLAttributes,t),children:pM("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",r=[];return t.content.forEach(i=>{const l=e.renderChildren([i]).split(`
- `).map(c=>c.trim()===""?n:`${n} ${c}`);r.push(l.join(`
- `))}),r.join(`
- ${n}
- `)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Hg({find:_We,type:this.type})]}}),SWe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,MWe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,NWe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,EWe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,AWe=bh.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 pM("strong",{...li(this.options.HTMLAttributes,t),children:pM("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[$g({find:SWe,type:this.type}),$g({find:NWe,type:this.type})]},addPasteRules(){return[om({find:MWe,type:this.type}),om({find:EWe,type:this.type})]}}),TWe=/(^|[^`])`([^`]+)`(?!`)$/,CWe=/(^|[^`])`([^`]+)`(?!`)/g,kWe=bh.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[$g({find:TWe,type:this.type})]},addPasteRules(){return[om({find:CWe,type:this.type})]}}),Pj=4,jWe=/^```([a-z]+)?[\s\n]$/,PWe=/^~~~([a-z]+)?[\s\n]$/,RWe=As.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Pj,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(`
- `):r=`\`\`\`${i}
- \`\`\``,r},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:Pj,{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,`
- `,`
- `).split(`
- `).map(b=>l+b).join(`
- `);return c.replaceWith(u,d,r.schema.text(p)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:Pj,{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,`
- `,`
- `).split(`
- `);let b=0,y=0;const x=u-d;for(let k=0;k<p.length;k+=1){if(y+p[k].length>=x){b=k;break}y+=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 E=d;for(let k=0;k<b;k+=1)E+=p[k].length+1;return l.delete(E,E+M),u-E<=M&&l.setSelection(fn.create(l.doc,E)),!0}):t.commands.command(({tr:l})=>{const{from:c,to:u}=i,m=r.doc.textBetween(c,u,`
- `,`
- `).split(`
- `).map(p=>{var b;const y=((b=p.match(/^ */))==null?void 0:b[0])||"",x=Math.min(y.length,n);return p.slice(x)}).join(`
- `);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(`
- `);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(Nn.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[JR({find:jWe,type:this.type,getAttributes:t=>({language:t[1]})}),JR({find:PWe,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,`
- `));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}}})]}}),DWe=As.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):""}),OWe=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`
- `},renderMarkdown:()=>`
- `,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:i,storedMarks:a}=n;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks: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()}}}),LWe=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=>JR({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),IWe=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(!h9e(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return mre(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[jre({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),FWe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,UWe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,zWe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,BWe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,$We=bh.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[$g({find:FWe,type:this.type}),$g({find:zWe,type:this.type})]},addPasteRules(){return[om({find:UWe,type:this.type}),om({find:BWe,type:this.type})]}});const HWe="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",VWe="ελ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",nD="numeric",rD="ascii",iD="alpha",m0="asciinumeric",Qb="alphanumeric",aD="domain",Ore="emoji",GWe="scheme",WWe="slashscheme",Rj="whitespace";function qWe(t,e){return t in e||(e[t]=[]),e[t]}function vf(t,e,n){e[nD]&&(e[m0]=!0,e[Qb]=!0),e[rD]&&(e[m0]=!0,e[iD]=!0),e[m0]&&(e[Qb]=!0),e[iD]&&(e[Qb]=!0),e[Qb]&&(e[aD]=!0),e[Ore]&&(e[aD]=!0);for(const r in e){const i=qWe(r,n);i.indexOf(t)<0&&i.push(t)}}function KWe(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function bs(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}bs.groups={};bs.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||bs.groups;let i;return e&&e.j?i=e:(i=new bs(e),n&&r&&vf(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||bs.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 bs,Object.assign(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new bs,a){if(r)if(o.t&&typeof o.t=="string"){const c=Object.assign(KWe(o.t,r),n);vf(a,c,r)}else n&&vf(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),OW=(t,e,n,r,i)=>t.ts(e,n,r,i),jt=(t,e,n,r,i)=>t.tt(e,n,r,i),Gc="WORD",sD="UWORD",Lre="ASCIINUMERICAL",Ire="ALPHANUMERICAL",dy="LOCALHOST",oD="TLD",lD="UTLD",_w="SCHEME",Vp="SLASH_SCHEME",JL="NUM",cD="WS",eI="NL",p0="OPENBRACE",g0="CLOSEBRACE",gM="OPENBRACKET",xM="CLOSEBRACKET",bM="OPENPAREN",yM="CLOSEPAREN",vM="OPENANGLEBRACKET",_M="CLOSEANGLEBRACKET",wM="FULLWIDTHLEFTPAREN",SM="FULLWIDTHRIGHTPAREN",MM="LEFTCORNERBRACKET",NM="RIGHTCORNERBRACKET",EM="LEFTWHITECORNERBRACKET",AM="RIGHTWHITECORNERBRACKET",TM="FULLWIDTHLESSTHAN",CM="FULLWIDTHGREATERTHAN",kM="AMPERSAND",jM="APOSTROPHE",PM="ASTERISK",_d="AT",RM="BACKSLASH",DM="BACKTICK",OM="CARET",Ad="COLON",tI="COMMA",LM="DOLLAR",Pl="DOT",IM="EQUALS",nI="EXCLAMATION",bo="HYPHEN",x0="PERCENT",FM="PIPE",UM="PLUS",zM="POUND",b0="QUERY",rI="QUOTE",Fre="FULLWIDTHMIDDLEDOT",iI="SEMI",Rl="SLASH",y0="TILDE",BM="UNDERSCORE",Ure="EMOJI",$M="SYM";var zre=Object.freeze({__proto__:null,ALPHANUMERICAL:Ire,AMPERSAND:kM,APOSTROPHE:jM,ASCIINUMERICAL:Lre,ASTERISK:PM,AT:_d,BACKSLASH:RM,BACKTICK:DM,CARET:OM,CLOSEANGLEBRACKET:_M,CLOSEBRACE:g0,CLOSEBRACKET:xM,CLOSEPAREN:yM,COLON:Ad,COMMA:tI,DOLLAR:LM,DOT:Pl,EMOJI:Ure,EQUALS:IM,EXCLAMATION:nI,FULLWIDTHGREATERTHAN:CM,FULLWIDTHLEFTPAREN:wM,FULLWIDTHLESSTHAN:TM,FULLWIDTHMIDDLEDOT:Fre,FULLWIDTHRIGHTPAREN:SM,HYPHEN:bo,LEFTCORNERBRACKET:MM,LEFTWHITECORNERBRACKET:EM,LOCALHOST:dy,NL:eI,NUM:JL,OPENANGLEBRACKET:vM,OPENBRACE:p0,OPENBRACKET:gM,OPENPAREN:bM,PERCENT:x0,PIPE:FM,PLUS:UM,POUND:zM,QUERY:b0,QUOTE:rI,RIGHTCORNERBRACKET:NM,RIGHTWHITECORNERBRACKET:AM,SCHEME:_w,SEMI:iI,SLASH:Rl,SLASH_SCHEME:Vp,SYM:$M,TILDE:y0,TLD:oD,UNDERSCORE:BM,UTLD:lD,UWORD:sD,WORD:Gc,WS:cD});const Bc=/[a-z]/,Db=new RegExp("\\p{L}","u"),Dj=new RegExp("\\p{Emoji}","u"),$c=/\d/,Oj=/\s/,LW="\r",Lj=`
- `,XWe="️",YWe="",Ij="";let B1=null,$1=null;function QWe(t=[]){const e={};bs.groups=e;const n=new bs;B1==null&&(B1=IW(HWe)),$1==null&&($1=IW(VWe)),jt(n,"'",jM),jt(n,"{",p0),jt(n,"}",g0),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,"」",NM),jt(n,"『",EM),jt(n,"』",AM),jt(n,"<",TM),jt(n,">",CM),jt(n,"&",kM),jt(n,"*",PM),jt(n,"@",_d),jt(n,"`",DM),jt(n,"^",OM),jt(n,":",Ad),jt(n,",",tI),jt(n,"$",LM),jt(n,".",Pl),jt(n,"=",IM),jt(n,"!",nI),jt(n,"-",bo),jt(n,"%",x0),jt(n,"|",FM),jt(n,"+",UM),jt(n,"#",zM),jt(n,"?",b0),jt(n,'"',rI),jt(n,"/",Rl),jt(n,";",iI),jt(n,"~",y0),jt(n,"_",BM),jt(n,"\\",RM),jt(n,"・",Fre);const r=Jr(n,$c,JL,{[nD]:!0});Jr(r,$c,r);const i=Jr(r,Bc,Lre,{[m0]:!0}),a=Jr(r,Db,Ire,{[Qb]:!0}),o=Jr(n,Bc,Gc,{[rD]:!0});Jr(o,$c,i),Jr(o,Bc,o),Jr(i,$c,i),Jr(i,Bc,i);const l=Jr(n,Db,sD,{[iD]:!0});Jr(l,Bc),Jr(l,$c,a),Jr(l,Db,l),Jr(a,$c,a),Jr(a,Bc),Jr(a,Db,a);const c=jt(n,Lj,eI,{[Rj]:!0}),u=jt(n,LW,cD,{[Rj]:!0}),d=Jr(n,Oj,cD,{[Rj]:!0});jt(n,Ij,d),jt(u,Lj,c),jt(u,Ij,d),Jr(u,Oj,d),jt(d,LW),jt(d,Lj),Jr(d,Oj,d),jt(d,Ij,d);const f=Jr(n,Dj,Ure,{[Ore]:!0});jt(f,"#"),Jr(f,Dj,f),jt(f,XWe,f);const m=jt(f,YWe);jt(m,"#"),Jr(m,Dj,f);const p=[[Bc,o],[$c,i]],b=[[Bc,null],[Db,l],[$c,a]];for(let y=0;y<B1.length;y++)fd(n,B1[y],oD,Gc,p);for(let y=0;y<$1.length;y++)fd(n,$1[y],lD,sD,b);vf(oD,{tld:!0,ascii:!0},e),vf(lD,{utld:!0,alpha:!0},e),fd(n,"file",_w,Gc,p),fd(n,"mailto",_w,Gc,p),fd(n,"http",Vp,Gc,p),fd(n,"https",Vp,Gc,p),fd(n,"ftp",Vp,Gc,p),fd(n,"ftps",Vp,Gc,p),vf(_w,{scheme:!0,ascii:!0},e),vf(Vp,{slashscheme:!0,ascii:!0},e),t=t.sort((y,x)=>y[0]>x[0]?1:-1);for(let y=0;y<t.length;y++){const x=t[y][0],S=t[y][1]?{[GWe]:!0}:{[WWe]:!0};x.indexOf("-")>=0?S[aD]=!0:Bc.test(x)?$c.test(x)?S[m0]=!0:S[rD]=!0:S[nD]=!0,OW(n,x,x,S)}return OW(n,"localhost",dy,{ascii:!0}),n.jd=new bs($M),{start:n,tokens:Object.assign({groups:e},zre)}}function Bre(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 fd(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 bs(r),a.jr=i.slice(),t.j[c]=a),t=a}return a=new bs(n),a.jr=i.slice(),t.j[e[o-1]]=a,a}function IW(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 hy={defaultProtocol:"http",events:null,format:FW,formatHref:FW,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function aI(t,e=null){let n=Object.assign({},hy);t&&(n=Object.assign(n,t instanceof aI?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}aI.prototype={o:hy,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]:hy[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 FW(t){return t}function $re(t,e){this.t="token",this.v=t,this.tk=e}$re.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=hy.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 RE(t,e){class n extends $re{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 UW=RE("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),zW=RE("text"),JWe=RE("nl"),H1=RE("url",{isLink:!0,toHref(t=hy.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==dy&&t[1].t===Ad}}),po=t=>new bs(t);function eqe({groups:t}){const e=t.domain.concat([kM,PM,_d,RM,DM,OM,LM,IM,bo,JL,x0,FM,UM,zM,Rl,$M,y0,BM]),n=[jM,Ad,tI,Pl,nI,x0,b0,rI,iI,vM,_M,p0,g0,xM,gM,bM,yM,wM,SM,MM,NM,EM,AM,TM,CM],r=[kM,jM,PM,RM,DM,OM,LM,IM,bo,p0,g0,x0,FM,UM,zM,b0,Rl,$M,y0,BM],i=po(),a=jt(i,y0);_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,_d);jt(a,_d,u),jt(l,_d,u),jt(c,_d,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(UW);_n(m,t.tld,p),_n(m,t.utld,p),jt(u,dy,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 y=jt(p,Ad);_n(y,t.numeric,UW);const x=jt(o,bo),v=jt(o,Pl);jt(x,bo,x),_n(x,t.domain,o),_n(v,r,a),_n(v,t.domain,o);const S=po(H1);_n(v,t.tld,S),_n(v,t.utld,S),_n(S,t.domain,o),_n(S,r,a),jt(S,Pl,v),jt(S,bo,x),jt(S,_d,u);const M=jt(S,Ad),E=po(H1);_n(M,t.numeric,E);const A=po(H1),k=po();_n(A,e,A),_n(A,n,k),_n(k,e,A),_n(k,n,k),jt(S,Rl,A),jt(E,Rl,A);const T=jt(l,Ad),D=jt(c,Ad),C=jt(D,Rl),R=jt(C,Rl);_n(l,t.domain,o),jt(l,Pl,v),jt(l,bo,x),_n(c,t.domain,o),jt(c,Pl,v),jt(c,bo,x),_n(T,t.domain,A),jt(T,Rl,A),jt(T,b0,A),_n(R,t.domain,A),_n(R,e,A),jt(R,Rl,A);const U=[[p0,g0],[gM,xM],[bM,yM],[vM,_M],[wM,SM],[MM,NM],[EM,AM],[TM,CM]];for(let O=0;O<U.length;O++){const[q,j]=U[O],W=jt(A,q);jt(k,q,W),jt(W,j,A);const X=po(H1);_n(W,e,X);const G=po();_n(W,n),_n(X,e,X),_n(X,n,G),_n(G,e,X),_n(G,n,G),jt(X,j,A),jt(G,j,A)}return jt(i,dy,S),jt(i,eI,JWe),{start:i,tokens:zre}}function tqe(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(Fj(zW,e,o)),o=[]),i-=m,d-=m;const p=f.t,b=n.slice(i-d,i);a.push(Fj(p,e,b))}}return o.length>0&&a.push(Fj(zW,e,o)),a}function Fj(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 nqe=typeof console<"u"&&console&&console.warn||(()=>{}),rqe="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 iqe(){return bs.groups={},Or.scanner=null,Or.parser=null,Or.tokenQueue=[],Or.pluginQueue=[],Or.customSchemes=[],Or.initialized=!1,Or}function BW(t,e=!1){if(Or.initialized&&nqe(`linkifyjs: already initialized - will not register custom scheme "${t}" ${rqe}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
- 1. Must only contain digits, lowercase ASCII letters or "-"
- 2. Cannot start or end with "-"
- 3. "-" cannot repeat`);Or.customSchemes.push([t,e])}function aqe(){Or.scanner=QWe(Or.customSchemes);for(let t=0;t<Or.tokenQueue.length;t++)Or.tokenQueue[t][1]({scanner:Or.scanner});Or.parser=eqe(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 sI(t){return Or.initialized||aqe(),tqe(Or.parser.start,t,Bre(Or.scanner.start,t))}sI.scan=Bre;function Hre(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 aI(n),i=sI(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 oI="[\0- -\u2029 ]",sqe=new RegExp(oI),oqe=new RegExp(`${oI}$`),lqe=new RegExp(oI,"g");function cqe(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function uqe(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=sre(n.doc,[...e]);if(fre(l).forEach(({newRange:u})=>{const d=d7e(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(!oqe.test(p))return;f=d[0],m=r.doc.textBetween(f.pos,u.to,void 0," ")}if(f&&m){const p=m.split(sqe).filter(Boolean);if(p.length<=0)return!1;const b=p[p.length-1],y=f.pos+m.lastIndexOf(b);if(!b)return!1;const x=sI(b).map(v=>v.toObject(t.defaultProtocol));if(!cqe(x))return!1;x.filter(v=>v.isLink).map(v=>({...v,from:y+v.start+1,to:y+v.end+1})).filter(v=>r.schema.marks.code?!r.doc.rangeHasMark(v.from,v.to,r.schema.marks.code):!0).filter(v=>t.validate(v.value)).filter(v=>t.shouldAutoLink(v.value)).forEach(v=>{KL(v.from,v.to,r.doc).some(S=>S.mark.type===t.type)||o.addMark(v.from,v.to,t.type.create({href:v.href}))})}}),!!o.steps.length)return o}})}function dqe(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=hre(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 hqe(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=Hre(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 Kh(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(lqe,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var Vre=bh.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"){BW(t);return}BW(t.scheme,t.optionalSlashes)})},onDestroy(){iqe()},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)=>!!Kh(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=>!!Kh(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=>!!Kh(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=>!!Kh(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=>!!Kh(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[om({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=Hre(t).filter(a=>a.isLink&&this.options.isAllowedUri(a.value,{defaultValidate:o=>!!Kh(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(uqe({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!Kh(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(dqe({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(hqe({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),fqe=Vre,mqe=Object.defineProperty,pqe=(t,e)=>{for(var n in e)mqe(t,n,{get:e[n],enumerable:!0})},gqe="listItem",$W="textStyle",HW=/^\s*([-+*])\s$/,Gre=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,`
- `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(gqe,this.editor.getAttributes($W)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Hg({find:HW,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Hg({find:HW,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes($W),editor:this.editor})),[t]}}),Wre=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)}}}),xqe={};pqe(xqe,{findListItemPos:()=>Qy,getNextListDepth:()=>lI,handleBackspace:()=>uD,handleDelete:()=>dD,hasListBefore:()=>qre,hasListItemAfter:()=>bqe,hasListItemBefore:()=>Kre,listItemHasSubList:()=>Xre,nextListIsDeeper:()=>Yre,nextListIsHigher:()=>Qre});var Qy=(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}},lI=(t,e)=>{const n=Qy(t,e);if(!n)return!1;const[,r]=_7e(e,t,n.$pos.pos+4);return r},qre=(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))},Kre=(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)},Xre=(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},uD=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!oh(t.state,e)&&qre(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(!oh(t.state,e)||!N7e(t.state))return!1;const r=Qy(e,t.state);if(!r)return!1;const a=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=Xre(e,t.state,a);return Kre(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},Yre=(t,e)=>{const n=lI(t,e),r=Qy(t,e);return!r||!n?!1:n>r.depth},Qre=(t,e)=>{const n=lI(t,e),r=Qy(t,e);return!r||!n?!1:n<r.depth},dD=(t,e)=>{if(!oh(t.state,e)||!M7e(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:Yre(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():Qre(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},bqe=(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&&dD(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&&dD(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&&uD(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&&uD(t,n,r)&&(e=!0)}),e}}}}),VW=/^(\s*)(\d+)\.\s+(.*)$/,yqe=/^\s/;function vqe(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n],a=i.match(VW);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(VW))break;if(p.trim()==="")m.push(p),d+=`
- `,f+=1;else if(p.match(yqe))m.push(p),d+=`
- ${p.slice(u+2)}`,f+=1;else break}e.push({indent:u,number:parseInt(l,10),content:d.trim(),raw:m.join(`
- `)}),r=f,n=f}return[e,r]}function Jre(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(`
- `),c=((r=l[0])==null?void 0:r.trim())||"",u=[];c&&u.push({type:"paragraph",raw:c,tokens:n.inlineTokens(c)});const d=l.slice(1).join(`
- `).trim();if(d){const p=n.blockTokens(d);u.push(...p)}let f=a+1;const 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(y=>y.indent)),b=Jre(m,p,n);u.push({type:"list",ordered:!0,start:m[0].number,items:b,raw:m.map(y=>y.raw).join(`
- `)})}i.push({type:"list_item",raw:o.raw,tokens:u}),a=f}else a+=1}return i}function _qe(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 wqe="listItem",GW="textStyle",WW=/^(\d+)\.\s$/,eie=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?_qe(t.items,e):[];return n!==1?{type:"orderedList",attrs:{start:n},content:r}:{type:"orderedList",content:r}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(/^(\s*)(\d+)\.\s+/),n=e?.index;return n!==void 0?n:-1},tokenize:(t,e,n)=>{var r;const i=t.split(`
- `),[a,o]=vqe(i);if(a.length===0)return;const l=Jre(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(`
- `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(wqe,this.editor.getAttributes(GW)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Hg({find:WW,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=Hg({find:WW,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(GW)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),Sqe=/^\s*(\[([( |x])?\])\s$/,Mqe=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 y=p.doc.nodeAt(b);return p.setNodeMarkup(b,void 0,{...y?.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=uy(f,m),b=new Set(Object.keys(p)),y=this.options.HTMLAttributes;return d.forEach(x=>{b.has(x)||(x in y?i.setAttribute(x,y[x]):i.removeAttribute(x))}),Object.entries(p).forEach(([x,v])=>{v==null?x in y?i.setAttribute(x,y[x]):i.removeAttribute(x):i.setAttribute(x,v)}),d=b,!0}}}},addInputRules(){return[Hg({find:Sqe,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),Nqe=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,`
- `):"",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=eD(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=eD(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(Gre.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(Wre.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(Zre.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(eie.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(Mqe.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(Nqe.configure(this.options.taskList)),t}});var qW=" ",Eqe=" ",Aqe=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===qW||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?qW:e.renderChildren(n)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Tqe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Cqe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,kqe=bh.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[$g({find:Tqe,type:this.type})]},addPasteRules(){return[om({find:Cqe,type:this.type})]}}),jqe=As.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),tie=bh.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()}}}),Pqe=tie;function Rqe(t={}){return new Yr({view(e){return new Dqe(e,t)}})}class Dqe{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(),y=f?b.bottom:b.top;f&&m&&(y=(y+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let x=this.width/2*l;r={left:b.left,right:b.right,top:y-x,bottom:y+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=Qte(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 Nn{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return ii.valid(r)?new ii(r):Nn.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 cI(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!Oqe(e)||!Lqe(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;Nn.jsonID("gapcursor",ii);class cI{constructor(e){this.pos=e}map(e){return new cI(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return ii.valid(n)?new ii(n):Nn.near(n)}}function nie(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function Oqe(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||nie(i.type))return!0;if(i.inlineContent)return!1}}return!0}function Lqe(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||nie(i.type))return!0;if(i.inlineContent)return!1}}return!0}function Iqe(){return new Yr({props:{decorations:Bqe,createSelectionBetween(t,e,n){return e.pos==n.pos&&ii.valid(n)?new ii(n):null},handleClick:Uqe,handleKeyDown:Fqe,handleDOMEvents:{beforeinput:zqe}}})}const Fqe=Zne({ArrowLeft:V1("horiz",-1),ArrowRight:V1("horiz",1),ArrowUp:V1("vert",-1),ArrowDown:V1("vert",1)});function V1(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 Uqe(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 zqe(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 Bqe(t){if(!(t.selection instanceof ii))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Vr.create(t.doc,[Za.widget(t.selection.head,e,{key:"gapcursor"})])}var HM=200,ia=function(){};ia.prototype.append=function(e){return e.length?(e=ia.from(e),!this.length&&e||e.length<HM&&this.leafAppend(e)||this.length<HM&&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 $qe(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 rie(e):ia.empty};var rie=(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<=HM)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=HM)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 rie([]);var $qe=(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 Hqe=500;class tl{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 tl(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>Gqe&&(l=Vqe(l,u),o-=u),new tl(l.append(a),o)}remapping(e,n){let r=new iy;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 tl(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 y=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,y,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 tl(d,l);return f.emptyItemCount()>Hqe&&(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 tl(ia.from(i.reverse()),a)}}tl.empty=new tl(ia.empty,0);function Vqe(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 wd{constructor(e,n,r,i,a){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=a}}const Gqe=20;function Wqe(t,e,n,r){let i=n.getMeta(Df),a;if(i)return i.historyState;n.getMeta(Xqe)&&(t=new wd(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(Df))return o.getMeta(Df).redo?new wd(t.done.addTransform(n,void 0,r,ww(e)),t.undone,KW(n.mapping.maps),t.prevTime,t.prevComposition):new wd(t.done,t.undone.addTransform(n,void 0,r,ww(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||!qqe(n,t.prevRanges)),u=o?Uj(t.prevRanges,n.mapping):KW(n.mapping.maps);return new wd(t.done.addTransform(n,c?e.selection.getBookmark():void 0,r,ww(e)),tl.empty,u,n.time,l??t.prevComposition)}else return(a=n.getMeta("rebased"))?new wd(t.done.rebased(n,a),t.undone.rebased(n,a),Uj(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new wd(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Uj(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function qqe(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 KW(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 Uj(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 Kqe(t,e,n){let r=ww(e),i=Df.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 wd(n?l:a.remaining,n?a.remaining:l,null,0,-1);return a.transform.setSelection(o).setMeta(Df,{redo:n,historyState:c})}let zj=!1,XW=null;function ww(t){let e=t.plugins;if(XW!=e){zj=!1,XW=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){zj=!0;break}}return zj}const Df=new Vi("history"),Xqe=new Vi("closeHistory");function Yqe(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Yr({key:Df,state:{init(){return new wd(tl.empty,tl.empty,null,0,-1)},apply(e,n,r){return Wqe(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?aie:r=="historyRedo"?sie:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function iie(t,e){return(n,r)=>{let i=Df.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let a=Kqe(i,n,t);a&&r(e?a.scrollIntoView():a)}return!0}}const aie=iie(!1,!0),sie=iie(!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 Qqe=br.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Rqe(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(Za.node(u,u+c.nodeSize,{class:this.options.className}))}),Vr.create(t,a)}}})]}});var Zqe=br.create({name:"gapCursor",addProseMirrorPlugins(){return[Iqe()]},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&&kE(o);if((c||!this.options.showOnlyCurrent)&&u){const d=[this.options.emptyNodeClass];a&&d.push(this.options.emptyEditorClass);const f=Za.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||mre(n.selection)||t.view.dragging?null:Vr.create(n.doc,[Za.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function YW({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var Jqe=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!YW({node:o,types:r})},apply:(i,a)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return a;const o=i.doc.lastChild;return!YW({node:o,types:r})}}})]}}),eKe=br.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>aie(t,e),redo:()=>({state:t,dispatch:e})=>sie(t,e)}},addProseMirrorPlugins(){return[Yqe(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()}}}),tKe=br.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push(AWe.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(wWe.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(Gre.configure(this.options.bulletList)),this.options.code!==!1&&i.push(kWe.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(RWe.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(DWe.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(Qqe.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(Zqe.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(OWe.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(LWe.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(eKe.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(IWe.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push($We.configure(this.options.italic)),this.options.listItem!==!1&&i.push(Wre.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(Vre.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(eie.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(Aqe.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(kqe.configure(this.options.strike)),this.options.text!==!1&&i.push(jqe.configure(this.options.text)),this.options.underline!==!1&&i.push(tie.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(Jqe.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),nKe=tKe,rKe=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")}}}),iKe=rKe,aKe=20,oie=(t,e=0)=>{const n=[];return!t.children.length||e>aKe||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...oie(r,e+1))}),n},sKe=t=>{if(!t.children.length)return;const e=oie(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}`)})},lie=bh.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&sKe(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}}}}),oKe=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()}}}),cie=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()}}}),lKe=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()}}}),cKe=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()}}}),uKe=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(oKe.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(cie.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(lKe.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(cKe.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(uKe.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(lie.configure(this.options.textStyle)),t}});var dKe=cie,hKe=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,fKe=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?``:``},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 d9e({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[jre({find:hKe,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),mKe=fKe;function hD({content:t,onChange:e,placeholder:n}){const r=xWe({extensions:[nKe.configure({heading:!1,codeBlock:!1,code:!1}),Pqe,fqe.configure({openOnClick:!1,HTMLAttributes:{target:"_blank",rel:"noopener noreferrer"}}),iKe.configure({types:["paragraph"]}),lie,dKe,mKe.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(Fue,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().toggleItalic().run(),isActive:r.isActive("italic"),title:"Italic",children:s.jsx(Che,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().toggleUnderline().run(),isActive:r.isActive("underline"),title:"Underline",children:s.jsx(bme,{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(cN,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().toggleOrderedList().run(),isActive:r.isActive("orderedList"),title:"Numbered List",children:s.jsx(pK,{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(ume,{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(sme,{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(lme,{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(Yg,{className:"w-4 h-4"})}),r.isActive("link")&&s.jsx(i,{onClick:()=>r.chain().focus().unsetLink().run(),title:"Remove Link",children:s.jsx($D,{className:"w-4 h-4"})})]}),s.jsx(uWe,{editor:r})]})}function uie({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:()=>fe.getArchiveProjectPage(t)}),p=pt({mutationFn:A=>fe.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?v():n())};return document.addEventListener("keydown",A),()=>document.removeEventListener("keydown",A)},[o,i,n]);const b=[...d?.model_pictures||[],...d?.profile_pictures||[]],y=()=>{u({title:d?.title||"",description:d?.description||"",designer:d?.designer||"",license:d?.license||"",profile_title:d?.profile_title||"",profile_description:d?.profile_description||""}),a(!0)},x=()=>{p.mutate(c)},v=()=>{a(!1),u({})},S=A=>{const k=["p","br","b","strong","i","em","u","a","ul","ol","li","figure","img"],T=new DOMParser().parseFromString(A,"text/html"),D=C=>{if(C.nodeType===Node.TEXT_NODE)return C.textContent||"";if(C.nodeType===Node.ELEMENT_NODE){const R=C,U=R.tagName.toLowerCase();if(!k.includes(U))return Array.from(R.childNodes).map(D).join("");let O="";if(U==="a"&&R.getAttribute("href")){const j=R.getAttribute("href");j?.toLowerCase().startsWith("http")&&(O=` href="${j}" target="_blank" rel="noopener noreferrer"`)}if(U==="img"){const j=R.getAttribute("src");if(!j?.toLowerCase().startsWith("http"))return"";O=` src="${j}" style="max-width: 100%; height: auto;"`}const q=Array.from(R.childNodes).map(D).join("");return["br","img"].includes(U)?`<${U}${O} />`:`<${U}${O}>${q}</${U}>`}return""};return Array.from(T.body.childNodes).map(D).join("")},M=d&&(d.title||d.description||d.designer||d.profile_title||b.length>0),E=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:E,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:y,children:[s.jsx(zf,{className:"w-4 h-4 mr-1"}),"Edit"]}),i&&s.jsxs(s.Fragment,{children:[s.jsx(Me,{variant:"ghost",size:"sm",onClick:v,children:"Cancel"}),s.jsxs(Me,{variant:"primary",size:"sm",onClick:x,disabled:p.isPending,children:[s.jsx(ys,{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(Ht,{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(wP,{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(wP,{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(hD,{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(hD,{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(yy,{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(Ff,{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(Qs,{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(Ht,{className:"w-6 h-6 text-white"})}),s.jsxs("div",{className:"absolute bottom-4 text-white text-sm",children:[o+1," / ",b.length]})]})]})}const pKe=[.25,.5,.75,1,1.5,2,3,4];function Lp(t){const e=Math.floor(t/60),n=Math.floor(t%60);return`${e}:${n.toString().padStart(2,"0")}`}function gKe({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),[y,x]=w.useState(0),[v,S]=w.useState(1),[M,E]=w.useState(null),[A,k]=w.useState(null),[T,D]=w.useState(.8),[C,R]=w.useState(!1),{data:U,isLoading:O}=ft({queryKey:["timelapse-info",t],queryFn:()=>fe.getTimelapseInfo(t)}),{data:q}=ft({queryKey:["timelapse-thumbnails",t],queryFn:()=>fe.getTimelapseThumbnails(t,15)}),j=pt({mutationFn:()=>fe.processTimelapse(t,{trimStart:p,trimEnd:y,speed:v,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&&y===0&&x(U.duration)},[U?.duration,y]),w.useEffect(()=>{const z=V=>{V.key==="Escape"&&n()};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[n]),w.useEffect(()=>{const z=a.current;if(!z)return;const V=()=>{const me=z.currentTime;d(me),me>=y&&(z.currentTime=p)},ne=()=>{m(z.duration),y===0&&x(z.duration)},ie=()=>c(!0),he=()=>c(!1);return z.addEventListener("timeupdate",V),z.addEventListener("durationchange",ne),z.addEventListener("play",ie),z.addEventListener("pause",he),()=>{z.removeEventListener("timeupdate",V),z.removeEventListener("durationchange",ne),z.removeEventListener("play",ie),z.removeEventListener("pause",he)}},[p,y]),w.useEffect(()=>{const z=o.current,V=a.current;!z||!V||!A||(z.currentTime=V.currentTime,z.playbackRate=V.playbackRate,l&&!C?z.play().catch(()=>{}):z.pause())},[l,A,C]),w.useEffect(()=>{o.current&&(o.current.volume=C?0:T)},[T,C]),w.useEffect(()=>{a.current&&(a.current.playbackRate=v),o.current&&(o.current.playbackRate=v)},[v]);const W=w.useCallback(()=>{const z=a.current;z&&(l?z.pause():(z.currentTime<p&&(z.currentTime=p),z.play()))},[l,p]),X=z=>{const V=a.current;V&&(V.currentTime=Math.max(p,Math.min(y,z)))},G=z=>{const V=z.target.files?.[0];V&&(A&&URL.revokeObjectURL(A),E(V),k(URL.createObjectURL(V)))},Z=()=>{A&&URL.revokeObjectURL(A),E(null),k(null)};w.useEffect(()=>()=>{A&&URL.revokeObjectURL(A)},[A]);const te=y-p,ee=te/v;return O?s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:s.jsxs("div",{className:"flex items-center gap-3 text-white",children:[s.jsx(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(Fd,{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(ys,{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(Ht,{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(cl,{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(Dfe,{className:"w-4 h-4"}),s.jsx("span",{children:"Trim"}),s.jsxs("span",{className:"ml-auto",children:[Lp(p)," - ",Lp(y)," (",Lp(te),")"]})]}),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,V)=>s.jsx("div",{className:"flex-1 bg-cover bg-center",style:{backgroundImage:`url(data:image/jpeg;base64,${z})`}},V))}),s.jsx("div",{className:"absolute inset-y-0 left-0 bg-black/60",style:{width:`${p/f*100}%`}}),s.jsx("div",{className:"absolute inset-y-0 right-0 bg-black/60",style:{width:`${(f-y)/f*100}%`}}),s.jsx("div",{className:"absolute inset-y-0 border-2 border-bambu-green",style:{left:`${p/f*100}%`,right:`${(f-y)/f*100}%`}}),s.jsx("div",{className:"absolute top-0 bottom-0 w-0.5 bg-white shadow-lg",style:{left:`${u/f*100}%`}}),s.jsx("input",{type:"range",min:0,max:f,step:.1,value:p,onChange:z=>{const V=parseFloat(z.target.value);V<y-1&&(b(V),a.current&&a.current.currentTime<V&&(a.current.currentTime=V))},className:"absolute inset-0 w-full opacity-0 cursor-ew-resize",style:{clipPath:"inset(0 50% 0 0)"}}),s.jsx("input",{type:"range",min:0,max:f,step:.1,value:y,onChange:z=>{const V=parseFloat(z.target.value);V>p+1&&x(V)},className:"absolute inset-0 w-full opacity-0 cursor-ew-resize",style:{clipPath:"inset(0 0 0 50%)"}})]}),s.jsx("input",{type:"range",min:0,max:f,step:.1,value:u,onChange:z=>X(parseFloat(z.target.value)),className:`w-full h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
- [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
- [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full
- [&::-webkit-slider-thumb]:cursor-pointer`}),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(zD,{className:"w-5 h-5 text-white"}):s.jsx(cl,{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(aN,{className:"w-4 h-4"}),s.jsx("span",{children:"Speed"}),s.jsxs("span",{className:"ml-auto",children:[v,"x (output: ",Lp(ee),")"]})]}),s.jsx("div",{className:"flex gap-1",children:pKe.map(z=>s.jsxs("button",{onClick:()=>S(z),className:`flex-1 px-2 py-2 text-sm rounded transition-colors ${v===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(vP,{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(vP,{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(!C),className:"p-2 hover:bg-bambu-dark-tertiary rounded transition-colors",children:C?s.jsx(Ame,{className:"w-4 h-4 text-bambu-gray"}):s.jsx(Nme,{className:"w-4 h-4 text-bambu-green"})}),s.jsx("input",{type:"range",min:0,max:1,step:.1,value:T,onChange:z=>D(parseFloat(z.target.value)),className:`w-20 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
- [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
- [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full`}),s.jsx("button",{onClick:Z,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:G,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:"})," ",Lp(f)," @ ",U?.width,"x",U?.height]}),s.jsxs("p",{className:"text-bambu-gray",children:[s.jsx("span",{className:"text-white",children:"Output:"})," ",Lp(ee)," @ ",v,"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 xKe=[.25,.5,.75,1,1.5,2,3,4];function die({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),[y,x]=w.useState(!1);w.useEffect(()=>{const T=o.current;T&&(T.playbackRate=u)},[u]),w.useEffect(()=>{const T=D=>{D.key==="Escape"&&i()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[i]),w.useEffect(()=>{const T=o.current;if(!T)return;const D=()=>m(T.currentTime),C=()=>b(T.duration),R=()=>c(!0),U=()=>c(!1);return T.addEventListener("timeupdate",D),T.addEventListener("durationchange",C),T.addEventListener("play",R),T.addEventListener("pause",U),()=>{T.removeEventListener("timeupdate",D),T.removeEventListener("durationchange",C),T.removeEventListener("play",R),T.removeEventListener("pause",U)}},[]);const v=()=>{const T=o.current;T&&(l?T.pause():T.play())},S=T=>{const D=o.current;D&&(D.currentTime=parseFloat(T.target.value))},M=()=>{const T=o.current;T&&(T.currentTime=Math.max(0,T.currentTime-5))},E=()=>{const T=o.current;T&&(T.currentTime=Math.min(p,T.currentTime+5))},A=T=>{const D=Math.floor(T/60),C=Math.floor(T%60);return`${D}:${C.toString().padStart(2,"0")}`},k=()=>{const T=document.createElement("a");T.href=t,T.download=n,T.click()};return s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:[s.jsxs("div",{className:"relative bg-bambu-dark-secondary rounded-xl max-w-4xl w-full mx-4 overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Fd,{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(sa,{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(Ht,{className:"w-5 h-5 text-bambu-gray"})})]})]}),s.jsxs("div",{className:"p-4",children:[s.jsx("video",{ref:o,src:t,autoPlay:!0,className:"w-full rounded-lg",onClick:v}),s.jsxs("div",{className:"mt-4 space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"text-xs text-bambu-gray w-12 text-right",children:A(f)}),s.jsx("input",{type:"range",min:0,max:p||100,value:f,onChange:S,className:`flex-1 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
- [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
- [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full
- [&::-webkit-slider-thumb]:cursor-pointer`}),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(Gfe,{className:"w-5 h-5 text-bambu-gray"})}),s.jsx("button",{onClick:v,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:l?s.jsx(zD,{className:"w-5 h-5 text-white"}):s.jsx(cl,{className:"w-5 h-5 text-white"})}),s.jsx("button",{onClick:E,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip forward 5s",children:s.jsx(Lw,{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:xKe.map(T=>s.jsxs("button",{onClick:()=>d(T),className:`px-2 py-1 text-xs rounded transition-colors ${u===T?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:bg-bambu-dark-tertiary/80"}`,children:[T,"x"]},T))})]})]})]})]})]}),y&&r&&s.jsx(gKe,{archiveId:r,timelapseSrc:t,onClose:()=>x(!1),onSave:a})]})}function bKe({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:()=>fe.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(Ht,{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(yKe,{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 yKe({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(ts,{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 vKe(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function _Ke(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 wKe({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,y]=w.useState(!1);return s.jsx(Et,{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(wf,{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:vKe(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"}),_Ke(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(hu,{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:()=>y(!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),y(!1)},onCancel:()=>y(!1)}),o&&s.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary space-y-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Tags"}),s.jsx("input",{type:"text",value:c,onChange: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 SKe(){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:Up.list,refetchInterval:1e4}),{data:m}=ft({queryKey:["projects"],queryFn:()=>fe.getProjects()}),p=pt({mutationFn:({id:v,data:S})=>Up.archive(v,S),onMutate:({id:v})=>{l(S=>new Set(S).add(v))},onSettled:(v,S,{id:M})=>{l(E=>{const A=new Set(E);return A.delete(M),A})},onSuccess:v=>{t.invalidateQueries({queryKey:["pending-uploads"]}),t.invalidateQueries({queryKey:["archives"]}),e(`Archived: ${v.print_name}`)},onError:v=>{e(v.message||"Failed to archive","error")}}),b=pt({mutationFn:v=>Up.discard(v),onMutate:v=>{u(S=>new Set(S).add(v))},onSettled:(v,S,M)=>{u(E=>{const A=new Set(E);return A.delete(M),A})},onSuccess:()=>{t.invalidateQueries({queryKey:["pending-uploads"]}),e("Upload discarded")},onError:v=>{e(v.message||"Failed to discard","error")}}),y=pt({mutationFn:Up.archiveAll,onSuccess:v=>{t.invalidateQueries({queryKey:["pending-uploads"]}),t.invalidateQueries({queryKey:["archives"]}),e(`Archived ${v.archived} files${v.failed>0?`, ${v.failed} failed`:""}`)},onError:v=>{e(v.message||"Failed to archive all","error")}}),x=pt({mutationFn:Up.discardAll,onSuccess:v=>{t.invalidateQueries({queryKey:["pending-uploads"]}),e(`Discarded ${v.discarded} files`)},onError:v=>{e(v.message||"Failed to discard all","error")}});return f?s.jsx(Et,{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(Et,{className:"border-l-4 border-l-yellow-500",children:[s.jsx(Nr,{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:y.isPending,children:y.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(v=>s.jsx(wKe,{upload:v,projects:m||[],onArchive:(S,M)=>p.mutate({id:S,data:M}),onDiscard:S=>b.mutate(S),isArchiving:o.has(v.id),isDiscarding:c.has(v.id)},v.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:()=>{y.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 VM(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Ob(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function of(t){if(!t)return!1;const e=t.toLowerCase();return e.endsWith(".gcode")||e.includes(".gcode.")}function MKe({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=CK(),[f,m]=w.useState(!1),[p,b]=w.useState(!1),[y,x]=w.useState(!1),[v,S]=w.useState(!1),[M,E]=w.useState(!1),[A,k]=w.useState(!1),[T,D]=w.useState([]),[C,R]=w.useState(!1),[U,O]=w.useState(!1),[q,j]=w.useState(!1),[W,X]=w.useState(!1),[G,Z]=w.useState(!1),[te,ee]=w.useState(!1),[z,V]=w.useState(null),ne=w.useRef(null),ie=w.useRef(null),he=pt({mutationFn:I=>fe.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")}}),me=pt({mutationFn:()=>fe.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=>fe.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")}}),Ae=pt({mutationFn:()=>fe.deleteF3d(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u("F3D removed")},onError:I=>{u(I.message||"Failed to remove F3D","error")}}),ge=pt({mutationFn:()=>fe.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")}}),Ne=pt({mutationFn:I=>fe.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")}}),_e=pt({mutationFn:()=>fe.deleteArchive(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u("Archive deleted")},onError:()=>{u("Failed to delete archive","error")}}),le=pt({mutationFn:()=>fe.toggleFavorite(t.id),onSuccess:I=>{c.invalidateQueries({queryKey:["archives"]}),u(I.is_favorite?"Added to favorites":"Removed from favorites")}}),{data:He}=ft({queryKey:["archive-folders",t.id],queryFn:()=>fe.getLibraryFoldersByArchive(t.id)}),H=pt({mutationFn:I=>fe.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")}}),J=I=>{I.preventDefault(),V({x:I.clientX,y:I.clientY})},B=[...of(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 I=t.print_name||t.filename||"model",ce=`${window.location.origin}${fe.getArchiveForSlicer(t.id,I)}`;Xc(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}${fe.getArchiveForSlicer(t.id,I)}`;Xc(ce)}}],{label:t.external_url?"External Link":"View on MakerWorld",icon:s.jsx(Ud,{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(Fd,{className:"w-4 h-4"}),onClick:()=>E(!0),disabled:!t.timelapse_path},{label:"Scan for Timelapse",icon:s.jsx(Ow,{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(jw,{className:"w-4 h-4"}),onClick:()=>{if(t.source_3mf_path){const I=document.createElement("a");I.href=fe.getSource3mfDownloadUrl(t.id),I.download=`${t.print_name||t.filename}_source.3mf`,I.click()}else ne.current?.click()}},...t.source_3mf_path?[{label:"Replace Source 3MF",icon:s.jsx(fi,{className:"w-4 h-4"}),onClick:()=>ne.current?.click()},{label:"Remove Source 3MF",icon:s.jsx(hn,{className:"w-4 h-4"}),onClick:()=>Z(!0),danger:!0}]:[],{label:t.f3d_path?"Replace F3D":"Upload F3D",icon:s.jsx(Bs,{className:"w-4 h-4"}),onClick:()=>ie.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=fe.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:()=>ee(!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=fe.getArchiveDownload(t.id),I.download=`${t.print_name||t.filename}.3mf`,I.click()}},{label:"Copy Download Link",icon:s.jsx(sl,{className:"w-4 h-4"}),onClick:()=>{const I=`${window.location.origin}${fe.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(yK,{className:"w-4 h-4"}),onClick:()=>R(!0)},{label:`View Photos${t.photos?.length?` (${t.photos.length})`:""}`,icon:s.jsx(mg,{className:"w-4 h-4"}),onClick:()=>O(!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(Bf,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>le.mutate()},{label:"Edit",icon:s.jsx(sa,{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(Ht,{className:"w-4 h-4"}),onClick:()=>H.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:()=>H.mutate(Ee.id),disabled:t.project_id===Ee.id})})}return I})()},{label:n?"Deselect":"Select",icon:n?s.jsx(Do,{className:"w-4 h-4"}):s.jsx(Oo,{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(Et,{"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:J,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(Do,{className:"w-5 h-5 text-bambu-green"}):s.jsx(Oo,{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:fe.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(yy,{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();V({x:ce.left,y:ce.bottom+4})},title:"Right-click for more options",children:s.jsx(Id,{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(),le.mutate()},title:t.is_favorite?"Remove from favorites":"Add to favorites",children:s.jsx(Bf,{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(sl,{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}${fe.getSource3mfForSlicer(t.id,ce)}`;Xc(Ee)},title:"Open source 3MF in Bambu Studio (right-click for more options)",children:s.jsx(jw,{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=fe.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(),E(!0)},title:"View timelapse",children:s.jsx(Fd,{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(),O(!0)},title:`View ${t.photos.length} photo${t.photos.length>1?"s":""}`,children:[s.jsx(mg,{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})]}),He&&He.length>0&&s.jsx(gs,{to:`/files?folder=${He[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: ${He[0].name}`,style:{left:t.source_3mf_path?t.f3d_path?"5.5rem":"3rem":t.f3d_path?"3rem":"0.5rem"},children:s.jsx(ol,{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 ${of(t.filename)?"bg-bambu-green/20 text-bambu-green":"bg-orange-500/20 text-orange-400"}`,title:of(t.filename)?"Sliced file - ready to print":"Source file only - no AMS mapping available",children:of(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: ${Ob(t.print_time_seconds||0)}
- Actual: ${Ob(t.actual_time_seconds||0)}
- Accuracy: ${t.time_accuracy.toFixed(0)}%`:t.actual_time_seconds?`Actual: ${Ob(t.actual_time_seconds)}`:`Estimated: ${Ob(t.print_time_seconds||0)}`,children:[s.jsx(Jn,{className:"w-3 h-3"}),Ob(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(Zl,{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(ll,{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(_K,{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:yg(t.created_at,l)}),s.jsx("span",{children:VM(t.file_size)})]}),s.jsxs("div",{className:"flex gap-1 mt-3",children:[of(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}${fe.getArchiveForSlicer(t.id,I)}`;Xc(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}${fe.getArchiveForSlicer(t.id,I)}`;Xc(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(Ud,{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=fe.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(sa,{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"})})]})]}),v&&s.jsx(_te,{archive:t,onClose:()=>S(!1)}),f&&s.jsx(xte,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>m(!1)}),p&&s.jsx(ah,{mode:"reprint",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>b(!1)}),y&&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:()=>{_e.mutate(),x(!1)},onCancel:()=>x(!1)}),G&&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:()=>{me.mutate(),Z(!1)},onCancel:()=>Z(!1)}),te&&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:()=>{Ae.mutate(),ee(!1)},onCancel:()=>ee(!1)}),z&&s.jsx(wte,{x:z.x,y:z.y,items:B,onClose:()=>V(null)}),M&&t.timelapse_path&&s.jsx(die,{src:fe.getArchiveTimelapse(t.id),title:`${t.print_name||t.filename} - Timelapse`,downloadFilename:`${t.print_name||t.filename}_timelapse.mp4`,archiveId:t.id,onClose:()=>E(!1),onEdit:()=>{c.invalidateQueries({queryKey:["archives"]}),E(!1)}}),A&&T.length>0&&s.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-card-dark rounded-lg max-w-lg w-full max-h-[80vh] flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Select Timelapse"}),s.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"No auto-match found. Select the timelapse for this print:"})]}),s.jsx("button",{onClick:()=>{k(!1),D([])},className:"text-gray-400 hover:text-white p-1",children:s.jsx(Ht,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:T.map(I=>s.jsxs("button",{onClick:()=>Ne.mutate(I.name),disabled:Ne.isPending,className:"w-full text-left p-3 rounded-lg hover:bg-gray-700 transition-colors flex items-center gap-3 disabled:opacity-50",children:[s.jsx(Fd,{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:[VM(I.size),I.mtime&&` • ${yg(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"})})]})}),C&&s.jsx(Ste,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>R(!1)}),U&&t.photos&&t.photos.length>0&&s.jsx(Mte,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>O(!1),onDelete:async I=>{try{await fe.deleteArchivePhoto(t.id,I),c.invalidateQueries({queryKey:["archives"]}),u("Photo deleted")}catch{u("Failed to delete photo","error")}}}),q&&s.jsx(uie,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>j(!1)}),W&&s.jsx(ah,{mode:"add-to-queue",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>X(!1)}),s.jsx("input",{ref:ne,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:ie,type:"file",accept:".f3d",className:"hidden",onChange:I=>{const ce=I.target.files?.[0];ce&&oe.mutate(ce),I.target.value=""}})]})}function NKe({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),[y,x]=w.useState(!1),[v,S]=w.useState(!1),[M,E]=w.useState(!1),[A,k]=w.useState(!1),[T,D]=w.useState([]),[C,R]=w.useState(!1),[U,O]=w.useState(!1),[q,j]=w.useState(!1),[W,X]=w.useState(!1),[G,Z]=w.useState(!1),[te,ee]=w.useState(null),z=w.useRef(null),V=w.useRef(null),ne=pt({mutationFn:K=>fe.uploadSource3mf(t.id,K),onSuccess:K=>{l.invalidateQueries({queryKey:["archives"]}),c(`Source 3MF attached: ${K.filename}`)},onError:K=>{c(K.message||"Failed to upload source 3MF","error")}}),ie=pt({mutationFn:()=>fe.deleteSource3mf(t.id),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),c("Source 3MF removed")},onError:K=>{c(K.message||"Failed to remove source 3MF","error")}}),he=pt({mutationFn:K=>fe.uploadF3d(t.id,K),onSuccess:K=>{l.invalidateQueries({queryKey:["archives"]}),c(`F3D attached: ${K.filename}`)},onError:K=>{c(K.message||"Failed to upload F3D","error")}}),me=pt({mutationFn:()=>fe.deleteF3d(t.id),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),c("F3D removed")},onError:K=>{c(K.message||"Failed to remove F3D","error")}}),oe=pt({mutationFn:()=>fe.scanArchiveTimelapse(t.id),onSuccess:K=>{K.status==="attached"?(l.invalidateQueries({queryKey:["archives"]}),c(`Timelapse attached: ${K.filename}`)):K.status==="exists"?c("Timelapse already attached"):K.status==="not_found"&&K.available_files&&K.available_files.length>0?(D(K.available_files),k(!0)):c(K.message||"No matching timelapse found","warning")},onError:K=>{c(K.message||"Failed to scan for timelapse","error")}}),Ae=pt({mutationFn:K=>fe.selectArchiveTimelapse(t.id,K),onSuccess:K=>{l.invalidateQueries({queryKey:["archives"]}),c(`Timelapse attached: ${K.filename}`),k(!1),D([])},onError:K=>{c(K.message||"Failed to attach timelapse","error")}}),ge=pt({mutationFn:()=>fe.deleteArchive(t.id),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),c("Archive deleted")},onError:()=>{c("Failed to delete archive","error")}}),Ne=pt({mutationFn:()=>fe.toggleFavorite(t.id),onSuccess:K=>{l.invalidateQueries({queryKey:["archives"]}),c(K.is_favorite?"Added to favorites":"Removed from favorites")}}),{data:_e}=ft({queryKey:["archive-folders",t.id],queryFn:()=>fe.getLibraryFoldersByArchive(t.id)}),le=pt({mutationFn:K=>fe.updateArchive(t.id,{project_id:K}),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),l.invalidateQueries({queryKey:["projects"]}),c("Project updated")},onError:()=>{c("Failed to update project","error")}}),He=K=>{K.preventDefault(),ee({x:K.clientX,y:K.clientY})},J=[...of(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 K=t.print_name||t.filename||"model",B=`${window.location.origin}${fe.getArchiveForSlicer(t.id,K)}`;Xc(B)}}]:[{label:"Slice",icon:s.jsx(Gr,{className:"w-4 h-4"}),onClick:()=>{const K=t.print_name||t.filename||"model",B=`${window.location.origin}${fe.getArchiveForSlicer(t.id,K)}`;Xc(B)}}],{label:t.external_url?"External Link":"View on MakerWorld",icon:s.jsx(Ud,{className:"w-4 h-4"}),onClick:()=>{const K=t.external_url||t.makerworld_url;K&&window.open(K,"_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(Fd,{className:"w-4 h-4"}),onClick:()=>E(!0),disabled:!t.timelapse_path},{label:"Scan for Timelapse",icon:s.jsx(Ow,{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(jw,{className:"w-4 h-4"}),onClick:()=>{if(t.source_3mf_path){const K=document.createElement("a");K.href=fe.getSource3mfDownloadUrl(t.id),K.download=`${t.print_name||t.filename}_source.3mf`,K.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:()=>X(!0),danger:!0}]:[],{label:t.f3d_path?"Replace F3D":"Upload F3D",icon:s.jsx(Bs,{className:"w-4 h-4"}),onClick:()=>V.current?.click()},...t.f3d_path?[{label:"Download F3D",icon:s.jsx($r,{className:"w-4 h-4"}),onClick:()=>{const K=document.createElement("a");K.href=fe.getF3dDownloadUrl(t.id),K.download=`${t.print_name||t.filename}.f3d`,K.click()}},{label:"Remove F3D",icon:s.jsx(hn,{className:"w-4 h-4"}),onClick:()=>Z(!0),danger:!0}]:[],{label:"",divider:!0,onClick:()=>{}},{label:"Download",icon:s.jsx($r,{className:"w-4 h-4"}),onClick:()=>{const K=document.createElement("a");K.href=fe.getArchiveDownload(t.id),K.download=`${t.print_name||t.filename}.3mf`,K.click()}},{label:"Copy Download Link",icon:s.jsx(sl,{className:"w-4 h-4"}),onClick:()=>{const K=`${window.location.origin}${fe.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(K).then(()=>{c("Link copied to clipboard")}).catch(()=>{c("Failed to copy link","error")})}},{label:"QR Code",icon:s.jsx(yK,{className:"w-4 h-4"}),onClick:()=>R(!0)},{label:`View Photos${t.photos?.length?` (${t.photos.length})`:""}`,icon:s.jsx(mg,{className:"w-4 h-4"}),onClick:()=>O(!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(Bf,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>Ne.mutate()},{label:"Edit",icon:s.jsx(sa,{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 K=[];if(t.project_id&&K.push({label:"Remove from Project",icon:s.jsx(Ht,{className:"w-4 h-4"}),onClick:()=>le.mutate(null)}),!a)K.push({label:"Loading...",icon:s.jsx(mt,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const B=a.filter(I=>I.status==="active");B.length===0?K.push({label:"No projects available",icon:s.jsx(Ea,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):B.forEach(I=>{K.push({label:I.name,icon:s.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:I.color||"#888"}}),onClick:()=>le.mutate(I.id),disabled:t.project_id===I.id})})}return K})()},{label:n?"Deselect":"Select",icon:n?s.jsx(Do,{className:"w-4 h-4"}):s.jsx(Oo,{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:He,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(Do,{className:"w-4 h-4 text-bambu-green"}):s.jsx(Oo,{className:"w-4 h-4 text-bambu-gray"})}),t.thumbnail_path?s.jsx("img",{src:fe.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(yy,{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(Fd,{className:"w-3.5 h-3.5 text-bambu-green flex-shrink-0"})}),_e&&_e.length>0&&s.jsx(gs,{to:`/files?folder=${_e[0].id}`,className:"flex-shrink-0",title:`Open folder: ${_e[0].name}`,onClick:K=>K.stopPropagation(),children:s.jsx(ol,{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((K,B)=>s.jsx("div",{className:"w-2.5 h-2.5 rounded-full border border-white/20",style:{backgroundColor:K},title:K},B))})]})]}),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:bg(t.created_at)}),s.jsx("div",{className:"col-span-1 text-sm text-bambu-gray",children:VM(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 K=t.print_name||t.filename||"model",B=`${window.location.origin}${fe.getArchiveForSlicer(t.id,K)}`;Xc(B)},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(Ud,{className:"w-4 h-4"})}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>{const K=document.createElement("a");K.href=fe.getArchiveDownload(t.id),K.download=`${t.print_name||t.filename}.3mf`,K.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(sa,{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:K=>{const B=K.currentTarget.getBoundingClientRect();ee({x:B.left,y:B.bottom+4})},title:"More options",children:s.jsx(Id,{className:"w-4 h-4"})})]})]}),u&&s.jsx(_te,{archive:t,onClose:()=>d(!1)}),v&&s.jsx(xte,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>S(!1)}),p&&s.jsx(ah,{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:()=>{ie.mutate(),X(!1)},onCancel:()=>X(!1)}),G&&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:()=>{me.mutate(),Z(!1)},onCancel:()=>Z(!1)}),te&&s.jsx(wte,{x:te.x,y:te.y,items:J,onClose:()=>ee(null)}),M&&t.timelapse_path&&s.jsx(die,{src:fe.getArchiveTimelapse(t.id),title:`${t.print_name||t.filename} - Timelapse`,downloadFilename:`${t.print_name||t.filename}_timelapse.mp4`,archiveId:t.id,onClose:()=>E(!1),onEdit:()=>{l.invalidateQueries({queryKey:["archives"]}),E(!1)}}),A&&T.length>0&&s.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-card-dark rounded-lg max-w-lg w-full max-h-[80vh] flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Select Timelapse"}),s.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"No auto-match found. Select the timelapse for this print:"})]}),s.jsx("button",{onClick:()=>{k(!1),D([])},className:"text-gray-400 hover:text-white p-1",children:s.jsx(Ht,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:T.map(K=>s.jsxs("button",{onClick:()=>Ae.mutate(K.name),disabled:Ae.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:K.name}),s.jsxs("div",{className:"text-sm text-gray-400 flex gap-3",children:[s.jsx("span",{children:VM(K.size)}),K.mtime&&s.jsx("span",{children:bg(K.mtime)})]})]},K.name))})]})}),C&&s.jsx(Ste,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>R(!1)}),U&&t.photos&&s.jsx(Mte,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>O(!1),onDelete:async K=>{try{await fe.deleteArchivePhoto(t.id,K),l.invalidateQueries({queryKey:["archives"]}),c("Photo deleted")}catch{c("Failed to delete photo","error")}}}),q&&s.jsx(uie,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>j(!1)}),y&&s.jsx(ah,{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:K=>{const B=K.target.files?.[0];B&&ne.mutate(B),K.target.value=""}}),s.jsx("input",{ref:V,type:"file",accept:".f3d",className:"hidden",onChange:K=>{const B=K.target.files?.[0];B&&he.mutate(B),K.target.value=""}})]})}const EKe=[{id:"all",label:"All Archives",icon:s.jsx(ol,{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(Bf,{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(sl,{className:"w-4 h-4"})}];function AKe(){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"),[y,x]=w.useState(()=>localStorage.getItem("archiveHideFailed")==="true"),[v,S]=w.useState(()=>localStorage.getItem("archiveFilterTag")),[M,E]=w.useState(()=>localStorage.getItem("archiveFilterFileType")||"all"),[A,k]=w.useState(!1),[T,D]=w.useState([]),[C,R]=w.useState(!1),[U,O]=w.useState(new Set),[q,j]=w.useState(!1),[W,X]=w.useState(!1),[G,Z]=w.useState(!1),[te,ee]=w.useState(!1),[z,V]=w.useState(()=>localStorage.getItem("archiveViewMode")||"grid"),[ne,ie]=w.useState(()=>localStorage.getItem("archiveSortBy")||"date-desc"),[he,me]=w.useState(()=>localStorage.getItem("archiveCollection")||"all"),[oe,Ae]=w.useState(!1),[ge,Ne]=w.useState(!1),[_e,le]=w.useState(!1),[He,H]=w.useState(null);w.useEffect(()=>{if(He){const re=setTimeout(()=>{const ve=document.querySelector(`[data-archive-id="${He}"]`);ve&&ve.scrollIntoView({behavior:"smooth",block:"center"})},100),Fe=setTimeout(()=>H(null),5e3);return()=>{clearTimeout(re),clearTimeout(Fe)}}},[He]);const{data:J,isLoading:K}=ft({queryKey:["archives",a],queryFn:()=>fe.getArchives(a||void 0)}),{data:B}=ft({queryKey:["printers"],queryFn:fe.getPrinters}),{data:I}=ft({queryKey:["projects"],queryFn:()=>fe.getProjects()}),{data:ce}=ft({queryKey:["settings"],queryFn:fe.getSettings}),Ee=ce?.time_format||"system",Ie=pt({mutationFn:async re=>(await Promise.all(re.map(Fe=>fe.deleteArchive(Fe))),re.length),onSuccess:re=>{t.invalidateQueries({queryKey:["archives"]}),O(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",y.toString())},[y]),w.useEffect(()=>{v?localStorage.setItem("archiveFilterTag",v):localStorage.removeItem("archiveFilterTag")},[v]),w.useEffect(()=>{localStorage.setItem("archiveFilterFileType",M)},[M]),w.useEffect(()=>{localStorage.setItem("archiveViewMode",z)},[z]),w.useEffect(()=>{localStorage.setItem("archiveSortBy",ne)},[ne]),w.useEffect(()=>{localStorage.setItem("archiveCollection",he)},[he]);const ue=new Map(B?.map(re=>[re.id,re.name])||[]),$=[...new Set(J?.flatMap(re=>re.filament_type?.split(", ")||[]).filter(Boolean)||[])].sort(),L=[...new Set(J?.flatMap(re=>re.filament_color?.split(",")||[]).filter(Boolean)||[])],Y=[...new Set(J?.flatMap(re=>re.tags?.split(",").map(Fe=>Fe.trim())||[]).filter(Boolean)||[])].sort(),pe=J?.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()),Te=!l||re.filament_type?.split(", ").includes(l),We=re.filament_color?.split(",")||[],it=u.size===0||(f==="or"?We.some(Yt=>u.has(Yt)):[...u].every(Yt=>We.includes(Yt))),Ot=he==="favorites"||!p||re.is_favorite,kt=he==="failed"||!y||re.status!=="failed"&&re.status!=="aborted",on=re.tags?.split(",").map(Yt=>Yt.trim())||[],Ut=!v||on.includes(v),yn=of(re.filename);return $e&&Le&&Te&&it&&Ot&&kt&&Ut&&(M==="all"||M==="gcode"&&yn||M==="source"&&!yn)}).sort((re,Fe)=>{switch(ne){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}}),Se=q||U.size>0,ae=re=>{O(Fe=>{const ve=new Set(Fe);return ve.has(re)?ve.delete(re):ve.add(re),ve})},je=()=>{pe&&O(new Set(pe.map(re=>re.id)))},De=()=>{O(new Set),j(!1)},Xe=re=>{d(Fe=>{const ve=new Set(Fe);return ve.has(re)?ve.delete(re):ve.add(re),ve})},et=()=>{d(new Set)},Qe=()=>{i(""),o(null),c(null),b(!1),x(!1),S(null),E("all")},se=r||a||l||p||y||v||M!=="all",ye=w.useCallback(re=>{re.preventDefault(),re.dataTransfer.types.includes("Files")&&R(!0)},[]),ke=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":Se&&De();break}},[Se]);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:ke,onDrop:Ue,children:[C&&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"})]})}),Se&&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(Ht,{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:je,children:"Select All"}),s.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>Z(!0),children:[s.jsx(xg,{className:"w-4 h-4"}),"Tags"]}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>ee(!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=>fe.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(Bf,{className:"w-4 h-4"}),"Favorite"]}),s.jsxs(Me,{size:"sm",className:"bg-red-500 hover:bg-red-600",onClick:()=>X(!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=>me(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 ",J?.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:()=>Ae(!oe),disabled:ge,children:[ge?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(Pw,{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()=>{Ae(!1),Ne(!0);try{const{blob:re,filename:Fe}=await fe.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{Ne(!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()=>{Ae(!1),Ne(!0);try{const{blob:re,filename:Fe}=await fe.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{Ne(!1)}},children:[s.jsx(Pw,{className:"w-4 h-4"}),"Export as Excel"]})]})]}),U.size>=2&&U.size<=5&&s.jsxs(Me,{variant:"secondary",onClick:()=>le(!0),children:[s.jsx(Zp,{className:"w-4 h-4"}),"Compare (",U.size,")"]}),!Se&&s.jsxs(Me,{variant:"secondary",onClick:()=>j(!0),children:[s.jsx(Do,{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(Et,{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(Ma,{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(iN,{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"}),B?.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(Zl,{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"}),$.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(jw,{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=>E(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(Bf,{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(!y),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${y?"bg-red-500/20 border-red-500 text-red-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:y?"Show failed prints":"Hide failed prints",children:[s.jsx(aa,{className:"w-4 h-4 "}),s.jsx("span",{className:"text-sm hidden md:inline",children:"Hide Failed"})]}),Y.length>0&&s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(xg,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),s.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:v||"",onChange: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(cK,{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:ne,onChange:re=>ie(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:()=>V("grid"),title:"Grid view",children:s.jsx(lN,{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:()=>V("list"),title:"List view",children:s.jsx(cN,{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:()=>V("calendar"),title:"Calendar view",children:s.jsx(Que,{className:"w-4 h-4"})})]})]}),se&&s.jsxs(Me,{variant:"ghost",size:"sm",onClick:Qe,className:"text-bambu-gray hover:text-white",children:[s.jsx(Ht,{className:"w-4 h-4"}),"Reset"]})]}),L.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:L.map(re=>s.jsx("button",{onClick:()=>Xe(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(Ht,{className:"w-3 h-3"}),"Clear"]})]})]})}),s.jsx(SKe,{}),K?s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading archives..."}):pe?.length===0?s.jsx(Et,{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(Et,{className:"p-6",children:s.jsx(f$e,{archives:pe||[],onArchiveClick:re=>{i(""),V("grid"),H(re.id)},highlightedArchiveId:He})}):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(MKe,{archive:re,printerName:re.printer_id?ue.get(re.printer_id)||"Unknown":"No Printer",isSelected:U.has(re.id),onSelect:ae,selectionMode:Se,projects:I,isHighlighted:re.id===He,timeFormat:Ee},re.id))}):z==="list"?s.jsx(Et,{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(NKe,{archive:re,printerName:re.printer_id?ue.get(re.printer_id)||"Unknown":"No Printer",isSelected:U.has(re.id),onSelect:ae,selectionMode:Se,projects:I,isHighlighted:re.id===He},re.id))]})}):null,A&&s.jsx(i$e,{onClose:()=>{k(!1),D([])},initialFiles:T}),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)),X(!1)},onCancel:()=>X(!1)}),G&&s.jsx(o$e,{selectedIds:Array.from(U),existingTags:Y,onClose:()=>Z(!1)}),te&&s.jsx(l$e,{selectedIds:Array.from(U),onClose:()=>ee(!1)}),_e&&U.size>=2&&U.size<=5&&s.jsx(bKe,{archiveIds:Array.from(U),onClose:()=>{le(!1),O(new Set),j(!1)}})]})}function TKe(){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 DE=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function mx(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function uI(t){return"nodeType"in t}function Ts(t){var e,n;return t?mx(t)?t:uI(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function dI(t){const{Document:e}=Ts(t);return t instanceof e}function Zy(t){return mx(t)?!1:t instanceof Ts(t).HTMLElement}function hie(t){return t instanceof Ts(t).SVGElement}function px(t){return t?mx(t)?t.document:uI(t)?dI(t)?t:Zy(t)||hie(t)?t.ownerDocument:document:document:document}const oc=DE?w.useLayoutEffect:w.useEffect;function hI(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 CKe(){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 fy(t,e){e===void 0&&(e=[t]);const n=w.useRef(t);return oc(()=>{n.current!==t&&(n.current=t)},e),n}function Jy(t,e){const n=w.useRef();return w.useMemo(()=>{const r=t(n.current);return n.current=r,r},[...e])}function GM(t){const e=hI(t),n=w.useRef(null),r=w.useCallback(i=>{i!==n.current&&e?.(i,n.current),n.current=i},[]);return[n,r]}function fD(t){const e=w.useRef();return w.useEffect(()=>{e.current=t},[t]),e.current}let Bj={};function ev(t,e){return w.useMemo(()=>{if(e)return e;const n=Bj[t]==null?0:Bj[t]+1;return Bj[t]=n,t+"-"+n},[t,e])}function fie(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 hg=fie(1),my=fie(-1);function kKe(t){return"clientX"in t&&"clientY"in t}function fI(t){if(!t)return!1;const{KeyboardEvent:e}=Ts(t.target);return e&&t instanceof e}function jKe(t){if(!t)return!1;const{TouchEvent:e}=Ts(t.target);return e&&t instanceof e}function mD(t){if(jKe(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 kKe(t)?{x:t.clientX,y:t.clientY}:null}const Vg=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[Vg.Translate.toString(t),Vg.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:r}=t;return e+" "+n+"ms "+r}}}),QW="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function PKe(t){return t.matches(QW)?t:t.querySelector(QW)}const RKe={display:"none"};function DKe(t){let{id:e,value:n}=t;return Ur.createElement("div",{id:e,style:RKe},n)}function OKe(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 LKe(){const[t,e]=w.useState("");return{announce:w.useCallback(r=>{r!=null&&e(r)},[]),announcement:t}}const mie=w.createContext(null);function IKe(t){const e=w.useContext(mie);w.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function FKe(){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 UKe={draggable:`
- To pick up a draggable item, press the space bar.
- While dragging, use the arrow keys to move the item.
- Press space again to drop the item in its new position, or press escape to cancel.
- `},zKe={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 BKe(t){let{announcements:e=zKe,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=UKe}=t;const{announce:a,announcement:o}=LKe(),l=ev("DndLiveRegion"),[c,u]=w.useState(!1);if(w.useEffect(()=>{u(!0)},[]),IKe(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(DKe,{id:r,value:i.draggable}),Ur.createElement(OKe,{id:l,announcement:o}));return n?Qc.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 WM(){}function qM(t,e){return w.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function pie(){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 gie(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function xie(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return n-r}function $Ke(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 bie(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function JW(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 yie=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=JW(e,e.left,e.top),a=[];for(const o of r){const{id:l}=o,c=n.get(l);if(c){const u=gie(JW(c),i);a.push({id:l,data:{droppableContainer:o,value:u}})}}return a.sort(xie)},HKe=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+gie(u[b],p),0),f=Number((d/4).toFixed(4));a.push({id:l,data:{droppableContainer:o,value:f}})}}return a.sort(xie)};function VKe(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 GKe=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=VKe(l,e);c>0&&i.push({id:o,data:{droppableContainer:a,value:c}})}}return i.sort($Ke)};function WKe(t,e,n){return{...t,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function vie(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:fl}function qKe(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 KKe=qKe(1);function XKe(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 YKe(t,e,n){const r=XKe(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 QKe={ignoreTransform:!1};function gx(t,e){e===void 0&&(e=QKe);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:u,transformOrigin:d}=Ts(t).getComputedStyle(t);u&&(n=YKe(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 eq(t){return gx(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 JKe(t,e){return e===void 0&&(e=Ts(t).getComputedStyle(t)),e.position==="fixed"}function eXe(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 OE(t,e){const n=[];function r(i){if(e!=null&&n.length>=e||!i)return n;if(dI(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!Zy(i)||hie(i)||n.includes(i))return n;const a=Ts(t).getComputedStyle(i);return i!==t&&eXe(i,a)&&n.push(i),JKe(i,a)?n:r(i.parentNode)}return t?r(t):n}function _ie(t){const[e]=OE(t,1);return e??null}function $j(t){return!DE||!t?null:mx(t)?t:uI(t)?dI(t)||t===px(t).scrollingElement?window:Zy(t)?t:null:null}function wie(t){return mx(t)?t.scrollX:t.scrollLeft}function Sie(t){return mx(t)?t.scrollY:t.scrollTop}function pD(t){return{x:wie(t),y:Sie(t)}}var Zi;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Zi||(Zi={}));function Mie(t){return!DE||!t?!1:t===document.scrollingElement}function Nie(t){const e={x:0,y:0},n=Mie(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 tXe={x:.2,y:.2};function nXe(t,e,n,r,i){let{top:a,left:o,right:l,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=tXe);const{isTop:u,isBottom:d,isLeft:f,isRight:m}=Nie(t),p={x:0,y:0},b={x:0,y:0},y={height:e.height*i.y,width:e.width*i.x};return!u&&a<=e.top+y.height?(p.y=Zi.Backward,b.y=r*Math.abs((e.top+y.height-a)/y.height)):!d&&c>=e.bottom-y.height&&(p.y=Zi.Forward,b.y=r*Math.abs((e.bottom-y.height-c)/y.height)),!m&&l>=e.right-y.width?(p.x=Zi.Forward,b.x=r*Math.abs((e.right-y.width-l)/y.width)):!f&&o<=e.left+y.width&&(p.x=Zi.Backward,b.x=r*Math.abs((e.left+y.width-o)/y.width)),{direction:p,speed:b}}function rXe(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)=>hg(e,pD(n)),fl)}function iXe(t){return t.reduce((e,n)=>e+wie(n),0)}function aXe(t){return t.reduce((e,n)=>e+Sie(n),0)}function sXe(t,e){if(e===void 0&&(e=gx),!t)return;const{top:n,left:r,bottom:i,right:a}=e(t);_ie(t)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const oXe=[["x",["left","right"],iXe],["y",["top","bottom"],aXe]];class mI{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=OE(n),i=Eie(r);this.rect={...e},this.width=e.width,this.height=e.height;for(const[a,o,l]of oXe)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 v0{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 lXe(t){const{EventTarget:e}=Ts(t);return t instanceof e?t:px(t)}function Hj(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 tq(t){t.preventDefault()}function cXe(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 Aie={start:[In.Space,In.Enter],cancel:[In.Esc],end:[In.Space,In.Enter,In.Tab]},uXe=(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 LE{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 v0(px(n)),this.windowListeners=new v0(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&&sXe(r),n(fl)}handleKeyDown(e){if(fI(e)){const{active:n,context:r,options:i}=this.props,{keyboardCodes:a=Aie,coordinateGetter:o=uXe,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=my(f,d),p={x:0,y:0},{scrollableAncestors:b}=r.current;for(const y of b){const x=e.code,{isTop:v,isRight:S,isLeft:M,isBottom:E,maxScroll:A,minScroll:k}=Nie(y),T=rXe(y),D={x:Math.min(x===In.Right?T.right-T.width/2:T.right,Math.max(x===In.Right?T.left:T.left+T.width/2,f.x)),y:Math.min(x===In.Down?T.bottom-T.height/2:T.bottom,Math.max(x===In.Down?T.top:T.top+T.height/2,f.y))},C=x===In.Right&&!S||x===In.Left&&!M,R=x===In.Down&&!E||x===In.Up&&!v;if(C&&D.x!==f.x){const U=y.scrollLeft+m.x,O=x===In.Right&&U<=A.x||x===In.Left&&U>=k.x;if(O&&!m.y){y.scrollTo({left:U,behavior:l});return}O?p.x=y.scrollLeft-U:p.x=x===In.Right?y.scrollLeft-A.x:y.scrollLeft-k.x,p.x&&y.scrollBy({left:-p.x,behavior:l});break}else if(R&&D.y!==f.y){const U=y.scrollTop+m.y,O=x===In.Down&&U<=A.y||x===In.Up&&U>=k.y;if(O&&!m.x){y.scrollTo({top:U,behavior:l});return}O?p.y=y.scrollTop-U:p.y=x===In.Down?y.scrollTop-A.y:y.scrollTop-k.y,p.y&&y.scrollBy({top:-p.y,behavior:l});break}}this.handleMove(e,hg(my(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()}}LE.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:r=Aie,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 nq(t){return!!(t&&"distance"in t)}function rq(t){return!!(t&&"delay"in t)}class pI{constructor(e,n,r){var i;r===void 0&&(r=lXe(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=px(o),this.documentListeners=new v0(this.document),this.listeners=new v0(r),this.windowListeners=new v0(Ts(o)),this.initialCoordinates=(i=mD(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,tq),this.windowListeners.add(wo.VisibilityChange,this.handleCancel),this.windowListeners.add(wo.ContextMenu,tq),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(rq(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(nq(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,cXe,{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=mD(e))!=null?n:fl,u=my(i,c);if(!r&&l){if(nq(l)){if(l.tolerance!=null&&Hj(u,l.tolerance))return this.handleCancel();if(Hj(u,l.distance))return this.handleStart()}if(rq(l)&&Hj(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 dXe={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class IE extends pI{constructor(e){const{event:n}=e,r=px(n.target);super(e,dXe,r)}}IE.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 hXe={move:{name:"mousemove"},end:{name:"mouseup"}};var gD;(function(t){t[t.RightClick=2]="RightClick"})(gD||(gD={}));class fXe extends pI{constructor(e){super(e,hXe,px(e.event.target))}}fXe.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return n.button===gD.RightClick?!1:(r?.({event:n}),!0)}}];const Vj={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class mXe extends pI{constructor(e){super(e,Vj)}static setup(){return window.addEventListener(Vj.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Vj.move.name,e)};function e(){}}}mXe.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 _0;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(_0||(_0={}));var KM;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(KM||(KM={}));function pXe(t){let{acceleration:e,activator:n=_0.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:l=KM.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:d,delta:f,threshold:m}=t;const p=xXe({delta:f,disabled:!a}),[b,y]=CKe(),x=w.useRef({x:0,y:0}),v=w.useRef({x:0,y:0}),S=w.useMemo(()=>{switch(n){case _0.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case _0.DraggableRect:return i}},[n,i,c]),M=w.useRef(null),E=w.useCallback(()=>{const k=M.current;if(!k)return;const T=x.current.x*v.current.x,D=x.current.y*v.current.y;k.scrollBy(T,D)},[]),A=w.useMemo(()=>l===KM.TreeOrder?[...u].reverse():u,[l,u]);w.useEffect(()=>{if(!a||!u.length||!S){y();return}for(const k of A){if(r?.(k)===!1)continue;const T=u.indexOf(k),D=d[T];if(!D)continue;const{direction:C,speed:R}=nXe(k,D,S,e,m);for(const U of["x","y"])p[U][C[U]]||(R[U]=0,C[U]=0);if(R.x>0||R.y>0){y(),M.current=k,b(E,o),x.current=R,v.current=C;return}}x.current={x:0,y:0},v.current={x:0,y:0},y()},[e,E,r,y,a,o,JSON.stringify(S),JSON.stringify(p),b,u,A,d,JSON.stringify(m)])}const gXe={x:{[Zi.Backward]:!1,[Zi.Forward]:!1},y:{[Zi.Backward]:!1,[Zi.Forward]:!1}};function xXe(t){let{delta:e,disabled:n}=t;const r=fD(e);return Jy(i=>{if(n||!r||!i)return gXe;const a={x:Math.sign(e.x-r.x),y:Math.sign(e.y-r.y)};return{x:{[Zi.Backward]:i.x[Zi.Backward]||a.x===-1,[Zi.Forward]:i.x[Zi.Forward]||a.x===1},y:{[Zi.Backward]:i.y[Zi.Backward]||a.y===-1,[Zi.Forward]:i.y[Zi.Forward]||a.y===1}}},[n,e,r])}function bXe(t,e){const n=e!=null?t.get(e):void 0,r=n?n.node.current:null;return Jy(i=>{var a;return e==null?null:(a=r??i)!=null?a:null},[r,e])}function yXe(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 py;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(py||(py={}));var xD;(function(t){t.Optimized="optimized"})(xD||(xD={}));const iq=new Map;function vXe(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=fy(f),p=w.useCallback(function(v){v===void 0&&(v=[]),!m.current&&o(S=>S===null?v:S.concat(v.filter(M=>!S.includes(M))))},[m]),b=w.useRef(null),y=Jy(v=>{if(f&&!n)return iq;if(!v||v===iq||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 E=M.node.current,A=E?new mI(c(E),E):null;M.rect.current=A,A&&S.set(M.id,A)}return S}return v},[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:y,measureDroppableContainers:p,measuringScheduled:a!=null};function x(){switch(u){case py.Always:return!1;case py.BeforeDragging:return n;default:return!n}}}function Tie(t,e){return Jy(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function _Xe(t,e){return Tie(t,e)}function wXe(t){let{callback:e,disabled:n}=t;const r=hI(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 FE(t){let{callback:e,disabled:n}=t;const r=hI(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 SXe(t){return new mI(gx(t),t)}function aq(t,e,n){e===void 0&&(e=SXe);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=wXe({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=FE({callback:a});return oc(()=>{a(),t?(l?.observe(t),o?.observe(document.body,{childList:!0,subtree:!0})):(l?.disconnect(),o?.disconnect())},[t]),r}function MXe(t){const e=Tie(t);return vie(t,e)}const sq=[];function NXe(t){const e=w.useRef(t),n=Jy(r=>t?r&&r!==sq&&t&&e.current&&t.parentNode===e.current.parentNode?r:OE(t):sq,[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=$j(a.target);o&&n(l=>l?(l.set(o,pD(o)),new Map(l)):null)},[]);return w.useEffect(()=>{const a=r.current;if(t!==a){o(a);const l=t.map(c=>{const u=$j(c);return u?(u.addEventListener("scroll",i,{passive:!0}),[u,pD(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=$j(c);u?.removeEventListener("scroll",i)})}},[i,t]),w.useMemo(()=>t.length?e?Array.from(e.values()).reduce((a,o)=>hg(a,o),fl):Eie(t):fl,[t,e])}function oq(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?my(t,n.current):fl}function AXe(t){w.useEffect(()=>{if(!DE)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 TXe(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 Cie(t){return w.useMemo(()=>t?ZKe(t):null,[t])}const lq=[];function CXe(t,e){e===void 0&&(e=gx);const[n]=t,r=Cie(n?Ts(n):null),[i,a]=w.useState(lq);function o(){a(()=>t.length?t.map(c=>Mie(c)?r:new mI(e(c),c)):lq)}const l=FE({callback:o});return oc(()=>{l?.disconnect(),o(),t.forEach(c=>l?.observe(c))},[t]),i}function kXe(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return Zy(e)?e:t}function jXe(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=FE({callback:i}),o=w.useCallback(u=>{const d=kXe(u);a?.disconnect(),d&&a?.observe(d),r(d?e(d):null)},[e,a]),[l,c]=GM(o);return w.useMemo(()=>({nodeRef:l,rect:n,setRef:c}),[n,l,c])}const PXe=[{sensor:IE,options:{}},{sensor:LE,options:{}}],RXe={current:{}},Sw={draggable:{measure:eq},droppable:{measure:eq,strategy:py.WhileDragging,frequency:xD.Optimized},dragOverlay:{measure:gx}};class w0 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 DXe={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new w0,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:WM},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Sw,measureDroppableContainers:WM,windowRect:null,measuringScheduled:!1},OXe={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:WM,draggableNodes:new Map,over:null,measureDroppableContainers:WM},UE=w.createContext(OXe),kie=w.createContext(DXe);function LXe(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new w0}}}function IXe(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 w0(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 w0(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 w0(t.droppable.containers);return a.delete(n),{...t,droppable:{...t.droppable,containers:a}}}default:return t}}function FXe(t){let{disabled:e}=t;const{active:n,activatorEvent:r,draggableNodes:i}=w.useContext(UE),a=fD(r),o=fD(n?.id);return w.useEffect(()=>{if(!e&&!r&&a&&o!=null){if(!fI(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=PKe(d);if(f){f.focus();break}}})}},[r,e,i,o,a]),null}function UXe(t,e){let{transform:n,...r}=e;return t!=null&&t.length?t.reduce((i,a)=>a({transform:i,...r}),n):n}function zXe(t){return w.useMemo(()=>({draggable:{...Sw.draggable,...t?.draggable},droppable:{...Sw.droppable,...t?.droppable},dragOverlay:{...Sw.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function BXe(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=vie(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=_ie(u);m&&m.scrollBy({top:f.y,left:f.x})}},[e,o,l,r,n])}const jie=w.createContext({...fl,scaleX:1,scaleY:1});var Sd;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(Sd||(Sd={}));const Pie=w.memo(function(e){var n,r,i,a;let{id:o,accessibility:l,autoScroll:c=!0,children:u,sensors:d=PXe,collisionDetection:f=GKe,measuring:m,modifiers:p,...b}=e;const y=w.useReducer(IXe,void 0,LXe),[x,v]=y,[S,M]=FKe(),[E,A]=w.useState(Sd.Uninitialized),k=E===Sd.Initialized,{draggable:{active:T,nodes:D,translate:C},droppable:{containers:R}}=x,U=T!=null?D.get(T):null,O=w.useRef({initial:null,translated:null}),q=w.useMemo(()=>{var $e;return T!=null?{id:T,data:($e=U?.data)!=null?$e:RXe,rect:O}:null},[T,U]),j=w.useRef(null),[W,X]=w.useState(null),[G,Z]=w.useState(null),te=fy(b,Object.values(b)),ee=ev("DndDescribedBy",o),z=w.useMemo(()=>R.getEnabled(),[R]),V=zXe(m),{droppableRects:ne,measureDroppableContainers:ie,measuringScheduled:he}=vXe(z,{dragging:k,dependencies:[C.x,C.y],config:V.droppable}),me=bXe(D,T),oe=w.useMemo(()=>G?mD(G):null,[G]),Ae=ve(),ge=_Xe(me,V.draggable.measure);BXe({activeNode:T!=null?D.get(T):null,config:Ae.layoutShiftCompensation,initialRect:ge,measure:V.draggable.measure});const Ne=aq(me,V.draggable.measure,ge),_e=aq(me?me.parentElement:null),le=w.useRef({activatorEvent:null,active:null,activeNode:me,collisionRect:null,collisions:null,droppableRects:ne,draggableNodes:D,draggingNode:null,draggingNodeRect:null,droppableContainers:R,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),He=R.getNodeFor((n=le.current.over)==null?void 0:n.id),H=jXe({measure:V.dragOverlay.measure}),J=(r=H.nodeRef.current)!=null?r:me,K=k?(i=H.rect)!=null?i:Ne:null,B=!!(H.nodeRef.current&&H.rect),I=MXe(B?null:Ne),ce=Cie(J?Ts(J):null),Ee=NXe(k?He??me:null),Ie=CXe(Ee),ue=UXe(p,{transform:{x:C.x-I.x,y:C.y-I.y,scaleX:1,scaleY:1},activatorEvent:G,active:q,activeNodeRect:Ne,containerNodeRect:_e,draggingNodeRect:K,over:le.current.over,overlayNodeRect:H.rect,scrollableAncestors:Ee,scrollableAncestorRects:Ie,windowRect:ce}),$=oe?hg(oe,C):null,L=EXe(Ee),Y=oq(L),pe=oq(L,[Ne]),Se=hg(ue,Y),ae=K?KKe(K,ue):null,je=q&&ae?f({active:q,collisionRect:ae,droppableRects:ne,droppableContainers:z,pointerCoordinates:$}):null,De=bie(je,"id"),[Xe,et]=w.useState(null),Qe=B?ue:hg(ue,pe),se=WKe(Qe,(a=Xe?.rect)!=null?a:null,Ne),ye=w.useRef(null),ke=w.useCallback(($e,Le)=>{let{sensor:Te,options:We}=Le;if(j.current==null)return;const it=D.get(j.current);if(!it)return;const Ot=$e.nativeEvent,kt=new Te({active:j.current,activeNode:it,event:Ot,options:We,context:le,onAbort(Ut){if(!D.get(Ut))return;const{onDragAbort:xt}=te.current,Yt={id:Ut};xt?.(Yt),S({type:"onDragAbort",event:Yt})},onPending(Ut,yn,xt,Yt){if(!D.get(Ut))return;const{onDragPending:Tt}=te.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}=te.current,sn={activatorEvent:Ot,active:{id:yn,data:xt.data,rect:O}};Qc.unstable_batchedUpdates(()=>{Yt?.(sn),A(Sd.Initializing),v({type:Di.DragStart,initialCoordinates:Ut,active:yn}),S({type:"onDragStart",event:sn}),X(ye.current),Z(Ot)})},onMove(Ut){v({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}=le.current;let Cn=null;if(xt&&Tt){const{cancelDrop:Cr}=te.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,Qc.unstable_batchedUpdates(()=>{v({type:Ut}),A(Sd.Uninitialized),et(null),X(null),Z(null),ye.current=null;const Cr=Ut===Di.DragEnd?"onDragEnd":"onDragCancel";if(Cn){const er=te.current[Cr];er?.(Cn),S({type:Cr,event:Cn})}})}}},[D]),Ue=w.useCallback(($e,Le)=>(Te,We)=>{const it=Te.nativeEvent,Ot=D.get(We);if(j.current!==null||!Ot||it.dndKit||it.defaultPrevented)return;const kt={active:Ot};$e(Te,Le.options,kt)===!0&&(it.dndKit={capturedBy:Le.sensor},j.current=We,ke(Te,Le))},[D,ke]),dt=yXe(d,Ue);AXe(d),oc(()=>{Ne&&E===Sd.Initializing&&A(Sd.Initialized)},[Ne,E]),w.useEffect(()=>{const{onDragMove:$e}=te.current,{active:Le,activatorEvent:Te,collisions:We,over:it}=le.current;if(!Le||!Te)return;const Ot={active:Le,activatorEvent:Te,collisions:We,delta:{x:Se.x,y:Se.y},over:it};Qc.unstable_batchedUpdates(()=>{$e?.(Ot),S({type:"onDragMove",event:Ot})})},[Se.x,Se.y]),w.useEffect(()=>{const{active:$e,activatorEvent:Le,collisions:Te,droppableContainers:We,scrollAdjustedTranslate:it}=le.current;if(!$e||j.current==null||!Le||!it)return;const{onDragOver:Ot}=te.current,kt=We.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:Te,delta:{x:it.x,y:it.y},over:on};Qc.unstable_batchedUpdates(()=>{et(on),Ot?.(Ut),S({type:"onDragOver",event:Ut})})},[De]),oc(()=>{le.current={activatorEvent:G,active:q,activeNode:me,collisionRect:ae,collisions:je,droppableRects:ne,draggableNodes:D,draggingNode:J,draggingNodeRect:K,droppableContainers:R,over:Xe,scrollableAncestors:Ee,scrollAdjustedTranslate:Se},O.current={initial:K,translated:ae}},[q,me,je,ae,D,J,K,ne,R,Xe,Ee,Se]),pXe({...Ae,delta:C,draggingRect:ae,pointerCoordinates:$,scrollableAncestors:Ee,scrollableAncestorRects:Ie});const re=w.useMemo(()=>({active:q,activeNode:me,activeNodeRect:Ne,activatorEvent:G,collisions:je,containerNodeRect:_e,dragOverlay:H,draggableNodes:D,droppableContainers:R,droppableRects:ne,over:Xe,measureDroppableContainers:ie,scrollableAncestors:Ee,scrollableAncestorRects:Ie,measuringConfiguration:V,measuringScheduled:he,windowRect:ce}),[q,me,Ne,G,je,_e,H,D,R,ne,Xe,ie,Ee,Ie,V,he,ce]),Fe=w.useMemo(()=>({activatorEvent:G,activators:dt,active:q,activeNodeRect:Ne,ariaDescribedById:{draggable:ee},dispatch:v,draggableNodes:D,over:Xe,measureDroppableContainers:ie}),[G,dt,q,Ne,v,ee,D,Xe,ie]);return Ur.createElement(mie.Provider,{value:M},Ur.createElement(UE.Provider,{value:Fe},Ur.createElement(kie.Provider,{value:re},Ur.createElement(jie.Provider,{value:se},u)),Ur.createElement(FXe,{disabled:l?.restoreFocus===!1})),Ur.createElement(BKe,{...l,hiddenTextDescribedById:ee}));function ve(){const $e=W?.autoScrollEnabled===!1,Le=typeof c=="object"?c.enabled===!1:c===!1,Te=k&&!$e&&!Le;return typeof c=="object"?{...c,enabled:Te}:{enabled:Te}}}),$Xe=w.createContext(null),cq="button",HXe="Draggable";function VXe(t){let{id:e,data:n,disabled:r=!1,attributes:i}=t;const a=ev(HXe),{activators:o,activatorEvent:l,active:c,activeNodeRect:u,ariaDescribedById:d,draggableNodes:f,over:m}=w.useContext(UE),{role:p=cq,roleDescription:b="draggable",tabIndex:y=0}=i??{},x=c?.id===e,v=w.useContext(x?jie:$Xe),[S,M]=GM(),[E,A]=GM(),k=TXe(o,e),T=fy(n);oc(()=>(f.set(e,{id:e,key:a,node:S,activatorNode:E,data:T}),()=>{const C=f.get(e);C&&C.key===a&&f.delete(e)}),[f,e]);const D=w.useMemo(()=>({role:p,tabIndex:y,"aria-disabled":r,"aria-pressed":x&&p===cq?!0:void 0,"aria-roledescription":b,"aria-describedby":d.draggable}),[r,p,y,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:v}}function GXe(){return w.useContext(kie)}const WXe="Droppable",qXe={timeout:25};function KXe(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:i}=t;const a=ev(WXe),{active:o,dispatch:l,over:c,measureDroppableContainers:u}=w.useContext(UE),d=w.useRef({disabled:n}),f=w.useRef(!1),m=w.useRef(null),p=w.useRef(null),{disabled:b,updateMeasurementsFor:y,timeout:x}={...qXe,...i},v=fy(y??r),S=w.useCallback(()=>{if(!f.current){f.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{u(Array.isArray(v.current)?v.current:[v.current]),p.current=null},x)},[x]),M=FE({callback:S,disabled:b||!o}),E=w.useCallback((D,C)=>{M&&(C&&(M.unobserve(C),f.current=!1),D&&M.observe(D))},[M]),[A,k]=GM(E),T=fy(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:T}}),()=>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 zE(t,e,n){const r=t.slice();return r.splice(n<0?r.length+n:n,0,r.splice(e,1)[0]),r}function XXe(t,e){return t.reduce((n,r,i)=>{const a=e.get(r);return a&&(n[i]=a),n},Array(t.length))}function G1(t){return t!==null&&t>=0}function YXe(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 QXe(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const gI=t=>{let{rects:e,activeIndex:n,overIndex:r,index:i}=t;const a=zE(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}},W1={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,...W1}:null}const c=JXe(a,i,n);return i>n&&i<=o?{x:0,y:-l.height-c,...W1}:i<n&&i>=o?{x:0,y:l.height+c,...W1}:{x:0,y:0,...W1}};function JXe(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 Rie="Sortable",Die=Ur.createContext({activeIndex:-1,containerId:Rie,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:gI,disabled:{draggable:!1,droppable:!1}});function Oie(t){let{children:e,id:n,items:r,strategy:i=gI,disabled:a=!1}=t;const{active:o,dragOverlay:l,droppableRects:c,over:u,measureDroppableContainers:d}=GXe(),f=ev(Rie,n),m=l.rect!==null,p=w.useMemo(()=>r.map(k=>typeof k=="object"&&"id"in k?k.id:k),[r]),b=o!=null,y=o?p.indexOf(o.id):-1,x=u?p.indexOf(u.id):-1,v=w.useRef(p),S=!YXe(p,v.current),M=x!==-1&&y===-1||S,E=QXe(a);oc(()=>{S&&b&&d(p)},[S,p,b,d]),w.useEffect(()=>{v.current=p},[p]);const A=w.useMemo(()=>({activeIndex:y,containerId:f,disabled:E,disableTransforms:M,items:p,overIndex:x,useDragOverlay:m,sortedRects:XXe(p,c),strategy:i}),[y,f,E.draggable,E.droppable,M,p,x,c,m,i]);return Ur.createElement(Die.Provider,{value:A},e)}const eYe=t=>{let{id:e,items:n,activeIndex:r,overIndex:i}=t;return zE(n,r,i).indexOf(e)},tYe=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},nYe={duration:200,easing:"ease"},Lie="transform",rYe=Vg.Transition.toString({property:Lie,duration:0,easing:"linear"}),iYe={roleDescription:"sortable"};function aYe(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=gx(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 Iie(t){let{animateLayoutChanges:e=tYe,attributes:n,disabled:r,data:i,getNewIndex:a=eYe,id:o,strategy:l,resizeObserverConfig:c,transition:u=nYe}=t;const{items:d,containerId:f,activeIndex:m,disabled:p,disableTransforms:b,sortedRects:y,overIndex:x,useDragOverlay:v,strategy:S}=w.useContext(Die),M=sYe(r,p),E=d.indexOf(o),A=w.useMemo(()=>({sortable:{containerId:f,index:E,items:d},...i}),[f,i,E,d]),k=w.useMemo(()=>d.slice(d.indexOf(o)),[d,o]),{rect:T,node:D,isOver:C,setNodeRef:R}=KXe({id:o,data:A,disabled:M.droppable,resizeObserverConfig:{updateMeasurementsFor:k,...c}}),{active:U,activatorEvent:O,activeNodeRect:q,attributes:j,setNodeRef:W,listeners:X,isDragging:G,over:Z,setActivatorNodeRef:te,transform:ee}=VXe({id:o,data:A,attributes:{...iYe,...n},disabled:M.draggable}),z=TKe(R,W),V=!!U,ne=V&&!b&&G1(m)&&G1(x),ie=!v&&G,he=ie&&ne?ee:null,oe=ne?he??(l??S)({rects:y,activeNodeRect:q,activeIndex:m,overIndex:x,index:E}):null,Ae=G1(m)&&G1(x)?a({id:o,items:d,activeIndex:m,overIndex:x}):E,ge=U?.id,Ne=w.useRef({activeId:ge,items:d,newIndex:Ae,containerId:f}),_e=d!==Ne.current.items,le=e({active:U,containerId:f,isDragging:G,isSorting:V,id:o,index:E,items:d,newIndex:Ne.current.newIndex,previousItems:Ne.current.items,previousContainerId:Ne.current.containerId,transition:u,wasDragging:Ne.current.activeId!=null}),He=aYe({disabled:!le,index:E,node:D,rect:T});return w.useEffect(()=>{V&&Ne.current.newIndex!==Ae&&(Ne.current.newIndex=Ae),f!==Ne.current.containerId&&(Ne.current.containerId=f),d!==Ne.current.items&&(Ne.current.items=d)},[V,Ae,f,d]),w.useEffect(()=>{if(ge===Ne.current.activeId)return;if(ge!=null&&Ne.current.activeId==null){Ne.current.activeId=ge;return}const J=setTimeout(()=>{Ne.current.activeId=ge},50);return()=>clearTimeout(J)},[ge]),{active:U,activeIndex:m,attributes:j,data:A,rect:T,index:E,newIndex:Ae,items:d,isOver:C,isSorting:V,isDragging:G,listeners:X,node:D,overIndex:x,over:Z,setNodeRef:z,setActivatorNodeRef:te,setDroppableNodeRef:R,setDraggableNodeRef:W,transform:He??oe,transition:H()};function H(){if(He||_e&&Ne.current.newIndex===E)return rYe;if(!(ie&&!fI(O)||!u)&&(V||le))return Vg.Transition.toString({...u,property:Lie})}}function sYe(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 XM(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 oYe=[In.Down,In.Right,In.Up,In.Left],Fie=(t,e)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:a,over:o,scrollableAncestors:l}}=e;if(oYe.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=HKe({collisionRect:r,droppableRects:i,droppableContainers:c});let d=bie(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=OE(b).some((k,T)=>l[T]!==k),v=Uie(f,m),S=lYe(f,m),M=x||!v?{x:0,y:0}:{x:S?r.width-p.width:0,y:S?r.height-p.height:0},E={x:p.left,y:p.top};return M.x&&M.y?E:my(E,M)}}}};function Uie(t,e){return!XM(t)||!XM(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function lYe(t,e){return!XM(t)||!XM(e)||!Uie(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}function zie(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 cYe(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`:yg(t,e)}function uYe({status:t}){const e={pending:{icon:Jn,color:"text-status-warning bg-status-warning/10 border-status-warning/20",label:"Pending"},printing:{icon:cl,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:Lw,color:"text-orange-400 bg-orange-400/10 border-orange-400/20",label:"Skipped"},cancelled:{icon:Ht,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 dYe({selectedCount:t,printers:e,onSave:n,onClose:r,isSaving:i}){const[a,o]=w.useState("unchanged"),[l,c]=w.useState("unchanged"),[u,d]=w.useState("unchanged"),[f,m]=w.useState("unchanged"),[p,b]=w.useState("unchanged"),[y,x]=w.useState("unchanged"),[v,S]=w.useState("unchanged"),[M,E]=w.useState("unchanged"),[A,k]=w.useState("unchanged"),[T,D]=w.useState("unchanged"),C=()=>{const U={};a!=="unchanged"&&(U.printer_id=a),l!=="unchanged"&&(U.manual_start=l),u!=="unchanged"&&(U.auto_off_after=u),f!=="unchanged"&&(U.require_previous_success=f),p!=="unchanged"&&(U.bed_levelling=p),y!=="unchanged"&&(U.flow_cali=y),v!=="unchanged"&&(U.vibration_cali=v),M!=="unchanged"&&(U.layer_inspect=M),A!=="unchanged"&&(U.timelapse=A),T!=="unchanged"&&(U.use_ams=T),n(U)},R=a!=="unchanged"||l!=="unchanged"||u!=="unchanged"||f!=="unchanged"||p!=="unchanged"||y!=="unchanged"||v!=="unchanged"||M!=="unchanged"||A!=="unchanged"||T!=="unchanged";return s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-lg max-h-[90vh] overflow-y-auto",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",children:["Edit ",t," Item",t!==1?"s":""]}),s.jsx("button",{onClick:r,className:"p-1 hover:bg-bambu-dark rounded",children:s.jsx(Ht,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Only changed settings will be applied to selected items."}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Printer"}),s.jsxs("select",{value:a===null?"null":a==="unchanged"?"unchanged":String(a),onChange:U=>{const O=U.target.value;o(O==="unchanged"?"unchanged":O==="null"?null:Number(O))},className:"w-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:"unchanged",children:"— No change —"}),s.jsx("option",{value:"null",children:"Unassigned"}),e.map(U=>s.jsx("option",{value:U.id,children:U.name},U.id))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Queue Options"}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Hc,{label:"Staged (manual start)",value:l,onChange:c}),s.jsx(Hc,{label:"Auto power off after print",value:u,onChange:d}),s.jsx(Hc,{label:"Require previous success",value:f,onChange:m})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Print Options"}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Hc,{label:"Bed levelling",value:p,onChange:b}),s.jsx(Hc,{label:"Flow calibration",value:y,onChange:x}),s.jsx(Hc,{label:"Vibration calibration",value:v,onChange:S}),s.jsx(Hc,{label:"First layer inspection",value:M,onChange:E}),s.jsx(Hc,{label:"Timelapse",value:A,onChange:k}),s.jsx(Hc,{label:"Use AMS",value:T,onChange:D})]})]})]}),s.jsxs("div",{className:"flex justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(Me,{variant:"secondary",onClick:r,children:"Cancel"}),s.jsx(Me,{onClick:C,disabled:!R||i,children:i?"Saving...":"Apply Changes"})]})]})})}function Hc({label:t,value:e,onChange:n}){return s.jsxs("div",{className:"flex items-center justify-between py-1",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:t}),s.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark rounded-lg p-0.5",children:[s.jsx("button",{onClick:()=>n("unchanged"),className:`px-2 py-1 text-xs rounded ${e==="unchanged"?"bg-bambu-dark-tertiary text-white":"text-bambu-gray hover:text-white"}`,children:"—"}),s.jsx("button",{onClick:()=>n(!1),className:`px-2 py-1 text-xs rounded ${e===!1?"bg-red-500/20 text-red-400":"text-bambu-gray hover:text-white"}`,children:"Off"}),s.jsx("button",{onClick:()=>n(!0),className:`px-2 py-1 text-xs rounded ${e===!0?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:text-white"}`,children:"On"})]})]})}function Gj({item:t,position:e,onEdit:n,onCancel:r,onRemove:i,onStop:a,onRequeue:o,onStart:l,timeFormat:c="system",isSelected:u=!1,onToggleSelect:d}){const{attributes:f,listeners:m,setNodeRef:p,transform:b,transition:y,isDragging:x}=Iie({id:t.id,disabled:t.status!=="pending"}),v={transform:Vg.Transform.toString(b),transition:y},S=t.status==="printing",M=t.status==="pending",E=["completed","failed","skipped","cancelled"].includes(t.status);return s.jsx("div",{ref:p,style:v,className:`
- group relative bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary
- transition-all duration-200 hover:border-bambu-dark-tertiary/80
- ${x?"opacity-50 scale-[1.02] shadow-xl z-50":""}
- ${S?"border-blue-500/30 bg-gradient-to-r from-blue-500/5 to-transparent":""}
- `,children:s.jsxs("div",{className:"flex items-center gap-4 p-4",children:[M&&d&&s.jsx("button",{onClick:A=>{A.stopPropagation(),d()},className:`flex items-center justify-center w-6 h-6 rounded border transition-colors ${u?"bg-bambu-green border-bambu-green text-white":"border-white/30 bg-black/30 hover:border-bambu-green/50"}`,children:u&&s.jsx(ts,{className:"w-4 h-4"})}),M?s.jsx("div",{...f,...m,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(gg,{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:fe.getArchiveThumbnail(t.archive_id),alt:"",className:"w-full h-full object-cover"}):t.library_file_thumbnail?s.jsx("img",{src:fe.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(ll,{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(gs,{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(gs,{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(Td,{className:"w-3.5 h-3.5"}),zie(t.print_time_seconds)]}),M&&!t.manual_start&&s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx(Jn,{className:"w-3.5 h-3.5"}),cYe(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(mK,{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(Su,{className:"w-3 h-3"}),"Auto power off"]})]}),S&&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(uYe,{status:t.status}),s.jsxs("div",{className:"flex items-center gap-1",children:[S&&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(mde,{className:"w-4 h-4"})}),M&&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(cl,{className:"w-4 h-4"})}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:n,title:"Edit",children:s.jsx(sa,{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(Ht,{className:"w-4 h-4"})})]}),E&&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 hYe(){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,y]=w.useState([]),[x,v]=w.useState(!1),[S,M]=w.useState(()=>localStorage.getItem("queue.historySortBy")||"date"),[E,A]=w.useState(()=>{const _e=localStorage.getItem("queue.historySortAsc");return _e!==null?_e==="true":!1}),[k,T]=w.useState(()=>localStorage.getItem("queue.pendingSortBy")||"position"),[D,C]=w.useState(()=>{const _e=localStorage.getItem("queue.pendingSortAsc");return _e!==null?_e==="true":!0});w.useEffect(()=>{localStorage.setItem("queue.historySortBy",S)},[S]),w.useEffect(()=>{localStorage.setItem("queue.historySortAsc",String(E))},[E]),w.useEffect(()=>{localStorage.setItem("queue.pendingSortBy",k)},[k]),w.useEffect(()=>{localStorage.setItem("queue.pendingSortAsc",String(D))},[D]);const R=pie(qM(IE,{activationConstraint:{distance:8}}),qM(LE,{coordinateGetter:Fie})),{data:U}=ft({queryKey:["settings"],queryFn:fe.getSettings}),O=U?.time_format||"system",{data:q,isLoading:j}=ft({queryKey:["queue",n,i],queryFn:()=>fe.getQueue(n||void 0,i||void 0),refetchInterval:5e3}),{data:W}=ft({queryKey:["printers"],queryFn:()=>fe.getPrinters()}),X=pt({mutationFn:_e=>fe.cancelQueueItem(_e),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item cancelled")},onError:()=>e("Failed to cancel item","error")}),G=pt({mutationFn:_e=>fe.removeFromQueue(_e),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item removed")},onError:()=>e("Failed to remove item","error")}),Z=pt({mutationFn:_e=>fe.stopQueueItem(_e),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Print stopped")},onError:()=>e("Failed to stop print","error")}),te=pt({mutationFn:_e=>fe.startQueueItem(_e),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Print released to queue")},onError:()=>e("Failed to start print","error")}),ee=pt({mutationFn:_e=>fe.reorderQueue(_e),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]})},onError:()=>e("Failed to reorder queue","error")}),z=pt({mutationFn:async()=>{const _e=q?.filter(le=>["completed","failed","skipped","cancelled"].includes(le.status))||[];for(const le of _e)await fe.removeFromQueue(le.id);return _e.length},onSuccess:_e=>{t.invalidateQueries({queryKey:["queue"]}),e(`Cleared ${_e} history item${_e!==1?"s":""}`)},onError:()=>e("Failed to clear history","error")}),V=pt({mutationFn:_e=>fe.bulkUpdateQueue(_e),onSuccess:_e=>{t.invalidateQueries({queryKey:["queue"]}),y([]),v(!1),e(_e.message)},onError:()=>e("Failed to update items","error")}),ne=pt({mutationFn:async _e=>{for(const le of _e)await fe.cancelQueueItem(le);return _e.length},onSuccess:_e=>{t.invalidateQueries({queryKey:["queue"]}),y([]),e(`Cancelled ${_e} item${_e!==1?"s":""}`)},onError:()=>e("Failed to cancel items","error")}),ie=_e=>{y(le=>le.includes(_e)?le.filter(He=>He!==_e):[...le,_e])},he=w.useMemo(()=>{const _e=q?.filter(He=>He.status==="pending")||[],le=He=>{if(!He.scheduled_time)return 0;const H=new Date(He.scheduled_time).getTime(),J=Date.now()+4320*60*60*1e3;return H>J?0:H};return[..._e].sort((He,H)=>{let J;if(k==="name"){const K=He.archive_name||He.library_file_name||"",B=H.archive_name||H.library_file_name||"";J=K.localeCompare(B)}else k==="printer"?J=(He.printer_name||"").localeCompare(H.printer_name||""):k==="time"?J=le(He)-le(H):J=He.position-H.position;return D?J:-J})},[q,k,D]),me=()=>{const _e=he.map(le=>le.id);b.length===_e.length?y([]):y(_e)},oe=q?.filter(_e=>_e.status==="printing")||[],Ae=w.useMemo(()=>[...q?.filter(le=>["completed","failed","skipped","cancelled"].includes(le.status))||[]].sort((le,He)=>{let H;if(S==="name"){const J=le.archive_name||le.library_file_name||"",K=He.archive_name||He.library_file_name||"";H=J.localeCompare(K)}else S==="printer"?H=(le.printer_name||"").localeCompare(He.printer_name||""):H=new Date(He.completed_at||He.created_at).getTime()-new Date(le.completed_at||le.created_at).getTime();return E?-H:H}),[q,S,E]),ge=w.useMemo(()=>he.reduce((_e,le)=>_e+(le.print_time_seconds||0),0),[he]),Ne=_e=>{const{active:le,over:He}=_e;if(!He||le.id===He.id)return;const H=he.findIndex(K=>K.id===le.id),J=he.findIndex(K=>K.id===He.id);if(H!==-1&&J!==-1){const B=zE(he,H,J).map((I,ce)=>({id:I.id,position:ce+1}));ee.mutate(B)}};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(pK,{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(Et,{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(cl,{className:"w-5 h-5 text-blue-400"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:oe.length}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Printing"})]})]})})}),s.jsx(Et,{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:he.length}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Queued"})]})]})})}),s.jsx(Et,{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(Td,{className:"w-5 h-5 text-bambu-green"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:zie(ge)}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Total Queue Time"})]})]})})}),s.jsx(Et,{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:Ae.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:_e=>{const le=_e.target.value;r(le==="unassigned"?-1:le===""?null:Number(le))},children:[s.jsx("option",{value:"",children:"All Printers"}),s.jsx("option",{value:"unassigned",children:"Unassigned"}),W?.map(_e=>s.jsx("option",{value:_e.id,children:_e.name},_e.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:_e=>a(_e.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"}),Ae.length>0&&s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>l(!0),children:[s.jsx(hn,{className:"w-4 h-4"}),"Clear History"]})]}),j?s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading..."}):q?.length===0?s.jsxs(Et,{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:[oe.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:oe.map(_e=>s.jsx(Gj,{item:_e,onEdit:()=>{},onCancel:()=>{},onRemove:()=>{},onStop:()=>p({type:"stop",item:_e}),onRequeue:()=>{},onStart:()=>{},timeFormat:O},_e.id))})]}),he.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:["(",he.length," item",he.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:k,onChange:_e=>T(_e.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:()=>C(!D),title:D?"Ascending":"Descending",className:"px-2",children:D?s.jsx(fg,{className:"w-4 h-4"}):s.jsx(T0,{className:"w-4 h-4"})})]})]}),s.jsxs("div",{className:"flex items-center gap-3 mb-4 p-3 bg-bambu-dark rounded-lg",children:[s.jsxs(Me,{variant:"ghost",size:"sm",onClick:me,className:"flex items-center gap-2",children:[b.length===he.length&&he.length>0?s.jsx(Do,{className:"w-4 h-4 text-bambu-green"}):s.jsx(Oo,{className:"w-4 h-4"}),b.length===he.length&&he.length>0?"Deselect All":"Select All"]}),b.length>0&&s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"text-sm text-bambu-gray",children:[b.length," selected"]}),s.jsx("div",{className:"h-4 w-px bg-bambu-dark-tertiary"}),s.jsxs(Me,{variant:"ghost",size:"sm",onClick:()=>v(!0),className:"flex items-center gap-2 text-bambu-green hover:text-bambu-green-light",children:[s.jsx(sa,{className:"w-4 h-4"}),"Edit Selected"]}),s.jsxs(Me,{variant:"ghost",size:"sm",onClick:()=>ne.mutate(b),className:"flex items-center gap-2 text-red-400 hover:text-red-300",disabled:ne.isPending,children:[s.jsx(Ht,{className:"w-4 h-4"}),"Cancel Selected"]})]})]}),s.jsx(Pie,{sensors:R,collisionDetection:yie,onDragEnd:Ne,children:s.jsx(Oie,{items:he.map(_e=>_e.id),strategy:ZXe,children:s.jsx("div",{className:"space-y-3",children:he.map((_e,le)=>s.jsx(Gj,{item:_e,position:le+1,onEdit:()=>u(_e),onCancel:()=>p({type:"cancel",item:_e}),onRemove:()=>{},onStop:()=>{},onRequeue:()=>{},onStart:()=>te.mutate(_e.id),timeFormat:O,isSelected:b.includes(_e.id),onToggleSelect:()=>ie(_e.id)},_e.id))})})})]}),Ae.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:["(",Ae.length," item",Ae.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:S,onChange:_e=>M(_e.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:()=>A(!E),title:E?"Ascending (oldest first)":"Descending (newest first)",className:"px-2",children:E?s.jsx(fg,{className:"w-4 h-4"}):s.jsx(T0,{className:"w-4 h-4"})})]})]}),s.jsx("div",{className:"space-y-3",children:Ae.slice(0,20).map((_e,le)=>s.jsx(Gj,{item:_e,position:le+1,onEdit:()=>{},onCancel:()=>{},onRemove:()=>p({type:"remove",item:_e}),onStop:()=>{},onRequeue:()=>f(_e),onStart:()=>{},timeFormat:O},_e.id))})]})]}),c&&s.jsx(ah,{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(ah,{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"?X.mutate(m.item.id):m.type==="stop"?Z.mutate(m.item.id):G.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 ${Ae.length} item${Ae.length!==1?"s":""} from the history?`,confirmText:"Clear History",variant:"danger",onConfirm:()=>{z.mutate(),l(!1)},onCancel:()=>l(!1)}),x&&s.jsx(dYe,{selectedCount:b.length,printers:W?.map(_e=>({id:_e.id,name:_e.name}))||[],onSave:_e=>{Object.keys(_e).length>0&&V.mutate({item_ids:b,..._e})},onClose:()=>v(!1),isSaving:V.isPending})]})}function fYe({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(E=>{const A=E[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 O=U.split("T")[0];S[O]=(S[O]||0)+1});const M=new Date,E=new Date(M);E.setMonth(E.getMonth()-e),E.setDate(E.getDate()-E.getDay());const A=[],k=[];let T=[],D=-1;const C=new Date(E);let R=0;for(;C<=M;)C.getDay()===0&&T.length>0&&(A.push(T),T=[],R++),C.getMonth()!==D&&(k.push({month:C.toLocaleDateString("en-US",{month:"short"}),weekIndex:R}),D=C.getMonth()),T.push(new Date(C)),C.setDate(C.getDate()+1);return T.length>0&&A.push(T),{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,y=f>0?Math.floor((b-(f-1)*p)/f):12,x=Math.max(8,Math.min(20,y)),v=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},E)=>s.jsx("div",{className:"text-bambu-gray",style:{fontSize:v,marginLeft:E===0?0:`${(M-(o[E-1]?.weekIndex||0))*(x+p)-24}px`},children:S},E))}),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:v,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(E=>{const A=S.find(C=>C.getDay()===E);if(!A)return s.jsx("div",{style:{width:x,height:x}},E);const k=A.toISOString().split("T")[0],T=l[k]||0,D=k===new Date().toISOString().split("T")[0];return s.jsx("div",{className:`rounded-sm ${u(T)} ${D?"ring-1 ring-white":""}`,style:{width:x,height:x},title:`${A.toLocaleDateString()}: ${T} print${T!==1?"s":""}`},E)})},M))]}),s.jsxs("div",{className:"flex items-center gap-2 mt-3 text-bambu-gray",style:{fontSize:v},children:[s.jsx("span",{children:"Less"}),s.jsxs("div",{className:"flex",style:{gap:p},children:[s.jsx("div",{className:"rounded-sm bg-bambu-dark",style:{width: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 q1=["#00ae42","#3b82f6","#f59e0b","#ef4444","#8b5cf6","#ec4899","#14b8a6","#f97316"];function mYe(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 pYe({archives:t,currency:e="$"}){const[n,r]=w.useState("30d"),i=w.useMemo(()=>{const m=mYe(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,y=`${b.getFullYear()}-${String(b.getMonth()+1).padStart(2,"0")}-${String(b.getDate()).padStart(2,"0")}`,x=m.get(y)||{date:y,filament:0,cost:0,prints:0};x.filament+=p.filament_used_grams||0,x.cost+=p.cost||0,x.prints+=1,m.set(y,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,y=new Date(b);y.setDate(b.getDate()-b.getDay());const x=`${y.getFullYear()}-${String(y.getMonth()+1).padStart(2,"0")}-${String(y.getDate()).padStart(2,"0")}`,v=m.get(x)||{week:x,filament:0,cost:0,prints:0};v.filament+=p.filament_used_grams||0,v.cost+=p.cost||0,v.prints+=1,m.set(x,v)}),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 y=(p.filament_type||"Unknown").split(", ");y.forEach(x=>{const v=(p.filament_used_grams||0)/y.length;m.set(x,(m.get(x)||0)+v)})}),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 y=new Date(m.getFullYear(),m.getMonth()-b,1),x=new Date(m.getFullYear(),m.getMonth()-b+1,0),v=y.toLocaleDateString("en-US",{month:"short",year:"2-digit"}),S=t.filter(M=>{const E=Si(M.completed_at||M.created_at)||new Date(0);return E>=y&&E<=x});p.push({month:v,filament:Math.round(S.reduce((M,E)=>M+(E.filament_used_grams||0),0)),cost:S.reduce((M,E)=>M+(E.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(rw,{width:"100%",height:250,children:s.jsxs(SPe,{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(PS,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),s.jsx(LS,{dataKey:"dateLabel",stroke:"#9ca3af",tick:{fontSize:12},interval:"preserveStartEnd"}),s.jsx(IS,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:m=>`${m}g`}),s.jsx(aw,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},labelStyle:{color:"#fff"},formatter:m=>[`${Number(m??0).toFixed(0)}g`,"Filament"]}),s.jsx(NJ,{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(rw,{width:160,height:160,children:s.jsxs(_Pe,{children:[s.jsx(QZ,{data:l,cx:"50%",cy:"50%",innerRadius:40,outerRadius:70,paddingAngle:2,dataKey:"value",children:l.map((m,p)=>s.jsx(By,{fill:q1[p%q1.length]},`cell-${p}`))}),s.jsx(aw,{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,v)=>x+v.value,0),y=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:q1[p%q1.length]}}),s.jsx("span",{className:"text-white truncate flex-1",children:m.name}),s.jsxs("span",{className:"text-bambu-gray flex-shrink-0",children:[y,"%"]})]},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(rw,{width:"100%",height:200,children:s.jsxs(cPe,{data:c,children:[s.jsx(PS,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),s.jsx(LS,{dataKey:"month",stroke:"#9ca3af",tick:{fontSize:12}}),s.jsx(IS,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:m=>`${m}g`}),s.jsx(aw,{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(yO,{}),s.jsx(kJ,{dataKey:"filament",name:"Filament (g)",fill:"#00ae42",radius:[4,4,0,0]})]})})]})]})]})}function gYe({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}=Iie({id:t}),p={transform:Vg.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(gg,{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(xK,{className:"w-4 h-4 text-bambu-gray hover:text-white"}):s.jsx(gK,{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(nN,{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 xYe({widgets:t,storageKey:e,columns:n=4,hideControls:r=!1,onResetLayout:i,renderControls:a}){const o=()=>{const E={};return t.forEach(A=>{E[A.id]=A.defaultSize||4}),E},[l,c]=w.useState(()=>{const E=localStorage.getItem(e);if(E)try{const A=JSON.parse(E);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 E=()=>d(A=>!A);return window.addEventListener("toggle-hidden-panel",E),()=>window.removeEventListener("toggle-hidden-panel",E)},[]),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=pie(qM(IE,{activationConstraint:{distance:8}}),qM(LE,{coordinateGetter:Fie})),m=E=>{const{active:A,over:k}=E;k&&A.id!==k.id&&c(T=>{const D=T.order.indexOf(A.id),C=T.order.indexOf(k.id);return{...T,order:zE(T.order,D,C)}})},p=E=>{c(A=>({...A,hidden:A.hidden.includes(E)?A.hidden.filter(k=>k!==E):[...A.hidden,E]}))},b=E=>{c(A=>{const k=A.sizes[E]||4,T=k===1?2:k===2?4:1;return{...A,sizes:{...A.sizes,[E]:T}}})},y=()=>{const E={order:t.map(A=>A.id),hidden:t.filter(A=>A.defaultVisible===!1).map(A=>A.id),sizes:o()};c(E),i?.()},x=l.order.map(E=>t.find(A=>A.id===E)).filter(Boolean),v=x.filter(E=>!l.hidden.includes(E.id)),S=x.filter(E=>l.hidden.includes(E.id)),M=a?.({hiddenCount:S.length,showHiddenPanel:u,setShowHiddenPanel:d,resetLayout:y});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:y,children:[s.jsx(cm,{className:"w-4 h-4"}),"Reset Layout"]}),S.length>0&&s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>d(!u),children:[s.jsx(Uf,{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(E=>s.jsxs("button",{onClick:()=>p(E.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(Uf,{className:"w-3 h-3"}),E.title]},E.id))})]}),s.jsx(Pie,{sensors:f,collisionDetection:yie,onDragEnd:m,children:s.jsx(Oie,{items:v.map(E=>E.id),strategy:gI,children:s.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:v.map(E=>s.jsx(gYe,{id:E.id,title:E.title,component:E.component,isHidden:l.hidden.includes(E.id),size:l.sizes[E.id]||2,onToggleVisibility:()=>p(E.id),onToggleSize:()=>b(E.id)},E.id))})})}),v.length===0&&s.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[s.jsx("p",{children:"All widgets are hidden."}),s.jsx(Me,{className:"mt-4",onClick:y,children:"Reset Layout"})]})]})}function bYe({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(Zl,{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(Zl,{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(pP,{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($f,{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(pP,{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 yYe({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 vYe({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(wK,{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,y])=>s.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[s.jsx("span",{className:"text-bambu-gray truncate max-w-[100px]",children:e.get(b)||`Printer ${b}`}),s.jsxs("span",{className:`font-medium ${y>=95&&y<=105?"text-status-ok":y>105?"text-blue-400":"text-status-warning"}`,children:[y.toFixed(0),"%"]})]},b))})]})]})}function _Ye({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 wYe({printDates:t,size:e=2}){const n=e===1?3:e===2?6:12;return s.jsx(fYe,{printDates:t,months:n})}function SYe({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 MYe({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(pYe,{archives:t,currency:e})}function NYe({size:t=1}){const{data:e,isLoading:n}=ft({queryKey:["failureAnalysis"],queryFn:()=>fe.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(MK,{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 EYe(){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 T=()=>{try{const C=localStorage.getItem("bambusy-dashboard-layout");if(C){const R=JSON.parse(C);c(R.hidden?.length||0)}}catch{c(0)}};T(),window.addEventListener("storage",T);const D=setInterval(T,500);return()=>{window.removeEventListener("storage",T),clearInterval(D)}},[a]);const{data:f,isLoading:m,refetch:p}=ft({queryKey:["archiveStats"],queryFn:fe.getArchiveStats}),{data:b}=ft({queryKey:["printers"],queryFn:fe.getPrinters}),{data:y}=ft({queryKey:["archives"],queryFn:()=>fe.getArchives(void 0,void 0,1e3,0)}),{data:x}=ft({queryKey:["settings"],queryFn:fe.getSettings}),v=async T=>{i(!1),n(!0);try{const{blob:D,filename:C}=await fe.exportStats({format:T,days:90}),R=URL.createObjectURL(D),U=document.createElement("a");U.href=R,U.download=C,U.click(),URL.revokeObjectURL(R),t("Export downloaded")}catch{t("Export failed","error")}finally{n(!1)}},S=async()=>{d(!0);try{const T=await fe.recalculateCosts();await p(),t(`Recalculated costs for ${T.updated} archives`)}catch{t("Failed to recalculate costs","error")}finally{d(!1)}},M=x?.currency||"$",E=new Map(b?.map(T=>[String(T.id),T.name])||[]),A=y?.map(T=>T.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(bYe,{stats:f,currency:M}),defaultSize:2},{id:"success-rate",title:"Success Rate",component:T=>s.jsx(yYe,{stats:f,printerMap:E,size:T}),defaultSize:1},{id:"time-accuracy",title:"Time Accuracy",component:T=>s.jsx(vYe,{stats:f,printerMap:E,size:T}),defaultSize:1},{id:"filament-types",title:"Filament Types",component:T=>s.jsx(_Ye,{stats:f,size:T}),defaultSize:1},{id:"failure-analysis",title:"Failure Analysis (30 days)",component:T=>s.jsx(NYe,{size:T}),defaultSize:1},{id:"print-activity",title:"Print Activity",component:T=>s.jsx(wYe,{printDates:A,size:T}),defaultSize:2},{id:"prints-by-printer",title:"Prints by Printer",component:s.jsx(SYe,{stats:f,printerMap:E}),defaultSize:2},{id:"filament-trends",title:"Filament Usage Trends",component:s.jsx(MYe,{archives:y||[],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(Uf,{className:"w-4 h-4"}),l," Hidden"]}),s.jsxs(Me,{variant:"secondary",onClick:()=>{localStorage.removeItem("bambusy-dashboard-layout"),o(T=>T+1),t("Layout reset")},children:[s.jsx(cm,{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(Xue,{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(Pw,{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:()=>v("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:()=>v("xlsx"),children:[s.jsx(Pw,{className:"w-4 h-4"}),"Export as Excel"]})]})]})]})]}),s.jsx(xYe,{widgets:k,storageKey:"bambusy-dashboard-layout",hideControls:!0},a)]})}function AYe({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:()=>fe.getSmartPlugStatus(t.id),refetchInterval:3e4}),{data:b}=ft({queryKey:["printers"],queryFn:fe.getPrinters}),y=b?.find(D=>D.id===t.printer_id),x=pt({mutationFn:D=>fe.controlSmartPlug(t.id,D),onMutate:async D=>{await n.cancelQueries({queryKey:["smart-plug-status",t.id]});const C=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:C}},onError:(D,C,R)=>{R?.previousStatus&&n.setQueryData(["smart-plug-status",t.id],R.previousStatus),r(`Failed to turn ${C} "${t.name}"`,"error")},onSettled:()=>{setTimeout(()=>{n.invalidateQueries({queryKey:["smart-plug-status",t.id]}),n.invalidateQueries({queryKey:["smart-plugs"]})},1e3)}}),v=pt({mutationFn:D=>fe.updateSmartPlug(t.id,D),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&n.invalidateQueries({queryKey:["smartPlugByPrinter",t.printer_id]})}}),S=pt({mutationFn:()=>fe.deleteSmartPlug(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]})}}),M=m?.state==="ON",E=m?.reachable??!1,A=x.isPending,T=(()=>{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(Et,{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 ${E?M?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:t.plug_type==="homeassistant"?s.jsx(oN,{className:`w-5 h-5 ${E?M?"text-bambu-green":"text-bambu-gray":"text-red-400"}`}):s.jsx(Ws,{className:`w-5 h-5 ${E?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"}):E?s.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[s.jsx(Jp,{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(Qg,{className:"w-4 h-4"}),s.jsx("span",{children:"Offline"})]}),T&&s.jsxs("a",{href:T,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"]})]})]}),y&&s.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Linked to: "}),s.jsx("span",{className:"text-sm text-white",children:y.name})]}),(t.power_alert_enabled||t.schedule_enabled)&&s.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-3",children:[t.power_alert_enabled&&s.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded-full",children:[s.jsx(_f,{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:!E||A,onClick:()=>l(!0),className:"flex-1",children:[A?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(Su,{className:"w-4 h-4"}),"On"]}),s.jsxs(Me,{size:"sm",variant:M?"secondary":"primary",disabled:!E||A,onClick:()=>u(!0),className:"flex-1",children:[A?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(dN,{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(Xd,{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(lN,{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=>v.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=>v.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=>v.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=>v.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:()=>v.mutate({off_delay_mode:"time"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="time"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[s.jsx(Jn,{className:"w-4 h-4"}),"Time"]}),s.jsxs("button",{onClick:()=>v.mutate({off_delay_mode:"temperature"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="temperature"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[s.jsx(fN,{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=>v.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=>v.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(uN,{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 TYe({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,y]=w.useState(t?.ha_entity_id||""),[x,v]=w.useState(t?.ha_power_entity||""),[S,M]=w.useState(t?.ha_energy_today_entity||""),[E,A]=w.useState(t?.ha_energy_total_entity||""),[k,T]=w.useState(""),[D,C]=w.useState(""),[R,U]=w.useState(!1),O=w.useRef(null),[q,j]=w.useState(""),[W,X]=w.useState(!1),G=w.useRef(null),[Z,te]=w.useState(""),[ee,z]=w.useState(!1),V=w.useRef(null),[ne,ie]=w.useState(""),[he,me]=w.useState(!1),oe=w.useRef(null),[Ae,ge]=w.useState(t?.printer_id||null),[Ne,_e]=w.useState(null),[le,He]=w.useState(null),[H,J]=w.useState(t?.power_alert_enabled||!1),[K,B]=w.useState(t?.power_alert_high?.toString()||""),[I,ce]=w.useState(t?.power_alert_low?.toString()||""),[Ee,Ie]=w.useState(t?.schedule_enabled||!1),[ue,$]=w.useState(t?.schedule_on_time||""),[L,Y]=w.useState(t?.schedule_off_time||""),[pe,Se]=w.useState(t?.show_in_switchbar||!1),[ae,je]=w.useState(!1),[De,Xe]=w.useState({scanned:0,total:0}),[et,Qe]=w.useState([]),se=w.useRef(null),{data:ye}=ft({queryKey:["printers"],queryFn:fe.getPrinters}),{data:ke}=ft({queryKey:["smart-plugs"],queryFn:fe.getSmartPlugs}),{data:Ue}=ft({queryKey:["settings"],queryFn:fe.getSettings}),dt=!!(Ue?.ha_enabled&&Ue?.ha_url&&Ue?.ha_token);w.useEffect(()=>{const xt=setTimeout(()=>{C(k)},300);return()=>clearTimeout(xt)},[k]),w.useEffect(()=>{const xt=Yt=>{O.current&&!O.current.contains(Yt.target)&&U(!1),G.current&&!G.current.contains(Yt.target)&&X(!1),V.current&&!V.current.contains(Yt.target)&&z(!1),oe.current&&!oe.current.contains(Yt.target)&&me(!1)};return document.addEventListener("mousedown",xt),()=>document.removeEventListener("mousedown",xt)},[]);const{data:re,isLoading:Fe,error:ve}=ft({queryKey:["ha-entities",D],queryFn:()=>fe.getHAEntities(D||void 0),enabled:i==="homeassistant"&&dt,retry:!1,staleTime:0}),{data:$e}=ft({queryKey:["ha-sensor-entities"],queryFn:fe.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()=>{je(!0),Qe([]),Xe({scanned:0,total:0}),He(null);try{await fe.startTasmotaScan();const xt=async()=>{try{const Yt=await fe.getTasmotaScanStatus();Xe({scanned:Yt.scanned,total:Yt.total});const sn=await fe.getDiscoveredTasmotaDevices();Qe(sn),Yt.running||(je(!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){je(!1);const Yt=xt instanceof Error?xt.message:typeof xt=="string"?xt:JSON.stringify(xt);He(Yt||"Failed to start scan")}},Te=async()=>{try{await fe.stopTasmotaScan()}catch{}je(!1),se.current&&(clearInterval(se.current),se.current=null)},We=xt=>{u(xt.ip_address),l(xt.name),_e(null)},it=pt({mutationFn:()=>fe.testSmartPlugConnection(c,d||null,m||null),onSuccess:xt=>{_e(xt),He(null),!o&&xt.device_name&&l(xt.device_name)},onError:xt=>{_e(null),He(xt.message)}}),Ot=pt({mutationFn:xt=>fe.createSmartPlug(xt),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:xt=>{He(xt.message)}}),kt=pt({mutationFn:xt=>fe.updateSmartPlug(t.id,xt),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:xt=>{He(xt.message)}}),on=ye?.filter(xt=>!ke?.some(sn=>sn.printer_id===xt.id&&sn.id!==t?.id)),Ut=xt=>{if(xt.preventDefault(),He(null),!o.trim()){He("Name is required");return}if(i==="tasmota"&&!c.trim()){He("IP address is required for Tasmota plugs");return}if(i==="homeassistant"&&!b){He("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"&&E||null,username:i==="tasmota"&&d.trim()||null,password:i==="tasmota"&&m.trim()||null,printer_id:Ae,power_alert_enabled:H,power_alert_high:K?parseFloat(K):null,power_alert_low:I?parseFloat(I):null,schedule_enabled:Ee,schedule_on_time:ue||null,schedule_off_time:L||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(Ht,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:Ut,className:"p-6 space-y-4 overflow-y-auto",children:[le&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:le}),!r&&s.jsxs("div",{className:"flex gap-2 mb-2",children:[s.jsxs("button",{type:"button",onClick:()=>{a("tasmota"),_e(null),He(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"),_e(null),He(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(oN,{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:Te,className:"w-full",children:[s.jsx(Ht,{className:"w-4 h-4"}),"Stop Scanning"]}):s.jsxs(Me,{type:"button",variant:"primary",onClick:Le,className:"w-full",children:[s.jsx(Ma,{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:()=>We(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(Su,{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=ke?.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:O,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(Ma,{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=>{T(Tt.target.value),R||U(!0)},onFocus:()=>{U(!0),T("")},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:()=>{y(""),T("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Ht,{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:()=>{y(Tt.entity_id),U(!1),T(""),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:G,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(Ma,{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||X(!0)},onFocus:()=>{X(!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:()=>{v(""),j("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Ht,{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:()=>{v(""),X(!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:()=>{v(Tt.entity_id),X(!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=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===S);return s.jsxs("div",{ref:V,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(Ma,{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:ee?Z:sn?`${sn.friendly_name} (${sn.state} ${sn.unit_of_measurement})`:"",onChange:Tt=>{te(Tt.target.value),ee||z(!0)},onFocus:()=>{z(!0),te("")},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&&!ee&&s.jsx("button",{type:"button",onClick:()=>{M(""),te("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Ht,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),ee&&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),te("")},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),te("")},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=ne?xt.filter(Tt=>Tt.entity_id.toLowerCase().includes(ne.toLowerCase())||Tt.friendly_name.toLowerCase().includes(ne.toLowerCase())):xt,sn=$e.find(Tt=>Tt.entity_id===E);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(Ma,{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?ne:sn?`${sn.friendly_name} (${sn.state} ${sn.unit_of_measurement})`:"",onChange:Tt=>{ie(Tt.target.value),he||me(!0)},onFocus:()=>{me(!0),ie("")},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"}),E&&!he&&s.jsx("button",{type:"button",onClick:()=>{A(""),ie("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Ht,{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(""),me(!1),ie("")},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),me(!1),ie("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${Tt.entity_id===E?"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),_e(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(Jp,{className:"w-4 h-4"}),"Test"]})]})]}),i==="tasmota"&&Ne&&s.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${Ne.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:Ne.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:[Ne.device_name&&`Device: ${Ne.device_name} - `,"State: ",Ne.state]})]})]}):s.jsxs(s.Fragment,{children:[s.jsx(Qg,{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:Ae??"",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(_f,{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:H,onChange:xt=>J(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"})]})]}),H&&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:K,onChange:xt=>B(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:ue,onChange:xt=>$(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:L,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(lN,{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=>Se(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(ys,{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 CYe={callmebot:"CallMeBot/WhatsApp",ntfy:"ntfy",pushover:"Pushover",telegram:"Telegram",email:"Email",discord:"Discord",webhook:"Webhook"};function kYe({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:fe.getPrinters}),d=u?.find(y=>y.id===t.printer_id),f=pt({mutationFn:y=>fe.updateNotificationProvider(t.id,y),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),m=pt({mutationFn:()=>fe.deleteNotificationProvider(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),p=pt({mutationFn:()=>fe.testNotificationProvider(t.id),onSuccess:y=>{c(y),n.invalidateQueries({queryKey:["notification-providers"]})},onError:y=>{c({success:!1,message:y.message})}}),b=y=>y||"";return s.jsxs(s.Fragment,{children:[s.jsx(Et,{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(_f,{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:CYe[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: ",bg(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:y=>f.mutate({enabled:y})})]})]}),d&&s.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Printer: "}),s.jsx("span",{className:"text-sm text-white",children:d.name})]}),!d&&!t.printer_id&&s.jsx("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:s.jsx("span",{className:"text-xs text-bambu-gray",children:"All printers"})}),s.jsxs("div",{className:"mb-3 flex flex-wrap gap-1",children:[t.on_print_start&&s.jsx("span",{className:"px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded",children:"Start"}),t.on_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(Dw,{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(BD,{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(Xd,{className:"w-4 h-4"}),"Event Settings"]}),a?s.jsx(hu,{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:y=>f.mutate({enabled:y})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Print Events"}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Print Started"}),s.jsx(qn,{checked:t.on_print_start,onChange:y=>f.mutate({on_print_start:y})})]}),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:y=>f.mutate({on_plate_not_empty:y})})]}),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:y=>f.mutate({on_print_complete:y})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Print Failed"}),s.jsx(qn,{checked:t.on_print_failed,onChange:y=>f.mutate({on_print_failed:y})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Print Stopped"}),s.jsx(qn,{checked:t.on_print_stopped,onChange:y=>f.mutate({on_print_stopped:y})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Progress Milestones"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify at 25%, 50%, 75%"})]}),s.jsx(qn,{checked:t.on_print_progress,onChange:y=>f.mutate({on_print_progress:y})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Printer Status"}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Printer Offline"}),s.jsx(qn,{checked:t.on_printer_offline,onChange:y=>f.mutate({on_printer_offline:y})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Printer Error"}),s.jsx(qn,{checked:t.on_printer_error,onChange:y=>f.mutate({on_printer_error:y})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Low Filament"}),s.jsx(qn,{checked:t.on_filament_low,onChange:y=>f.mutate({on_filament_low:y})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Maintenance Due"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify when maintenance is needed"})]}),s.jsx(qn,{checked:t.on_maintenance_due??!1,onChange:y=>f.mutate({on_maintenance_due:y})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"AMS Alarms"}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"AMS Humidity High"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Regular AMS humidity exceeds threshold"})]}),s.jsx(qn,{checked:t.on_ams_humidity_high??!1,onChange:y=>f.mutate({on_ams_humidity_high:y})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"AMS Temperature High"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Regular AMS temperature exceeds threshold"})]}),s.jsx(qn,{checked:t.on_ams_temperature_high??!1,onChange:y=>f.mutate({on_ams_temperature_high:y})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"AMS-HT Alarms"}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"AMS-HT Humidity High"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"AMS-HT humidity exceeds threshold"})]}),s.jsx(qn,{checked:t.on_ams_ht_humidity_high??!1,onChange:y=>f.mutate({on_ams_ht_humidity_high:y})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"AMS-HT Temperature High"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"AMS-HT temperature exceeds threshold"})]}),s.jsx(qn,{checked:t.on_ams_ht_temperature_high??!1,onChange:y=>f.mutate({on_ams_ht_temperature_high:y})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Dw,{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:y=>f.mutate({quiet_hours_enabled:y})})]}),t.quiet_hours_enabled&&s.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"No notifications during these hours"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(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:y=>f.mutate({daily_digest_enabled:y})})]}),t.daily_digest_enabled&&s.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(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(uN,{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 uq=[{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 jYe({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,y]=w.useState(t?.quiet_hours_end||"07:00"),[x,v]=w.useState(t?.daily_digest_enabled||!1),[S,M]=w.useState(t?.daily_digest_time||"08:00"),[E,A]=w.useState(t?.on_print_start??!1),[k,T]=w.useState(t?.on_print_complete??!0),[D,C]=w.useState(t?.on_print_failed??!0),[R,U]=w.useState(t?.on_print_stopped??!0),[O,q]=w.useState(t?.on_print_progress??!1),[j,W]=w.useState(t?.on_printer_offline??!1),[X,G]=w.useState(t?.on_printer_error??!1),[Z,te]=w.useState(t?.on_filament_low??!1),[ee,z]=w.useState(t?.on_maintenance_due??!1),[V,ne]=w.useState(t?.config?Object.fromEntries(Object.entries(t.config).map(([B,I])=>[B,String(I)])):{}),[ie,he]=w.useState(null),[me,oe]=w.useState(null),{data:Ae}=ft({queryKey:["printers"],queryFn:fe.getPrinters});w.useEffect(()=>{const B=I=>{I.key==="Escape"&&e()};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[e]);const ge=pt({mutationFn:()=>fe.testNotificationConfig({provider_type:o,config:V}),onSuccess:B=>{he(B),oe(null)},onError:B=>{he({success:!1,message:B.message})}}),Ne=pt({mutationFn:B=>fe.createNotificationProvider(B),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:B=>{oe(B.message)}}),_e=pt({mutationFn:B=>fe.updateNotificationProvider(t.id,B),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:B=>{oe(B.message)}}),le=B=>{if(B.preventDefault(),oe(null),!i.trim()){oe("Name is required");return}const I=J(o);for(const Ee of I)if(!V[Ee.key]?.trim()){oe(`${Ee.label} is required`);return}const ce={name:i.trim(),provider_type:o,config:V,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:E,on_print_complete:k,on_print_failed:D,on_print_stopped:R,on_print_progress:O,on_printer_offline:j,on_printer_error:X,on_filament_low:Z,on_maintenance_due:ee};r?_e.mutate(ce):Ne.mutate(ce)},He=Ne.isPending||_e.isPending,H=B=>{switch(B){case"callmebot":return[{key:"phone",label:"Phone Number",placeholder:"+1234567890",type:"text",required:!0},{key:"apikey",label:"API Key",placeholder:"Your CallMeBot API key",type:"text",required:!0}];case"ntfy":return[{key:"server",label:"Server URL",placeholder:"https://ntfy.sh",type:"text",required:!1},{key:"topic",label:"Topic",placeholder:"my-bambuddy",type:"text",required:!0},{key:"auth_token",label:"Auth Token",placeholder:"Optional authentication",type:"password",required:!1}];case"pushover":return[{key:"user_key",label:"User Key",placeholder:"Your Pushover user key",type:"text",required:!0},{key:"app_token",label:"App Token",placeholder:"Your Pushover app token",type:"text",required:!0},{key:"priority",label:"Priority",placeholder:"0 (normal)",type:"number",required:!1}];case"telegram":return[{key:"bot_token",label:"Bot Token",placeholder:"Bot token from @BotFather",type:"password",required:!0},{key:"chat_id",label:"Chat ID",placeholder:"Your chat or group ID",type:"text",required:!0}];case"email":return[{key:"smtp_server",label:"SMTP Server",placeholder:"smtp.gmail.com",type:"text",required:!0},{key:"smtp_port",label:"SMTP Port",placeholder:"587",type:"number",required:!1},{key:"security",label:"Security",type:"select",required:!1,options:[{value:"starttls",label:"STARTTLS (Port 587)"},{value:"ssl",label:"SSL/TLS (Port 465)"},{value:"none",label:"None (Port 25)"}]},{key:"auth_enabled",label:"Authentication",type:"select",required:!1,options:[{value:"true",label:"Enabled"},{value:"false",label:"Disabled"}]},{key:"username",label:"Username",placeholder:"your@email.com",type:"text",required:!1},{key:"password",label:"Password",placeholder:"App password",type:"password",required:!1},{key:"from_email",label:"From Email",placeholder:"your@email.com",type:"text",required:!0},{key:"to_email",label:"To Email",placeholder:"recipient@email.com",type:"text",required:!0}];case"discord":return[{key:"webhook_url",label:"Webhook URL",placeholder:"https://discord.com/api/webhooks/...",type:"text",required:!0}];case"webhook":return[{key:"webhook_url",label:"Webhook URL",placeholder:"https://example.com/webhook",type:"text",required:!0},{key:"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[]}},J=B=>H(B).filter(I=>I.required),K=H(o);return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4 overflow-y-auto",onClick:e,children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-lg my-8 max-h-[90vh] overflow-y-auto",onClick:B=>B.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Notification Provider":"Add Notification Provider"}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Ht,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:le,className:"p-6 space-y-4",children:[me&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:me}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),s.jsx("input",{type:"text",value:i,onChange:B=>a(B.target.value),placeholder:"My Notifications",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Provider Type *"}),s.jsx("select",{value:o,onChange:B=>{l(B.target.value),ne({}),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:uq.map(B=>s.jsx("option",{value:B.value,children:B.label},B.value))}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:uq.find(B=>B.value===o)?.description})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Configuration"}),K.filter(B=>!("showIf"in B)||B.showIf?.(V)!==!1).map(B=>s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[B.label," ",B.required&&"*"]}),B.type==="select"&&"options"in B&&B.options?s.jsx("select",{value:V[B.key]||B.options[0]?.value||"",onChange:I=>{ne({...V,[B.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:B.options.map(I=>s.jsx("option",{value:I.value,children:I.label},I.value))}):s.jsx("input",{type:B.type,value:V[B.key]||"",onChange:I=>{ne({...V,[B.key]:I.target.value}),he(null)},placeholder:B.placeholder,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]},B.key))]}),s.jsx("div",{className:"flex gap-2",children:s.jsxs(Me,{type:"button",variant:"secondary",onClick:()=>{he(null),ge.mutate()},disabled:ge.isPending||!V[J(o)[0]?.key],className:"flex-1",children:[ge.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(BD,{className:"w-4 h-4"}),"Test Configuration"]})}),ie&&s.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${ie.success?"bg-bambu-green/20 border border-bambu-green/50 text-bambu-green":"bg-red-500/20 border border-red-500/50 text-red-400"}`,children:ie.success?s.jsxs(s.Fragment,{children:[s.jsx(Hn,{className:"w-5 h-5"}),s.jsx("span",{children:ie.message})]}):s.jsxs(s.Fragment,{children:[s.jsx(za,{className:"w-5 h-5"}),s.jsx("span",{children:ie.message})]})}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer Filter"}),s.jsxs("select",{value:c??"",onChange:B=>u(B.target.value?Number(B.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"",children:"All printers"}),Ae?.map(B=>s.jsx("option",{value:B.id,children:B.name},B.id))]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Only send notifications for events from this printer"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"text-sm text-white",children:"Quiet Hours (Do Not Disturb)"}),s.jsx(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:B=>p(B.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"End"}),s.jsx("input",{type:"time",value:b,onChange:B=>y(B.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-white",children:"Daily Digest"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"})]}),s.jsx(qn,{checked:x,onChange:v})]}),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:B=>M(B.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Events will be collected and sent as a single summary at this time"})]})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Notification Events"}),s.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Print Events"}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Start"}),s.jsx(qn,{checked:E,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:T})]}),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:C})]}),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:O,onChange:q})]})]})]}),s.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Printer Status"}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Offline"}),s.jsx(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:X,onChange:G})]}),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:Z,onChange:te})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Maintenance"}),s.jsx(qn,{checked:ee,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:He,className:"flex-1",children:[He?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(ys,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function PYe({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:fe.getTemplateVariables}),p=m?.find(A=>A.event_type===t.event_type),{data:b,isLoading:y}=ft({queryKey:["template-preview",t.event_type,i,o],queryFn:()=>fe.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=>fe.updateNotificationTemplate(t.id,A),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-templates"]}),e()},onError:A=>{u(A.message)}}),v=pt({mutationFn:()=>fe.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 T=k.selectionStart,D=k.selectionEnd,C=o,R=C.substring(0,T),U=C.substring(D),O=R+`{${A}}`+U;l(O),setTimeout(()=>{k.focus();const q=T+A.length+2;k.setSelectionRange(q,q)},0)},E=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(Ht,{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(Uf,{className:"w-4 h-4"}),"Live Preview"]}),s.jsx("button",{type:"button",onClick:()=>f(!d),className:"text-xs text-bambu-green hover:text-bambu-green-light",children:d?"Hide":"Show"})]}),d&&s.jsx("div",{className:"bg-bambu-dark border border-bambu-dark-tertiary rounded p-3 space-y-2",children:y?s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-sm",children:[s.jsx(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:()=>v.mutate(),disabled:v.isPending,className:"text-orange-400 hover:text-orange-300",children:[v.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin mr-2"}):s.jsx(cm,{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||!E,children:[x.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin mr-2"}):s.jsx(ys,{className:"w-4 h-4 mr-2"}),"Save"]})]})]})]})})}const RYe={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"},DYe={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 OYe({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:fe.getSettings}),d=u?.time_format||"system",{data:f,isLoading:m,refetch:p,isRefetching:b}=ft({queryKey:["notification-logs",r,l],queryFn:()=>fe.getNotificationLogs({days:r,limit:100,success:l?!1:void 0})}),{data:y}=ft({queryKey:["notification-log-stats",r],queryFn:()=>fe.getNotificationLogStats(r)}),x=pt({mutationFn:()=>fe.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")}}),v=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()+" "+Kme(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(Rw,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Notification Log"})]}),s.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:"×"})]}),y&&s.jsx("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50",children:s.jsxs("div",{className:"flex items-center gap-6 text-sm",children:[s.jsxs("span",{className:"text-bambu-gray",children:["Last ",r," days: ",s.jsx("span",{className:"text-white font-medium",children:y.total})," notifications"]}),s.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[s.jsx(Hn,{className:"w-4 h-4"}),y.success_count," sent"]}),y.failure_count>0&&s.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[s.jsx(za,{className:"w-4 h-4"}),y.failure_count," failed"]})]})}),s.jsxs("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary flex items-center gap-4",children:[s.jsxs("select",{value:r,onChange: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(LYe,{log:S,isExpanded:a===S.id,onToggle:()=>o(a===S.id?null:S.id),formatDate:v,formatFullDate:M=>yg(M,d)},S.id))}):s.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[s.jsx(Rw,{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 LYe({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 ${DYe[t.event_type]||"text-bambu-gray"}`,children:RYe[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(hu,{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 K1=[{id:"settings",labelKey:"backup.categories.settings",defaultLabel:"App Settings",icon:s.jsx(hN,{className:"w-4 h-4"}),default:!0,description:"Language, theme, update preferences"},{id:"notifications",labelKey:"backup.categories.notifications",defaultLabel:"Notification Providers",icon:s.jsx(_f,{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(Yg,{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(UD,{className:"w-4 h-4"}),default:!1,description:"Filament types and costs"},{id:"maintenance",labelKey:"backup.categories.maintenance",defaultLabel:"Maintenance Types",icon:s.jsx(Yd,{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(cf,{className:"w-4 h-4"}),default:!1,description:"Webhook API keys (new keys generated on import)"}];function IYe({onClose:t,onExport:e}){const{t:n}=Wg(),[r,i]=w.useState(()=>{const b={};return K1.forEach(y=>{b[y.id]=y.default}),b}),[a,o]=w.useState(!1),[l,c]=w.useState(!1);w.useEffect(()=>{const b=y=>{y.key==="Escape"&&t()};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[t]);const u=b=>{i(y=>({...y,[b]:!y[b]}))},d=()=>{const b={};K1.forEach(y=>{b[y.id]=!0}),i(b)},f=()=>{const b={};K1.forEach(y=>{b[y.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(Et,{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(Ht,{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:K1.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(cf,{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 dq={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 FYe({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 E=A=>{A.key==="Escape"&&r!=="restoring"&&(r==="result"&&u?.success&&n(),t())};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[t,n,r,u]);const b=E=>{const A=E.target.files?.[0];A&&c(A)},y=async()=>{if(l){i("restoring");try{const E=await e(l,a);d(E),i("result")}catch{d({success:!1,message:"Failed to restore backup. Please check the file format."}),i("result")}}},x=()=>{u?.success&&n(),t()},v=E=>{m(A=>{const k=new Set(A);return k.has(E)?k.delete(E):k.add(E),k})},S=u?.restored?Object.values(u.restored).reduce((E,A)=>E+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:E=>{E.target===E.currentTarget&&r!=="restoring"&&t()},children:s.jsx(Et,{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(Ht,{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(Lw,{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:y,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(([,E])=>E>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(([,E])=>E>0).map(([E,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:dq[E]||E}),s.jsx("span",{className:"text-bambu-green font-medium",children:A})]},E)),(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(([,E])=>E>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(Lw,{className:"w-4 h-4 text-yellow-500"}),"Skipped (already exist)"]}),s.jsx("div",{className:"space-y-1",children:Object.entries(u.skipped).filter(([,E])=>E>0).map(([E,A])=>{const k=u.skipped_details?.[E]||[],T=f.has(E);return s.jsxs("div",{children:[s.jsxs("button",{onClick:()=>k.length>0&&v(E),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:[dq[E]||E,k.length>0&&(T?s.jsx(hu,{className:"w-3 h-3"}):s.jsx(Oi,{className:"w-3 h-3"}))]}),s.jsx("span",{className:"text-yellow-500 font-medium",children:A})]}),T&&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,C)=>s.jsx("div",{children:D},C)),k.length>10&&s.jsxs("div",{className:"text-bambu-gray/60",children:["...and ",k.length-10," more"]})]})]},E)})})]}),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((E,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:E.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:E.key}),s.jsx("button",{onClick:()=>navigator.clipboard.writeText(E.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 UYe(){const t=await fetch("/api/v1/settings/spoolman");if(!t.ok)throw new Error("Failed to load Spoolman settings");return t.json()}async function zYe(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 BYe(){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:y,isLoading:x}=ft({queryKey:["spoolman-settings"],queryFn:UYe}),{data:v,isLoading:S,refetch:M}=ft({queryKey:["spoolman-status"],queryFn:fe.getSpoolmanStatus,refetchInterval:3e4}),{data:E}=ft({queryKey:["printers"],queryFn:fe.getPrinters});w.useEffect(()=>{y&&(n(y.spoolman_enabled==="true"),i(y.spoolman_url||""),o(y.spoolman_sync_mode||"auto"),m(!0))},[y]),w.useEffect(()=>{if(!f||!y)return;if(y.spoolman_enabled==="true"!==e||(y.spoolman_url||"")!==r||(y.spoolman_sync_mode||"auto")!==a){const W=setTimeout(()=>{A.mutate()},500);return()=>clearTimeout(W)}},[e,r,a,f]);const A=pt({mutationFn:()=>zYe({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:fe.connectSpoolman,onSuccess:()=>{M()}}),T=pt({mutationFn:fe.disconnectSpoolman,onSuccess:()=>{M()}}),D=pt({mutationFn:fe.syncAllPrintersAms,onSuccess:j=>{j.success}}),C=pt({mutationFn:j=>fe.syncPrinterAms(j),onSuccess:j=>{j.success}}),R=()=>{u==="all"?D.mutate():C.mutate(u)},U=D.isPending||C.isPending,O=u==="all"?D.data:C.data,q=u==="all"?D.isSuccess:C.isSuccess;return x?s.jsxs(Et,{children:[s.jsx(Nr,{children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(pg,{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(Et,{children:[s.jsx(Nr,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(pg,{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(ts,{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(Ql,{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"}):v?.connected?s.jsxs("span",{className:"flex items-center gap-1 text-sm text-green-500",children:[s.jsx(ts,{className:"w-4 h-4"}),"Connected"]}):s.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-500",children:[s.jsx(Ht,{className:"w-4 h-4"}),"Disconnected"]})]}),s.jsx("div",{className:"flex gap-2",children:v?.connected?s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>T.mutate(),disabled:T.isPending,children:[T.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(Ohe,{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}),v?.connected&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Sync AMS Data"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Manually sync printer AMS data to Spoolman"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsxs("select",{value:u,onChange: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"}),E?.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&&O&&s.jsxs("div",{className:"mt-3 space-y-2",children:[s.jsx("div",{className:`p-2 rounded text-sm ${O.success?"bg-green-500/20 border border-green-500/50 text-green-400":"bg-yellow-500/20 border border-yellow-500/50 text-yellow-400"}`,children:O.success?`Synced ${O.synced_count} spool${O.synced_count!==1?"s":""} successfully`:`Synced ${O.synced_count} spool${O.synced_count!==1?"s":""} with ${O.errors.length} error${O.errors.length!==1?"s":""}`}),O.skipped_count>0&&s.jsxs("div",{className:"p-2 bg-amber-500/10 border border-amber-500/30 rounded text-sm",children:[s.jsxs("div",{className:"flex items-center justify-between text-amber-400 mb-1",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(Tn,{className:"w-3.5 h-3.5"}),s.jsxs("span",{className:"font-medium",children:[O.skipped_count," spool",O.skipped_count!==1?"s":""," skipped"]})]}),O.skipped_count>5&&s.jsx("button",{onClick:()=>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?O.skipped:O.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&&O.skipped_count>5&&s.jsxs("li",{className:"text-amber-300/60 italic",children:["...and ",O.skipped_count-5," more"]})]})]}),O.errors.length>0&&s.jsxs("div",{className:"p-2 bg-red-500/10 border border-red-500/30 rounded text-sm",children:[s.jsx("div",{className:"text-red-400 font-medium mb-1",children:"Errors:"}),s.jsx("ul",{className:"text-xs text-red-300/80 space-y-0.5",children:O.errors.map((j,W)=>s.jsx("li",{children:j},W))})]})]})]})]})]})}function $Ye({link:t,onClose:e}){const n=ln(),{mode:r}=lh(),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,y]=w.useState(t?.custom_icon?fe.getExternalLinkIconUrl(t.id):null),[x,v]=w.useState(null),[S,M]=w.useState(null);w.useEffect(()=>{const U=O=>{O.key==="Escape"&&e()};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[e]);const E=pt({mutationFn:async U=>{const O=await fe.createExternalLink(U);return x?await fe.uploadExternalLinkIcon(O.id,x):O},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:U=>{M(U.message)}}),A=pt({mutationFn:async U=>{let O=await fe.updateExternalLink(t.id,U);return x?O=await fe.uploadExternalLinkIcon(t.id,x):!m&&t?.custom_icon&&(O=await fe.deleteExternalLinkIcon(t.id)),O},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:U=>{M(U.message)}}),k=U=>{const O=U.target.files?.[0];if(O){if(!["image/png","image/jpeg","image/gif","image/svg+xml","image/webp","image/x-icon"].includes(O.type)){M("Please select a valid image file (PNG, JPG, GIF, SVG, WebP, or ICO)");return}if(O.size>1024*1024){M("Image file must be less than 1MB");return}v(O),p(!0);const j=new FileReader;j.onload=W=>{y(W.target?.result)},j.readAsDataURL(O)}},T=()=>{v(null),y(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 O={name:o.trim(),url:c.trim(),icon:d};i?A.mutate(O):E.mutate(O)},C=E.isPending||A.isPending,R=mN(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(Ht,{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:T,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($me,{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:C,className:"flex-1",children:[C?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(ys,{className:"w-4 h-4"}),i?"Save":"Add"]})]})]})]})})}function HYe(){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:fe.getExternalLinks}),f=pt({mutationFn:S=>fe.deleteExternalLink(S),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),m=pt({mutationFn:S=>fe.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"},y=(S,M)=>{if(S.preventDefault(),l===null||l===M||!u)return;const E=u.map(D=>D.id),A=E.indexOf(l),k=E.indexOf(M);if(A===-1||k===-1)return;const T=[...E];T.splice(A,1),T.splice(k,0,l),m.mutate(T),c(null)},x=S=>{o(S)},v=()=>{a&&(f.mutate(a.id),o(null))};return s.jsxs(s.Fragment,{children:[s.jsxs(Et,{children:[s.jsx(Nr,{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=mN(S.icon);return s.jsxs("div",{draggable:!0,onDragStart:E=>p(E,S.id),onDragOver:b,onDrop:E=>y(E,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(gg,{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(sa,{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($Ye,{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:v,onCancel:()=>o(null)})]})}function VYe(){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:y}=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 v=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 C=b.mode==="queue"?"review":b.mode;l(C==="print_queue"||C==="review"?C:"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"),v.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"),v.mutate({access_code:i}),a("")},E=D=>{l(D),p("mode"),v.mutate({mode:D})},A=D=>{u(D),p("model"),v.mutate({model:D})};if(y)return s.jsx(Et,{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,T=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(Et,{children:[s.jsx(Nr,{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 ${T?"text-green-400":"text-bambu-gray"}`,children:[s.jsx("span",{className:`w-2 h-2 rounded-full ${T?"bg-green-400 animate-pulse":"bg-gray-500"}`}),T?"Running":"Stopped"]})]})}),s.jsxs(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:T?'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],[,C])=>D.localeCompare(C)).map(([D,C])=>s.jsx("option",{value:D,children:C},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&&T&&s.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:[s.jsx(Ql,{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(ts,{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(nN,{className:"w-4 h-4"}):s.jsx(Uf,{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:()=>E("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:()=>E("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:()=>E("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(Et,{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(Et,{children:s.jsx(Ct,{className:"py-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Ql,{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&&T&&s.jsxs(Et,{children:[s.jsx(Nr,{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 GYe={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 WYe(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,WYe(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 qYe({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),[y,x]=w.useState(!1);w.useEffect(()=>{if(a&&n.parameters){const D={};for(const C of n.parameters)C.schema?.default!==void 0&&(D[C.name]=String(C.schema.default));c(C=>({...D,...C}))}},[a,n.parameters]),w.useEffect(()=>{if(a&&n.requestBody?.content?.["application/json"]?.schema&&!u){const D=n.requestBody.content["application/json"].schema,C=Zb(r,D);d(JSON.stringify(C,null,2))}},[a,n.requestBody,r,u]);const S=(()=>{const D=[];for(const C of n.parameters||[])if(C.in==="path"||C.required){const R=l[C.name];(R===void 0||R==="")&&D.push(C.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 C=new URLSearchParams;for(const ee of n.parameters||[]){const z=l[ee.name];z!==void 0&&z!==""&&(ee.in==="path"?D=D.replace(`{${ee.name}}`,encodeURIComponent(z)):ee.in==="query"&&C.append(ee.name,z))}const R=C.toString(),U=`${D}${R?`?${R}`:""}`,O={"Content-Type":"application/json"};i&&(O["X-API-Key"]=i);const q={method:e.toUpperCase(),headers:O};["post","put","patch"].includes(e)&&u&&(q.body=u);const j=performance.now(),W=await fetch(U,q),X=Math.round(performance.now()-j),G={};W.headers.forEach((ee,z)=>{G[z]=ee});let Z;W.headers.get("content-type")?.includes("application/json")?Z=await W.json():Z=await W.text(),m({status:W.status,statusText:W.statusText,headers:G,body:Z,duration:X})}catch(D){m({status:0,statusText:"Network Error",headers:{},body:D instanceof Error?D.message:"Unknown error",duration:0})}finally{b(!1)}},E=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 C=document.createElement("textarea");C.value=D,C.style.position="fixed",C.style.left="-999999px",document.body.appendChild(C),C.select(),document.execCommand("copy"),document.body.removeChild(C),x(!0),setTimeout(()=>x(!1),2e3)}}},A=(n.parameters||[]).filter(D=>D.in==="path"),k=(n.parameters||[]).filter(D=>D.in==="query"),T=["post","put","patch"].includes(e)&&n.requestBody;return s.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden",children:[s.jsxs("button",{onClick:()=>o(!a),className:"w-full flex items-center gap-3 p-3 hover:bg-bambu-dark-tertiary/50 transition-colors text-left",children:[a?s.jsx(Oi,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}):s.jsx(Qs,{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 ${GYe[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:C=>c(R=>({...R,[D.name]:C.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:C=>c(R=>({...R,[D.name]:C.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(C=>s.jsx("option",{value:C,children:C},C))]}):s.jsx("input",{type:"text",value:l[D.name]||"",onChange:C=>c(R=>({...R,[D.name]:C.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))})]}),T&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("h4",{className:"text-sm font-medium text-white",children:"Request Body"}),s.jsx("textarea",{value:u,onChange: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(cl,{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:E,children:y?s.jsx(Hn,{className:"w-3 h-3 text-green-400"}):s.jsx(sl,{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 KYe({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 v=await fetch("/openapi.json");if(!v.ok)throw new Error("Failed to fetch OpenAPI schema");const S=await v.json();n(S)}catch(v){o(v instanceof Error?v.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(Et,{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,v]of Object.entries(e.paths))for(const[S,M]of Object.entries(v)){if(S==="parameters")continue;const E=M.tags||["Other"];for(const A of E)f[A]||(f[A]=[]),f[A].push({path:x,method:S,spec:M})}const m=Object.entries(f).map(([x,v])=>{if(!u)return{tag:x,endpoints:v};const S=v.filter(({path:M,method:E,spec:A})=>{const k=u.toLowerCase();return M.toLowerCase().includes(k)||E.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,v)=>x.tag.localeCompare(v.tag)),p=x=>{c(v=>{const S=new Set(v);return S.has(x)?S.delete(x):S.add(x),S})},b=()=>{c(new Set(m.map(x=>x.tag)))},y=()=>{c(new Set)};return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between gap-4",children:[s.jsx("div",{className:"flex-1",children:s.jsx("input",{type:"text",value:u,onChange: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:y,children:"Collapse All"}),s.jsxs("a",{href:"/docs",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-sm text-bambu-green hover:underline",children:[s.jsx(Gr,{className:"w-4 h-4"}),"Swagger UI"]})]})]}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:[m.reduce((x,v)=>x+v.endpoints.length,0)," endpoints in ",m.length," categories"]}),s.jsx("div",{className:"space-y-3",children:m.map(({tag:x,endpoints:v})=>s.jsxs(Et,{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(Qs,{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:v.length})]})}),l.has(x)&&s.jsx(Ct,{className:"pt-0 space-y-2",children:v.map(({path:S,method:M,spec:E})=>s.jsx(qYe,{path:S,method:M,spec:E,schema:e,apiKey:t},`${M}-${S}`))})]},x))})]})}const XYe=["general","network","plugs","notifications","filament","apikeys","virtual-printer","users"];function YYe(){const t=ln(),e=pl(),[n,r]=Vq(),{t:i,i18n:a}=Wg(),{showToast:o,showPersistentToast:l,dismissToast:c}=Yn(),{authEnabled:u,user:d,refreshAuth:f}=ch(),{mode:m,darkStyle:p,darkBackground:b,darkAccent:y,lightStyle:x,lightBackground:v,lightAccent:S,setDarkStyle:M,setDarkBackground:E,setDarkAccent:A,setLightStyle:k,setLightBackground:T,setLightAccent:D}=lh(),[C,R]=w.useState(null),[U,O]=w.useState(!1),[q,j]=w.useState(null),[W,X]=w.useState(!1),[G,Z]=w.useState(null),[te,ee]=w.useState(null),[z,V]=w.useState(!1),[ne,ie]=w.useState(jK()),he=n.get("tab"),me=he&&XYe.includes(he)?he:"general",[oe,Ae]=w.useState(me),ge=be=>{Ae(be),be==="general"?n.delete("tab"):n.set("tab",be),r(n,{replace:!0})},[Ne,_e]=w.useState(!1),[le,He]=w.useState(""),[H,J]=w.useState({can_queue:!0,can_control_printer:!1,can_read_status:!0}),[K,B]=w.useState(null),[I,ce]=w.useState(null),[Ee,Ie]=w.useState(""),[ue,$]=w.useState(!1),[L,Y]=w.useState(!1),[pe,Se]=w.useState(null),[ae,je]=w.useState(!1),[De,Xe]=w.useState(!1),[et,Qe]=w.useState(!1),[se,ye]=w.useState(!1),[ke,Ue]=w.useState(null),[dt,re]=w.useState(!1),[Fe,ve]=w.useState({}),[$e,Le]=w.useState({}),Te=be=>{ie(be),Wme(be)},We=()=>{localStorage.removeItem("sidebarOrder"),window.location.reload()},{data:it,isLoading:Ot}=ft({queryKey:["settings"],queryFn:fe.getSettings}),{data:kt,isLoading:on}=ft({queryKey:["smart-plugs"],queryFn:fe.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 fe.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:fe.getNotificationProviders}),{data:sn,isLoading:Tt}=ft({queryKey:["api-keys"],queryFn:fe.getAPIKeys}),Cn=pt({mutationFn:be=>fe.createAPIKey(be),onSuccess:be=>{B(be.key||null),_e(!1),He(""),t.invalidateQueries({queryKey:["api-keys"]}),o("API key created")},onError:be=>{o(`Failed to create API key: ${be.message}`,"error")}}),Cr=pt({mutationFn:be=>fe.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:fe.getPrinters}),{data:Un,isLoading:yr}=ft({queryKey:["notification-templates"],queryFn:fe.getNotificationTemplates}),{data:Ci}=ft({queryKey:["virtual-printer-settings"],queryFn:Z1.getSettings,refetchInterval:1e4}),gi=Ci?.status?.running??!1,{data:we}=ft({queryKey:["ffmpeg-status"],queryFn:fe.checkFfmpeg}),{data:Je}=ft({queryKey:["version"],queryFn:fe.getVersion}),{data:Ze,refetch:lt,isRefetching:st}=ft({queryKey:["updateCheck"],queryFn:fe.checkForUpdates,staleTime:300*1e3}),{data:Pt,refetch:Bt}=ft({queryKey:["updateStatus"],queryFn:fe.getUpdateStatus,refetchInterval:be=>{const ut=be.state.data;return ut?.status==="downloading"||ut?.status==="installing"?1e3:!1}}),{data:Vt}=ft({queryKey:["mqtt-status"],queryFn:fe.getMQTTStatus,refetchInterval:oe==="network"?5e3:!1}),Jt=pt({mutationFn:fe.applyUpdate,onSuccess:be=>{be.is_docker?o(be.message,"error"):Bt()}}),[de,Pe]=w.useState(null),Ge=pt({mutationFn:fe.testAllNotificationProviders,onSuccess:be=>{Pe(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")}}),qe=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 fe.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")}}),Ve=w.useRef(null),wt=w.useRef(!1),Dt=w.useRef(!0);w.useEffect(()=>{if(it&&!C){const be={...it,external_url:it.external_url||window.location.origin};R(be),setTimeout(()=>{Dt.current=!1},100)}},[it,C]);const Nt=pt({mutationFn:fe.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})=>fe.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||!C||!it||!(it.auto_archive!==C.auto_archive||it.save_thumbnails!==C.save_thumbnails||it.capture_finish_photo!==C.capture_finish_photo||it.default_filament_cost!==C.default_filament_cost||it.currency!==C.currency||it.energy_cost_per_kwh!==C.energy_cost_per_kwh||it.energy_tracking_mode!==C.energy_tracking_mode||it.check_updates!==C.check_updates||it.notification_language!==C.notification_language||it.ams_humidity_good!==C.ams_humidity_good||it.ams_humidity_fair!==C.ams_humidity_fair||it.ams_temp_good!==C.ams_temp_good||it.ams_temp_fair!==C.ams_temp_fair||it.ams_history_retention_days!==C.ams_history_retention_days||it.per_printer_mapping_expanded!==C.per_printer_mapping_expanded||it.date_format!==C.date_format||it.time_format!==C.time_format||it.default_printer_id!==C.default_printer_id||it.ftp_retry_enabled!==C.ftp_retry_enabled||it.ftp_retry_count!==C.ftp_retry_count||it.ftp_retry_delay!==C.ftp_retry_delay||it.ftp_timeout!==C.ftp_timeout||it.mqtt_enabled!==C.mqtt_enabled||it.mqtt_broker!==C.mqtt_broker||it.mqtt_port!==C.mqtt_port||it.mqtt_username!==C.mqtt_username||it.mqtt_password!==C.mqtt_password||it.mqtt_topic_prefix!==C.mqtt_topic_prefix||it.mqtt_use_tls!==C.mqtt_use_tls||it.external_url!==C.external_url||it.ha_enabled!==C.ha_enabled||it.ha_url!==C.ha_url||it.ha_token!==C.ha_token||(it.library_archive_mode??"ask")!==(C.library_archive_mode??"ask")||Number(it.library_disk_warning_gb??5)!==Number(C.library_disk_warning_gb??5)||(it.camera_view_mode??"window")!==(C.camera_view_mode??"window")))&&!wt.current)return Ve.current&&clearTimeout(Ve.current),Ve.current=setTimeout(()=>{if(wt.current)return;wt.current=!0;const ut={auto_archive:C.auto_archive,save_thumbnails:C.save_thumbnails,capture_finish_photo:C.capture_finish_photo,default_filament_cost:C.default_filament_cost,currency:C.currency,energy_cost_per_kwh:C.energy_cost_per_kwh,energy_tracking_mode:C.energy_tracking_mode,check_updates:C.check_updates,notification_language:C.notification_language,ams_humidity_good:C.ams_humidity_good,ams_humidity_fair:C.ams_humidity_fair,ams_temp_good:C.ams_temp_good,ams_temp_fair:C.ams_temp_fair,ams_history_retention_days:C.ams_history_retention_days,per_printer_mapping_expanded:C.per_printer_mapping_expanded,date_format:C.date_format,time_format:C.time_format,default_printer_id:C.default_printer_id,ftp_retry_enabled:C.ftp_retry_enabled,ftp_retry_count:C.ftp_retry_count,ftp_retry_delay:C.ftp_retry_delay,ftp_timeout:C.ftp_timeout,mqtt_enabled:C.mqtt_enabled,mqtt_broker:C.mqtt_broker,mqtt_port:C.mqtt_port,mqtt_username:C.mqtt_username,mqtt_password:C.mqtt_password,mqtt_topic_prefix:C.mqtt_topic_prefix,mqtt_use_tls:C.mqtt_use_tls,external_url:C.external_url,ha_enabled:C.ha_enabled,ha_url:C.ha_url,ha_token:C.ha_token,library_archive_mode:C.library_archive_mode,library_disk_warning_gb:C.library_disk_warning_gb,camera_view_mode:C.camera_view_mode};Nt.mutate(ut)},500),()=>{Ve.current&&clearTimeout(Ve.current)}},[C,it,Nt]);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 fe.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&>[ut.id]===void 0&&(be[ut.id]=ut.external_camera_url)}),Object.keys(be).length>0&&Rt(ut=>({...ut,...be}))}},[er]);const Qt=(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||!C?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(_f,{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(jde,{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(Jp,{className:"w-4 h-4"}),"Network",s.jsx("span",{className:`w-2 h-2 rounded-full ${Vt?.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(cf,{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(uf,{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(Et,{children:[s.jsx(Nr,{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(Ud,{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:Az.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:ne,onChange:be=>Te(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:k0.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:C.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:C.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:C.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:We,children:[s.jsx(cm,{className:"w-4 h-4"}),"Reset"]})]})]})]}),s.jsxs(Et,{children:[s.jsx(Nr,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(UD,{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=>{E(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:y,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:v,onChange:be=>{T(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(Et,{children:[s.jsx(Nr,{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:C.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:C.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:C.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"})]})]}),C.capture_finish_photo&&we&&!we.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(Et,{children:[s.jsx(Nr,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(HD,{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:C.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:C.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=>Qt(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(Et,{children:[s.jsx(Nr,{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:C.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:C.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:C.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:C.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:C.energy_tracking_mode==="print"?"Dashboard shows sum of energy used during prints":"Dashboard shows lifetime energy from smart plugs"})]})]})]}),s.jsxs(Et,{children:[s.jsx(Nr,{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:C.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:C.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(HYe,{}),s.jsxs(Et,{children:[s.jsx(Nr,{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:C.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:()=>Qe(!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(Et,{children:[s.jsx(Nr,{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:()=>je(!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:()=>Xe(!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:()=>$(!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"&&C&&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(Et,{children:[s.jsx(Nr,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Ud,{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:C.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(Et,{children:[s.jsx(Nr,{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:C.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"})]})]}),C.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:C.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:C.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:C.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(Et,{children:[s.jsx(Nr,{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(oN,{className:"w-5 h-5 text-bambu-green"}),"Home Assistant"]}),C.ha_enabled&&ke&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${ke.success?"bg-green-400":"bg-red-400"}`}),s.jsx("span",{className:`text-sm ${ke.success?"text-green-400":"text-red-400"}`,children:ke.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:C.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"})]})]}),C.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:C.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:C.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"})]}),C.ha_url&&C.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 fe.testHAConnection(C.ha_url,C.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(Jp,{className:"w-4 h-4"}),"Test Connection"]})})]})]})]}),s.jsxs(Et,{children:[s.jsx(Nr,{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(Jp,{className:"w-5 h-5 text-blue-400"}),"MQTT Publishing"]}),Vt?.enabled&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${Vt.connected?"bg-green-400":"bg-red-400"}`}),s.jsx("span",{className:`text-sm ${Vt.connected?"text-green-400":"text-red-400"}`,children:Vt.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:C.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"})]})]}),C.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:C.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:C.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:C.mqtt_use_tls??!1,onChange:be=>{const ut=be.target.checked;Mt("mqtt_use_tls",ut);const It=C.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:C.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:C.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:C.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: ",C.mqtt_topic_prefix||"bambuddy","/printers/<serial>/status, etc."]})]}),Vt&&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 ${Vt.connected?"bg-green-400":"bg-red-400"}`}),s.jsx("span",{className:"text-bambu-gray",children:Vt.connected?s.jsxs(s.Fragment,{children:["Connected to ",s.jsxs("span",{className:"text-white",children:[Vt.broker,":",Vt.port]})]}):"Not connected"})]})})]})]})]})]})]}),ke&&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:[ke.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:ke.success?"Connection Successful":"Connection Failed"})]}),s.jsx("p",{className:"text-bambu-gray mb-6",children:ke.success?ke.message||"Successfully connected to Home Assistant.":ke.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:()=>Se("on"),disabled:qe.isPending,title:"Turn all plugs on",children:[qe.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(Su,{className:"w-4 h-4 text-bambu-green"}),"All On"]}),s.jsxs(Me,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>Se("off"),disabled:qe.isPending,title:"Turn all plugs off",children:[qe.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(dN,{className:"w-4 h-4 text-red-400"}),"All Off"]})]}),s.jsxs(Me,{className:"whitespace-nowrap",onClick:()=>{j(null),O(!0)},children:[s.jsx(rr,{className:"w-4 h-4"}),"Add Smart Plug"]})]})]}),kt&&kt.length>0&&s.jsxs(Et,{className:"mb-6",children:[s.jsx(Nr,{children:s.jsxs("h3",{className:"text-base font-semibold text-white flex items-center gap-2",children:[s.jsx($f,{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($f,{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"})]}),C&&C.energy_cost_per_kwh>0&&s.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(Ut.totalToday*C.energy_cost_per_kwh).toFixed(2)," ",C.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(NK,{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"})]}),C&&C.energy_cost_per_kwh>0&&s.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(Ut.totalYesterday*C.energy_cost_per_kwh).toFixed(2)," ",C.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(pP,{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"})]}),C&&C.energy_cost_per_kwh>0&&s.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(Ut.totalLifetime*C.energy_cost_per_kwh).toFixed(2)," ",C.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(AYe,{plug:be,onEdit:ut=>{j(ut),O(!0)}},be.id))}):s.jsx(Et,{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),O(!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(_f,{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:()=>V(!0),children:[s.jsx(Rw,{className:"w-4 h-4"}),"Log"]}),xt&&xt.length>0&&s.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>{Pe(null),Ge.mutate()},disabled:Ge.isPending,children:[Ge.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(BD,{className:"w-4 h-4"}),"Test All"]}),s.jsxs(Me,{size:"sm",onClick:()=>{Z(null),X(!0)},children:[s.jsx(rr,{className:"w-4 h-4"}),"Add"]})]})]}),s.jsx(Et,{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:C.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:Az.map(be=>s.jsx("option",{value:be.code,children:be.nativeName},be.code))})]})})}),de&&s.jsx(Et,{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:()=>Pe(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"}),de.success," passed"]}),de.failed>0&&s.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[s.jsx(za,{className:"w-4 h-4"}),de.failed," failed"]})]}),de.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:de.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(kYe,{provider:be,onEdit:ut=>{Z(ut),X(!0)}},be.id))}):s.jsx(Et,{children:s.jsx(Ct,{className:"py-8",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(_f,{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:()=>{Z(null),X(!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(Et,{className:"cursor-pointer hover:border-bambu-green/50 transition-colors",onClick:()=>ee(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(),ee(be)},children:s.jsx(uN,{className:"w-4 h-4 text-bambu-gray"})})]})})},be.id))}):s.jsx(Et,{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(cf,{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:()=>_e(!0),className:"flex-shrink-0",children:[s.jsx(rr,{className:"w-4 h-4"}),"Create Key"]})]}),K&&s.jsx(Et,{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:K}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(K);else{const be=document.createElement("textarea");be.value=K,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(sl,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"flex gap-2 mt-3",children:[s.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>{Ie(K),o("Key added to API Browser")},children:"Use in API Browser"}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>B(null),children:"Dismiss"})]})]})]})})}),Ne&&s.jsxs(Et,{className:"mb-6",children:[s.jsx(Nr,{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:le,onChange:be=>He(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:H.can_read_status,onChange:be=>J(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:H.can_queue,onChange:be=>J(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:H.can_control_printer,onChange:be=>J(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:le||"Unnamed Key",...H}),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:()=>_e(!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(Et,{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(cf,{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: ${bg(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(Et,{children:s.jsx(Ct,{className:"py-12",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(cf,{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:()=>_e(!0),children:[s.jsx(rr,{className:"w-4 h-4"}),"Create Your First Key"]})]})})}),s.jsxs(Et,{className:"mt-6",children:[s.jsx(Nr,{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(Ud,{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(Et,{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(KYe,{apiKey:Ee})]})]}),oe==="virtual-printer"&&s.jsx(VYe,{}),oe==="filament"&&C&&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(Et,{children:[s.jsx(Nr,{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(FD,{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:C.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:C.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(fN,{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:C.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:C.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(pg,{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:C.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:C.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(BYe,{})})]}),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(TYe,{plug:q,onClose:()=>{O(!1),j(null)}}),W&&s.jsx(jYe,{provider:G,onClose:()=>{X(!1),Z(null)}}),te&&s.jsx(PYe,{template:te,onClose:()=>ee(null)}),z&&s.jsx(OYe,{onClose:()=>V(!1)}),ue&&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()=>{$(!1);try{const be=await fe.clearNotificationLogs(30);o(be.message,"success")}catch{o("Failed to clear logs","error")}},onCancel:()=>$(!1)}),L&&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;Se(null),qe.mutate(be)},onCancel:()=>Se(null)}),ae&&s.jsx(IYe,{onClose:()=>je(!1),onExport:async be=>{je(!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 fe.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(FYe,{onClose:()=>Xe(!1),onRestore:async(be,ut)=>await fe.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:()=>Qe(!1),children:s.jsxs(Et,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",onClick:be=>be.stopPropagation(),children:[s.jsxs(Nr,{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:()=>Qe(!1),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:s.jsx(Ht,{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:()=>Qe(!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(uf,{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(Et,{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(sT,{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(uf,{className:"w-4 h-4"}),"Manage Users"]}),d?.role==="admin"&&s.jsxs(Me,{onClick:()=>ye(!0),className:"w-full",variant:"secondary",children:[s.jsx(qz,{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(sT,{className:"w-6 h-6 text-green-400"}):s.jsx(qz,{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(sT,{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(_P,{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(Et,{children:[s.jsx(Nr,{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(_P,{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(Et,{children:[s.jsx(Nr,{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(uf,{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 fe.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 Bie=t=>{const e=parseFloat(t);return(Math.trunc(e*1e3)/1e3).toFixed(3)},QYe=t=>t.startsWith("HH")?"HF":"S",ZYe=t=>{const e=t.match(/^([A-Z]{2}\d{2})/);return e?e[1]:"HH00"},bD=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 Wj({profile:t,onEdit:e,onCopy:n,selectionMode:r,isSelected:i,onToggleSelect:a,note:o}){const l=QYe(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(Do,{className:"w-4 h-4 text-bambu-green"}):s.jsx(Oo,{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:Bie(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(_K,{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(sl,{className:"w-4 h-4"})})]})}function qj({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?Bie(t.k_value):"0.020"),[y,x]=w.useState(t?.filament_id||""),[v,S]=w.useState(t?.nozzle_id?ZYe(t.nozzle_id):"HH00"),[M,E]=w.useState(t?.nozzle_diameter||n),[A,k]=w.useState(t?[t.extruder_id]:i?[0,1]:[0]),[T,D]=w.useState(!1),[C,R]=w.useState({current:0,total:0}),[U,O]=w.useState(a),q=Ur.useMemo(()=>{const ee=new Map;for(const z of r)if(z.filament_id&&!ee.has(z.filament_id)){const V=bD(z.name||"");ee.set(z.filament_id,{id:z.filament_id,name:V||z.filament_id})}return Array.from(ee.values()).sort((z,V)=>z.name.localeCompare(V.name))},[r]),j=pt({mutationFn:ee=>(console.log("[KProfile] Calling API..."),fe.setKProfile(e,ee)),onSuccess:ee=>{if(console.log("[KProfile] Save success:",ee),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}_${y}`,u(z,U)}D(!0),setTimeout(()=>{D(!1),c()},2500)},onError:ee=>{console.error("[KProfile] Save error:",ee),d(ee.message,"error"),D(!1)}}),W=pt({mutationFn:ee=>(console.log("[KProfile] Deleting profile..."),fe.deleteKProfile(e,ee)),onSuccess:ee=>{console.log("[KProfile] Delete success:",ee),d("K-profile deleted"),D(!0),setTimeout(()=>{D(!1),l()},4e3)},onError:ee=>{console.error("[KProfile] Delete error:",ee),d(ee.message,"error"),D(!1)}}),[X,G]=w.useState(!1),Z=()=>{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})},te=async ee=>{if(ee.preventDefault(),i&&!t&&A.length===0){d("Please select at least one extruder","error");return}const z=parseFloat(p).toFixed(6),V=`${v}-${M}`;if(t||A.length===1){const ie={name:f,k_value:z,filament_id:y,nozzle_id:V,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:",ie),j.mutate(ie);return}D(!0),R({current:1,total:A.length});const ne=A.map(ie=>({name:f,k_value:z,filament_id:y,nozzle_id:V,nozzle_diameter:M,extruder_id:ie,setting_id:void 0,slot_id:0}));console.log(`[KProfile] Saving ${ne.length} profiles in batch:`,ne);try{if(await fe.setKProfilesBatch(e,ne),d(`K-profile saved to ${A.length} extruders`),u&&U){const ie=`name_${f}_${y}`;u(ie,U)}}catch(ie){console.error("[KProfile] Failed to save batch:",ie),d("Failed to save K-profiles","error"),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(Et,{className:"w-full max-w-md relative",children:[T&&s.jsxs("div",{className:"absolute inset-0 bg-bambu-dark-secondary/90 flex flex-col items-center justify-center z-10 rounded-lg",children:[s.jsx(mt,{className:"w-8 h-8 text-bambu-green animate-spin mb-3"}),s.jsx("p",{className:"text-white font-medium",children:C.total>1?`Saving to extruder ${C.current}/${C.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:T,children:s.jsx(Ht,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:te,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:ee=>m(ee.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:ee=>{const z=ee.target.value;(z===""||/^\d*\.?\d*$/.test(z))&&b(z)},onBlur:ee=>{const z=parseFloat(ee.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:y,onChange:ee=>{const z=ee.target.value;if(x(z),!t&&z&&!f){const V=q.find(ne=>ne.id===z);V&&m(`${v==="HH00"?"HF":"S"} ${V.name}`)}},disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,required:!t,children:[s.jsx("option",{value:"",children:"Select filament..."}),t?.filament_id&&s.jsx("option",{value:t.filament_id,children:q.find(ee=>ee.id===t.filament_id)?.name||t.filament_id},t.filament_id),!t&&q.map(ee=>s.jsx("option",{value:ee.id,children:ee.name},ee.id))]}),!t&&q.length===0&&s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"No filaments found. Create a K-profile in Bambu Studio first."})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Flow Type"}),s.jsxs("select",{value:v,onChange:ee=>{const z=ee.target.value;if(S(z),!t&&y&&!f){const V=q.find(ne=>ne.id===y);V&&m(`${z==="HS00"?"HF":"S"} ${V.name}`)}},disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,children:[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:ee=>E(ee.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:ee=>{ee.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:ee=>{ee.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:ee=>O(ee.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:()=>G(!0),disabled:W.isPending||T,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:T,className:"flex-1",children:"Cancel"}),s.jsxs(Me,{type:"submit",disabled:j.isPending||T,className:"flex-1",children:[j.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(aN,{className:"w-4 h-4"}),"Save"]})]})]})]})]}),X&&s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[60]",children:s.jsx(Et,{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:()=>G(!1),className:"flex-1",children:"Cancel"}),s.jsxs(Me,{onClick:()=>{G(!1),Z()},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 X1={NOZZLE_DIAMETER:"bambusy_kprofiles_nozzle",SORT_OPTION:"bambusy_kprofiles_sort"};function JYe(){const{showToast:t}=Yn(),[e,n]=w.useState(null),[r,i]=w.useState(()=>localStorage.getItem(X1.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"),[y,x]=w.useState("all"),[v,S]=w.useState(()=>localStorage.getItem(X1.SORT_OPTION)||"name"),[M,E]=w.useState(!1),[A,k]=w.useState(new Set),[T,D]=w.useState(!1),[C,R]=w.useState(!1),U=w.useCallback(B=>`${B.slot_id}_${B.extruder_id}`,[]);w.useEffect(()=>{localStorage.setItem(X1.NOZZLE_DIAMETER,r)},[r]),w.useEffect(()=>{localStorage.setItem(X1.SORT_OPTION,v)},[v]);const{data:O,isLoading:q}=ft({queryKey:["printers"],queryFn:fe.getPrinters}),{data:j,isLoading:W,isFetching:X,error:G,refetch:Z}=ft({queryKey:["kprofiles",e,r],queryFn:async()=>{console.log("[KProfiles] Fetching profiles for printer",e,"nozzle",r);const B=await fe.getKProfiles(e,r);return console.log("[KProfiles] Received profiles:",B?.profiles?.length||0,"profiles"),B},enabled:!!e,retry:!1,staleTime:0,gcTime:0,refetchOnMount:"always"}),{data:te}=ft({queryKey:["kprofiles",e,"0.4"],queryFn:()=>fe.getKProfiles(e,"0.4"),enabled:!!e,staleTime:6e4}),{data:ee,refetch:z}=ft({queryKey:["kprofile-notes",e],queryFn:()=>fe.getKProfileNotes(e),enabled:!!e,staleTime:3e4}),V=G?.message?.includes("not connected");w.useEffect(()=>{if(!e&&O&&O.length>0){const B=O.find(I=>I.is_active);B&&n(B.id)}},[e,O]),w.useEffect(()=>{if(e){const B=setTimeout(()=>{Z()},150);return()=>clearTimeout(B)}},[e,r]);const ne=O?.filter(B=>B.is_active)||[],ie=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,ue=y==="all"||y==="hf"&&I.nozzle_id.startsWith("HH")||y==="s"&&I.nozzle_id.startsWith("HS");return Ee&&Ie&&ue}).sort((I,ce)=>{switch(v){case"k_value":return parseFloat(I.k_value)-parseFloat(ce.k_value);case"filament":return bD(I.name).localeCompare(bD(ce.name));default:return I.name.localeCompare(ce.name)}}):[],[j?.profiles,f,p,y,v]),he=O?.find(B=>B.id===e),me=he?.nozzle_count===2;w.useEffect(()=>{const B=I=>{I.target instanceof HTMLInputElement||I.target instanceof HTMLTextAreaElement||I.target instanceof HTMLSelectElement||a||l||u||(I.key==="r"||I.key==="R"?(I.preventDefault(),Z()):I.key==="n"||I.key==="N"?(I.preventDefault(),c(!0)):I.key==="Escape"&&M&&(I.preventDefault(),E(!1),k(new Set)))};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[a,l,u,M,Z]);const oe=w.useCallback(()=>{if(!j?.profiles||j.profiles.length===0){t("No profiles to export","error");return}const B={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(B,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]),Ae=w.useCallback(()=>{const B=document.createElement("input");B.type="file",B.accept=".json",B.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 ue=0;for(const $ of Ie.profiles)if(!(!$.name||!$.k_value||!$.filament_id))try{await fe.setKProfile(e,{name:$.name,k_value:parseFloat($.k_value).toFixed(6),filament_id:$.filament_id,nozzle_id:$.nozzle_id||`HH00-${r}`,nozzle_diameter:$.nozzle_diameter||r,extruder_id:$.extruder_id??0,slot_id:0}),ue++,await new Promise(L=>setTimeout(L,500))}catch(L){console.error("Failed to import profile:",$.name,L)}t(`Imported ${ue} of ${Ie.profiles.length} profiles`),Z()}catch(Ee){console.error("Import error:",Ee),t("Failed to parse import file","error")}},B.click()},[e,r,t,Z]),ge=w.useCallback(B=>{k(I=>{const ce=new Set(I);return ce.has(B)?ce.delete(B):ce.add(B),ce})},[]),Ne=w.useCallback(()=>{k(new Set(ie.map(B=>U(B))))},[ie,U]),_e=w.useCallback(()=>{A.size!==0&&D(!0)},[A.size]),le=w.useCallback(async()=>{const B=ie.filter(ce=>A.has(U(ce)));R(!0);let I=0;for(const ce of B)try{await fe.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),E(!1),k(new Set),Z()},[e,A,ie,t,Z,U]),He=w.useCallback(B=>{const I=[];return B.setting_id&&I.push(B.setting_id),I.push(`slot_${B.slot_id}_${B.filament_id}_${B.extruder_id}`),I.push(`name_${B.name}_${B.filament_id}`),I},[]),H=w.useCallback(async(B,I)=>{if(e)try{await fe.setKProfileNote(e,B,I),z()}catch(ce){console.error("Failed to save note:",ce),t("Failed to save note","error")}},[e,z,t]),J=w.useCallback(B=>{if(!ee?.notes)return{note:"",key:null};const I=He(B);for(const ce of I)if(ee.notes[ce])return{note:ee.notes[ce],key:ce};return{note:"",key:null}},[ee,He]),K=w.useCallback(B=>J(B).note,[J]);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"})}):!O||O.length===0?s.jsx(Et,{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"})]})}):ne.length===0?s.jsx(Et,{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:[X&&!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:B=>n(parseInt(B.target.value)),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:ne.map(B=>s.jsx("option",{value:B.id,children:B.name},B.id))})]}),s.jsxs("div",{className:"w-32",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle"}),s.jsxs("select",{value:r,onChange:B=>i(B.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"0.2",children:"0.2mm"}),s.jsx("option",{value:"0.4",children:"0.4mm"}),s.jsx("option",{value:"0.6",children:"0.6mm"}),s.jsx("option",{value:"0.8",children:"0.8mm"})]})]}),s.jsxs("div",{className:"flex items-end gap-2",children:[s.jsxs(Me,{variant:"secondary",onClick:()=>Z(),disabled:X,children:[s.jsx(Ar,{className:`w-4 h-4 ${X?"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(Ma,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:f,onChange:B=>m(B.target.value),placeholder:"Search by name or filament...",className:"w-full pl-10 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),me&&s.jsx("div",{className:"w-36",children:s.jsxs("select",{value:p,onChange:B=>b(B.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"all",children:"All Extruders"}),s.jsx("option",{value:"left",children:"Left Only"}),s.jsx("option",{value:"right",children:"Right Only"})]})}),s.jsx("div",{className:"w-32",children:s.jsxs("select",{value:y,onChange:B=>x(B.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"all",children:"All Flow"}),s.jsx("option",{value:"hf",children:"HF Only"}),s.jsx("option",{value:"s",children:"S Only"})]})}),s.jsx("div",{className:"w-32",children:s.jsxs("select",{value:v,onChange:B=>S(B.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"name",children:"Sort: Name"}),s.jsx("option",{value:"k_value",children:"Sort: K-Value"}),s.jsx("option",{value:"filament",children:"Sort: Filament"})]})})]}),s.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[s.jsxs(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:Ae,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:Ne,title:"Select all visible profiles",children:[s.jsx(Do,{className:"w-4 h-4"}),"Select All"]}),s.jsxs(Me,{variant:"secondary",onClick:_e,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:()=>{E(!1),k(new Set)},children:[s.jsx(Ht,{className:"w-4 h-4"}),"Cancel"]})]}):s.jsxs(Me,{variant:"secondary",onClick:()=>E(!0),disabled:!ie.length,title:"Enter selection mode for bulk delete",children:[s.jsx(Do,{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"})}):V?s.jsx(Et,{children:s.jsxs(Ct,{className:"py-12 text-center",children:[s.jsx(Qg,{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:()=>Z(),children:[s.jsx(Ar,{className:"w-4 h-4"}),"Retry"]})]})}):ie.length>0?me?s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Left Extruder"}),s.jsx("div",{className:"space-y-1",children:ie.filter(B=>B.extruder_id===1).map(B=>s.jsx(Wj,{profile:B,onEdit:()=>o(B),onCopy:()=>d(B),selectionMode:M,isSelected:A.has(U(B)),onToggleSelect:()=>ge(U(B)),note:K(B)},U(B)))})]}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Right Extruder"}),s.jsx("div",{className:"space-y-1",children:ie.filter(B=>B.extruder_id===0).map(B=>s.jsx(Wj,{profile:B,onEdit:()=>o(B),onCopy:()=>d(B),selectionMode:M,isSelected:A.has(U(B)),onToggleSelect:()=>ge(U(B)),note:K(B)},U(B)))})]})]}):s.jsx("div",{className:"space-y-1",children:ie.map(B=>s.jsx(Wj,{profile:B,onEdit:()=>o(B),onCopy:()=>d(B),selectionMode:M,isSelected:A.has(U(B)),onToggleSelect:()=>ge(U(B)),note:K(B)},U(B)))}):f||p!=="all"||y!=="all"?s.jsx(Et,{children:s.jsxs(Ct,{className:"py-12 text-center",children:[s.jsx(Ma,{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(Et,{children:s.jsxs(Ct,{className:"py-12 text-center",children:[s.jsx(aN,{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:B,key:I}=J(a);return s.jsx(qj,{profile:a,printerId:e,nozzleDiameter:r,existingProfiles:te?.profiles||j?.profiles,isDualNozzle:me,initialNote:B,initialNoteKey:I,onSaveNote:H,onClose:()=>{console.log("[KProfiles] Edit modal onClose - refetching profiles..."),o(null),Z()},onSave:()=>{o(null),Z()}})})(),l&&e&&s.jsx(qj,{printerId:e,nozzleDiameter:r,existingProfiles:te?.profiles||j?.profiles,isDualNozzle:me,onSaveNote:H,onClose:()=>{c(!1),Z()},onSave:()=>{c(!1),Z()}}),u&&e&&s.jsx(qj,{printerId:e,nozzleDiameter:r,existingProfiles:te?.profiles||j?.profiles,isDualNozzle:me,onSaveNote:H,profile:{...u,slot_id:0,name:`${u.name} (Copy)`},onClose:()=>{d(null),Z()},onSave:()=>{d(null),Z()}}),T&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(Et,{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:C,className:"flex-1",children:"Cancel"}),s.jsxs(Me,{onClick:le,disabled:C,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[C?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(hn,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}function xI(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 gy(t){return/^(P[FPM]US|PF\d|PP\d)/.test(t)}function eQe(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 tQe({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:()=>fe.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")}),y=pt({mutationFn:()=>fe.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:()=>fe.cloudSetToken(d),onSuccess:()=>{e("Token set successfully"),t()},onError:M=>e(M.message,"error")}),v=M=>{M.preventDefault(),n==="email"?b.mutate():n==="code"?y.mutate():n==="token"&&x.mutate()},S=b.isPending||y.isPending||x.isPending;return s.jsx(Et,{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(tN,{className:"w-6 h-6 text-bambu-green"})}),s.jsx("h2",{className:"text-xl font-semibold text-white",children:"Connect to Bambu Cloud"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Sync your slicer presets across devices"})]}),s.jsxs("form",{onSubmit:v,className:"space-y-4",children:[n==="email"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Email"}),s.jsx("input",{type:"email",value:i,onChange: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(Kz,{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(cf,{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(Kz,{className:"w-4 h-4"}),"Login with email instead"]})})]})]})})}function Ip({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 nQe(){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(fg,{className:"w-5 h-5"})}):null}function Kj({setting:t,onClick:e,onDuplicate:n,compareMode:r,isCompareSelected:i,compareIndex:a,compareDisabled:o}){const l=xI(t.name),c=gy(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(sl,{className:"w-4 h-4"})})]})}function yD(t,e=0){const n=" ".repeat(e);if(t===null)return"null";if(t===void 0)return"undefined";if(typeof t=="string"){if(t.includes("\\n")||t.includes(`
- `)){const i=t.replace(/\\n/g,`
- `).replace(/\\"/g,'"').replace(/\\t/g," ").split(`
- `);if(i.length>1)return`"""
- `+i.map(a=>n+" "+a).join(`
- `)+`
- `+n+'"""'}return JSON.stringify(t)}if(typeof t=="number"||typeof t=="boolean")return String(t);if(Array.isArray(t))return t.length===0?"[]":`[
- `+t.map(i=>n+" "+yD(i,e+1)).join(`,
- `)+`
- `+n+"]";if(typeof t=="object"){const r=Object.entries(t);return r.length===0?"{}":`{
- `+r.map(([a,o])=>n+" "+JSON.stringify(a)+": "+yD(o,e+1)).join(`,
- `)+`
- `+n+"}"}return String(t)}function rQe({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:()=>fe.getCloudSettingDetail(t.setting_id)}),f=pt({mutationFn:()=>fe.deleteCloudSetting(t.setting_id),onSuccess:()=>{a("Preset deleted"),o.invalidateQueries({queryKey:["cloudSettings"]}),n()},onError:b=>a(b.message,"error")}),m=gy(t.setting_id),p=xI(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(Et,{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(Ht,{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:yD(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(sl,{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(sa,{className:"w-4 h-4"}),"Edit"]}),s.jsx(Me,{variant:"danger",onClick:()=>c(!0),children:s.jsx(hn,{className:"w-4 h-4"})})]})]})})]})})})}function $ie(){try{const t=localStorage.getItem("bambusy_preset_templates");return t?JSON.parse(t):[]}catch{return[]}}function Hie(t){localStorage.setItem("bambusy_preset_templates",JSON.stringify(t))}function iQe({onClose:t,onApply:e}){const{showToast:n}=Yn(),[r,i]=w.useState($ie),[a,o]=w.useState("all"),[l,c]=w.useState(null),[u,d]=w.useState(""),[f,m]=w.useState(""),[p,b]=w.useState("{}"),[y,x]=w.useState(null),[v,S]=w.useState(null),M=a==="all"?r:r.filter(O=>O.type===a),E=O=>{i(O),Hie(O)},A=O=>{const q=r.filter(j=>j.id!==O);E(q),S(null),n("Template deleted")},k=O=>{c(O.id),d(O.name),m(O.description),b(JSON.stringify(O.settings,null,2)),x(null)},T=()=>{if(!(!l||!u.trim()))try{const O=JSON.parse(p),q=r.map(j=>j.id===l?{...j,name:u.trim(),description:f.trim(),settings:O}:j);E(q),c(null),n("Template updated")}catch(O){x(O.message)}},D=()=>{c(null),d(""),m(""),b("{}"),x(null)},C=O=>{const q=r.map(j=>j.id===O?{...j,showInModal:!j.showInModal}:j);E(q)},R={filament:{label:"Filament",icon:ID,color:"text-amber-400"},print:{label:"Process",icon:Xd,color:"text-blue-400"},printer:{label:"Printer",icon:Wr,color:"text-purple-400"}},U=v?r.find(O=>O.id===v):null;return w.useEffect(()=>{const O=q=>{q.key==="Escape"&&(v?S(null):l?D():t())};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[v,l,t]),s.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:[U&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-60",children:s.jsx(Et,{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(v),className:"flex-1 bg-red-500 hover:bg-red-600",children:[s.jsx(hn,{className:"w-4 h-4"}),"Delete"]})]})]})})}),s.jsx(Et,{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(C0,{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(Ht,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"flex items-center gap-2 p-4 border-b border-bambu-dark-tertiary",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:"Type:"}),["all","filament","print","printer"].map(O=>s.jsx("button",{onClick:()=>o(O),className:`px-3 py-1 text-sm rounded-lg transition-colors ${a===O?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:O==="all"?"All":R[O].label},O))]}),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(C0,{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(O=>{const q=R[O.type],j=q.icon;return l===O.id?s.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg border border-bambu-green",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-3",children:[s.jsx("input",{type:"text",value:u,onChange: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 ${y?"border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`}),y&&s.jsx("p",{className:"text-xs text-red-400 mt-1",children:y})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Me,{size:"sm",onClick:T,disabled:!u.trim(),children:[s.jsx(ys,{className:"w-4 h-4"}),"Save"]}),s.jsx(Me,{size:"sm",variant:"secondary",onClick:D,children:"Cancel"})]})]},O.id):s.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary hover:border-bambu-gray-dark transition-colors",children:[s.jsx(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:O.name}),s.jsx("p",{className:"text-xs text-bambu-gray truncate",children:O.description})]}),s.jsxs("span",{className:"text-xs text-bambu-gray-dark px-2 py-1 bg-bambu-dark-secondary rounded",children:[Object.keys(O.settings).length," fields"]}),s.jsx("button",{onClick:()=>C(O.id),className:`p-1 transition-colors ${O.showInModal?"text-bambu-green hover:text-bambu-green/70":"text-bambu-gray hover:text-white"}`,title:O.showInModal?"Shown in modals":"Hidden in modals",children:O.showInModal?s.jsx(Uf,{className:"w-4 h-4"}):s.jsx(nN,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>e(O),className:"px-3 py-1 text-xs bg-bambu-green/20 text-bambu-green rounded hover:bg-bambu-green/30 transition-colors",children:"Apply"}),s.jsx("button",{onClick:()=>k(O),className:"p-1 text-bambu-gray hover:text-white",title:"Edit",children:s.jsx(sa,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>S(O.id),className:"p-1 text-bambu-gray hover:text-red-400",title:"Delete",children:s.jsx(hn,{className:"w-4 h-4"})})]},O.id)})})})]})})]})}function Vie({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 y of p){if(y==="inherits"||y==="version")continue;const x=e[y],v=n[y],S=y in e,M=y in n;let E;!S&&M?E="added":S&&!M?E="removed":JSON.stringify(x)!==JSON.stringify(v)?E="changed":E="same",b.push({key:y,left:x,right:v,status:E})}return b.sort((y,x)=>{const v={changed:0,added:1,removed:2,same:3};return v[y.status]!==v[x.status]?v[y.status]-v[x.status]:y.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(y=>y.key.toLowerCase().includes(b)||String(y.left).toLowerCase().includes(b)||String(y.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 y=b.split("\\n").length;if(y>1)return`[${y} 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(Et,{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(Ht,{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(yP,{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(fP,{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(aT,{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(Ma,{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(aT,{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],y={added:s.jsx(rr,{className:"w-3.5 h-3.5 text-green-400"}),removed:s.jsx(yP,{className:"w-3.5 h-3.5 text-red-400"}),changed:s.jsx(fP,{className:"w-3.5 h-3.5 text-amber-400"}),same:s.jsx(aT,{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:[y,s.jsx("span",{className:"text-sm text-white font-mono",children:p.key})]})}),s.jsx("td",{className:"p-3",children:s.jsx("span",{className:`text-sm font-mono break-all ${p.status==="removed"?"text-red-300":p.status==="changed"?"text-white":"text-bambu-gray"}`,children: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 aQe({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,y]=w.useState(""),[x,v]=w.useState(e?.setting||{inherits:""}),[S,M]=w.useState(JSON.stringify(e?.setting||{inherits:""},null,2)),[E,A]=w.useState(null),[k,T]=w.useState(""),[D,C]=w.useState(!1),[R,U]=w.useState(""),[O,q]=w.useState(!1),[j,W]=w.useState($ie),[X,G]=w.useState(!1),[Z,te]=w.useState(""),[ee,z]=w.useState(""),[V,ne]=w.useState(!0),[ie,he]=w.useState(null),[me,oe]=w.useState(!1),Ae=w.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer})[c]||[],[n,c]),ge=w.useMemo(()=>Ae.filter(se=>gy(se.setting_id)),[Ae]),{data:Ne}=ft({queryKey:["cloudFields",c],queryFn:()=>fe.getCloudFields(c==="print"?"process":c),staleTime:1e3*60*60}),{data:_e}=ft({queryKey:["allPresetDetails",c,ge.map(se=>se.setting_id).join(",")],queryFn:async()=>{const se={};for(let ke=0;ke<ge.length;ke+=5){const Ue=ge.slice(ke,ke+5);(await Promise.all(Ue.map(async re=>{try{const Fe=await fe.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:le,isLoading:He}=ft({queryKey:["cloudSettingDetail",m],queryFn:()=>fe.getCloudSettingDetail(m),enabled:!!m});w.useEffect(()=>{o!=="json"&&M(JSON.stringify(x,null,2))},[x,o]);const H=w.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer}[c]||[]).filter(ye=>!gy(ye.setting_id)).sort((ye,ke)=>ye.name.localeCompare(ke.name)),[n,c]);w.useEffect(()=>{if(!m)return;const se=H.find(ye=>ye.setting_id===m);se&&(y(se.name),a||(v({inherits:se.name}),M(JSON.stringify({inherits:se.name},null,2))))},[m,H,a]);const J=w.useMemo(()=>{const se=Ne?.fields||[],ye=new Set(se.map(re=>re.key)),ke=new Set,Ue=new Set(["inherits","updated_time","compatible_printers","compatible_prints"]);_e&&Object.values(_e).forEach(re=>{re?.setting&&Object.keys(re.setting).forEach(Fe=>{!ye.has(Fe)&&!Ue.has(Fe)&&ke.add(Fe)})}),Object.keys(x).forEach(re=>{!ye.has(re)&&!Ue.has(re)&&ke.add(re)});const dt=Array.from(ke).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]},[Ne,_e,x]),K=J.filter(se=>se.label.toLowerCase().includes(k.toLowerCase())||se.key.toLowerCase().includes(k.toLowerCase())),B=()=>{if(R.trim()){const se=R.trim().toLowerCase().replace(/\s+/g,"_");I(se,""),U(""),q(!1),r(`Field "${se}" added`)}},I=(se,ye)=>{v(ke=>{const Ue={...ke};return ye===""||ye===void 0?delete Ue[se]:Ue[se]=ye,Ue})},ce=se=>{v(ye=>({...ye,...se.settings})),he(se.name),r("Template applied")},Ee=()=>{if(!Z.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:Z.trim(),description:ee.trim()||"Custom template",type:c,settings:se,showInModal:V},ke=[...j,ye];W(ke),Hie(ke),G(!1),te(""),z(""),ne(!0),r("Template saved")},Ie=w.useMemo(()=>j.filter(se=>se.type===c&&se.showInModal),[c,j]),ue=se=>{M(se);try{const ye=JSON.parse(se);v(ye),A(null)}catch(ye){A(ye.message)}},$=se=>{se.preventDefault(),C(!1);const ye=se.dataTransfer.files[0];if(ye&&ye.name.endsWith(".json")){const ke=new FileReader;ke.onload=Ue=>{try{const dt=Ue.target?.result,re=JSON.parse(dt),Fe=re.setting||re;v(ve=>({...ve,...Fe})),M(JSON.stringify({...x,...Fe},null,2)),r("File imported successfully")}catch{r("Invalid JSON file","error")}},ke.readAsText(ye)}},L=pt({mutationFn:()=>{const se={...x},ye=c==="filament"?"filament_settings_id":c==="print"?"print_settings_id":"printer_settings_id";se[ye]=`"${d}"`;const ke={type:c,name:d,base_id:m,setting:se};return fe.createCloudSetting(ke)},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 fe.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:L,Se=le?.setting?.inherits,ae=Se?H.find(se=>se.name===Se):void 0,{data:je}=ft({queryKey:["cloudSettingDetail",ae?.setting_id],queryFn:()=>fe.getCloudSettingDetail(ae.setting_id),enabled:!!ae?.setting_id}),De=w.useMemo(()=>{const se=je?.setting||{},ye=le?.setting||{},ke=m&&_e?.[m]?.setting?_e[m].setting:{};return{...se,...ye,...ke}},[m,le,je,_e]),Xe=se=>{if(se==null)return"";if(Array.isArray(se)){const ye=[...new Set(se.map(ke=>String(ke)))];return ye.length===1?ye[0]:se.join(", ")}return String(se)},et=se=>{const ye=x[se.key],ke=De[se.key],Ue=Xe(ke),dt=He?"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&&ke==="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})]})},Qe=w.useMemo(()=>le?.setting?le.setting:{},[le]);return s.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onDragOver:se=>{se.preventDefault(),C(!0)},onDragLeave:()=>C(!1),onDrop:$,children:[me&&m&&s.jsx(Vie,{onClose:()=>oe(!1),leftPreset:Qe,rightPreset:x,leftLabel:`Base: ${b||m}`,rightLabel:`Current: ${d||"New Preset"}`}),s.jsx(Et,{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(Ht,{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..."}),H.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(ts,{className:"w-3 h-3 text-bambu-green"}),"Inherits from: ",s.jsx("span",{className:"text-white",children:b}),He&&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(Xz,{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(cN,{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(dK,{className:"w-4 h-4"}),"JSON",E&&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"}),ke=URL.createObjectURL(ye),Ue=document.createElement("a");Ue.href=ke,Ue.download=`${d||"preset"}.json`,document.body.appendChild(Ue),Ue.click(),document.body.removeChild(Ue),URL.revokeObjectURL(ke),r("Preset exported")},className:"flex items-center gap-2 px-4 py-3 text-sm text-bambu-gray hover:text-white transition-colors",title:"Export current settings to JSON file",children:[s.jsx($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 ke=new FileReader;ke.onload=Ue=>{try{const dt=JSON.parse(Ue.target?.result),re=dt.setting||dt;v(Fe=>({...Fe,...re})),r("File imported")}catch{r("Invalid JSON","error")}},ke.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(C0,{className:"w-4 h-4 text-amber-400"}),"Quick Templates"]}),Object.keys(x).filter(se=>se!=="inherits").length>0&&s.jsxs("button",{onClick:()=>G(!X),className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1 transition-colors",children:[s.jsx(ys,{className:"w-3 h-3"}),"Save as template"]})]}),X&&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:Z,onChange:se=>te(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:ee,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:!Z.trim(),children:[s.jsx(ys,{className:"w-3 h-3"}),"Save"]}),s.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>G(!1),children:"Cancel"})]}),s.jsxs("button",{onClick:()=>ne(!V),className:`flex items-center gap-1.5 text-xs transition-colors ${V?"text-bambu-green":"text-bambu-gray hover:text-white"}`,children:[V?s.jsx(Uf,{className:"w-3.5 h-3.5"}):s.jsx(nN,{className:"w-3.5 h-3.5"}),V?"Show in modals":"Hidden in modals"]})]})]}),ie&&s.jsxs("div",{className:"mb-3 px-3 py-2 bg-bambu-green/10 border border-bambu-green/30 rounded-lg flex items-center gap-2",children:[s.jsx(ts,{className:"w-4 h-4 text-bambu-green"}),s.jsxs("span",{className:"text-sm text-bambu-green",children:["Template applied: ",s.jsx("span",{className:"font-medium",children:ie})]}),s.jsx("button",{onClick:()=>he(null),className:"ml-auto text-bambu-green/70 hover:text-bambu-green",children:s.jsx(Ht,{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:J.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(Ht,{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:_e?`${J.length} fields`:"Loading..."})]}),s.jsxs("div",{className:"relative mb-3 flex-shrink-0",children:[s.jsx(Ma,{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=>T(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:[K.filter(se=>!(se.key in x)).map(se=>{const ye=De[se.key],ke=Xe(ye);return s.jsxs("div",{onClick:()=>{v(Ue=>({...Ue,[se.key]:ke||""}))},className:"flex items-center justify-between gap-2 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors cursor-pointer group",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-sm text-white truncate",children: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:[ke&&s.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark px-2 py-0.5 rounded max-w-32 truncate",title:ke,children:[ke.slice(0,20),ke.length>20?"...":""]}),s.jsx("div",{className:"w-6 h-6 flex items-center justify-center rounded bg-bambu-dark-tertiary group-hover:bg-bambu-green/20 transition-colors",children:s.jsx(rr,{className:"w-4 h-4 text-bambu-gray group-hover:text-bambu-green transition-colors"})})]})]},se.key)}),K.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:O?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"&&B(),placeholder:"custom_field_name",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white font-mono text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",autoFocus:!0}),s.jsx(Me,{size:"sm",onClick:B,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(Ht,{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 ke=J.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:ke?.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(Ht,{className:"w-4 h-4"})})]}),ke?et(ke):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(Xz,{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:()=>{G(!0),l("common")},className:"w-full flex items-center justify-center gap-2 p-2 text-sm text-bambu-gray hover:text-white border border-dashed border-bambu-dark-tertiary hover:border-bambu-gray-dark rounded-lg transition-colors",children:[s.jsx(ys,{className:"w-4 h-4"}),"Save as template"]})})]})]}),o==="json"&&s.jsxs("div",{className:"space-y-2",children:[E&&s.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[s.jsx(aa,{className:"w-4 h-4"}),E]}),s.jsx("textarea",{value:S,onChange:se=>ue(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 ${E?"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||!!E,className:"flex-1",children:[pe.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):a?s.jsx(ys,{className:"w-4 h-4"}):s.jsx(rr,{className:"w-4 h-4"}),a?"Save":e?"Duplicate":"Create"]})]})]})})]})}function sQe({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"),[y,x]=w.useState("all"),[v,S]=w.useState("all"),[M,E]=w.useState(null),[A,k]=w.useState(!1),[T,D]=w.useState(!1),[C,R]=w.useState(null),[U,O]=w.useState(null),[q,j]=w.useState(null),[W,X]=w.useState(!1),[G,Z]=w.useState([null,null]),[te,ee]=w.useState(!1),[z,V]=w.useState(null),ne=ln(),ie=w.useMemo(()=>[...t.filament.map(K=>({...K,type:"filament"})),...t.printer.map(K=>({...K,type:"printer"})),...t.process.map(K=>({...K,type:"process"}))].map(K=>({...K,meta:xI(K.name)})),[t]),he=w.useMemo(()=>{const J=new Set,K=new Set,B=new Set;return ie.forEach(I=>{I.meta.nozzle&&J.add(I.meta.nozzle),I.meta.filamentType&&K.add(I.meta.filamentType),I.meta.layerHeight&&B.add(I.meta.layerHeight)}),{printers:i.map(I=>({id:I.id.toString(),name:I.name})),nozzles:Array.from(J).sort((I,ce)=>parseFloat(I)-parseFloat(ce)),filaments:Array.from(K).sort(),layerHeights:Array.from(B).sort((I,ce)=>parseFloat(I)-parseFloat(ce))}},[ie,i]),me=w.useMemo(()=>f==="all"?null:i.find(K=>K.id.toString()===f)?.model||null,[f,i]),oe=w.useMemo(()=>ie.filter(J=>l==="all"||J.type===l).filter(J=>{if(u==="all")return!0;const K=gy(J.setting_id);return u==="custom"?K:!K}).filter(J=>{if(f==="all"||!me)return!0;const K=J.meta.printer?.toLowerCase()||"",B=me.toLowerCase();return K.includes(B)||B.includes(K)}).filter(J=>p==="all"||J.meta.nozzle===p).filter(J=>y==="all"||J.meta.filamentType===y).filter(J=>v==="all"||J.meta.layerHeight===v).filter(J=>a===""||J.name.toLowerCase().includes(a.toLowerCase())).sort((J,K)=>J.name.localeCompare(K.name)),[ie,l,u,f,me,p,y,v,a]),Ae=J=>{if(W){const K=G[0]?.setting_id===J.setting_id,B=G[1]?.setting_id===J.setting_id;if(K)Z([G[1],null]);else if(B)Z([G[0],null]);else if(!G[0])Z([J,null]);else if(G[1]){if(G[0].type!==J.type)return;Z([G[0],J])}else{if(G[0].type!==J.type)return;Z([G[0],J])}}else E(J)},ge=J=>{if(G[0]?.setting_id===J.setting_id)return 0;if(G[1]?.setting_id===J.setting_id)return 1},Ne=async J=>{try{const K=await fe.getCloudSettingDetail(J.setting_id),B=J.type==="process"?"print":J.type;R({type:B,name:J.name,base_id:K.base_id||"GFSA00",setting:K.setting||{}}),E(null)}catch(K){console.error("Failed to fetch preset details for duplication:",K)}},_e=async J=>{try{ne.removeQueries({queryKey:["cloudSettingDetail",J.setting_id]});const K=await fe.getCloudSettingDetail(J.setting_id),B=J.type==="process"?"print":J.type;O({type:B,name:J.name,base_id:K.base_id||"GFSA00",setting:K.setting||{},setting_id:J.setting_id}),E(null)}catch(K){console.error("Failed to fetch preset details for editing:",K)}},le=()=>{c("all"),d("all"),m("all"),b("all"),x("all"),S("all"),o("")},He=l!=="all"||u!=="all"||f!=="all"||p!=="all"||y!=="all"||v!=="all"||a!=="",H=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(Ma,{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:J=>o(J.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?(X(!1),Z([null,null])):X(!0)},children:[s.jsx(Zp,{className:"w-4 h-4"}),W?"Cancel":"Compare"]}),s.jsxs(Me,{variant:"secondary",onClick:()=>D(!0),children:[s.jsx(C0,{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(iN,{className:"w-4 h-4 text-bambu-gray"}),s.jsx(Ip,{label:"Type",value:l,options:[{value:"all",label:"All",count:H},{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:J=>c(J)}),s.jsx(Ip,{label:"Owner",value:u,options:[{value:"all",label:"All"},{value:"custom",label:"My Presets"},{value:"builtin",label:"Built-in"}],onChange:J=>d(J)}),he.printers.length>0&&s.jsx(Ip,{label:"Printer",value:f,options:[{value:"all",label:"All"},...he.printers.map(J=>({value:J.id,label:J.name}))],onChange:m}),he.nozzles.length>0&&s.jsx(Ip,{label:"Nozzle",value:p,options:[{value:"all",label:"All"},...he.nozzles.map(J=>({value:J,label:J}))],onChange:b}),he.filaments.length>0&&(l==="all"||l==="filament")&&s.jsx(Ip,{label:"Filament",value:y,options:[{value:"all",label:"All"},...he.filaments.map(J=>({value:J,label:J}))],onChange:x}),he.layerHeights.length>0&&(l==="all"||l==="process")&&s.jsx(Ip,{label:"Layer",value:v,options:[{value:"all",label:"All"},...he.layerHeights.map(J=>({value:J,label:J}))],onChange:S}),He&&s.jsx("button",{onClick:le,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:G[0]?`Select another ${G[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] ${G[0]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:G[0]?G[0].name:"1. Select first"}),s.jsx(fP,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${G[1]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:G[1]?G[1].name:"2. Select second"})]}),G[0]&&G[1]&&s.jsxs(Me,{size:"sm",onClick:async()=>{try{const[J,K]=await Promise.all([fe.getCloudSettingDetail(G[0].setting_id),fe.getCloudSettingDetail(G[1].setting_id)]);V([J.setting||{},K.setting||{}]),ee(!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: ",eQe(e.toISOString())]}),s.jsxs("span",{children:["Showing ",oe.length," of ",H," 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(ll,{className:"w-12 h-12 text-bambu-gray-dark mx-auto mb-4"}),s.jsx("p",{className:"text-bambu-gray",children:"No presets found"}),He&&s.jsx("button",{onClick:le,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(ID,{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(J=>J.type==="filament").length,")"]})]}),s.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[oe.filter(J=>J.type==="filament").map(J=>s.jsx(Kj,{setting:J,onClick:()=>Ae(J),onDuplicate:()=>Ne(J),compareMode:W,isCompareSelected:ge(J)!==void 0,compareIndex:ge(J),compareDisabled:W&&!!G[0]&&G[0].type!==J.type},J.setting_id)),oe.filter(J=>J.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(Xd,{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(J=>J.type==="process").length,")"]})]}),s.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[oe.filter(J=>J.type==="process").map(J=>s.jsx(Kj,{setting:J,onClick:()=>Ae(J),onDuplicate:()=>Ne(J),compareMode:W,isCompareSelected:ge(J)!==void 0,compareIndex:ge(J),compareDisabled:W&&!!G[0]&&G[0].type!==J.type},J.setting_id)),oe.filter(J=>J.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(J=>J.type==="printer").length,")"]})]}),s.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[oe.filter(J=>J.type==="printer").map(J=>s.jsx(Kj,{setting:J,onClick:()=>Ae(J),onDuplicate:()=>Ne(J),compareMode:W,isCompareSelected:ge(J)!==void 0,compareIndex:ge(J),compareDisabled:W&&!!G[0]&&G[0].type!==J.type},J.setting_id)),oe.filter(J=>J.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(rQe,{setting:M,onClose:()=>E(null),onDeleted:()=>E(null),onDuplicate:()=>Ne(M),onEdit:()=>_e(M)}),(A||C||U||q)&&s.jsx(aQe,{onClose:()=>{k(!1),R(null),O(null),j(null)},initialData:U||C||(q?{type:q.type,name:"",base_id:"",setting:q.setting}:void 0),allPresets:t}),T&&s.jsx(iQe,{onClose:()=>D(!1),onApply:J=>{j({type:J.type,setting:J.settings}),D(!1)}}),te&&z&&G[0]&&G[1]&&s.jsx(Vie,{onClose:()=>{ee(!1),V(null)},leftPreset:z[0],rightPreset:z[1],leftLabel:G[0].name,rightLabel:G[1].name})]})}function oQe(){const t=ln(),{showToast:e}=Yn(),[n,r]=w.useState("cloud"),[i,a]=w.useState(),{data:o,isLoading:l}=ft({queryKey:["cloudStatus"],queryFn:fe.getCloudStatus}),{data:c=[]}=ft({queryKey:["printers"],queryFn:fe.getPrinters}),{data:u,isLoading:d,refetch:f,dataUpdatedAt:m}=ft({queryKey:["cloudSettings"],queryFn:()=>fe.getCloudSettings(),enabled:!!o?.is_authenticated,retry:!1,staleTime:1e3*60*5});w.useEffect(()=>{m&&a(new Date(m))},[m]);const p=pt({mutationFn:fe.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(tN,{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(aN,{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(bP,{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(sQe,{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(tQe,{onSuccess:b})]}),n==="kprofiles"&&s.jsx(JYe,{}),s.jsx(nQe,{})]})}const Jb={Droplet:ID,Flame:Zde,Ruler:kfe,Sparkles:C0,Square:Oo,Cable:que,Wrench:Yd,Calendar:si,Timer:Td,Cog:Nde,Fan:hK,Zap:$f,Wind:EK,Thermometer:fN,Layers:ll,Box:Bs,Target:wK,RefreshCw:Ar,Settings:hN,Filter:iN,CircleDot:hde};function S0(t){return t&&Jb[t]||Yd}function Fp(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 Xj(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 lQe(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 cQe({item:t,onPerform:e,onToggle:n}){const r=S0(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 ${Fp(Math.abs(f),"days")}`:t.is_warning?`Due in ${Fp(f,"days")}`:`${Fp(f,"days")} left`}else return t.is_due?`Overdue by ${Fp(Math.abs(t.hours_until_due),"hours")}`:t.is_warning?`Due in ${Fp(t.hours_until_due,"hours")}`:`${Fp(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||lQe(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(ts,{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(cm,{className:"w-3.5 h-3.5"}),"Reset"]})]})]})})}function uQe({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(Et,{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(ts,{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(hu,{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(Td,{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(zf,{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=S0(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(cQe,{item:p,onPerform:e,onToggle:n},p.id))})})]})}function dQe({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,y]=w.useState(!1),[x,v]=w.useState(""),[S,M]=w.useState("100"),[E,A]=w.useState("hours"),[k,T]=w.useState("Wrench"),[D,C]=w.useState(""),[R,U]=w.useState(new Set),[O,q]=w.useState(null),j=w.useMemo(()=>t?t.map(B=>({id:B.printer_id,name:B.printer_name})):[],[t]),W=B=>t?t.filter(I=>I.maintenance_items.some(ce=>ce.maintenance_type_id===B)).map(I=>({printerId:I.printer_id,printerName:I.printer_name,itemId:I.maintenance_items.find(ce=>ce.maintenance_type_id===B)?.id})):[],X=B=>{if(!t)return[];const I=new Set(W(B).map(ce=>ce.printerId));return j.filter(ce=>!I.has(ce.id))},[G,Z]=w.useState(null),[te,ee]=w.useState(""),[z,V]=w.useState(""),[ne,ie]=w.useState("hours"),[he,me]=w.useState("Wrench"),[oe,Ae]=w.useState(""),ge=B=>{Z(B),ee(B.name),V(B.default_interval_hours.toString()),ie(B.interval_type||"hours"),me(B.icon||"Wrench"),Ae(B.wiki_url||"")},Ne=()=>{G&&te.trim()&&parseFloat(z)>0&&(i(G.id,{name:te.trim(),default_interval_hours:parseFloat(z),interval_type:ne,icon:he,wiki_url:oe.trim()||null}),Z(null))},_e=(B,I,ce)=>{const Ee=parseFloat(d);if(!isNaN(Ee)&&Ee>0){const Ie=Math.abs(Ee-I)<.01?null:Ee;n(B,{custom_interval_hours:Ie,custom_interval_type:m!==ce?m:null})}u(null)},le=B=>{B.preventDefault(),x.trim()&&parseFloat(S)>0&&R.size>0&&(r({name:x.trim(),default_interval_hours:parseFloat(S),interval_type:E,icon:k,wiki_url:D.trim()||null},Array.from(R)),v(""),M("100"),A("hours"),C(""),U(new Set),y(!1))},He=B=>{U(I=>{const ce=new Set(I);return ce.has(B)?ce.delete(B):ce.add(B),ce})},H=t?.map(B=>({printerId:B.printer_id,printerName:B.printer_name,items:B.maintenance_items.sort((I,ce)=>I.maintenance_type_id-ce.maintenance_type_id)})).sort((B,I)=>B.printerName.localeCompare(I.printerName))||[],J=e.filter(B=>B.is_system),K=e.filter(B=>!B.is_system);return s.jsxs("div",{className:"space-y-8",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Maintenance Types"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"System types and your custom maintenance tasks"})]}),s.jsxs(Me,{onClick:()=>y(!b),children:[s.jsx(rr,{className:"w-4 h-4"}),"Add Custom Type"]})]}),b&&s.jsx(Et,{className:"mb-6",children:s.jsx(Ct,{className:"py-4",children:s.jsxs("form",{onSubmit:le,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:B=>v(B.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:"e.g., Replace HEPA Filter",autoFocus:!0})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Interval Type"}),s.jsxs("select",{value:E,onChange:B=>{A(B.target.value),B.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 (",E==="days"?"days":"hours",")"]}),s.jsx("input",{type:"number",value:S,onChange:B=>M(B.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",min:"1"})]})]}),s.jsx("div",{className:"mt-4 flex items-end justify-between",children:s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Icon"}),s.jsx("div",{className:"flex gap-1",children:Object.keys(Jb).map(B=>{const I=Jb[B];return s.jsx("button",{type:"button",onClick:()=>T(B),className:`p-2 rounded-lg transition-colors ${k===B?"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"})},B)})})]})}),s.jsxs("div",{className:"mt-4",children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Documentation Link (optional)"}),s.jsx("input",{type:"url",value:D,onChange:B=>C(B.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:"https://wiki.bambulab.com/..."})]}),s.jsxs("div",{className:"mt-4",children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Assign to Printers"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:j.map(B=>s.jsx("button",{type:"button",onClick:()=>He(B.id),className:`px-3 py-1.5 rounded-lg text-sm transition-colors ${R.has(B.id)?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:B.name},B.id))}),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:()=>{y(!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:[J.map(B=>{const I=S0(B.icon),ce=B.interval_type||"hours";return s.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-dark-tertiary",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2.5 bg-bambu-dark rounded-lg",children:s.jsx(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:B.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(Td,{className:"w-3 h-3"}),Xj(B.default_interval_hours,ce)]})]})]})},B.id)}),K.map(B=>{const I=S0(B.icon),ce=B.interval_type||"hours";if(G?.id===B.id)return s.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green",children:s.jsxs("div",{className:"space-y-3",children:[s.jsx("input",{type:"text",value:te,onChange:L=>ee(L.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:"Name",autoFocus:!0}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("select",{value:ne,onChange:L=>ie(L.target.value),className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"hours",children:"Print Hours"}),s.jsx("option",{value:"days",children:"Calendar Days"})]}),s.jsx("input",{type:"number",value:z,onChange:L=>V(L.target.value),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",min:"1"})]}),s.jsx("div",{className:"flex flex-wrap gap-1",children:Object.keys(Jb).map(L=>{const Y=Jb[L];return s.jsx("button",{type:"button",onClick:()=>me(L),className:`p-1.5 rounded transition-colors ${he===L?"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"})},L)})}),s.jsx("input",{type:"url",value:oe,onChange:L=>Ae(L.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:"Documentation link (optional)"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Me,{size:"sm",onClick:Ne,disabled:!te.trim(),children:"Save"}),s.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>Z(null),children:"Cancel"})]})]})},B.id);const Ie=W(B.id),ue=X(B.id),$=O===B.id;return s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green/30",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2.5 bg-bambu-green/20 rounded-lg",children:s.jsx(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:B.name}),s.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-green/20 text-bambu-green text-[10px] font-medium rounded",children:"Custom"})]}),s.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[ce==="days"?s.jsx(si,{className:"w-3 h-3"}):s.jsx(Td,{className:"w-3 h-3"}),Xj(B.default_interval_hours,ce)]})]}),s.jsxs("button",{onClick:()=>q($?null:B.id),className:`px-2 py-1 rounded-lg border transition-colors flex items-center gap-1 ${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 ${$?"rotate-180":""}`})]}),s.jsx("button",{onClick:()=>ge(B),className:"p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",children:s.jsx(zf,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>{confirm(`Delete "${B.name}"?`)&&a(B.id)},className:"p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors",children:s.jsx(hn,{className:"w-4 h-4"})})]}),$&&s.jsxs("div",{className:"mt-3 pt-3 border-t border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Assigned to printers:"}),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(L=>s.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark rounded text-xs text-white",children:[L.printerName,s.jsx("button",{onClick:()=>L.itemId&&l(L.itemId),className:"hover:text-red-400 ml-1",title:"Remove from this printer",children:"×"})]},L.printerId))}),ue.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:"}),ue.map(L=>s.jsxs("button",{onClick:()=>o(L.id,B.id),className:"px-2 py-1 bg-bambu-dark hover:bg-bambu-green/20 rounded text-xs text-bambu-gray hover:text-bambu-green transition-colors",children:["+ ",L.name]},L.id))]})]})]},B.id)})]})]}),H.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:H.map(B=>s.jsx(Et,{children:s.jsxs(Ct,{className:"py-4",children:[s.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:B.printerName}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:B.items.map(I=>{const ce=S0(I.maintenance_type_icon),Ee=e.find(Y=>Y.id===I.maintenance_type_id),Ie=Ee?.default_interval_hours||I.interval_hours,ue=Ee?.interval_type||"hours",$=I.interval_type||"hours",L=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}),L?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(Td,{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"&&_e(I.id,Ie,ue),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:()=>_e(I.id,Ie,ue),children:"OK"})]}):s.jsxs("button",{onClick:()=>{u(I.id),f(I.interval_hours.toString()),p($)},className:"px-2 py-1 bg-bambu-dark-tertiary hover:bg-bambu-dark-secondary border border-bambu-dark-tertiary hover:border-bambu-green rounded text-xs font-medium text-white transition-colors flex items-center gap-1",children:[$==="days"?s.jsx(si,{className:"w-3 h-3"}):s.jsx(Td,{className:"w-3 h-3"}),Xj(I.interval_hours,$),s.jsx(zf,{className:"w-3 h-3 text-bambu-gray"})]})]},I.id)})})]})},B.printerId))})]}),H.length===0&&s.jsx(Et,{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 hQe(){const t=ln(),{showToast:e}=Yn(),[n,r]=w.useState("status"),{data:i,isLoading:a}=ft({queryKey:["maintenanceOverview"],queryFn:fe.getMaintenanceOverview}),{data:o}=ft({queryKey:["maintenanceTypes"],queryFn:fe.getMaintenanceTypes}),l=pt({mutationFn:({id:M,notes:E})=>fe.performMaintenance(M,E),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:E})=>fe.updateMaintenanceItem(M,E),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:M=>{e(M.message,"error")}}),u=pt({mutationFn:({id:M,data:E})=>fe.updateMaintenanceType(M,E),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type updated")},onError:M=>{e(M.message,"error")}}),d=pt({mutationFn:fe.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:E})=>fe.setPrinterHours(M,E),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:E})=>fe.assignMaintenanceType(M,E),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Printer assigned")},onError:M=>{e(M.message,"error")}}),p=pt({mutationFn:fe.removeMaintenanceItem,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Printer removed")},onError:M=>{e(M.message,"error")}}),b=M=>{l.mutate({id:M})},y=(M,E)=>{c.mutate({id:M,data:{enabled:E}})},x=(M,E)=>{f.mutate({printerId:M,hours:E})};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 v=i?.reduce((M,E)=>M+E.due_count,0)||0,S=i?.reduce((M,E)=>M+E.warning_count,0)||0;return s.jsxs("div",{className:"p-4 md:p-8",children:[s.jsxs("div",{className:"mb-6",children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:"Maintenance"}),s.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:n==="status"?s.jsxs(s.Fragment,{children:[v>0&&s.jsxs("span",{className:"text-red-400",children:[v," task",v!==1?"s":""," overdue"]}),v>0&&S>0&&" · ",S>0&&s.jsxs("span",{className:"text-amber-400",children:[S," due soon"]}),v===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,E)=>{const A=M.due_count*10+M.warning_count,k=E.due_count*10+E.warning_count;return A!==k?k-A:M.printer_name.localeCompare(E.printer_name)}).map(M=>s.jsx(uQe,{overview:M,onPerform:b,onToggle:y,onSetHours:x},M.printer_id)):s.jsx(Et,{children:s.jsxs(Ct,{className:"text-center py-16",children:[s.jsx(Yd,{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(dQe,{overview:i,types:o||[],onUpdateInterval:(M,E)=>c.mutate({id:M,data:E}),onAddType:async(M,E)=>{const A=await fe.createMaintenanceType(M);for(const k of E)await fe.assignMaintenanceType(k,A.id);t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type added")},onUpdateType:(M,E)=>u.mutate({id:M,data:E}),onDeleteType:M=>d.mutate(M),onAssignType:(M,E)=>m.mutate({printerId:M,typeId:E}),onRemoveItem:M=>p.mutate(M)})]})}const hq=["#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#6b7280"];function Gie({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||hq[0]),[d,f]=w.useState(t?.target_count?.toString()||""),[m,p]=w.useState(t?.target_parts_count?.toString()||""),[b,y]=w.useState(t?.status||"active"),[x,v]=w.useState(t?.tags||""),[S,M]=w.useState(t?.due_date?.split("T")[0]||""),[E,A]=w.useState(t?.priority||"normal"),k=T=>{T.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:E,...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:T=>a(T.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"e.g., Voron 2.4 Build",required:!0})]}),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:T=>l(T.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green resize-none",placeholder:"Optional description...",rows:2})]}),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:hq.map(T=>s.jsx("button",{type:"button",onClick:()=>u(T),className:`w-8 h-8 rounded-full transition-transform ${c===T?"ring-2 ring-white ring-offset-2 ring-offset-bambu-dark-secondary scale-110":""}`,style:{backgroundColor:T}},T))})]}),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:T=>f(T.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"e.g., 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:T=>p(T.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"e.g., 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:T=>v(T.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"e.g., voron, functional, gift"})]}),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:T=>M(T.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Priority"}),s.jsxs("select",{value:E,onChange:T=>A(T.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green",children:[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:T=>y(T.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green",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 fQe({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:eN,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(v=>v.trim())).filter(Boolean),p=[...new Set(m)],b=t.archives.map(x=>x.filament_color).filter(Boolean).flatMap(x=>x.split(",").map(v=>v.trim())).filter(x=>x.startsWith("#")||/^[0-9A-Fa-f]{6}$/.test(x)),y=[...new Set(b)];return p.length===0&&y.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)),y.length>0&&s.jsxs("div",{className:"flex items-center gap-0.5",children:[y.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)),y.length>5&&s.jsxs("span",{className:"text-[10px] text-bambu-gray ml-0.5",children:["+",y.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(Id,{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(zf,{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:fe.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(Zl,{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(ll,{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(Zl,{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(xP,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:t.queue_count})]})]}),s.jsx(Qs,{className:"w-4 h-4 text-bambu-gray/50 group-hover:text-bambu-gray transition-colors"})]})]})]})}function mQe(){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:()=>fe.getProjects(l==="all"?void 0:l)}),p=pt({mutationFn:U=>fe.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:O})=>fe.updateProject(U,O),onSuccess:()=>{e.invalidateQueries({queryKey:["projects"]}),i(!1),o(void 0),n("Project updated","success")},onError:U=>{n(U.message,"error")}}),y=pt({mutationFn:U=>fe.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=>fe.importProject(U),onSuccess:()=>{e.invalidateQueries({queryKey:["projects"]}),n("Project imported","success")},onError:U=>{n(U.message,"error")}}),v=w.useRef(null),S=async()=>{try{const U=await fe.getProjects(),O=await Promise.all(U.map(async X=>await fe.exportProjectJson(X.id))),q=new Blob([JSON.stringify(O,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=()=>{v.current?.click()},E=async U=>{const O=U.target.files?.[0];if(O){try{if(O.name.toLowerCase().endsWith(".zip")){const j=new FormData;j.append("file",O);const W=await fetch("/api/v1/projects/import/file",{method:"POST",body:j});if(!W.ok){const X=await W.json();throw new Error(X.detail||"Import failed")}e.invalidateQueries({queryKey:["projects"]}),n("Project imported","success")}else{const j=await O.text(),W=JSON.parse(j),X=Array.isArray(W)?W:[W];for(const G of X)await x.mutateAsync(G);X.length>1&&n(`${X.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)},T=U=>{t(`/projects/${U.id}`)},D=U=>{d(U)},C=()=>{u!==null&&y.mutate(u)},R=f?.reduce((U,O)=>(U[O.status]=(U[O.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:v,type:"file",accept:".json,.zip",onChange:E,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:eN},{key:"archived",label:"Archived",icon:Ja},{key:"all",label:"All",icon:Ea}].map(({key:U,label:O,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:O}),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(fQe,{project:U,onClick:()=>T(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:C,onCancel:()=>d(null)}),r&&s.jsx(Gie,{project:a,onClose:()=>{i(!1),o(void 0)},onSave:A,isLoading:p.isPending||b.isPending})]})}function pQe(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 gQe(t){return t>=1e3?`${(t/1e3).toFixed(2)}kg`:`${Math.round(t)}g`}function xQe({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 fq({icon:t,label:e,value:n,subValue:r,hint:i,color:a="text-bambu-gray"}){return s.jsx(Et,{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 bQe({archives:t}){return t.length===0?s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx(Zl,{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(gs,{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:fe.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(Zl,{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 yQe({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 vQe(t){return t?bg(t,{year:"numeric",month:"short",day:"numeric"}):""}function Yj(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 _Qe(){const{id:t}=ND(),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:()=>fe.getProject(d),enabled:d>0}),{data:b,isLoading:y}=ft({queryKey:["project-archives",d],queryFn:()=>fe.getProjectArchives(d),enabled:d>0}),{data:x,isLoading:v}=ft({queryKey:["project-bom",d],queryFn:()=>fe.getProjectBOM(d),enabled:d>0}),{data:S,isLoading:M}=ft({queryKey:["project-timeline",d],queryFn:()=>fe.getProjectTimeline(d,20),enabled:d>0}),{data:E}=ft({queryKey:["settings"],queryFn:fe.getSettings}),{data:A}=ft({queryKey:["project-folders",d],queryFn:()=>fe.getLibraryFoldersByProject(d),enabled:d>0}),k=E?.currency||"$",T=E?.time_format||"system",D=pt({mutationFn:ye=>fe.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")}}),C=()=>{u(f?.notes||""),l(!0)},R=()=>{D.mutate({notes:c})},U=()=>{l(!1),u("")},[O,q]=w.useState(""),[j,W]=w.useState(1),[X,G]=w.useState(""),[Z,te]=w.useState(""),[ee,z]=w.useState(""),[V,ne]=w.useState(!1),[ie,he]=w.useState(!1),[me,oe]=w.useState(null),[Ae,ge]=w.useState(""),[Ne,_e]=w.useState(1),[le,He]=w.useState(""),[H,J]=w.useState(""),[K,B]=w.useState(""),[I,ce]=w.useState({isOpen:!1,title:"",message:"",onConfirm:()=>{}}),Ee=pt({mutationFn:ye=>fe.createBOMItem(d,ye),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",d]}),n.invalidateQueries({queryKey:["project",d]}),q(""),W(1),G(""),te(""),z(""),ne(!1),r("Part added","success")},onError:ye=>r(ye.message,"error")}),Ie=pt({mutationFn:({itemId:ye,data:ke})=>fe.updateBOMItem(d,ye,ke),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",d]}),n.invalidateQueries({queryKey:["project",d]}),oe(null)},onError:ye=>r(ye.message,"error")}),ue=pt({mutationFn:ye=>fe.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")}),$=ye=>{ye.preventDefault(),O.trim()&&Ee.mutate({name:O.trim(),quantity_needed:j,unit_price:X?parseFloat(X):void 0,sourcing_url:Z.trim()||void 0,remarks:ee.trim()||void 0})},L=ye=>{const ke=ye.is_complete?0:ye.quantity_needed;Ie.mutate({itemId:ye.id,data:{quantity_acquired:ke}})},Y=(ye,ke)=>{ce({isOpen:!0,title:"Delete Part",message:`Are you sure you want to delete "${ke}"?`,onConfirm:()=>{ce(Ue=>({...Ue,isOpen:!1})),ue.mutate(ye)}})},pe=ye=>{oe(ye),ge(ye.name),_e(ye.quantity_needed),He(ye.unit_price?.toString()||""),J(ye.sourcing_url||""),B(ye.remarks||"")},Se=ye=>{ye.preventDefault(),!(!me||!Ae.trim())&&Ie.mutate({itemId:me.id,data:{name:Ae.trim(),quantity_needed:Ne,unit_price:le?parseFloat(le):void 0,sourcing_url:H.trim()||void 0,remarks:K.trim()||void 0}})},ae=()=>{oe(null)},je=async()=>{try{const ye=await fetch(`/api/v1/projects/${d}/export`);if(!ye.ok)throw new Error("Export failed");const ke=await ye.blob(),Ue=URL.createObjectURL(ke),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:()=>fe.createTemplateFromProject(d),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),r("Template created","success")},onError:ye=>r(ye.message,"error")}),Xe=ye=>yg(ye,T,{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,Qe=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(gs,{to:"/projects",className:"hover:text-white transition-colors",children:"Projects"}),s.jsx(Qs,{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(lK,{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(xQe,{status:f.status})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Me,{variant:"secondary",onClick:je,title:"Export project",children:[s.jsx($r,{className:"w-4 h-4 mr-2"}),"Export"]}),s.jsxs(Me,{onClick:()=>a(!0),children:[s.jsx(zf,{className:"w-4 h-4 mr-2"}),"Edit"]})]})]}),(f.target_count||f.target_parts_count)&&s.jsx(Et,{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(Qe,100)}%`,backgroundColor:Qe>=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:[Qe.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(Et,{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(Zl,{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(fq,{icon:Jn,label:"Print Time",value:pQe(et.total_print_time_hours),color:"text-yellow-400"}),s.jsx(fq,{icon:Wr,label:"Filament Used",value:gQe(et.total_filament_grams),color:"text-purple-400"})]}),et&&(et.estimated_cost>0||f.budget)&&s.jsx(Et,{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(Et,{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(ihe,{className:"w-5 h-5"}),"Sub-projects (",f.children.length,")"]}),s.jsx("div",{className:"space-y-2",children:f.children.map(ye=>s.jsxs(gs,{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(ll,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("span",{className:"text-bambu-gray",children:"Part of:"}),s.jsx(gs,{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(yQe,{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:vQe(f.due_date)}),Yj(f.due_date)&&s.jsxs("span",{className:`text-xs ${Yj(f.due_date).color}`,children:["(",Yj(f.due_date).label,")"]})]}),f.tags&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(xg,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("div",{className:"flex flex-wrap gap-1",children:f.tags.split(",").map((ye,ke)=>s.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark-tertiary text-bambu-gray text-xs rounded",children:ye.trim()},ke))})]})]}),s.jsx(Et,{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(Ht,{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(ys,{className:"w-4 h-4 mr-1"}),"Save"]})]}):s.jsxs(Me,{variant:"secondary",size:"sm",onClick:C,children:[s.jsx(zf,{className:"w-4 h-4 mr-1"}),"Edit"]})]}),o?s.jsx(hD,{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(Et,{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(ol,{className:"w-5 h-5"}),"Files"]})}),s.jsxs("p",{className:"text-xs text-bambu-gray mb-3",children:[s.jsx(gs,{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(gs,{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(ol,{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(Qs,{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(Et,{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(vK,{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(!ie),className:`text-xs px-2 py-1 rounded transition-colors ${ie?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:ie?"Show all":"Hide done"}),!V&&s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>ne(!0),children:[s.jsx(rr,{className:"w-4 h-4 mr-1"}),"Add Part"]})]})]}),V&&s.jsxs("form",{onSubmit:$,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:O,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:X,onChange:ye=>G(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:Z,onChange:ye=>te(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:ee,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:()=>ne(!1),children:"Cancel"}),s.jsx(Me,{type:"submit",size:"sm",disabled:!O.trim()||Ee.isPending,children:Ee.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):"Add Part"})]})]}),v?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=>!ie||!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:me?.id===ye.id?s.jsxs("form",{onSubmit:Se,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:Ae,onChange:ke=>ge(ke.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:Ne,onChange:ke=>_e(parseInt(ke.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:le,onChange:ke=>He(ke.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:H,onChange:ke=>J(ke.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:K,onChange:ke=>B(ke.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:!Ae.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:()=>L(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(sa,{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:ke=>ke.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,ke)=>ye+(ke.unit_price||0)*ke.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(Et,{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(Rw,{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,ke)=>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(xP,{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:Xe(ye.timestamp)})]})]},ke))}):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(sl,{className:"w-4 h-4 mr-2"}),"Save as Template"]})}),et&&(et.queued_prints>0||et.in_progress_prints>0)&&s.jsx(Et,{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(xP,{className:"w-5 h-5"}),"Queue"]}),s.jsx(gs,{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(Zl,{className:"w-5 h-5"}),"Prints (",b?.length||0,")"]})}),y?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(bQe,{archives:b||[]})]}),i&&s.jsx(Gie,{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 Gp(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 wQe(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 SQe({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 MQe({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 NQe({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(ol,{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 EQe({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:()=>fe.getProjects()}),{data:u}=ft({queryKey:["archives-for-link"],queryFn:()=>fe.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(Ht,{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(uK,{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(wf,{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($D,{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 AQe({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)},y=R=>{R.preventDefault(),o(!1)},x=R=>{R.preventDefault(),o(!1);const U=Array.from(R.dataTransfer.files);S(U)},v=R=>{R.target.files&&S(Array.from(R.target.files))},S=R=>{const U=R.map(O=>({file:O,status:"pending",isZip:O.name.toLowerCase().endsWith(".zip")}));i(O=>[...O,...U])},M=R=>{i(U=>U.filter((O,q)=>q!==R))},E=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((O,q)=>q===R?{...O,status:"uploading"}:O));try{if(r[R].isZip){const U=await fe.extractZipFile(r[R].file,t,u,f);i(O=>O.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 fe.uploadLibraryFile(r[R].file,t),i(U=>U.map((O,q)=>q===R?{...O,status:"success"}:O))}catch(U){i(O=>O.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,T=r.filter(R=>R.status==="success").length,D=r.filter(R=>R.status==="error").length,C=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(Ht,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsxs("div",{onDragOver:b,onDragLeave:y,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:v}),E&&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(rN,{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(Ht,{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))}),C&&s.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:s.jsxs("p",{className:"text-sm text-white",children:["Upload complete: ",T," 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:C?"Close":"Cancel"}),!C&&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 Wie({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-center 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",children:s.jsx(Qs,{className:`w-3.5 h-3.5 transition-transform ${l?"rotate-90":""}`})}):s.jsx("div",{className:"w-4.5"}),s.jsx(ol,{className:"w-4 h-4 text-bambu-green flex-shrink-0"}),s.jsx("span",{className:"text-sm truncate flex-1",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(uK,{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(Id,{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(sa,{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(Wie,{folder:p,selectedFolderId:e,onSelect:n,onDelete:r,onLink:i,onRename:a,depth:o+1},p.id))})]})}function vD(t){const e=t.toLowerCase();return e.endsWith(".gcode")||e.includes(".gcode.")}function TQe({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:fe.getLibraryFileThumbnailUrl(t.id),alt:t.filename,className:"w-full h-full object-cover"}):s.jsx(wf,{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:Gp(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"}),wQe(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(Id,{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&&vD(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&&vD(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(sa,{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 CQe(){const t=ln(),{showToast:e}=Yn(),[n]=Vq(),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),[y,x]=w.useState(null),[v,S]=w.useState(null),[M,E]=w.useState(null),[A,k]=w.useState(null),[T,D]=w.useState(null),[C,R]=w.useState(()=>localStorage.getItem("library-view-mode")||"grid"),[U,O]=w.useState(""),[q,j]=w.useState("all"),[W,X]=w.useState("date"),[G,Z]=w.useState("desc");w.useEffect(()=>{const ae=n.get("folder");if(ae){const je=parseInt(ae,10);o(je)}},[n]);const{data:te}=ft({queryKey:["settings"],queryFn:()=>fe.getSettings()}),{data:ee,isLoading:z}=ft({queryKey:["library-folders"],queryFn:()=>fe.getLibraryFolders()}),{data:V,isLoading:ne}=ft({queryKey:["library-files",a],queryFn:()=>fe.getLibraryFiles(a,a===null)}),{data:ie}=ft({queryKey:["library-stats"],queryFn:()=>fe.getLibraryStats()}),he=w.useMemo(()=>{if(!V)return[];const ae=new Set(V.map(je=>je.file_type));return Array.from(ae).sort()},[V]),me=w.useMemo(()=>{if(!V)return[];let ae=[...V];if(U.trim()){const je=U.toLowerCase();ae=ae.filter(De=>De.filename.toLowerCase().includes(je)||De.print_name&&De.print_name.toLowerCase().includes(je))}return q!=="all"&&(ae=ae.filter(je=>je.file_type===q)),ae.sort((je,De)=>{let Xe=0;switch(W){case"name":Xe=(je.print_name||je.filename).localeCompare(De.print_name||De.filename);break;case"date":Xe=new Date(je.created_at).getTime()-new Date(De.created_at).getTime();break;case"size":Xe=je.file_size-De.file_size;break;case"type":Xe=je.file_type.localeCompare(De.file_type);break;case"prints":Xe=je.print_count-De.print_count;break}return G==="asc"?Xe:-Xe}),ae},[V,U,q,W,G]),oe=w.useMemo(()=>{if(!ie||!te)return!1;const ae=(te.library_disk_warning_gb||5)*1024*1024*1024;return ie.disk_free_bytes<ae},[ie,te]),Ae=pt({mutationFn:ae=>fe.createLibraryFolder(ae),onSuccess:()=>{t.invalidateQueries({queryKey:["library-folders"]}),d(!1),e("Folder created","success")},onError:ae=>e(ae.message,"error")}),ge=pt({mutationFn:ae=>fe.deleteLibraryFolder(ae),onSuccess:()=>{t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-stats"]}),a===v?.id&&o(null),S(null),e("Folder deleted","success")},onError:ae=>{S(null),e(ae.message,"error")}}),Ne=pt({mutationFn:ae=>fe.deleteLibraryFile(ae),onSuccess:()=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-stats"]}),c(ae=>ae.filter(je=>je!==v?.id)),S(null),e("File deleted","success")},onError:ae=>{S(null),e(ae.message,"error")}}),_e=pt({mutationFn:ae=>fe.bulkDeleteLibrary(ae,[]),onSuccess:(ae,je)=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-stats"]}),e(`Deleted ${je.length} files`,"success"),c([]),S(null)},onError:ae=>{S(null),e(ae.message,"error")}}),le=pt({mutationFn:({fileIds:ae,folderId:je})=>fe.moveLibraryFiles(ae,je),onSuccess:()=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-folders"]}),c([]),m(!1),e("Files moved","success")},onError:ae=>e(ae.message,"error")}),He=pt({mutationFn:({id:ae,data:je})=>fe.updateLibraryFolder(ae,je),onSuccess:(ae,je)=>{t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["project-folders"]}),t.invalidateQueries({queryKey:["archive-folders"]}),x(null);const De=je.data.project_id===0&&je.data.archive_id===0;e(De?"Folder unlinked":"Folder linked","success")},onError:ae=>e(ae.message,"error")}),H=pt({mutationFn:ae=>fe.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")}),J=pt({mutationFn:({id:ae,filename:je})=>fe.updateLibraryFile(ae,{filename:je}),onSuccess:()=>{t.invalidateQueries({queryKey:["library-files"]}),D(null),e("File renamed","success")},onError:ae=>{D(null),e(ae.message,"error")}}),K=pt({mutationFn:({id:ae,name:je})=>fe.updateLibraryFolder(ae,{name:je}),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")}}),B=w.useCallback(ae=>{const je=ae.toLowerCase();return je.endsWith(".gcode")||je.includes(".gcode.")},[]),I=w.useMemo(()=>V?V.filter(ae=>l.includes(ae.id)&&B(ae.filename)):[],[V,l,B]),ce=w.useCallback(ae=>{c(je=>je.includes(ae)?je.filter(De=>De!==ae):[...je,ae])},[]),Ee=w.useCallback(()=>{me.length>0&&c(me.map(ae=>ae.id))},[me]),Ie=w.useCallback(()=>{c([])},[]),ue=()=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-stats"]})},$=ae=>{window.open(fe.getLibraryFileDownloadUrl(ae),"_blank")},L=()=>{v&&(v.type==="file"?Ne.mutate(v.id):v.type==="folder"?ge.mutate(v.id):v.type==="bulk"&&_e.mutate(l))},Y=ge.isPending||Ne.isPending||_e.isPending,pe=ae=>{R(ae),localStorage.setItem("library-view-mode",ae)},Se=z||ne;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(ol,{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 ${C==="grid"?"bg-bambu-card text-white":"text-bambu-gray hover:text-white"}`,title:"Grid view",children:s.jsx(lN,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>pe("list"),className:`p-1.5 rounded transition-colors ${C==="list"?"bg-bambu-card text-white":"text-bambu-gray hover:text-white"}`,title:"List view",children:s.jsx(cN,{className:"w-4 h-4"})})]}),s.jsxs(Me,{variant:"secondary",onClick:()=>d(!0),children:[s.jsx(nhe,{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&&ie&&te&&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 ",Gp(ie.disk_free_bytes)," free of ",Gp(ie.disk_total_bytes)," total. Threshold is set to ",te.library_disk_warning_gb," GB in settings."]})]})]}),ie&&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(rN,{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:ie.total_files})]}),s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(ol,{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:ie.total_folders})]}),s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(sN,{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:Gp(ie.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:Gp(ie.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(wf,{className:"w-4 h-4"}),s.jsx("span",{className:"text-sm",children:"All Files"})]}),ee?.map(ae=>s.jsx(Wie,{folder:ae,selectedFolderId:a,onSelect:o,onDelete:je=>S({type:"folder",id:je}),onLink:x,onRename:je=>D({type:"folder",id:je.id,name:je.name})},ae.id))]})]}),s.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[V&&V.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(Ma,{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=>O(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(iN,{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=>X(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:()=>Z(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:G==="asc"?"Ascending":"Descending",children:G==="asc"?s.jsx(Due,{className:"w-4 h-4 text-white"}):s.jsx(Tue,{className:"w-4 h-4 text-white"})})]}),(U||q!=="all")&&s.jsxs("span",{className:"text-sm text-bambu-gray",children:[me.length," of ",V.length," files"]})]}),me.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===me.length&&l.length>0?s.jsxs(Me,{variant:"secondary",size:"sm",onClick:Ie,children:[s.jsx(Oo,{className:"w-4 h-4 mr-1"}),"Deselect All"]}):s.jsxs(Me,{variant:"secondary",size:"sm",onClick:Ee,children:[s.jsx(Do,{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(cl,{className:"w-4 h-4 mr-1"}),"Print"]}),I.length>0&&s.jsxs(Me,{variant:I.length===1?"secondary":"primary",size:"sm",onClick:()=>H.mutate(I.map(ae=>ae.id)),disabled:H.isPending,children:[s.jsx(Jn,{className:"w-4 h-4 mr-1"}),H.isPending?"Adding...":`Add to Queue${I.length<l.length?` (${I.length})`:""}`]}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>m(!0),children:[s.jsx(ufe,{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"})]})]}),Se?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..."})]})}):V?.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(wf,{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"]})]}):me.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(Ma,{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:()=>{O(""),j("all")},children:"Clear filters"})]}):C==="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:me.map(ae=>s.jsx(TQe,{file:ae,isSelected:l.includes(ae.id),onSelect:ce,onDelete:je=>S({type:"file",id:je}),onDownload:$,onAddToQueue:je=>H.mutate([je]),onPrint:E,onRename:je=>D({type:"file",id:je.id,name:je.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",{})]}),me.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:fe.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(wf,{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:fe.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:Gp(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:je=>je.stopPropagation(),children:[vD(ae.filename)&&s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>E(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:()=>H.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:H.isPending,children:s.jsx(Jn,{className:"w-4 h-4"})})]}),s.jsx("button",{onClick:()=>$(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(sa,{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(SQe,{parentId:a,onClose:()=>d(!1),onSave:ae=>Ae.mutate(ae),isLoading:Ae.isPending}),f&&ee&&s.jsx(NQe,{folders:ee,selectedFiles:l,currentFolderId:a,onClose:()=>m(!1),onMove:ae=>le.mutate({fileIds:l,folderId:ae}),isLoading:le.isPending}),p&&s.jsx(AQe,{folderId:a,onClose:()=>b(!1),onUploadComplete:ue}),y&&s.jsx(EQe,{folder:y,onClose:()=>x(null),onLink:ae=>He.mutate({id:y.id,data:ae}),isLoading:He.isPending}),v&&s.jsx(zn,{title:v.type==="folder"?"Delete Folder":v.type==="bulk"?`Delete ${v.count} Files`:"Delete File",message:v.type==="folder"?"Are you sure you want to delete this folder? All files inside will also be deleted.":v.type==="bulk"?`Are you sure you want to delete ${v.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:L,onCancel:()=>S(null)}),M&&s.jsx(ah,{mode:"reprint",libraryFileId:M.id,archiveName:M.print_name||M.filename,onClose:()=>E(null),onSuccess:()=>{E(null),t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["archives"]})}}),A&&s.jsx(ah,{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"]})}}),T&&s.jsx(MQe,{type:T.type,currentName:T.name,onClose:()=>D(null),onSave:ae=>{T.type==="file"?J.mutate({id:T.id,filename:ae}):K.mutate({id:T.id,name:ae})},isLoading:J.isPending||K.isPending})]})}const Qj=5,kQe=2e3,jQe=3e4,PQe=5e3;function RQe(){const{printerId:t}=ND(),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,y]=w.useState(0),[x,v]=w.useState(!1),[S,M]=w.useState(0),[E,A]=w.useState(1),[k,T]=w.useState({x:0,y:0}),[D,C]=w.useState(!1),[R,U]=w.useState({x:0,y:0}),[O,q]=w.useState(null),[j,W]=w.useState(null),X=w.useRef(null),G=w.useRef(null),Z=w.useRef(null),te=w.useRef(null),ee=w.useRef(null),{data:z}=ft({queryKey:["printer",e],queryFn:()=>fe.getPrinter(e),enabled:e>0});w.useEffect(()=>(z&&(document.title=`${z.name} - Camera`),()=>{document.title="Bambuddy"}),[z]);const V=w.useRef(!1);w.useEffect(()=>{const Y=`/api/v1/printers/${e}/camera/stop`;V.current=!1;const pe=()=>{e>0&&!V.current&&(V.current=!0,navigator.sendBeacon(Y))},Se=()=>{pe()};window.addEventListener("beforeunload",Se);const ae=X.current;return()=>{window.removeEventListener("beforeunload",Se),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),T({x:0,y:0}),n==="stream"&&!d&&(X.current&&(X.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(()=>()=>{Z.current&&clearTimeout(Z.current),te.current&&clearInterval(te.current),ee.current&&clearInterval(ee.current)},[]);const ne=w.useCallback(()=>{if(b>=Qj){v(!1),a(!0);return}const Y=Math.min(kQe*Math.pow(2,b),jQe);v(!0),M(Math.ceil(Y/1e3)),te.current=setInterval(()=>{M(pe=>pe<=1?(te.current&&clearInterval(te.current),0):pe-1)},1e3),Z.current=setTimeout(()=>{y(pe=>pe+1),v(!1),l(!0),a(!1),X.current&&(X.current.src=""),u(Date.now())},Y)},[b]);w.useEffect(()=>{if(n!=="stream"||o||x||d){ee.current&&(clearInterval(ee.current),ee.current=null);return}return ee.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...`),ee.current&&(clearInterval(ee.current),ee.current=null),l(!1),ne())}}catch{}},PQe),()=>{ee.current&&(clearInterval(ee.current),ee.current=null)}},[n,o,i,x,d,e,ne]);const ie=()=>{l(!1),n==="stream"&&b<Qj?ne():a(!0)},he=()=>{if(l(!1),a(!1),y(0),v(!1),Z.current&&clearTimeout(Z.current),te.current&&clearInterval(te.current),X.current&&!localStorage.getItem("cameraWindowState")){const Y=X.current,pe=Y.naturalWidth,Se=Y.naturalHeight;if(pe>0&&Se>0){const De=window.outerWidth-window.innerWidth,Xe=window.outerHeight-window.innerHeight,et=pe+16+De,Qe=Se+45+16+Xe;try{window.resizeTo(et,Qe)}catch{}}}},me=()=>{e>0&&fetch(`/api/v1/printers/${e}/camera/stop`).catch(()=>{})},oe=Y=>{n===Y||d||(f(!0),l(!0),a(!1),y(0),v(!1),A(1),T({x:0,y:0}),Z.current&&clearTimeout(Z.current),te.current&&clearInterval(te.current),X.current&&(X.current.src=""),n==="stream"&&me(),setTimeout(()=>{r(Y),u(Date.now()),f(!1)},100))},Ae=()=>{d||(f(!0),l(!0),a(!1),y(0),v(!1),Z.current&&clearTimeout(Z.current),te.current&&clearInterval(te.current),X.current&&(X.current.src=""),n==="stream"&&me(),setTimeout(()=>{u(Date.now()),f(!1)},100))},ge=()=>{G.current&&(document.fullscreenElement?document.exitFullscreen():G.current.requestFullscreen())},Ne=()=>{A(Y=>Math.min(Y+.5,4))},_e=()=>{A(Y=>{const pe=Math.max(Y-.5,1);return pe===1&&T({x:0,y:0}),pe})},le=Y=>{Y.preventDefault(),Y.deltaY<0?Ne():_e()},He=Y=>{E>1&&(Y.preventDefault(),C(!0),U({x:Y.clientX-k.x,y:Y.clientY-k.y}))},H=w.useCallback(()=>{if(!G.current)return{x:300,y:200};const Y=G.current.getBoundingClientRect(),pe=Y.width*(E-1)/2,Se=Y.height*(E-1)/2;return{x:Math.max(50,pe),y:Math.max(50,Se)}},[E]),J=Y=>{if(D&&E>1){const pe=Y.clientX-R.x,Se=Y.clientY-R.y,ae=H();T({x:Math.max(-ae.x,Math.min(ae.x,pe)),y:Math.max(-ae.y,Math.min(ae.y,Se))})}},K=()=>{C(!1)},B=Y=>{if(Y.length<2)return 0;const pe=Y[0].clientX-Y[1].clientX,Se=Y[0].clientY-Y[1].clientY;return Math.sqrt(pe*pe+Se*Se)},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(B(Y.touches)),W(I(Y.touches))):Y.touches.length===1&&E>1&&(Y.preventDefault(),C(!0),U({x:Y.touches[0].clientX-k.x,y:Y.touches[0].clientY-k.y}))},Ee=Y=>{if(Y.touches.length===2&&O!==null){Y.preventDefault();const pe=B(Y.touches),Se=pe/O;A(je=>{const De=Math.max(1,Math.min(4,je*Se));return De===1&&T({x:0,y:0}),De}),q(pe);const ae=I(Y.touches);if(j){const je=H();T(De=>({x:Math.max(-je.x,Math.min(je.x,De.x+(ae.x-j.x))),y:Math.max(-je.y,Math.min(je.y,De.y+(ae.y-j.y)))}))}W(ae)}else if(Y.touches.length===1&&D&&E>1){Y.preventDefault();const pe=Y.touches[0].clientX-R.x,Se=Y.touches[0].clientY-R.y,ae=H();T({x:Math.max(-ae.x,Math.min(ae.x,pe)),y:Math.max(-ae.y,Math.min(ae.y,Se))})}},Ie=Y=>{Y.touches.length<2&&(q(null),W(null)),Y.touches.length===0&&C(!1)},ue=()=>{A(1),T({x:0,y:0})},$=d?"":n==="stream"?`/api/v1/printers/${e}/camera/stream?fps=10&t=${c}`:`/api/v1/printers/${e}/camera/snapshot?t=${c}`,L=o||d||x;return e?s.jsxs("div",{ref:G,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(mg,{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:L,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:L,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:Ae,disabled:L,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 ${L?"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(bK,{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:le,onMouseMove:J,onMouseUp:K,onMouseLeave:K,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(Qg,{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,"/",Qj,")"]}),s.jsx("button",{onClick:Ae,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:Ae,className:"px-4 py-2 bg-bambu-green text-white rounded hover:bg-bambu-green/80 transition-colors",children:"Retry"})]})}),s.jsx("img",{ref:X,src:$,alt:"Camera stream",className:"max-w-full max-h-full object-contain select-none",style:{transform:`scale(${E}) translate(${k.x/E}px, ${k.y/E}px)`,cursor:E>1?D?"grabbing":"grab":"default"},onError:$?ie:void 0,onLoad:$?he:void 0,onMouseDown:He,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:_e,disabled:E<=1,className:"p-1.5 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom out",children:s.jsx(GD,{className:"w-4 h-4 text-white"})}),s.jsxs("button",{onClick:ue,className:"px-2 py-1 text-sm text-white hover:bg-white/10 rounded min-w-[48px]",title:"Reset zoom",children:[Math.round(E*100),"%"]}),s.jsx("button",{onClick:Ne,disabled:E>=4,className:"p-1.5 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom in",children:s.jsx(VD,{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 DQe(){const{id:t}=ND(),{mode:e}=lh(),{data:n,isLoading:r,error:i}=ft({queryKey:["external-link",t],queryFn:()=>fe.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 mq=["DEBUG","INFO","WARNING","ERROR"],Zj={DEBUG:"text-gray-400",INFO:"text-blue-400",WARNING:"text-yellow-400",ERROR:"text-red-400"},OQe={DEBUG:JM,INFO:Ql,WARNING:Tn,ERROR:aa};function LQe(){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:y,refetch:x}=ft({queryKey:["application-logs",l,a],queryFn:()=>eg.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 v=pt({mutationFn:()=>eg.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=T=>{i(D=>{const C=new Set(D);return C.has(T)?C.delete(T):C.add(T),C})},M=T=>{const D=T.split(" ");return D.length>=2?D[1]:T},E=w.useMemo(()=>b?.entries??[],[b?.entries]),A=w.useMemo(()=>[...E].reverse(),[E]),k=({level:T})=>{const D=OQe[T]||Ql;return s.jsx(D,{className:`w-3.5 h-3.5 ${Zj[T]||"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(JM,{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(hu,{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:T=>{T.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(Oo,{className:"w-4 h-4"}),"Stop"]}):s.jsxs("button",{onClick:T=>{T.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(cl,{className:"w-4 h-4"}),"Start"]}),s.jsxs("button",{onClick:()=>v.mutate(),disabled:v.isPending||E.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:y,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 ${y?"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:T=>n(T.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(Ma,{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:T=>o(T.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(Ht,{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"}),mq.map((T,D)=>s.jsx("button",{onClick:()=>c(T),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${D===mq.length-1?"rounded-r":""} ${l===T?`${Zj[T]} bg-bambu-dark-tertiary`:"text-bambu-gray hover:text-white"}`,children:T},T))]})]})]}),s.jsx("div",{ref:p,className:"overflow-auto font-mono text-xs bg-black min-h-[300px] max-h-[500px]",children:E.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((T,D)=>{const C=r.has(D),R=T.message.includes(`
- `);return s.jsx("div",{className:`p-2 cursor-pointer hover:bg-bambu-dark-secondary/50 transition-colors ${C?"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(T.timestamp)}),s.jsx("span",{className:"shrink-0",children:s.jsx(k,{level:T.level})}),s.jsxs("span",{className:"text-purple-400/80 shrink-0 max-w-[200px] truncate",title:T.logger_name,children:["[",T.logger_name,"]"]}),s.jsx("span",{className:`flex-1 ${Zj[T.level]||"text-white/80"} ${!C&&R?"truncate":""}`,children:C?s.jsx("pre",{className:"whitespace-pre-wrap break-all",children:T.message}):T.message.split(`
- `)[0]}),R&&s.jsx("span",{className:"text-bambu-gray/50 shrink-0",children:C?s.jsx(hu,{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 IQe(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 pq({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 md({title:t,icon:e,children:n}){return s.jsxs(Et,{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 FQe(){const{t}=Wg(),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:fe.getSystemInfo,refetchInterval:3e4}),{data:m}=ft({queryKey:["debugLogging"],queryFn:eg.getDebugLoggingState,staleTime:10*1e3,refetchInterval:10*1e3}),{data:p}=ft({queryKey:["settings"],queryFn:fe.getSettings}),{data:b}=ft({queryKey:["library-stats"],queryFn:fe.getLibraryStats}),y=p?.time_format||"system",x=async()=>{l(!0);try{const E=await eg.setDebugLogging(!m?.enabled);e.setQueryData(["debugLogging"],E)}catch(E){console.error("Failed to toggle debug logging:",E)}finally{l(!1)}},v=async()=>{r(null),a(!0);try{await eg.downloadSupportBundle()}catch(E){r(E instanceof Error?E.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(md,{title:t("system.application","Application"),icon:Xh,children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[s.jsx(ei,{icon:Xh,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:Xh,label:t("system.hostname","Hostname"),value:c.system.hostname})]})}),s.jsx(md,{title:t("support.title","Support & Troubleshooting"),icon:_he,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(JM,{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:v,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(LQe,{})]})}),s.jsxs(md,{title:t("system.database","Database"),icon:pg,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:eN,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:UD,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(md,{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(E=>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:E.name})]}),s.jsxs("div",{className:"flex items-center gap-4 text-sm text-bambu-gray",children:[s.jsx("span",{children:E.model}),s.jsx("span",{className:`px-2 py-0.5 rounded ${E.state==="RUNNING"?"bg-bambu-green/20 text-bambu-green":E.state==="IDLE"?"bg-blue-500/20 text-blue-400":"bg-bambu-dark-tertiary"}`,children:E.state})]})]},E.id))}):s.jsx("p",{className:"text-bambu-gray",children:t("system.noPrintersConnected","No printers connected")})]}),s.jsx(md,{title:t("system.storage","Storage"),icon:sN,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(pq,{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:pg,label:t("system.databaseSize","Database Size"),value:c.storage.database_size_formatted}),b&&s.jsx(ei,{icon:ol,label:t("system.fileManagerStorage","File Manager"),value:IQe(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(md,{title:t("system.memory","Memory"),icon:efe,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(pq,{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(md,{title:t("system.cpu","CPU"),icon:m_,children:s.jsx("div",{className:"space-y-4",children:s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsx(ei,{icon:m_,label:t("system.cores","Cores"),value:c.cpu.count,subValue:`${c.cpu.count_logical} logical`}),s.jsx(ei,{icon:m_,label:t("system.usage","Usage"),value:`${c.cpu.percent}%`})]})})})]}),s.jsx(md,{title:t("system.systemDetails","System Details"),icon:Xh,children:s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsx(ei,{icon:Xh,label:t("system.os","Operating System"),value:c.system.platform,subValue:c.system.platform_release}),s.jsx(ei,{icon:m_,label:t("system.architecture","Architecture"),value:c.system.architecture}),s.jsx(ei,{icon:Xh,label:t("system.python","Python"),value:c.system.python_version}),s.jsx(ei,{icon:Jn,label:t("system.bootTime","Boot Time"),value:yg(c.system.boot_time,y)})]})})]})}function UQe(){const t=pl(),{login:e}=ch(),{showToast:n}=Yn(),{mode:r}=lh(),[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 zQe(){const t=pl(),{showToast:e}=Yn(),{mode:n}=lh(),{refreshAuth:r}=ch(),[i,a]=w.useState(!1),[o,l]=w.useState(""),[c,u]=w.useState(""),[d,f]=w.useState(""),m=pt({mutationFn:()=>fe.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(Ql,{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 BQe(){const t=pl(),{user:e}=ch(),{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:()=>fe.getUsers()}),b=pt({mutationFn:A=>fe.createUser(A),onSuccess:()=>{r.invalidateQueries({queryKey:["users"]}),a(!1),f({username:"",password:"",role:"user"}),n("User created successfully")},onError:A=>{n(A.message,"error")}}),y=pt({mutationFn:({id:A,data:k})=>fe.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=>fe.deleteUser(A),onSuccess:()=>{r.invalidateQueries({queryKey:["users"]}),n("User deleted successfully")},onError:A=>{n(A.message,"error")}}),v=()=>{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,y.mutate({id:A,data:k})},M=A=>{u(A)},E=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(Et,{children:s.jsx(Ct,{className:"py-6",children:s.jsxs("div",{className:"flex items-center gap-3 text-red-400",children:[s.jsx(_P,{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(lK,{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(uf,{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(Et,{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:y.isPending,children:[y.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(ys,{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:()=>E(A),children:[s.jsx(uN,{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(Et,{className:"w-full max-w-md",onClick:A=>A.stopPropagation(),children:[s.jsx(Nr,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(uf,{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(Ht,{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:v,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 $Qe(){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`,E=new WebSocket(M);let A=null;E.onopen=()=>{console.log("[WebSocket] Connected"),i(!0),A=window.setInterval(()=>{E.readyState===WebSocket.OPEN&&E.send(JSON.stringify({type:"ping"}))},3e4)},E.onmessage=k=>{try{const T=JSON.parse(k.data);T.type==="printer_status"&&T.printer_id!==void 0&&T.data?f.current(T):(u.current.push(T),m())}catch{}},E.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)},E.onerror=k=>{console.error("[WebSocket] Error",k),E.close()},t.current=E},[m]),b=w.useCallback((S,M)=>{const E=l.current.get(S)||{};l.current.set(S,{...E,...M}),c.current||(c.current=window.setTimeout(()=>{const A=new Map(l.current);l.current.clear(),c.current=null,requestAnimationFrame(()=>{A.forEach((k,T)=>{n.setQueryData(["printerStatus",T],D=>{const C={...D,...k};return C.wifi_signal==null&&D?.wifi_signal!=null&&(C.wifi_signal=D.wifi_signal),C})})})},100))},[n]),y=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 E=0;M.forEach(A=>{setTimeout(()=>{requestAnimationFrame(()=>{n.invalidateQueries({queryKey:[A]})})},E),E+=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":y("archives"),y("archiveStats");break;case"archive_created":y("archives"),y("archiveStats");break;case"archive_updated":y("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,y,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 v=w.useCallback(S=>{t.current?.readyState===WebSocket.OPEN&&t.current.send(JSON.stringify(S))},[]);return{isConnected:r,sendMessage:v}}const HQe=new fue({defaultOptions:{queries:{staleTime:1e3*60,retry:1}}});function VQe({children:t}){return $Qe(),s.jsx(s.Fragment,{children:t})}function GQe({children:t}){const{authEnabled:e,loading:n,user:r}=ch();return n?s.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e&&!r?s.jsx(Tw,{to:"/login",replace:!0}):s.jsx(s.Fragment,{children:t})}function WQe({children:t}){const{authEnabled:e,loading:n,user:r}=ch();return n?s.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e?r?r.role!=="admin"?s.jsx(Tw,{to:"/",replace:!0}):s.jsx(s.Fragment,{children:t}):s.jsx(Tw,{to:"/login",replace:!0}):s.jsx(s.Fragment,{children:t})}function qQe({children:t}){const{authEnabled:e,loading:n}=ch();return n?s.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e?s.jsx(Tw,{to:"/login",replace:!0}):s.jsx(s.Fragment,{children:t})}function KQe(){return s.jsx(Fme,{children:s.jsx(Qme,{children:s.jsx(mue,{client:HQe,children:s.jsx(Hme,{children:s.jsx(Rce,{children:s.jsxs(lce,{children:[s.jsx(Ki,{path:"/setup",element:s.jsx(qQe,{children:s.jsx(zQe,{})})}),s.jsx(Ki,{path:"/login",element:s.jsx(UQe,{})}),s.jsx(Ki,{path:"/camera/:printerId",element:s.jsx(RQe,{})}),s.jsxs(Ki,{element:s.jsx(GQe,{children:s.jsx(VQe,{children:s.jsx(qme,{})})}),children:[s.jsx(Ki,{index:!0,element:s.jsx(QPe,{})}),s.jsx(Ki,{path:"archives",element:s.jsx(AKe,{})}),s.jsx(Ki,{path:"queue",element:s.jsx(hYe,{})}),s.jsx(Ki,{path:"stats",element:s.jsx(EYe,{})}),s.jsx(Ki,{path:"profiles",element:s.jsx(oQe,{})}),s.jsx(Ki,{path:"maintenance",element:s.jsx(hQe,{})}),s.jsx(Ki,{path:"projects",element:s.jsx(mQe,{})}),s.jsx(Ki,{path:"projects/:id",element:s.jsx(_Qe,{})}),s.jsx(Ki,{path:"files",element:s.jsx(CQe,{})}),s.jsx(Ki,{path:"settings",element:s.jsx(WQe,{children:s.jsx(YYe,{})})}),s.jsx(Ki,{path:"users",element:s.jsx(BQe,{})}),s.jsx(Ki,{path:"system",element:s.jsx(FQe,{})}),s.jsx(Ki,{path:"external/:id",element:s.jsx(DQe,{})})]})]})})})})})})}ooe.createRoot(document.getElementById("root")).render(s.jsx(w.StrictMode,{children:s.jsx(KQe,{})}));
|