| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729 |
- function Jse(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 p_=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function pl(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var WA={exports:{}},ob={};var ez;function eoe(){if(ez)return ob;ez=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 ob.Fragment=e,ob.jsx=n,ob.jsxs=n,ob}var tz;function toe(){return tz||(tz=1,WA.exports=eoe()),WA.exports}var s=toe(),qA={exports:{}},gn={};var nz;function noe(){if(nz)return gn;nz=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,G,ne){this.props=z,this.context=G,this.refs=x,this.updater=ne||b}v.prototype.isReactComponent={},v.prototype.setState=function(z,G){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,G,"setState")},v.prototype.forceUpdate=function(z){this.updater.enqueueForceUpdate(this,z,"forceUpdate")};function S(){}S.prototype=v.prototype;function M(z,G,ne){this.props=z,this.context=G,this.refs=x,this.updater=ne||b}var A=M.prototype=new S;A.constructor=M,y(A,v.prototype),A.isPureReactComponent=!0;var T=Array.isArray;function k(){}var E={H:null,A:null,T:null,S:null},O=Object.prototype.hasOwnProperty;function C(z,G,ne){var ae=ne.ref;return{$$typeof:t,type:z,key:G,ref:ae!==void 0?ae:null,props:ne}}function D(z,G){return C(z.type,G,z.props)}function U(z){return typeof z=="object"&&z!==null&&z.$$typeof===t}function L(z){var G={"=":"=0",":":"=2"};return"$"+z.replace(/[=:]/g,function(ne){return G[ne]})}var q=/\/+/g;function P(z,G){return typeof z=="object"&&z!==null&&z.key!=null?L(""+z.key):G.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(G){z.status==="pending"&&(z.status="fulfilled",z.value=G)},function(G){z.status==="pending"&&(z.status="rejected",z.reason=G)})),z.status){case"fulfilled":return z.value;case"rejected":throw z.reason}}throw z}function K(z,G,ne,ae,de){var fe=typeof z;(fe==="undefined"||fe==="boolean")&&(z=null);var ie=!1;if(z===null)ie=!0;else switch(fe){case"bigint":case"string":case"number":ie=!0;break;case"object":switch(z.$$typeof){case t:case e:ie=!0;break;case d:return ie=z._init,K(ie(z._payload),G,ne,ae,de)}}if(ie)return de=de(z),ie=ae===""?"."+P(z,0):ae,T(de)?(ne="",ie!=null&&(ne=ie.replace(q,"$&/")+"/"),K(de,G,ne,"",function(Ne){return Ne})):de!=null&&(U(de)&&(de=D(de,ne+(de.key==null||z&&z.key===de.key?"":(""+de.key).replace(q,"$&/")+"/")+ie)),G.push(de)),1;ie=0;var Ae=ae===""?".":ae+":";if(T(z))for(var me=0;me<z.length;me++)ae=z[me],fe=Ae+P(ae,me),ie+=K(ae,G,ne,fe,de);else if(me=p(z),typeof me=="function")for(z=me.call(z),me=0;!(ae=z.next()).done;)ae=ae.value,fe=Ae+P(ae,me++),ie+=K(ae,G,ne,fe,de);else if(fe==="object"){if(typeof z.then=="function")return K(W(z),G,ne,ae,de);throw G=String(z),Error("Objects are not valid as a React child (found: "+(G==="[object Object]"?"object with keys {"+Object.keys(z).join(", ")+"}":G)+"). If you meant to render a collection of children, use an array instead.")}return ie}function V(z,G,ne){if(z==null)return z;var ae=[],de=0;return K(z,ae,"","",function(fe){return G.call(ne,fe,de++)}),ae}function Q(z){if(z._status===-1){var G=z._result;G=G(),G.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=G)}if(z._status===1)return z._result.default;throw z._result}var re=typeof reportError=="function"?reportError:function(z){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var G=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(G))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",z);return}console.error(z)},J={map:V,forEach:function(z,G,ne){V(z,function(){G.apply(this,arguments)},ne)},count:function(z){var G=0;return V(z,function(){G++}),G},toArray:function(z){return V(z,function(G){return G})||[]},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=J,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=E,gn.__COMPILER_RUNTIME={__proto__:null,c:function(z){return E.H.useMemoCache(z)}},gn.cache=function(z){return function(){return z.apply(null,arguments)}},gn.cacheSignal=function(){return null},gn.cloneElement=function(z,G,ne){if(z==null)throw Error("The argument must be a React element, but you passed "+z+".");var ae=y({},z.props),de=z.key;if(G!=null)for(fe in G.key!==void 0&&(de=""+G.key),G)!O.call(G,fe)||fe==="key"||fe==="__self"||fe==="__source"||fe==="ref"&&G.ref===void 0||(ae[fe]=G[fe]);var fe=arguments.length-2;if(fe===1)ae.children=ne;else if(1<fe){for(var ie=Array(fe),Ae=0;Ae<fe;Ae++)ie[Ae]=arguments[Ae+2];ae.children=ie}return C(z.type,de,ae)},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,G,ne){var ae,de={},fe=null;if(G!=null)for(ae in G.key!==void 0&&(fe=""+G.key),G)O.call(G,ae)&&ae!=="key"&&ae!=="__self"&&ae!=="__source"&&(de[ae]=G[ae]);var ie=arguments.length-2;if(ie===1)de.children=ne;else if(1<ie){for(var Ae=Array(ie),me=0;me<ie;me++)Ae[me]=arguments[me+2];de.children=Ae}if(z&&z.defaultProps)for(ae in ie=z.defaultProps,ie)de[ae]===void 0&&(de[ae]=ie[ae]);return C(z,fe,de)},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:Q}},gn.memo=function(z,G){return{$$typeof:u,type:z,compare:G===void 0?null:G}},gn.startTransition=function(z){var G=E.T,ne={};E.T=ne;try{var ae=z(),de=E.S;de!==null&&de(ne,ae),typeof ae=="object"&&ae!==null&&typeof ae.then=="function"&&ae.then(k,re)}catch(fe){re(fe)}finally{G!==null&&ne.types!==null&&(G.types=ne.types),E.T=G}},gn.unstable_useCacheRefresh=function(){return E.H.useCacheRefresh()},gn.use=function(z){return E.H.use(z)},gn.useActionState=function(z,G,ne){return E.H.useActionState(z,G,ne)},gn.useCallback=function(z,G){return E.H.useCallback(z,G)},gn.useContext=function(z){return E.H.useContext(z)},gn.useDebugValue=function(){},gn.useDeferredValue=function(z,G){return E.H.useDeferredValue(z,G)},gn.useEffect=function(z,G){return E.H.useEffect(z,G)},gn.useEffectEvent=function(z){return E.H.useEffectEvent(z)},gn.useId=function(){return E.H.useId()},gn.useImperativeHandle=function(z,G,ne){return E.H.useImperativeHandle(z,G,ne)},gn.useInsertionEffect=function(z,G){return E.H.useInsertionEffect(z,G)},gn.useLayoutEffect=function(z,G){return E.H.useLayoutEffect(z,G)},gn.useMemo=function(z,G){return E.H.useMemo(z,G)},gn.useOptimistic=function(z,G){return E.H.useOptimistic(z,G)},gn.useReducer=function(z,G,ne){return E.H.useReducer(z,G,ne)},gn.useRef=function(z){return E.H.useRef(z)},gn.useState=function(z){return E.H.useState(z)},gn.useSyncExternalStore=function(z,G,ne){return E.H.useSyncExternalStore(z,G,ne)},gn.useTransition=function(){return E.H.useTransition()},gn.version="19.2.3",gn}var rz;function Kg(){return rz||(rz=1,qA.exports=noe()),qA.exports}var w=Kg();const Ur=pl(w),roe=Jse({__proto__:null,default:Ur},[w]);var KA={exports:{}},lb={},XA={exports:{}},YA={};var iz;function ioe(){return iz||(iz=1,(function(t){function e(K,V){var Q=K.length;K.push(V);e:for(;0<Q;){var re=Q-1>>>1,J=K[re];if(0<i(J,V))K[re]=V,K[Q]=J,Q=re;else break e}}function n(K){return K.length===0?null:K[0]}function r(K){if(K.length===0)return null;var V=K[0],Q=K.pop();if(Q!==V){K[0]=Q;e:for(var re=0,J=K.length,z=J>>>1;re<z;){var G=2*(re+1)-1,ne=K[G],ae=G+1,de=K[ae];if(0>i(ne,Q))ae<J&&0>i(de,ne)?(K[re]=de,K[ae]=Q,re=ae):(K[re]=ne,K[G]=Q,re=G);else if(ae<J&&0>i(de,Q))K[re]=de,K[ae]=Q,re=ae;else break e}}return V}function i(K,V){var Q=K.sortIndex-V.sortIndex;return Q!==0?Q:K.id-V.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;t.unstable_now=function(){return a.now()}}else{var o=Date,l=o.now();t.unstable_now=function(){return o.now()-l}}var c=[],u=[],d=1,f=null,m=3,p=!1,b=!1,y=!1,x=!1,v=typeof setTimeout=="function"?setTimeout:null,S=typeof clearTimeout=="function"?clearTimeout:null,M=typeof setImmediate<"u"?setImmediate:null;function A(K){for(var V=n(u);V!==null;){if(V.callback===null)r(u);else if(V.startTime<=K)r(u),V.sortIndex=V.expirationTime,e(c,V);else break;V=n(u)}}function T(K){if(y=!1,A(K),!b)if(n(c)!==null)b=!0,k||(k=!0,L());else{var V=n(u);V!==null&&W(T,V.startTime-K)}}var k=!1,E=-1,O=5,C=-1;function D(){return x?!0:!(t.unstable_now()-C<O)}function U(){if(x=!1,k){var K=t.unstable_now();C=K;var V=!0;try{e:{b=!1,y&&(y=!1,S(E),E=-1),p=!0;var Q=m;try{t:{for(A(K),f=n(c);f!==null&&!(f.expirationTime>K&&D());){var re=f.callback;if(typeof re=="function"){f.callback=null,m=f.priorityLevel;var J=re(f.expirationTime<=K);if(K=t.unstable_now(),typeof J=="function"){f.callback=J,A(K),V=!0;break t}f===n(c)&&r(c),A(K)}else r(c);f=n(c)}if(f!==null)V=!0;else{var z=n(u);z!==null&&W(T,z.startTime-K),V=!1}}break e}finally{f=null,m=Q,p=!1}V=void 0}}finally{V?L():k=!1}}}var L;if(typeof M=="function")L=function(){M(U)};else if(typeof MessageChannel<"u"){var q=new MessageChannel,P=q.port2;q.port1.onmessage=U,L=function(){P.postMessage(null)}}else L=function(){v(U,0)};function W(K,V){E=v(function(){K(t.unstable_now())},V)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(K){K.callback=null},t.unstable_forceFrameRate=function(K){0>K||125<K?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):O=0<K?Math.floor(1e3/K):5},t.unstable_getCurrentPriorityLevel=function(){return m},t.unstable_next=function(K){switch(m){case 1:case 2:case 3:var V=3;break;default:V=m}var Q=m;m=V;try{return K()}finally{m=Q}},t.unstable_requestPaint=function(){x=!0},t.unstable_runWithPriority=function(K,V){switch(K){case 1:case 2:case 3:case 4:case 5:break;default:K=3}var Q=m;m=K;try{return V()}finally{m=Q}},t.unstable_scheduleCallback=function(K,V,Q){var re=t.unstable_now();switch(typeof Q=="object"&&Q!==null?(Q=Q.delay,Q=typeof Q=="number"&&0<Q?re+Q:re):Q=re,K){case 1:var J=-1;break;case 2:J=250;break;case 5:J=1073741823;break;case 4:J=1e4;break;default:J=5e3}return J=Q+J,K={id:d++,callback:V,priorityLevel:K,startTime:Q,expirationTime:J,sortIndex:-1},Q>re?(K.sortIndex=Q,e(u,K),n(c)===null&&K===n(u)&&(y?(S(E),E=-1):y=!0,W(T,Q-re))):(K.sortIndex=J,e(c,K),b||p||(b=!0,k||(k=!0,L()))),K},t.unstable_shouldYield=D,t.unstable_wrapCallback=function(K){var V=m;return function(){var Q=m;m=V;try{return K.apply(this,arguments)}finally{m=Q}}}})(YA)),YA}var az;function aoe(){return az||(az=1,XA.exports=ioe()),XA.exports}var ZA={exports:{}},ja={};var sz;function soe(){if(sz)return ja;sz=1;var t=Kg();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 ja.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,ja.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)},ja.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()}},ja.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))},ja.prefetchDNS=function(c){typeof c=="string"&&r.d.D(c)},ja.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})}},ja.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)},ja.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})}},ja.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)},ja.requestFormReset=function(c){r.d.r(c)},ja.unstable_batchedUpdates=function(c,u){return c(u)},ja.useFormState=function(c,u,d){return o.H.useFormState(c,u,d)},ja.useFormStatus=function(){return o.H.useHostTransitionStatus()},ja.version="19.2.3",ja}var oz;function _q(){if(oz)return ZA.exports;oz=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),ZA.exports=soe(),ZA.exports}var lz;function ooe(){if(lz)return lb;lz=1;var t=aoe(),e=Kg(),n=_q();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 R=_.return;if(R===null)break;var F=R.alternate;if(F===null){if(N=R.return,N!==null){_=N;continue}break}if(R.child===F.child){for(F=R.child;F;){if(F===_)return c(R),h;if(F===N)return c(R),g;F=F.sibling}throw Error(r(188))}if(_.return!==N.return)_=R,N=F;else{for(var Z=!1,pe=R.child;pe;){if(pe===_){Z=!0,_=R,N=F;break}if(pe===N){Z=!0,N=R,_=F;break}pe=pe.sibling}if(!Z){for(pe=F.child;pe;){if(pe===_){Z=!0,_=F,N=R;break}if(pe===N){Z=!0,N=F,_=R;break}pe=pe.sibling}if(!Z)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"),A=Symbol.for("react.forward_ref"),T=Symbol.for("react.suspense"),k=Symbol.for("react.suspense_list"),E=Symbol.for("react.memo"),O=Symbol.for("react.lazy"),C=Symbol.for("react.activity"),D=Symbol.for("react.memo_cache_sentinel"),U=Symbol.iterator;function L(h){return h===null||typeof h!="object"?null:(h=U&&h[U]||h["@@iterator"],typeof h=="function"?h:null)}var q=Symbol.for("react.client.reference");function P(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 T: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 A:var g=h.render;return h=h.displayName,h||(h=g.displayName||g.name||"",h=h!==""?"ForwardRef("+h+")":"ForwardRef"),h;case E:return g=h.displayName||null,g!==null?g:P(h.type)||"Memo";case O:g=h._payload,h=h._init;try{return P(h(g))}catch{}}return null}var W=Array.isArray,K=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,V=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Q={pending:!1,data:null,method:null,action:null},re=[],J=-1;function z(h){return{current:h}}function G(h){0>J||(h.current=re[J],re[J]=null,J--)}function ne(h,g){J++,re[J]=h.current,h.current=g}var ae=z(null),de=z(null),fe=z(null),ie=z(null);function Ae(h,g){switch(ne(fe,g),ne(de,h),ne(ae,null),g.nodeType){case 9:case 11:h=(h=g.documentElement)&&(h=h.namespaceURI)?SU(h):0;break;default:if(h=g.tagName,g=g.namespaceURI)g=SU(g),h=MU(g,h);else switch(h){case"svg":h=1;break;case"math":h=2;break;default:h=0}}G(ae),ne(ae,h)}function me(){G(ae),G(de),G(fe)}function Ne(h){h.memoizedState!==null&&ne(ie,h);var g=ae.current,_=MU(g,h.type);g!==_&&(ne(de,h),ne(ae,_))}function ye(h){de.current===h&&(G(ae),G(de)),ie.current===h&&(G(ie),rb._currentValue=Q)}var le,$e;function H(h){if(le===void 0)try{throw Error()}catch(_){var g=_.stack.trim().match(/\n( *(at )?)/);le=g&&g[1]||"",$e=-1<_.stack.indexOf(`
- at`)?" (<anonymous>)":-1<_.stack.indexOf("@")?"@unknown:0:0":""}return`
- `+le+h+$e}var ee=!1;function X(h,g){if(!h||ee)return"";ee=!0;var _=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var N={DetermineComponentFrameRoot:function(){try{if(g){var vt=function(){throw Error()};if(Object.defineProperty(vt.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(vt,[])}catch(ft){var st=ft}Reflect.construct(h,[],vt)}else{try{vt.call()}catch(ft){st=ft}h.call(vt.prototype)}}else{try{throw Error()}catch(ft){st=ft}(vt=h())&&typeof vt.catch=="function"&&vt.catch(function(){})}}catch(ft){if(ft&&st&&typeof ft.stack=="string")return[ft.stack,st.stack]}return[null,null]}};N.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var R=Object.getOwnPropertyDescriptor(N.DetermineComponentFrameRoot,"name");R&&R.configurable&&Object.defineProperty(N.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var F=N.DetermineComponentFrameRoot(),Z=F[0],pe=F[1];if(Z&&pe){var De=Z.split(`
- `),it=pe.split(`
- `);for(R=N=0;N<De.length&&!De[N].includes("DetermineComponentFrameRoot");)N++;for(;R<it.length&&!it[R].includes("DetermineComponentFrameRoot");)R++;if(N===De.length||R===it.length)for(N=De.length-1,R=it.length-1;1<=N&&0<=R&&De[N]!==it[R];)R--;for(;1<=N&&0<=R;N--,R--)if(De[N]!==it[R]){if(N!==1||R!==1)do if(N--,R--,0>R||De[N]!==it[R]){var xt=`
- `+De[N].replace(" at new "," at ");return h.displayName&&xt.includes("<anonymous>")&&(xt=xt.replace("<anonymous>",h.displayName)),xt}while(1<=N&&0<=R);break}}}finally{ee=!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 X(h.type,!1);case 11:return X(h.type.render,!1);case 1:return X(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,Te=t.unstable_scheduleCallback,Le=t.unstable_cancelCallback,Ee=t.unstable_shouldYield,$=t.unstable_requestPaint,j=t.unstable_now,Y=t.unstable_getCurrentPriorityLevel,ge=t.unstable_ImmediatePriority,we=t.unstable_UserBlockingPriority,ve=t.unstable_NormalPriority,Ze=t.unstable_LowPriority,Ie=t.unstable_IdlePriority,qe=t.log,Je=t.unstable_setDisableYieldValue,Qe=null,oe=null;function te(h){if(typeof qe=="function"&&Je(h),oe&&typeof oe.setStrictMode=="function")try{oe.setStrictMode(Qe,h)}catch{}}var Me=Math.clz32?Math.clz32:se,Fe=Math.log,ot=Math.LN2;function se(h){return h>>>=0,h===0?32:31-(Fe(h)/ot|0)|0}var je=256,xe=262144,Oe=4194304;function Ue(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 Ce(h,g,_){var N=h.pendingLanes;if(N===0)return 0;var R=0,F=h.suspendedLanes,Z=h.pingedLanes;h=h.warmLanes;var pe=N&134217727;return pe!==0?(N=pe&~F,N!==0?R=Ue(N):(Z&=pe,Z!==0?R=Ue(Z):_||(_=pe&~h,_!==0&&(R=Ue(_))))):(pe=N&~F,pe!==0?R=Ue(pe):Z!==0?R=Ue(Z):_||(_=N&~h,_!==0&&(R=Ue(_)))),R===0?0:g!==0&&g!==R&&(g&F)===0&&(F=R&-R,_=g&-g,F>=_||F===32&&(_&4194048)!==0)?g:R}function We(h,g){return(h.pendingLanes&~(h.suspendedLanes&~h.pingedLanes)&g)===0}function pt(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 kt(){var h=Oe;return Oe<<=1,(Oe&62914560)===0&&(Oe=4194304),h}function Lt(h){for(var g=[],_=0;31>_;_++)g.push(h);return g}function ln(h,g){h.pendingLanes|=g,g!==268435456&&(h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0)}function Gt(h,g,_,N,R,F){var Z=h.pendingLanes;h.pendingLanes=_,h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0,h.expiredLanes&=_,h.entangledLanes&=_,h.errorRecoveryDisabledLanes&=_,h.shellSuspendCounter=0;var pe=h.entanglements,De=h.expirationTimes,it=h.hiddenUpdates;for(_=Z&~_;0<_;){var xt=31-Me(_),vt=1<<xt;pe[xt]=0,De[xt]=-1;var st=it[xt];if(st!==null)for(it[xt]=null,xt=0;xt<st.length;xt++){var ft=st[xt];ft!==null&&(ft.lane&=-536870913)}_&=~vt}N!==0&&_n(h,N,0),F!==0&&R===0&&h.tag!==0&&(h.suspendedLanes|=F&~(Z&~g))}function _n(h,g,_){h.pendingLanes|=g,h.suspendedLanes&=~g;var N=31-Me(g);h.entangledLanes|=g,h.entanglements[N]=h.entanglements[N]|1073741824|_&261930}function gt(h,g){var _=h.entangledLanes|=g;for(h=h.entanglements;_;){var N=31-Me(_),R=1<<N;R&g|h[N]&g&&(h[N]|=g),_&=~R}}function Kt(h,g){var _=g&-g;return _=(_&42)!==0?1:bn(_),(_&(h.suspendedLanes|g))!==0?0:_}function bn(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 At(h){return h&=-h,2<h?8<h?(h&134217727)!==0?32:268435456:8:2}function Pr(){var h=V.p;return h!==0?h:(h=window.event,h===void 0?32:qU(h.type))}function yr(h,g){var _=V.p;try{return V.p=h,g()}finally{V.p=_}}var jn=Math.random().toString(36).slice(2),sn="__reactFiber$"+jn,Rr="__reactProps$"+jn,Gr="__reactContainer$"+jn,Dr="__reactEvents$"+jn,_e="__reactListeners$"+jn,Ve="__reactHandles$"+jn,at="__reactResources$"+jn,ct="__reactMarker$"+jn;function rt(h){delete h[sn],delete h[Rr],delete h[Dr],delete h[_e],delete h[Ve]}function jt(h){var g=h[sn];if(g)return g;for(var _=h.parentNode;_;){if(g=_[Gr]||_[sn]){if(_=g.alternate,g.child!==null||_!==null&&_.child!==null)for(h=jU(h);h!==null;){if(_=h[sn])return _;h=jU(h)}return g}h=_,_=h.parentNode}return null}function zt(h){if(h=h[sn]||h[Gr]){var g=h.tag;if(g===5||g===6||g===13||g===31||g===26||g===27||g===3)return h}return null}function Xt(h){var g=h.tag;if(g===5||g===26||g===27||g===6)return h.stateNode;throw Error(r(33))}function Yt(h){var g=h[at];return g||(g=h[at]={hoistableStyles:new Map,hoistableScripts:new Map}),g}function ue(h){h[ct]=!0}var Re=new Set,He={};function Xe(h,g){Ge(h,g),Ge(h+"Capture",g)}function Ge(h,g){for(He[h]=g,h=0;h<g.length;h++)Re.add(g[h])}var ht=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]*$"),Pt={},_t={};function yt(h){return ce.call(_t,h)?!0:ce.call(Pt,h)?!1:ht.test(h)?_t[h]=!0:(Pt[h]=!0,!1)}function It(h,g,_){if(yt(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 Ot(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 Ft(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 be(h){switch(typeof h){case"bigint":case"boolean":case"number":case"string":case"undefined":return h;case"object":return h;default:return""}}function Pe(h){var g=h.type;return(h=h.nodeName)&&h.toLowerCase()==="input"&&(g==="checkbox"||g==="radio")}function wt(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 R=N.get,F=N.set;return Object.defineProperty(h,g,{configurable:!0,get:function(){return R.call(this)},set:function(Z){_=""+Z,F.call(this,Z)}}),Object.defineProperty(h,g,{enumerable:N.enumerable}),{getValue:function(){return _},setValue:function(Z){_=""+Z},stopTracking:function(){h._valueTracker=null,delete h[g]}}}}function Mt(h){if(!h._valueTracker){var g=Pe(h)?"checked":"value";h._valueTracker=wt(h,g,""+h[g])}}function lt(h){if(!h)return!1;var g=h._valueTracker;if(!g)return!0;var _=g.getValue(),N="";return h&&(N=Pe(h)?h.checked?"true":"false":h.value),h=N,h!==_?(g.setValue(h),!0):!1}function Tt(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 Rt=/[\n"\\]/g;function $t(h){return h.replace(Rt,function(g){return"\\"+g.charCodeAt(0).toString(16)+" "})}function Ln(h,g,_,N,R,F,Z,pe){h.name="",Z!=null&&typeof Z!="function"&&typeof Z!="symbol"&&typeof Z!="boolean"?h.type=Z:h.removeAttribute("type"),g!=null?Z==="number"?(g===0&&h.value===""||h.value!=g)&&(h.value=""+be(g)):h.value!==""+be(g)&&(h.value=""+be(g)):Z!=="submit"&&Z!=="reset"||h.removeAttribute("value"),g!=null?Qt(h,Z,be(g)):_!=null?Qt(h,Z,be(_)):N!=null&&h.removeAttribute("value"),R==null&&F!=null&&(h.defaultChecked=!!F),R!=null&&(h.checked=R&&typeof R!="function"&&typeof R!="symbol"),pe!=null&&typeof pe!="function"&&typeof pe!="symbol"&&typeof pe!="boolean"?h.name=""+be(pe):h.removeAttribute("name")}function bi(h,g,_,N,R,F,Z,pe){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)){Mt(h);return}_=_!=null?""+be(_):"",g=g!=null?""+be(g):_,pe||g===h.value||(h.value=g),h.defaultValue=g}N=N??R,N=typeof N!="function"&&typeof N!="symbol"&&!!N,h.checked=pe?h.checked:!!N,h.defaultChecked=!!N,Z!=null&&typeof Z!="function"&&typeof Z!="symbol"&&typeof Z!="boolean"&&(h.name=Z),Mt(h)}function Qt(h,g,_){g==="number"&&Tt(h.ownerDocument)===h||h.defaultValue===""+_||(h.defaultValue=""+_)}function cn(h,g,_,N){if(h=h.options,g){g={};for(var R=0;R<_.length;R++)g["$"+_[R]]=!0;for(_=0;_<h.length;_++)R=g.hasOwnProperty("$"+h[_].value),h[_].selected!==R&&(h[_].selected=R),R&&N&&(h[_].defaultSelected=!0)}else{for(_=""+be(_),g=null,R=0;R<h.length;R++){if(h[R].value===_){h[R].selected=!0,N&&(h[R].defaultSelected=!0);return}g!==null||h[R].disabled||(g=h[R])}g!==null&&(g.selected=!0)}}function An(h,g,_){if(g!=null&&(g=""+be(g),g!==h.value&&(h.value=g),_==null)){h.defaultValue!==g&&(h.defaultValue=g);return}h.defaultValue=_!=null?""+be(_):""}function Or(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=_}_=be(g),h.defaultValue=_,N=h.textContent,N===_&&N!==""&&N!==null&&(h.value=N),Mt(h)}function Lr(h,g){if(g){var _=h.firstChild;if(_&&_===h.lastChild&&_.nodeType===3){_.nodeValue=g;return}}h.textContent=g}var di=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 hi(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||di.has(g)?g==="float"?h.cssFloat=_:h[g]=(""+_).trim():h[g]=_+"px"}function cs(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 R in g)N=g[R],g.hasOwnProperty(R)&&_[R]!==N&&hi(h,R,N)}else for(var F in g)g.hasOwnProperty(F)&&hi(h,F,g[F])}function Er(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 mc=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"]]),Mh=/^[\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 Gi(h){return Mh.test(""+h)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":h}function pc(){}var HE=null;function VE(h){return h=h.target||h.srcElement||window,h.correspondingUseElement&&(h=h.correspondingUseElement),h.nodeType===3?h.parentNode:h}var _m=null,wm=null;function wI(h){var g=zt(h);if(g&&(h=g.stateNode)){var _=h[Rr]||null;e:switch(h=g.stateNode,g.type){case"input":if(Ln(h,_.value,_.defaultValue,_.defaultValue,_.checked,_.defaultChecked,_.type,_.name),g=_.name,_.type==="radio"&&g!=null){for(_=h;_.parentNode;)_=_.parentNode;for(_=_.querySelectorAll('input[name="'+$t(""+g)+'"][type="radio"]'),g=0;g<_.length;g++){var N=_[g];if(N!==h&&N.form===h.form){var R=N[Rr]||null;if(!R)throw Error(r(90));Ln(N,R.value,R.defaultValue,R.defaultValue,R.checked,R.defaultChecked,R.type,R.name)}}for(g=0;g<_.length;g++)N=_[g],N.form===h.form&<(N)}break e;case"textarea":An(h,_.value,_.defaultValue);break e;case"select":g=_.value,g!=null&&cn(h,!!_.multiple,g,!1)}}}var GE=!1;function SI(h,g,_){if(GE)return h(g,_);GE=!0;try{var N=h(g);return N}finally{if(GE=!1,(_m!==null||wm!==null)&&(qv(),_m&&(g=_m,h=wm,wm=_m=null,wI(g),h)))for(g=0;g<h.length;g++)wI(h[g])}}function vx(h,g){var _=h.stateNode;if(_===null)return null;var N=_[Rr]||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 gc=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),WE=!1;if(gc)try{var _x={};Object.defineProperty(_x,"passive",{get:function(){WE=!0}}),window.addEventListener("test",_x,_x),window.removeEventListener("test",_x,_x)}catch{WE=!1}var Ru=null,qE=null,ov=null;function MI(){if(ov)return ov;var h,g=qE,_=g.length,N,R="value"in Ru?Ru.value:Ru.textContent,F=R.length;for(h=0;h<_&&g[h]===R[h];h++);var Z=_-h;for(N=1;N<=Z&&g[_-N]===R[F-N];N++);return ov=R.slice(h,1<N?1-N:void 0)}function lv(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 cv(){return!0}function NI(){return!1}function us(h){function g(_,N,R,F,Z){this._reactName=_,this._targetInst=R,this.type=N,this.nativeEvent=F,this.target=Z,this.currentTarget=null;for(var pe in h)h.hasOwnProperty(pe)&&(_=h[pe],this[pe]=_?_(F):F[pe]);return this.isDefaultPrevented=(F.defaultPrevented!=null?F.defaultPrevented:F.returnValue===!1)?cv:NI,this.isPropagationStopped=NI,this}return f(g.prototype,{preventDefault:function(){this.defaultPrevented=!0;var _=this.nativeEvent;_&&(_.preventDefault?_.preventDefault():typeof _.returnValue!="unknown"&&(_.returnValue=!1),this.isDefaultPrevented=cv)},stopPropagation:function(){var _=this.nativeEvent;_&&(_.stopPropagation?_.stopPropagation():typeof _.cancelBubble!="unknown"&&(_.cancelBubble=!0),this.isPropagationStopped=cv)},persist:function(){},isPersistent:cv}),g}var Nh={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(h){return h.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},uv=us(Nh),wx=f({},Nh,{view:0,detail:0}),Zie=us(wx),KE,XE,Sx,dv=f({},wx,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:ZE,button:0,buttons:0,relatedTarget:function(h){return h.relatedTarget===void 0?h.fromElement===h.srcElement?h.toElement:h.fromElement:h.relatedTarget},movementX:function(h){return"movementX"in h?h.movementX:(h!==Sx&&(Sx&&h.type==="mousemove"?(KE=h.screenX-Sx.screenX,XE=h.screenY-Sx.screenY):XE=KE=0,Sx=h),KE)},movementY:function(h){return"movementY"in h?h.movementY:XE}}),EI=us(dv),Qie=f({},dv,{dataTransfer:0}),Jie=us(Qie),eae=f({},wx,{relatedTarget:0}),YE=us(eae),tae=f({},Nh,{animationName:0,elapsedTime:0,pseudoElement:0}),nae=us(tae),rae=f({},Nh,{clipboardData:function(h){return"clipboardData"in h?h.clipboardData:window.clipboardData}}),iae=us(rae),aae=f({},Nh,{data:0}),AI=us(aae),sae={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},oae={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"},lae={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function cae(h){var g=this.nativeEvent;return g.getModifierState?g.getModifierState(h):(h=lae[h])?!!g[h]:!1}function ZE(){return cae}var uae=f({},wx,{key:function(h){if(h.key){var g=sae[h.key]||h.key;if(g!=="Unidentified")return g}return h.type==="keypress"?(h=lv(h),h===13?"Enter":String.fromCharCode(h)):h.type==="keydown"||h.type==="keyup"?oae[h.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:ZE,charCode:function(h){return h.type==="keypress"?lv(h):0},keyCode:function(h){return h.type==="keydown"||h.type==="keyup"?h.keyCode:0},which:function(h){return h.type==="keypress"?lv(h):h.type==="keydown"||h.type==="keyup"?h.keyCode:0}}),dae=us(uae),hae=f({},dv,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),TI=us(hae),fae=f({},wx,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:ZE}),mae=us(fae),pae=f({},Nh,{propertyName:0,elapsedTime:0,pseudoElement:0}),gae=us(pae),xae=f({},dv,{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}),bae=us(xae),yae=f({},Nh,{newState:0,oldState:0}),vae=us(yae),_ae=[9,13,27,32],QE=gc&&"CompositionEvent"in window,Mx=null;gc&&"documentMode"in document&&(Mx=document.documentMode);var wae=gc&&"TextEvent"in window&&!Mx,CI=gc&&(!QE||Mx&&8<Mx&&11>=Mx),kI=" ",jI=!1;function PI(h,g){switch(h){case"keyup":return _ae.indexOf(g.keyCode)!==-1;case"keydown":return g.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function RI(h){return h=h.detail,typeof h=="object"&&"data"in h?h.data:null}var Sm=!1;function Sae(h,g){switch(h){case"compositionend":return RI(g);case"keypress":return g.which!==32?null:(jI=!0,kI);case"textInput":return h=g.data,h===kI&&jI?null:h;default:return null}}function Mae(h,g){if(Sm)return h==="compositionend"||!QE&&PI(h,g)?(h=MI(),ov=qE=Ru=null,Sm=!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 CI&&g.locale!=="ko"?null:g.data;default:return null}}var Nae={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 DI(h){var g=h&&h.nodeName&&h.nodeName.toLowerCase();return g==="input"?!!Nae[h.type]:g==="textarea"}function OI(h,g,_,N){_m?wm?wm.push(N):wm=[N]:_m=N,g=e_(g,"onChange"),0<g.length&&(_=new uv("onChange","change",null,_,N),h.push({event:_,listeners:g}))}var Nx=null,Ex=null;function Eae(h){xU(h,0)}function hv(h){var g=Xt(h);if(lt(g))return h}function LI(h,g){if(h==="change")return g}var II=!1;if(gc){var JE;if(gc){var e2="oninput"in document;if(!e2){var FI=document.createElement("div");FI.setAttribute("oninput","return;"),e2=typeof FI.oninput=="function"}JE=e2}else JE=!1;II=JE&&(!document.documentMode||9<document.documentMode)}function UI(){Nx&&(Nx.detachEvent("onpropertychange",zI),Ex=Nx=null)}function zI(h){if(h.propertyName==="value"&&hv(Ex)){var g=[];OI(g,Ex,h,VE(h)),SI(Eae,g)}}function Aae(h,g,_){h==="focusin"?(UI(),Nx=g,Ex=_,Nx.attachEvent("onpropertychange",zI)):h==="focusout"&&UI()}function Tae(h){if(h==="selectionchange"||h==="keyup"||h==="keydown")return hv(Ex)}function Cae(h,g){if(h==="click")return hv(g)}function kae(h,g){if(h==="input"||h==="change")return hv(g)}function jae(h,g){return h===g&&(h!==0||1/h===1/g)||h!==h&&g!==g}var js=typeof Object.is=="function"?Object.is:jae;function Ax(h,g){if(js(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 R=_[N];if(!ce.call(g,R)||!js(h[R],g[R]))return!1}return!0}function BI(h){for(;h&&h.firstChild;)h=h.firstChild;return h}function $I(h,g){var _=BI(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}_=BI(_)}}function HI(h,g){return h&&g?h===g?!0:h&&h.nodeType===3?!1:g&&g.nodeType===3?HI(h,g.parentNode):"contains"in h?h.contains(g):h.compareDocumentPosition?!!(h.compareDocumentPosition(g)&16):!1:!1}function VI(h){h=h!=null&&h.ownerDocument!=null&&h.ownerDocument.defaultView!=null?h.ownerDocument.defaultView:window;for(var g=Tt(h.document);g instanceof h.HTMLIFrameElement;){try{var _=typeof g.contentWindow.location.href=="string"}catch{_=!1}if(_)h=g.contentWindow;else break;g=Tt(h.document)}return g}function t2(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 Pae=gc&&"documentMode"in document&&11>=document.documentMode,Mm=null,n2=null,Tx=null,r2=!1;function GI(h,g,_){var N=_.window===_?_.document:_.nodeType===9?_:_.ownerDocument;r2||Mm==null||Mm!==Tt(N)||(N=Mm,"selectionStart"in N&&t2(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}),Tx&&Ax(Tx,N)||(Tx=N,N=e_(n2,"onSelect"),0<N.length&&(g=new uv("onSelect","select",null,g,_),h.push({event:g,listeners:N}),g.target=Mm)))}function Eh(h,g){var _={};return _[h.toLowerCase()]=g.toLowerCase(),_["Webkit"+h]="webkit"+g,_["Moz"+h]="moz"+g,_}var Nm={animationend:Eh("Animation","AnimationEnd"),animationiteration:Eh("Animation","AnimationIteration"),animationstart:Eh("Animation","AnimationStart"),transitionrun:Eh("Transition","TransitionRun"),transitionstart:Eh("Transition","TransitionStart"),transitioncancel:Eh("Transition","TransitionCancel"),transitionend:Eh("Transition","TransitionEnd")},i2={},WI={};gc&&(WI=document.createElement("div").style,"AnimationEvent"in window||(delete Nm.animationend.animation,delete Nm.animationiteration.animation,delete Nm.animationstart.animation),"TransitionEvent"in window||delete Nm.transitionend.transition);function Ah(h){if(i2[h])return i2[h];if(!Nm[h])return h;var g=Nm[h],_;for(_ in g)if(g.hasOwnProperty(_)&&_ in WI)return i2[h]=g[_];return h}var qI=Ah("animationend"),KI=Ah("animationiteration"),XI=Ah("animationstart"),Rae=Ah("transitionrun"),Dae=Ah("transitionstart"),Oae=Ah("transitioncancel"),YI=Ah("transitionend"),ZI=new Map,a2="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(" ");a2.push("scrollEnd");function Ho(h,g){ZI.set(h,g),Xe(g,[h])}var fv=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)},ro=[],Em=0,s2=0;function mv(){for(var h=Em,g=s2=Em=0;g<h;){var _=ro[g];ro[g++]=null;var N=ro[g];ro[g++]=null;var R=ro[g];ro[g++]=null;var F=ro[g];if(ro[g++]=null,N!==null&&R!==null){var Z=N.pending;Z===null?R.next=R:(R.next=Z.next,Z.next=R),N.pending=R}F!==0&&QI(_,R,F)}}function pv(h,g,_,N){ro[Em++]=h,ro[Em++]=g,ro[Em++]=_,ro[Em++]=N,s2|=N,h.lanes|=N,h=h.alternate,h!==null&&(h.lanes|=N)}function o2(h,g,_,N){return pv(h,g,_,N),gv(h)}function Th(h,g){return pv(h,null,null,g),gv(h)}function QI(h,g,_){h.lanes|=_;var N=h.alternate;N!==null&&(N.lanes|=_);for(var R=!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||(R=!0)),h=F,F=F.return;return h.tag===3?(F=h.stateNode,R&&g!==null&&(R=31-Me(_),h=F.hiddenUpdates,N=h[R],N===null?h[R]=[g]:N.push(g),g.lane=_|536870912),F):null}function gv(h){if(50<Yx)throw Yx=0,gA=null,Error(r(185));for(var g=h.return;g!==null;)h=g,g=h.return;return h.tag===3?h.stateNode:null}var Am={};function Lae(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 Ps(h,g,_,N){return new Lae(h,g,_,N)}function l2(h){return h=h.prototype,!(!h||!h.isReactComponent)}function xc(h,g){var _=h.alternate;return _===null?(_=Ps(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 JI(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 xv(h,g,_,N,R,F){var Z=0;if(N=h,typeof h=="function")l2(h)&&(Z=1);else if(typeof h=="string")Z=Bse(h,_,ae.current)?26:h==="html"||h==="head"||h==="body"?27:5;else e:switch(h){case C:return h=Ps(31,_,g,R),h.elementType=C,h.lanes=F,h;case y:return Ch(_.children,R,F,g);case x:Z=8,R|=24;break;case v:return h=Ps(12,_,g,R|2),h.elementType=v,h.lanes=F,h;case T:return h=Ps(13,_,g,R),h.elementType=T,h.lanes=F,h;case k:return h=Ps(19,_,g,R),h.elementType=k,h.lanes=F,h;default:if(typeof h=="object"&&h!==null)switch(h.$$typeof){case M:Z=10;break e;case S:Z=9;break e;case A:Z=11;break e;case E:Z=14;break e;case O:Z=16,N=null;break e}Z=29,_=Error(r(130,h===null?"null":typeof h,"")),N=null}return g=Ps(Z,_,g,R),g.elementType=h,g.type=N,g.lanes=F,g}function Ch(h,g,_,N){return h=Ps(7,h,N,g),h.lanes=_,h}function c2(h,g,_){return h=Ps(6,h,null,g),h.lanes=_,h}function eF(h){var g=Ps(18,null,null,0);return g.stateNode=h,g}function u2(h,g,_){return g=Ps(4,h.children!==null?h.children:[],h.key,g),g.lanes=_,g.stateNode={containerInfo:h.containerInfo,pendingChildren:null,implementation:h.implementation},g}var tF=new WeakMap;function io(h,g){if(typeof h=="object"&&h!==null){var _=tF.get(h);return _!==void 0?_:(g={value:h,source:g,stack:I(g)},tF.set(h,g),g)}return{value:h,source:g,stack:I(g)}}var Tm=[],Cm=0,bv=null,Cx=0,ao=[],so=0,Du=null,_l=1,wl="";function bc(h,g){Tm[Cm++]=Cx,Tm[Cm++]=bv,bv=h,Cx=g}function nF(h,g,_){ao[so++]=_l,ao[so++]=wl,ao[so++]=Du,Du=h;var N=_l;h=wl;var R=32-Me(N)-1;N&=~(1<<R),_+=1;var F=32-Me(g)+R;if(30<F){var Z=R-R%5;F=(N&(1<<Z)-1).toString(32),N>>=Z,R-=Z,_l=1<<32-Me(g)+R|_<<R|N,wl=F+h}else _l=1<<F|_<<R|N,wl=h}function d2(h){h.return!==null&&(bc(h,1),nF(h,1,0))}function h2(h){for(;h===bv;)bv=Tm[--Cm],Tm[Cm]=null,Cx=Tm[--Cm],Tm[Cm]=null;for(;h===Du;)Du=ao[--so],ao[so]=null,wl=ao[--so],ao[so]=null,_l=ao[--so],ao[so]=null}function rF(h,g){ao[so++]=_l,ao[so++]=wl,ao[so++]=Du,_l=g.id,wl=g.overflow,Du=h}var da=null,Ar=null,zn=!1,Ou=null,oo=!1,f2=Error(r(519));function Lu(h){var g=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw kx(io(g,h)),f2}function iF(h){var g=h.stateNode,_=h.type,N=h.memoizedProps;switch(g[sn]=h,g[Rr]=N,_){case"dialog":Rn("cancel",g),Rn("close",g);break;case"iframe":case"object":case"embed":Rn("load",g);break;case"video":case"audio":for(_=0;_<Qx.length;_++)Rn(Qx[_],g);break;case"source":Rn("error",g);break;case"img":case"image":case"link":Rn("error",g),Rn("load",g);break;case"details":Rn("toggle",g);break;case"input":Rn("invalid",g),bi(g,N.value,N.defaultValue,N.checked,N.defaultChecked,N.type,N.name,!0);break;case"select":Rn("invalid",g);break;case"textarea":Rn("invalid",g),Or(g,N.value,N.defaultValue,N.children)}_=N.children,typeof _!="string"&&typeof _!="number"&&typeof _!="bigint"||g.textContent===""+_||N.suppressHydrationWarning===!0||_U(g.textContent,_)?(N.popover!=null&&(Rn("beforetoggle",g),Rn("toggle",g)),N.onScroll!=null&&Rn("scroll",g),N.onScrollEnd!=null&&Rn("scrollend",g),N.onClick!=null&&(g.onclick=pc),g=!0):g=!1,g||Lu(h,!0)}function aF(h){for(da=h.return;da;)switch(da.tag){case 5:case 31:case 13:oo=!1;return;case 27:case 3:oo=!0;return;default:da=da.return}}function km(h){if(h!==da)return!1;if(!zn)return aF(h),zn=!0,!1;var g=h.tag,_;if((_=g!==3&&g!==27)&&((_=g===5)&&(_=h.type,_=!(_!=="form"&&_!=="button")||jA(h.type,h.memoizedProps)),_=!_),_&&Ar&&Lu(h),aF(h),g===13){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));Ar=kU(h)}else if(g===31){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));Ar=kU(h)}else g===27?(g=Ar,Yu(h.type)?(h=LA,LA=null,Ar=h):Ar=g):Ar=da?co(h.stateNode.nextSibling):null;return!0}function kh(){Ar=da=null,zn=!1}function m2(){var h=Ou;return h!==null&&(ms===null?ms=h:ms.push.apply(ms,h),Ou=null),h}function kx(h){Ou===null?Ou=[h]:Ou.push(h)}var p2=z(null),jh=null,yc=null;function Iu(h,g,_){ne(p2,g._currentValue),g._currentValue=_}function vc(h){h._currentValue=p2.current,G(p2)}function g2(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 x2(h,g,_,N){var R=h.child;for(R!==null&&(R.return=h);R!==null;){var F=R.dependencies;if(F!==null){var Z=R.child;F=F.firstContext;e:for(;F!==null;){var pe=F;F=R;for(var De=0;De<g.length;De++)if(pe.context===g[De]){F.lanes|=_,pe=F.alternate,pe!==null&&(pe.lanes|=_),g2(F.return,_,h),N||(Z=null);break e}F=pe.next}}else if(R.tag===18){if(Z=R.return,Z===null)throw Error(r(341));Z.lanes|=_,F=Z.alternate,F!==null&&(F.lanes|=_),g2(Z,_,h),Z=null}else Z=R.child;if(Z!==null)Z.return=R;else for(Z=R;Z!==null;){if(Z===h){Z=null;break}if(R=Z.sibling,R!==null){R.return=Z.return,Z=R;break}Z=Z.return}R=Z}}function jm(h,g,_,N){h=null;for(var R=g,F=!1;R!==null;){if(!F){if((R.flags&524288)!==0)F=!0;else if((R.flags&262144)!==0)break}if(R.tag===10){var Z=R.alternate;if(Z===null)throw Error(r(387));if(Z=Z.memoizedProps,Z!==null){var pe=R.type;js(R.pendingProps.value,Z.value)||(h!==null?h.push(pe):h=[pe])}}else if(R===ie.current){if(Z=R.alternate,Z===null)throw Error(r(387));Z.memoizedState.memoizedState!==R.memoizedState.memoizedState&&(h!==null?h.push(rb):h=[rb])}R=R.return}h!==null&&x2(g,h,_,N),g.flags|=262144}function yv(h){for(h=h.firstContext;h!==null;){if(!js(h.context._currentValue,h.memoizedValue))return!0;h=h.next}return!1}function Ph(h){jh=h,yc=null,h=h.dependencies,h!==null&&(h.firstContext=null)}function ha(h){return sF(jh,h)}function vv(h,g){return jh===null&&Ph(h),sF(h,g)}function sF(h,g){var _=g._currentValue;if(g={context:g,memoizedValue:_,next:null},yc===null){if(h===null)throw Error(r(308));yc=g,h.dependencies={lanes:0,firstContext:g},h.flags|=524288}else yc=yc.next=g;return _}var Iae=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 _()})}},Fae=t.unstable_scheduleCallback,Uae=t.unstable_NormalPriority,yi={$$typeof:M,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function b2(){return{controller:new Iae,data:new Map,refCount:0}}function jx(h){h.refCount--,h.refCount===0&&Fae(Uae,function(){h.controller.abort()})}var Px=null,y2=0,Pm=0,Rm=null;function zae(h,g){if(Px===null){var _=Px=[];y2=0,Pm=wA(),Rm={status:"pending",value:void 0,then:function(N){_.push(N)}}}return y2++,g.then(oF,oF),g}function oF(){if(--y2===0&&Px!==null){Rm!==null&&(Rm.status="fulfilled");var h=Px;Px=null,Pm=0,Rm=null;for(var g=0;g<h.length;g++)(0,h[g])()}}function Bae(h,g){var _=[],N={status:"pending",value:null,reason:null,then:function(R){_.push(R)}};return h.then(function(){N.status="fulfilled",N.value=g;for(var R=0;R<_.length;R++)(0,_[R])(g)},function(R){for(N.status="rejected",N.reason=R,R=0;R<_.length;R++)(0,_[R])(void 0)}),N}var lF=K.S;K.S=function(h,g){G5=j(),typeof g=="object"&&g!==null&&typeof g.then=="function"&&zae(h,g),lF!==null&&lF(h,g)};var Rh=z(null);function v2(){var h=Rh.current;return h!==null?h:vr.pooledCache}function _v(h,g){g===null?ne(Rh,Rh.current):ne(Rh,g.pool)}function cF(){var h=v2();return h===null?null:{parent:yi._currentValue,pool:h}}var Dm=Error(r(460)),_2=Error(r(474)),wv=Error(r(542)),Sv={then:function(){}};function uF(h){return h=h.status,h==="fulfilled"||h==="rejected"}function dF(h,g,_){switch(_=h[_],_===void 0?h.push(g):_!==g&&(g.then(pc,pc),g=_),g.status){case"fulfilled":return g.value;case"rejected":throw h=g.reason,fF(h),h;default:if(typeof g.status=="string")g.then(pc,pc);else{if(h=vr,h!==null&&100<h.shellSuspendCounter)throw Error(r(482));h=g,h.status="pending",h.then(function(N){if(g.status==="pending"){var R=g;R.status="fulfilled",R.value=N}},function(N){if(g.status==="pending"){var R=g;R.status="rejected",R.reason=N}})}switch(g.status){case"fulfilled":return g.value;case"rejected":throw h=g.reason,fF(h),h}throw Oh=g,Dm}}function Dh(h){try{var g=h._init;return g(h._payload)}catch(_){throw _!==null&&typeof _=="object"&&typeof _.then=="function"?(Oh=_,Dm):_}}var Oh=null;function hF(){if(Oh===null)throw Error(r(459));var h=Oh;return Oh=null,h}function fF(h){if(h===Dm||h===wv)throw Error(r(483))}var Om=null,Rx=0;function Mv(h){var g=Rx;return Rx+=1,Om===null&&(Om=[]),dF(Om,h,g)}function Dx(h,g){g=g.props.ref,h.ref=g!==void 0?g:null}function Nv(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 mF(h){function g(Ye,ze){if(h){var nt=Ye.deletions;nt===null?(Ye.deletions=[ze],Ye.flags|=16):nt.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 R(Ye,ze){return Ye=xc(Ye,ze),Ye.index=0,Ye.sibling=null,Ye}function F(Ye,ze,nt){return Ye.index=nt,h?(nt=Ye.alternate,nt!==null?(nt=nt.index,nt<ze?(Ye.flags|=67108866,ze):nt):(Ye.flags|=67108866,ze)):(Ye.flags|=1048576,ze)}function Z(Ye){return h&&Ye.alternate===null&&(Ye.flags|=67108866),Ye}function pe(Ye,ze,nt,bt){return ze===null||ze.tag!==6?(ze=c2(nt,Ye.mode,bt),ze.return=Ye,ze):(ze=R(ze,nt),ze.return=Ye,ze)}function De(Ye,ze,nt,bt){var tn=nt.type;return tn===y?xt(Ye,ze,nt.props.children,bt,nt.key):ze!==null&&(ze.elementType===tn||typeof tn=="object"&&tn!==null&&tn.$$typeof===O&&Dh(tn)===ze.type)?(ze=R(ze,nt.props),Dx(ze,nt),ze.return=Ye,ze):(ze=xv(nt.type,nt.key,nt.props,null,Ye.mode,bt),Dx(ze,nt),ze.return=Ye,ze)}function it(Ye,ze,nt,bt){return ze===null||ze.tag!==4||ze.stateNode.containerInfo!==nt.containerInfo||ze.stateNode.implementation!==nt.implementation?(ze=u2(nt,Ye.mode,bt),ze.return=Ye,ze):(ze=R(ze,nt.children||[]),ze.return=Ye,ze)}function xt(Ye,ze,nt,bt,tn){return ze===null||ze.tag!==7?(ze=Ch(nt,Ye.mode,bt,tn),ze.return=Ye,ze):(ze=R(ze,nt),ze.return=Ye,ze)}function vt(Ye,ze,nt){if(typeof ze=="string"&&ze!==""||typeof ze=="number"||typeof ze=="bigint")return ze=c2(""+ze,Ye.mode,nt),ze.return=Ye,ze;if(typeof ze=="object"&&ze!==null){switch(ze.$$typeof){case p:return nt=xv(ze.type,ze.key,ze.props,null,Ye.mode,nt),Dx(nt,ze),nt.return=Ye,nt;case b:return ze=u2(ze,Ye.mode,nt),ze.return=Ye,ze;case O:return ze=Dh(ze),vt(Ye,ze,nt)}if(W(ze)||L(ze))return ze=Ch(ze,Ye.mode,nt,null),ze.return=Ye,ze;if(typeof ze.then=="function")return vt(Ye,Mv(ze),nt);if(ze.$$typeof===M)return vt(Ye,vv(Ye,ze),nt);Nv(Ye,ze)}return null}function st(Ye,ze,nt,bt){var tn=ze!==null?ze.key:null;if(typeof nt=="string"&&nt!==""||typeof nt=="number"||typeof nt=="bigint")return tn!==null?null:pe(Ye,ze,""+nt,bt);if(typeof nt=="object"&&nt!==null){switch(nt.$$typeof){case p:return nt.key===tn?De(Ye,ze,nt,bt):null;case b:return nt.key===tn?it(Ye,ze,nt,bt):null;case O:return nt=Dh(nt),st(Ye,ze,nt,bt)}if(W(nt)||L(nt))return tn!==null?null:xt(Ye,ze,nt,bt,null);if(typeof nt.then=="function")return st(Ye,ze,Mv(nt),bt);if(nt.$$typeof===M)return st(Ye,ze,vv(Ye,nt),bt);Nv(Ye,nt)}return null}function ft(Ye,ze,nt,bt,tn){if(typeof bt=="string"&&bt!==""||typeof bt=="number"||typeof bt=="bigint")return Ye=Ye.get(nt)||null,pe(ze,Ye,""+bt,tn);if(typeof bt=="object"&&bt!==null){switch(bt.$$typeof){case p:return Ye=Ye.get(bt.key===null?nt:bt.key)||null,De(ze,Ye,bt,tn);case b:return Ye=Ye.get(bt.key===null?nt:bt.key)||null,it(ze,Ye,bt,tn);case O:return bt=Dh(bt),ft(Ye,ze,nt,bt,tn)}if(W(bt)||L(bt))return Ye=Ye.get(nt)||null,xt(ze,Ye,bt,tn,null);if(typeof bt.then=="function")return ft(Ye,ze,nt,Mv(bt),tn);if(bt.$$typeof===M)return ft(Ye,ze,nt,vv(ze,bt),tn);Nv(ze,bt)}return null}function Zt(Ye,ze,nt,bt){for(var tn=null,Kn=null,Jt=ze,vn=ze=0,Fn=null;Jt!==null&&vn<nt.length;vn++){Jt.index>vn?(Fn=Jt,Jt=null):Fn=Jt.sibling;var Xn=st(Ye,Jt,nt[vn],bt);if(Xn===null){Jt===null&&(Jt=Fn);break}h&&Jt&&Xn.alternate===null&&g(Ye,Jt),ze=F(Xn,ze,vn),Kn===null?tn=Xn:Kn.sibling=Xn,Kn=Xn,Jt=Fn}if(vn===nt.length)return _(Ye,Jt),zn&&bc(Ye,vn),tn;if(Jt===null){for(;vn<nt.length;vn++)Jt=vt(Ye,nt[vn],bt),Jt!==null&&(ze=F(Jt,ze,vn),Kn===null?tn=Jt:Kn.sibling=Jt,Kn=Jt);return zn&&bc(Ye,vn),tn}for(Jt=N(Jt);vn<nt.length;vn++)Fn=ft(Jt,Ye,vn,nt[vn],bt),Fn!==null&&(h&&Fn.alternate!==null&&Jt.delete(Fn.key===null?vn:Fn.key),ze=F(Fn,ze,vn),Kn===null?tn=Fn:Kn.sibling=Fn,Kn=Fn);return h&&Jt.forEach(function(td){return g(Ye,td)}),zn&&bc(Ye,vn),tn}function an(Ye,ze,nt,bt){if(nt==null)throw Error(r(151));for(var tn=null,Kn=null,Jt=ze,vn=ze=0,Fn=null,Xn=nt.next();Jt!==null&&!Xn.done;vn++,Xn=nt.next()){Jt.index>vn?(Fn=Jt,Jt=null):Fn=Jt.sibling;var td=st(Ye,Jt,Xn.value,bt);if(td===null){Jt===null&&(Jt=Fn);break}h&&Jt&&td.alternate===null&&g(Ye,Jt),ze=F(td,ze,vn),Kn===null?tn=td:Kn.sibling=td,Kn=td,Jt=Fn}if(Xn.done)return _(Ye,Jt),zn&&bc(Ye,vn),tn;if(Jt===null){for(;!Xn.done;vn++,Xn=nt.next())Xn=vt(Ye,Xn.value,bt),Xn!==null&&(ze=F(Xn,ze,vn),Kn===null?tn=Xn:Kn.sibling=Xn,Kn=Xn);return zn&&bc(Ye,vn),tn}for(Jt=N(Jt);!Xn.done;vn++,Xn=nt.next())Xn=ft(Jt,Ye,vn,Xn.value,bt),Xn!==null&&(h&&Xn.alternate!==null&&Jt.delete(Xn.key===null?vn:Xn.key),ze=F(Xn,ze,vn),Kn===null?tn=Xn:Kn.sibling=Xn,Kn=Xn);return h&&Jt.forEach(function(Qse){return g(Ye,Qse)}),zn&&bc(Ye,vn),tn}function dr(Ye,ze,nt,bt){if(typeof nt=="object"&&nt!==null&&nt.type===y&&nt.key===null&&(nt=nt.props.children),typeof nt=="object"&&nt!==null){switch(nt.$$typeof){case p:e:{for(var tn=nt.key;ze!==null;){if(ze.key===tn){if(tn=nt.type,tn===y){if(ze.tag===7){_(Ye,ze.sibling),bt=R(ze,nt.props.children),bt.return=Ye,Ye=bt;break e}}else if(ze.elementType===tn||typeof tn=="object"&&tn!==null&&tn.$$typeof===O&&Dh(tn)===ze.type){_(Ye,ze.sibling),bt=R(ze,nt.props),Dx(bt,nt),bt.return=Ye,Ye=bt;break e}_(Ye,ze);break}else g(Ye,ze);ze=ze.sibling}nt.type===y?(bt=Ch(nt.props.children,Ye.mode,bt,nt.key),bt.return=Ye,Ye=bt):(bt=xv(nt.type,nt.key,nt.props,null,Ye.mode,bt),Dx(bt,nt),bt.return=Ye,Ye=bt)}return Z(Ye);case b:e:{for(tn=nt.key;ze!==null;){if(ze.key===tn)if(ze.tag===4&&ze.stateNode.containerInfo===nt.containerInfo&&ze.stateNode.implementation===nt.implementation){_(Ye,ze.sibling),bt=R(ze,nt.children||[]),bt.return=Ye,Ye=bt;break e}else{_(Ye,ze);break}else g(Ye,ze);ze=ze.sibling}bt=u2(nt,Ye.mode,bt),bt.return=Ye,Ye=bt}return Z(Ye);case O:return nt=Dh(nt),dr(Ye,ze,nt,bt)}if(W(nt))return Zt(Ye,ze,nt,bt);if(L(nt)){if(tn=L(nt),typeof tn!="function")throw Error(r(150));return nt=tn.call(nt),an(Ye,ze,nt,bt)}if(typeof nt.then=="function")return dr(Ye,ze,Mv(nt),bt);if(nt.$$typeof===M)return dr(Ye,ze,vv(Ye,nt),bt);Nv(Ye,nt)}return typeof nt=="string"&&nt!==""||typeof nt=="number"||typeof nt=="bigint"?(nt=""+nt,ze!==null&&ze.tag===6?(_(Ye,ze.sibling),bt=R(ze,nt),bt.return=Ye,Ye=bt):(_(Ye,ze),bt=c2(nt,Ye.mode,bt),bt.return=Ye,Ye=bt),Z(Ye)):_(Ye,ze)}return function(Ye,ze,nt,bt){try{Rx=0;var tn=dr(Ye,ze,nt,bt);return Om=null,tn}catch(Jt){if(Jt===Dm||Jt===wv)throw Jt;var Kn=Ps(29,Jt,null,Ye.mode);return Kn.lanes=bt,Kn.return=Ye,Kn}}}var Lh=mF(!0),pF=mF(!1),Fu=!1;function w2(h){h.updateQueue={baseState:h.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function S2(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 Uu(h){return{lane:h,tag:0,payload:null,callback:null,next:null}}function zu(h,g,_){var N=h.updateQueue;if(N===null)return null;if(N=N.shared,(Jn&2)!==0){var R=N.pending;return R===null?g.next=g:(g.next=R.next,R.next=g),N.pending=g,g=gv(h),QI(h,null,_),g}return pv(h,N,g,_),gv(h)}function Ox(h,g,_){if(g=g.updateQueue,g!==null&&(g=g.shared,(_&4194048)!==0)){var N=g.lanes;N&=h.pendingLanes,_|=N,g.lanes=_,gt(h,_)}}function M2(h,g){var _=h.updateQueue,N=h.alternate;if(N!==null&&(N=N.updateQueue,_===N)){var R=null,F=null;if(_=_.firstBaseUpdate,_!==null){do{var Z={lane:_.lane,tag:_.tag,payload:_.payload,callback:null,next:null};F===null?R=F=Z:F=F.next=Z,_=_.next}while(_!==null);F===null?R=F=g:F=F.next=g}else R=F=g;_={baseState:N.baseState,firstBaseUpdate:R,lastBaseUpdate:F,shared:N.shared,callbacks:N.callbacks},h.updateQueue=_;return}h=_.lastBaseUpdate,h===null?_.firstBaseUpdate=g:h.next=g,_.lastBaseUpdate=g}var N2=!1;function Lx(){if(N2){var h=Rm;if(h!==null)throw h}}function Ix(h,g,_,N){N2=!1;var R=h.updateQueue;Fu=!1;var F=R.firstBaseUpdate,Z=R.lastBaseUpdate,pe=R.shared.pending;if(pe!==null){R.shared.pending=null;var De=pe,it=De.next;De.next=null,Z===null?F=it:Z.next=it,Z=De;var xt=h.alternate;xt!==null&&(xt=xt.updateQueue,pe=xt.lastBaseUpdate,pe!==Z&&(pe===null?xt.firstBaseUpdate=it:pe.next=it,xt.lastBaseUpdate=De))}if(F!==null){var vt=R.baseState;Z=0,xt=it=De=null,pe=F;do{var st=pe.lane&-536870913,ft=st!==pe.lane;if(ft?(In&st)===st:(N&st)===st){st!==0&&st===Pm&&(N2=!0),xt!==null&&(xt=xt.next={lane:0,tag:pe.tag,payload:pe.payload,callback:null,next:null});e:{var Zt=h,an=pe;st=g;var dr=_;switch(an.tag){case 1:if(Zt=an.payload,typeof Zt=="function"){vt=Zt.call(dr,vt,st);break e}vt=Zt;break e;case 3:Zt.flags=Zt.flags&-65537|128;case 0:if(Zt=an.payload,st=typeof Zt=="function"?Zt.call(dr,vt,st):Zt,st==null)break e;vt=f({},vt,st);break e;case 2:Fu=!0}}st=pe.callback,st!==null&&(h.flags|=64,ft&&(h.flags|=8192),ft=R.callbacks,ft===null?R.callbacks=[st]:ft.push(st))}else ft={lane:st,tag:pe.tag,payload:pe.payload,callback:pe.callback,next:null},xt===null?(it=xt=ft,De=vt):xt=xt.next=ft,Z|=st;if(pe=pe.next,pe===null){if(pe=R.shared.pending,pe===null)break;ft=pe,pe=ft.next,ft.next=null,R.lastBaseUpdate=ft,R.shared.pending=null}}while(!0);xt===null&&(De=vt),R.baseState=De,R.firstBaseUpdate=it,R.lastBaseUpdate=xt,F===null&&(R.shared.lanes=0),Gu|=Z,h.lanes=Z,h.memoizedState=vt}}function gF(h,g){if(typeof h!="function")throw Error(r(191,h));h.call(g)}function xF(h,g){var _=h.callbacks;if(_!==null)for(h.callbacks=null,h=0;h<_.length;h++)gF(_[h],g)}var Lm=z(null),Ev=z(0);function bF(h,g){h=Cc,ne(Ev,h),ne(Lm,g),Cc=h|g.baseLanes}function E2(){ne(Ev,Cc),ne(Lm,Lm.current)}function A2(){Cc=Ev.current,G(Lm),G(Ev)}var Rs=z(null),lo=null;function Bu(h){var g=h.alternate;ne(fi,fi.current&1),ne(Rs,h),lo===null&&(g===null||Lm.current!==null||g.memoizedState!==null)&&(lo=h)}function T2(h){ne(fi,fi.current),ne(Rs,h),lo===null&&(lo=h)}function yF(h){h.tag===22?(ne(fi,fi.current),ne(Rs,h),lo===null&&(lo=h)):$u()}function $u(){ne(fi,fi.current),ne(Rs,Rs.current)}function Ds(h){G(Rs),lo===h&&(lo=null),G(fi)}var fi=z(0);function Av(h){for(var g=h;g!==null;){if(g.tag===13){var _=g.memoizedState;if(_!==null&&(_=_.dehydrated,_===null||DA(_)||OA(_)))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 _c=0,yn=null,cr=null,vi=null,Tv=!1,Im=!1,Ih=!1,Cv=0,Fx=0,Fm=null,$ae=0;function Qr(){throw Error(r(321))}function C2(h,g){if(g===null)return!1;for(var _=0;_<g.length&&_<h.length;_++)if(!js(h[_],g[_]))return!1;return!0}function k2(h,g,_,N,R,F){return _c=F,yn=g,g.memoizedState=null,g.updateQueue=null,g.lanes=0,K.H=h===null||h.memoizedState===null?n5:G2,Ih=!1,F=_(N,R),Ih=!1,Im&&(F=_F(g,_,N,R)),vF(h),F}function vF(h){K.H=Bx;var g=cr!==null&&cr.next!==null;if(_c=0,vi=cr=yn=null,Tv=!1,Fx=0,Fm=null,g)throw Error(r(300));h===null||_i||(h=h.dependencies,h!==null&&yv(h)&&(_i=!0))}function _F(h,g,_,N){yn=h;var R=0;do{if(Im&&(Fm=null),Fx=0,Im=!1,25<=R)throw Error(r(301));if(R+=1,vi=cr=null,h.updateQueue!=null){var F=h.updateQueue;F.lastEffect=null,F.events=null,F.stores=null,F.memoCache!=null&&(F.memoCache.index=0)}K.H=r5,F=g(_,N)}while(Im);return F}function Hae(){var h=K.H,g=h.useState()[0];return g=typeof g.then=="function"?Ux(g):g,h=h.useState()[0],(cr!==null?cr.memoizedState:null)!==h&&(yn.flags|=1024),g}function j2(){var h=Cv!==0;return Cv=0,h}function P2(h,g,_){g.updateQueue=h.updateQueue,g.flags&=-2053,h.lanes&=~_}function R2(h){if(Tv){for(h=h.memoizedState;h!==null;){var g=h.queue;g!==null&&(g.pending=null),h=h.next}Tv=!1}_c=0,vi=cr=yn=null,Im=!1,Fx=Cv=0,Fm=null}function Wa(){var h={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return vi===null?yn.memoizedState=vi=h:vi=vi.next=h,vi}function mi(){if(cr===null){var h=yn.alternate;h=h!==null?h.memoizedState:null}else h=cr.next;var g=vi===null?yn.memoizedState:vi.next;if(g!==null)vi=g,cr=h;else{if(h===null)throw yn.alternate===null?Error(r(467)):Error(r(310));cr=h,h={memoizedState:cr.memoizedState,baseState:cr.baseState,baseQueue:cr.baseQueue,queue:cr.queue,next:null},vi===null?yn.memoizedState=vi=h:vi=vi.next=h}return vi}function kv(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Ux(h){var g=Fx;return Fx+=1,Fm===null&&(Fm=[]),h=dF(Fm,h,g),g=yn,(vi===null?g.memoizedState:vi.next)===null&&(g=g.alternate,K.H=g===null||g.memoizedState===null?n5:G2),h}function jv(h){if(h!==null&&typeof h=="object"){if(typeof h.then=="function")return Ux(h);if(h.$$typeof===M)return ha(h)}throw Error(r(438,String(h)))}function D2(h){var g=null,_=yn.updateQueue;if(_!==null&&(g=_.memoCache),g==null){var N=yn.alternate;N!==null&&(N=N.updateQueue,N!==null&&(N=N.memoCache,N!=null&&(g={data:N.data.map(function(R){return R.slice()}),index:0})))}if(g==null&&(g={data:[],index:0}),_===null&&(_=kv(),yn.updateQueue=_),_.memoCache=g,_=g.data[g.index],_===void 0)for(_=g.data[g.index]=Array(h),N=0;N<h;N++)_[N]=D;return g.index++,_}function wc(h,g){return typeof g=="function"?g(h):g}function Pv(h){var g=mi();return O2(g,cr,h)}function O2(h,g,_){var N=h.queue;if(N===null)throw Error(r(311));N.lastRenderedReducer=_;var R=h.baseQueue,F=N.pending;if(F!==null){if(R!==null){var Z=R.next;R.next=F.next,F.next=Z}g.baseQueue=R=F,N.pending=null}if(F=h.baseState,R===null)h.memoizedState=F;else{g=R.next;var pe=Z=null,De=null,it=g,xt=!1;do{var vt=it.lane&-536870913;if(vt!==it.lane?(In&vt)===vt:(_c&vt)===vt){var st=it.revertLane;if(st===0)De!==null&&(De=De.next={lane:0,revertLane:0,gesture:null,action:it.action,hasEagerState:it.hasEagerState,eagerState:it.eagerState,next:null}),vt===Pm&&(xt=!0);else if((_c&st)===st){it=it.next,st===Pm&&(xt=!0);continue}else vt={lane:0,revertLane:it.revertLane,gesture:null,action:it.action,hasEagerState:it.hasEagerState,eagerState:it.eagerState,next:null},De===null?(pe=De=vt,Z=F):De=De.next=vt,yn.lanes|=st,Gu|=st;vt=it.action,Ih&&_(F,vt),F=it.hasEagerState?it.eagerState:_(F,vt)}else st={lane:vt,revertLane:it.revertLane,gesture:it.gesture,action:it.action,hasEagerState:it.hasEagerState,eagerState:it.eagerState,next:null},De===null?(pe=De=st,Z=F):De=De.next=st,yn.lanes|=vt,Gu|=vt;it=it.next}while(it!==null&&it!==g);if(De===null?Z=F:De.next=pe,!js(F,h.memoizedState)&&(_i=!0,xt&&(_=Rm,_!==null)))throw _;h.memoizedState=F,h.baseState=Z,h.baseQueue=De,N.lastRenderedState=F}return R===null&&(N.lanes=0),[h.memoizedState,N.dispatch]}function L2(h){var g=mi(),_=g.queue;if(_===null)throw Error(r(311));_.lastRenderedReducer=h;var N=_.dispatch,R=_.pending,F=g.memoizedState;if(R!==null){_.pending=null;var Z=R=R.next;do F=h(F,Z.action),Z=Z.next;while(Z!==R);js(F,g.memoizedState)||(_i=!0),g.memoizedState=F,g.baseQueue===null&&(g.baseState=F),_.lastRenderedState=F}return[F,N]}function wF(h,g,_){var N=yn,R=mi(),F=zn;if(F){if(_===void 0)throw Error(r(407));_=_()}else _=g();var Z=!js((cr||R).memoizedState,_);if(Z&&(R.memoizedState=_,_i=!0),R=R.queue,U2(NF.bind(null,N,R,h),[h]),R.getSnapshot!==g||Z||vi!==null&&vi.memoizedState.tag&1){if(N.flags|=2048,Um(9,{destroy:void 0},MF.bind(null,N,R,_,g),null),vr===null)throw Error(r(349));F||(_c&127)!==0||SF(N,g,_)}return _}function SF(h,g,_){h.flags|=16384,h={getSnapshot:g,value:_},g=yn.updateQueue,g===null?(g=kv(),yn.updateQueue=g,g.stores=[h]):(_=g.stores,_===null?g.stores=[h]:_.push(h))}function MF(h,g,_,N){g.value=_,g.getSnapshot=N,EF(g)&&AF(h)}function NF(h,g,_){return _(function(){EF(g)&&AF(h)})}function EF(h){var g=h.getSnapshot;h=h.value;try{var _=g();return!js(h,_)}catch{return!0}}function AF(h){var g=Th(h,2);g!==null&&ps(g,h,2)}function I2(h){var g=Wa();if(typeof h=="function"){var _=h;if(h=_(),Ih){te(!0);try{_()}finally{te(!1)}}}return g.memoizedState=g.baseState=h,g.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:wc,lastRenderedState:h},g}function TF(h,g,_,N){return h.baseState=_,O2(h,cr,typeof N=="function"?N:wc)}function Vae(h,g,_,N,R){if(Ov(h))throw Error(r(485));if(h=g.action,h!==null){var F={payload:R,action:h,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(Z){F.listeners.push(Z)}};K.T!==null?_(!0):F.isTransition=!1,N(F),_=g.pending,_===null?(F.next=g.pending=F,CF(g,F)):(F.next=_.next,g.pending=_.next=F)}}function CF(h,g){var _=g.action,N=g.payload,R=h.state;if(g.isTransition){var F=K.T,Z={};K.T=Z;try{var pe=_(R,N),De=K.S;De!==null&&De(Z,pe),kF(h,g,pe)}catch(it){F2(h,g,it)}finally{F!==null&&Z.types!==null&&(F.types=Z.types),K.T=F}}else try{F=_(R,N),kF(h,g,F)}catch(it){F2(h,g,it)}}function kF(h,g,_){_!==null&&typeof _=="object"&&typeof _.then=="function"?_.then(function(N){jF(h,g,N)},function(N){return F2(h,g,N)}):jF(h,g,_)}function jF(h,g,_){g.status="fulfilled",g.value=_,PF(g),h.state=_,g=h.pending,g!==null&&(_=g.next,_===g?h.pending=null:(_=_.next,g.next=_,CF(h,_)))}function F2(h,g,_){var N=h.pending;if(h.pending=null,N!==null){N=N.next;do g.status="rejected",g.reason=_,PF(g),g=g.next;while(g!==N)}h.action=null}function PF(h){h=h.listeners;for(var g=0;g<h.length;g++)(0,h[g])()}function RF(h,g){return g}function DF(h,g){if(zn){var _=vr.formState;if(_!==null){e:{var N=yn;if(zn){if(Ar){t:{for(var R=Ar,F=oo;R.nodeType!==8;){if(!F){R=null;break t}if(R=co(R.nextSibling),R===null){R=null;break t}}F=R.data,R=F==="F!"||F==="F"?R:null}if(R){Ar=co(R.nextSibling),N=R.data==="F!";break e}}Lu(N)}N=!1}N&&(g=_[0])}}return _=Wa(),_.memoizedState=_.baseState=g,N={pending:null,lanes:0,dispatch:null,lastRenderedReducer:RF,lastRenderedState:g},_.queue=N,_=JF.bind(null,yn,N),N.dispatch=_,N=I2(!1),F=V2.bind(null,yn,!1,N.queue),N=Wa(),R={state:g,dispatch:null,action:h,pending:null},N.queue=R,_=Vae.bind(null,yn,R,F,_),R.dispatch=_,N.memoizedState=h,[g,_,!1]}function OF(h){var g=mi();return LF(g,cr,h)}function LF(h,g,_){if(g=O2(h,g,RF)[0],h=Pv(wc)[0],typeof g=="object"&&g!==null&&typeof g.then=="function")try{var N=Ux(g)}catch(Z){throw Z===Dm?wv:Z}else N=g;g=mi();var R=g.queue,F=R.dispatch;return _!==g.memoizedState&&(yn.flags|=2048,Um(9,{destroy:void 0},Gae.bind(null,R,_),null)),[N,F,h]}function Gae(h,g){h.action=g}function IF(h){var g=mi(),_=cr;if(_!==null)return LF(g,_,h);mi(),g=g.memoizedState,_=mi();var N=_.queue.dispatch;return _.memoizedState=h,[g,N,!1]}function Um(h,g,_,N){return h={tag:h,create:_,deps:N,inst:g,next:null},g=yn.updateQueue,g===null&&(g=kv(),yn.updateQueue=g),_=g.lastEffect,_===null?g.lastEffect=h.next=h:(N=_.next,_.next=h,h.next=N,g.lastEffect=h),h}function FF(){return mi().memoizedState}function Rv(h,g,_,N){var R=Wa();yn.flags|=h,R.memoizedState=Um(1|g,{destroy:void 0},_,N===void 0?null:N)}function Dv(h,g,_,N){var R=mi();N=N===void 0?null:N;var F=R.memoizedState.inst;cr!==null&&N!==null&&C2(N,cr.memoizedState.deps)?R.memoizedState=Um(g,F,_,N):(yn.flags|=h,R.memoizedState=Um(1|g,F,_,N))}function UF(h,g){Rv(8390656,8,h,g)}function U2(h,g){Dv(2048,8,h,g)}function Wae(h){yn.flags|=4;var g=yn.updateQueue;if(g===null)g=kv(),yn.updateQueue=g,g.events=[h];else{var _=g.events;_===null?g.events=[h]:_.push(h)}}function zF(h){var g=mi().memoizedState;return Wae({ref:g,nextImpl:h}),function(){if((Jn&2)!==0)throw Error(r(440));return g.impl.apply(void 0,arguments)}}function BF(h,g){return Dv(4,2,h,g)}function $F(h,g){return Dv(4,4,h,g)}function HF(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 VF(h,g,_){_=_!=null?_.concat([h]):null,Dv(4,4,HF.bind(null,g,h),_)}function z2(){}function GF(h,g){var _=mi();g=g===void 0?null:g;var N=_.memoizedState;return g!==null&&C2(g,N[1])?N[0]:(_.memoizedState=[h,g],h)}function WF(h,g){var _=mi();g=g===void 0?null:g;var N=_.memoizedState;if(g!==null&&C2(g,N[1]))return N[0];if(N=h(),Ih){te(!0);try{h()}finally{te(!1)}}return _.memoizedState=[N,g],N}function B2(h,g,_){return _===void 0||(_c&1073741824)!==0&&(In&261930)===0?h.memoizedState=g:(h.memoizedState=_,h=q5(),yn.lanes|=h,Gu|=h,_)}function qF(h,g,_,N){return js(_,g)?_:Lm.current!==null?(h=B2(h,_,N),js(h,g)||(_i=!0),h):(_c&42)===0||(_c&1073741824)!==0&&(In&261930)===0?(_i=!0,h.memoizedState=_):(h=q5(),yn.lanes|=h,Gu|=h,g)}function KF(h,g,_,N,R){var F=V.p;V.p=F!==0&&8>F?F:8;var Z=K.T,pe={};K.T=pe,V2(h,!1,g,_);try{var De=R(),it=K.S;if(it!==null&&it(pe,De),De!==null&&typeof De=="object"&&typeof De.then=="function"){var xt=Bae(De,N);zx(h,g,xt,Is(h))}else zx(h,g,N,Is(h))}catch(vt){zx(h,g,{then:function(){},status:"rejected",reason:vt},Is())}finally{V.p=F,Z!==null&&pe.types!==null&&(Z.types=pe.types),K.T=Z}}function qae(){}function $2(h,g,_,N){if(h.tag!==5)throw Error(r(476));var R=XF(h).queue;KF(h,R,g,Q,_===null?qae:function(){return YF(h),_(N)})}function XF(h){var g=h.memoizedState;if(g!==null)return g;g={memoizedState:Q,baseState:Q,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:wc,lastRenderedState:Q},next:null};var _={};return g.next={memoizedState:_,baseState:_,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:wc,lastRenderedState:_},next:null},h.memoizedState=g,h=h.alternate,h!==null&&(h.memoizedState=g),g}function YF(h){var g=XF(h);g.next===null&&(g=h.alternate.memoizedState),zx(h,g.next.queue,{},Is())}function H2(){return ha(rb)}function ZF(){return mi().memoizedState}function QF(){return mi().memoizedState}function Kae(h){for(var g=h.return;g!==null;){switch(g.tag){case 24:case 3:var _=Is();h=Uu(_);var N=zu(g,h,_);N!==null&&(ps(N,g,_),Ox(N,g,_)),g={cache:b2()},h.payload=g;return}g=g.return}}function Xae(h,g,_){var N=Is();_={lane:N,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null},Ov(h)?e5(g,_):(_=o2(h,g,_,N),_!==null&&(ps(_,h,N),t5(_,g,N)))}function JF(h,g,_){var N=Is();zx(h,g,_,N)}function zx(h,g,_,N){var R={lane:N,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null};if(Ov(h))e5(g,R);else{var F=h.alternate;if(h.lanes===0&&(F===null||F.lanes===0)&&(F=g.lastRenderedReducer,F!==null))try{var Z=g.lastRenderedState,pe=F(Z,_);if(R.hasEagerState=!0,R.eagerState=pe,js(pe,Z))return pv(h,g,R,0),vr===null&&mv(),!1}catch{}if(_=o2(h,g,R,N),_!==null)return ps(_,h,N),t5(_,g,N),!0}return!1}function V2(h,g,_,N){if(N={lane:2,revertLane:wA(),gesture:null,action:N,hasEagerState:!1,eagerState:null,next:null},Ov(h)){if(g)throw Error(r(479))}else g=o2(h,_,N,2),g!==null&&ps(g,h,2)}function Ov(h){var g=h.alternate;return h===yn||g!==null&&g===yn}function e5(h,g){Im=Tv=!0;var _=h.pending;_===null?g.next=g:(g.next=_.next,_.next=g),h.pending=g}function t5(h,g,_){if((_&4194048)!==0){var N=g.lanes;N&=h.pendingLanes,_|=N,g.lanes=_,gt(h,_)}}var Bx={readContext:ha,use:jv,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};Bx.useEffectEvent=Qr;var n5={readContext:ha,use:jv,useCallback:function(h,g){return Wa().memoizedState=[h,g===void 0?null:g],h},useContext:ha,useEffect:UF,useImperativeHandle:function(h,g,_){_=_!=null?_.concat([h]):null,Rv(4194308,4,HF.bind(null,g,h),_)},useLayoutEffect:function(h,g){return Rv(4194308,4,h,g)},useInsertionEffect:function(h,g){Rv(4,2,h,g)},useMemo:function(h,g){var _=Wa();g=g===void 0?null:g;var N=h();if(Ih){te(!0);try{h()}finally{te(!1)}}return _.memoizedState=[N,g],N},useReducer:function(h,g,_){var N=Wa();if(_!==void 0){var R=_(g);if(Ih){te(!0);try{_(g)}finally{te(!1)}}}else R=g;return N.memoizedState=N.baseState=R,h={pending:null,lanes:0,dispatch:null,lastRenderedReducer:h,lastRenderedState:R},N.queue=h,h=h.dispatch=Xae.bind(null,yn,h),[N.memoizedState,h]},useRef:function(h){var g=Wa();return h={current:h},g.memoizedState=h},useState:function(h){h=I2(h);var g=h.queue,_=JF.bind(null,yn,g);return g.dispatch=_,[h.memoizedState,_]},useDebugValue:z2,useDeferredValue:function(h,g){var _=Wa();return B2(_,h,g)},useTransition:function(){var h=I2(!1);return h=KF.bind(null,yn,h.queue,!0,!1),Wa().memoizedState=h,[!1,h]},useSyncExternalStore:function(h,g,_){var N=yn,R=Wa();if(zn){if(_===void 0)throw Error(r(407));_=_()}else{if(_=g(),vr===null)throw Error(r(349));(In&127)!==0||SF(N,g,_)}R.memoizedState=_;var F={value:_,getSnapshot:g};return R.queue=F,UF(NF.bind(null,N,F,h),[h]),N.flags|=2048,Um(9,{destroy:void 0},MF.bind(null,N,F,_,g),null),_},useId:function(){var h=Wa(),g=vr.identifierPrefix;if(zn){var _=wl,N=_l;_=(N&~(1<<32-Me(N)-1)).toString(32)+_,g="_"+g+"R_"+_,_=Cv++,0<_&&(g+="H"+_.toString(32)),g+="_"}else _=$ae++,g="_"+g+"r_"+_.toString(32)+"_";return h.memoizedState=g},useHostTransitionStatus:H2,useFormState:DF,useActionState:DF,useOptimistic:function(h){var g=Wa();g.memoizedState=g.baseState=h;var _={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return g.queue=_,g=V2.bind(null,yn,!0,_),_.dispatch=g,[h,g]},useMemoCache:D2,useCacheRefresh:function(){return Wa().memoizedState=Kae.bind(null,yn)},useEffectEvent:function(h){var g=Wa(),_={impl:h};return g.memoizedState=_,function(){if((Jn&2)!==0)throw Error(r(440));return _.impl.apply(void 0,arguments)}}},G2={readContext:ha,use:jv,useCallback:GF,useContext:ha,useEffect:U2,useImperativeHandle:VF,useInsertionEffect:BF,useLayoutEffect:$F,useMemo:WF,useReducer:Pv,useRef:FF,useState:function(){return Pv(wc)},useDebugValue:z2,useDeferredValue:function(h,g){var _=mi();return qF(_,cr.memoizedState,h,g)},useTransition:function(){var h=Pv(wc)[0],g=mi().memoizedState;return[typeof h=="boolean"?h:Ux(h),g]},useSyncExternalStore:wF,useId:ZF,useHostTransitionStatus:H2,useFormState:OF,useActionState:OF,useOptimistic:function(h,g){var _=mi();return TF(_,cr,h,g)},useMemoCache:D2,useCacheRefresh:QF};G2.useEffectEvent=zF;var r5={readContext:ha,use:jv,useCallback:GF,useContext:ha,useEffect:U2,useImperativeHandle:VF,useInsertionEffect:BF,useLayoutEffect:$F,useMemo:WF,useReducer:L2,useRef:FF,useState:function(){return L2(wc)},useDebugValue:z2,useDeferredValue:function(h,g){var _=mi();return cr===null?B2(_,h,g):qF(_,cr.memoizedState,h,g)},useTransition:function(){var h=L2(wc)[0],g=mi().memoizedState;return[typeof h=="boolean"?h:Ux(h),g]},useSyncExternalStore:wF,useId:ZF,useHostTransitionStatus:H2,useFormState:IF,useActionState:IF,useOptimistic:function(h,g){var _=mi();return cr!==null?TF(_,cr,h,g):(_.baseState=h,[h,_.queue.dispatch])},useMemoCache:D2,useCacheRefresh:QF};r5.useEffectEvent=zF;function W2(h,g,_,N){g=h.memoizedState,_=_(N,g),_=_==null?g:f({},g,_),h.memoizedState=_,h.lanes===0&&(h.updateQueue.baseState=_)}var q2={enqueueSetState:function(h,g,_){h=h._reactInternals;var N=Is(),R=Uu(N);R.payload=g,_!=null&&(R.callback=_),g=zu(h,R,N),g!==null&&(ps(g,h,N),Ox(g,h,N))},enqueueReplaceState:function(h,g,_){h=h._reactInternals;var N=Is(),R=Uu(N);R.tag=1,R.payload=g,_!=null&&(R.callback=_),g=zu(h,R,N),g!==null&&(ps(g,h,N),Ox(g,h,N))},enqueueForceUpdate:function(h,g){h=h._reactInternals;var _=Is(),N=Uu(_);N.tag=2,g!=null&&(N.callback=g),g=zu(h,N,_),g!==null&&(ps(g,h,_),Ox(g,h,_))}};function i5(h,g,_,N,R,F,Z){return h=h.stateNode,typeof h.shouldComponentUpdate=="function"?h.shouldComponentUpdate(N,F,Z):g.prototype&&g.prototype.isPureReactComponent?!Ax(_,N)||!Ax(R,F):!0}function a5(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&&q2.enqueueReplaceState(g,g.state,null)}function Fh(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 R in h)_[R]===void 0&&(_[R]=h[R])}return _}function s5(h){fv(h)}function o5(h){console.error(h)}function l5(h){fv(h)}function Lv(h,g){try{var _=h.onUncaughtError;_(g.value,{componentStack:g.stack})}catch(N){setTimeout(function(){throw N})}}function c5(h,g,_){try{var N=h.onCaughtError;N(_.value,{componentStack:_.stack,errorBoundary:g.tag===1?g.stateNode:null})}catch(R){setTimeout(function(){throw R})}}function K2(h,g,_){return _=Uu(_),_.tag=3,_.payload={element:null},_.callback=function(){Lv(h,g)},_}function u5(h){return h=Uu(h),h.tag=3,h}function d5(h,g,_,N){var R=_.type.getDerivedStateFromError;if(typeof R=="function"){var F=N.value;h.payload=function(){return R(F)},h.callback=function(){c5(g,_,N)}}var Z=_.stateNode;Z!==null&&typeof Z.componentDidCatch=="function"&&(h.callback=function(){c5(g,_,N),typeof R!="function"&&(Wu===null?Wu=new Set([this]):Wu.add(this));var pe=N.stack;this.componentDidCatch(N.value,{componentStack:pe!==null?pe:""})})}function Yae(h,g,_,N,R){if(_.flags|=32768,N!==null&&typeof N=="object"&&typeof N.then=="function"){if(g=_.alternate,g!==null&&jm(g,_,R,!0),_=Rs.current,_!==null){switch(_.tag){case 31:case 13:return lo===null?Kv():_.alternate===null&&Jr===0&&(Jr=3),_.flags&=-257,_.flags|=65536,_.lanes=R,N===Sv?_.flags|=16384:(g=_.updateQueue,g===null?_.updateQueue=new Set([N]):g.add(N),yA(h,N,R)),!1;case 22:return _.flags|=65536,N===Sv?_.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)),yA(h,N,R)),!1}throw Error(r(435,_.tag))}return yA(h,N,R),Kv(),!1}if(zn)return g=Rs.current,g!==null?((g.flags&65536)===0&&(g.flags|=256),g.flags|=65536,g.lanes=R,N!==f2&&(h=Error(r(422),{cause:N}),kx(io(h,_)))):(N!==f2&&(g=Error(r(423),{cause:N}),kx(io(g,_))),h=h.current.alternate,h.flags|=65536,R&=-R,h.lanes|=R,N=io(N,_),R=K2(h.stateNode,N,R),M2(h,R),Jr!==4&&(Jr=2)),!1;var F=Error(r(520),{cause:N});if(F=io(F,_),Xx===null?Xx=[F]:Xx.push(F),Jr!==4&&(Jr=2),g===null)return!0;N=io(N,_),_=g;do{switch(_.tag){case 3:return _.flags|=65536,h=R&-R,_.lanes|=h,h=K2(_.stateNode,N,h),M2(_,h),!1;case 1:if(g=_.type,F=_.stateNode,(_.flags&128)===0&&(typeof g.getDerivedStateFromError=="function"||F!==null&&typeof F.componentDidCatch=="function"&&(Wu===null||!Wu.has(F))))return _.flags|=65536,R&=-R,_.lanes|=R,R=u5(R),d5(R,h,_,N),M2(_,R),!1}_=_.return}while(_!==null);return!1}var X2=Error(r(461)),_i=!1;function fa(h,g,_,N){g.child=h===null?pF(g,null,_,N):Lh(g,h.child,_,N)}function h5(h,g,_,N,R){_=_.render;var F=g.ref;if("ref"in N){var Z={};for(var pe in N)pe!=="ref"&&(Z[pe]=N[pe])}else Z=N;return Ph(g),N=k2(h,g,_,Z,F,R),pe=j2(),h!==null&&!_i?(P2(h,g,R),Sc(h,g,R)):(zn&&pe&&d2(g),g.flags|=1,fa(h,g,N,R),g.child)}function f5(h,g,_,N,R){if(h===null){var F=_.type;return typeof F=="function"&&!l2(F)&&F.defaultProps===void 0&&_.compare===null?(g.tag=15,g.type=F,m5(h,g,F,N,R)):(h=xv(_.type,null,N,g,g.mode,R),h.ref=g.ref,h.return=g,g.child=h)}if(F=h.child,!rA(h,R)){var Z=F.memoizedProps;if(_=_.compare,_=_!==null?_:Ax,_(Z,N)&&h.ref===g.ref)return Sc(h,g,R)}return g.flags|=1,h=xc(F,N),h.ref=g.ref,h.return=g,g.child=h}function m5(h,g,_,N,R){if(h!==null){var F=h.memoizedProps;if(Ax(F,N)&&h.ref===g.ref)if(_i=!1,g.pendingProps=N=F,rA(h,R))(h.flags&131072)!==0&&(_i=!0);else return g.lanes=h.lanes,Sc(h,g,R)}return Y2(h,g,_,N,R)}function p5(h,g,_,N){var R=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,R=0;N!==null;)R=R|N.lanes|N.childLanes,N=N.sibling;N=R&~F}else N=0,g.child=null;return g5(h,g,F,_,N)}if((_&536870912)!==0)g.memoizedState={baseLanes:0,cachePool:null},h!==null&&_v(g,F!==null?F.cachePool:null),F!==null?bF(g,F):E2(),yF(g);else return N=g.lanes=536870912,g5(h,g,F!==null?F.baseLanes|_:_,_,N)}else F!==null?(_v(g,F.cachePool),bF(g,F),$u(),g.memoizedState=null):(h!==null&&_v(g,null),E2(),$u());return fa(h,g,R,_),g.child}function $x(h,g){return h!==null&&h.tag===22||g.stateNode!==null||(g.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),g.sibling}function g5(h,g,_,N,R){var F=v2();return F=F===null?null:{parent:yi._currentValue,pool:F},g.memoizedState={baseLanes:_,cachePool:F},h!==null&&_v(g,null),E2(),yF(g),h!==null&&jm(h,g,N,!0),g.childLanes=R,null}function Iv(h,g){return g=Uv({mode:g.mode,children:g.children},h.mode),g.ref=h.ref,h.child=g,g.return=h,g}function x5(h,g,_){return Lh(g,h.child,null,_),h=Iv(g,g.pendingProps),h.flags|=2,Ds(g),g.memoizedState=null,h}function Zae(h,g,_){var N=g.pendingProps,R=(g.flags&128)!==0;if(g.flags&=-129,h===null){if(zn){if(N.mode==="hidden")return h=Iv(g,N),g.lanes=536870912,$x(null,h);if(T2(g),(h=Ar)?(h=CU(h,oo),h=h!==null&&h.data==="&"?h:null,h!==null&&(g.memoizedState={dehydrated:h,treeContext:Du!==null?{id:_l,overflow:wl}:null,retryLane:536870912,hydrationErrors:null},_=eF(h),_.return=g,g.child=_,da=g,Ar=null)):h=null,h===null)throw Lu(g);return g.lanes=536870912,null}return Iv(g,N)}var F=h.memoizedState;if(F!==null){var Z=F.dehydrated;if(T2(g),R)if(g.flags&256)g.flags&=-257,g=x5(h,g,_);else if(g.memoizedState!==null)g.child=h.child,g.flags|=128,g=null;else throw Error(r(558));else if(_i||jm(h,g,_,!1),R=(_&h.childLanes)!==0,_i||R){if(N=vr,N!==null&&(Z=Kt(N,_),Z!==0&&Z!==F.retryLane))throw F.retryLane=Z,Th(h,Z),ps(N,h,Z),X2;Kv(),g=x5(h,g,_)}else h=F.treeContext,Ar=co(Z.nextSibling),da=g,zn=!0,Ou=null,oo=!1,h!==null&&rF(g,h),g=Iv(g,N),g.flags|=4096;return g}return h=xc(h.child,{mode:N.mode,children:N.children}),h.ref=g.ref,g.child=h,h.return=g,h}function Fv(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 Y2(h,g,_,N,R){return Ph(g),_=k2(h,g,_,N,void 0,R),N=j2(),h!==null&&!_i?(P2(h,g,R),Sc(h,g,R)):(zn&&N&&d2(g),g.flags|=1,fa(h,g,_,R),g.child)}function b5(h,g,_,N,R,F){return Ph(g),g.updateQueue=null,_=_F(g,N,_,R),vF(h),N=j2(),h!==null&&!_i?(P2(h,g,F),Sc(h,g,F)):(zn&&N&&d2(g),g.flags|=1,fa(h,g,_,F),g.child)}function y5(h,g,_,N,R){if(Ph(g),g.stateNode===null){var F=Am,Z=_.contextType;typeof Z=="object"&&Z!==null&&(F=ha(Z)),F=new _(N,F),g.memoizedState=F.state!==null&&F.state!==void 0?F.state:null,F.updater=q2,g.stateNode=F,F._reactInternals=g,F=g.stateNode,F.props=N,F.state=g.memoizedState,F.refs={},w2(g),Z=_.contextType,F.context=typeof Z=="object"&&Z!==null?ha(Z):Am,F.state=g.memoizedState,Z=_.getDerivedStateFromProps,typeof Z=="function"&&(W2(g,_,Z,N),F.state=g.memoizedState),typeof _.getDerivedStateFromProps=="function"||typeof F.getSnapshotBeforeUpdate=="function"||typeof F.UNSAFE_componentWillMount!="function"&&typeof F.componentWillMount!="function"||(Z=F.state,typeof F.componentWillMount=="function"&&F.componentWillMount(),typeof F.UNSAFE_componentWillMount=="function"&&F.UNSAFE_componentWillMount(),Z!==F.state&&q2.enqueueReplaceState(F,F.state,null),Ix(g,N,F,R),Lx(),F.state=g.memoizedState),typeof F.componentDidMount=="function"&&(g.flags|=4194308),N=!0}else if(h===null){F=g.stateNode;var pe=g.memoizedProps,De=Fh(_,pe);F.props=De;var it=F.context,xt=_.contextType;Z=Am,typeof xt=="object"&&xt!==null&&(Z=ha(xt));var vt=_.getDerivedStateFromProps;xt=typeof vt=="function"||typeof F.getSnapshotBeforeUpdate=="function",pe=g.pendingProps!==pe,xt||typeof F.UNSAFE_componentWillReceiveProps!="function"&&typeof F.componentWillReceiveProps!="function"||(pe||it!==Z)&&a5(g,F,N,Z),Fu=!1;var st=g.memoizedState;F.state=st,Ix(g,N,F,R),Lx(),it=g.memoizedState,pe||st!==it||Fu?(typeof vt=="function"&&(W2(g,_,vt,N),it=g.memoizedState),(De=Fu||i5(g,_,De,N,st,it,Z))?(xt||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=it),F.props=N,F.state=it,F.context=Z,N=De):(typeof F.componentDidMount=="function"&&(g.flags|=4194308),N=!1)}else{F=g.stateNode,S2(h,g),Z=g.memoizedProps,xt=Fh(_,Z),F.props=xt,vt=g.pendingProps,st=F.context,it=_.contextType,De=Am,typeof it=="object"&&it!==null&&(De=ha(it)),pe=_.getDerivedStateFromProps,(it=typeof pe=="function"||typeof F.getSnapshotBeforeUpdate=="function")||typeof F.UNSAFE_componentWillReceiveProps!="function"&&typeof F.componentWillReceiveProps!="function"||(Z!==vt||st!==De)&&a5(g,F,N,De),Fu=!1,st=g.memoizedState,F.state=st,Ix(g,N,F,R),Lx();var ft=g.memoizedState;Z!==vt||st!==ft||Fu||h!==null&&h.dependencies!==null&&yv(h.dependencies)?(typeof pe=="function"&&(W2(g,_,pe,N),ft=g.memoizedState),(xt=Fu||i5(g,_,xt,N,st,ft,De)||h!==null&&h.dependencies!==null&&yv(h.dependencies))?(it||typeof F.UNSAFE_componentWillUpdate!="function"&&typeof F.componentWillUpdate!="function"||(typeof F.componentWillUpdate=="function"&&F.componentWillUpdate(N,ft,De),typeof F.UNSAFE_componentWillUpdate=="function"&&F.UNSAFE_componentWillUpdate(N,ft,De)),typeof F.componentDidUpdate=="function"&&(g.flags|=4),typeof F.getSnapshotBeforeUpdate=="function"&&(g.flags|=1024)):(typeof F.componentDidUpdate!="function"||Z===h.memoizedProps&&st===h.memoizedState||(g.flags|=4),typeof F.getSnapshotBeforeUpdate!="function"||Z===h.memoizedProps&&st===h.memoizedState||(g.flags|=1024),g.memoizedProps=N,g.memoizedState=ft),F.props=N,F.state=ft,F.context=De,N=xt):(typeof F.componentDidUpdate!="function"||Z===h.memoizedProps&&st===h.memoizedState||(g.flags|=4),typeof F.getSnapshotBeforeUpdate!="function"||Z===h.memoizedProps&&st===h.memoizedState||(g.flags|=1024),N=!1)}return F=N,Fv(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=Lh(g,h.child,null,R),g.child=Lh(g,null,_,R)):fa(h,g,_,R),g.memoizedState=F.state,h=g.child):h=Sc(h,g,R),h}function v5(h,g,_,N){return kh(),g.flags|=256,fa(h,g,_,N),g.child}var Z2={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Q2(h){return{baseLanes:h,cachePool:cF()}}function J2(h,g,_){return h=h!==null?h.childLanes&~_:0,g&&(h|=Ls),h}function _5(h,g,_){var N=g.pendingProps,R=!1,F=(g.flags&128)!==0,Z;if((Z=F)||(Z=h!==null&&h.memoizedState===null?!1:(fi.current&2)!==0),Z&&(R=!0,g.flags&=-129),Z=(g.flags&32)!==0,g.flags&=-33,h===null){if(zn){if(R?Bu(g):$u(),(h=Ar)?(h=CU(h,oo),h=h!==null&&h.data!=="&"?h:null,h!==null&&(g.memoizedState={dehydrated:h,treeContext:Du!==null?{id:_l,overflow:wl}:null,retryLane:536870912,hydrationErrors:null},_=eF(h),_.return=g,g.child=_,da=g,Ar=null)):h=null,h===null)throw Lu(g);return OA(h)?g.lanes=32:g.lanes=536870912,null}var pe=N.children;return N=N.fallback,R?($u(),R=g.mode,pe=Uv({mode:"hidden",children:pe},R),N=Ch(N,R,_,null),pe.return=g,N.return=g,pe.sibling=N,g.child=pe,N=g.child,N.memoizedState=Q2(_),N.childLanes=J2(h,Z,_),g.memoizedState=Z2,$x(null,N)):(Bu(g),eA(g,pe))}var De=h.memoizedState;if(De!==null&&(pe=De.dehydrated,pe!==null)){if(F)g.flags&256?(Bu(g),g.flags&=-257,g=tA(h,g,_)):g.memoizedState!==null?($u(),g.child=h.child,g.flags|=128,g=null):($u(),pe=N.fallback,R=g.mode,N=Uv({mode:"visible",children:N.children},R),pe=Ch(pe,R,_,null),pe.flags|=2,N.return=g,pe.return=g,N.sibling=pe,g.child=N,Lh(g,h.child,null,_),N=g.child,N.memoizedState=Q2(_),N.childLanes=J2(h,Z,_),g.memoizedState=Z2,g=$x(null,N));else if(Bu(g),OA(pe)){if(Z=pe.nextSibling&&pe.nextSibling.dataset,Z)var it=Z.dgst;Z=it,N=Error(r(419)),N.stack="",N.digest=Z,kx({value:N,source:null,stack:null}),g=tA(h,g,_)}else if(_i||jm(h,g,_,!1),Z=(_&h.childLanes)!==0,_i||Z){if(Z=vr,Z!==null&&(N=Kt(Z,_),N!==0&&N!==De.retryLane))throw De.retryLane=N,Th(h,N),ps(Z,h,N),X2;DA(pe)||Kv(),g=tA(h,g,_)}else DA(pe)?(g.flags|=192,g.child=h.child,g=null):(h=De.treeContext,Ar=co(pe.nextSibling),da=g,zn=!0,Ou=null,oo=!1,h!==null&&rF(g,h),g=eA(g,N.children),g.flags|=4096);return g}return R?($u(),pe=N.fallback,R=g.mode,De=h.child,it=De.sibling,N=xc(De,{mode:"hidden",children:N.children}),N.subtreeFlags=De.subtreeFlags&65011712,it!==null?pe=xc(it,pe):(pe=Ch(pe,R,_,null),pe.flags|=2),pe.return=g,N.return=g,N.sibling=pe,g.child=N,$x(null,N),N=g.child,pe=h.child.memoizedState,pe===null?pe=Q2(_):(R=pe.cachePool,R!==null?(De=yi._currentValue,R=R.parent!==De?{parent:De,pool:De}:R):R=cF(),pe={baseLanes:pe.baseLanes|_,cachePool:R}),N.memoizedState=pe,N.childLanes=J2(h,Z,_),g.memoizedState=Z2,$x(h.child,N)):(Bu(g),_=h.child,h=_.sibling,_=xc(_,{mode:"visible",children:N.children}),_.return=g,_.sibling=null,h!==null&&(Z=g.deletions,Z===null?(g.deletions=[h],g.flags|=16):Z.push(h)),g.child=_,g.memoizedState=null,_)}function eA(h,g){return g=Uv({mode:"visible",children:g},h.mode),g.return=h,h.child=g}function Uv(h,g){return h=Ps(22,h,null,g),h.lanes=0,h}function tA(h,g,_){return Lh(g,h.child,null,_),h=eA(g,g.pendingProps.children),h.flags|=2,g.memoizedState=null,h}function w5(h,g,_){h.lanes|=g;var N=h.alternate;N!==null&&(N.lanes|=g),g2(h.return,g,_)}function nA(h,g,_,N,R,F){var Z=h.memoizedState;Z===null?h.memoizedState={isBackwards:g,rendering:null,renderingStartTime:0,last:N,tail:_,tailMode:R,treeForkCount:F}:(Z.isBackwards=g,Z.rendering=null,Z.renderingStartTime=0,Z.last=N,Z.tail=_,Z.tailMode=R,Z.treeForkCount=F)}function S5(h,g,_){var N=g.pendingProps,R=N.revealOrder,F=N.tail;N=N.children;var Z=fi.current,pe=(Z&2)!==0;if(pe?(Z=Z&1|2,g.flags|=128):Z&=1,ne(fi,Z),fa(h,g,N,_),N=zn?Cx:0,!pe&&h!==null&&(h.flags&128)!==0)e:for(h=g.child;h!==null;){if(h.tag===13)h.memoizedState!==null&&w5(h,_,g);else if(h.tag===19)w5(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(R){case"forwards":for(_=g.child,R=null;_!==null;)h=_.alternate,h!==null&&Av(h)===null&&(R=_),_=_.sibling;_=R,_===null?(R=g.child,g.child=null):(R=_.sibling,_.sibling=null),nA(g,!1,R,_,F,N);break;case"backwards":case"unstable_legacy-backwards":for(_=null,R=g.child,g.child=null;R!==null;){if(h=R.alternate,h!==null&&Av(h)===null){g.child=R;break}h=R.sibling,R.sibling=_,_=R,R=h}nA(g,!0,_,null,F,N);break;case"together":nA(g,!1,null,null,void 0,N);break;default:g.memoizedState=null}return g.child}function Sc(h,g,_){if(h!==null&&(g.dependencies=h.dependencies),Gu|=g.lanes,(_&g.childLanes)===0)if(h!==null){if(jm(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,_=xc(h,h.pendingProps),g.child=_,_.return=g;h.sibling!==null;)h=h.sibling,_=_.sibling=xc(h,h.pendingProps),_.return=g;_.sibling=null}return g.child}function rA(h,g){return(h.lanes&g)!==0?!0:(h=h.dependencies,!!(h!==null&&yv(h)))}function Qae(h,g,_){switch(g.tag){case 3:Ae(g,g.stateNode.containerInfo),Iu(g,yi,h.memoizedState.cache),kh();break;case 27:case 5:Ne(g);break;case 4:Ae(g,g.stateNode.containerInfo);break;case 10:Iu(g,g.type,g.memoizedProps.value);break;case 31:if(g.memoizedState!==null)return g.flags|=128,T2(g),null;break;case 13:var N=g.memoizedState;if(N!==null)return N.dehydrated!==null?(Bu(g),g.flags|=128,null):(_&g.child.childLanes)!==0?_5(h,g,_):(Bu(g),h=Sc(h,g,_),h!==null?h.sibling:null);Bu(g);break;case 19:var R=(h.flags&128)!==0;if(N=(_&g.childLanes)!==0,N||(jm(h,g,_,!1),N=(_&g.childLanes)!==0),R){if(N)return S5(h,g,_);g.flags|=128}if(R=g.memoizedState,R!==null&&(R.rendering=null,R.tail=null,R.lastEffect=null),ne(fi,fi.current),N)break;return null;case 22:return g.lanes=0,p5(h,g,_,g.pendingProps);case 24:Iu(g,yi,h.memoizedState.cache)}return Sc(h,g,_)}function M5(h,g,_){if(h!==null)if(h.memoizedProps!==g.pendingProps)_i=!0;else{if(!rA(h,_)&&(g.flags&128)===0)return _i=!1,Qae(h,g,_);_i=(h.flags&131072)!==0}else _i=!1,zn&&(g.flags&1048576)!==0&&nF(g,Cx,g.index);switch(g.lanes=0,g.tag){case 16:e:{var N=g.pendingProps;if(h=Dh(g.elementType),g.type=h,typeof h=="function")l2(h)?(N=Fh(h,N),g.tag=1,g=y5(null,g,h,N,_)):(g.tag=0,g=Y2(null,g,h,N,_));else{if(h!=null){var R=h.$$typeof;if(R===A){g.tag=11,g=h5(null,g,h,N,_);break e}else if(R===E){g.tag=14,g=f5(null,g,h,N,_);break e}}throw g=P(h)||h,Error(r(306,g,""))}}return g;case 0:return Y2(h,g,g.type,g.pendingProps,_);case 1:return N=g.type,R=Fh(N,g.pendingProps),y5(h,g,N,R,_);case 3:e:{if(Ae(g,g.stateNode.containerInfo),h===null)throw Error(r(387));N=g.pendingProps;var F=g.memoizedState;R=F.element,S2(h,g),Ix(g,N,null,_);var Z=g.memoizedState;if(N=Z.cache,Iu(g,yi,N),N!==F.cache&&x2(g,[yi],_,!0),Lx(),N=Z.element,F.isDehydrated)if(F={element:N,isDehydrated:!1,cache:Z.cache},g.updateQueue.baseState=F,g.memoizedState=F,g.flags&256){g=v5(h,g,N,_);break e}else if(N!==R){R=io(Error(r(424)),g),kx(R),g=v5(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,Ar=co(h.firstChild),da=g,zn=!0,Ou=null,oo=!0,_=pF(g,null,N,_),g.child=_;_;)_.flags=_.flags&-3|4096,_=_.sibling;else{if(kh(),N===R){g=Sc(h,g,_);break e}fa(h,g,N,_)}g=g.child}return g;case 26:return Fv(h,g),h===null?(_=OU(g.type,null,g.pendingProps,null))?g.memoizedState=_:zn||(_=g.type,h=g.pendingProps,N=t_(fe.current).createElement(_),N[sn]=g,N[Rr]=h,ma(N,_,h),ue(N),g.stateNode=N):g.memoizedState=OU(g.type,h.memoizedProps,g.pendingProps,h.memoizedState),null;case 27:return Ne(g),h===null&&zn&&(N=g.stateNode=PU(g.type,g.pendingProps,fe.current),da=g,oo=!0,R=Ar,Yu(g.type)?(LA=R,Ar=co(N.firstChild)):Ar=R),fa(h,g,g.pendingProps.children,_),Fv(h,g),h===null&&(g.flags|=4194304),g.child;case 5:return h===null&&zn&&((R=N=Ar)&&(N=Tse(N,g.type,g.pendingProps,oo),N!==null?(g.stateNode=N,da=g,Ar=co(N.firstChild),oo=!1,R=!0):R=!1),R||Lu(g)),Ne(g),R=g.type,F=g.pendingProps,Z=h!==null?h.memoizedProps:null,N=F.children,jA(R,F)?N=null:Z!==null&&jA(R,Z)&&(g.flags|=32),g.memoizedState!==null&&(R=k2(h,g,Hae,null,null,_),rb._currentValue=R),Fv(h,g),fa(h,g,N,_),g.child;case 6:return h===null&&zn&&((h=_=Ar)&&(_=Cse(_,g.pendingProps,oo),_!==null?(g.stateNode=_,da=g,Ar=null,h=!0):h=!1),h||Lu(g)),null;case 13:return _5(h,g,_);case 4:return Ae(g,g.stateNode.containerInfo),N=g.pendingProps,h===null?g.child=Lh(g,null,N,_):fa(h,g,N,_),g.child;case 11:return h5(h,g,g.type,g.pendingProps,_);case 7:return fa(h,g,g.pendingProps,_),g.child;case 8:return fa(h,g,g.pendingProps.children,_),g.child;case 12:return fa(h,g,g.pendingProps.children,_),g.child;case 10:return N=g.pendingProps,Iu(g,g.type,N.value),fa(h,g,N.children,_),g.child;case 9:return R=g.type._context,N=g.pendingProps.children,Ph(g),R=ha(R),N=N(R),g.flags|=1,fa(h,g,N,_),g.child;case 14:return f5(h,g,g.type,g.pendingProps,_);case 15:return m5(h,g,g.type,g.pendingProps,_);case 19:return S5(h,g,_);case 31:return Zae(h,g,_);case 22:return p5(h,g,_,g.pendingProps);case 24:return Ph(g),N=ha(yi),h===null?(R=v2(),R===null&&(R=vr,F=b2(),R.pooledCache=F,F.refCount++,F!==null&&(R.pooledCacheLanes|=_),R=F),g.memoizedState={parent:N,cache:R},w2(g),Iu(g,yi,R)):((h.lanes&_)!==0&&(S2(h,g),Ix(g,null,null,_),Lx()),R=h.memoizedState,F=g.memoizedState,R.parent!==N?(R={parent:N,cache:N},g.memoizedState=R,g.lanes===0&&(g.memoizedState=g.updateQueue.baseState=R),Iu(g,yi,N)):(N=F.cache,Iu(g,yi,N),N!==R.cache&&x2(g,[yi],_,!0))),fa(h,g,g.pendingProps.children,_),g.child;case 29:throw g.pendingProps}throw Error(r(156,g.tag))}function Mc(h){h.flags|=4}function iA(h,g,_,N,R){if((g=(h.mode&32)!==0)&&(g=!1),g){if(h.flags|=16777216,(R&335544128)===R)if(h.stateNode.complete)h.flags|=8192;else if(Z5())h.flags|=8192;else throw Oh=Sv,_2}else h.flags&=-16777217}function N5(h,g){if(g.type!=="stylesheet"||(g.state.loading&4)!==0)h.flags&=-16777217;else if(h.flags|=16777216,!zU(g))if(Z5())h.flags|=8192;else throw Oh=Sv,_2}function zv(h,g){g!==null&&(h.flags|=4),h.flags&16384&&(g=h.tag!==22?kt():536870912,h.lanes|=g,Hm|=g)}function Hx(h,g){if(!zn)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 Tr(h){var g=h.alternate!==null&&h.alternate.child===h.child,_=0,N=0;if(g)for(var R=h.child;R!==null;)_|=R.lanes|R.childLanes,N|=R.subtreeFlags&65011712,N|=R.flags&65011712,R.return=h,R=R.sibling;else for(R=h.child;R!==null;)_|=R.lanes|R.childLanes,N|=R.subtreeFlags,N|=R.flags,R.return=h,R=R.sibling;return h.subtreeFlags|=N,h.childLanes=_,g}function Jae(h,g,_){var N=g.pendingProps;switch(h2(g),g.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Tr(g),null;case 1:return Tr(g),null;case 3:return _=g.stateNode,N=null,h!==null&&(N=h.memoizedState.cache),g.memoizedState.cache!==N&&(g.flags|=2048),vc(yi),me(),_.pendingContext&&(_.context=_.pendingContext,_.pendingContext=null),(h===null||h.child===null)&&(km(g)?Mc(g):h===null||h.memoizedState.isDehydrated&&(g.flags&256)===0||(g.flags|=1024,m2())),Tr(g),null;case 26:var R=g.type,F=g.memoizedState;return h===null?(Mc(g),F!==null?(Tr(g),N5(g,F)):(Tr(g),iA(g,R,null,N,_))):F?F!==h.memoizedState?(Mc(g),Tr(g),N5(g,F)):(Tr(g),g.flags&=-16777217):(h=h.memoizedProps,h!==N&&Mc(g),Tr(g),iA(g,R,h,N,_)),null;case 27:if(ye(g),_=fe.current,R=g.type,h!==null&&g.stateNode!=null)h.memoizedProps!==N&&Mc(g);else{if(!N){if(g.stateNode===null)throw Error(r(166));return Tr(g),null}h=ae.current,km(g)?iF(g):(h=PU(R,N,_),g.stateNode=h,Mc(g))}return Tr(g),null;case 5:if(ye(g),R=g.type,h!==null&&g.stateNode!=null)h.memoizedProps!==N&&Mc(g);else{if(!N){if(g.stateNode===null)throw Error(r(166));return Tr(g),null}if(F=ae.current,km(g))iF(g);else{var Z=t_(fe.current);switch(F){case 1:F=Z.createElementNS("http://www.w3.org/2000/svg",R);break;case 2:F=Z.createElementNS("http://www.w3.org/1998/Math/MathML",R);break;default:switch(R){case"svg":F=Z.createElementNS("http://www.w3.org/2000/svg",R);break;case"math":F=Z.createElementNS("http://www.w3.org/1998/Math/MathML",R);break;case"script":F=Z.createElement("div"),F.innerHTML="<script><\/script>",F=F.removeChild(F.firstChild);break;case"select":F=typeof N.is=="string"?Z.createElement("select",{is:N.is}):Z.createElement("select"),N.multiple?F.multiple=!0:N.size&&(F.size=N.size);break;default:F=typeof N.is=="string"?Z.createElement(R,{is:N.is}):Z.createElement(R)}}F[sn]=g,F[Rr]=N;e:for(Z=g.child;Z!==null;){if(Z.tag===5||Z.tag===6)F.appendChild(Z.stateNode);else if(Z.tag!==4&&Z.tag!==27&&Z.child!==null){Z.child.return=Z,Z=Z.child;continue}if(Z===g)break e;for(;Z.sibling===null;){if(Z.return===null||Z.return===g)break e;Z=Z.return}Z.sibling.return=Z.return,Z=Z.sibling}g.stateNode=F;e:switch(ma(F,R,N),R){case"button":case"input":case"select":case"textarea":N=!!N.autoFocus;break e;case"img":N=!0;break e;default:N=!1}N&&Mc(g)}}return Tr(g),iA(g,g.type,h===null?null:h.memoizedProps,g.pendingProps,_),null;case 6:if(h&&g.stateNode!=null)h.memoizedProps!==N&&Mc(g);else{if(typeof N!="string"&&g.stateNode===null)throw Error(r(166));if(h=fe.current,km(g)){if(h=g.stateNode,_=g.memoizedProps,N=null,R=da,R!==null)switch(R.tag){case 27:case 5:N=R.memoizedProps}h[sn]=g,h=!!(h.nodeValue===_||N!==null&&N.suppressHydrationWarning===!0||_U(h.nodeValue,_)),h||Lu(g,!0)}else h=t_(h).createTextNode(N),h[sn]=g,g.stateNode=h}return Tr(g),null;case 31:if(_=g.memoizedState,h===null||h.memoizedState!==null){if(N=km(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[sn]=g}else kh(),(g.flags&128)===0&&(g.memoizedState=null),g.flags|=4;Tr(g),h=!1}else _=m2(),h!==null&&h.memoizedState!==null&&(h.memoizedState.hydrationErrors=_),h=!0;if(!h)return g.flags&256?(Ds(g),g):(Ds(g),null);if((g.flags&128)!==0)throw Error(r(558))}return Tr(g),null;case 13:if(N=g.memoizedState,h===null||h.memoizedState!==null&&h.memoizedState.dehydrated!==null){if(R=km(g),N!==null&&N.dehydrated!==null){if(h===null){if(!R)throw Error(r(318));if(R=g.memoizedState,R=R!==null?R.dehydrated:null,!R)throw Error(r(317));R[sn]=g}else kh(),(g.flags&128)===0&&(g.memoizedState=null),g.flags|=4;Tr(g),R=!1}else R=m2(),h!==null&&h.memoizedState!==null&&(h.memoizedState.hydrationErrors=R),R=!0;if(!R)return g.flags&256?(Ds(g),g):(Ds(g),null)}return Ds(g),(g.flags&128)!==0?(g.lanes=_,g):(_=N!==null,h=h!==null&&h.memoizedState!==null,_&&(N=g.child,R=null,N.alternate!==null&&N.alternate.memoizedState!==null&&N.alternate.memoizedState.cachePool!==null&&(R=N.alternate.memoizedState.cachePool.pool),F=null,N.memoizedState!==null&&N.memoizedState.cachePool!==null&&(F=N.memoizedState.cachePool.pool),F!==R&&(N.flags|=2048)),_!==h&&_&&(g.child.flags|=8192),zv(g,g.updateQueue),Tr(g),null);case 4:return me(),h===null&&EA(g.stateNode.containerInfo),Tr(g),null;case 10:return vc(g.type),Tr(g),null;case 19:if(G(fi),N=g.memoizedState,N===null)return Tr(g),null;if(R=(g.flags&128)!==0,F=N.rendering,F===null)if(R)Hx(N,!1);else{if(Jr!==0||h!==null&&(h.flags&128)!==0)for(h=g.child;h!==null;){if(F=Av(h),F!==null){for(g.flags|=128,Hx(N,!1),h=F.updateQueue,g.updateQueue=h,zv(g,h),g.subtreeFlags=0,h=_,_=g.child;_!==null;)JI(_,h),_=_.sibling;return ne(fi,fi.current&1|2),zn&&bc(g,N.treeForkCount),g.child}h=h.sibling}N.tail!==null&&j()>Gv&&(g.flags|=128,R=!0,Hx(N,!1),g.lanes=4194304)}else{if(!R)if(h=Av(F),h!==null){if(g.flags|=128,R=!0,h=h.updateQueue,g.updateQueue=h,zv(g,h),Hx(N,!0),N.tail===null&&N.tailMode==="hidden"&&!F.alternate&&!zn)return Tr(g),null}else 2*j()-N.renderingStartTime>Gv&&_!==536870912&&(g.flags|=128,R=!0,Hx(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=j(),h.sibling=null,_=fi.current,ne(fi,R?_&1|2:_&1),zn&&bc(g,N.treeForkCount),h):(Tr(g),null);case 22:case 23:return Ds(g),A2(),N=g.memoizedState!==null,h!==null?h.memoizedState!==null!==N&&(g.flags|=8192):N&&(g.flags|=8192),N?(_&536870912)!==0&&(g.flags&128)===0&&(Tr(g),g.subtreeFlags&6&&(g.flags|=8192)):Tr(g),_=g.updateQueue,_!==null&&zv(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&&G(Rh),null;case 24:return _=null,h!==null&&(_=h.memoizedState.cache),g.memoizedState.cache!==_&&(g.flags|=2048),vc(yi),Tr(g),null;case 25:return null;case 30:return null}throw Error(r(156,g.tag))}function ese(h,g){switch(h2(g),g.tag){case 1:return h=g.flags,h&65536?(g.flags=h&-65537|128,g):null;case 3:return vc(yi),me(),h=g.flags,(h&65536)!==0&&(h&128)===0?(g.flags=h&-65537|128,g):null;case 26:case 27:case 5:return ye(g),null;case 31:if(g.memoizedState!==null){if(Ds(g),g.alternate===null)throw Error(r(340));kh()}return h=g.flags,h&65536?(g.flags=h&-65537|128,g):null;case 13:if(Ds(g),h=g.memoizedState,h!==null&&h.dehydrated!==null){if(g.alternate===null)throw Error(r(340));kh()}return h=g.flags,h&65536?(g.flags=h&-65537|128,g):null;case 19:return G(fi),null;case 4:return me(),null;case 10:return vc(g.type),null;case 22:case 23:return Ds(g),A2(),h!==null&&G(Rh),h=g.flags,h&65536?(g.flags=h&-65537|128,g):null;case 24:return vc(yi),null;case 25:return null;default:return null}}function E5(h,g){switch(h2(g),g.tag){case 3:vc(yi),me();break;case 26:case 27:case 5:ye(g);break;case 4:me();break;case 31:g.memoizedState!==null&&Ds(g);break;case 13:Ds(g);break;case 19:G(fi);break;case 10:vc(g.type);break;case 22:case 23:Ds(g),A2(),h!==null&&G(Rh);break;case 24:vc(yi)}}function Vx(h,g){try{var _=g.updateQueue,N=_!==null?_.lastEffect:null;if(N!==null){var R=N.next;_=R;do{if((_.tag&h)===h){N=void 0;var F=_.create,Z=_.inst;N=F(),Z.destroy=N}_=_.next}while(_!==R)}}catch(pe){ar(g,g.return,pe)}}function Hu(h,g,_){try{var N=g.updateQueue,R=N!==null?N.lastEffect:null;if(R!==null){var F=R.next;N=F;do{if((N.tag&h)===h){var Z=N.inst,pe=Z.destroy;if(pe!==void 0){Z.destroy=void 0,R=g;var De=_,it=pe;try{it()}catch(xt){ar(R,De,xt)}}}N=N.next}while(N!==F)}}catch(xt){ar(g,g.return,xt)}}function A5(h){var g=h.updateQueue;if(g!==null){var _=h.stateNode;try{xF(g,_)}catch(N){ar(h,h.return,N)}}}function T5(h,g,_){_.props=Fh(h.type,h.memoizedProps),_.state=h.memoizedState;try{_.componentWillUnmount()}catch(N){ar(h,g,N)}}function Gx(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(R){ar(h,g,R)}}function Sl(h,g){var _=h.ref,N=h.refCleanup;if(_!==null)if(typeof N=="function")try{N()}catch(R){ar(h,g,R)}finally{h.refCleanup=null,h=h.alternate,h!=null&&(h.refCleanup=null)}else if(typeof _=="function")try{_(null)}catch(R){ar(h,g,R)}else _.current=null}function C5(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(R){ar(h,h.return,R)}}function aA(h,g,_){try{var N=h.stateNode;wse(N,h.type,_,g),N[Rr]=g}catch(R){ar(h,h.return,R)}}function k5(h){return h.tag===5||h.tag===3||h.tag===26||h.tag===27&&Yu(h.type)||h.tag===4}function sA(h){e:for(;;){for(;h.sibling===null;){if(h.return===null||k5(h.return))return null;h=h.return}for(h.sibling.return=h.return,h=h.sibling;h.tag!==5&&h.tag!==6&&h.tag!==18;){if(h.tag===27&&Yu(h.type)||h.flags&2||h.child===null||h.tag===4)continue e;h.child.return=h,h=h.child}if(!(h.flags&2))return h.stateNode}}function oA(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=pc));else if(N!==4&&(N===27&&Yu(h.type)&&(_=h.stateNode,g=null),h=h.child,h!==null))for(oA(h,g,_),h=h.sibling;h!==null;)oA(h,g,_),h=h.sibling}function Bv(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&&Yu(h.type)&&(_=h.stateNode),h=h.child,h!==null))for(Bv(h,g,_),h=h.sibling;h!==null;)Bv(h,g,_),h=h.sibling}function j5(h){var g=h.stateNode,_=h.memoizedProps;try{for(var N=h.type,R=g.attributes;R.length;)g.removeAttributeNode(R[0]);ma(g,N,_),g[sn]=h,g[Rr]=_}catch(F){ar(h,h.return,F)}}var Nc=!1,wi=!1,lA=!1,P5=typeof WeakSet=="function"?WeakSet:Set,Wi=null;function tse(h,g){if(h=h.containerInfo,CA=l_,h=VI(h),t2(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 R=N.anchorOffset,F=N.focusNode;N=N.focusOffset;try{_.nodeType,F.nodeType}catch{_=null;break e}var Z=0,pe=-1,De=-1,it=0,xt=0,vt=h,st=null;t:for(;;){for(var ft;vt!==_||R!==0&&vt.nodeType!==3||(pe=Z+R),vt!==F||N!==0&&vt.nodeType!==3||(De=Z+N),vt.nodeType===3&&(Z+=vt.nodeValue.length),(ft=vt.firstChild)!==null;)st=vt,vt=ft;for(;;){if(vt===h)break t;if(st===_&&++it===R&&(pe=Z),st===F&&++xt===N&&(De=Z),(ft=vt.nextSibling)!==null)break;vt=st,st=vt.parentNode}vt=ft}_=pe===-1||De===-1?null:{start:pe,end:De}}else _=null}_=_||{start:0,end:0}}else _=null;for(kA={focusedElem:h,selectionRange:_},l_=!1,Wi=g;Wi!==null;)if(g=Wi,h=g.child,(g.subtreeFlags&1028)!==0&&h!==null)h.return=g,Wi=h;else for(;Wi!==null;){switch(g=Wi,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;_++)R=h[_],R.ref.impl=R.nextImpl;break;case 11:case 15:break;case 1:if((h&1024)!==0&&F!==null){h=void 0,_=g,R=F.memoizedProps,F=F.memoizedState,N=_.stateNode;try{var Zt=Fh(_.type,R);h=N.getSnapshotBeforeUpdate(Zt,F),N.__reactInternalSnapshotBeforeUpdate=h}catch(an){ar(_,_.return,an)}}break;case 3:if((h&1024)!==0){if(h=g.stateNode.containerInfo,_=h.nodeType,_===9)RA(h);else if(_===1)switch(h.nodeName){case"HEAD":case"HTML":case"BODY":RA(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,Wi=h;break}Wi=g.return}}function R5(h,g,_){var N=_.flags;switch(_.tag){case 0:case 11:case 15:Ac(h,_),N&4&&Vx(5,_);break;case 1:if(Ac(h,_),N&4)if(h=_.stateNode,g===null)try{h.componentDidMount()}catch(Z){ar(_,_.return,Z)}else{var R=Fh(_.type,g.memoizedProps);g=g.memoizedState;try{h.componentDidUpdate(R,g,h.__reactInternalSnapshotBeforeUpdate)}catch(Z){ar(_,_.return,Z)}}N&64&&A5(_),N&512&&Gx(_,_.return);break;case 3:if(Ac(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{xF(h,g)}catch(Z){ar(_,_.return,Z)}}break;case 27:g===null&&N&4&&j5(_);case 26:case 5:Ac(h,_),g===null&&N&4&&C5(_),N&512&&Gx(_,_.return);break;case 12:Ac(h,_);break;case 31:Ac(h,_),N&4&&L5(h,_);break;case 13:Ac(h,_),N&4&&I5(h,_),N&64&&(h=_.memoizedState,h!==null&&(h=h.dehydrated,h!==null&&(_=use.bind(null,_),kse(h,_))));break;case 22:if(N=_.memoizedState!==null||Nc,!N){g=g!==null&&g.memoizedState!==null||wi,R=Nc;var F=wi;Nc=N,(wi=g)&&!F?Tc(h,_,(_.subtreeFlags&8772)!==0):Ac(h,_),Nc=R,wi=F}break;case 30:break;default:Ac(h,_)}}function D5(h){var g=h.alternate;g!==null&&(h.alternate=null,D5(g)),h.child=null,h.deletions=null,h.sibling=null,h.tag===5&&(g=h.stateNode,g!==null&&rt(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,ds=!1;function Ec(h,g,_){for(_=_.child;_!==null;)O5(h,g,_),_=_.sibling}function O5(h,g,_){if(oe&&typeof oe.onCommitFiberUnmount=="function")try{oe.onCommitFiberUnmount(Qe,_)}catch{}switch(_.tag){case 26:wi||Sl(_,g),Ec(h,g,_),_.memoizedState?_.memoizedState.count--:_.stateNode&&(_=_.stateNode,_.parentNode.removeChild(_));break;case 27:wi||Sl(_,g);var N=Ir,R=ds;Yu(_.type)&&(Ir=_.stateNode,ds=!1),Ec(h,g,_),eb(_.stateNode),Ir=N,ds=R;break;case 5:wi||Sl(_,g);case 6:if(N=Ir,R=ds,Ir=null,Ec(h,g,_),Ir=N,ds=R,Ir!==null)if(ds)try{(Ir.nodeType===9?Ir.body:Ir.nodeName==="HTML"?Ir.ownerDocument.body:Ir).removeChild(_.stateNode)}catch(F){ar(_,g,F)}else try{Ir.removeChild(_.stateNode)}catch(F){ar(_,g,F)}break;case 18:Ir!==null&&(ds?(h=Ir,AU(h.nodeType===9?h.body:h.nodeName==="HTML"?h.ownerDocument.body:h,_.stateNode),Zm(h)):AU(Ir,_.stateNode));break;case 4:N=Ir,R=ds,Ir=_.stateNode.containerInfo,ds=!0,Ec(h,g,_),Ir=N,ds=R;break;case 0:case 11:case 14:case 15:Hu(2,_,g),wi||Hu(4,_,g),Ec(h,g,_);break;case 1:wi||(Sl(_,g),N=_.stateNode,typeof N.componentWillUnmount=="function"&&T5(_,g,N)),Ec(h,g,_);break;case 21:Ec(h,g,_);break;case 22:wi=(N=wi)||_.memoizedState!==null,Ec(h,g,_),wi=N;break;default:Ec(h,g,_)}}function L5(h,g){if(g.memoizedState===null&&(h=g.alternate,h!==null&&(h=h.memoizedState,h!==null))){h=h.dehydrated;try{Zm(h)}catch(_){ar(g,g.return,_)}}}function I5(h,g){if(g.memoizedState===null&&(h=g.alternate,h!==null&&(h=h.memoizedState,h!==null&&(h=h.dehydrated,h!==null))))try{Zm(h)}catch(_){ar(g,g.return,_)}}function nse(h){switch(h.tag){case 31:case 13:case 19:var g=h.stateNode;return g===null&&(g=h.stateNode=new P5),g;case 22:return h=h.stateNode,g=h._retryCache,g===null&&(g=h._retryCache=new P5),g;default:throw Error(r(435,h.tag))}}function $v(h,g){var _=nse(h);g.forEach(function(N){if(!_.has(N)){_.add(N);var R=dse.bind(null,h,N);N.then(R,R)}})}function hs(h,g){var _=g.deletions;if(_!==null)for(var N=0;N<_.length;N++){var R=_[N],F=h,Z=g,pe=Z;e:for(;pe!==null;){switch(pe.tag){case 27:if(Yu(pe.type)){Ir=pe.stateNode,ds=!1;break e}break;case 5:Ir=pe.stateNode,ds=!1;break e;case 3:case 4:Ir=pe.stateNode.containerInfo,ds=!0;break e}pe=pe.return}if(Ir===null)throw Error(r(160));O5(F,Z,R),Ir=null,ds=!1,F=R.alternate,F!==null&&(F.return=null),R.return=null}if(g.subtreeFlags&13886)for(g=g.child;g!==null;)F5(g,h),g=g.sibling}var Vo=null;function F5(h,g){var _=h.alternate,N=h.flags;switch(h.tag){case 0:case 11:case 14:case 15:hs(g,h),fs(h),N&4&&(Hu(3,h,h.return),Vx(3,h),Hu(5,h,h.return));break;case 1:hs(g,h),fs(h),N&512&&(wi||_===null||Sl(_,_.return)),N&64&&Nc&&(h=h.updateQueue,h!==null&&(N=h.callbacks,N!==null&&(_=h.shared.hiddenCallbacks,h.shared.hiddenCallbacks=_===null?N:_.concat(N))));break;case 26:var R=Vo;if(hs(g,h),fs(h),N&512&&(wi||_===null||Sl(_,_.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,R=R.ownerDocument||R;t:switch(N){case"title":F=R.getElementsByTagName("title")[0],(!F||F[ct]||F[sn]||F.namespaceURI==="http://www.w3.org/2000/svg"||F.hasAttribute("itemprop"))&&(F=R.createElement(N),R.head.insertBefore(F,R.querySelector("head > title"))),ma(F,N,_),F[sn]=h,ue(F),N=F;break e;case"link":var Z=FU("link","href",R).get(N+(_.href||""));if(Z){for(var pe=0;pe<Z.length;pe++)if(F=Z[pe],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)){Z.splice(pe,1);break t}}F=R.createElement(N),ma(F,N,_),R.head.appendChild(F);break;case"meta":if(Z=FU("meta","content",R).get(N+(_.content||""))){for(pe=0;pe<Z.length;pe++)if(F=Z[pe],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)){Z.splice(pe,1);break t}}F=R.createElement(N),ma(F,N,_),R.head.appendChild(F);break;default:throw Error(r(468,N))}F[sn]=h,ue(F),N=F}h.stateNode=N}else UU(R,h.type,h.stateNode);else h.stateNode=IU(R,N,h.memoizedProps);else F!==N?(F===null?_.stateNode!==null&&(_=_.stateNode,_.parentNode.removeChild(_)):F.count--,N===null?UU(R,h.type,h.stateNode):IU(R,N,h.memoizedProps)):N===null&&h.stateNode!==null&&aA(h,h.memoizedProps,_.memoizedProps)}break;case 27:hs(g,h),fs(h),N&512&&(wi||_===null||Sl(_,_.return)),_!==null&&N&4&&aA(h,h.memoizedProps,_.memoizedProps);break;case 5:if(hs(g,h),fs(h),N&512&&(wi||_===null||Sl(_,_.return)),h.flags&32){R=h.stateNode;try{Lr(R,"")}catch(Zt){ar(h,h.return,Zt)}}N&4&&h.stateNode!=null&&(R=h.memoizedProps,aA(h,R,_!==null?_.memoizedProps:R)),N&1024&&(lA=!0);break;case 6:if(hs(g,h),fs(h),N&4){if(h.stateNode===null)throw Error(r(162));N=h.memoizedProps,_=h.stateNode;try{_.nodeValue=N}catch(Zt){ar(h,h.return,Zt)}}break;case 3:if(i_=null,R=Vo,Vo=n_(g.containerInfo),hs(g,h),Vo=R,fs(h),N&4&&_!==null&&_.memoizedState.isDehydrated)try{Zm(g.containerInfo)}catch(Zt){ar(h,h.return,Zt)}lA&&(lA=!1,U5(h));break;case 4:N=Vo,Vo=n_(h.stateNode.containerInfo),hs(g,h),fs(h),Vo=N;break;case 12:hs(g,h),fs(h);break;case 31:hs(g,h),fs(h),N&4&&(N=h.updateQueue,N!==null&&(h.updateQueue=null,$v(h,N)));break;case 13:hs(g,h),fs(h),h.child.flags&8192&&h.memoizedState!==null!=(_!==null&&_.memoizedState!==null)&&(Vv=j()),N&4&&(N=h.updateQueue,N!==null&&(h.updateQueue=null,$v(h,N)));break;case 22:R=h.memoizedState!==null;var De=_!==null&&_.memoizedState!==null,it=Nc,xt=wi;if(Nc=it||R,wi=xt||De,hs(g,h),wi=xt,Nc=it,fs(h),N&8192)e:for(g=h.stateNode,g._visibility=R?g._visibility&-2:g._visibility|1,R&&(_===null||De||Nc||wi||Uh(h)),_=null,g=h;;){if(g.tag===5||g.tag===26){if(_===null){De=_=g;try{if(F=De.stateNode,R)Z=F.style,typeof Z.setProperty=="function"?Z.setProperty("display","none","important"):Z.display="none";else{pe=De.stateNode;var vt=De.memoizedProps.style,st=vt!=null&&vt.hasOwnProperty("display")?vt.display:null;pe.style.display=st==null||typeof st=="boolean"?"":(""+st).trim()}}catch(Zt){ar(De,De.return,Zt)}}}else if(g.tag===6){if(_===null){De=g;try{De.stateNode.nodeValue=R?"":De.memoizedProps}catch(Zt){ar(De,De.return,Zt)}}}else if(g.tag===18){if(_===null){De=g;try{var ft=De.stateNode;R?TU(ft,!0):TU(De.stateNode,!1)}catch(Zt){ar(De,De.return,Zt)}}}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,$v(h,_))));break;case 19:hs(g,h),fs(h),N&4&&(N=h.updateQueue,N!==null&&(h.updateQueue=null,$v(h,N)));break;case 30:break;case 21:break;default:hs(g,h),fs(h)}}function fs(h){var g=h.flags;if(g&2){try{for(var _,N=h.return;N!==null;){if(k5(N)){_=N;break}N=N.return}if(_==null)throw Error(r(160));switch(_.tag){case 27:var R=_.stateNode,F=sA(h);Bv(h,F,R);break;case 5:var Z=_.stateNode;_.flags&32&&(Lr(Z,""),_.flags&=-33);var pe=sA(h);Bv(h,pe,Z);break;case 3:case 4:var De=_.stateNode.containerInfo,it=sA(h);oA(h,it,De);break;default:throw Error(r(161))}}catch(xt){ar(h,h.return,xt)}h.flags&=-3}g&4096&&(h.flags&=-4097)}function U5(h){if(h.subtreeFlags&1024)for(h=h.child;h!==null;){var g=h;U5(g),g.tag===5&&g.flags&1024&&g.stateNode.reset(),h=h.sibling}}function Ac(h,g){if(g.subtreeFlags&8772)for(g=g.child;g!==null;)R5(h,g.alternate,g),g=g.sibling}function Uh(h){for(h=h.child;h!==null;){var g=h;switch(g.tag){case 0:case 11:case 14:case 15:Hu(4,g,g.return),Uh(g);break;case 1:Sl(g,g.return);var _=g.stateNode;typeof _.componentWillUnmount=="function"&&T5(g,g.return,_),Uh(g);break;case 27:eb(g.stateNode);case 26:case 5:Sl(g,g.return),Uh(g);break;case 22:g.memoizedState===null&&Uh(g);break;case 30:Uh(g);break;default:Uh(g)}h=h.sibling}}function Tc(h,g,_){for(_=_&&(g.subtreeFlags&8772)!==0,g=g.child;g!==null;){var N=g.alternate,R=h,F=g,Z=F.flags;switch(F.tag){case 0:case 11:case 15:Tc(R,F,_),Vx(4,F);break;case 1:if(Tc(R,F,_),N=F,R=N.stateNode,typeof R.componentDidMount=="function")try{R.componentDidMount()}catch(it){ar(N,N.return,it)}if(N=F,R=N.updateQueue,R!==null){var pe=N.stateNode;try{var De=R.shared.hiddenCallbacks;if(De!==null)for(R.shared.hiddenCallbacks=null,R=0;R<De.length;R++)gF(De[R],pe)}catch(it){ar(N,N.return,it)}}_&&Z&64&&A5(F),Gx(F,F.return);break;case 27:j5(F);case 26:case 5:Tc(R,F,_),_&&N===null&&Z&4&&C5(F),Gx(F,F.return);break;case 12:Tc(R,F,_);break;case 31:Tc(R,F,_),_&&Z&4&&L5(R,F);break;case 13:Tc(R,F,_),_&&Z&4&&I5(R,F);break;case 22:F.memoizedState===null&&Tc(R,F,_),Gx(F,F.return);break;case 30:break;default:Tc(R,F,_)}g=g.sibling}}function cA(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&&jx(_))}function uA(h,g){h=null,g.alternate!==null&&(h=g.alternate.memoizedState.cache),g=g.memoizedState.cache,g!==h&&(g.refCount++,h!=null&&jx(h))}function Go(h,g,_,N){if(g.subtreeFlags&10256)for(g=g.child;g!==null;)z5(h,g,_,N),g=g.sibling}function z5(h,g,_,N){var R=g.flags;switch(g.tag){case 0:case 11:case 15:Go(h,g,_,N),R&2048&&Vx(9,g);break;case 1:Go(h,g,_,N);break;case 3:Go(h,g,_,N),R&2048&&(h=null,g.alternate!==null&&(h=g.alternate.memoizedState.cache),g=g.memoizedState.cache,g!==h&&(g.refCount++,h!=null&&jx(h)));break;case 12:if(R&2048){Go(h,g,_,N),h=g.stateNode;try{var F=g.memoizedProps,Z=F.id,pe=F.onPostCommit;typeof pe=="function"&&pe(Z,g.alternate===null?"mount":"update",h.passiveEffectDuration,-0)}catch(De){ar(g,g.return,De)}}else Go(h,g,_,N);break;case 31:Go(h,g,_,N);break;case 13:Go(h,g,_,N);break;case 23:break;case 22:F=g.stateNode,Z=g.alternate,g.memoizedState!==null?F._visibility&2?Go(h,g,_,N):Wx(h,g):F._visibility&2?Go(h,g,_,N):(F._visibility|=2,zm(h,g,_,N,(g.subtreeFlags&10256)!==0||!1)),R&2048&&cA(Z,g);break;case 24:Go(h,g,_,N),R&2048&&uA(g.alternate,g);break;default:Go(h,g,_,N)}}function zm(h,g,_,N,R){for(R=R&&((g.subtreeFlags&10256)!==0||!1),g=g.child;g!==null;){var F=h,Z=g,pe=_,De=N,it=Z.flags;switch(Z.tag){case 0:case 11:case 15:zm(F,Z,pe,De,R),Vx(8,Z);break;case 23:break;case 22:var xt=Z.stateNode;Z.memoizedState!==null?xt._visibility&2?zm(F,Z,pe,De,R):Wx(F,Z):(xt._visibility|=2,zm(F,Z,pe,De,R)),R&&it&2048&&cA(Z.alternate,Z);break;case 24:zm(F,Z,pe,De,R),R&&it&2048&&uA(Z.alternate,Z);break;default:zm(F,Z,pe,De,R)}g=g.sibling}}function Wx(h,g){if(g.subtreeFlags&10256)for(g=g.child;g!==null;){var _=h,N=g,R=N.flags;switch(N.tag){case 22:Wx(_,N),R&2048&&cA(N.alternate,N);break;case 24:Wx(_,N),R&2048&&uA(N.alternate,N);break;default:Wx(_,N)}g=g.sibling}}var qx=8192;function Bm(h,g,_){if(h.subtreeFlags&qx)for(h=h.child;h!==null;)B5(h,g,_),h=h.sibling}function B5(h,g,_){switch(h.tag){case 26:Bm(h,g,_),h.flags&qx&&h.memoizedState!==null&&$se(_,Vo,h.memoizedState,h.memoizedProps);break;case 5:Bm(h,g,_);break;case 3:case 4:var N=Vo;Vo=n_(h.stateNode.containerInfo),Bm(h,g,_),Vo=N;break;case 22:h.memoizedState===null&&(N=h.alternate,N!==null&&N.memoizedState!==null?(N=qx,qx=16777216,Bm(h,g,_),qx=N):Bm(h,g,_));break;default:Bm(h,g,_)}}function $5(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 Kx(h){var g=h.deletions;if((h.flags&16)!==0){if(g!==null)for(var _=0;_<g.length;_++){var N=g[_];Wi=N,V5(N,h)}$5(h)}if(h.subtreeFlags&10256)for(h=h.child;h!==null;)H5(h),h=h.sibling}function H5(h){switch(h.tag){case 0:case 11:case 15:Kx(h),h.flags&2048&&Hu(9,h,h.return);break;case 3:Kx(h);break;case 12:Kx(h);break;case 22:var g=h.stateNode;h.memoizedState!==null&&g._visibility&2&&(h.return===null||h.return.tag!==13)?(g._visibility&=-3,Hv(h)):Kx(h);break;default:Kx(h)}}function Hv(h){var g=h.deletions;if((h.flags&16)!==0){if(g!==null)for(var _=0;_<g.length;_++){var N=g[_];Wi=N,V5(N,h)}$5(h)}for(h=h.child;h!==null;){switch(g=h,g.tag){case 0:case 11:case 15:Hu(8,g,g.return),Hv(g);break;case 22:_=g.stateNode,_._visibility&2&&(_._visibility&=-3,Hv(g));break;default:Hv(g)}h=h.sibling}}function V5(h,g){for(;Wi!==null;){var _=Wi;switch(_.tag){case 0:case 11:case 15:Hu(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:jx(_.memoizedState.cache)}if(N=_.child,N!==null)N.return=_,Wi=N;else e:for(_=h;Wi!==null;){N=Wi;var R=N.sibling,F=N.return;if(D5(N),N===_){Wi=null;break e}if(R!==null){R.return=F,Wi=R;break e}Wi=F}}}var rse={getCacheForType:function(h){var g=ha(yi),_=g.data.get(h);return _===void 0&&(_=h(),g.data.set(h,_)),_},cacheSignal:function(){return ha(yi).controller.signal}},ise=typeof WeakMap=="function"?WeakMap:Map,Jn=0,vr=null,Pn=null,In=0,ir=0,Os=null,Vu=!1,$m=!1,dA=!1,Cc=0,Jr=0,Gu=0,zh=0,hA=0,Ls=0,Hm=0,Xx=null,ms=null,fA=!1,Vv=0,G5=0,Gv=1/0,Wv=null,Wu=null,ji=0,qu=null,Vm=null,kc=0,mA=0,pA=null,W5=null,Yx=0,gA=null;function Is(){return(Jn&2)!==0&&In!==0?In&-In:K.T!==null?wA():Pr()}function q5(){if(Ls===0)if((In&536870912)===0||zn){var h=xe;xe<<=1,(xe&3932160)===0&&(xe=262144),Ls=h}else Ls=536870912;return h=Rs.current,h!==null&&(h.flags|=32),Ls}function ps(h,g,_){(h===vr&&(ir===2||ir===9)||h.cancelPendingCommit!==null)&&(Gm(h,0),Ku(h,In,Ls,!1)),ln(h,_),((Jn&2)===0||h!==vr)&&(h===vr&&((Jn&2)===0&&(zh|=_),Jr===4&&Ku(h,In,Ls,!1)),Ml(h))}function K5(h,g,_){if((Jn&6)!==0)throw Error(r(327));var N=!_&&(g&127)===0&&(g&h.expiredLanes)===0||We(h,g),R=N?ose(h,g):bA(h,g,!0),F=N;do{if(R===0){$m&&!N&&Ku(h,g,0,!1);break}else{if(_=h.current.alternate,F&&!ase(_)){R=bA(h,g,!1),F=!1;continue}if(R===2){if(F=g,h.errorRecoveryDisabledLanes&F)var Z=0;else Z=h.pendingLanes&-536870913,Z=Z!==0?Z:Z&536870912?536870912:0;if(Z!==0){g=Z;e:{var pe=h;R=Xx;var De=pe.current.memoizedState.isDehydrated;if(De&&(Gm(pe,Z).flags|=256),Z=bA(pe,Z,!1),Z!==2){if(dA&&!De){pe.errorRecoveryDisabledLanes|=F,zh|=F,R=4;break e}F=ms,ms=R,F!==null&&(ms===null?ms=F:ms.push.apply(ms,F))}R=Z}if(F=!1,R!==2)continue}}if(R===1){Gm(h,0),Ku(h,g,0,!0);break}e:{switch(N=h,F=R,F){case 0:case 1:throw Error(r(345));case 4:if((g&4194048)!==g)break;case 6:Ku(N,g,Ls,!Vu);break e;case 2:ms=null;break;case 3:case 5:break;default:throw Error(r(329))}if((g&62914560)===g&&(R=Vv+300-j(),10<R)){if(Ku(N,g,Ls,!Vu),Ce(N,0,!0)!==0)break e;kc=g,N.timeoutHandle=NU(X5.bind(null,N,_,ms,Wv,fA,g,Ls,zh,Hm,Vu,F,"Throttled",-0,0),R);break e}X5(N,_,ms,Wv,fA,g,Ls,zh,Hm,Vu,F,null,-0,0)}}break}while(!0);Ml(h)}function X5(h,g,_,N,R,F,Z,pe,De,it,xt,vt,st,ft){if(h.timeoutHandle=-1,vt=g.subtreeFlags,vt&8192||(vt&16785408)===16785408){vt={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:pc},B5(g,F,vt);var Zt=(F&62914560)===F?Vv-j():(F&4194048)===F?G5-j():0;if(Zt=Hse(vt,Zt),Zt!==null){kc=F,h.cancelPendingCommit=Zt(rU.bind(null,h,g,F,_,N,R,Z,pe,De,xt,vt,null,st,ft)),Ku(h,F,Z,!it);return}}rU(h,g,F,_,N,R,Z,pe,De)}function ase(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 R=_[N],F=R.getSnapshot;R=R.value;try{if(!js(F(),R))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 Ku(h,g,_,N){g&=~hA,g&=~zh,h.suspendedLanes|=g,h.pingedLanes&=~g,N&&(h.warmLanes|=g),N=h.expirationTimes;for(var R=g;0<R;){var F=31-Me(R),Z=1<<F;N[F]=-1,R&=~Z}_!==0&&_n(h,_,g)}function qv(){return(Jn&6)===0?(Zx(0),!1):!0}function xA(){if(Pn!==null){if(ir===0)var h=Pn.return;else h=Pn,yc=jh=null,R2(h),Om=null,Rx=0,h=Pn;for(;h!==null;)E5(h.alternate,h),h=h.return;Pn=null}}function Gm(h,g){var _=h.timeoutHandle;_!==-1&&(h.timeoutHandle=-1,Nse(_)),_=h.cancelPendingCommit,_!==null&&(h.cancelPendingCommit=null,_()),kc=0,xA(),vr=h,Pn=_=xc(h.current,null),In=g,ir=0,Os=null,Vu=!1,$m=We(h,g),dA=!1,Hm=Ls=hA=zh=Gu=Jr=0,ms=Xx=null,fA=!1,(g&8)!==0&&(g|=g&32);var N=h.entangledLanes;if(N!==0)for(h=h.entanglements,N&=g;0<N;){var R=31-Me(N),F=1<<R;g|=h[R],N&=~F}return Cc=g,mv(),_}function Y5(h,g){yn=null,K.H=Bx,g===Dm||g===wv?(g=hF(),ir=3):g===_2?(g=hF(),ir=4):ir=g===X2?8:g!==null&&typeof g=="object"&&typeof g.then=="function"?6:1,Os=g,Pn===null&&(Jr=1,Lv(h,io(g,h.current)))}function Z5(){var h=Rs.current;return h===null?!0:(In&4194048)===In?lo===null:(In&62914560)===In||(In&536870912)!==0?h===lo:!1}function Q5(){var h=K.H;return K.H=Bx,h===null?Bx:h}function J5(){var h=K.A;return K.A=rse,h}function Kv(){Jr=4,Vu||(In&4194048)!==In&&Rs.current!==null||($m=!0),(Gu&134217727)===0&&(zh&134217727)===0||vr===null||Ku(vr,In,Ls,!1)}function bA(h,g,_){var N=Jn;Jn|=2;var R=Q5(),F=J5();(vr!==h||In!==g)&&(Wv=null,Gm(h,g)),g=!1;var Z=Jr;e:do try{if(ir!==0&&Pn!==null){var pe=Pn,De=Os;switch(ir){case 8:xA(),Z=6;break e;case 3:case 2:case 9:case 6:Rs.current===null&&(g=!0);var it=ir;if(ir=0,Os=null,Wm(h,pe,De,it),_&&$m){Z=0;break e}break;default:it=ir,ir=0,Os=null,Wm(h,pe,De,it)}}sse(),Z=Jr;break}catch(xt){Y5(h,xt)}while(!0);return g&&h.shellSuspendCounter++,yc=jh=null,Jn=N,K.H=R,K.A=F,Pn===null&&(vr=null,In=0,mv()),Z}function sse(){for(;Pn!==null;)eU(Pn)}function ose(h,g){var _=Jn;Jn|=2;var N=Q5(),R=J5();vr!==h||In!==g?(Wv=null,Gv=j()+500,Gm(h,g)):$m=We(h,g);e:do try{if(ir!==0&&Pn!==null){g=Pn;var F=Os;t:switch(ir){case 1:ir=0,Os=null,Wm(h,g,F,1);break;case 2:case 9:if(uF(F)){ir=0,Os=null,tU(g);break}g=function(){ir!==2&&ir!==9||vr!==h||(ir=7),Ml(h)},F.then(g,g);break e;case 3:ir=7;break e;case 4:ir=5;break e;case 7:uF(F)?(ir=0,Os=null,tU(g)):(ir=0,Os=null,Wm(h,g,F,7));break;case 5:var Z=null;switch(Pn.tag){case 26:Z=Pn.memoizedState;case 5:case 27:var pe=Pn;if(Z?zU(Z):pe.stateNode.complete){ir=0,Os=null;var De=pe.sibling;if(De!==null)Pn=De;else{var it=pe.return;it!==null?(Pn=it,Xv(it)):Pn=null}break t}}ir=0,Os=null,Wm(h,g,F,5);break;case 6:ir=0,Os=null,Wm(h,g,F,6);break;case 8:xA(),Jr=6;break e;default:throw Error(r(462))}}lse();break}catch(xt){Y5(h,xt)}while(!0);return yc=jh=null,K.H=N,K.A=R,Jn=_,Pn!==null?0:(vr=null,In=0,mv(),Jr)}function lse(){for(;Pn!==null&&!Ee();)eU(Pn)}function eU(h){var g=M5(h.alternate,h,Cc);h.memoizedProps=h.pendingProps,g===null?Xv(h):Pn=g}function tU(h){var g=h,_=g.alternate;switch(g.tag){case 15:case 0:g=b5(_,g,g.pendingProps,g.type,void 0,In);break;case 11:g=b5(_,g,g.pendingProps,g.type.render,g.ref,In);break;case 5:R2(g);default:E5(_,g),g=Pn=JI(g,Cc),g=M5(_,g,Cc)}h.memoizedProps=h.pendingProps,g===null?Xv(h):Pn=g}function Wm(h,g,_,N){yc=jh=null,R2(g),Om=null,Rx=0;var R=g.return;try{if(Yae(h,R,g,_,In)){Jr=1,Lv(h,io(_,h.current)),Pn=null;return}}catch(F){if(R!==null)throw Pn=R,F;Jr=1,Lv(h,io(_,h.current)),Pn=null;return}g.flags&32768?(zn||N===1?h=!0:$m||(In&536870912)!==0?h=!1:(Vu=h=!0,(N===2||N===9||N===3||N===6)&&(N=Rs.current,N!==null&&N.tag===13&&(N.flags|=16384))),nU(g,h)):Xv(g)}function Xv(h){var g=h;do{if((g.flags&32768)!==0){nU(g,Vu);return}h=g.return;var _=Jae(g.alternate,g,Cc);if(_!==null){Pn=_;return}if(g=g.sibling,g!==null){Pn=g;return}Pn=g=h}while(g!==null);Jr===0&&(Jr=5)}function nU(h,g){do{var _=ese(h.alternate,h);if(_!==null){_.flags&=32767,Pn=_;return}if(_=h.return,_!==null&&(_.flags|=32768,_.subtreeFlags=0,_.deletions=null),!g&&(h=h.sibling,h!==null)){Pn=h;return}Pn=h=_}while(h!==null);Jr=6,Pn=null}function rU(h,g,_,N,R,F,Z,pe,De){h.cancelPendingCommit=null;do Yv();while(ji!==0);if((Jn&6)!==0)throw Error(r(327));if(g!==null){if(g===h.current)throw Error(r(177));if(F=g.lanes|g.childLanes,F|=s2,Gt(h,_,F,Z,pe,De),h===vr&&(Pn=vr=null,In=0),Vm=g,qu=h,kc=_,mA=F,pA=R,W5=N,(g.subtreeFlags&10256)!==0||(g.flags&10256)!==0?(h.callbackNode=null,h.callbackPriority=0,hse(ve,function(){return lU(),null})):(h.callbackNode=null,h.callbackPriority=0),N=(g.flags&13878)!==0,(g.subtreeFlags&13878)!==0||N){N=K.T,K.T=null,R=V.p,V.p=2,Z=Jn,Jn|=4;try{tse(h,g,_)}finally{Jn=Z,V.p=R,K.T=N}}ji=1,iU(),aU(),sU()}}function iU(){if(ji===1){ji=0;var h=qu,g=Vm,_=(g.flags&13878)!==0;if((g.subtreeFlags&13878)!==0||_){_=K.T,K.T=null;var N=V.p;V.p=2;var R=Jn;Jn|=4;try{F5(g,h);var F=kA,Z=VI(h.containerInfo),pe=F.focusedElem,De=F.selectionRange;if(Z!==pe&&pe&&pe.ownerDocument&&HI(pe.ownerDocument.documentElement,pe)){if(De!==null&&t2(pe)){var it=De.start,xt=De.end;if(xt===void 0&&(xt=it),"selectionStart"in pe)pe.selectionStart=it,pe.selectionEnd=Math.min(xt,pe.value.length);else{var vt=pe.ownerDocument||document,st=vt&&vt.defaultView||window;if(st.getSelection){var ft=st.getSelection(),Zt=pe.textContent.length,an=Math.min(De.start,Zt),dr=De.end===void 0?an:Math.min(De.end,Zt);!ft.extend&&an>dr&&(Z=dr,dr=an,an=Z);var Ye=$I(pe,an),ze=$I(pe,dr);if(Ye&&ze&&(ft.rangeCount!==1||ft.anchorNode!==Ye.node||ft.anchorOffset!==Ye.offset||ft.focusNode!==ze.node||ft.focusOffset!==ze.offset)){var nt=vt.createRange();nt.setStart(Ye.node,Ye.offset),ft.removeAllRanges(),an>dr?(ft.addRange(nt),ft.extend(ze.node,ze.offset)):(nt.setEnd(ze.node,ze.offset),ft.addRange(nt))}}}}for(vt=[],ft=pe;ft=ft.parentNode;)ft.nodeType===1&&vt.push({element:ft,left:ft.scrollLeft,top:ft.scrollTop});for(typeof pe.focus=="function"&&pe.focus(),pe=0;pe<vt.length;pe++){var bt=vt[pe];bt.element.scrollLeft=bt.left,bt.element.scrollTop=bt.top}}l_=!!CA,kA=CA=null}finally{Jn=R,V.p=N,K.T=_}}h.current=g,ji=2}}function aU(){if(ji===2){ji=0;var h=qu,g=Vm,_=(g.flags&8772)!==0;if((g.subtreeFlags&8772)!==0||_){_=K.T,K.T=null;var N=V.p;V.p=2;var R=Jn;Jn|=4;try{R5(h,g.alternate,g)}finally{Jn=R,V.p=N,K.T=_}}ji=3}}function sU(){if(ji===4||ji===3){ji=0,$();var h=qu,g=Vm,_=kc,N=W5;(g.subtreeFlags&10256)!==0||(g.flags&10256)!==0?ji=5:(ji=0,Vm=qu=null,oU(h,h.pendingLanes));var R=h.pendingLanes;if(R===0&&(Wu=null),At(_),g=g.stateNode,oe&&typeof oe.onCommitFiberRoot=="function")try{oe.onCommitFiberRoot(Qe,g,void 0,(g.current.flags&128)===128)}catch{}if(N!==null){g=K.T,R=V.p,V.p=2,K.T=null;try{for(var F=h.onRecoverableError,Z=0;Z<N.length;Z++){var pe=N[Z];F(pe.value,{componentStack:pe.stack})}}finally{K.T=g,V.p=R}}(kc&3)!==0&&Yv(),Ml(h),R=h.pendingLanes,(_&261930)!==0&&(R&42)!==0?h===gA?Yx++:(Yx=0,gA=h):Yx=0,Zx(0)}}function oU(h,g){(h.pooledCacheLanes&=g)===0&&(g=h.pooledCache,g!=null&&(h.pooledCache=null,jx(g)))}function Yv(){return iU(),aU(),sU(),lU()}function lU(){if(ji!==5)return!1;var h=qu,g=mA;mA=0;var _=At(kc),N=K.T,R=V.p;try{V.p=32>_?32:_,K.T=null,_=pA,pA=null;var F=qu,Z=kc;if(ji=0,Vm=qu=null,kc=0,(Jn&6)!==0)throw Error(r(331));var pe=Jn;if(Jn|=4,H5(F.current),z5(F,F.current,Z,_),Jn=pe,Zx(0,!1),oe&&typeof oe.onPostCommitFiberRoot=="function")try{oe.onPostCommitFiberRoot(Qe,F)}catch{}return!0}finally{V.p=R,K.T=N,oU(h,g)}}function cU(h,g,_){g=io(_,g),g=K2(h.stateNode,g,2),h=zu(h,g,2),h!==null&&(ln(h,2),Ml(h))}function ar(h,g,_){if(h.tag===3)cU(h,h,_);else for(;g!==null;){if(g.tag===3){cU(g,h,_);break}else if(g.tag===1){var N=g.stateNode;if(typeof g.type.getDerivedStateFromError=="function"||typeof N.componentDidCatch=="function"&&(Wu===null||!Wu.has(N))){h=io(_,h),_=u5(2),N=zu(g,_,2),N!==null&&(d5(_,N,g,h),ln(N,2),Ml(N));break}}g=g.return}}function yA(h,g,_){var N=h.pingCache;if(N===null){N=h.pingCache=new ise;var R=new Set;N.set(g,R)}else R=N.get(g),R===void 0&&(R=new Set,N.set(g,R));R.has(_)||(dA=!0,R.add(_),h=cse.bind(null,h,g,_),g.then(h,h))}function cse(h,g,_){var N=h.pingCache;N!==null&&N.delete(g),h.pingedLanes|=h.suspendedLanes&_,h.warmLanes&=~_,vr===h&&(In&_)===_&&(Jr===4||Jr===3&&(In&62914560)===In&&300>j()-Vv?(Jn&2)===0&&Gm(h,0):hA|=_,Hm===In&&(Hm=0)),Ml(h)}function uU(h,g){g===0&&(g=kt()),h=Th(h,g),h!==null&&(ln(h,g),Ml(h))}function use(h){var g=h.memoizedState,_=0;g!==null&&(_=g.retryLane),uU(h,_)}function dse(h,g){var _=0;switch(h.tag){case 31:case 13:var N=h.stateNode,R=h.memoizedState;R!==null&&(_=R.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),uU(h,_)}function hse(h,g){return Te(h,g)}var Zv=null,qm=null,vA=!1,Qv=!1,_A=!1,Xu=0;function Ml(h){h!==qm&&h.next===null&&(qm===null?Zv=qm=h:qm=qm.next=h),Qv=!0,vA||(vA=!0,mse())}function Zx(h,g){if(!_A&&Qv){_A=!0;do for(var _=!1,N=Zv;N!==null;){if(h!==0){var R=N.pendingLanes;if(R===0)var F=0;else{var Z=N.suspendedLanes,pe=N.pingedLanes;F=(1<<31-Me(42|h)+1)-1,F&=R&~(Z&~pe),F=F&201326741?F&201326741|1:F?F|2:0}F!==0&&(_=!0,mU(N,F))}else F=In,F=Ce(N,N===vr?F:0,N.cancelPendingCommit!==null||N.timeoutHandle!==-1),(F&3)===0||We(N,F)||(_=!0,mU(N,F));N=N.next}while(_);_A=!1}}function fse(){dU()}function dU(){Qv=vA=!1;var h=0;Xu!==0&&Mse()&&(h=Xu);for(var g=j(),_=null,N=Zv;N!==null;){var R=N.next,F=hU(N,g);F===0?(N.next=null,_===null?Zv=R:_.next=R,R===null&&(qm=_)):(_=N,(h!==0||(F&3)!==0)&&(Qv=!0)),N=R}ji!==0&&ji!==5||Zx(h),Xu!==0&&(Xu=0)}function hU(h,g){for(var _=h.suspendedLanes,N=h.pingedLanes,R=h.expirationTimes,F=h.pendingLanes&-62914561;0<F;){var Z=31-Me(F),pe=1<<Z,De=R[Z];De===-1?((pe&_)===0||(pe&N)!==0)&&(R[Z]=pt(pe,g)):De<=g&&(h.expiredLanes|=pe),F&=~pe}if(g=vr,_=In,_=Ce(h,h===g?_:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),N=h.callbackNode,_===0||h===g&&(ir===2||ir===9)||h.cancelPendingCommit!==null)return N!==null&&N!==null&&Le(N),h.callbackNode=null,h.callbackPriority=0;if((_&3)===0||We(h,_)){if(g=_&-_,g===h.callbackPriority)return g;switch(N!==null&&Le(N),At(_)){case 2:case 8:_=we;break;case 32:_=ve;break;case 268435456:_=Ie;break;default:_=ve}return N=fU.bind(null,h),_=Te(_,N),h.callbackPriority=g,h.callbackNode=_,g}return N!==null&&N!==null&&Le(N),h.callbackPriority=2,h.callbackNode=null,2}function fU(h,g){if(ji!==0&&ji!==5)return h.callbackNode=null,h.callbackPriority=0,null;var _=h.callbackNode;if(Yv()&&h.callbackNode!==_)return null;var N=In;return N=Ce(h,h===vr?N:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),N===0?null:(K5(h,N,g),hU(h,j()),h.callbackNode!=null&&h.callbackNode===_?fU.bind(null,h):null)}function mU(h,g){if(Yv())return null;K5(h,g,!0)}function mse(){Ese(function(){(Jn&6)!==0?Te(ge,fse):dU()})}function wA(){if(Xu===0){var h=Pm;h===0&&(h=je,je<<=1,(je&261888)===0&&(je=256)),Xu=h}return Xu}function pU(h){return h==null||typeof h=="symbol"||typeof h=="boolean"?null:typeof h=="function"?h:Gi(""+h)}function gU(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 pse(h,g,_,N,R){if(g==="submit"&&_&&_.stateNode===R){var F=pU((R[Rr]||null).action),Z=N.submitter;Z&&(g=(g=Z[Rr]||null)?pU(g.formAction):Z.getAttribute("formAction"),g!==null&&(F=g,Z=null));var pe=new uv("action","action",null,N,R);h.push({event:pe,listeners:[{instance:null,listener:function(){if(N.defaultPrevented){if(Xu!==0){var De=Z?gU(R,Z):new FormData(R);$2(_,{pending:!0,data:De,method:R.method,action:F},null,De)}}else typeof F=="function"&&(pe.preventDefault(),De=Z?gU(R,Z):new FormData(R),$2(_,{pending:!0,data:De,method:R.method,action:F},F,De))},currentTarget:R}]})}}for(var SA=0;SA<a2.length;SA++){var MA=a2[SA],gse=MA.toLowerCase(),xse=MA[0].toUpperCase()+MA.slice(1);Ho(gse,"on"+xse)}Ho(qI,"onAnimationEnd"),Ho(KI,"onAnimationIteration"),Ho(XI,"onAnimationStart"),Ho("dblclick","onDoubleClick"),Ho("focusin","onFocus"),Ho("focusout","onBlur"),Ho(Rae,"onTransitionRun"),Ho(Dae,"onTransitionStart"),Ho(Oae,"onTransitionCancel"),Ho(YI,"onTransitionEnd"),Ge("onMouseEnter",["mouseout","mouseover"]),Ge("onMouseLeave",["mouseout","mouseover"]),Ge("onPointerEnter",["pointerout","pointerover"]),Ge("onPointerLeave",["pointerout","pointerover"]),Xe("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Xe("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Xe("onBeforeInput",["compositionend","keypress","textInput","paste"]),Xe("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Xe("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Xe("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Qx="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(" "),bse=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Qx));function xU(h,g){g=(g&4)!==0;for(var _=0;_<h.length;_++){var N=h[_],R=N.event;N=N.listeners;e:{var F=void 0;if(g)for(var Z=N.length-1;0<=Z;Z--){var pe=N[Z],De=pe.instance,it=pe.currentTarget;if(pe=pe.listener,De!==F&&R.isPropagationStopped())break e;F=pe,R.currentTarget=it;try{F(R)}catch(xt){fv(xt)}R.currentTarget=null,F=De}else for(Z=0;Z<N.length;Z++){if(pe=N[Z],De=pe.instance,it=pe.currentTarget,pe=pe.listener,De!==F&&R.isPropagationStopped())break e;F=pe,R.currentTarget=it;try{F(R)}catch(xt){fv(xt)}R.currentTarget=null,F=De}}}}function Rn(h,g){var _=g[Dr];_===void 0&&(_=g[Dr]=new Set);var N=h+"__bubble";_.has(N)||(bU(g,h,2,!1),_.add(N))}function NA(h,g,_){var N=0;g&&(N|=4),bU(_,h,N,g)}var Jv="_reactListening"+Math.random().toString(36).slice(2);function EA(h){if(!h[Jv]){h[Jv]=!0,Re.forEach(function(_){_!=="selectionchange"&&(bse.has(_)||NA(_,!1,h),NA(_,!0,h))});var g=h.nodeType===9?h:h.ownerDocument;g===null||g[Jv]||(g[Jv]=!0,NA("selectionchange",!1,g))}}function bU(h,g,_,N){switch(qU(g)){case 2:var R=Wse;break;case 8:R=qse;break;default:R=BA}_=R.bind(null,g,_,h),R=void 0,!WE||g!=="touchstart"&&g!=="touchmove"&&g!=="wheel"||(R=!0),N?R!==void 0?h.addEventListener(g,_,{capture:!0,passive:R}):h.addEventListener(g,_,!0):R!==void 0?h.addEventListener(g,_,{passive:R}):h.addEventListener(g,_,!1)}function AA(h,g,_,N,R){var F=N;if((g&1)===0&&(g&2)===0&&N!==null)e:for(;;){if(N===null)return;var Z=N.tag;if(Z===3||Z===4){var pe=N.stateNode.containerInfo;if(pe===R)break;if(Z===4)for(Z=N.return;Z!==null;){var De=Z.tag;if((De===3||De===4)&&Z.stateNode.containerInfo===R)return;Z=Z.return}for(;pe!==null;){if(Z=jt(pe),Z===null)return;if(De=Z.tag,De===5||De===6||De===26||De===27){N=F=Z;continue e}pe=pe.parentNode}}N=N.return}SI(function(){var it=F,xt=VE(_),vt=[];e:{var st=ZI.get(h);if(st!==void 0){var ft=uv,Zt=h;switch(h){case"keypress":if(lv(_)===0)break e;case"keydown":case"keyup":ft=dae;break;case"focusin":Zt="focus",ft=YE;break;case"focusout":Zt="blur",ft=YE;break;case"beforeblur":case"afterblur":ft=YE;break;case"click":if(_.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ft=EI;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ft=Jie;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ft=mae;break;case qI:case KI:case XI:ft=nae;break;case YI:ft=gae;break;case"scroll":case"scrollend":ft=Zie;break;case"wheel":ft=bae;break;case"copy":case"cut":case"paste":ft=iae;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ft=TI;break;case"toggle":case"beforetoggle":ft=vae}var an=(g&4)!==0,dr=!an&&(h==="scroll"||h==="scrollend"),Ye=an?st!==null?st+"Capture":null:st;an=[];for(var ze=it,nt;ze!==null;){var bt=ze;if(nt=bt.stateNode,bt=bt.tag,bt!==5&&bt!==26&&bt!==27||nt===null||Ye===null||(bt=vx(ze,Ye),bt!=null&&an.push(Jx(ze,bt,nt))),dr)break;ze=ze.return}0<an.length&&(st=new ft(st,Zt,null,_,xt),vt.push({event:st,listeners:an}))}}if((g&7)===0){e:{if(st=h==="mouseover"||h==="pointerover",ft=h==="mouseout"||h==="pointerout",st&&_!==HE&&(Zt=_.relatedTarget||_.fromElement)&&(jt(Zt)||Zt[Gr]))break e;if((ft||st)&&(st=xt.window===xt?xt:(st=xt.ownerDocument)?st.defaultView||st.parentWindow:window,ft?(Zt=_.relatedTarget||_.toElement,ft=it,Zt=Zt?jt(Zt):null,Zt!==null&&(dr=a(Zt),an=Zt.tag,Zt!==dr||an!==5&&an!==27&&an!==6)&&(Zt=null)):(ft=null,Zt=it),ft!==Zt)){if(an=EI,bt="onMouseLeave",Ye="onMouseEnter",ze="mouse",(h==="pointerout"||h==="pointerover")&&(an=TI,bt="onPointerLeave",Ye="onPointerEnter",ze="pointer"),dr=ft==null?st:Xt(ft),nt=Zt==null?st:Xt(Zt),st=new an(bt,ze+"leave",ft,_,xt),st.target=dr,st.relatedTarget=nt,bt=null,jt(xt)===it&&(an=new an(Ye,ze+"enter",Zt,_,xt),an.target=nt,an.relatedTarget=dr,bt=an),dr=bt,ft&&Zt)t:{for(an=yse,Ye=ft,ze=Zt,nt=0,bt=Ye;bt;bt=an(bt))nt++;bt=0;for(var tn=ze;tn;tn=an(tn))bt++;for(;0<nt-bt;)Ye=an(Ye),nt--;for(;0<bt-nt;)ze=an(ze),bt--;for(;nt--;){if(Ye===ze||ze!==null&&Ye===ze.alternate){an=Ye;break t}Ye=an(Ye),ze=an(ze)}an=null}else an=null;ft!==null&&yU(vt,st,ft,an,!1),Zt!==null&&dr!==null&&yU(vt,dr,Zt,an,!0)}}e:{if(st=it?Xt(it):window,ft=st.nodeName&&st.nodeName.toLowerCase(),ft==="select"||ft==="input"&&st.type==="file")var Kn=LI;else if(DI(st))if(II)Kn=kae;else{Kn=Tae;var Jt=Aae}else ft=st.nodeName,!ft||ft.toLowerCase()!=="input"||st.type!=="checkbox"&&st.type!=="radio"?it&&Er(it.elementType)&&(Kn=LI):Kn=Cae;if(Kn&&(Kn=Kn(h,it))){OI(vt,Kn,_,xt);break e}Jt&&Jt(h,st,it),h==="focusout"&&it&&st.type==="number"&&it.memoizedProps.value!=null&&Qt(st,"number",st.value)}switch(Jt=it?Xt(it):window,h){case"focusin":(DI(Jt)||Jt.contentEditable==="true")&&(Mm=Jt,n2=it,Tx=null);break;case"focusout":Tx=n2=Mm=null;break;case"mousedown":r2=!0;break;case"contextmenu":case"mouseup":case"dragend":r2=!1,GI(vt,_,xt);break;case"selectionchange":if(Pae)break;case"keydown":case"keyup":GI(vt,_,xt)}var vn;if(QE)e:{switch(h){case"compositionstart":var Fn="onCompositionStart";break e;case"compositionend":Fn="onCompositionEnd";break e;case"compositionupdate":Fn="onCompositionUpdate";break e}Fn=void 0}else Sm?PI(h,_)&&(Fn="onCompositionEnd"):h==="keydown"&&_.keyCode===229&&(Fn="onCompositionStart");Fn&&(CI&&_.locale!=="ko"&&(Sm||Fn!=="onCompositionStart"?Fn==="onCompositionEnd"&&Sm&&(vn=MI()):(Ru=xt,qE="value"in Ru?Ru.value:Ru.textContent,Sm=!0)),Jt=e_(it,Fn),0<Jt.length&&(Fn=new AI(Fn,h,null,_,xt),vt.push({event:Fn,listeners:Jt}),vn?Fn.data=vn:(vn=RI(_),vn!==null&&(Fn.data=vn)))),(vn=wae?Sae(h,_):Mae(h,_))&&(Fn=e_(it,"onBeforeInput"),0<Fn.length&&(Jt=new AI("onBeforeInput","beforeinput",null,_,xt),vt.push({event:Jt,listeners:Fn}),Jt.data=vn)),pse(vt,h,it,_,xt)}xU(vt,g)})}function Jx(h,g,_){return{instance:h,listener:g,currentTarget:_}}function e_(h,g){for(var _=g+"Capture",N=[];h!==null;){var R=h,F=R.stateNode;if(R=R.tag,R!==5&&R!==26&&R!==27||F===null||(R=vx(h,_),R!=null&&N.unshift(Jx(h,R,F)),R=vx(h,g),R!=null&&N.push(Jx(h,R,F))),h.tag===3)return N;h=h.return}return[]}function yse(h){if(h===null)return null;do h=h.return;while(h&&h.tag!==5&&h.tag!==27);return h||null}function yU(h,g,_,N,R){for(var F=g._reactName,Z=[];_!==null&&_!==N;){var pe=_,De=pe.alternate,it=pe.stateNode;if(pe=pe.tag,De!==null&&De===N)break;pe!==5&&pe!==26&&pe!==27||it===null||(De=it,R?(it=vx(_,F),it!=null&&Z.unshift(Jx(_,it,De))):R||(it=vx(_,F),it!=null&&Z.push(Jx(_,it,De)))),_=_.return}Z.length!==0&&h.push({event:g,listeners:Z})}var vse=/\r\n?/g,_se=/\u0000|\uFFFD/g;function vU(h){return(typeof h=="string"?h:""+h).replace(vse,`
- `).replace(_se,"")}function _U(h,g){return g=vU(g),vU(h)===g}function ur(h,g,_,N,R,F){switch(_){case"children":typeof N=="string"?g==="body"||g==="textarea"&&N===""||Lr(h,N):(typeof N=="number"||typeof N=="bigint")&&g!=="body"&&Lr(h,""+N);break;case"className":Ot(h,"class",N);break;case"tabIndex":Ot(h,"tabindex",N);break;case"dir":case"role":case"viewBox":case"width":case"height":Ot(h,_,N);break;case"style":cs(h,N,F);break;case"data":if(g!=="object"){Ot(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=Gi(""+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"&&ur(h,g,"name",R.name,R,null),ur(h,g,"formEncType",R.formEncType,R,null),ur(h,g,"formMethod",R.formMethod,R,null),ur(h,g,"formTarget",R.formTarget,R,null)):(ur(h,g,"encType",R.encType,R,null),ur(h,g,"method",R.method,R,null),ur(h,g,"target",R.target,R,null)));if(N==null||typeof N=="symbol"||typeof N=="boolean"){h.removeAttribute(_);break}N=Gi(""+N),h.setAttribute(_,N);break;case"onClick":N!=null&&(h.onclick=pc);break;case"onScroll":N!=null&&Rn("scroll",h);break;case"onScrollEnd":N!=null&&Rn("scrollend",h);break;case"dangerouslySetInnerHTML":if(N!=null){if(typeof N!="object"||!("__html"in N))throw Error(r(61));if(_=N.__html,_!=null){if(R.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}_=Gi(""+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":Rn("beforetoggle",h),Rn("toggle",h),It(h,"popover",N);break;case"xlinkActuate":Ft(h,"http://www.w3.org/1999/xlink","xlink:actuate",N);break;case"xlinkArcrole":Ft(h,"http://www.w3.org/1999/xlink","xlink:arcrole",N);break;case"xlinkRole":Ft(h,"http://www.w3.org/1999/xlink","xlink:role",N);break;case"xlinkShow":Ft(h,"http://www.w3.org/1999/xlink","xlink:show",N);break;case"xlinkTitle":Ft(h,"http://www.w3.org/1999/xlink","xlink:title",N);break;case"xlinkType":Ft(h,"http://www.w3.org/1999/xlink","xlink:type",N);break;case"xmlBase":Ft(h,"http://www.w3.org/XML/1998/namespace","xml:base",N);break;case"xmlLang":Ft(h,"http://www.w3.org/XML/1998/namespace","xml:lang",N);break;case"xmlSpace":Ft(h,"http://www.w3.org/XML/1998/namespace","xml:space",N);break;case"is":It(h,"is",N);break;case"innerText":case"textContent":break;default:(!(2<_.length)||_[0]!=="o"&&_[0]!=="O"||_[1]!=="n"&&_[1]!=="N")&&(_=mc.get(_)||_,It(h,_,N))}}function TA(h,g,_,N,R,F){switch(_){case"style":cs(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(R.children!=null)throw Error(r(60));h.innerHTML=_}}break;case"children":typeof N=="string"?Lr(h,N):(typeof N=="number"||typeof N=="bigint")&&Lr(h,""+N);break;case"onScroll":N!=null&&Rn("scroll",h);break;case"onScrollEnd":N!=null&&Rn("scrollend",h);break;case"onClick":N!=null&&(h.onclick=pc);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!He.hasOwnProperty(_))e:{if(_[0]==="o"&&_[1]==="n"&&(R=_.endsWith("Capture"),g=_.slice(2,R?_.length-7:void 0),F=h[Rr]||null,F=F!=null?F[_]:null,typeof F=="function"&&h.removeEventListener(g,F,R),typeof N=="function")){typeof F!="function"&&F!==null&&(_ in h?h[_]=null:h.hasAttribute(_)&&h.removeAttribute(_)),h.addEventListener(g,N,R);break e}_ in h?h[_]=N:N===!0?h.setAttribute(_,""):It(h,_,N)}}}function ma(h,g,_){switch(g){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Rn("error",h),Rn("load",h);var N=!1,R=!1,F;for(F in _)if(_.hasOwnProperty(F)){var Z=_[F];if(Z!=null)switch(F){case"src":N=!0;break;case"srcSet":R=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,g));default:ur(h,g,F,Z,_,null)}}R&&ur(h,g,"srcSet",_.srcSet,_,null),N&&ur(h,g,"src",_.src,_,null);return;case"input":Rn("invalid",h);var pe=F=Z=R=null,De=null,it=null;for(N in _)if(_.hasOwnProperty(N)){var xt=_[N];if(xt!=null)switch(N){case"name":R=xt;break;case"type":Z=xt;break;case"checked":De=xt;break;case"defaultChecked":it=xt;break;case"value":F=xt;break;case"defaultValue":pe=xt;break;case"children":case"dangerouslySetInnerHTML":if(xt!=null)throw Error(r(137,g));break;default:ur(h,g,N,xt,_,null)}}bi(h,F,pe,De,it,Z,R,!1);return;case"select":Rn("invalid",h),N=Z=F=null;for(R in _)if(_.hasOwnProperty(R)&&(pe=_[R],pe!=null))switch(R){case"value":F=pe;break;case"defaultValue":Z=pe;break;case"multiple":N=pe;default:ur(h,g,R,pe,_,null)}g=F,_=Z,h.multiple=!!N,g!=null?cn(h,!!N,g,!1):_!=null&&cn(h,!!N,_,!0);return;case"textarea":Rn("invalid",h),F=R=N=null;for(Z in _)if(_.hasOwnProperty(Z)&&(pe=_[Z],pe!=null))switch(Z){case"value":N=pe;break;case"defaultValue":R=pe;break;case"children":F=pe;break;case"dangerouslySetInnerHTML":if(pe!=null)throw Error(r(91));break;default:ur(h,g,Z,pe,_,null)}Or(h,N,R,F);return;case"option":for(De in _)_.hasOwnProperty(De)&&(N=_[De],N!=null)&&(De==="selected"?h.selected=N&&typeof N!="function"&&typeof N!="symbol":ur(h,g,De,N,_,null));return;case"dialog":Rn("beforetoggle",h),Rn("toggle",h),Rn("cancel",h),Rn("close",h);break;case"iframe":case"object":Rn("load",h);break;case"video":case"audio":for(N=0;N<Qx.length;N++)Rn(Qx[N],h);break;case"image":Rn("error",h),Rn("load",h);break;case"details":Rn("toggle",h);break;case"embed":case"source":case"link":Rn("error",h),Rn("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(it in _)if(_.hasOwnProperty(it)&&(N=_[it],N!=null))switch(it){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,g));default:ur(h,g,it,N,_,null)}return;default:if(Er(g)){for(xt in _)_.hasOwnProperty(xt)&&(N=_[xt],N!==void 0&&TA(h,g,xt,N,_,void 0));return}}for(pe in _)_.hasOwnProperty(pe)&&(N=_[pe],N!=null&&ur(h,g,pe,N,_,null))}function wse(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 R=null,F=null,Z=null,pe=null,De=null,it=null,xt=null;for(ft in _){var vt=_[ft];if(_.hasOwnProperty(ft)&&vt!=null)switch(ft){case"checked":break;case"value":break;case"defaultValue":De=vt;default:N.hasOwnProperty(ft)||ur(h,g,ft,null,N,vt)}}for(var st in N){var ft=N[st];if(vt=_[st],N.hasOwnProperty(st)&&(ft!=null||vt!=null))switch(st){case"type":F=ft;break;case"name":R=ft;break;case"checked":it=ft;break;case"defaultChecked":xt=ft;break;case"value":Z=ft;break;case"defaultValue":pe=ft;break;case"children":case"dangerouslySetInnerHTML":if(ft!=null)throw Error(r(137,g));break;default:ft!==vt&&ur(h,g,st,ft,N,vt)}}Ln(h,Z,pe,De,it,xt,F,R);return;case"select":ft=Z=pe=st=null;for(F in _)if(De=_[F],_.hasOwnProperty(F)&&De!=null)switch(F){case"value":break;case"multiple":ft=De;default:N.hasOwnProperty(F)||ur(h,g,F,null,N,De)}for(R in N)if(F=N[R],De=_[R],N.hasOwnProperty(R)&&(F!=null||De!=null))switch(R){case"value":st=F;break;case"defaultValue":pe=F;break;case"multiple":Z=F;default:F!==De&&ur(h,g,R,F,N,De)}g=pe,_=Z,N=ft,st!=null?cn(h,!!_,st,!1):!!N!=!!_&&(g!=null?cn(h,!!_,g,!0):cn(h,!!_,_?[]:"",!1));return;case"textarea":ft=st=null;for(pe in _)if(R=_[pe],_.hasOwnProperty(pe)&&R!=null&&!N.hasOwnProperty(pe))switch(pe){case"value":break;case"children":break;default:ur(h,g,pe,null,N,R)}for(Z in N)if(R=N[Z],F=_[Z],N.hasOwnProperty(Z)&&(R!=null||F!=null))switch(Z){case"value":st=R;break;case"defaultValue":ft=R;break;case"children":break;case"dangerouslySetInnerHTML":if(R!=null)throw Error(r(91));break;default:R!==F&&ur(h,g,Z,R,N,F)}An(h,st,ft);return;case"option":for(var Zt in _)st=_[Zt],_.hasOwnProperty(Zt)&&st!=null&&!N.hasOwnProperty(Zt)&&(Zt==="selected"?h.selected=!1:ur(h,g,Zt,null,N,st));for(De in N)st=N[De],ft=_[De],N.hasOwnProperty(De)&&st!==ft&&(st!=null||ft!=null)&&(De==="selected"?h.selected=st&&typeof st!="function"&&typeof st!="symbol":ur(h,g,De,st,N,ft));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 _)st=_[an],_.hasOwnProperty(an)&&st!=null&&!N.hasOwnProperty(an)&&ur(h,g,an,null,N,st);for(it in N)if(st=N[it],ft=_[it],N.hasOwnProperty(it)&&st!==ft&&(st!=null||ft!=null))switch(it){case"children":case"dangerouslySetInnerHTML":if(st!=null)throw Error(r(137,g));break;default:ur(h,g,it,st,N,ft)}return;default:if(Er(g)){for(var dr in _)st=_[dr],_.hasOwnProperty(dr)&&st!==void 0&&!N.hasOwnProperty(dr)&&TA(h,g,dr,void 0,N,st);for(xt in N)st=N[xt],ft=_[xt],!N.hasOwnProperty(xt)||st===ft||st===void 0&&ft===void 0||TA(h,g,xt,st,N,ft);return}}for(var Ye in _)st=_[Ye],_.hasOwnProperty(Ye)&&st!=null&&!N.hasOwnProperty(Ye)&&ur(h,g,Ye,null,N,st);for(vt in N)st=N[vt],ft=_[vt],!N.hasOwnProperty(vt)||st===ft||st==null&&ft==null||ur(h,g,vt,st,N,ft)}function wU(h){switch(h){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Sse(){if(typeof performance.getEntriesByType=="function"){for(var h=0,g=0,_=performance.getEntriesByType("resource"),N=0;N<_.length;N++){var R=_[N],F=R.transferSize,Z=R.initiatorType,pe=R.duration;if(F&&pe&&wU(Z)){for(Z=0,pe=R.responseEnd,N+=1;N<_.length;N++){var De=_[N],it=De.startTime;if(it>pe)break;var xt=De.transferSize,vt=De.initiatorType;xt&&wU(vt)&&(De=De.responseEnd,Z+=xt*(De<pe?1:(pe-it)/(De-it)))}if(--N,g+=8*(F+Z)/(R.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 CA=null,kA=null;function t_(h){return h.nodeType===9?h:h.ownerDocument}function SU(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 MU(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 jA(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 PA=null;function Mse(){var h=window.event;return h&&h.type==="popstate"?h===PA?!1:(PA=h,!0):(PA=null,!1)}var NU=typeof setTimeout=="function"?setTimeout:void 0,Nse=typeof clearTimeout=="function"?clearTimeout:void 0,EU=typeof Promise=="function"?Promise:void 0,Ese=typeof queueMicrotask=="function"?queueMicrotask:typeof EU<"u"?function(h){return EU.resolve(null).then(h).catch(Ase)}:NU;function Ase(h){setTimeout(function(){throw h})}function Yu(h){return h==="head"}function AU(h,g){var _=g,N=0;do{var R=_.nextSibling;if(h.removeChild(_),R&&R.nodeType===8)if(_=R.data,_==="/$"||_==="/&"){if(N===0){h.removeChild(R),Zm(g);return}N--}else if(_==="$"||_==="$?"||_==="$~"||_==="$!"||_==="&")N++;else if(_==="html")eb(h.ownerDocument.documentElement);else if(_==="head"){_=h.ownerDocument.head,eb(_);for(var F=_.firstChild;F;){var Z=F.nextSibling,pe=F.nodeName;F[ct]||pe==="SCRIPT"||pe==="STYLE"||pe==="LINK"&&F.rel.toLowerCase()==="stylesheet"||_.removeChild(F),F=Z}}else _==="body"&&eb(h.ownerDocument.body);_=R}while(_);Zm(g)}function TU(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 RA(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":RA(_),rt(_);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(_.rel.toLowerCase()==="stylesheet")continue}h.removeChild(_)}}function Tse(h,g,_,N){for(;h.nodeType===1;){var R=_;if(h.nodeName.toLowerCase()!==g.toLowerCase()){if(!N&&(h.nodeName!=="INPUT"||h.type!=="hidden"))break}else if(N){if(!h[ct])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!==R.rel||h.getAttribute("href")!==(R.href==null||R.href===""?null:R.href)||h.getAttribute("crossorigin")!==(R.crossOrigin==null?null:R.crossOrigin)||h.getAttribute("title")!==(R.title==null?null:R.title))break;return h;case"style":if(h.hasAttribute("data-precedence"))break;return h;case"script":if(F=h.getAttribute("src"),(F!==(R.src==null?null:R.src)||h.getAttribute("type")!==(R.type==null?null:R.type)||h.getAttribute("crossorigin")!==(R.crossOrigin==null?null:R.crossOrigin))&&F&&h.hasAttribute("async")&&!h.hasAttribute("itemprop"))break;return h;default:return h}}else if(g==="input"&&h.type==="hidden"){var F=R.name==null?null:""+R.name;if(R.type==="hidden"&&h.getAttribute("name")===F)return h}else return h;if(h=co(h.nextSibling),h===null)break}return null}function Cse(h,g,_){if(g==="")return null;for(;h.nodeType!==3;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!_||(h=co(h.nextSibling),h===null))return null;return h}function CU(h,g){for(;h.nodeType!==8;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!g||(h=co(h.nextSibling),h===null))return null;return h}function DA(h){return h.data==="$?"||h.data==="$~"}function OA(h){return h.data==="$!"||h.data==="$?"&&h.ownerDocument.readyState!=="loading"}function kse(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 co(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 LA=null;function kU(h){h=h.nextSibling;for(var g=0;h;){if(h.nodeType===8){var _=h.data;if(_==="/$"||_==="/&"){if(g===0)return co(h.nextSibling);g--}else _!=="$"&&_!=="$!"&&_!=="$?"&&_!=="$~"&&_!=="&"||g++}h=h.nextSibling}return null}function jU(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 PU(h,g,_){switch(g=t_(_),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 eb(h){for(var g=h.attributes;g.length;)h.removeAttributeNode(g[0]);rt(h)}var uo=new Map,RU=new Set;function n_(h){return typeof h.getRootNode=="function"?h.getRootNode():h.nodeType===9?h:h.ownerDocument}var jc=V.d;V.d={f:jse,r:Pse,D:Rse,C:Dse,L:Ose,m:Lse,X:Fse,S:Ise,M:Use};function jse(){var h=jc.f(),g=qv();return h||g}function Pse(h){var g=zt(h);g!==null&&g.tag===5&&g.type==="form"?YF(g):jc.r(h)}var Km=typeof document>"u"?null:document;function DU(h,g,_){var N=Km;if(N&&typeof g=="string"&&g){var R=$t(g);R='link[rel="'+h+'"][href="'+R+'"]',typeof _=="string"&&(R+='[crossorigin="'+_+'"]'),RU.has(R)||(RU.add(R),h={rel:h,crossOrigin:_,href:g},N.querySelector(R)===null&&(g=N.createElement("link"),ma(g,"link",h),ue(g),N.head.appendChild(g)))}}function Rse(h){jc.D(h),DU("dns-prefetch",h,null)}function Dse(h,g){jc.C(h,g),DU("preconnect",h,g)}function Ose(h,g,_){jc.L(h,g,_);var N=Km;if(N&&h&&g){var R='link[rel="preload"][as="'+$t(g)+'"]';g==="image"&&_&&_.imageSrcSet?(R+='[imagesrcset="'+$t(_.imageSrcSet)+'"]',typeof _.imageSizes=="string"&&(R+='[imagesizes="'+$t(_.imageSizes)+'"]')):R+='[href="'+$t(h)+'"]';var F=R;switch(g){case"style":F=Xm(h);break;case"script":F=Ym(h)}uo.has(F)||(h=f({rel:"preload",href:g==="image"&&_&&_.imageSrcSet?void 0:h,as:g},_),uo.set(F,h),N.querySelector(R)!==null||g==="style"&&N.querySelector(tb(F))||g==="script"&&N.querySelector(nb(F))||(g=N.createElement("link"),ma(g,"link",h),ue(g),N.head.appendChild(g)))}}function Lse(h,g){jc.m(h,g);var _=Km;if(_&&h){var N=g&&typeof g.as=="string"?g.as:"script",R='link[rel="modulepreload"][as="'+$t(N)+'"][href="'+$t(h)+'"]',F=R;switch(N){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":F=Ym(h)}if(!uo.has(F)&&(h=f({rel:"modulepreload",href:h},g),uo.set(F,h),_.querySelector(R)===null)){switch(N){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(_.querySelector(nb(F)))return}N=_.createElement("link"),ma(N,"link",h),ue(N),_.head.appendChild(N)}}}function Ise(h,g,_){jc.S(h,g,_);var N=Km;if(N&&h){var R=Yt(N).hoistableStyles,F=Xm(h);g=g||"default";var Z=R.get(F);if(!Z){var pe={loading:0,preload:null};if(Z=N.querySelector(tb(F)))pe.loading=5;else{h=f({rel:"stylesheet",href:h,"data-precedence":g},_),(_=uo.get(F))&&IA(h,_);var De=Z=N.createElement("link");ue(De),ma(De,"link",h),De._p=new Promise(function(it,xt){De.onload=it,De.onerror=xt}),De.addEventListener("load",function(){pe.loading|=1}),De.addEventListener("error",function(){pe.loading|=2}),pe.loading|=4,r_(Z,g,N)}Z={type:"stylesheet",instance:Z,count:1,state:pe},R.set(F,Z)}}}function Fse(h,g){jc.X(h,g);var _=Km;if(_&&h){var N=Yt(_).hoistableScripts,R=Ym(h),F=N.get(R);F||(F=_.querySelector(nb(R)),F||(h=f({src:h,async:!0},g),(g=uo.get(R))&&FA(h,g),F=_.createElement("script"),ue(F),ma(F,"link",h),_.head.appendChild(F)),F={type:"script",instance:F,count:1,state:null},N.set(R,F))}}function Use(h,g){jc.M(h,g);var _=Km;if(_&&h){var N=Yt(_).hoistableScripts,R=Ym(h),F=N.get(R);F||(F=_.querySelector(nb(R)),F||(h=f({src:h,async:!0,type:"module"},g),(g=uo.get(R))&&FA(h,g),F=_.createElement("script"),ue(F),ma(F,"link",h),_.head.appendChild(F)),F={type:"script",instance:F,count:1,state:null},N.set(R,F))}}function OU(h,g,_,N){var R=(R=fe.current)?n_(R):null;if(!R)throw Error(r(446));switch(h){case"meta":case"title":return null;case"style":return typeof _.precedence=="string"&&typeof _.href=="string"?(g=Xm(_.href),_=Yt(R).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=Xm(_.href);var F=Yt(R).hoistableStyles,Z=F.get(h);if(Z||(R=R.ownerDocument||R,Z={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},F.set(h,Z),(F=R.querySelector(tb(h)))&&!F._p&&(Z.instance=F,Z.state.loading=5),uo.has(h)||(_={rel:"preload",as:"style",href:_.href,crossOrigin:_.crossOrigin,integrity:_.integrity,media:_.media,hrefLang:_.hrefLang,referrerPolicy:_.referrerPolicy},uo.set(h,_),F||zse(R,h,_,Z.state))),g&&N===null)throw Error(r(528,""));return Z}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=Ym(_),_=Yt(R).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 Xm(h){return'href="'+$t(h)+'"'}function tb(h){return'link[rel="stylesheet"]['+h+"]"}function LU(h){return f({},h,{"data-precedence":h.precedence,precedence:null})}function zse(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}),ma(g,"link",_),ue(g),h.head.appendChild(g))}function Ym(h){return'[src="'+$t(h)+'"]'}function nb(h){return"script[async]"+h}function IU(h,g,_){if(g.count++,g.instance===null)switch(g.type){case"style":var N=h.querySelector('style[data-href~="'+$t(_.href)+'"]');if(N)return g.instance=N,ue(N),N;var R=f({},_,{"data-href":_.href,"data-precedence":_.precedence,href:null,precedence:null});return N=(h.ownerDocument||h).createElement("style"),ue(N),ma(N,"style",R),r_(N,_.precedence,h),g.instance=N;case"stylesheet":R=Xm(_.href);var F=h.querySelector(tb(R));if(F)return g.state.loading|=4,g.instance=F,ue(F),F;N=LU(_),(R=uo.get(R))&&IA(N,R),F=(h.ownerDocument||h).createElement("link"),ue(F);var Z=F;return Z._p=new Promise(function(pe,De){Z.onload=pe,Z.onerror=De}),ma(F,"link",N),g.state.loading|=4,r_(F,_.precedence,h),g.instance=F;case"script":return F=Ym(_.src),(R=h.querySelector(nb(F)))?(g.instance=R,ue(R),R):(N=_,(R=uo.get(F))&&(N=f({},_),FA(N,R)),h=h.ownerDocument||h,R=h.createElement("script"),ue(R),ma(R,"link",N),h.head.appendChild(R),g.instance=R);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,r_(N,_.precedence,h));return g.instance}function r_(h,g,_){for(var N=_.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),R=N.length?N[N.length-1]:null,F=R,Z=0;Z<N.length;Z++){var pe=N[Z];if(pe.dataset.precedence===g)F=pe;else if(F!==R)break}F?F.parentNode.insertBefore(h,F.nextSibling):(g=_.nodeType===9?_.head:_,g.insertBefore(h,g.firstChild))}function IA(h,g){h.crossOrigin==null&&(h.crossOrigin=g.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=g.referrerPolicy),h.title==null&&(h.title=g.title)}function FA(h,g){h.crossOrigin==null&&(h.crossOrigin=g.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=g.referrerPolicy),h.integrity==null&&(h.integrity=g.integrity)}var i_=null;function FU(h,g,_){if(i_===null){var N=new Map,R=i_=new Map;R.set(_,N)}else R=i_,N=R.get(_),N||(N=new Map,R.set(_,N));if(N.has(h))return N;for(N.set(h,null),_=_.getElementsByTagName(h),R=0;R<_.length;R++){var F=_[R];if(!(F[ct]||F[sn]||h==="link"&&F.getAttribute("rel")==="stylesheet")&&F.namespaceURI!=="http://www.w3.org/2000/svg"){var Z=F.getAttribute(g)||"";Z=h+Z;var pe=N.get(Z);pe?pe.push(F):N.set(Z,[F])}}return N}function UU(h,g,_){h=h.ownerDocument||h,h.head.insertBefore(_,g==="title"?h.querySelector("head > title"):null)}function Bse(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 zU(h){return!(h.type==="stylesheet"&&(h.state.loading&3)===0)}function $se(h,g,_,N){if(_.type==="stylesheet"&&(typeof N.media!="string"||matchMedia(N.media).matches!==!1)&&(_.state.loading&4)===0){if(_.instance===null){var R=Xm(N.href),F=g.querySelector(tb(R));if(F){g=F._p,g!==null&&typeof g=="object"&&typeof g.then=="function"&&(h.count++,h=a_.bind(h),g.then(h,h)),_.state.loading|=4,_.instance=F,ue(F);return}F=g.ownerDocument||g,N=LU(N),(R=uo.get(R))&&IA(N,R),F=F.createElement("link"),ue(F);var Z=F;Z._p=new Promise(function(pe,De){Z.onload=pe,Z.onerror=De}),ma(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++,_=a_.bind(h),g.addEventListener("load",_),g.addEventListener("error",_))}}var UA=0;function Hse(h,g){return h.stylesheets&&h.count===0&&o_(h,h.stylesheets),0<h.count||0<h.imgCount?function(_){var N=setTimeout(function(){if(h.stylesheets&&o_(h,h.stylesheets),h.unsuspend){var F=h.unsuspend;h.unsuspend=null,F()}},6e4+g);0<h.imgBytes&&UA===0&&(UA=62500*Sse());var R=setTimeout(function(){if(h.waitingForImages=!1,h.count===0&&(h.stylesheets&&o_(h,h.stylesheets),h.unsuspend)){var F=h.unsuspend;h.unsuspend=null,F()}},(h.imgBytes>UA?50:800)+g);return h.unsuspend=_,function(){h.unsuspend=null,clearTimeout(N),clearTimeout(R)}}:null}function a_(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)o_(this,this.stylesheets);else if(this.unsuspend){var h=this.unsuspend;this.unsuspend=null,h()}}}var s_=null;function o_(h,g){h.stylesheets=null,h.unsuspend!==null&&(h.count++,s_=new Map,g.forEach(Vse,h),s_=null,a_.call(h))}function Vse(h,g){if(!(g.state.loading&4)){var _=s_.get(h);if(_)var N=_.get(null);else{_=new Map,s_.set(h,_);for(var R=h.querySelectorAll("link[data-precedence],style[data-precedence]"),F=0;F<R.length;F++){var Z=R[F];(Z.nodeName==="LINK"||Z.getAttribute("media")!=="not all")&&(_.set(Z.dataset.precedence,Z),N=Z)}N&&_.set(null,N)}R=g.instance,Z=R.getAttribute("data-precedence"),F=_.get(Z)||N,F===N&&_.set(null,R),_.set(Z,R),this.count++,N=a_.bind(this),R.addEventListener("load",N),R.addEventListener("error",N),F?F.parentNode.insertBefore(R,F.nextSibling):(h=h.nodeType===9?h.head:h,h.insertBefore(R,h.firstChild)),g.state.loading|=4}}var rb={$$typeof:M,Provider:null,Consumer:null,_currentValue:Q,_currentValue2:Q,_threadCount:0};function Gse(h,g,_,N,R,F,Z,pe,De){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=Lt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Lt(0),this.hiddenUpdates=Lt(null),this.identifierPrefix=N,this.onUncaughtError=R,this.onCaughtError=F,this.onRecoverableError=Z,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=De,this.incompleteTransitions=new Map}function BU(h,g,_,N,R,F,Z,pe,De,it,xt,vt){return h=new Gse(h,g,_,Z,De,it,xt,vt,pe),g=1,F===!0&&(g|=24),F=Ps(3,null,null,g),h.current=F,F.stateNode=h,g=b2(),g.refCount++,h.pooledCache=g,g.refCount++,F.memoizedState={element:N,isDehydrated:_,cache:g},w2(F),h}function $U(h){return h?(h=Am,h):Am}function HU(h,g,_,N,R,F){R=$U(R),N.context===null?N.context=R:N.pendingContext=R,N=Uu(g),N.payload={element:_},F=F===void 0?null:F,F!==null&&(N.callback=F),_=zu(h,N,g),_!==null&&(ps(_,h,g),Ox(_,h,g))}function VU(h,g){if(h=h.memoizedState,h!==null&&h.dehydrated!==null){var _=h.retryLane;h.retryLane=_!==0&&_<g?_:g}}function zA(h,g){VU(h,g),(h=h.alternate)&&VU(h,g)}function GU(h){if(h.tag===13||h.tag===31){var g=Th(h,67108864);g!==null&&ps(g,h,67108864),zA(h,67108864)}}function WU(h){if(h.tag===13||h.tag===31){var g=Is();g=bn(g);var _=Th(h,g);_!==null&&ps(_,h,g),zA(h,g)}}var l_=!0;function Wse(h,g,_,N){var R=K.T;K.T=null;var F=V.p;try{V.p=2,BA(h,g,_,N)}finally{V.p=F,K.T=R}}function qse(h,g,_,N){var R=K.T;K.T=null;var F=V.p;try{V.p=8,BA(h,g,_,N)}finally{V.p=F,K.T=R}}function BA(h,g,_,N){if(l_){var R=$A(N);if(R===null)AA(h,g,N,c_,_),KU(h,N);else if(Xse(R,h,g,_,N))N.stopPropagation();else if(KU(h,N),g&4&&-1<Kse.indexOf(h)){for(;R!==null;){var F=zt(R);if(F!==null)switch(F.tag){case 3:if(F=F.stateNode,F.current.memoizedState.isDehydrated){var Z=Ue(F.pendingLanes);if(Z!==0){var pe=F;for(pe.pendingLanes|=2,pe.entangledLanes|=2;Z;){var De=1<<31-Me(Z);pe.entanglements[1]|=De,Z&=~De}Ml(F),(Jn&6)===0&&(Gv=j()+500,Zx(0))}}break;case 31:case 13:pe=Th(F,2),pe!==null&&ps(pe,F,2),qv(),zA(F,2)}if(F=$A(N),F===null&&AA(h,g,N,c_,_),F===R)break;R=F}R!==null&&N.stopPropagation()}else AA(h,g,N,null,_)}}function $A(h){return h=VE(h),HA(h)}var c_=null;function HA(h){if(c_=null,h=jt(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 c_=h,null}function qU(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 ge:return 2;case we:return 8;case ve:case Ze:return 32;case Ie:return 268435456;default:return 32}default:return 32}}var VA=!1,Zu=null,Qu=null,Ju=null,ib=new Map,ab=new Map,ed=[],Kse="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 KU(h,g){switch(h){case"focusin":case"focusout":Zu=null;break;case"dragenter":case"dragleave":Qu=null;break;case"mouseover":case"mouseout":Ju=null;break;case"pointerover":case"pointerout":ib.delete(g.pointerId);break;case"gotpointercapture":case"lostpointercapture":ab.delete(g.pointerId)}}function sb(h,g,_,N,R,F){return h===null||h.nativeEvent!==F?(h={blockedOn:g,domEventName:_,eventSystemFlags:N,nativeEvent:F,targetContainers:[R]},g!==null&&(g=zt(g),g!==null&&GU(g)),h):(h.eventSystemFlags|=N,g=h.targetContainers,R!==null&&g.indexOf(R)===-1&&g.push(R),h)}function Xse(h,g,_,N,R){switch(g){case"focusin":return Zu=sb(Zu,h,g,_,N,R),!0;case"dragenter":return Qu=sb(Qu,h,g,_,N,R),!0;case"mouseover":return Ju=sb(Ju,h,g,_,N,R),!0;case"pointerover":var F=R.pointerId;return ib.set(F,sb(ib.get(F)||null,h,g,_,N,R)),!0;case"gotpointercapture":return F=R.pointerId,ab.set(F,sb(ab.get(F)||null,h,g,_,N,R)),!0}return!1}function XU(h){var g=jt(h.target);if(g!==null){var _=a(g);if(_!==null){if(g=_.tag,g===13){if(g=o(_),g!==null){h.blockedOn=g,yr(h.priority,function(){WU(_)});return}}else if(g===31){if(g=l(_),g!==null){h.blockedOn=g,yr(h.priority,function(){WU(_)});return}}else if(g===3&&_.stateNode.current.memoizedState.isDehydrated){h.blockedOn=_.tag===3?_.stateNode.containerInfo:null;return}}}h.blockedOn=null}function u_(h){if(h.blockedOn!==null)return!1;for(var g=h.targetContainers;0<g.length;){var _=$A(h.nativeEvent);if(_===null){_=h.nativeEvent;var N=new _.constructor(_.type,_);HE=N,_.target.dispatchEvent(N),HE=null}else return g=zt(_),g!==null&&GU(g),h.blockedOn=_,!1;g.shift()}return!0}function YU(h,g,_){u_(h)&&_.delete(g)}function Yse(){VA=!1,Zu!==null&&u_(Zu)&&(Zu=null),Qu!==null&&u_(Qu)&&(Qu=null),Ju!==null&&u_(Ju)&&(Ju=null),ib.forEach(YU),ab.forEach(YU)}function d_(h,g){h.blockedOn===g&&(h.blockedOn=null,VA||(VA=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Yse)))}var h_=null;function ZU(h){h_!==h&&(h_=h,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){h_===h&&(h_=null);for(var g=0;g<h.length;g+=3){var _=h[g],N=h[g+1],R=h[g+2];if(typeof N!="function"){if(HA(N||_)===null)continue;break}var F=zt(_);F!==null&&(h.splice(g,3),g-=3,$2(F,{pending:!0,data:R,method:_.method,action:N},N,R))}}))}function Zm(h){function g(De){return d_(De,h)}Zu!==null&&d_(Zu,h),Qu!==null&&d_(Qu,h),Ju!==null&&d_(Ju,h),ib.forEach(g),ab.forEach(g);for(var _=0;_<ed.length;_++){var N=ed[_];N.blockedOn===h&&(N.blockedOn=null)}for(;0<ed.length&&(_=ed[0],_.blockedOn===null);)XU(_),_.blockedOn===null&&ed.shift();if(_=(h.ownerDocument||h).$$reactFormReplay,_!=null)for(N=0;N<_.length;N+=3){var R=_[N],F=_[N+1],Z=R[Rr]||null;if(typeof F=="function")Z||ZU(_);else if(Z){var pe=null;if(F&&F.hasAttribute("formAction")){if(R=F,Z=F[Rr]||null)pe=Z.formAction;else if(HA(R)!==null)continue}else pe=Z.action;typeof pe=="function"?_[N+1]=pe:(_.splice(N,3),N-=3),ZU(_)}}}function QU(){function h(F){F.canIntercept&&F.info==="react-transition"&&F.intercept({handler:function(){return new Promise(function(Z){return R=Z})},focusReset:"manual",scroll:"manual"})}function g(){R!==null&&(R(),R=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,R=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),R!==null&&(R(),R=null)}}}function GA(h){this._internalRoot=h}f_.prototype.render=GA.prototype.render=function(h){var g=this._internalRoot;if(g===null)throw Error(r(409));var _=g.current,N=Is();HU(_,N,h,g,null,null)},f_.prototype.unmount=GA.prototype.unmount=function(){var h=this._internalRoot;if(h!==null){this._internalRoot=null;var g=h.containerInfo;HU(h.current,2,null,h,null,null),qv(),g[Gr]=null}};function f_(h){this._internalRoot=h}f_.prototype.unstable_scheduleHydration=function(h){if(h){var g=Pr();h={blockedOn:null,target:h,priority:g};for(var _=0;_<ed.length&&g!==0&&g<ed[_].priority;_++);ed.splice(_,0,h),_===0&&XU(h)}};var JU=e.version;if(JU!=="19.2.3")throw Error(r(527,JU,"19.2.3"));V.findDOMNode=function(h){var g=h._reactInternals;if(g===void 0)throw typeof h.render=="function"?Error(r(188)):(h=Object.keys(h).join(","),Error(r(268,h)));return h=u(g),h=h!==null?d(h):null,h=h===null?null:h.stateNode,h};var Zse={bundleType:0,version:"19.2.3",rendererPackageName:"react-dom",currentDispatcherRef:K,reconcilerVersion:"19.2.3"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var m_=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!m_.isDisabled&&m_.supportsFiber)try{Qe=m_.inject(Zse),oe=m_}catch{}}return lb.createRoot=function(h,g){if(!i(h))throw Error(r(299));var _=!1,N="",R=s5,F=o5,Z=l5;return g!=null&&(g.unstable_strictMode===!0&&(_=!0),g.identifierPrefix!==void 0&&(N=g.identifierPrefix),g.onUncaughtError!==void 0&&(R=g.onUncaughtError),g.onCaughtError!==void 0&&(F=g.onCaughtError),g.onRecoverableError!==void 0&&(Z=g.onRecoverableError)),g=BU(h,1,!1,null,null,_,N,null,R,F,Z,QU),h[Gr]=g.current,EA(h),new GA(g)},lb.hydrateRoot=function(h,g,_){if(!i(h))throw Error(r(299));var N=!1,R="",F=s5,Z=o5,pe=l5,De=null;return _!=null&&(_.unstable_strictMode===!0&&(N=!0),_.identifierPrefix!==void 0&&(R=_.identifierPrefix),_.onUncaughtError!==void 0&&(F=_.onUncaughtError),_.onCaughtError!==void 0&&(Z=_.onCaughtError),_.onRecoverableError!==void 0&&(pe=_.onRecoverableError),_.formState!==void 0&&(De=_.formState)),g=BU(h,1,!0,g,_??null,N,R,De,F,Z,pe,QU),g.context=$U(null),_=g.current,N=Is(),N=bn(N),R=Uu(N),R.callback=null,zu(_,R,N),_=N,g.current.lanes=_,ln(g,_),Ml(g),h[Gr]=g.current,EA(h),new f_(g)},lb.version="19.2.3",lb}var cz;function loe(){if(cz)return KA.exports;cz=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),KA.exports=ooe(),KA.exports}var coe=loe();const hn=t=>typeof t=="string",cb=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},uz=t=>t==null?"":""+t,uoe=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},doe=/###/g,dz=t=>t&&t.indexOf("###")>-1?t.replace(doe,"."):t,hz=t=>!t||hn(t),r0=(t,e,n)=>{const r=hn(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(hz(t))return{};const a=dz(r[i]);!t[a]&&n&&(t[a]=new n),Object.prototype.hasOwnProperty.call(t,a)?t=t[a]:t={},++i}return hz(t)?{}:{obj:t,k:dz(r[i])}},fz=(t,e,n)=>{const{obj:r,k:i}=r0(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=r0(t,o,Object);for(;l.obj===void 0&&o.length;)a=`${o[o.length-1]}.${a}`,o=o.slice(0,o.length-1),l=r0(t,o,Object),l?.obj&&typeof l.obj[`${l.k}.${a}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${a}`]=n},hoe=(t,e,n,r)=>{const{obj:i,k:a}=r0(t,e,Object);i[a]=i[a]||[],i[a].push(n)},C1=(t,e)=>{const{obj:n,k:r}=r0(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},foe=(t,e,n)=>{const r=C1(t,n);return r!==void 0?r:C1(e,n)},wq=(t,e,n)=>{for(const r in e)r!=="__proto__"&&r!=="constructor"&&(r in t?hn(t[r])||t[r]instanceof String||hn(e[r])||e[r]instanceof String?n&&(t[r]=e[r]):wq(t[r],e[r],n):t[r]=e[r]);return t},Qm=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var moe={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const poe=t=>hn(t)?t.replace(/[&<>"'\/]/g,e=>moe[e]):t;class goe{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 xoe=[" ",",","?","!",";"],boe=new goe(20),yoe=(t,e,n)=>{e=e||"",n=n||"";const r=xoe.filter(o=>e.indexOf(o)<0&&n.indexOf(o)<0);if(r.length===0)return!0;const i=boe.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},tP=(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},A0=t=>t?.replace("_","-"),voe={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 k1{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||voe,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:(hn(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new k1(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new k1(this.logger,e)}}var zl=new k1;let JM=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 mz extends JM{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):hn(r)&&a?l.push(...r.split(a)):l.push(r)));const c=C1(this.data,l);return!c&&!n&&!r&&e.indexOf(".")>-1&&(e=l[0],n=l[1],r=l.slice(2).join(".")),c||!o||!hn(r)?c:tP(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),fz(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)(hn(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=C1(this.data,l)||{};o.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?wq(c,r,a):c={...c,...r},fz(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 Sq={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 Mq=Symbol("i18next/PATH_KEY");function _oe(){const t=[],e=Object.create(null);let n;return e.get=(r,i)=>(n?.revoke?.(),i===Mq?t:(t.push(i),n=Proxy.revocable(r,e),n.proxy)),Proxy.revocable(Object.create(null),e).proxy}function nP(t,e){const{[Mq]:n}=t(_oe());return n.join(e?.keySeparator??".")}const pz={},QA=t=>!hn(t)&&typeof t!="boolean"&&typeof t!="number";class j1 extends JM{constructor(e,n={}){super(),uoe(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=zl.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=QA(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&&!yoe(e,r,i);if(o&&!l){const c=e.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:e,namespaces:hn(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:hn(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=nP(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,A=i.count!==void 0&&!hn(i.count),T=j1.hasDefaultValue(i),k=A?this.pluralResolver.getSuffix(f,i.count,i):"",E=i.ordinal&&A?this.pluralResolver.getSuffix(f,i.count,{ordinal:!1}):"",O=A&&!i.ordinal&&i.count===0,C=O&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${k}`]||i[`defaultValue${E}`]||i.defaultValue;let D=b;M&&!b&&T&&(D=C);const U=QA(D),L=Object.prototype.toString.apply(D);if(M&&D&&U&&v.indexOf(L)<0&&!(hn(S)&&Array.isArray(D))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const q=this.options.returnedObjectHandler?this.options.returnedObjectHandler(y,D,{...i,ns:c}):`key '${l} (${this.language})' returned an object instead of string.`;return a?(p.res=q,p.usedParams=this.getUsedParamsDetails(i),p):q}if(o){const q=Array.isArray(D),P=q?[]:{},W=q?x:y;for(const K in D)if(Object.prototype.hasOwnProperty.call(D,K)){const V=`${W}${o}${K}`;T&&!b?P[K]=this.translate(V,{...i,defaultValue:QA(C)?C[K]:void 0,joinArrays:!1,ns:c}):P[K]=this.translate(V,{...i,joinArrays:!1,ns:c}),P[K]===V&&(P[K]=D[K])}b=P}}else if(M&&hn(S)&&Array.isArray(b))b=b.join(S),b&&(b=this.extendTranslation(b,e,i,r));else{let q=!1,P=!1;!this.isValidLookup(b)&&T&&(q=!0,b=C),this.isValidLookup(b)||(P=!0,b=l);const K=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&P?void 0:b,V=T&&C!==b&&this.options.updateMissing;if(P||q||V){if(this.logger.log(V?"updateKey":"missingKey",f,u,l,V?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 Q=[];const re=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&re&&re[0])for(let z=0;z<re.length;z++)Q.push(re[z]);else this.options.saveMissingTo==="all"?Q=this.languageUtils.toResolveHierarchy(i.lng||this.language):Q.push(i.lng||this.language);const J=(z,G,ne)=>{const ae=T&&ne!==b?ne:K;this.options.missingKeyHandler?this.options.missingKeyHandler(z,u,G,ae,V,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(z,u,G,ae,V,i),this.emit("missingKey",z,u,G,b)};this.options.saveMissing&&(this.options.saveMissingPlurals&&A?Q.forEach(z=>{const G=this.pluralResolver.getSuffixes(z,i);O&&i[`defaultValue${this.options.pluralSeparator}zero`]&&G.indexOf(`${this.options.pluralSeparator}zero`)<0&&G.push(`${this.options.pluralSeparator}zero`),G.forEach(ne=>{J([z],l+ne,i[`defaultValue${ne}`]||C)})}):J(Q,l,C))}b=this.extendTranslation(b,e,i,p,r),P&&b===l&&this.options.appendNamespaceToMissingKey&&(b=`${u}${d}${l}`),(P||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=hn(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&&!hn(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=hn(o)?[o]:o;return e!=null&&l?.length&&r.applyPostProcessor!==!1&&(e=Sq.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 hn(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&&!hn(n.count),p=m&&!n.ordinal&&n.count===0,b=n.context!==void 0&&(hn(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,!pz[`${y[0]}-${x}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(l)&&(pz[`${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 A;m&&(A=this.pluralResolver.getSuffix(v,n.count,n));const T=`${this.options.pluralSeparator}zero`,k=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(m&&(n.ordinal&&A.indexOf(k)===0&&S.push(d+A.replace(k,this.options.pluralSeparator)),S.push(d+A),p&&S.push(d+T)),b){const E=`${d}${this.options.contextSeparator||"_"}${n.context}`;S.push(E),m&&(n.ordinal&&A.indexOf(k)===0&&S.push(E+A.replace(k,this.options.pluralSeparator)),S.push(E+A),p&&S.push(E+T))}}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&&!hn(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 gz{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=zl.create("languageUtils")}getScriptPartFromCode(e){if(e=A0(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=A0(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(hn(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)),hn(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 hn(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))):hn(e)&&a(this.formatLanguageCode(e)),r.forEach(o=>{i.indexOf(o)<0&&a(this.formatLanguageCode(o))}),i}}const xz={zero:0,one:1,two:2,few:3,many:4,other:5},bz={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class woe{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=zl.create("pluralResolver"),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){const r=A0(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!"),bz;if(!e.match(/-|_/))return bz;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)=>xz[i]-xz[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 yz=(t,e,n,r=".",i=!0)=>{let a=foe(t,e,n);return!a&&i&&hn(n)&&(a=tP(t,n,r),a===void 0&&(a=tP(e,n,r))),a},JA=t=>t.replace(/\$/g,"$$$$");class vz{constructor(e={}){this.logger=zl.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:poe,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=yz(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(yz(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=>JA(p)},{regex:this.regexp,safeValue:p=>this.escapeValue?JA(this.escape(p)):JA(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=hn(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!hn(o)&&!this.useRawValueToEscape&&(o=uz(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&&!hn(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&&!hn(a))return a;hn(a)||(a=uz(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 Soe=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}},_z=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(A0(r),i),e[o]=l),l(n)}},Moe=t=>(e,n,r)=>t(A0(n),r)(e);class Noe{constructor(e={}){this.logger=zl.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const r=n.cacheInBuiltFormats?_z:Moe;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()]=_z(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}=Soe(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 Eoe=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class Aoe extends JM{constructor(e,n,r,i={}){super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=zl.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=>{hoe(c.loaded,[a],o),Eoe(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();hn(e)&&(e=this.languageUtils.toResolveHierarchy(e)),hn(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 eT=()=>({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]),hn(t[1])&&(e.defaultValue=t[1]),hn(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}),wz=t=>(hn(t.ns)&&(t.ns=[t.ns]),hn(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),hn(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),g_=()=>{},Toe=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class i0 extends JM{constructor(e={},n){if(super(),this.options=wz(e),this.services={},this.logger=zl,this.modules={external:[]},Toe(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&&(hn(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const r=eT();this.options={...r,...this.options,...wz(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?zl.init(i(this.modules.logger),this.options):zl.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=Noe;const d=new gz(this.options);this.store=new mz(this.options.resources,this.options);const f=this.services;f.logger=zl,f.resourceStore=this.store,f.languageUtils=d,f.pluralResolver=new woe(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 vz(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new Aoe(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 j1(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=g_),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=cb(),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=g_){let r=n;const i=hn(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=cb();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=g_),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"&&Sq.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=cb();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=hn(l)?l:l&&l[0],u=this.store.hasLanguageSomeTranslations(c)?c:this.services.languageUtils.getBestMatchFromCodes(hn(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=nP(f,{...this.options,...o})),`${c.keyPrefix}${u}${f}`)):(typeof a=="function"&&(a=nP(a,{...this.options,...o})),d=c.keyPrefix?`${c.keyPrefix}${u}${a}`:a),this.t(d,c)};return hn(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=cb();return this.options.ns?(hn(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=cb();hn(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 gz(eT());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 i0(e,n);return r.createInstance=i0.createInstance,r}cloneInstance(e={},n=g_){const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},a=new i0(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 mz(l,i),a.services.resourceStore=a.store}if(e.interpolation){const c={...eT().interpolation,...this.options.interpolation,...e.interpolation},u={...i,interpolation:c};a.services.interpolator=new vz(u)}return a.translator=new j1(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 ls=i0.createInstance();ls.createInstance;ls.dir;ls.init;ls.loadResources;ls.reloadResources;ls.use;ls.changeLanguage;ls.getFixedT;ls.t;ls.exists;ls.setDefaultNamespace;ls.hasLoadedNamespace;ls.loadNamespaces;ls.loadLanguages;const Coe=(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);zf(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),t?.services?.logger?.warn?t.services.logger.warn(...i):console?.warn&&console.warn(...i)},Sz={},Nq=(t,e,n,r)=>{zf(n)&&Sz[n]||(zf(n)&&(Sz[n]=new Date),Coe(t,e,n,r))},Eq=(t,e)=>()=>{if(t.isInitialized)e();else{const n=()=>{setTimeout(()=>{t.off("initialized",n)},0),e()};t.on("initialized",n)}},rP=(t,e,n)=>{t.loadNamespaces(e,Eq(t,n))},Mz=(t,e,n,r)=>{if(zf(n)&&(n=[n]),t.options.preload&&t.options.preload.indexOf(e)>-1)return rP(t,n,r);n.forEach(i=>{t.options.ns.indexOf(i)<0&&t.options.ns.push(i)}),t.loadLanguages(e,Eq(t,r))},koe=(t,e,n={})=>!e.languages||!e.languages.length?(Nq(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}}),zf=t=>typeof t=="string",joe=t=>typeof t=="object"&&t!==null,Poe=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,Roe={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},Doe=t=>Roe[t],Ooe=t=>t.replace(Poe,Doe);let iP={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:Ooe,transDefaultProps:void 0};const Loe=(t={})=>{iP={...iP,...t}},Ioe=()=>iP;let Aq;const Foe=t=>{Aq=t},Uoe=()=>Aq,zoe={type:"3rdParty",init(t){Loe(t.options.react),Foe(t)}},Boe=w.createContext();class $oe{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var tT={exports:{}},nT={};var Nz;function Hoe(){if(Nz)return nT;Nz=1;var t=Kg();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 nT.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:d,nT}var Ez;function Tq(){return Ez||(Ez=1,tT.exports=Hoe()),tT.exports}var ND=Tq();const Voe=(t,e)=>zf(e)?e:joe(e)&&zf(e.defaultValue)?e.defaultValue:Array.isArray(t)?t[t.length-1]:t,Goe={t:Voe,ready:!1},Woe=()=>()=>{},Xg=(t,e={})=>{const{i18n:n}=e,{i18n:r,defaultNS:i}=w.useContext(Boe)||{},a=n||r||Uoe();a&&!a.reportNamespaces&&(a.reportNamespaces=new $oe),a||Nq(a,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const o=w.useMemo(()=>({...Ioe(),...a?.options?.react,...e}),[a,e]),{useSuspense:l,keyPrefix:c}=o,u=i||a?.options?.defaultNS,d=zf(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 Woe;const{bindI18n:D,bindI18nStore:U}=o,L=()=>{m.current+=1,C()};return D&&a.on(D,L),U&&a.store.on(U,L),()=>{D&&D.split(" ").forEach(q=>a.off(q,L)),U&&U.split(" ").forEach(q=>a.store.off(q,L))}},[a,o]),b=w.useRef(),y=w.useCallback(()=>{if(!a)return Goe;const C=!!(a.isInitialized||a.initializedStoreOnce)&&f.every(W=>koe(W,a,o)),D=e.lng||a.language,U=m.current,L=b.current;if(L&&L.ready===C&&L.lng===D&&L.keyPrefix===c&&L.revision===U)return L;const P={t:a.getFixedT(D,o.nsMode==="fallback"?f:f[0],c),ready:C,lng:D,keyPrefix:c,revision:U};return b.current=P,P},[a,f,c,o,e.lng]),[x,v]=w.useState(0),{t:S,ready:M}=ND.useSyncExternalStore(p,y,y);w.useEffect(()=>{if(a&&!M&&!l){const C=()=>v(D=>D+1);e.lng?Mz(a,e.lng,f,C):rP(a,f,C)}},[a,e.lng,f,M,l,x]);const A=a||{},T=w.useRef(null),k=w.useRef(),E=C=>{const D=Object.getOwnPropertyDescriptors(C);D.__original&&delete D.__original;const U=Object.create(Object.getPrototypeOf(C),D);if(!Object.prototype.hasOwnProperty.call(U,"__original"))try{Object.defineProperty(U,"__original",{value:C,writable:!1,enumerable:!1,configurable:!1})}catch{}return U},O=w.useMemo(()=>{const C=A,D=C?.language;let U=C;C&&(T.current&&T.current.__original===C?k.current!==D?(U=E(C),T.current=U,k.current=D):U=T.current:(U=E(C),T.current=U,k.current=D));const L=[S,U,M];return L.t=S,L.i18n=U,L.ready=M,L},[S,A,M,A.resolvedLanguage,A.language,A.languages]);if(a&&l&&!M)throw new Promise(C=>{const D=()=>C();e.lng?Mz(a,e.lng,f,D):rP(a,f,D)});return O},{slice:qoe,forEach:Koe}=[];function Xoe(t){return Koe.call(qoe.call(arguments,1),e=>{if(e)for(const n in e)t[n]===void 0&&(t[n]=e[n])}),t}function Yoe(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 Az=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,Zoe=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(!Az.test(r.domain))throw new TypeError("option domain is invalid");a+=`; Domain=${r.domain}`}if(r.path){if(!Az.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},Tz={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=Zoe(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 Qoe={name:"cookie",lookup(t){let{lookupCookie:e}=t;if(e&&typeof document<"u")return Tz.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:n,cookieMinutes:r,cookieDomain:i,cookieOptions:a}=e;n&&typeof document<"u"&&Tz.create(n,t,r,i,a)}},Joe={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}},ele={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 Jm=null;const Cz=()=>{if(Jm!==null)return Jm;try{if(Jm=typeof window<"u"&&window.localStorage!==null,!Jm)return!1;const t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{Jm=!1}return Jm};var tle={name:"localStorage",lookup(t){let{lookupLocalStorage:e}=t;if(e&&Cz())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:n}=e;n&&Cz()&&window.localStorage.setItem(n,t)}};let ep=null;const kz=()=>{if(ep!==null)return ep;try{if(ep=typeof window<"u"&&window.sessionStorage!==null,!ep)return!1;const t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{ep=!1}return ep};var nle={name:"sessionStorage",lookup(t){let{lookupSessionStorage:e}=t;if(e&&kz())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupSessionStorage:n}=e;n&&kz()&&window.sessionStorage.setItem(n,t)}},rle={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}},ile={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}},ale={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}},sle={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 Cq=!1;try{document.cookie,Cq=!0}catch{}const kq=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];Cq||kq.splice(1,1);const ole=()=>({order:kq,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:t=>t});class jq{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=Xoe(n,this.options||{},ole()),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(Qoe),this.addDetector(Joe),this.addDetector(tle),this.addDetector(nle),this.addDetector(rle),this.addDetector(ile),this.addDetector(ale),this.addDetector(sle),this.addDetector(ele)}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&&!Yoe(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)}))}}jq.type="languageDetector";const lle={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?"}},cle={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?"}},ule={en:{translation:lle},de:{translation:cle}};ls.use(jq).use(zoe).init({resources:ule,fallbackLng:"en",supportedLngs:["en","de"],detection:{order:["localStorage","navigator","htmlTag"],lookupLocalStorage:"bambutrack_language",caches:["localStorage"]},interpolation:{escapeValue:!1},react:{useSuspense:!1}});const jz=[{code:"en",name:"English",nativeName:"English"},{code:"de",name:"German",nativeName:"Deutsch"}];var Pz="popstate";function dle(t={}){function e(r,i){let{pathname:a,search:o,hash:l}=r.location;return aP("",{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:T0(i)}return fle(e,n,null,t)}function $r(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function Do(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function hle(){return Math.random().toString(36).substring(2,10)}function Rz(t,e){return{usr:t.state,key:t.key,idx:e}}function aP(t,e,n=null,r){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof e=="string"?Yg(e):e,state:n,key:e&&e.key||r||hle()}}function T0({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 Yg(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 fle(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=aP(y.location,x,v);u=d()+1;let M=Rz(S,u),A=y.createHref(S);try{o.pushState(M,"",A)}catch(T){if(T instanceof DOMException&&T.name==="DataCloneError")throw T;i.location.assign(A)}a&&c&&c({action:l,location:y.location,delta:1})}function p(x,v){l="REPLACE";let S=aP(y.location,x,v);u=d();let M=Rz(S,u),A=y.createHref(S);o.replaceState(M,"",A),a&&c&&c({action:l,location:y.location,delta:0})}function b(x){return mle(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(Pz,f),c=x,()=>{i.removeEventListener(Pz,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 mle(t,e=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),$r(n,"No window.location.(origin|href) available to create URL");let r=typeof t=="string"?t:T0(t);return r=r.replace(/ $/,"%20"),!e&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function Pq(t,e,n="/"){return ple(t,e,n,!1)}function ple(t,e,n,r){let i=typeof e=="string"?Yg(e):e,a=mu(i.pathname||"/",n);if(a==null)return null;let o=Rq(t);gle(o);let l=null;for(let c=0;l==null&&c<o.length;++c){let u=Ale(a);l=Nle(o[c],u,r)}return l}function Rq(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;$r(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=au([r,d.relativePath]),m=n.concat(d);o.children&&o.children.length>0&&($r(o.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${f}".`),Rq(o.children,e,m,f,c)),!(o.path==null&&!o.index)&&e.push({path:f,score:Sle(f,o.index),routesMeta:m})};return t.forEach((o,l)=>{if(o.path===""||!o.path?.includes("?"))a(o,l);else for(let c of Dq(o.path))a(o,l,!0,c)}),e}function Dq(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=Dq(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 gle(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:Mle(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var xle=/^:[\w-]+$/,ble=3,yle=2,vle=1,_le=10,wle=-2,Dz=t=>t==="*";function Sle(t,e){let n=t.split("/"),r=n.length;return n.some(Dz)&&(r+=wle),e&&(r+=yle),n.filter(i=>!Dz(i)).reduce((i,a)=>i+(xle.test(a)?ble:a===""?vle:_le),r)}function Mle(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 Nle(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=P1({path:c.relativePath,caseSensitive:c.caseSensitive,end:u},d),m=c.route;if(!f&&u&&n&&!r[r.length-1].route.index&&(f=P1({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},d)),!f)return null;Object.assign(i,f.params),o.push({params:i,pathname:au([a,f.pathname]),pathnameBase:jle(au([a,f.pathnameBase])),route:m}),f.pathnameBase!=="/"&&(a=au([a,f.pathnameBase]))}return o}function P1(t,e){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,r]=Ele(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 Ele(t,e=!1,n=!0){Do(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 Ale(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return Do(!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 mu(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 Tle=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function Cle(t,e="/"){let{pathname:n,search:r="",hash:i=""}=typeof t=="string"?Yg(t):t,a;return n?(n=n.replace(/\/\/+/g,"/"),n.startsWith("/")?a=Oz(n.substring(1),"/"):a=Oz(n,e)):a=e,{pathname:a,search:Ple(r),hash:Rle(i)}}function Oz(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 rT(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 kle(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function ED(t){let e=kle(t);return e.map((n,r)=>r===e.length-1?n.pathname:n.pathnameBase)}function AD(t,e,n,r=!1){let i;typeof t=="string"?i=Yg(t):(i={...t},$r(!i.pathname||!i.pathname.includes("?"),rT("?","pathname","search",i)),$r(!i.pathname||!i.pathname.includes("#"),rT("#","pathname","hash",i)),$r(!i.search||!i.search.includes("#"),rT("#","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=Cle(i,l),u=o&&o!=="/"&&o.endsWith("/"),d=(a||o===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}var au=t=>t.join("/").replace(/\/\/+/g,"/"),jle=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),Ple=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,Rle=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t,Dle=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 Ole(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}function Lle(t){return t.map(e=>e.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var Oq=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Lq(t,e){let n=t;if(typeof n!="string"||!Tle.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(Oq)try{let a=new URL(window.location.href),o=n.startsWith("//")?new URL(a.protocol+n):new URL(n),l=mu(o.pathname,e);o.origin===a.origin&&l!=null?n=l+o.search+o.hash:i=!0}catch{Do(!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 Iq=["POST","PUT","PATCH","DELETE"];new Set(Iq);var Ile=["GET",...Iq];new Set(Ile);var Zg=w.createContext(null);Zg.displayName="DataRouter";var eN=w.createContext(null);eN.displayName="DataRouterState";var Fle=w.createContext(!1),Fq=w.createContext({isTransitioning:!1});Fq.displayName="ViewTransition";var Ule=w.createContext(new Map);Ule.displayName="Fetchers";var zle=w.createContext(null);zle.displayName="Await";var no=w.createContext(null);no.displayName="Navigation";var wy=w.createContext(null);wy.displayName="Location";var Bo=w.createContext({outlet:null,matches:[],isDataRoute:!1});Bo.displayName="Route";var TD=w.createContext(null);TD.displayName="RouteError";var Uq="REACT_ROUTER_ERROR",Ble="REDIRECT",$le="ROUTE_ERROR_RESPONSE";function Hle(t){if(t.startsWith(`${Uq}:${Ble}:{`))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 Vle(t){if(t.startsWith(`${Uq}:${$le}:{`))try{let e=JSON.parse(t.slice(40));if(typeof e=="object"&&e&&typeof e.status=="number"&&typeof e.statusText=="string")return new Dle(e.status,e.statusText,e.data)}catch{}}function Gle(t,{relative:e}={}){$r(Qg(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=w.useContext(no),{hash:i,pathname:a,search:o}=Sy(t,{relative:e}),l=a;return n!=="/"&&(l=a==="/"?n:au([n,a])),r.createHref({pathname:l,search:o,hash:i})}function Qg(){return w.useContext(wy)!=null}function cc(){return $r(Qg(),"useLocation() may be used only in the context of a <Router> component."),w.useContext(wy).location}var zq="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Bq(t){w.useContext(no).static||w.useLayoutEffect(t)}function gl(){let{isDataRoute:t}=w.useContext(Bo);return t?sce():Wle()}function Wle(){$r(Qg(),"useNavigate() may be used only in the context of a <Router> component.");let t=w.useContext(Zg),{basename:e,navigator:n}=w.useContext(no),{matches:r}=w.useContext(Bo),{pathname:i}=cc(),a=JSON.stringify(ED(r)),o=w.useRef(!1);return Bq(()=>{o.current=!0}),w.useCallback((c,u={})=>{if(Do(o.current,zq),!o.current)return;if(typeof c=="number"){n.go(c);return}let d=AD(c,JSON.parse(a),i,u.relative==="path");t==null&&e!=="/"&&(d.pathname=d.pathname==="/"?e:au([e,d.pathname])),(u.replace?n.replace:n.push)(d,u.state,u)},[e,n,a,i,t])}var qle=w.createContext(null);function Kle(t){let e=w.useContext(Bo).outlet;return w.useMemo(()=>e&&w.createElement(qle.Provider,{value:t},e),[e,t])}function CD(){let{matches:t}=w.useContext(Bo),e=t[t.length-1];return e?e.params:{}}function Sy(t,{relative:e}={}){let{matches:n}=w.useContext(Bo),{pathname:r}=cc(),i=JSON.stringify(ED(n));return w.useMemo(()=>AD(t,JSON.parse(i),r,e==="path"),[t,i,r,e])}function Xle(t,e){return $q(t,e)}function $q(t,e,n,r,i){$r(Qg(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:a}=w.useContext(no),{matches:o}=w.useContext(Bo),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||"";Vq(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=cc(),p;if(e){let S=typeof e=="string"?Yg(e):e;$r(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=Pq(t,{pathname:y});Do(f||x!=null,`No routes matched location "${p.pathname}${p.search}${p.hash}" `),Do(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=ece(x&&x.map(S=>Object.assign({},S,{params:Object.assign({},c,S.params),pathname:au([d,a.encodeLocation?a.encodeLocation(S.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:S.pathname]),pathnameBase:S.pathnameBase==="/"?d:au([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(wy.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...p},navigationType:"POP"}},v):v}function Yle(){let t=ace(),e=Ole(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 Zle=w.createElement(Yle,null),Hq=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=Vle(t.digest);n&&(t=n)}let e=t!==void 0?w.createElement(Bo.Provider,{value:this.props.routeContext},w.createElement(TD.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?w.createElement(Qle,{error:t},e):e}};Hq.contextType=Fle;var iT=new WeakMap;function Qle({children:t,error:e}){let{basename:n}=w.useContext(no);if(typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){let r=Hle(e.digest);if(r){let i=iT.get(e);if(i)throw i;let a=Lq(r.location,n);if(Oq&&!iT.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 iT.set(e,o),o}return w.createElement("meta",{httpEquiv:"refresh",content:`0;url=${a.absoluteURL||a.to}`})}}return t}function Jle({routeContext:t,match:e,children:n}){let r=w.useContext(Zg);return r&&r.static&&r.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=e.route.id),w.createElement(Bo.Provider,{value:t},n)}function ece(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);$r(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:Lle(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||Zle,l&&(c<0&&m===0?(Vq("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(Jle,{match:f,routeContext:{outlet:d,matches:v,isDataRoute:n!=null},children:M})};return n&&(f.route.ErrorBoundary||f.route.errorElement||m===0)?w.createElement(Hq,{location:n.location,revalidation:n.revalidation,component:y,error:p,children:S(),routeContext:{outlet:null,matches:v,isDataRoute:!0},onError:u}):S()},null)}function kD(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function tce(t){let e=w.useContext(Zg);return $r(e,kD(t)),e}function nce(t){let e=w.useContext(eN);return $r(e,kD(t)),e}function rce(t){let e=w.useContext(Bo);return $r(e,kD(t)),e}function jD(t){let e=rce(t),n=e.matches[e.matches.length-1];return $r(n.route.id,`${t} can only be used on routes that contain a unique "id"`),n.route.id}function ice(){return jD("useRouteId")}function ace(){let t=w.useContext(TD),e=nce("useRouteError"),n=jD("useRouteError");return t!==void 0?t:e.errors?.[n]}function sce(){let{router:t}=tce("useNavigate"),e=jD("useNavigate"),n=w.useRef(!1);return Bq(()=>{n.current=!0}),w.useCallback(async(i,a={})=>{Do(n.current,zq),n.current&&(typeof i=="number"?await t.navigate(i):await t.navigate(i,{fromRouteId:e,...a}))},[t,e])}var Lz={};function Vq(t,e,n){!e&&!Lz[t]&&(Lz[t]=!0,Do(!1,n))}w.memo(oce);function oce({routes:t,future:e,state:n,onError:r}){return $q(t,void 0,n,r,e)}function R1({to:t,replace:e,state:n,relative:r}){$r(Qg(),"<Navigate> may be used only in the context of a <Router> component.");let{static:i}=w.useContext(no);Do(!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(Bo),{pathname:o}=cc(),l=gl(),c=AD(t,ED(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 lce(t){return Kle(t.context)}function Xi(t){$r(!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 cce({basename:t="/",children:e=null,location:n,navigationType:r="POP",navigator:i,static:a=!1,unstable_useTransitions:o}){$r(!Qg(),"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=Yg(n));let{pathname:u="/",search:d="",hash:f="",state:m=null,key:p="default"}=n,b=w.useMemo(()=>{let y=mu(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 Do(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(no.Provider,{value:c},w.createElement(wy.Provider,{children:e,value:b}))}function uce({children:t,location:e}){return Xle(sP(t),e)}function sP(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,sP(r.props.children,a));return}$r(r.type===Xi,`[${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>`),$r(!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=sP(r.props.children,a)),n.push(o)}),n}var t1="get",n1="application/x-www-form-urlencoded";function tN(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function dce(t){return tN(t)&&t.tagName.toLowerCase()==="button"}function hce(t){return tN(t)&&t.tagName.toLowerCase()==="form"}function fce(t){return tN(t)&&t.tagName.toLowerCase()==="input"}function mce(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function pce(t,e){return t.button===0&&(!e||e==="_self")&&!mce(t)}function oP(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 gce(t,e){let n=oP(t);return e&&e.forEach((r,i)=>{n.has(i)||e.getAll(i).forEach(a=>{n.append(i,a)})}),n}var x_=null;function xce(){if(x_===null)try{new FormData(document.createElement("form"),0),x_=!1}catch{x_=!0}return x_}var bce=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function aT(t){return t!=null&&!bce.has(t)?(Do(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${n1}"`),null):t}function yce(t,e){let n,r,i,a,o;if(hce(t)){let l=t.getAttribute("action");r=l?mu(l,e):null,n=t.getAttribute("method")||t1,i=aT(t.getAttribute("enctype"))||n1,a=new FormData(t)}else if(dce(t)||fce(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?mu(c,e):null,n=t.getAttribute("formmethod")||l.getAttribute("method")||t1,i=aT(t.getAttribute("formenctype"))||aT(l.getAttribute("enctype"))||n1,a=new FormData(l,t),!xce()){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(tN(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=t1,r=null,i=n1,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 PD(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function vce(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&&mu(i.pathname,e)==="/"?i.pathname=`${e.replace(/\/$/,"")}/_root.${r}`:i.pathname=`${i.pathname.replace(/\/$/,"")}.${r}`,i}async function _ce(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 wce(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 Sce(t,e,n){let r=await Promise.all(t.map(async i=>{let a=e.routes[i.route.id];if(a){let o=await _ce(a,n);return o.links?o.links():[]}return[]}));return Ace(r.flat(1).filter(wce).filter(i=>i.rel==="stylesheet"||i.rel==="preload").map(i=>i.rel==="stylesheet"?{...i,rel:"prefetch",as:"style"}:{...i,rel:"prefetch"}))}function Iz(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 Mce(t,e,{includeHydrateFallback:n}={}){return Nce(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 Nce(t){return[...new Set(t)]}function Ece(t){let e={},n=Object.keys(t).sort();for(let r of n)e[r]=t[r];return e}function Ace(t,e){let n=new Set;return new Set(e),t.reduce((r,i)=>{let a=JSON.stringify(Ece(i));return n.has(a)||(n.add(a),r.push({key:a,link:i})),r},[])}function Gq(){let t=w.useContext(Zg);return PD(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function Tce(){let t=w.useContext(eN);return PD(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var RD=w.createContext(void 0);RD.displayName="FrameworkContext";function Wq(){let t=w.useContext(RD);return PD(t,"You must render this element inside a <HydratedRouter> element"),t}function Cce(t,e){let n=w.useContext(RD),[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:ub(l,p),onBlur:ub(c,b),onMouseEnter:ub(u,p),onMouseLeave:ub(d,b),onTouchStart:ub(f,p)}]:[!1,m,{}]}function ub(t,e){return n=>{t&&t(n),n.defaultPrevented||e(n)}}function kce({page:t,...e}){let{router:n}=Gq(),r=w.useMemo(()=>Pq(n.routes,t,n.basename),[n.routes,t,n.basename]);return r?w.createElement(Pce,{page:t,matches:r,...e}):null}function jce(t){let{manifest:e,routeModules:n}=Wq(),[r,i]=w.useState([]);return w.useEffect(()=>{let a=!1;return Sce(t,e,n).then(o=>{a||i(o)}),()=>{a=!0}},[t,e,n]),r}function Pce({page:t,matches:e,...n}){let r=cc(),{future:i,manifest:a,routeModules:o}=Wq(),{basename:l}=Gq(),{loaderData:c,matches:u}=Tce(),d=w.useMemo(()=>Iz(t,e,u,a,r,"data"),[t,e,u,a,r]),f=w.useMemo(()=>Iz(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(A=>A.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=vce(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(()=>Mce(f,a),[f,a]),b=jce(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 Rce(...t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}var Dce=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Dce&&(window.__reactRouterVersion="7.13.0")}catch{}function Oce({basename:t,children:e,unstable_useTransitions:n,window:r}){let i=w.useRef();i.current==null&&(i.current=dle({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(cce,{basename:t,children:e,location:o.location,navigationType:o.action,navigator:a,unstable_useTransitions:n})}var qq=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,bs=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(no),v=typeof u=="string"&&qq.test(u),S=Lq(u,y);u=S.to;let M=Gle(u,{relative:i}),[A,T,k]=Cce(r,p),E=Fce(u,{replace:o,state:l,target:c,preventScrollReset:d,relative:i,viewTransition:f,unstable_defaultShouldRevalidate:m,unstable_useTransitions:x});function O(D){e&&e(D),D.defaultPrevented||E(D)}let C=w.createElement("a",{...p,...k,href:S.absoluteURL||M,onClick:S.isExternal||a?e:O,ref:Rce(b,T),target:c,"data-discover":!v&&n==="render"?"true":void 0});return A&&!v?w.createElement(w.Fragment,null,C,w.createElement(kce,{page:M})):C});bs.displayName="Link";var Ub=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=Sy(o,{relative:u.relative}),m=cc(),p=w.useContext(eN),{navigator:b,basename:y}=w.useContext(no),x=p!=null&&Hce(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=mu(M,y)||M);const A=v!=="/"&&v.endsWith("/")?v.length-1:v.length;let T=S===v||!i&&S.startsWith(v)&&S.charAt(A)==="/",k=M!=null&&(M===v||!i&&M.startsWith(v)&&M.charAt(v.length)==="/"),E={isActive:T,isPending:k,isTransitioning:x},O=T?e:void 0,C;typeof r=="function"?C=r(E):C=[r,T?"active":null,k?"pending":null,x?"transitioning":null].filter(Boolean).join(" ");let D=typeof a=="function"?a(E):a;return w.createElement(bs,{...u,"aria-current":O,className:C,ref:d,style:D,to:o,viewTransition:l},typeof c=="function"?c(E):c)});Ub.displayName="NavLink";var Lce=w.forwardRef(({discover:t="render",fetcherKey:e,navigate:n,reloadDocument:r,replace:i,state:a,method:o=t1,action:l,onSubmit:c,relative:u,preventScrollReset:d,viewTransition:f,unstable_defaultShouldRevalidate:m,...p},b)=>{let{unstable_useTransitions:y}=w.useContext(no),x=Bce(),v=$ce(l,{relative:u}),S=o.toLowerCase()==="get"?"get":"post",M=typeof l=="string"&&qq.test(l),A=T=>{if(c&&c(T),T.defaultPrevented)return;T.preventDefault();let k=T.nativeEvent.submitter,E=k?.getAttribute("formmethod")||o,O=()=>x(k||T.currentTarget,{fetcherKey:e,method:E,navigate:n,replace:i,state:a,relative:u,preventScrollReset:d,viewTransition:f,unstable_defaultShouldRevalidate:m});y&&n!==!1?w.startTransition(()=>O()):O()};return w.createElement("form",{ref:b,method:S,action:v,onSubmit:r?c:A,...p,"data-discover":!M&&t==="render"?"true":void 0})});Lce.displayName="Form";function Ice(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Kq(t){let e=w.useContext(Zg);return $r(e,Ice(t)),e}function Fce(t,{target:e,replace:n,state:r,preventScrollReset:i,relative:a,viewTransition:o,unstable_defaultShouldRevalidate:l,unstable_useTransitions:c}={}){let u=gl(),d=cc(),f=Sy(t,{relative:a});return w.useCallback(m=>{if(pce(m,e)){m.preventDefault();let p=n!==void 0?n:T0(d)===T0(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 Xq(t){Do(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(oP(t)),n=w.useRef(!1),r=cc(),i=w.useMemo(()=>gce(r.search,n.current?null:e.current),[r.search]),a=gl(),o=w.useCallback((l,c)=>{const u=oP(typeof l=="function"?l(new URLSearchParams(i)):l);n.current=!0,a("?"+u,c)},[a,i]);return[i,o]}var Uce=0,zce=()=>`__${String(++Uce)}__`;function Bce(){let{router:t}=Kq("useSubmit"),{basename:e}=w.useContext(no),n=ice(),r=t.fetch,i=t.navigate;return w.useCallback(async(a,o={})=>{let{action:l,method:c,encType:u,formData:d,body:f}=yce(a,e);if(o.navigate===!1){let m=o.fetcherKey||zce();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 $ce(t,{relative:e}={}){let{basename:n}=w.useContext(no),r=w.useContext(Bo);$r(r,"useFormAction must be used inside a RouteContext");let[i]=r.matches.slice(-1),a={...Sy(t||".",{relative:e})},o=cc();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:au([n,a.pathname])),T0(a)}function Hce(t,{relative:e}={}){let n=w.useContext(Fq);$r(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=Kq("useViewTransitionState"),i=Sy(t,{relative:e});if(!n.isTransitioning)return!1;let a=mu(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=mu(n.nextLocation.pathname,r)||n.nextLocation.pathname;return P1(i.pathname,o)!=null||P1(i.pathname,a)!=null}var Jc=_q();const Vce=pl(Jc);var fm=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(){}},Gce={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},Wce=class{#t=Gce;#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)}},ff=new Wce;function qce(t){setTimeout(t,0)}var Bf=typeof window>"u"||"Deno"in globalThis;function Ua(){}function Kce(t,e){return typeof t=="function"?t(e):t}function lP(t){return typeof t=="number"&&t>=0&&t!==1/0}function Yq(t,e){return Math.max(t+(e||0)-Date.now(),0)}function Ud(t,e){return typeof t=="function"?t(e):t}function vo(t,e){return typeof t=="function"?t(e):t}function Fz(t,e){const{type:n="all",exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:l}=t;if(o){if(r){if(e.queryHash!==DD(o,e.options))return!1}else if(!C0(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 Uz(t,e){const{exact:n,status:r,predicate:i,mutationKey:a}=t;if(a){if(!e.options.mutationKey)return!1;if(n){if($f(e.options.mutationKey)!==$f(a))return!1}else if(!C0(e.options.mutationKey,a))return!1}return!(r&&e.state.status!==r||i&&!i(e))}function DD(t,e){return(e?.queryKeyHashFn||$f)(t)}function $f(t){return JSON.stringify(t,(e,n)=>cP(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function C0(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(n=>C0(t[n],e[n])):!1}var Xce=Object.prototype.hasOwnProperty;function OD(t,e,n=0){if(t===e)return t;if(n>500)return e;const r=zz(t)&&zz(e);if(!r&&!(cP(t)&&cP(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:Xce.call(t,f))&&u++;continue}if(m===null||p===null||typeof m!="object"||typeof p!="object"){c[f]=p;continue}const b=OD(m,p,n+1);c[f]=b,b===m&&u++}return a===l&&u===a?t:c}function k0(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 zz(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function cP(t){if(!Bz(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!Bz(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function Bz(t){return Object.prototype.toString.call(t)==="[object Object]"}function Yce(t){return new Promise(e=>{ff.setTimeout(e,t)})}function uP(t,e,n){return typeof n.structuralSharing=="function"?n.structuralSharing(t,e):n.structuralSharing!==!1?OD(t,e):e}function Zce(t,e,n=0){const r=[...t,e];return n&&r.length>n?r.slice(1):r}function Qce(t,e,n=0){const r=[e,...t];return n&&r.length>n?r.slice(0,-1):r}var LD=Symbol();function Zq(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===LD?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function ID(t,e){return typeof t=="function"?t(...e):!!t}function Jce(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 eue=class extends fm{#t;#e;#n;constructor(){super(),this.#n=t=>{if(!Bf&&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"}},FD=new eue;function dP(){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 tue=qce;function nue(){let t=[],e=0,n=l=>{l()},r=l=>{l()},i=tue;const a=l=>{e?t.push(l):i(()=>{n(l)})},o=()=>{const l=t;t=[],l.length&&i(()=>{r(()=>{l.forEach(c=>{n(c)})})})};return{batch:l=>{let c;e++;try{c=l()}finally{e--,e||o()}return c},batchCalls:l=>(...c)=>{a(()=>{l(...c)})},schedule:a,setNotifyFunction:l=>{n=l},setBatchNotifyFunction:l=>{r=l},setScheduler:l=>{i=l}}}var si=nue(),rue=class extends fm{#t=!0;#e;#n;constructor(){super(),this.#n=t=>{if(!Bf&&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}},D1=new rue;function iue(t){return Math.min(1e3*2**t,3e4)}function Qq(t){return(t??"online")==="online"?D1.isOnline():!0}var hP=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function Jq(t){let e=!1,n=0,r;const i=dP(),a=()=>i.status!=="pending",o=y=>{if(!a()){const x=new hP(y);m(x),t.onCancel?.(x)}},l=()=>{e=!0},c=()=>{e=!1},u=()=>FD.isFocused()&&(t.networkMode==="always"||D1.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??(Bf?0:3),M=t.retryDelay??iue,A=typeof M=="function"?M(n,v):M,T=S===!0||typeof S=="number"&&n<S||typeof S=="function"&&S(n,v);if(e||!T){m(v);return}n++,t.onFail?.(n,v),Yce(A).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 eK=class{#t;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),lP(this.gcTime)&&(this.#t=ff.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(Bf?1/0:300*1e3))}clearGcTimeout(){this.#t&&(ff.clearTimeout(this.#t),this.#t=void 0)}},aue=class extends eK{#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=Hz(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=Hz(this.options);e.data!==void 0&&(this.setState($z(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(t,e){const n=uP(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(Ua).catch(Ua):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#t)}isActive(){return this.observers.some(t=>vo(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===LD||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>Ud(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:!Yq(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=Zq(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=Jq({initialPromise:e?.initialPromise,fn:o.fetchFn,onCancel:l=>{l instanceof hP&&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 hP){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,...tK(n.data,this.options),fetchMeta:t.meta??null};case"success":const r={...n,...$z(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),si.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:t})})}};function tK(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Qq(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function $z(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Hz(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 UD=class extends fm{constructor(t,e){super(),this.options=e,this.#t=t,this.#s=null,this.#o=dP(),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),Vz(this.#e,this.options)?this.#p():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return fP(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return fP(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 vo(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&&!k0(this.options,e)&&this.#t.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const r=this.hasListeners();r&&Gz(this.#e,n,this.options,e)&&this.#p(),this.updateResult(),r&&(this.#e!==n||vo(this.options.enabled,this.#e)!==vo(e.enabled,this.#e)||Ud(this.options.staleTime,this.#e)!==Ud(e.staleTime,this.#e))&&this.#g();const i=this.#x();r&&(this.#e!==n||vo(this.options.enabled,this.#e)!==vo(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 oue(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(Ua)),e}#g(){this.#v();const t=Ud(this.options.staleTime,this.#e);if(Bf||this.#i.isStale||!lP(t))return;const n=Yq(this.#i.dataUpdatedAt,t)+1;this.#c=ff.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,!(Bf||vo(this.options.enabled,this.#e)===!1||!lP(this.#l)||this.#l===0)&&(this.#u=ff.setInterval(()=>{(this.options.refetchIntervalInBackground||FD.isFocused())&&this.#p()},this.#l))}#y(){this.#g(),this.#b(this.#x())}#v(){this.#c&&(ff.clearTimeout(this.#c),this.#c=void 0)}#_(){this.#u&&(ff.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 O=this.hasListeners(),C=!O&&Vz(t,e),D=O&&Gz(t,n,e,r);(C||D)&&(d={...d,...tK(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 O;i?.isPlaceholderData&&e.placeholderData===o?.placeholderData?(O=i.data,x=!0):O=typeof e.placeholderData=="function"?e.placeholderData(this.#h?.state.data,this.#h):e.placeholderData,O!==void 0&&(y="success",m=uP(i?.data,O,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=uP(i?.data,m,e),this.#d=m,this.#s=null}catch(O){this.#s=O}this.#s&&(p=this.#s,m=this.#d,b=Date.now(),y="error");const v=d.fetchStatus==="fetching",S=y==="pending",M=y==="error",A=S&&v,T=m!==void 0,E={status:y,fetchStatus:d.fetchStatus,isPending:S,isSuccess:y==="success",isError:M,isInitialLoading:A,isLoading:A,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&&!T,isPaused:d.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:M&&T,isStale:zD(t,e),refetch:this.refetch,promise:this.#o,isEnabled:vo(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const O=E.data!==void 0,C=E.status==="error"&&!O,D=q=>{C?q.reject(E.error):O&&q.resolve(E.data)},U=()=>{const q=this.#o=E.promise=dP();D(q)},L=this.#o;switch(L.status){case"pending":t.queryHash===n.queryHash&&D(L);break;case"fulfilled":(C||E.data!==L.value)&&U();break;case"rejected":(!C||E.error!==L.reason)&&U();break}}return E}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),k0(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){si.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#i)}),this.#t.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function sue(t,e){return vo(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function Vz(t,e){return sue(t,e)||t.state.data!==void 0&&fP(t,e,e.refetchOnMount)}function fP(t,e,n){if(vo(e.enabled,t)!==!1&&Ud(e.staleTime,t)!=="static"){const r=typeof n=="function"?n(t):n;return r==="always"||r!==!1&&zD(t,e)}return!1}function Gz(t,e,n,r){return(t!==e||vo(r.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&zD(t,n)}function zD(t,e){return vo(e.enabled,t)!==!1&&t.isStaleByTime(Ud(e.staleTime,t))}function oue(t,e){return!k0(t.getCurrentResult(),e)}function Wz(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=>{Jce(b,()=>e.signal,()=>d=!0)},m=Zq(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:A}=e.options,T=x?Qce:Zce;return{pages:T(b.pages,M,A),pageParams:T(b.pageParams,y,A)}};if(i&&a.length){const b=i==="backward",y=b?lue:qz,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:qz(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 qz(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 lue(t,{pages:e,pageParams:n}){return e.length>0?t.getPreviousPageParam?.(e[0],e,n[0],n):void 0}var cue=class extends eK{#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||nK(),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=Jq({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),si.batch(()=>{this.#e.forEach(n=>{n.onMutationUpdate(t)}),this.#n.notify({mutation:this,type:"updated",action:t})})}};function nK(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var uue=class extends fm{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 cue({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=b_(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=b_(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=b_(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=b_(t);return typeof e=="string"?this.#e.get(e)?.find(r=>r!==t&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){si.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=>Uz(e,n))}findAll(t={}){return this.getAll().filter(e=>Uz(t,e))}notify(t){si.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(e=>e.state.isPaused);return si.batch(()=>Promise.all(t.map(e=>e.continue().catch(Ua))))}};function b_(t){return t.options.scope?.id}var due=class extends fm{#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),k0(this.options,n)||this.#t.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),n?.mutationKey&&this.options.mutationKey&&$f(n.mutationKey)!==$f(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??nK();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){si.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 Kz(t,e){const n=new Set(e);return t.filter(r=>!n.has(r))}function hue(t,e,n){const r=t.slice(0);return r[e]=n,r}var fue=class extends fm{#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,si.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||!k0(d,m)});!c&&!u||(c&&(this.#d=r,this.#r=i),this.#e=a,this.hasListeners()&&(c&&(Kz(n,i).forEach(d=>{d.destroy()}),Kz(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=OD(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 UD(this.#t,i);n.push({defaultedQueryOptions:i,observer:o})}),n}#l(t,e){const n=this.#r.indexOf(t);n!==-1&&(this.#e=hue(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&&si.batch(()=>{this.listeners.forEach(r=>{r(this.#e)})})}}},mue=class extends fm{constructor(t={}){super(),this.config=t,this.#t=new Map}#t;build(t,e,n){const r=e.queryKey,i=e.queryHash??DD(r,e);let a=this.get(i);return a||(a=new aue({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(){si.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=>Fz(e,n))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(n=>Fz(t,n)):e}notify(t){si.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){si.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){si.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},pue=class{#t;#e;#n;#i;#r;#a;#o;#s;constructor(t={}){this.#t=t.queryCache||new mue,this.#e=t.mutationCache||new uue,this.#n=t.defaultOptions||{},this.#i=new Map,this.#r=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=FD.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#t.onFocus())}),this.#s=D1.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(Ud(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=Kce(e,a);if(o!==void 0)return this.#t.build(this,r).setData(o,{...n,manual:!0})}setQueriesData(t,e,n){return si.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;si.batch(()=>{e.findAll(t).forEach(n=>{e.remove(n)})})}resetQueries(t,e){const n=this.#t;return si.batch(()=>(n.findAll(t).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const n={revert:!0,...e},r=si.batch(()=>this.#t.findAll(t).map(i=>i.cancel(n)));return Promise.all(r).then(Ua).catch(Ua)}invalidateQueries(t,e={}){return si.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=si.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(Ua)),i.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(Ua)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const n=this.#t.build(this,e);return n.isStaleByTime(Ud(e.staleTime,n))?n.fetch(e):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(Ua).catch(Ua)}fetchInfiniteQuery(t){return t.behavior=Wz(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(Ua).catch(Ua)}ensureInfiniteQueryData(t){return t.behavior=Wz(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return D1.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($f(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#i.values()],n={};return e.forEach(r=>{C0(t,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(t,e){this.#r.set($f(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#r.values()],n={};return e.forEach(r=>{C0(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=DD(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===LD&&(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()}},rK=w.createContext(void 0),on=t=>{const e=w.useContext(rK);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},gue=({client:t,children:e})=>(w.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),s.jsx(rK.Provider,{value:t,children:e})),iK=w.createContext(!1),aK=()=>w.useContext(iK);iK.Provider;function xue(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var bue=w.createContext(xue()),sK=()=>w.useContext(bue),oK=(t,e,n)=>{const r=n?.state.error&&typeof t.throwOnError=="function"?ID(t.throwOnError,[n.state.error,n]):t.throwOnError;(t.suspense||t.experimental_prefetchInRender||r)&&(e.isReset()||(t.retryOnMount=!1))},lK=t=>{w.useEffect(()=>{t.clearReset()},[t])},cK=({result:t,errorResetBoundary:e,throwOnError:n,query:r,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(i&&t.data===void 0||ID(n,[t.error,r])),uK=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))}},dK=(t,e)=>t.isLoading&&t.isFetching&&!e,mP=(t,e)=>t?.suspense&&e.isPending,O1=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function yue({queries:t,...e},n){const r=on(),i=aK(),a=sK(),o=w.useMemo(()=>t.map(y=>{const x=r.defaultQueryOptions(y);return x._optimisticResults=i?"isRestoring":"optimistic",x}),[t,r,i]);o.forEach(y=>{uK(y);const x=r.getQueryCache().get(y.queryHash);oK(y,a,x)}),lK(a);const[l]=w.useState(()=>new fue(r,o,e)),[c,u,d]=l.getOptimisticResult(o,e.combine),f=!i&&e.subscribed!==!1;w.useSyncExternalStore(w.useCallback(y=>f?l.subscribe(si.batchCalls(y)):Ua,[l,f]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),w.useEffect(()=>{l.setQueries(o,e)},[o,e,l]);const p=c.some((y,x)=>mP(o[x],y))?c.flatMap((y,x)=>{const v=o[x];if(v){const S=new UD(r,v);if(mP(v,y))return O1(v,S,a);dK(y,i)&&O1(v,S,a)}return[]}):[];if(p.length>0)throw Promise.all(p);const b=c.find((y,x)=>{const v=o[x];return v&&cK({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 vue(t,e,n){const r=aK(),i=sK(),a=on(),o=a.defaultQueryOptions(t);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);const l=a.getQueryCache().get(o.queryHash);o._optimisticResults=r?"isRestoring":"optimistic",uK(o),oK(o,i,l),lK(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(si.batchCalls(m)):Ua;return u.updateResult(),p},[u,f]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),w.useEffect(()=>{u.setOptions(o)},[o,u]),mP(o,d))throw O1(o,u,i);if(cK({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&&!Bf&&dK(d,r)&&(c?O1(o,u,i):l?.promise)?.catch(Ua).finally(()=>{u.updateResult()}),o.notifyOnChangeProps?d:u.trackResult(d)}function ut(t,e){return vue(t,UD)}function mt(t,e){const n=on(),[r]=w.useState(()=>new due(n,t));w.useEffect(()=>{r.setOptions(t)},[r,t]);const i=w.useSyncExternalStore(w.useCallback(o=>r.subscribe(si.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=w.useCallback((o,l)=>{r.mutate(o,l).catch(Ua)},[r]);if(i.error&&ID(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}const hK=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim();const _ue=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const wue=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase());const Xz=t=>{const e=wue(t);return e.charAt(0).toUpperCase()+e.slice(1)};var Sue={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 Mue=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0;return!1};const Nue=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,...Sue,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:hK("lucide",i),...!a&&!Mue(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(Nue,{ref:a,iconNode:e,className:hK(`lucide-${_ue(Xz(t))}`,`lucide-${t}`,r),...i}));return n.displayName=Xz(t),n};const Eue=[["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"}]],Aue=Ke("air-vent",Eue);const Tue=[["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"}]],es=Ke("archive",Tue);const Cue=[["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"}]],kue=Ke("arrow-down-wide-narrow",Cue);const jue=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],j0=Ke("arrow-down",jue);const Pue=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],fK=Ke("arrow-left",Pue);const Rue=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],pP=Ke("arrow-right",Rue);const Due=[["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"}]],mK=Ke("arrow-up-down",Due);const Oue=[["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"}]],Lue=Ke("arrow-up-narrow-wide",Oue);const Iue=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],bg=Ke("arrow-up",Iue);const Fue=[["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"}]],Ef=Ke("bell",Fue);const Uue=[["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"}]],zue=Ke("bold",Uue);const Bue=[["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"}]],$ue=Ke("book",Bue);const Hue=[["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"}]],Vue=Ke("bookmark",Hue);const Gue=[["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"}]],Hs=Ke("box",Gue);const Wue=[["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"}]],pK=Ke("briefcase",Wue);const que=[["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"}]],nN=Ke("bug",que);const Kue=[["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"}]],Xue=Ke("cable",Kue);const Yue=[["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"}]],Zue=Ke("calculator",Yue);const Que=[["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"}]],Jue=Ke("calendar-days",Que);const ede=[["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"}]],oi=Ke("calendar",ede);const tde=[["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"}]],Hf=Ke("camera",tde);const nde=[["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"}]],rde=Ke("chart-column",nde);const ide=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],ns=Ke("check",ide);const ade=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Oi=Ke("chevron-down",ade);const sde=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Vf=Ke("chevron-left",sde);const ode=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Js=Ke("chevron-right",ode);const lde=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],pu=Ke("chevron-up",lde);const cde=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],oa=Ke("circle-alert",cde);const ude=[["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"}]],sT=Ke("circle-arrow-up",ude);const dde=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Un=Ke("circle-check-big",dde);const hde=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],rN=Ke("circle-check",hde);const fde=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],mde=Ke("circle-dot",fde);const pde=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],gde=Ke("circle-stop",pde);const xde=[["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"}]],ia=Ke("circle-x",xde);const bde=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],gP=Ke("circle",bde);const yde=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Zn=Ke("clock",yde);const vde=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],iN=Ke("cloud",vde);const _de=[["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"}]],wde=Ke("code-xml",_de);const Sde=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],gK=Ke("code",Sde);const Mde=[["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"}]],Nde=Ke("coffee",Mde);const Ede=[["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"}]],Ade=Ke("cog",Ede);const Tde=[["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"}]],Cde=Ke("compass",Tde);const kde=[["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"}]],ll=Ke("copy",kde);const jde=[["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"}]],y_=Ke("cpu",jde);const Pde=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5v14a9 3 0 0 0 18 0V5",key:"aqi0yr"}]],Rde=Ke("cylinder",Pde);const Dde=[["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"}]],su=Ke("database",Dde);const Ode=[["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"}]],xP=Ke("dollar-sign",Ode);const Lde=[["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"}]],Hr=Ke("download",Lde);const Ide=[["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"}]],BD=Ke("droplet",Ide);const Fde=[["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"}]],$D=Ke("droplets",Fde);const Ude=[["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"}]],zd=Ke("ellipsis-vertical",Ude);const zde=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],oT=Ke("equal",zde);const Bde=[["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"}]],zr=Ke("external-link",Bde);const $de=[["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"}]],My=Ke("eye-off",$de);const Hde=[["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"}]],Qd=Ke("eye",Hde);const Vde=[["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"}]],xK=Ke("fan",Vde);const Gde=[["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"}]],Af=Ke("file-box",Gde);const Wde=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]],L1=Ke("file-code",Wde);const qde=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Kde=Ke("file-exclamation-point",qde);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"}],["path",{d:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]],I1=Ke("file-spreadsheet",Xde);const Yde=[["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"}]],Za=Ke("file-text",Yde);const Zde=[["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"}]],aN=Ke("file",Zde);const Qde=[["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"}]],Bd=Ke("film",Qde);const Jde=[["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"}]],ehe=Ke("flame",Jde);const the=[["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"}]],Ta=Ke("folder-kanban",the);const nhe=[["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"}]],cl=Ke("folder-open",nhe);const rhe=[["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"}]],ihe=Ke("folder-plus",rhe);const ahe=[["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"}]],she=Ke("folder-tree",ahe);const ohe=[["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"}]],bK=Ke("folder",ohe);const lhe=[["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"}]],che=Ke("fullscreen",lhe);const uhe=[["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"}]],sN=Ke("funnel",uhe);const dhe=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],oN=Ke("gauge",dhe);const hhe=[["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"}]],fhe=Ke("gift",hhe);const mhe=[["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"}]],rg=Ke("git-compare",mhe);const phe=[["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"}]],bP=Ke("github",phe);const ghe=[["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"}]],$d=Ke("globe",ghe);const xhe=[["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"}]],yg=Ke("grip-vertical",xhe);const bhe=[["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"}]],yK=Ke("hand",bhe);const yhe=[["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"}]],lN=Ke("hard-drive",yhe);const vhe=[["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"}]],_he=Ke("hash",vhe);const whe=[["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"}]],She=Ke("headphones",whe);const Mhe=[["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"}]],Nhe=Ke("heart",Mhe);const Ehe=[["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"}]],P0=Ke("history",Ehe);const Ahe=[["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"}]],cN=Ke("house",Ahe);const The=[["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"}]],Ny=Ke("image",The);const Che=[["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",Che);const khe=[["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"}]],jhe=Ke("italic",khe);const Phe=[["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"}]],mf=Ke("key",Phe);const Rhe=[["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"}]],yP=Ke("keyboard",Rhe);const Dhe=[["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"}]],ul=Ke("layers",Dhe);const Ohe=[["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"}]],uN=Ke("layout-grid",Ohe);const Lhe=[["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"}]],Ihe=Ke("link-2-off",Lhe);const Fhe=[["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"}]],Wl=Ke("link-2",Fhe);const Uhe=[["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"}]],Jg=Ke("link",Uhe);const zhe=[["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"}]],vK=Ke("list-ordered",zhe);const Bhe=[["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"}]],vP=Ke("list-todo",Bhe);const $he=[["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"}]],dN=Ke("list",$he);const Hhe=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],dt=Ke("loader-circle",Hhe);const Vhe=[["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"}]],Yz=Ke("lock-open",Vhe);const Ghe=[["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"}]],lT=Ke("lock",Ghe);const Whe=[["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"}]],Zz=Ke("log-in",Whe);const qhe=[["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"}]],_P=Ke("log-out",qhe);const Khe=[["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"}]],Xhe=Ke("mail",Khe);const Yhe=[["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"}]],Zhe=Ke("map",Yhe);const Qhe=[["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"}]],_K=Ke("maximize-2",Qhe);const Jhe=[["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"}]],efe=Ke("maximize",Jhe);const tfe=[["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"}]],nfe=Ke("memory-stick",tfe);const rfe=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],ife=Ke("menu",rfe);const afe=[["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"}]],wK=Ke("minimize-2",afe);const sfe=[["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"}]],SK=Ke("minimize",sfe);const ofe=[["path",{d:"M5 12h14",key:"1ays0h"}]],wP=Ke("minus",ofe);const lfe=[["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"}]],cfe=Ke("monitor",lfe);const ufe=[["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"}]],F1=Ke("moon",ufe);const dfe=[["path",{d:"M18 8L22 12L18 16",key:"1r0oui"}],["path",{d:"M2 12H22",key:"1m8cig"}]],hfe=Ke("move-right",dfe);const ffe=[["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"}]],SP=Ke("music",ffe);const mfe=[["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"}]],Jl=Ke("package",mfe);const pfe=[["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"}]],HD=Ke("palette",pfe);const gfe=[["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"}]],VD=Ke("pause",gfe);const xfe=[["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"}]],Gf=Ke("pen-line",xfe);const bfe=[["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"}]],hN=Ke("pen",bfe);const yfe=[["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"}]],la=Ke("pencil",yfe);const vfe=[["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"}]],_fe=Ke("phone",vfe);const wfe=[["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"}]],Oo=Ke("play",wfe);const Sfe=[["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"}]],Ks=Ke("plug",Sfe);const Mfe=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],nr=Ke("plus",Mfe);const Nfe=[["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"}]],fN=Ke("power-off",Nfe);const Efe=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],Eu=Ke("power",Efe);const Afe=[["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"}]],qr=Ke("printer",Afe);const Tfe=[["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"}]],MK=Ke("qr-code",Tfe);const Cfe=[["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"}]],xr=Ke("refresh-cw",Cfe);const kfe=[["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"}]],mm=Ke("rotate-ccw",kfe);const jfe=[["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"}]],Pfe=Ke("ruler",jfe);const Rfe=[["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"}]],_s=Ke("save",Rfe);const Dfe=[["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"}]],U1=Ke("scan-search",Dfe);const Ofe=[["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"}]],Lfe=Ke("scissors",Ofe);const Ife=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Ea=Ke("search",Ife);const Ffe=[["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"}]],GD=Ke("send",Ffe);const Ufe=[["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"}]],ef=Ke("server",Ufe);const zfe=[["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"}]],Jd=Ke("settings-2",zfe);const Bfe=[["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"}]],mN=Ke("settings",Bfe);const $fe=[["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"}]],MP=Ke("shield",$fe);const Hfe=[["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"}]],NK=Ke("shopping-cart",Hfe);const Vfe=[["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"}]],Gfe=Ke("signal",Vfe);const Wfe=[["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"}]],qfe=Ke("skip-back",Wfe);const Kfe=[["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"}]],R0=Ke("skip-forward",Kfe);const Xfe=[["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"}]],Qz=Ke("sliders-vertical",Xfe);const Yfe=[["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"}]],D0=Ke("sparkles",Yfe);const Zfe=[["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"}]],Lo=Ke("square-check-big",Zfe);const Qfe=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}]],Jfe=Ke("square-minus",Qfe);const eme=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Io=Ke("square",eme);const tme=[["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"}]],Wf=Ke("star",tme);const nme=[["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"}]],EK=Ke("sticky-note",nme);const rme=[["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"}]],Jz=Ke("sun",rme);const ime=[["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"}]],vg=Ke("tag",ime);const ame=[["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"}]],AK=Ke("target",ame);const sme=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],TK=Ke("terminal",sme);const ome=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],lme=Ke("text-align-center",ome);const cme=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],ume=Ke("text-align-end",cme);const dme=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],hme=Ke("text-align-start",dme);const fme=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],pN=Ke("thermometer",fme);const mme=[["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"}]],jd=Ke("timer",mme);const pme=[["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"}]],dn=Ke("trash-2",pme);const gme=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],CK=Ke("trending-down",gme);const xme=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],NP=Ke("trending-up",xme);const bme=[["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"}]],kn=Ke("triangle-alert",bme);const yme=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],vme=Ke("underline",yme);const _me=[["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"}]],WD=Ke("unlink",_me);const wme=[["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"}]],pi=Ke("upload",wme);const Sme=[["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"}]],EP=Ke("user",Sme);const Mme=[["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"}]],pf=Ke("users",Mme);const Nme=[["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"}]],qD=Ke("video",Nme);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"}],["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"}]],Ame=Ke("volume-2",Eme);const Tme=[["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"}]],Cme=Ke("volume-x",Tme);const kme=[["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"}]],jme=Ke("wand-sparkles",kme);const Pme=[["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"}]],ex=Ke("wifi-off",Pme);const Rme=[["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"}]],ig=Ke("wifi",Rme);const Dme=[["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"}]],kK=Ke("wind",Dme);const Ome=[["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"}]],eh=Ke("wrench",Ome);const Lme=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Vt=Ke("x",Lme);const Ime=[["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"}]],qf=Ke("zap",Ime);const Fme=[["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"}]],KD=Ke("zoom-in",Fme);const Ume=[["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"}]],XD=Ke("zoom-out",Ume),xn="/api/v1";let z1=localStorage.getItem("auth_token");function zb(t){z1=t,t?localStorage.setItem("auth_token",t):localStorage.removeItem("auth_token")}function eB(){return z1}async function ke(t,e={}){const n={"Content-Type":"application/json",...e.headers};z1&&(n.Authorization=`Bearer ${z1}`);const r=await fetch(`${xn}${t}`,{...e,cache:"no-store",headers:n});if(!r.ok){r.status===401&&zb(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 he={getAuthStatus:()=>ke("/auth/status"),setupAuth:t=>ke("/auth/setup",{method:"POST",body:JSON.stringify(t)}),login:t=>ke("/auth/login",{method:"POST",body:JSON.stringify(t)}),logout:()=>ke("/auth/logout",{method:"POST"}),getCurrentUser:()=>ke("/auth/me"),disableAuth:()=>ke("/auth/disable",{method:"POST"}),getUsers:()=>ke("/users/"),getUser:t=>ke(`/users/${t}`),createUser:t=>ke("/users/",{method:"POST",body:JSON.stringify(t)}),updateUser:(t,e)=>ke(`/users/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteUser:t=>ke(`/users/${t}`,{method:"DELETE"}),getPrinters:()=>ke("/printers/"),getPrinter:t=>ke(`/printers/${t}`),createPrinter:t=>ke("/printers/",{method:"POST",body:JSON.stringify(t)}),updatePrinter:(t,e)=>ke(`/printers/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deletePrinter:(t,e=!0)=>ke(`/printers/${t}?delete_archives=${e}`,{method:"DELETE"}),getPrinterStatus:t=>ke(`/printers/${t}/status`),refreshPrinterStatus:t=>ke(`/printers/${t}/refresh-status`,{method:"POST"}),connectPrinter:t=>ke(`/printers/${t}/connect`,{method:"POST"}),disconnectPrinter:t=>ke(`/printers/${t}/disconnect`,{method:"POST"}),testExternalCamera:(t,e,n)=>ke(`/printers/${t}/camera/external/test?url=${encodeURIComponent(e)}&camera_type=${encodeURIComponent(n)}`,{method:"POST"}),stopPrint:t=>ke(`/printers/${t}/print/stop`,{method:"POST"}),pausePrint:t=>ke(`/printers/${t}/print/pause`,{method:"POST"}),resumePrint:t=>ke(`/printers/${t}/print/resume`,{method:"POST"}),setChamberLight:(t,e)=>ke(`/printers/${t}/chamber-light?on=${e}`,{method:"POST"}),getPrintableObjects:t=>ke(`/printers/${t}/print/objects`),skipObjects:(t,e)=>ke(`/printers/${t}/print/skip-objects`,{method:"POST",body:JSON.stringify(e)}),refreshAmsSlot:(t,e,n)=>ke(`/printers/${t}/ams/${e}/slot/${n}/refresh`,{method:"POST"}),enableMQTTLogging:t=>ke(`/printers/${t}/logging/enable`,{method:"POST"}),disableMQTTLogging:t=>ke(`/printers/${t}/logging/disable`,{method:"POST"}),getMQTTLogs:t=>ke(`/printers/${t}/logging`),clearMQTTLogs:t=>ke(`/printers/${t}/logging`,{method:"DELETE"}),getPrinterFiles:(t,e="/")=>ke(`/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)=>ke(`/printers/${t}/files?path=${encodeURIComponent(e)}`,{method:"DELETE"}),getPrinterStorage:t=>ke(`/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)),ke(`/archives/?${i}`)},getArchive:t=>ke(`/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)),ke(`/archives/search?${n}`)},rebuildSearchIndex:()=>ke("/archives/search/rebuild-index",{method:"POST"}),updateArchive:(t,e)=>ke(`/archives/${t}`,{method:"PATCH",body:JSON.stringify(e)}),toggleFavorite:t=>ke(`/archives/${t}/favorite`,{method:"POST"}),deleteArchive:t=>ke(`/archives/${t}`,{method:"DELETE"}),getArchiveStats:()=>ke("/archives/stats"),recalculateCosts:()=>ke("/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)),ke(`/archives/analysis/failures?${e}`)},compareArchives:t=>ke(`/archives/compare?archive_ids=${t.join(",")}`),findSimilarArchives:(t,e=10)=>ke(`/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=>ke(`/archives/${t}/duplicates`),backfillContentHashes:()=>ke("/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=>ke(`/archives/${t}/timelapse/scan`,{method:"POST"}),selectArchiveTimelapse:(t,e)=>ke(`/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=>ke(`/archives/${t}/timelapse/info`),getTimelapseThumbnails:(t,e=10)=>ke(`/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)=>ke(`/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=>ke(`/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=>ke(`/archives/${t}/f3d`,{method:"DELETE"}),getArchiveQRCodeUrl:(t,e=200)=>`${xn}/archives/${t}/qrcode?size=${e}`,getArchiveCapabilities:t=>ke(`/archives/${t}/capabilities`),getArchiveProjectPage:t=>ke(`/archives/${t}/project-page`),updateArchiveProjectPage:(t,e)=>ke(`/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=>ke(`/archives/${t}/plates`),getArchiveFilamentRequirements:(t,e)=>ke(`/archives/${t}/filament-requirements${e!==void 0?`?plate_id=${e}`:""}`),reprintArchive:(t,e,n)=>ke(`/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:()=>ke("/settings/"),updateSettings:t=>ke("/settings/",{method:"PUT",body:JSON.stringify(t)}),getMQTTStatus:()=>ke("/settings/mqtt/status"),resetSettings:()=>ke("/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.plate_calibration!==void 0&&e.set("include_plate_calibration",String(t.plate_calibration)),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:()=>ke("/settings/check-ffmpeg"),getCloudStatus:()=>ke("/cloud/status"),cloudLogin:(t,e,n="global")=>ke("/cloud/login",{method:"POST",body:JSON.stringify({email:t,password:e,region:n})}),cloudVerify:(t,e)=>ke("/cloud/verify",{method:"POST",body:JSON.stringify({email:t,code:e})}),cloudSetToken:t=>ke("/cloud/token",{method:"POST",body:JSON.stringify({access_token:t})}),cloudLogout:()=>ke("/cloud/logout",{method:"POST"}),getCloudSettings:(t="02.04.00.70")=>ke(`/cloud/settings?version=${t}`),getCloudSettingDetail:t=>ke(`/cloud/settings/${t}`),createCloudSetting:t=>ke("/cloud/settings",{method:"POST",body:JSON.stringify(t)}),updateCloudSetting:(t,e)=>ke(`/cloud/settings/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteCloudSetting:t=>ke(`/cloud/settings/${t}`,{method:"DELETE"}),getCloudDevices:()=>ke("/cloud/devices"),getCloudFields:t=>ke(`/cloud/fields/${t}`),getAllCloudFields:()=>ke("/cloud/fields"),getFilamentInfo:t=>ke("/cloud/filament-info",{method:"POST",body:JSON.stringify(t)}),getSmartPlugs:()=>ke("/smart-plugs/"),getSmartPlug:t=>ke(`/smart-plugs/${t}`),getSmartPlugByPrinter:t=>ke(`/smart-plugs/by-printer/${t}`),createSmartPlug:t=>ke("/smart-plugs/",{method:"POST",body:JSON.stringify(t)}),updateSmartPlug:(t,e)=>ke(`/smart-plugs/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteSmartPlug:t=>ke(`/smart-plugs/${t}`,{method:"DELETE"}),controlSmartPlug:(t,e)=>ke(`/smart-plugs/${t}/control`,{method:"POST",body:JSON.stringify({action:e})}),getSmartPlugStatus:t=>ke(`/smart-plugs/${t}/status`),testSmartPlugConnection:(t,e,n)=>ke("/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:()=>ke("/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:()=>ke("/smart-plugs/discover/devices"),testHAConnection:(t,e)=>ke("/smart-plugs/ha/test-connection",{method:"POST",body:JSON.stringify({url:t,token:e})}),getHAEntities:t=>{const e=t?`?search=${encodeURIComponent(t)}`:"";return ke(`/smart-plugs/ha/entities${e}`)},getHASensorEntities:()=>ke("/smart-plugs/ha/sensors"),getQueue:(t,e)=>{const n=new URLSearchParams;return t&&n.set("printer_id",String(t)),e&&n.set("status",e),ke(`/queue/?${n}`)},getQueueItem:t=>ke(`/queue/${t}`),addToQueue:t=>ke("/queue/",{method:"POST",body:JSON.stringify(t)}),updateQueueItem:(t,e)=>ke(`/queue/${t}`,{method:"PATCH",body:JSON.stringify(e)}),removeFromQueue:t=>ke(`/queue/${t}`,{method:"DELETE"}),reorderQueue:t=>ke("/queue/reorder",{method:"POST",body:JSON.stringify({items:t})}),cancelQueueItem:t=>ke(`/queue/${t}/cancel`,{method:"POST"}),stopQueueItem:t=>ke(`/queue/${t}/stop`,{method:"POST"}),startQueueItem:t=>ke(`/queue/${t}/start`,{method:"POST"}),bulkUpdateQueue:t=>ke("/queue/bulk",{method:"PATCH",body:JSON.stringify(t)}),getKProfiles:(t,e="0.4")=>ke(`/printers/${t}/kprofiles/?nozzle_diameter=${e}`),setKProfile:(t,e)=>ke(`/printers/${t}/kprofiles/`,{method:"POST",body:JSON.stringify(e)}),deleteKProfile:(t,e)=>ke(`/printers/${t}/kprofiles/`,{method:"DELETE",body:JSON.stringify(e)}),setKProfilesBatch:(t,e)=>ke(`/printers/${t}/kprofiles/batch`,{method:"POST",body:JSON.stringify(e)}),getKProfileNotes:t=>ke(`/printers/${t}/kprofiles/notes`),setKProfileNote:(t,e,n)=>ke(`/printers/${t}/kprofiles/notes`,{method:"PUT",body:JSON.stringify({setting_id:e,note:n})}),deleteKProfileNote:(t,e)=>ke(`/printers/${t}/kprofiles/notes/${encodeURIComponent(e)}`,{method:"DELETE"}),getSlotPresets:t=>ke(`/printers/${t}/slot-presets`),getSlotPreset:(t,e,n)=>ke(`/printers/${t}/slot-presets/${e}/${n}`),saveSlotPreset:(t,e,n,r,i)=>ke(`/printers/${t}/slot-presets/${e}/${n}?preset_id=${encodeURIComponent(r)}&preset_name=${encodeURIComponent(i)}`,{method:"PUT"}),deleteSlotPreset:(t,e,n)=>ke(`/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()),ke(`/printers/${t}/slots/${e}/${n}/configure?${i}`,{method:"POST"})},resetAmsSlot:(t,e,n)=>ke(`/printers/${t}/ams/${e}/tray/${n}/reset`,{method:"POST"}),listFilaments:()=>ke("/filaments/"),getFilament:t=>ke(`/filaments/${t}`),getFilamentsByType:t=>ke(`/filaments/by-type/${t}`),getNotificationProviders:()=>ke("/notifications/"),getNotificationProvider:t=>ke(`/notifications/${t}`),createNotificationProvider:t=>ke("/notifications/",{method:"POST",body:JSON.stringify(t)}),updateNotificationProvider:(t,e)=>ke(`/notifications/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteNotificationProvider:t=>ke(`/notifications/${t}`,{method:"DELETE"}),testNotificationProvider:t=>ke(`/notifications/${t}/test`,{method:"POST"}),testNotificationConfig:t=>ke("/notifications/test-config",{method:"POST",body:JSON.stringify(t)}),testAllNotificationProviders:()=>ke("/notifications/test-all",{method:"POST"}),getNotificationTemplates:()=>ke("/notification-templates"),getNotificationTemplate:t=>ke(`/notification-templates/${t}`),updateNotificationTemplate:(t,e)=>ke(`/notification-templates/${t}`,{method:"PUT",body:JSON.stringify(e)}),resetNotificationTemplate:t=>ke(`/notification-templates/${t}/reset`,{method:"POST"}),getTemplateVariables:()=>ke("/notification-templates/variables"),previewTemplate:t=>ke("/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)),ke(`/notifications/logs?${e}`)},getNotificationLogStats:(t=7)=>ke(`/notifications/logs/stats?days=${t}`),clearNotificationLogs:(t=30)=>ke(`/notifications/logs?older_than_days=${t}`,{method:"DELETE"}),getSpoolmanStatus:()=>ke("/spoolman/status"),connectSpoolman:()=>ke("/spoolman/connect",{method:"POST"}),disconnectSpoolman:()=>ke("/spoolman/disconnect",{method:"POST"}),syncPrinterAms:t=>ke(`/spoolman/sync/${t}`,{method:"POST"}),syncAllPrintersAms:()=>ke("/spoolman/sync-all",{method:"POST"}),getSpoolmanSpools:()=>ke("/spoolman/spools"),getSpoolmanFilaments:()=>ke("/spoolman/filaments"),getUnlinkedSpools:()=>ke("/spoolman/spools/unlinked"),linkSpool:(t,e)=>ke(`/spoolman/spools/${t}/link`,{method:"POST",body:JSON.stringify({tray_uuid:e})}),getVersion:()=>ke("/updates/version"),checkForUpdates:()=>ke("/updates/check"),applyUpdate:()=>ke("/updates/apply",{method:"POST"}),getUpdateStatus:()=>ke("/updates/status"),getMaintenanceTypes:()=>ke("/maintenance/types"),createMaintenanceType:t=>ke("/maintenance/types",{method:"POST",body:JSON.stringify(t)}),updateMaintenanceType:(t,e)=>ke(`/maintenance/types/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteMaintenanceType:t=>ke(`/maintenance/types/${t}`,{method:"DELETE"}),getMaintenanceOverview:()=>ke("/maintenance/overview"),getPrinterMaintenance:t=>ke(`/maintenance/printers/${t}`),updateMaintenanceItem:(t,e)=>ke(`/maintenance/items/${t}`,{method:"PATCH",body:JSON.stringify(e)}),performMaintenance:(t,e)=>ke(`/maintenance/items/${t}/perform`,{method:"POST",body:JSON.stringify({notes:e})}),getMaintenanceHistory:t=>ke(`/maintenance/items/${t}/history`),getMaintenanceSummary:()=>ke("/maintenance/summary"),setPrinterHours:(t,e)=>ke(`/maintenance/printers/${t}/hours?total_hours=${e}`,{method:"PATCH"}),assignMaintenanceType:(t,e)=>ke(`/maintenance/printers/${t}/assign/${e}`,{method:"POST"}),removeMaintenanceItem:t=>ke(`/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=>ke(`/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)),ke(`/printers/${t}/camera/check-plate?${n.toString()}`)},getPlateDetectionStatus:t=>ke(`/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)),ke(`/printers/${t}/camera/plate-detection/calibrate?${n.toString()}`,{method:"POST"})},deletePlateCalibration:t=>ke(`/printers/${t}/camera/plate-detection/calibrate`,{method:"DELETE"}),getPlateReferences:t=>ke(`/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),ke(`/printers/${t}/camera/plate-detection/references/${e}?${r.toString()}`,{method:"PUT"})},deletePlateReference:(t,e)=>ke(`/printers/${t}/camera/plate-detection/references/${e}`,{method:"DELETE"}),getExternalLinks:()=>ke("/external-links/"),getExternalLink:t=>ke(`/external-links/${t}`),createExternalLink:t=>ke("/external-links/",{method:"POST",body:JSON.stringify(t)}),updateExternalLink:(t,e)=>ke(`/external-links/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteExternalLink:t=>ke(`/external-links/${t}`,{method:"DELETE"}),reorderExternalLinks:t=>ke("/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=>ke(`/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),ke(`/projects/?${e}`)},getProject:t=>ke(`/projects/${t}`),createProject:t=>ke("/projects/",{method:"POST",body:JSON.stringify(t)}),updateProject:(t,e)=>ke(`/projects/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteProject:t=>ke(`/projects/${t}`,{method:"DELETE"}),getProjectArchives:(t,e=100,n=0)=>ke(`/projects/${t}/archives?limit=${e}&offset=${n}`),addArchivesToProject:(t,e)=>ke(`/projects/${t}/add-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),removeArchivesFromProject:(t,e)=>ke(`/projects/${t}/remove-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),addQueueItemsToProject:(t,e)=>ke(`/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)=>ke(`/projects/${t}/attachments/${encodeURIComponent(e)}`,{method:"DELETE"}),getProjectBOM:t=>ke(`/projects/${t}/bom`),createBOMItem:(t,e)=>ke(`/projects/${t}/bom`,{method:"POST",body:JSON.stringify(e)}),updateBOMItem:(t,e,n)=>ke(`/projects/${t}/bom/${e}`,{method:"PATCH",body:JSON.stringify(n)}),deleteBOMItem:(t,e)=>ke(`/projects/${t}/bom/${e}`,{method:"DELETE"}),getTemplates:()=>ke("/projects/templates/"),createTemplateFromProject:t=>ke(`/projects/${t}/create-template`,{method:"POST"}),createProjectFromTemplate:(t,e)=>ke(`/projects/from-template/${t}${e?`?name=${encodeURIComponent(e)}`:""}`,{method:"POST"}),getProjectTimeline:(t,e=50)=>ke(`/projects/${t}/timeline?limit=${e}`),exportProjectJson:t=>ke(`/projects/${t}/export?format=json`),importProject:t=>ke("/projects/import",{method:"POST",body:JSON.stringify(t)}),getAPIKeys:()=>ke("/api-keys/"),createAPIKey:t=>ke("/api-keys/",{method:"POST",body:JSON.stringify(t)}),updateAPIKey:(t,e)=>ke(`/api-keys/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteAPIKey:t=>ke(`/api-keys/${t}`,{method:"DELETE"}),getAMSHistory:(t,e,n=24)=>ke(`/ams-history/${t}/${e}?hours=${n}`),getSystemInfo:()=>ke("/system/info"),getLibraryFolders:()=>ke("/library/folders"),createLibraryFolder:t=>ke("/library/folders",{method:"POST",body:JSON.stringify(t)}),updateLibraryFolder:(t,e)=>ke(`/library/folders/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteLibraryFolder:t=>ke(`/library/folders/${t}`,{method:"DELETE"}),getLibraryFoldersByProject:t=>ke(`/library/folders/by-project/${t}`),getLibraryFoldersByArchive:t=>ke(`/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)),ke(`/library/files?${n}`)},getLibraryFile:t=>ke(`/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)=>ke(`/library/files/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteLibraryFile:t=>ke(`/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)=>ke("/library/files/move",{method:"POST",body:JSON.stringify({file_ids:t,folder_id:e})}),bulkDeleteLibrary:(t,e)=>ke("/library/bulk-delete",{method:"POST",body:JSON.stringify({file_ids:t,folder_ids:e})}),getLibraryStats:()=>ke("/library/stats"),addLibraryFilesToQueue:t=>ke("/library/files/add-to-queue",{method:"POST",body:JSON.stringify({file_ids:t})}),printLibraryFile:(t,e,n)=>ke(`/library/files/${t}/print?printer_id=${e}`,{method:"POST",body:n?JSON.stringify(n):void 0}),getLibraryFilePlates:t=>ke(`/library/files/${t}/plates`),getLibraryFileFilamentRequirements:(t,e)=>ke(`/library/files/${t}/filament-requirements${e!==void 0?`?plate_id=${e}`:""}`),getGitHubBackupConfig:()=>ke("/github-backup/config"),saveGitHubBackupConfig:t=>ke("/github-backup/config",{method:"POST",body:JSON.stringify(t)}),updateGitHubBackupConfig:t=>ke("/github-backup/config",{method:"PATCH",body:JSON.stringify(t)}),deleteGitHubBackupConfig:()=>ke("/github-backup/config",{method:"DELETE"}),testGitHubConnection:(t,e)=>ke(`/github-backup/test?repo_url=${encodeURIComponent(t)}&token=${encodeURIComponent(e)}`,{method:"POST"}),testGitHubStoredConnection:()=>ke("/github-backup/test-stored",{method:"POST"}),triggerGitHubBackup:()=>ke("/github-backup/run",{method:"POST"}),getGitHubBackupStatus:()=>ke("/github-backup/status"),getGitHubBackupLogs:(t=50)=>ke(`/github-backup/logs?limit=${t}`),clearGitHubBackupLogs:(t=10)=>ke(`/github-backup/logs?keep_last=${t}`,{method:"DELETE"})},Nl={getInfo:()=>ke("/discovery/info"),getStatus:()=>ke("/discovery/status"),startDiscovery:(t=10)=>ke(`/discovery/start?duration=${t}`,{method:"POST"}),stopDiscovery:()=>ke("/discovery/stop",{method:"POST"}),getDiscoveredPrinters:()=>ke("/discovery/printers"),startSubnetScan:(t,e=1)=>ke("/discovery/scan",{method:"POST",body:JSON.stringify({subnet:t,timeout:e})}),getScanStatus:()=>ke("/discovery/scan/status"),stopSubnetScan:()=>ke("/discovery/scan/stop",{method:"POST"})},r1={getSettings:()=>ke("/settings/virtual-printer"),getModels:()=>ke("/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),ke(`/settings/virtual-printer?${e.toString()}`,{method:"PUT"})}},Vp={list:()=>ke("/pending-uploads/"),getCount:()=>ke("/pending-uploads/count"),get:t=>ke(`/pending-uploads/${t}`),archive:(t,e)=>ke(`/pending-uploads/${t}/archive`,{method:"POST",body:JSON.stringify(e||{})}),discard:t=>ke(`/pending-uploads/${t}`,{method:"DELETE"}),archiveAll:()=>ke("/pending-uploads/archive-all",{method:"POST"}),discardAll:()=>ke("/pending-uploads/discard-all",{method:"DELETE"})},i1={checkUpdates:()=>ke("/firmware/updates"),checkPrinterUpdate:t=>ke(`/firmware/updates/${t}`),prepareUpload:t=>ke(`/firmware/updates/${t}/prepare`),startUpload:t=>ke(`/firmware/updates/${t}/upload`,{method:"POST"}),getUploadStatus:t=>ke(`/firmware/updates/${t}/upload/status`)},ag={getDebugLoggingState:()=>ke("/support/debug-logging"),setDebugLogging:t=>ke("/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 ke(`/support/logs${n?`?${n}`:""}`)},clearLogs:()=>ke("/support/logs",{method:"DELETE"})},jK=w.createContext(void 0);function zme({children:t}){const[e,n]=w.useState(()=>{const E=localStorage.getItem("theme-mode"),O=localStorage.getItem("theme");return E||O||"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(()=>{he.getSettings().then(E=>{E.dark_style&&(i(E.dark_style),localStorage.setItem("dark-style",E.dark_style)),E.dark_background&&(o(E.dark_background),localStorage.setItem("dark-background",E.dark_background)),E.dark_accent&&(c(E.dark_accent),localStorage.setItem("dark-accent",E.dark_accent)),E.light_style&&(d(E.light_style),localStorage.setItem("light-style",E.light_style)),E.light_background&&(m(E.light_background),localStorage.setItem("light-background",E.light_background)),E.light_accent&&(b(E.light_accent),localStorage.setItem("light-accent",E.light_accent))}).catch(()=>{})},[]),w.useEffect(()=>{const E=document.documentElement;E.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"?(E.classList.add("dark"),E.classList.add(`style-${r}`),E.classList.add(`bg-${a}`),E.classList.add(`accent-${l}`)):(E.classList.add(`style-${u}`),E.classList.add(`bg-${f}`),E.classList.add(`accent-${p}`)),localStorage.setItem("theme-mode",e),localStorage.removeItem("theme")},[e,r,a,l,u,f,p]);const y=()=>n(E=>E==="dark"?"light":"dark"),x=E=>n(E),v=E=>{i(E),localStorage.setItem("dark-style",E),he.updateSettings({dark_style:E}).catch(()=>{})},S=E=>{o(E),localStorage.setItem("dark-background",E),he.updateSettings({dark_background:E}).catch(()=>{})},M=E=>{c(E),localStorage.setItem("dark-accent",E),he.updateSettings({dark_accent:E}).catch(()=>{})},A=E=>{d(E),localStorage.setItem("light-style",E),he.updateSettings({light_style:E}).catch(()=>{})},T=E=>{m(E),localStorage.setItem("light-background",E),he.updateSettings({light_background:E}).catch(()=>{})},k=E=>{b(E),localStorage.setItem("light-accent",E),he.updateSettings({light_accent:E}).catch(()=>{})};return s.jsx(jK.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:A,setLightBackground:T,setLightAccent:k},children:t})}function hh(){const t=w.useContext(jK);if(!t)throw new Error("useTheme must be used within ThemeProvider");return t}function St({children:t,className:e="",onClick:n,onContextMenu:r,...i}){return s.jsx("div",{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary card-shadow ${e}`,onClick:n,onContextMenu:r,...i,children:t})}function er({children:t,className:e=""}){return s.jsx("div",{className:`px-6 py-4 border-b border-bambu-dark-tertiary ${e}`,children:t})}function Nt({children:t,className:e=""}){return s.jsx("div",{className:`p-6 ${e}`,children:t})}function Bme(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 tB({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 $me({onClose:t,navItems:e,sidebarItems:n}){const{t:r}=Xg(),i=Bme(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(St,{className:"w-full max-w-md",onClick:a=>a.stopPropagation(),children:s.jsxs(Nt,{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(yP,{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(Vt,{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(zr,{className:"w-3 h-3 text-bambu-gray"})]}),s.jsx("div",{className:"flex gap-1",children:o.keys.map(l=>s.jsx(tB,{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(tB,{children:"Esc"})," or click outside to close"]})})]})})})}function Se({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 Hn({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(St,{className:"w-full max-w-md",onClick:f=>f.stopPropagation(),children:s.jsxs(Nt,{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(kn,{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(Se,{variant:"secondary",onClick:c,className:"flex-1",disabled:a,children:r}),s.jsx(Se,{onClick:l,className:`flex-1 ${d.button}`,disabled:a,children:a?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 mr-2 animate-spin"}),o||"Processing..."]}):n})]})]})})})}function Hme({plug:t}){const e=on(),[n,r]=w.useState(null),{data:i,isLoading:a}=ut({queryKey:["smart-plug-status",t.id],queryFn:()=>he.getSmartPlugStatus(t.id),refetchInterval:1e4}),o=mt({mutationFn:f=>he.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(Ks,{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(dt,{className:"w-3 h-3 text-bambu-gray animate-spin"}):c?s.jsxs(s.Fragment,{children:[s.jsx(ig,{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(qf,{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(ex,{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(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(Eu,{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(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(fN,{className:"w-4 h-4"})})]})]}),n&&s.jsx(Hn,{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 nB({onClose:t}){const{data:e,isLoading:n}=ut({queryKey:["smart-plugs"],queryFn:he.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(Ks,{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(dt,{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(Ks,{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(Hme,{plug:i},i.id))})})]})}const PK=[{name:"globe",icon:$d},{name:"link",icon:Jg},{name:"external-link",icon:zr},{name:"book",icon:$ue},{name:"file-text",icon:Za},{name:"home",icon:cN},{name:"star",icon:Wf},{name:"heart",icon:Nhe},{name:"bookmark",icon:Vue},{name:"shopping-cart",icon:NK},{name:"music",icon:SP},{name:"video",icon:qD},{name:"image",icon:Ny},{name:"camera",icon:Hf},{name:"map",icon:Zhe},{name:"compass",icon:Cde},{name:"coffee",icon:Nde},{name:"gift",icon:fhe},{name:"wrench",icon:eh},{name:"zap",icon:qf},{name:"cloud",icon:iN},{name:"database",icon:su},{name:"folder",icon:bK},{name:"mail",icon:Xhe},{name:"phone",icon:_fe},{name:"user",icon:EP},{name:"users",icon:pf},{name:"server",icon:ef},{name:"terminal",icon:TK},{name:"code",icon:gK}];function gN(t){return PK.find(n=>n.name===t)?.icon||Jg}function Vme({value:t,onChange:e}){const[n,r]=w.useState(!1),i=gN(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:PK.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 rB=768;function RK(){const[t,e]=w.useState(()=>typeof window<"u"?window.innerWidth<rB:!1);return w.useEffect(()=>{const n=window.matchMedia(`(max-width: ${rB-1}px)`),r=i=>{e(i.matches)};return e(n.matches),n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),t}const DK=w.createContext(void 0);function Gme({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 he.getAuthStatus();if(!d.current)return;if(i(x.auth_enabled),o(x.requires_setup),x.auth_enabled)if(eB())try{const S=await he.getCurrentUser();if(!d.current)return;n(S)}catch{if(zb(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 he.login({username:x,password:v});zb(S.access_token),n(S.user)},p=()=>{zb(null),n(null),he.logout().catch(()=>{}),window.location.href="/login"},b=async()=>{if(r&&eB())try{const x=await he.getCurrentUser();d.current&&n(x)}catch{zb(null),d.current&&n(null)}},y=async()=>{await f()};return s.jsx(DK.Provider,{value:{user:e,authEnabled:r,requiresSetup:a,loading:l,login:m,logout:p,refreshUser:b,refreshAuth:y},children:t})}function fh(){const t=w.useContext(DK);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t}const O0=[{id:"printers",to:"/",icon:qr,labelKey:"nav.printers"},{id:"archives",to:"/archives",icon:es,labelKey:"nav.archives"},{id:"queue",to:"/queue",icon:oi,labelKey:"nav.queue"},{id:"stats",to:"/stats",icon:rde,labelKey:"nav.stats"},{id:"profiles",to:"/profiles",icon:iN,labelKey:"nav.profiles"},{id:"maintenance",to:"/maintenance",icon:eh,labelKey:"nav.maintenance"},{id:"projects",to:"/projects",icon:Ta,labelKey:"nav.projects"},{id:"files",to:"/files",icon:cl,labelKey:"nav.files"},{id:"settings",to:"/settings",icon:mN,labelKey:"nav.settings"}];function Wme(){const t=localStorage.getItem("sidebarOrder");if(t)try{return JSON.parse(t)}catch{return O0.map(e=>e.id)}return O0.map(e=>e.id)}function qme(t){localStorage.setItem("sidebarOrder",JSON.stringify(t))}function cT(t){return t.startsWith("ext-")}function OK(){return localStorage.getItem("defaultView")||"/"}function Kme(t){localStorage.setItem("defaultView",t)}function Xme(){const t=gl(),e=cc(),{mode:n,toggleMode:r}=hh(),{t:i}=Xg(),a=RK(),{user:o,authEnabled:l,logout:c}=fh(),[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(Wme),[M,A]=w.useState(null),[T,k]=w.useState(null),E=w.useRef(!1),[O,C]=w.useState(()=>sessionStorage.getItem("dismissedUpdateVersion")),[D,U]=w.useState(null),{data:L}=ut({queryKey:["version"],queryFn:he.getVersion,staleTime:1/0}),{data:q}=ut({queryKey:["settings"],queryFn:he.getSettings,staleTime:300*1e3}),{data:P}=ut({queryKey:["updateCheck"],queryFn:he.checkForUpdates,enabled:q?.check_updates!==!1,staleTime:3600*1e3,refetchInterval:3600*1e3}),{data:W}=ut({queryKey:["external-links"],queryFn:he.getExternalLinks}),{data:K}=ut({queryKey:["smart-plugs"],queryFn:he.getSmartPlugs,staleTime:30*1e3}),V=K?.some(X=>X.show_in_switchbar)??!1,{data:Q}=ut({queryKey:["debugLogging"],queryFn:ag.getDebugLoggingState,staleTime:60*1e3,refetchInterval:60*1e3}),{data:re}=ut({queryKey:["queue","pending"],queryFn:()=>he.getQueue(void 0,"pending"),staleTime:5*1e3,refetchInterval:5*1e3,refetchOnWindowFocus:!0}),J=re?.length??0,{data:z}=ut({queryKey:["pending-uploads","count"],queryFn:Vp.getCount,staleTime:5*1e3,refetchInterval:5*1e3,refetchOnWindowFocus:!0}),G=z?.count??0,[ne,ae]=w.useState(null);w.useEffect(()=>{if(!Q?.enabled||!Q.enabled_at){ae(null);return}const X=new Date(Q.enabled_at).getTime(),B=()=>{ae(Math.floor((Date.now()-X)/1e3))};B();const I=setInterval(B,1e3);return()=>clearInterval(I)},[Q?.enabled,Q?.enabled_at]);const de=w.useMemo(()=>new Map(O0.map(X=>[X.id,X])),[]),fe=w.useMemo(()=>new Map((W||[]).map(X=>[`ext-${X.id}`,X])),[W]),ie=(()=>{const X=[],B=new Set,I=l&&o?.role==="user";for(const ce of v)I&&ce==="settings"||(de.has(ce)||fe.has(ce))&&(X.push(ce),B.add(ce));for(const ce of O0)I&&ce.id==="settings"||B.has(ce.id)||(X.push(ce.id),B.add(ce.id));for(const ce of W||[]){const Te=`ext-${ce.id}`;B.has(Te)||(X.push(Te),B.add(Te))}return X})(),Ae=(X,B)=>{A(B),X.dataTransfer.effectAllowed="move",X.dataTransfer.setData("text/plain",B)},me=(X,B)=>{X.preventDefault(),X.dataTransfer.dropEffect="move",k(B)},Ne=()=>{k(null)},ye=(X,B)=>{if(X.preventDefault(),M===null||M===B){A(null),k(null);return}const I=[...ie],ce=I.indexOf(M),Te=I.indexOf(B);if(ce===-1||Te===-1){A(null),k(null);return}I.splice(ce,1),I.splice(Te,0,M),S(I),qme(I),A(null),k(null)},le=()=>{A(null),k(null)},$e=P?.update_available&&P.latest_version&&P.latest_version!==O,H=()=>{P?.latest_version&&(sessionStorage.setItem("dismissedUpdateVersion",P.latest_version),C(P.latest_version))};w.useEffect(()=>{if(!E.current&&e.pathname==="/"){const X=OK();X!=="/"&&(E.current=!0,t(X,{replace:!0}))}},[e.pathname,t]),w.useEffect(()=>{localStorage.setItem("sidebarExpanded",String(u))},[u]),w.useEffect(()=>{a&&m(!1)},[e.pathname,a]),w.useEffect(()=>{const X=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",X),()=>window.removeEventListener("plate-not-empty",X)},[]);const ee=w.useCallback(X=>{const B=X.target;if(!(B.tagName==="INPUT"||B.tagName==="TEXTAREA"||B.isContentEditable)&&!X.metaKey&&!X.ctrlKey&&!X.altKey){const I=parseInt(X.key);if(I>=1&&I<=ie.length&&I<=9){const ce=ie[I-1];if(X.preventDefault(),cT(ce)){const Te=ce.replace("ext-","");t(`/external/${Te}`)}else{const Te=de.get(ce);Te&&t(Te.to)}return}switch(X.key){case"?":X.preventDefault(),b(!0);break;case"Escape":b(!1);break}}},[t,ie,de]);return w.useEffect(()=>(document.addEventListener("keydown",ee),()=>document.removeEventListener("keydown",ee)),[ee]),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(ife,{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:ie.map(X=>{if(cT(X)){const I=fe.get(X);if(!I)return null;const ce=I.custom_icon?null:gN(I.icon);return s.jsx("li",{draggable:!0,onDragStart:Te=>Ae(Te,X),onDragOver:Te=>me(Te,X),onDragLeave:Ne,onDrop:Te=>ye(Te,X),onDragEnd:le,className:`relative ${M===X?"opacity-50":""} ${T===X&&M!==X?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:s.jsxs(Ub,{to:`/external/${I.id}`,className:({isActive:Te})=>`flex items-center ${a||u?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${Te?"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(yg,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),I.custom_icon?s.jsx("img",{src:`/api/v1/external-links/${I.id}/icon`,alt:"",className:`w-5 h-5 flex-shrink-0 ${n==="dark"?"invert opacity-[0.65]":"opacity-60"}`}):ce&&s.jsx(ce,{className:"w-5 h-5 flex-shrink-0"}),(a||u)&&s.jsx("span",{children:I.name})]})},X)}else{const I=de.get(X);if(!I)return null;const{to:ce,icon:Te,labelKey:Le}=I,Ee=X==="queue"&&J>0,$=X==="archives"&&G>0,j=Ee?J:$?G:0,Y=Ee||$;return s.jsx("li",{draggable:!0,onDragStart:ge=>Ae(ge,X),onDragOver:ge=>me(ge,X),onDragLeave:Ne,onDrop:ge=>ye(ge,X),onDragEnd:le,className:`relative ${M===X?"opacity-50":""} ${T===X&&M!==X?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:s.jsxs(Ub,{to:ce,className:({isActive:ge})=>`flex items-center ${a||u?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${ge?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!a&&!u?i(Le):void 0,children:[u&&!a&&s.jsx(yg,{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(Te,{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:j>99?"99+":j})]}),(a||u)&&s.jsx("span",{children:i(Le)})]})},X)}})})}),!a&&s.jsx("button",{onClick:()=>d(!u),className:"p-2 mx-2 mb-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white flex items-center justify-center",title:i(u?"nav.collapseSidebar":"nav.expandSidebar"),children:u?s.jsx(Vf,{className:"w-5 h-5"}):s.jsx(Js,{className:"w-5 h-5"})}),s.jsx("div",{className:"p-2 border-t border-bambu-dark-tertiary",children:a||u?s.jsxs("div",{className:"flex flex-col gap-2 px-2",children:[s.jsxs("div",{className:"flex items-center justify-center gap-1",children:[V&&s.jsxs("div",{className:"relative",children:[s.jsx("button",{onMouseEnter:()=>x(!0),className:`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${y?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.smartSwitches",{defaultValue:"Smart Switches"}),children:s.jsx(Ks,{className:"w-5 h-5"})}),y&&s.jsx(nB,{onClose:()=>x(!1)})]}),s.jsx(Ub,{to:"/system",className:({isActive:X})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${X?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:s.jsx(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(bP,{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(yP,{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(Jz,{className:"w-5 h-5"}):s.jsx(F1,{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(_P,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"flex items-center justify-center gap-2",children:[s.jsxs("span",{className:"text-sm text-bambu-gray",children:["v",L?.version||"..."]}),P?.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:P.latest_version}),children:[s.jsx(sT,{className:"w-4 h-4"}),s.jsx("span",{children:i("nav.update")})]})]})]}):s.jsxs("div",{className:"flex flex-col items-center gap-1",children:[P?.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:P.latest_version}),children:s.jsx(sT,{className:"w-5 h-5"})}),V&&s.jsxs("div",{className:"relative",children:[s.jsx("button",{onMouseEnter:()=>x(!0),className:`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${y?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.smartSwitches",{defaultValue:"Smart Switches"}),children:s.jsx(Ks,{className:"w-5 h-5"})}),y&&s.jsx(nB,{onClose:()=>x(!1)})]}),s.jsx(Ub,{to:"/system",className:({isActive:X})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${X?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:s.jsx(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(bP,{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(yP,{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(Jz,{className:"w-5 h-5"}):s.jsx(F1,{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(_P,{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:[Q?.enabled&&s.jsx("div",{className:"bg-amber-500/20 border-b border-amber-500/30 px-4 py-2 flex items-center justify-between",children:s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(nN,{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"})})]})}),$e&&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(sT,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{children:i("nav.updateAvailableBanner",{version:P?.latest_version,defaultValue:`Version ${P?.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(Vt,{className:"w-4 h-4"})})]}),s.jsx(lce,{})]}),p&&s.jsx($me,{onClose:()=>b(!1),sidebarItems:ie.map(X=>{if(cT(X)){const B=fe.get(X);return B?{type:"external",label:B.name}:null}else{const B=de.get(X);return B?{type:"nav",label:B.labelKey,labelKey:B.labelKey}:null}}).filter(Boolean)}),D&&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:D.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 a0(t,e="system"){return e==="12h"?t.hour12=!0:e==="24h"&&(t.hour12=!1),t}function Ni(t){return t?t.endsWith("Z")||/[+-]\d{2}:\d{2}$/.test(t)?new Date(t):new Date(t+"Z"):null}function _g(t,e){const n=Ni(t);if(!n)return"";const r={year:"numeric",month:"short",day:"numeric"};return n.toLocaleDateString(void 0,e??r)}function wg(t,e="system",n){const r=Ni(t);if(!r)return"";const a=a0(n??{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"},e);return r.toLocaleString(void 0,a)}function Yme(t,e="system",n){const i=a0({...{hour:"2-digit",minute:"2-digit"},...n},e);return t.toLocaleTimeString([],i)}const LK=w.createContext(void 0);function qn(){const t=w.useContext(LK);if(!t)throw new Error("useToast must be used within a ToastProvider");return t}const Zme={success:s.jsx(Un,{className:"w-5 h-5 text-green-400"}),error:s.jsx(ia,{className:"w-5 h-5 text-red-400"}),warning:s.jsx(oa,{className:"w-5 h-5 text-yellow-400"}),info:s.jsx(Ql,{className:"w-5 h-5 text-blue-400"}),loading:s.jsx(dt,{className:"w-5 h-5 text-bambu-green animate-spin"})},Qme={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 Jme({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(LK.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 ${Qme[o.type]}`,children:[Zme[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(Vt,{className:"w-4 h-4"})})]},o.id))})]})}function epe(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 iB(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 tpe(t,e){if(e)return bK;switch(t.toLowerCase().split(".").pop()||""){case"3mf":return Af;case"gcode":return Za;case"mp4":case"avi":return Bd;case"png":case"jpg":case"jpeg":return Ny;default:return aN}}const npe=[{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 rpe({printerId:t,printerName:e,onClose:n}){const{showToast:r}=qn(),i=on(),[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 P=W=>{W.key==="Escape"&&n()};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[n]);const{data:v,isLoading:S,refetch:M}=ut({queryKey:["printerFiles",t,a],queryFn:()=>he.getPrinterFiles(t,a)}),{data:A}=ut({queryKey:["printerStorage",t],queryFn:()=>he.getPrinterStorage(t),staleTime:3e4}),T=mt({mutationFn:async P=>{for(const W of P)await he.deletePrinterFile(t,W)},onSuccess:()=>{r(`Deleted ${f.length} file${f.length>1?"s":""}`),i.invalidateQueries({queryKey:["printerFiles",t]}),c(new Set),m([])},onError:P=>{r(`Delete failed: ${P.message}`,"error")}}),k=P=>{o(P),c(new Set)},E=()=>{if(a==="/")return;const P=a.split("/").filter(Boolean);P.pop(),o(P.length?"/"+P.join("/"):"/"),c(new Set)},O=(P,W)=>{W.stopPropagation(),c(K=>{const V=new Set(K);return V.has(P)?V.delete(P):V.add(P),V})},C=()=>{if(!v?.files)return;const P=v.files.filter(W=>!W.is_directory&&(!u||W.name.toLowerCase().includes(u.toLowerCase()))).map(W=>W.path);c(new Set(P))},D=()=>{c(new Set)},U=async()=>{if(l.size===0)return;const P=Array.from(l);if(P.length===1){window.open(he.getPrinterFileDownloadUrl(t,P[0]),"_blank"),c(new Set);return}x({current:0,total:P.length});try{const W=await he.downloadPrinterFilesAsZip(t,P),K=URL.createObjectURL(W),V=document.createElement("a");V.href=K,V.download=`${e.replace(/[^a-zA-Z0-9]/g,"_")}-files.zip`,document.body.appendChild(V),V.click(),document.body.removeChild(V),URL.revokeObjectURL(K),r(`Downloaded ${P.length} files as ZIP`),c(new Set)}catch(W){r(`Download failed: ${W instanceof Error?W.message:"Unknown error"}`,"error")}finally{x(null)}},L=()=>{l.size!==0&&m(Array.from(l))},q=[{path:"/",label:"Root"},{path:"/cache",label:"Cache"},{path:"/model",label:"Models"},{path:"/timelapse",label:"Timelapse"}];return s.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:[s.jsxs("div",{className:"w-full max-w-3xl max-h-[85vh] flex flex-col bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden",onClick:P=>P.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(lN,{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:[A&&(A.used_bytes!=null||A.free_bytes!=null)&&s.jsxs("div",{className:"text-sm text-bambu-gray flex items-center gap-2",children:[A.used_bytes!=null&&s.jsxs("span",{children:["Used: ",iB(A.used_bytes)]}),A.used_bytes!=null&&A.free_bytes!=null&&s.jsx("span",{className:"text-bambu-dark-tertiary",children:"|"}),A.free_bytes!=null&&s.jsxs("span",{children:["Free: ",iB(A.free_bytes)]})]}),s.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Vt,{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(P=>s.jsx("button",{onClick:()=>{k(P.path),d("")},className:`px-3 py-1 text-sm rounded-full transition-colors ${a===P.path?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:P.label},P.path)),s.jsx("div",{className:"flex-1"}),s.jsxs("div",{className:"relative",children:[s.jsx(Ea,{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:P=>d(P.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(mK,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("select",{value:p,onChange:P=>b(P.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:npe.map(P=>s.jsx("option",{value:P.value,children:P.label},P.value))})]}),s.jsx(Se,{variant:"secondary",size:"sm",onClick:()=>M(),disabled:S,children:s.jsx(xr,{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:E,disabled:a==="/",className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-50 disabled:cursor-not-allowed",children:s.jsx(Vf,{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(dt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):v?.files?.length?s.jsx("div",{className:"space-y-1",children:[...v.files].filter(P=>!u||P.name.toLowerCase().includes(u.toLowerCase())).sort((P,W)=>{if(P.is_directory&&!W.is_directory)return-1;if(!P.is_directory&&W.is_directory)return 1;switch(p){case"name-asc":return P.name.localeCompare(W.name);case"name-desc":return W.name.localeCompare(P.name);case"size-asc":return P.size-W.size;case"size-desc":return W.size-P.size;case"date-asc":{const K=P.mtime?new Date(P.mtime).getTime():0,V=W.mtime?new Date(W.mtime).getTime():0;return K-V}case"date-desc":{const K=P.mtime?new Date(P.mtime).getTime():0;return(W.mtime?new Date(W.mtime).getTime():0)-K}default:return P.name.localeCompare(W.name)}}).map(P=>{const W=tpe(P.name,P.is_directory),K=l.has(P.path);return s.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg cursor-pointer transition-colors ${K?"bg-bambu-green/20 border border-bambu-green/50":"hover:bg-bambu-dark-tertiary"}`,onClick:()=>{P.is_directory&&k(P.path)},children:[P.is_directory?null:s.jsx("button",{onClick:V=>O(P.path,V),className:"flex-shrink-0 text-bambu-gray hover:text-white",children:K?s.jsx(Lo,{className:"w-5 h-5 text-bambu-green"}):s.jsx(Io,{className:"w-5 h-5"})}),s.jsx(W,{className:`w-5 h-5 flex-shrink-0 ${P.is_directory?"text-bambu-green":"text-bambu-gray"}`}),s.jsx("span",{className:"flex-1 text-white truncate",children:P.name}),!P.is_directory&&s.jsx("span",{className:"text-sm text-bambu-gray",children:epe(P.size)}),P.is_directory&&s.jsx(Vf,{className:"w-4 h-4 text-bambu-gray rotate-180"})]},P.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(P=>P.name.toLowerCase().includes(u.toLowerCase())).length||0} of ${v?.files?.length||0} items`:`${v?.files?.length||0} items`}),v?.files?.some(P=>!P.is_directory)&&s.jsx("div",{className:"flex items-center gap-2",children:l.size>0?s.jsxs("button",{onClick:D,className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors",children:[s.jsx(Jfe,{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(Lo,{className:"w-4 h-4"}),"Select All"]})})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Se,{variant:"secondary",disabled:l.size===0||y!==null,onClick:U,children:y?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 animate-spin"}),y.current,"/",y.total]}):s.jsxs(s.Fragment,{children:[s.jsx(Hr,{className:"w-4 h-4"}),"Download",l.size>1?` (${l.size})`:""]})}),s.jsxs(Se,{variant:"secondary",disabled:l.size===0||T.isPending,onClick:L,className:"text-red-400 hover:text-red-300",children:[T.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(dn,{className:"w-4 h-4"}),"Delete",l.size>1?` (${l.size})`:""]})]})]})]}),f.length>0&&s.jsx(Hn,{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:()=>{T.mutate(f)},onCancel:()=>m([])})]})}const ipe="embeddedCameraState_",aB=5,ape=2e3,spe=3e4,ope=5e3,uT={x:window.innerWidth-420,y:20,width:400,height:300};function lpe({printerId:t,printerName:e,viewerIndex:n=0,onClose:r}){const i=`${ipe}${t}`,a=()=>{try{const te=localStorage.getItem(i);if(te){const Me=JSON.parse(te);return{x:Math.min(Math.max(0,Me.x),window.innerWidth-100),y:Math.min(Math.max(0,Me.y),window.innerHeight-100),width:Math.max(200,Math.min(Me.width,window.innerWidth-20)),height:Math.max(150,Math.min(Me.height,window.innerHeight-20))}}}catch{}const oe=n*30;return{...uT,x:Math.max(0,uT.x-oe),y:Math.max(0,uT.y+oe)}},[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),[A,T]=w.useState({x:0,y:0}),[k,E]=w.useState(!1),[O,C]=w.useState({x:0,y:0}),[D,U]=w.useState(null),[L,q]=w.useState(null),[P,W]=w.useState(!1),[K,V]=w.useState(!0),[Q,re]=w.useState(Date.now()),[J,z]=w.useState(0),[G,ne]=w.useState(!1),[ae,de]=w.useState(0),fe=w.useRef(null),ie=w.useRef(null),Ae=w.useRef(null),me=w.useRef(null),Ne=w.useRef(null),{data:ye}=ut({queryKey:["printer",t],queryFn:()=>he.getPrinter(t),enabled:t>0});w.useEffect(()=>{const oe=setTimeout(()=>{localStorage.setItem(i,JSON.stringify(o))},500);return()=>clearTimeout(oe)},[o,i]);const le=w.useRef(!1);w.useEffect(()=>{le.current=!1;const oe=`/api/v1/printers/${t}/camera/stop`,te=()=>{t>0&&!le.current&&(le.current=!0,navigator.sendBeacon(oe))},Me=ie.current;return()=>{Me&&(Me.src=""),te(),Ae.current&&clearTimeout(Ae.current),me.current&&clearInterval(me.current),Ne.current&&clearInterval(Ne.current)}},[t]),w.useEffect(()=>{if(K){const oe=setTimeout(()=>V(!1),3e3);return()=>clearTimeout(oe)}},[K,Q]);const $e=w.useCallback(()=>{if(J>=aB){ne(!1),W(!0);return}const oe=Math.min(ape*Math.pow(2,J),spe);ne(!0),de(Math.ceil(oe/1e3)),me.current=setInterval(()=>{de(te=>te<=1?(me.current&&clearInterval(me.current),0):te-1)},1e3),Ae.current=setTimeout(()=>{z(te=>te+1),ne(!1),V(!0),W(!1),ie.current&&(ie.current.src=""),re(Date.now())},oe)},[J]);w.useEffect(()=>{if(K||G||b){Ne.current&&(clearInterval(Ne.current),Ne.current=null);return}return Ne.current=setInterval(async()=>{try{const oe=await fetch(`/api/v1/printers/${t}/camera/status`);if(oe.ok){const te=await oe.json();(te.stalled||!te.active&&!P)&&(Ne.current&&(clearInterval(Ne.current),Ne.current=null),V(!1),$e())}}catch{}},ope),()=>{Ne.current&&(clearInterval(Ne.current),Ne.current=null)}},[K,P,G,b,t,$e]),w.useEffect(()=>{const oe=()=>{const te=!!document.fullscreenElement;v(te),te||(M(1),T({x:0,y:0}))};return document.addEventListener("fullscreenchange",oe),()=>document.removeEventListener("fullscreenchange",oe)},[]);const H=()=>{fe.current&&(document.fullscreenElement?document.exitFullscreen():fe.current.requestFullscreen())},ee=()=>{M(oe=>Math.min(oe+.5,4))},X=()=>{M(oe=>{const te=Math.max(oe-.5,1);return te===1&&T({x:0,y:0}),te})},B=oe=>{oe.preventDefault(),oe.deltaY<0?ee():X()},I=oe=>{S>1&&(oe.preventDefault(),E(!0),C({x:oe.clientX-A.x,y:oe.clientY-A.y}))},ce=w.useCallback(()=>{if(!fe.current||!ie.current)return{x:200,y:150};const oe=fe.current.getBoundingClientRect(),te=oe.width*(S-1)/2,Me=oe.height*(S-1)/2;return{x:Math.max(50,te),y:Math.max(50,Me)}},[S]),Te=oe=>{if(k&&S>1){const te=oe.clientX-O.x,Me=oe.clientY-O.y,Fe=ce();T({x:Math.max(-Fe.x,Math.min(Fe.x,te)),y:Math.max(-Fe.y,Math.min(Fe.y,Me))})}},Le=()=>{E(!1)},Ee=oe=>{if(oe.length<2)return 0;const te=oe[0].clientX-oe[1].clientX,Me=oe[0].clientY-oe[1].clientY;return Math.sqrt(te*te+Me*Me)},$=oe=>oe.length<2?{x:oe[0].clientX,y:oe[0].clientY}:{x:(oe[0].clientX+oe[1].clientX)/2,y:(oe[0].clientY+oe[1].clientY)/2},j=oe=>{oe.touches.length===2?(oe.preventDefault(),U(Ee(oe.touches)),q($(oe.touches))):oe.touches.length===1&&S>1&&(oe.preventDefault(),E(!0),C({x:oe.touches[0].clientX-A.x,y:oe.touches[0].clientY-A.y}))},Y=oe=>{if(oe.touches.length===2&&D!==null){oe.preventDefault();const te=Ee(oe.touches),Me=te/D;M(ot=>{const se=Math.max(1,Math.min(4,ot*Me));return se===1&&T({x:0,y:0}),se}),U(te);const Fe=$(oe.touches);if(L){const ot=ce();T(se=>({x:Math.max(-ot.x,Math.min(ot.x,se.x+(Fe.x-L.x))),y:Math.max(-ot.y,Math.min(ot.y,se.y+(Fe.y-L.y)))}))}q(Fe)}else if(oe.touches.length===1&&k&&S>1){oe.preventDefault();const te=oe.touches[0].clientX-O.x,Me=oe.touches[0].clientY-O.y,Fe=ce();T({x:Math.max(-Fe.x,Math.min(Fe.x,te)),y:Math.max(-Fe.y,Math.min(Fe.y,Me))})}},ge=oe=>{oe.touches.length<2&&(U(null),q(null)),oe.touches.length===0&&E(!1)},we=()=>{M(1),T({x:0,y:0})},ve=()=>{V(!1),J<aB?$e():W(!0)},Ze=()=>{V(!1),W(!1),z(0),ne(!1),Ae.current&&clearTimeout(Ae.current),me.current&&clearInterval(me.current)},Ie=()=>{V(!0),W(!1),z(0),ne(!1),Ae.current&&clearTimeout(Ae.current),me.current&&clearInterval(me.current),fetch(`/api/v1/printers/${t}/camera/stop`).catch(()=>{}),ie.current&&(ie.current.src=""),setTimeout(()=>re(Date.now()),100)},qe=oe=>{oe.target.closest(".no-drag")||(u(!0),p({x:oe.clientX-o.x,y:oe.clientY-o.y}))},Je=oe=>{oe.stopPropagation(),f(!0)};w.useEffect(()=>{const oe=Me=>{if(c)l(Fe=>({...Fe,x:Math.max(0,Math.min(Me.clientX-m.x,window.innerWidth-Fe.width)),y:Math.max(0,Math.min(Me.clientY-m.y,window.innerHeight-Fe.height))}));else if(d&&fe.current){const Fe=fe.current.getBoundingClientRect();l(ot=>({...ot,width:Math.max(200,Math.min(Me.clientX-Fe.left,window.innerWidth-ot.x-10)),height:Math.max(150,Math.min(Me.clientY-Fe.top,window.innerHeight-ot.y-10))}))}},te=()=>{u(!1),f(!1)};if(c||d)return document.addEventListener("mousemove",oe),document.addEventListener("mouseup",te),()=>{document.removeEventListener("mousemove",oe),document.removeEventListener("mouseup",te)}},[c,d,m]);const Qe=`/api/v1/printers/${t}/camera/stream?fps=10&t=${Q}`;return s.jsxs("div",{ref:fe,className:`${x?"fixed inset-0 z-[100]":"fixed z-50 rounded-lg shadow-2xl border border-bambu-dark-tertiary"} bg-bambu-dark-secondary overflow-hidden`,style:x?void 0:{left:o.x,top:o.y,width:b?200:o.width,height:b?40:o.height,cursor:c?"grabbing":"default"},children:[s.jsxs("div",{className:"flex items-center justify-between px-3 py-2 bg-bambu-dark border-b border-bambu-dark-tertiary cursor-grab active:cursor-grabbing",onMouseDown:qe,children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-white truncate",children:[s.jsx(yg,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"truncate",children:ye?.name||e})]}),s.jsxs("div",{className:"flex items-center gap-1 no-drag",children:[s.jsx("button",{onClick:Ie,disabled:K||G,className:"p-1 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:"Refresh stream",children:s.jsx(xr,{className:`w-3.5 h-3.5 text-bambu-gray ${K?"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(SK,{className:"w-3.5 h-3.5 text-bambu-gray"}):s.jsx(che,{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(_K,{className:"w-3.5 h-3.5 text-bambu-gray"}):s.jsx(wK,{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(Vt,{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:Te,onMouseUp:Le,onMouseLeave:Le,onTouchStart:j,onTouchMove:Y,onTouchEnd:ge,style:{touchAction:"none"},children:[K&&!G&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:s.jsx(xr,{className:"w-6 h-6 text-bambu-gray animate-spin"})}),G&&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(ex,{className:"w-6 h-6 text-orange-400 mx-auto mb-2"}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:["Reconnecting in ",ae,"s..."]})]})}),P&&!G&&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(kn,{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:Ie,className:"px-2 py-1 text-xs bg-bambu-green text-white rounded hover:bg-bambu-green/80",children:"Retry"})]})}),s.jsx("img",{ref:ie,src:Qe,alt:"Camera stream",className:"max-w-full max-h-full object-contain select-none",style:{transform:`scale(${S}) translate(${A.x/S}px, ${A.y/S}px)`,cursor:S>1?k?"grabbing":"grab":"default"},onError:ve,onLoad:Ze,onMouseDown:I,draggable:!1},Q),s.jsxs("div",{className:"absolute bottom-2 left-2 flex items-center gap-1 bg-black/60 rounded px-1.5 py-1 no-drag",children:[s.jsx("button",{onClick:X,disabled:S<=1,className:"p-1 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom out",children:s.jsx(XD,{className:"w-3.5 h-3.5 text-white"})}),s.jsxs("button",{onClick:we,className:"px-1.5 py-0.5 text-xs text-white hover:bg-white/10 rounded min-w-[32px]",title:"Reset zoom",children:[Math.round(S*100),"%"]}),s.jsx("button",{onClick:ee,disabled:S>=4,className:"p-1 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom in",children:s.jsx(KD,{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:Je,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 cpe({printerId:t,printerName:e,onClose:n}){const r=on(),[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}=ut({queryKey:["mqtt-logs",t],queryFn:()=>he.getMQTTLogs(t),refetchInterval:1e3}),x=mt({mutationFn:()=>he.enableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),v=mt({mutationFn:()=>he.disableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),S=mt({mutationFn:()=>he.clearMQTTLogs(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}});w.useEffect(()=>{const C=D=>{D.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(D=>{const U=new Set(D);return U.has(C)?U.delete(C):U.add(C),U})},A=C=>new Date(C).toLocaleTimeString("en-US",{hour12:!1,fractionalSecondDigits:3}),T=(C,D)=>{if(C==null)return"<empty>";const U=typeof C=="string"?JSON.parse(C):C,L=JSON.stringify(U,null,D?2:0);return!D&&L.length>100?L.substring(0,100)+"...":L},k=p?.logging_enabled??!1,E=w.useMemo(()=>p?.logs??[],[p?.logs]),O=w.useMemo(()=>E.filter(C=>{if(d!=="all"&&C.direction!==d)return!1;if(c.trim()){const D=c.toLowerCase(),U=C.topic.toLowerCase().includes(D),q=JSON.stringify(C.payload).toLowerCase().includes(D);return U||q}return!0}),[E,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(Vt,{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(Se,{size:"sm",variant:"secondary",onClick:()=>v.mutate(),disabled:v.isPending,children:[s.jsx(Io,{className:"w-4 h-4"}),"Stop"]}):s.jsxs(Se,{size:"sm",onClick:()=>x.mutate(),disabled:x.isPending,children:[s.jsx(Oo,{className:"w-4 h-4"}),"Start Logging"]}),s.jsxs(Se,{size:"sm",variant:"secondary",onClick:()=>S.mutate(),disabled:S.isPending||E.length===0,children:[s.jsx(dn,{className:"w-4 h-4"}),"Clear"]}),s.jsx(Se,{size:"sm",variant:"secondary",onClick:()=>y(),disabled:b,children:s.jsx(xr,{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:[O.length,"/",E.length]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(Ea,{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(Vt,{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(j0,{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(bg,{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:E.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'})]}):O.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:O.map((C,D)=>{const U=o.has(D),L=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(D),children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:"text-bambu-gray shrink-0",children:A(C.timestamp)}),s.jsx("span",{className:`shrink-0 ${L?"text-blue-400":"text-green-400"}`,title:L?"Incoming":"Outgoing",children:L?s.jsx(j0,{className:"w-3 h-3"}):s.jsx(bg,{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:T(C.payload,!0)}):s.jsx("pre",{className:"mt-1 text-white/80 truncate",children:T(C.payload,!1)})]},D)})})}),s.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary",children:[s.jsx("div",{className:"text-sm text-bambu-gray",children: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(Se,{variant:"secondary",onClick:n,children:"Close"})]})]})})}const AP={"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 upe(t){switch(t){case 1:return{label:"Fatal",color:"text-red-500",bgColor:"bg-red-500/20",Icon:kn};case 2:return{label:"Serious",color:"text-red-400",bgColor:"bg-red-500/15",Icon:kn};case 3:return{label:"Warning",color:"text-orange-400",bgColor:"bg-orange-500/20",Icon:oa};default:return{label:"Info",color:"text-blue-400",bgColor:"bg-blue-500/20",Icon:Ql}}}function TP(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 dpe(t){return t.filter(e=>{const n=parseInt(e.code.replace("0x",""),16)||0,r=TP(e.attr,n);return AP[r]!==void 0})}function hpe(){return"https://wiki.bambulab.com/en/hms/home"}function fpe({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=TP(i.attr,a);return AP[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(kn,{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(Vt,{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(oa,{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}=upe(i.severity),d=parseInt(i.code.replace("0x",""),16)||0,f=TP(i.attr,d),m=AP[f],p=hpe(),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(zr,{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 mpe(t){if(!t)return"ASAP";const e=Ni(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 ppe({printerId:t}){const{data:e}=ut({queryKey:["queue",t,"pending"],queryFn:()=>he.getQueue(t,"pending"),refetchInterval:3e4}),n=e?.[0],r=e?.length||0;return r===0?null:s.jsx(bs,{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(oi,{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(Zn,{className:"w-3 h-3"}),mpe(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(Js,{className:"w-4 h-4 text-bambu-gray"})]})]})})}function IK(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=IK(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function Vn(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=IK(t))&&(r&&(r+=" "),r+=e);return r}var gpe=["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 YD(t){if(typeof t!="string")return!1;var e=gpe;return e.includes(t)}var xpe=["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"],bpe=new Set(xpe);function FK(t){return typeof t!="string"?!1:bpe.has(t)}function UK(t){return typeof t=="string"&&t.startsWith("data-")}function rs(t){if(typeof t!="object"||t===null)return{};var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(FK(n)||UK(n))&&(e[n]=t[n]);return e}function Kf(t){if(t==null)return null;if(w.isValidElement(t)&&typeof t.props=="object"&&t.props!==null){var e=t.props;return rs(e)}return typeof t=="object"&&!Array.isArray(t)?rs(t):null}function Ca(t){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(FK(n)||UK(n)||YD(n))&&(e[n]=t[n]);return e}function ype(t){return t==null?null:w.isValidElement(t)?Ca(t.props):typeof t=="object"&&!Array.isArray(t)?Ca(t):null}var vpe=["children","width","height","viewBox","className","style","title","desc"];function CP(){return CP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},CP.apply(null,arguments)}function _pe(t,e){if(t==null)return{};var n,r,i=wpe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function wpe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var ZD=w.forwardRef((t,e)=>{var{children:n,width:r,height:i,viewBox:a,className:o,style:l,title:c,desc:u}=t,d=_pe(t,vpe),f=a||{width:r,height:i,x:0,y:0},m=Vn("recharts-surface",o);return w.createElement("svg",CP({},Ca(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)}),Spe=["children","className"];function kP(){return kP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},kP.apply(null,arguments)}function Mpe(t,e){if(t==null)return{};var n,r,i=Npe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Npe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var Kr=w.forwardRef((t,e)=>{var{children:n,className:r}=t,i=Mpe(t,Spe),a=Vn("recharts-layer",r);return w.createElement("g",kP({className:a},Ca(i),{ref:e}),n)}),zK=w.createContext(null),Epe=()=>w.useContext(zK);function Mr(t){return function(){return t}}const BK=Math.cos,B1=Math.sin,xl=Math.sqrt,$1=Math.PI,xN=2*$1,jP=Math.PI,PP=2*jP,tf=1e-6,Ape=PP-tf;function $K(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}function Tpe(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return $K;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 Cpe{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=e==null?$K:Tpe(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>tf)if(!(Math.abs(f*c-u*d)>tf)||!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((jP-Math.acos((y+m-x)/(2*v*S)))/2),A=M/S,T=M/v;Math.abs(A-1)>tf&&this._append`L${e+A*d},${n+A*f}`,this._append`A${a},${a},0,0,${+(f*p>d*b)},${this._x1=e+T*c},${this._y1=n+T*u}`}}arc(e,n,r,i,a,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)>tf||Math.abs(this._y1-d)>tf)&&this._append`L${u},${d}`,r&&(m<0&&(m=m%PP+PP),m>Ape?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>tf&&this._append`A${r},${r},0,${+(m>=jP)},${f},${this._x1=e+r*Math.cos(a)},${this._y1=n+r*Math.sin(a)}`)}rect(e,n,r,i){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+n}h${r=+r}v${+i}h${-r}Z`}toString(){return this._}}function QD(t){let e=3;return t.digits=function(n){if(!arguments.length)return e;if(n==null)e=null;else{const r=Math.floor(n);if(!(r>=0))throw new RangeError(`invalid digits: ${n}`);e=r}return t},()=>new Cpe(e)}function JD(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function HK(t){this._context=t}HK.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 bN(t){return new HK(t)}function VK(t){return t[0]}function GK(t){return t[1]}function WK(t,e){var n=Mr(!0),r=null,i=bN,a=null,o=QD(l);t=typeof t=="function"?t:t===void 0?VK:Mr(t),e=typeof e=="function"?e:e===void 0?GK:Mr(e);function l(c){var u,d=(c=JD(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:Mr(+c),l):t},l.y=function(c){return arguments.length?(e=typeof c=="function"?c:Mr(+c),l):e},l.defined=function(c){return arguments.length?(n=typeof c=="function"?c:Mr(!!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 v_(t,e,n){var r=null,i=Mr(!0),a=null,o=bN,l=null,c=QD(u);t=typeof t=="function"?t:t===void 0?VK:Mr(+t),e=typeof e=="function"?e:Mr(e===void 0?0:+e),n=typeof n=="function"?n:n===void 0?GK:Mr(+n);function u(f){var m,p,b,y=(f=JD(f)).length,x,v=!1,S,M=new Array(y),A=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],A[b]);l.lineEnd(),l.areaEnd()}v&&(M[m]=+t(x,m,f),A[m]=+e(x,m,f),l.point(r?+r(x,m,f):M[m],n?+n(x,m,f):A[m]))}if(S)return l=null,S+""||null}function d(){return WK().defined(i).curve(o).context(a)}return u.x=function(f){return arguments.length?(t=typeof f=="function"?f:Mr(+f),r=null,u):t},u.x0=function(f){return arguments.length?(t=typeof f=="function"?f:Mr(+f),u):t},u.x1=function(f){return arguments.length?(r=f==null?null:typeof f=="function"?f:Mr(+f),u):r},u.y=function(f){return arguments.length?(e=typeof f=="function"?f:Mr(+f),n=null,u):e},u.y0=function(f){return arguments.length?(e=typeof f=="function"?f:Mr(+f),u):e},u.y1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:Mr(+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:Mr(!!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 qK{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 kpe(t){return new qK(t,!0)}function jpe(t){return new qK(t,!1)}const eO={draw(t,e){const n=xl(e/$1);t.moveTo(n,0),t.arc(0,0,n,0,xN)}},Ppe={draw(t,e){const n=xl(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()}},KK=xl(1/3),Rpe=KK*2,Dpe={draw(t,e){const n=xl(e/Rpe),r=n*KK;t.moveTo(0,-n),t.lineTo(r,0),t.lineTo(0,n),t.lineTo(-r,0),t.closePath()}},Ope={draw(t,e){const n=xl(e),r=-n/2;t.rect(r,r,n,n)}},Lpe=.8908130915292852,XK=B1($1/10)/B1(7*$1/10),Ipe=B1(xN/10)*XK,Fpe=-BK(xN/10)*XK,Upe={draw(t,e){const n=xl(e*Lpe),r=Ipe*n,i=Fpe*n;t.moveTo(0,-n),t.lineTo(r,i);for(let a=1;a<5;++a){const o=xN*a/5,l=BK(o),c=B1(o);t.lineTo(c*n,-l*n),t.lineTo(l*r-c*i,c*r+l*i)}t.closePath()}},dT=xl(3),zpe={draw(t,e){const n=-xl(e/(dT*3));t.moveTo(0,n*2),t.lineTo(-dT*n,-n),t.lineTo(dT*n,-n),t.closePath()}},ho=-.5,fo=xl(3)/2,RP=1/xl(12),Bpe=(RP/2+1)*3,$pe={draw(t,e){const n=xl(e/Bpe),r=n/2,i=n*RP,a=r,o=n*RP+n,l=-a,c=o;t.moveTo(r,i),t.lineTo(a,o),t.lineTo(l,c),t.lineTo(ho*r-fo*i,fo*r+ho*i),t.lineTo(ho*a-fo*o,fo*a+ho*o),t.lineTo(ho*l-fo*c,fo*l+ho*c),t.lineTo(ho*r+fo*i,ho*i-fo*r),t.lineTo(ho*a+fo*o,ho*o-fo*a),t.lineTo(ho*l+fo*c,ho*c-fo*l),t.closePath()}};function Hpe(t,e){let n=null,r=QD(i);t=typeof t=="function"?t:Mr(t||eO),e=typeof e=="function"?e:Mr(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:Mr(a),i):t},i.size=function(a){return arguments.length?(e=typeof a=="function"?a:Mr(+a),i):e},i.context=function(a){return arguments.length?(n=a??null,i):n},i}function H1(){}function V1(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 YK(t){this._context=t}YK.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:V1(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:V1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function Vpe(t){return new YK(t)}function ZK(t){this._context=t}ZK.prototype={areaStart:H1,areaEnd:H1,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:V1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function Gpe(t){return new ZK(t)}function QK(t){this._context=t}QK.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var n=(this._x0+4*this._x1+t)/6,r=(this._y0+4*this._y1+e)/6;this._line?this._context.lineTo(n,r):this._context.moveTo(n,r);break;case 3:this._point=4;default:V1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function Wpe(t){return new QK(t)}function JK(t){this._context=t}JK.prototype={areaStart:H1,areaEnd:H1,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 qpe(t){return new JK(t)}function sB(t){return t<0?-1:1}function oB(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(sB(a)+sB(o))*Math.min(Math.abs(a),Math.abs(o),.5*Math.abs(l))||0}function lB(t,e){var n=t._x1-t._x0;return n?(3*(t._y1-t._y0)/n-e)/2:e}function hT(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 G1(t){this._context=t}G1.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:hT(this,this._t0,lB(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,hT(this,lB(this,n=oB(this,t,e)),n);break;default:hT(this,this._t0,n=oB(this,t,e));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e,this._t0=n}}};function eX(t){this._context=new tX(t)}(eX.prototype=Object.create(G1.prototype)).point=function(t,e){G1.prototype.point.call(this,e,t)};function tX(t){this._context=t}tX.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 Kpe(t){return new G1(t)}function Xpe(t){return new eX(t)}function nX(t){this._context=t}nX.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=cB(t),i=cB(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 cB(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 Ype(t){return new nX(t)}function yN(t,e){this._context=t,this._t=e}yN.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 Zpe(t){return new yN(t,.5)}function Qpe(t){return new yN(t,0)}function Jpe(t){return new yN(t,1)}function Xf(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 DP(t){for(var e=t.length,n=new Array(e);--e>=0;)n[e]=e;return n}function ege(t,e){return t[e]}function tge(t){const e=[];return e.key=t,e}function nge(){var t=Mr([]),e=DP,n=Xf,r=ege;function i(a){var o=Array.from(t.apply(this,arguments),tge),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=JD(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:Mr(Array.from(a)),i):t},i.value=function(a){return arguments.length?(r=typeof a=="function"?a:Mr(+a),i):r},i.order=function(a){return arguments.length?(e=a==null?DP:typeof a=="function"?a:Mr(Array.from(a)),i):e},i.offset=function(a){return arguments.length?(n=a??Xf,i):n},i}function rge(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}Xf(t,e)}}function ige(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}Xf(t,e)}}function age(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,Xf(t,e)}}var fT={},mT={},uB;function sge(){return uB||(uB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==="__proto__"}t.isUnsafeProperty=e})(mT)),mT}var pT={},dB;function rX(){return dB||(dB=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})(pT)),pT}var gT={},hB;function tO(){return hB||(hB=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})(gT)),gT}var xT={},bT={},fB;function oge(){return fB||(fB=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})(bT)),bT}var mB;function nO(){return mB||(mB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=oge(),n=tO();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})(xT)),xT}var pB;function rO(){return pB||(pB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=sge(),n=rX(),r=tO(),i=nO();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})(fT)),fT}var yT,gB;function lge(){return gB||(gB=1,yT=rO().get),yT}var cge=lge();const Yf=pl(cge);var uge=4;function Pd(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:uge,n=10**e,r=Math.round(t*n)/n;return Object.is(r,-0)?0:r}function ri(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+Pd(l)+a:i+a},"")}var ta=t=>t===0?0:t>0?1:-1,dl=t=>typeof t=="number"&&t!=+t,Zf=t=>typeof t=="string"&&t.indexOf("%")===t.length-1,Bt=t=>(typeof t=="number"||t instanceof Number)&&!dl(t),Fo=t=>Bt(t)||typeof t=="string",dge=0,L0=t=>{var e=++dge;return"".concat(t||"").concat(e)},$a=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!Bt(e)&&typeof e!="string")return r;var a;if(Zf(e)){if(n==null)return r;var o=e.indexOf("%");a=n*parseFloat(e.slice(0,o))/100}else a=+e;return dl(a)&&(a=r),i&&n!=null&&a>n&&(a=n),a},iX=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 tr(t,e,n){return Bt(t)&&Bt(e)?Pd(t+n*(e-t)):e}function aX(t,e,n){if(!(!t||!t.length))return t.find(r=>r&&(typeof e=="function"?e(r):Yf(r,e))===n)}var Vr=t=>t===null||typeof t>"u",Ey=t=>Vr(t)?t:"".concat(t.charAt(0).toUpperCase()).concat(t.slice(1));function ws(t){return t!=null}function mh(){}var hge=["type","size","sizeType"];function OP(){return OP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},OP.apply(null,arguments)}function 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 bB(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){fge(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 fge(t,e,n){return(e=mge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function mge(t){var e=pge(t,"string");return typeof e=="symbol"?e:e+""}function pge(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function gge(t,e){if(t==null)return{};var n,r,i=xge(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 xge(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 sX={symbolCircle:eO,symbolCross:Ppe,symbolDiamond:Dpe,symbolSquare:Ope,symbolStar:Upe,symbolTriangle:zpe,symbolWye:$pe},bge=Math.PI/180,yge=t=>{var e="symbol".concat(Ey(t));return sX[e]||eO},vge=(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*bge;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}},_ge=(t,e)=>{sX["symbol".concat(Ey(t))]=e},iO=t=>{var{type:e="circle",size:n=64,sizeType:r="area"}=t,i=gge(t,hge),a=bB(bB({},i),{},{type:e,size:n,sizeType:r}),o="circle";typeof e=="string"&&(o=e);var l=()=>{var m=yge(o),p=Hpe().type(m).size(vge(n,r,o)),b=p();if(b!==null)return b},{className:c,cx:u,cy:d}=a,f=Ca(a);return Bt(u)&&Bt(d)&&Bt(n)?w.createElement("path",OP({},f,{className:Vn("recharts-symbols",c),transform:"translate(".concat(u,", ").concat(d,")"),d:l()})):null};iO.registerSymbol=_ge;var oX=t=>"radius"in t&&"startAngle"in t&&"endAngle"in t,aO=(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=>{YD(i)&&(r[i]=(a=>n[i](n,a)))}),r},wge=(t,e,n)=>r=>(t(e,n,r),null),Ay=(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];YD(i)&&typeof a=="function"&&(r||(r={}),r[i]=wge(a,e,n))}),r};function yB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Sge(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?yB(Object(n),!0).forEach(function(r){Mge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):yB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Mge(t,e,n){return(e=Nge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Nge(t){var e=Ege(t,"string");return typeof e=="symbol"?e:e+""}function Ege(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Xr(t,e){var n=Sge({},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 W1(){return W1=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},W1.apply(null,arguments)}function vB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Age(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?vB(Object(n),!0).forEach(function(r){Tge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):vB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Tge(t,e,n){return(e=Cge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Cge(t){var e=kge(t,"string");return typeof e=="symbol"?e:e+""}function kge(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 bo=32,jge={align:"center",iconSize:14,inactiveColor:"#ccc",layout:"horizontal",verticalAlign:"middle"};function Pge(t){var{data:e,iconType:n,inactiveColor:r}=t,i=bo/2,a=bo/6,o=bo/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:bo,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(bo,"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(bo/8,"h").concat(bo,"v").concat(bo*3/4,"h").concat(-bo,"z"),className:"recharts-legend-icon"});if(w.isValidElement(e.legendIcon)){var d=Age({},e);return delete d.legendIcon,w.cloneElement(e.legendIcon,d)}return w.createElement(iO,{fill:l,cx:i,cy:i,size:bo,sizeType:"diameter",type:c})}function Rge(t){var{payload:e,iconSize:n,layout:r,formatter:i,inactiveColor:a,iconType:o}=t,l={x:0,y:0,width:bo,height:bo},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=Vn({"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",W1({className:p,style:c,key:"legend-item-".concat(f)},Ay(t,d,f)),w.createElement(ZD,{width:n,height:n,viewBox:l,style:u,"aria-label":"".concat(y," legend icon")},w.createElement(Pge,{data:d,iconType:o,inactiveColor:a})),w.createElement("span",{className:"recharts-legend-item-text",style:{color:b}},y))})}var Dge=t=>{var e=Xr(t,jge),{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(Rge,W1({},e,{payload:n})))},vT={},_T={},_B;function Oge(){return _B||(_B=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})(_T)),_T}var wT={},wB;function Lge(){return wB||(wB=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})(wT)),wT}var ST={},SB;function lX(){return SB||(SB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n}t.identity=e})(ST)),ST}var MT={},NT={},ET={},MB;function Ige(){return MB||(MB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Number.isSafeInteger(n)&&n>=0}t.isLength=e})(ET)),ET}var NB;function sO(){return NB||(NB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Ige();function n(r){return r!=null&&typeof r!="function"&&e.isLength(r.length)}t.isArrayLike=n})(NT)),NT}var AT={},EB;function Fge(){return EB||(EB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="object"&&n!==null}t.isObjectLike=e})(AT)),AT}var AB;function Uge(){return AB||(AB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=sO(),n=Fge();function r(i){return n.isObjectLike(i)&&e.isArrayLike(i)}t.isArrayLikeObject=r})(MT)),MT}var TT={},CT={},TB;function zge(){return TB||(TB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=rO();function n(r){return function(i){return e.get(i,r)}}t.property=n})(CT)),CT}var kT={},jT={},PT={},RT={},CB;function cX(){return CB||(CB=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})(RT)),RT}var DT={},kB;function uX(){return kB||(kB=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})(DT)),DT}var OT={},jB;function dX(){return jB||(jB=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})(OT)),OT}var PB;function Bge(){return PB||(PB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=cX(),n=uX(),r=dX();function i(d,f,m){return typeof m!="function"?i(d,f,()=>{}):a(d,f,function p(b,y,x,v,S,M){const A=m(b,y,x,v,S,M);return A!==void 0?!!A: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 A=!1;if(m(M,x,y,d,f,p)&&(A=!0),A){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})(PT)),PT}var RB;function hX(){return RB||(RB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Bge();function n(r,i){return e.isMatchWith(r,i,()=>{})}t.isMatch=n})(jT)),jT}var LT={},IT={},FT={},DB;function $ge(){return DB||(DB=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})(FT)),FT}var UT={},OB;function oO(){return OB||(OB=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})(UT)),UT}var zT={},LB;function fX(){return LB||(LB=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]",A="[object BigUint64Array]",T="[object Int8Array]",k="[object Int16Array]",E="[object Int32Array]",O="[object BigInt64Array]",C="[object Float32Array]",D="[object Float64Array]";t.argumentsTag=a,t.arrayBufferTag=m,t.arrayTag=d,t.bigInt64ArrayTag=O,t.bigUint64ArrayTag=A,t.booleanTag=i,t.dataViewTag=y,t.dateTag=l,t.errorTag=b,t.float32ArrayTag=C,t.float64ArrayTag=D,t.functionTag=f,t.int16ArrayTag=k,t.int32ArrayTag=E,t.int8ArrayTag=T,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})(zT)),zT}var BT={},IB;function Hge(){return IB||(IB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}t.isTypedArray=e})(BT)),BT}var FB;function mX(){return FB||(FB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=$ge(),n=oO(),r=fX(),i=uX(),a=Hge();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})(IT)),IT}var UB;function Vge(){return UB||(UB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=mX();function n(r){return e.cloneDeepWithImpl(r,void 0,r,new Map,void 0)}t.cloneDeep=n})(LT)),LT}var zB;function Gge(){return zB||(zB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=hX(),n=Vge();function r(i){return i=n.cloneDeep(i),a=>e.isMatch(a,i)}t.matches=r})(kT)),kT}var $T={},HT={},VT={},BB;function Wge(){return BB||(BB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=mX(),n=oO(),r=fX();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})(VT)),VT}var $B;function qge(){return $B||($B=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Wge();function n(r){return e.cloneDeepWith(r)}t.cloneDeep=n})(HT)),HT}var GT={},WT={},HB;function pX(){return HB||(HB=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})(WT)),WT}var qT={},VB;function Kge(){return VB||(VB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=oO();function n(r){return r!==null&&typeof r=="object"&&e.getTag(r)==="[object Arguments]"}t.isArguments=n})(qT)),qT}var GB;function Xge(){return GB||(GB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=rX(),n=pX(),r=Kge(),i=nO();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})(GT)),GT}var WB;function Yge(){return WB||(WB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=hX(),n=tO(),r=qge(),i=rO(),a=Xge();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})($T)),$T}var qB;function Zge(){return qB||(qB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=lX(),n=zge(),r=Gge(),i=Yge();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})(TT)),TT}var KB;function Qge(){return KB||(KB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Oge(),n=Lge(),r=lX(),i=Uge(),a=Zge();function o(l,c=r.identity){return i.isArrayLikeObject(l)?e.uniqBy(Array.from(l),n.ary(a.iteratee(c),1)):[]}t.uniqBy=o})(vT)),vT}var KT,XB;function Jge(){return XB||(XB=1,KT=Qge().uniqBy),KT}var exe=Jge();const YB=pl(exe);function gX(t,e,n){return e===!0?YB(t,n):typeof e=="function"?YB(t,e):t}var XT={exports:{}},YT={};var ZB;function txe(){if(ZB)return YT;ZB=1;var t=Kg(),e=Tq();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 YT.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 E=y.value;if(p(E,k))return A=E}return A=k}if(E=A,r(M,k))return E;var O=m(k);return p!==void 0&&p(E,O)?(M=k,E):(M=k,A=O)}var S=!1,M,A,T=f===void 0?null:f;return[function(){return v(d())},T===null?void 0:function(){return v(T())}]},[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},YT}var QB;function nxe(){return QB||(QB=1,XT.exports=txe()),XT.exports}var xX=nxe(),lO=w.createContext(null),rxe=t=>t,Sr=()=>{var t=w.useContext(lO);return t?t.store.dispatch:rxe},a1=()=>{},ixe=()=>a1,axe=(t,e)=>t===e;function Wt(t){var e=w.useContext(lO),n=w.useMemo(()=>e?r=>{if(r!=null)return t(r)}:a1,[e,t]);return xX.useSyncExternalStoreWithSelector(e?e.subscription.addNestedSub:ixe,e?e.store.getState:a1,e?e.store.getState:a1,n,axe)}function sxe(t,e=`expected a function, instead received ${typeof t}`){if(typeof t!="function")throw new TypeError(e)}function oxe(t,e=`expected an object, instead received ${typeof t}`){if(typeof t!="object")throw new TypeError(e)}function lxe(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 JB=t=>Array.isArray(t)?t:[t];function cxe(t){const e=Array.isArray(t[0])?t[0]:t;return lxe(e,"createSelector expects all input-selectors to be functions, but received the following types: "),e}function uxe(t,e){const n=[],{length:r}=t;for(let i=0;i<r;i++)n.push(t[i].apply(null,e));return n}var dxe=class{constructor(t){this.value=t}deref(){return this.value}},hxe=typeof WeakRef<"u"?WeakRef:dxe,fxe=0,e8=1;function __(){return{s:fxe,v:void 0,o:null,p:null}}function bX(t,e={}){let n=__();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=__(),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=__(),b.set(p,l)):l=y}}const u=l;let d;if(l.s===e8)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 hxe(d):d}return u.s=e8,u.v=d,d}return o.clearCache=()=>{n=__(),o.resetResultsCount()},o.resultsCount=()=>a,o.resetResultsCount=()=>{a=0},o}function mxe(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()),sxe(u,`createSelector expects an output function after the inputs, but received: [${typeof u}]`);const d={...n,...c},{memoize:f,memoizeOptions:m=[],argsMemoize:p=bX,argsMemoizeOptions:b=[]}=d,y=JB(m),x=JB(b),v=cxe(i),S=f(function(){return a++,u.apply(null,arguments)},...y),M=p(function(){o++;const T=uxe(v,arguments);return l=S.apply(null,T),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 et=mxe(bX),pxe=Object.assign((t,e=et)=>{oxe(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:()=>pxe}),ZT={},QT={},JT={},t8;function gxe(){return t8||(t8=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})(JT)),JT}var eC={},tC={},n8;function yX(){return n8||(n8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="symbol"||n instanceof Symbol}t.isSymbol=e})(tC)),tC}var r8;function xxe(){return r8||(r8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=yX(),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})(eC)),eC}var i8;function bxe(){return i8||(i8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=gxe(),n=xxe(),r=nO();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})(QT)),QT}var nC={},a8;function yxe(){return a8||(a8=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})(nC)),nC}var rC={},s8;function vX(){return s8||(s8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=pX(),n=sO(),r=cX(),i=dX();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})(rC)),rC}var o8;function vxe(){return o8||(o8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=bxe(),n=yxe(),r=vX();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})(ZT)),ZT}var iC,l8;function _xe(){return l8||(l8=1,iC=vxe().sortBy),iC}var wxe=_xe();const vN=pl(wxe);var _X=t=>t.legend.settings,Sxe=t=>t.legend.size,Mxe=t=>t.legend.payload,Nxe=et([Mxe,_X],(t,e)=>{var{itemSorter:n}=e,r=t.flat(1);return n?vN(r,n):r});function Exe(){return Wt(Nxe)}var w_=1;function wX(){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)>w_||Math.abs(o.left-e.left)>w_||Math.abs(o.top-e.top)>w_||Math.abs(o.width-e.width)>w_)&&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 ba(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 Axe=typeof Symbol=="function"&&Symbol.observable||"@@observable",c8=Axe,aC=()=>Math.random().toString(36).substring(7).split("").join("."),Txe={INIT:`@@redux/INIT${aC()}`,REPLACE:`@@redux/REPLACE${aC()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${aC()}`},q1=Txe;function cO(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 SX(t,e,n){if(typeof t!="function")throw new Error(ba(2));if(typeof e=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(ba(0));if(typeof e=="function"&&typeof n>"u"&&(n=e,e=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(ba(1));return n(SX)(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(ba(3));return i}function f(x){if(typeof x!="function")throw new Error(ba(4));if(c)throw new Error(ba(5));let v=!0;u();const S=l++;return o.set(S,x),function(){if(v){if(c)throw new Error(ba(6));v=!1,u(),o.delete(S),a=null}}}function m(x){if(!cO(x))throw new Error(ba(7));if(typeof x.type>"u")throw new Error(ba(8));if(typeof x.type!="string")throw new Error(ba(17));if(c)throw new Error(ba(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(ba(10));r=x,m({type:q1.REPLACE})}function b(){const x=f;return{subscribe(v){if(typeof v!="object"||v===null)throw new Error(ba(11));function S(){const A=v;A.next&&A.next(d())}return S(),{unsubscribe:x(S)}},[c8](){return this}}}return m({type:q1.INIT}),{dispatch:m,subscribe:f,getState:d,replaceReducer:p,[c8]:b}}function Cxe(t){Object.keys(t).forEach(e=>{const n=t[e];if(typeof n(void 0,{type:q1.INIT})>"u")throw new Error(ba(12));if(typeof n(void 0,{type:q1.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(ba(13))})}function MX(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{Cxe(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(ba(14));u[f]=b,c=c||b!==p}return c=c||r.length!==Object.keys(o).length,c?u:o}}function K1(...t){return t.length===0?e=>e:t.length===1?t[0]:t.reduce((e,n)=>(...r)=>e(n(...r)))}function kxe(...t){return e=>(n,r)=>{const i=e(n,r);let a=()=>{throw new Error(ba(15))};const o={getState:i.getState,dispatch:(c,...u)=>a(c,...u)},l=t.map(c=>c(o));return a=K1(...l)(i.dispatch),{...i,dispatch:a}}}function NX(t){return cO(t)&&"type"in t&&typeof t.type=="string"}var EX=Symbol.for("immer-nothing"),u8=Symbol.for("immer-draftable"),is=Symbol.for("immer-state");function Jo(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var qs=Object,Sg=qs.getPrototypeOf,X1="constructor",_N="prototype",LP="configurable",Y1="enumerable",s1="writable",I0="value",gu=t=>!!t&&!!t[is];function hl(t){return t?AX(t)||SN(t)||!!t[u8]||!!t[X1]?.[u8]||MN(t)||NN(t):!1}var jxe=qs[_N][X1].toString(),d8=new WeakMap;function AX(t){if(!t||!uO(t))return!1;const e=Sg(t);if(e===null||e===qs[_N])return!0;const n=qs.hasOwnProperty.call(e,X1)&&e[X1];if(n===Object)return!0;if(!Gp(n))return!1;let r=d8.get(n);return r===void 0&&(r=Function.toString.call(n),d8.set(n,r)),r===jxe}function wN(t,e,n=!0){Ty(t)===0?(n?Reflect.ownKeys(t):qs.keys(t)).forEach(i=>{e(i,t[i],t)}):t.forEach((r,i)=>e(i,r,t))}function Ty(t){const e=t[is];return e?e.type_:SN(t)?1:MN(t)?2:NN(t)?3:0}var h8=(t,e,n=Ty(t))=>n===2?t.has(e):qs[_N].hasOwnProperty.call(t,e),IP=(t,e,n=Ty(t))=>n===2?t.get(e):t[e],Z1=(t,e,n,r=Ty(t))=>{r===2?t.set(e,n):r===3?t.add(n):t[e]=n};function Pxe(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}var SN=Array.isArray,MN=t=>t instanceof Map,NN=t=>t instanceof Set,uO=t=>typeof t=="object",Gp=t=>typeof t=="function",sC=t=>typeof t=="boolean";function Rxe(t){const e=+t;return Number.isInteger(e)&&String(e)===t}var Xc=t=>t.copy_||t.base_,dO=t=>t.modified_?t.copy_:t.base_;function FP(t,e){if(MN(t))return new Map(t);if(NN(t))return new Set(t);if(SN(t))return Array[_N].slice.call(t);const n=AX(t);if(e===!0||e==="class_only"&&!n){const r=qs.getOwnPropertyDescriptors(t);delete r[is];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const o=i[a],l=r[o];l[s1]===!1&&(l[s1]=!0,l[LP]=!0),(l.get||l.set)&&(r[o]={[LP]:!0,[s1]:!0,[Y1]:l[Y1],[I0]:t[o]})}return qs.create(Sg(t),r)}else{const r=Sg(t);if(r!==null&&n)return{...t};const i=qs.create(r);return qs.assign(i,t)}}function hO(t,e=!1){return EN(t)||gu(t)||!hl(t)||(Ty(t)>1&&qs.defineProperties(t,{set:S_,add:S_,clear:S_,delete:S_}),qs.freeze(t),e&&wN(t,(n,r)=>{hO(r,!0)},!1)),t}function Dxe(){Jo(2)}var S_={[I0]:Dxe};function EN(t){return t===null||!uO(t)?!0:qs.isFrozen(t)}var Q1="MapSet",UP="Patches",f8="ArrayMethods",TX={};function Qf(t){const e=TX[t];return e||Jo(0,t),e}var m8=t=>!!TX[t],F0,CX=()=>F0,Oxe=(t,e)=>({drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:m8(Q1)?Qf(Q1):void 0,arrayMethodsPlugin_:m8(f8)?Qf(f8):void 0});function p8(t,e){e&&(t.patchPlugin_=Qf(UP),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function zP(t){BP(t),t.drafts_.forEach(Lxe),t.drafts_=null}function BP(t){t===F0&&(F0=t.parent_)}var g8=t=>F0=Oxe(F0,t);function Lxe(t){const e=t[is];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function x8(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];if(t!==void 0&&t!==n){n[is].modified_&&(zP(e),Jo(4)),hl(t)&&(t=b8(e,t));const{patchPlugin_:i}=e;i&&i.generateReplacementPatches_(n[is].base_,t,e)}else t=b8(e,n);return Ixe(e,t,!0),zP(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==EX?t:void 0}function b8(t,e){if(EN(e))return e;const n=e[is];if(!n)return J1(e,t.handledSet_,t);if(!AN(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);PX(n,t)}return n.copy_}function Ixe(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&hO(e,n)}function kX(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var AN=(t,e)=>t.scope_===e,Fxe=[];function jX(t,e,n,r){const i=Xc(t),a=t.type_;if(r!==void 0&&IP(i,r,a)===e){Z1(i,r,n,a);return}if(!t.draftLocations_){const l=t.draftLocations_=new Map;wN(i,(c,u)=>{if(gu(u)){const d=l.get(u)||[];d.push(c),l.set(u,d)}})}const o=t.draftLocations_.get(e)??Fxe;for(const l of o)Z1(i,l,n,a)}function Uxe(t,e,n){t.callbacks_.push(function(i){const a=e;if(!a||!AN(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const o=dO(a);jX(t,a.draft_??a,o,n),PX(a,i)})}function PX(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)}kX(t)}}function zxe(t,e,n){const{scope_:r}=t;if(gu(n)){const i=n[is];AN(i,r)&&i.callbacks_.push(function(){o1(t);const o=dO(i);jX(t,n,o,e)})}else hl(n)&&t.callbacks_.push(function(){const a=Xc(t);t.type_===3?a.has(n)&&J1(n,r.handledSet_,r):IP(a,e,t.type_)===n&&r.drafts_.length>1&&(t.assigned_.get(e)??!1)===!0&&t.copy_&&J1(IP(t.copy_,e,t.type_),r.handledSet_,r)})}function J1(t,e,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||gu(t)||e.has(t)||!hl(t)||EN(t)||(e.add(t),wN(t,(r,i)=>{if(gu(i)){const a=i[is];if(AN(a,n)){const o=dO(a);Z1(t,r,o,t.type_),kX(a)}}else hl(i)&&J1(i,e,n)})),t}function Bxe(t,e){const n=SN(t),r={type_:n?1:0,scope_:e?e.scope_:CX(),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=eS;n&&(i=[r],a=U0);const{revoke:o,proxy:l}=Proxy.revocable(i,a);return r.draft_=l,r.revoke_=o,[l,r]}var eS={get(t,e){if(e===is)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=Xc(t);if(!h8(i,e,t.type_))return $xe(t,i,e);const a=i[e];if(t.finalized_||!hl(a)||r&&t.operationMethod&&n?.isMutatingArrayMethod(t.operationMethod)&&Rxe(e))return a;if(a===oC(t.base_,e)){o1(t);const o=t.type_===1?+e:e,l=HP(t.scope_,a,t,o);return t.copy_[o]=l}return a},has(t,e){return e in Xc(t)},ownKeys(t){return Reflect.ownKeys(Xc(t))},set(t,e,n){const r=RX(Xc(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=oC(Xc(t),e),a=i?.[is];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_.set(e,!1),!0;if(Pxe(n,i)&&(n!==void 0||h8(t.base_,e,t.type_)))return!0;o1(t),$P(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),zxe(t,e,n)),!0},deleteProperty(t,e){return o1(t),oC(t.base_,e)!==void 0||e in t.base_?(t.assigned_.set(e,!1),$P(t)):t.assigned_.delete(e),t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=Xc(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{[s1]:!0,[LP]:t.type_!==1||e!=="length",[Y1]:r[Y1],[I0]:n[e]}},defineProperty(){Jo(11)},getPrototypeOf(t){return Sg(t.base_)},setPrototypeOf(){Jo(12)}},U0={};for(let t in eS){let e=eS[t];U0[t]=function(){const n=arguments;return n[0]=n[0][0],e.apply(this,n)}}U0.deleteProperty=function(t,e){return U0.set.call(this,t,e,void 0)};U0.set=function(t,e,n){return eS.set.call(this,t[0],e,n,t[0])};function oC(t,e){const n=t[is];return(n?Xc(n):t)[e]}function $xe(t,e,n){const r=RX(e,n);return r?I0 in r?r[I0]:r.get?.call(t.draft_):void 0}function RX(t,e){if(!(e in t))return;let n=Sg(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=Sg(n)}}function $P(t){t.modified_||(t.modified_=!0,t.parent_&&$P(t.parent_))}function o1(t){t.copy_||(t.assigned_=new Map,t.copy_=FP(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var Hxe=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(n,r,i)=>{if(Gp(n)&&!Gp(r)){const o=r;r=n;const l=this;return function(u=o,...d){return l.produce(u,f=>r.call(this,f,...d))}}Gp(r)||Jo(6),i!==void 0&&!Gp(i)&&Jo(7);let a;if(hl(n)){const o=g8(this),l=HP(o,n,void 0);let c=!0;try{a=r(l),c=!1}finally{c?zP(o):BP(o)}return p8(o,i),x8(a,o)}else if(!n||!uO(n)){if(a=r(n),a===void 0&&(a=n),a===EX&&(a=void 0),this.autoFreeze_&&hO(a,!0),i){const o=[],l=[];Qf(UP).generateReplacementPatches_(n,a,{patches_:o,inversePatches_:l}),i(o,l)}return a}else Jo(1,n)},this.produceWithPatches=(n,r)=>{if(Gp(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]},sC(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),sC(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),sC(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){hl(e)||Jo(8),gu(e)&&(e=ol(e));const n=g8(this),r=HP(n,e,void 0);return r[is].isManual_=!0,BP(n),r}finishDraft(e,n){const r=e&&e[is];(!r||!r.isManual_)&&Jo(9);const{scope_:i}=r;return p8(i,n),x8(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(UP).applyPatches_;return gu(e)?i(e,n):this.produce(e,a=>i(a,n))}};function HP(t,e,n,r){const[i,a]=MN(e)?Qf(Q1).proxyMap_(e,n):NN(e)?Qf(Q1).proxySet_(e,n):Bxe(e,n);return(n?.scope_??CX()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?Uxe(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 ol(t){return gu(t)||Jo(10,t),DX(t)}function DX(t){if(!hl(t)||EN(t))return t;const e=t[is];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=FP(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=FP(t,!0);return wN(n,(i,a)=>{Z1(n,i,DX(a))},r),e&&(e.finalized_=!1),n}var Vxe=new Hxe,OX=Vxe.produce;function LX(t){return({dispatch:n,getState:r})=>i=>a=>typeof a=="function"?a(n,r,t):i(a)}var Gxe=LX(),Wxe=LX,qxe=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?K1:K1.apply(null,arguments)};function Uo(t,e){function n(...r){if(e){let i=e(...r);if(!i)throw new Error(Xs(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=>NX(r)&&r.type===t,n}var IX=class Bb extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,Bb.prototype)}static get[Symbol.species](){return Bb}concat(...e){return super.concat.apply(this,e)}prepend(...e){return e.length===1&&Array.isArray(e[0])?new Bb(...e[0].concat(this)):new Bb(...e.concat(this))}};function y8(t){return hl(t)?OX(t,()=>{}):t}function M_(t,e,n){return t.has(e)?t.get(e):t.set(e,n(e)).get(e)}function Kxe(t){return typeof t=="boolean"}var Xxe=()=>function(e){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:i=!0,actionCreatorCheck:a=!0}=e??{};let o=new IX;return n&&(Kxe(n)?o.push(Gxe):o.push(Wxe(n.extraArgument))),o},FX="RTK_autoBatch",Fr=()=>t=>({payload:t,meta:{[FX]:!0}}),v8=t=>e=>{setTimeout(e,t)},UX=(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:v8(10):t.type==="callback"?t.queueNotification:v8(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?.[FX],a=!i,a&&(o||(o=!0,c(u))),r.dispatch(d)}finally{i=!0}}})},Yxe=t=>function(n){const{autoBatch:r=!0}=n??{};let i=new IX(t);return r&&i.push(UX(typeof r=="object"?r:void 0)),i};function Zxe(t){const e=Xxe(),{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(cO(n))l=MX(n);else throw new Error(Xs(1));let c;typeof r=="function"?c=r(e):c=e();let u=K1;i&&(u=qxe({trace:!1,...typeof i=="object"&&i}));const d=kxe(...c),f=Yxe(d);let m=typeof o=="function"?o(f):f();const p=u(...m);return SX(l,a,p)}function zX(t){const e={},n=[];let r;const i={addCase(a,o){const l=typeof a=="string"?a:a.type;if(!l)throw new Error(Xs(28));if(l in e)throw new Error(Xs(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 Qxe(t){return typeof t=="function"}function Jxe(t,e){let[n,r,i]=zX(e),a;if(Qxe(t))a=()=>y8(t());else{const l=y8(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(gu(d)){const p=f(d,c);return p===void 0?d:p}else{if(hl(d))return OX(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 ebe="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",tbe=(t=21)=>{let e="",n=t;for(;n--;)e+=ebe[Math.random()*64|0];return e},nbe=Symbol.for("rtk-slice-createasyncthunk");function rbe(t,e){return`${t}/${e}`}function ibe({creators:t}={}){const e=t?.asyncThunk?.[nbe];return function(r){const{name:i,reducerPath:a=i}=r;if(!i)throw new Error(Xs(11));const o=(typeof r.reducers=="function"?r.reducers(sbe()):r.reducers)||{},l=Object.keys(o),c={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},u={addCase(M,A){const T=typeof M=="string"?M:M.type;if(!T)throw new Error(Xs(12));if(T in c.sliceCaseReducersByType)throw new Error(Xs(13));return c.sliceCaseReducersByType[T]=A,u},addMatcher(M,A){return c.sliceMatchers.push({matcher:M,reducer:A}),u},exposeAction(M,A){return c.actionCreators[M]=A,u},exposeCaseReducer(M,A){return c.sliceCaseReducersByName[M]=A,u}};l.forEach(M=>{const A=o[M],T={reducerName:M,type:rbe(i,M),createNotation:typeof r.reducers=="function"};lbe(A)?ube(T,A,u,e):obe(T,A,u)});function d(){const[M={},A=[],T=void 0]=typeof r.extraReducers=="function"?zX(r.extraReducers):[r.extraReducers],k={...M,...c.sliceCaseReducersByType};return Jxe(r.initialState,E=>{for(let O in k)E.addCase(O,k[O]);for(let O of c.sliceMatchers)E.addMatcher(O.matcher,O.reducer);for(let O of A)E.addMatcher(O.matcher,O.reducer);T&&E.addDefaultCase(T)})}const f=M=>M,m=new Map,p=new WeakMap;let b;function y(M,A){return b||(b=d()),b(M,A)}function x(){return b||(b=d()),b.getInitialState()}function v(M,A=!1){function T(E){let O=E[M];return typeof O>"u"&&A&&(O=M_(p,T,x)),O}function k(E=f){const O=M_(m,A,()=>new WeakMap);return M_(O,E,()=>{const C={};for(const[D,U]of Object.entries(r.selectors??{}))C[D]=abe(U,E,()=>M_(p,E,x),A);return C})}return{reducerPath:M,getSelectors:k,get selectors(){return k(T)},selectSlice:T}}const S={name:i,reducer:y,actions:c.actionCreators,caseReducers:c.sliceCaseReducersByName,getInitialState:x,...v(a),injectInto(M,{reducerPath:A,...T}={}){const k=A??a;return M.inject({reducerPath:k,reducer:y},T),{...S,...v(k,!0)}}};return S}}function abe(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 Ts=ibe();function sbe(){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 obe({type:t,reducerName:e,createNotation:n},r,i){let a,o;if("reducer"in r){if(n&&!cbe(r))throw new Error(Xs(17));a=r.reducer,o=r.prepare}else a=r;i.addCase(t,a).exposeCaseReducer(e,a).exposeAction(e,o?Uo(t,o):Uo(t))}function lbe(t){return t._reducerDefinitionType==="asyncThunk"}function cbe(t){return t._reducerDefinitionType==="reducerWithPrepare"}function ube({type:t,reducerName:e},n,r,i){if(!i)throw new Error(Xs(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||N_,pending:l||N_,rejected:c||N_,settled:u||N_})}function N_(){}var dbe="task",BX="listener",$X="completed",fO="cancelled",hbe=`task-${fO}`,fbe=`task-${$X}`,VP=`${BX}-${fO}`,mbe=`${BX}-${$X}`,TN=class{constructor(t){this.code=t,this.message=`${dbe} ${fO} (reason: ${t})`}name="TaskAbortError";message},mO=(t,e)=>{if(typeof t!="function")throw new TypeError(Xs(32))},tS=()=>{},HX=(t,e=tS)=>(t.catch(e),t),VX=(t,e)=>(t.addEventListener("abort",e,{once:!0}),()=>t.removeEventListener("abort",e)),Tf=t=>{if(t.aborted)throw new TN(t.reason)};function GX(t,e){let n=tS;return new Promise((r,i)=>{const a=()=>i(new TN(t.reason));if(t.aborted){a();return}n=VX(t,a),e.finally(()=>n()).then(r,i)}).finally(()=>{n=tS})}var pbe=async(t,e)=>{try{return await Promise.resolve(),{status:"ok",value:await t()}}catch(n){return{status:n instanceof TN?"cancelled":"rejected",error:n}}finally{e?.()}},nS=t=>e=>HX(GX(t,e).then(n=>(Tf(t),n))),WX=t=>{const e=nS(t);return n=>e(new Promise(r=>setTimeout(r,n)))},{assign:sg}=Object,_8={},CN="listenerMiddleware",gbe=(t,e)=>{const n=r=>VX(t,()=>r.abort(t.reason));return(r,i)=>{mO(r);const a=new AbortController;n(a);const o=pbe(async()=>{Tf(t),Tf(a.signal);const l=await r({pause:nS(a.signal),delay:WX(a.signal),signal:a.signal});return Tf(a.signal),l},()=>a.abort(fbe));return i?.autoJoin&&e.push(o.catch(tS)),{result:nS(t)(o),cancel(){a.abort(hbe)}}}},xbe=(t,e)=>{const n=async(r,i)=>{Tf(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 GX(e,Promise.race(l));return Tf(e),c}finally{a()}};return(r,i)=>HX(n(r,i))},qX=t=>{let{type:e,actionCreator:n,matcher:r,predicate:i,effect:a}=t;if(e)i=Uo(e).match;else if(n)e=n.type,i=n.match;else if(r)i=r;else if(!i)throw new Error(Xs(21));return mO(a),{predicate:i,type:e,effect:a}},KX=sg(t=>{const{type:e,predicate:n,effect:r}=qX(t);return{id:tbe(),effect:r,type:e,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(Xs(22))}}},{withTypes:()=>KX}),w8=(t,e)=>{const{type:n,effect:r,predicate:i}=qX(e);return Array.from(t.values()).find(a=>(typeof n=="string"?a.type===n:a.predicate===i)&&a.effect===r)},GP=t=>{t.pending.forEach(e=>{e.abort(VP)})},bbe=(t,e)=>()=>{for(const n of e.keys())GP(n);t.clear()},S8=(t,e,n)=>{try{t(e,n)}catch(r){setTimeout(()=>{throw r},0)}},XX=sg(Uo(`${CN}/add`),{withTypes:()=>XX}),ybe=Uo(`${CN}/removeAll`),YX=sg(Uo(`${CN}/remove`),{withTypes:()=>YX}),vbe=(...t)=>{console.error(`${CN}/error`,...t)},Cy=(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=vbe}=t;mO(o);const l=p=>(p.unsubscribe=()=>e.delete(p.id),e.set(p.id,p),b=>{p.unsubscribe(),b?.cancelActive&&GP(p)}),c=p=>{const b=w8(e,p)??KX(p);return l(b)};sg(c,{withTypes:()=>c});const u=p=>{const b=w8(e,p);return b&&(b.unsubscribe(),p.cancelActive&&GP(b)),!!b};sg(u,{withTypes:()=>u});const d=async(p,b,y,x)=>{const v=new AbortController,S=xbe(c,v.signal),M=[];try{p.pending.add(v),r(p),await Promise.resolve(p.effect(b,sg({},y,{getOriginalState:x,condition:(A,T)=>S(A,T).then(Boolean),take:S,delay:WX(v.signal),pause:nS(v.signal),extra:a,signal:v.signal,fork:gbe(v.signal,M),unsubscribe:p.unsubscribe,subscribe:()=>{e.set(p.id,p)},cancelActiveListeners:()=>{p.pending.forEach((A,T,k)=>{A!==v&&(A.abort(VP),k.delete(A))})},cancel:()=>{v.abort(VP),p.pending.delete(v)},throwIfCancelled:()=>{Tf(v.signal)}})))}catch(A){A instanceof TN||S8(o,A,{raisedBy:"effect"})}finally{await Promise.all(M),v.abort(mbe),i(p),p.pending.delete(v)}},f=bbe(e,n);return{middleware:p=>b=>y=>{if(!NX(y))return b(y);if(XX.match(y))return c(y.payload);if(ybe.match(y)){f();return}if(YX.match(y))return u(y.payload);let x=p.getState();const v=()=>{if(x===_8)throw new Error(Xs(23));return x};let S;try{if(S=b(y),e.size>0){const M=p.getState(),A=Array.from(e.values());for(const T of A){let k=!1;try{k=T.predicate(y,M,x)}catch(E){k=!1,S8(o,E,{raisedBy:"predicate"})}k&&d(T,y,p,v)}}}finally{x=_8}return S},startListening:c,stopListening:u,clearListeners:f}};function Xs(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 _be={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},ZX=Ts({name:"chartLayout",initialState:_be,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:wbe,setLayout:Sbe,setChartSize:Mbe,setScale:Nbe}=ZX.actions,Ebe=ZX.reducer;function QX(t,e,n){return Array.isArray(t)&&t&&e+n!==0?t.slice(e,n+1):t}function pn(t){return Number.isFinite(t)}function ec(t){return typeof t=="number"&&t>0&&Number.isFinite(t)}function M8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Zp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?M8(Object(n),!0).forEach(function(r){Abe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):M8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Abe(t,e,n){return(e=Tbe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Tbe(t){var e=Cbe(t,"string");return typeof e=="symbol"?e:e+""}function Cbe(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 rr(t,e,n){return Vr(t)||Vr(e)?n:Fo(e)?Yf(t,e,n):typeof e=="function"?e(t):n}var kbe=(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"&&Bt(t[a]))return Zp(Zp({},t),{},{[a]:t[a]+(r||0)});if((l==="horizontal"||l==="vertical"&&a==="center")&&o!=="middle"&&Bt(t[o]))return Zp(Zp({},t),{},{[o]:t[o]+(i||0)})}return t},bl=(t,e)=>t==="horizontal"&&e==="xAxis"||t==="vertical"&&e==="yAxis"||t==="centric"&&e==="angleAxis"||t==="radial"&&e==="radiusAxis",JX=(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},eY=(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?ta(a[0]-a[1])*2*y:y,f||m){var x=(f||m||[]).map((v,S)=>{var M=r?r.indexOf(v):v,A=o.map(M);return pn(A)?{coordinate:A+y,value:v,offset:y,index:S}:null}).filter(ws);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(ws):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(ws):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(ws)},jbe=(t,e)=>{if(!e||e.length!==2||!Bt(e[0])||!Bt(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(!Bt(t[0])||t[0]<n)&&(i[0]=n),(!Bt(t[1])||t[1]>r)&&(i[1]=r),i[0]>r&&(i[0]=r),i[1]<n&&(i[1]=n),i},Pbe=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=dl(d)?f:d;m>=0?(u[0]=a,a+=m,u[1]=a):(u[0]=o,o+=m,u[1]=o)}}}},Rbe=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=dl(c[1])?c[0]:c[1];u>=0?(c[0]=a,a+=u,c[1]=a):(c[0]=0,c[1]=0)}}}},Dbe={sign:Pbe,expand:rge,none:Xf,silhouette:ige,wiggle:age,positive:Rbe},Obe=(t,e,n)=>{var r,i=(r=Dbe[n])!==null&&r!==void 0?r:Xf,a=nge().keys(e).value((l,c)=>Number(rr(l,c,0))).order(DP).offset(i),o=a(t);return o.forEach((l,c)=>{l.forEach((u,d)=>{var f=rr(t[d],e[c],0);Array.isArray(f)&&f.length===2&&Bt(f[0])&&Bt(f[1])&&(u[0]=f[0],u[1]=f[1])})}),o};function tY(t){return t==null?void 0:String(t)}function rS(t){var{axis:e,ticks:n,bandSize:r,entry:i,index:a,dataKey:o}=t;if(e.type==="category"){if(!e.allowDuplicatedCategory&&e.dataKey&&!Vr(i[e.dataKey])){var l=aX(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=rr(i,Vr(o)?e.dataKey:o),u=e.scale.map(c);return Bt(u)?u:null}var N8=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=rr(a,e.dataKey,e.scale.domain()[o]);if(Vr(l))return null;var c=e.scale.map(l);return Bt(c)?c-i/2+r:null},Lbe=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]},Ibe=t=>{var e=t.flat(2).filter(Bt);return[Math.min(...e),Math.max(...e)]},Fbe=t=>[t[0]===1/0?0:t[0],t[1]===-1/0?0:t[1]],Ube=(t,e,n)=>{if(t!=null)return Fbe(Object.keys(t).reduce((r,i)=>{var a=t[i];if(!a)return r;var{stackedData:o}=a,l=o.reduce((c,u)=>{var d=QX(u,e,n),f=Ibe(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]))},E8=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,A8=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,th=(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=vN(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 T8(t){var{tooltipEntrySettings:e,dataKey:n,payload:r,value:i,name:a}=t;return Zp(Zp({},e),{},{dataKey:n,payload:r,value:i,name:a})}function ph(t,e){if(t)return String(t);if(typeof e=="string")return e}var zbe=(t,e)=>{if(e==="horizontal")return t.chartX;if(e==="vertical")return t.chartY},Bbe=(t,e)=>e==="centric"?t.angle:t.radius,Au=t=>t.layout.width,Tu=t=>t.layout.height,$be=t=>t.layout.scale,nY=t=>t.layout.margin,kN=et(t=>t.cartesianAxis.xAxis,t=>Object.values(t)),jN=et(t=>t.cartesianAxis.yAxis,t=>Object.values(t)),rY="data-recharts-item-index",iY="data-recharts-item-id",ky=60;function C8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function E_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?C8(Object(n),!0).forEach(function(r){Hbe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):C8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Hbe(t,e,n){return(e=Vbe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Vbe(t){var e=Gbe(t,"string");return typeof e=="symbol"?e:e+""}function Gbe(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 Wbe=t=>t.brush.height;function qbe(t){var e=jN(t);return e.reduce((n,r)=>{if(r.orientation==="left"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:ky;return n+i}return n},0)}function Kbe(t){var e=jN(t);return e.reduce((n,r)=>{if(r.orientation==="right"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:ky;return n+i}return n},0)}function Xbe(t){var e=kN(t);return e.reduce((n,r)=>r.orientation==="top"&&!r.mirror&&!r.hide?n+r.height:n,0)}function Ybe(t){var e=kN(t);return e.reduce((n,r)=>r.orientation==="bottom"&&!r.mirror&&!r.hide?n+r.height:n,0)}var zi=et([Au,Tu,nY,Wbe,qbe,Kbe,Xbe,Ybe,_X,Sxe],(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=E_(E_({},f),d),p=m.bottom;m.bottom+=r,m=kbe(m,c,u);var b=t-m.left-m.right,y=e-m.top-m.bottom;return E_(E_({brushBottom:p},m),{},{width:Math.max(b,0),height:Math.max(y,0)})}),Zbe=et(zi,t=>({x:t.left,y:t.top,width:t.width,height:t.height})),pO=et(Au,Tu,(t,e)=>({x:0,y:0,width:t,height:e})),Qbe=w.createContext(null),Bi=()=>w.useContext(Qbe)!=null,PN=t=>t.brush,RN=et([PN,zi,nY],(t,e,n)=>({height:t.height,x:Bt(t.x)?t.x:e.left,y:Bt(t.y)?t.y:e.top+e.height+e.brushBottom-(n?.bottom||0),width:Bt(t.width)?t.width:e.width})),lC={},cC={},uC={},k8;function Jbe(){return k8||(k8=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})(uC)),uC}var j8;function e0e(){return j8||(j8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Jbe();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})(cC)),cC}var P8;function t0e(){return P8||(P8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=e0e();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})(lC)),lC}var dC,R8;function n0e(){return R8||(R8=1,dC=t0e().throttle),dC}var r0e=n0e();const i0e=pl(r0e);var iS=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++]))}},Bl={width:"100%",height:"100%",debounce:0,minWidth:0,initialDimension:{width:-1,height:-1}},aY=(t,e,n)=>{var{width:r=Bl.width,height:i=Bl.height,aspect:a,maxHeight:o}=n,l=Zf(r)?t:Number(r),c=Zf(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}},a0e={width:0,height:0,overflow:"visible"},s0e={width:0,overflowX:"visible"},o0e={height:0,overflowY:"visible"},l0e={},c0e=t=>{var{width:e,height:n}=t,r=Zf(e),i=Zf(n);return r&&i?a0e:r?s0e:i?o0e:l0e};function u0e(t){var{width:e,height:n,aspect:r}=t,i=e,a=n;return i===void 0&&a===void 0?(i=Bl.width,a=Bl.height):i===void 0?i=r&&r>0?void 0:Bl.width:a===void 0&&(a=r&&r>0?void 0:Bl.height),{width:i,height:a}}function WP(){return WP=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},WP.apply(null,arguments)}function D8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function O8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?D8(Object(n),!0).forEach(function(r){d0e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):D8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function d0e(t,e,n){return(e=h0e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function h0e(t){var e=f0e(t,"string");return typeof e=="symbol"?e:e+""}function f0e(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 sY=w.createContext(Bl.initialDimension);function m0e(t){return ec(t.width)&&ec(t.height)}function oY(t){var{children:e,width:n,height:r}=t,i=w.useMemo(()=>({width:n,height:r}),[n,r]);return m0e(i)?w.createElement(sY.Provider,{value:i},e):null}var gO=()=>w.useContext(sY),p0e=w.forwardRef((t,e)=>{var{aspect:n,initialDimension:r=Bl.initialDimension,width:i,height:a,minWidth:o=Bl.minWidth,minHeight:l,maxHeight:c,children:u,debounce:d=Bl.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((O,C)=>{S(D=>{var U=Math.round(O),L=Math.round(C);return D.containerWidth===U&&D.containerHeight===L?D:{containerWidth:U,containerHeight:L}})},[]);w.useEffect(()=>{if(y.current==null||typeof ResizeObserver>"u")return mh;var O=L=>{var q,P=L[0];if(P!=null){var{width:W,height:K}=P.contentRect;M(W,K),(q=x.current)===null||q===void 0||q.call(x,W,K)}};d>0&&(O=i0e(O,d,{trailing:!0,leading:!1}));var C=new ResizeObserver(O),{width:D,height:U}=y.current.getBoundingClientRect();return M(D,U),C.observe(y.current),()=>{C.disconnect()}},[M,d]);var{containerWidth:A,containerHeight:T}=v;iS(!n||n>0,"The aspect(%s) must be greater than zero.",n);var{calculatedWidth:k,calculatedHeight:E}=aY(A,T,{width:i,height:a,aspect:n,maxHeight:c});return iS(k!=null&&k>0||E!=null&&E>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,E,i,a,o,l,n),w.createElement("div",{id:f?"".concat(f):void 0,className:Vn("recharts-responsive-container",m),style:O8(O8({},b),{},{width:i,height:a,minWidth:o,minHeight:l,maxHeight:c}),ref:y},w.createElement("div",{style:c0e({width:i,height:a})},w.createElement(oY,{width:k,height:E},u)))}),l1=w.forwardRef((t,e)=>{var n=gO();if(ec(n.width)&&ec(n.height))return t.children;var{width:r,height:i}=u0e({width:t.width,height:t.height,aspect:t.aspect}),{calculatedWidth:a,calculatedHeight:o}=aY(void 0,void 0,{width:r,height:i,aspect:t.aspect,maxHeight:t.maxHeight});return Bt(a)&&Bt(o)?w.createElement(oY,{width:a,height:o},t.children):w.createElement(p0e,WP({},t,{width:r,height:i,ref:e}))});function xO(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 jy=()=>{var t,e=Bi(),n=Wt(Zbe),r=Wt(RN),i=(t=Wt(PN))===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}},g0e={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},lY=()=>{var t;return(t=Wt(zi))!==null&&t!==void 0?t:g0e},bO=()=>Wt(Au),yO=()=>Wt(Tu),x0e=()=>Wt(t=>t.layout.margin),$n=t=>t.layout.layoutType,gh=()=>Wt($n),vO=()=>{var t=gh();if(t==="horizontal"||t==="vertical")return t},cY=t=>{var e=t.layout.layoutType;if(e==="centric"||e==="radial")return e},b0e=()=>{var t=gh();return t!==void 0},Py=t=>{var e=Sr(),n=Bi(),{width:r,height:i}=t,a=gO(),o=r,l=i;return a&&(o=a.width>0?a.width:r,l=a.height>0?a.height:i),w.useEffect(()=>{!n&&ec(o)&&ec(l)&&e(Mbe({width:o,height:l}))},[e,n,o,l]),null},uY=Symbol.for("immer-nothing"),L8=Symbol.for("immer-draftable"),eo=Symbol.for("immer-state");function el(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var z0=Object.getPrototypeOf;function Mg(t){return!!t&&!!t[eo]}function Jf(t){return t?dY(t)||Array.isArray(t)||!!t[L8]||!!t.constructor?.[L8]||Ry(t)||ON(t):!1}var y0e=Object.prototype.constructor.toString(),I8=new WeakMap;function dY(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=I8.get(n);return r===void 0&&(r=Function.toString.call(n),I8.set(n,r)),r===y0e}function aS(t,e,n=!0){DN(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 DN(t){const e=t[eo];return e?e.type_:Array.isArray(t)?1:Ry(t)?2:ON(t)?3:0}function qP(t,e){return DN(t)===2?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function hY(t,e,n){const r=DN(t);r===2?t.set(e,n):r===3?t.add(n):t[e]=n}function v0e(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}function Ry(t){return t instanceof Map}function ON(t){return t instanceof Set}function nf(t){return t.copy_||t.base_}function KP(t,e){if(Ry(t))return new Map(t);if(ON(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=dY(t);if(e===!0||e==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(t);delete r[eo];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(z0(t),r)}else{const r=z0(t);if(r!==null&&n)return{...t};const i=Object.create(r);return Object.assign(i,t)}}function _O(t,e=!1){return LN(t)||Mg(t)||!Jf(t)||(DN(t)>1&&Object.defineProperties(t,{set:A_,add:A_,clear:A_,delete:A_}),Object.freeze(t),e&&Object.values(t).forEach(n=>_O(n,!0))),t}function _0e(){el(2)}var A_={value:_0e};function LN(t){return t===null||typeof t!="object"?!0:Object.isFrozen(t)}var w0e={};function em(t){const e=w0e[t];return e||el(0,t),e}var B0;function fY(){return B0}function S0e(t,e){return{drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function F8(t,e){e&&(em("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function XP(t){YP(t),t.drafts_.forEach(M0e),t.drafts_=null}function YP(t){t===B0&&(B0=t.parent_)}function U8(t){return B0=S0e(B0,t)}function M0e(t){const e=t[eo];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function z8(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];return t!==void 0&&t!==n?(n[eo].modified_&&(XP(e),el(4)),Jf(t)&&(t=sS(e,t),e.parent_||oS(e,t)),e.patches_&&em("Patches").generateReplacementPatches_(n[eo].base_,t,e.patches_,e.inversePatches_)):t=sS(e,n,[]),XP(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==uY?t:void 0}function sS(t,e,n){if(LN(e))return e;const r=t.immer_.shouldUseStrictIteration(),i=e[eo];if(!i)return aS(e,(a,o)=>B8(t,i,e,a,o,n),r),e;if(i.scope_!==t)return e;if(!i.modified_)return oS(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),aS(o,(c,u)=>B8(t,i,a,c,u,n,l),r),oS(t,a,!1),n&&t.patches_&&em("Patches").generatePatches_(i,n,t.patches_,t.inversePatches_)}return i.copy_}function B8(t,e,n,r,i,a,o){if(i==null||typeof i!="object"&&!o)return;const l=LN(i);if(!(l&&!o)){if(Mg(i)){const c=a&&e&&e.type_!==3&&!qP(e.assigned_,r)?a.concat(r):void 0,u=sS(t,i,c);if(hY(n,r,u),Mg(u))t.canAutoFreeze_=!1;else return}else o&&n.add(i);if(Jf(i)&&!l){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1||e&&e.base_&&e.base_[r]===i&&l)return;sS(t,i),(!e||!e.scope_.parent_)&&typeof r!="symbol"&&(Ry(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&oS(t,i)}}}function oS(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&_O(e,n)}function N0e(t,e){const n=Array.isArray(t),r={type_:n?1:0,scope_:e?e.scope_:fY(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,a=wO;n&&(i=[r],a=$0);const{revoke:o,proxy:l}=Proxy.revocable(i,a);return r.draft_=l,r.revoke_=o,l}var wO={get(t,e){if(e===eo)return t;const n=nf(t);if(!qP(n,e))return E0e(t,n,e);const r=n[e];return t.finalized_||!Jf(r)?r:r===hC(t.base_,e)?(fC(t),t.copy_[e]=QP(r,t)):r},has(t,e){return e in nf(t)},ownKeys(t){return Reflect.ownKeys(nf(t))},set(t,e,n){const r=mY(nf(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=hC(nf(t),e),a=i?.[eo];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(v0e(n,i)&&(n!==void 0||qP(t.base_,e)))return!0;fC(t),ZP(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 hC(t.base_,e)!==void 0||e in t.base_?(t.assigned_[e]=!1,fC(t),ZP(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=nf(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{writable:!0,configurable:t.type_!==1||e!=="length",enumerable:r.enumerable,value:n[e]}},defineProperty(){el(11)},getPrototypeOf(t){return z0(t.base_)},setPrototypeOf(){el(12)}},$0={};aS(wO,(t,e)=>{$0[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});$0.deleteProperty=function(t,e){return $0.set.call(this,t,e,void 0)};$0.set=function(t,e,n){return wO.set.call(this,t[0],e,n,t[0])};function hC(t,e){const n=t[eo];return(n?nf(n):t)[e]}function E0e(t,e,n){const r=mY(e,n);return r?"value"in r?r.value:r.get?.call(t.draft_):void 0}function mY(t,e){if(!(e in t))return;let n=z0(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=z0(n)}}function ZP(t){t.modified_||(t.modified_=!0,t.parent_&&ZP(t.parent_))}function fC(t){t.copy_||(t.copy_=KP(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var A0e=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"&&el(6),r!==void 0&&typeof r!="function"&&el(7);let i;if(Jf(e)){const a=U8(this),o=QP(e,void 0);let l=!0;try{i=n(o),l=!1}finally{l?XP(a):YP(a)}return F8(a,r),z8(i,a)}else if(!e||typeof e!="object"){if(i=n(e),i===void 0&&(i=e),i===uY&&(i=void 0),this.autoFreeze_&&_O(i,!0),r){const a=[],o=[];em("Patches").generateReplacementPatches_(e,i,a,o),r(a,o)}return i}else el(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){Jf(t)||el(8),Mg(t)&&(t=T0e(t));const e=U8(this),n=QP(t,void 0);return n[eo].isManual_=!0,YP(e),n}finishDraft(t,e){const n=t&&t[eo];(!n||!n.isManual_)&&el(9);const{scope_:r}=n;return F8(r,e),z8(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=em("Patches").applyPatches_;return Mg(t)?r(t,e):this.produce(t,i=>r(i,e))}};function QP(t,e){const n=Ry(t)?em("MapSet").proxyMap_(t,e):ON(t)?em("MapSet").proxySet_(t,e):N0e(t,e);return(e?e.scope_:fY()).drafts_.push(n),n}function T0e(t){return Mg(t)||el(10,t),pY(t)}function pY(t){if(!Jf(t)||LN(t))return t;const e=t[eo];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=KP(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=KP(t,!0);return aS(n,(i,a)=>{hY(n,i,pY(a))},r),e&&(e.finalized_=!1),n}var C0e=new A0e;C0e.produce;var k0e={settings:{layout:"horizontal",align:"center",verticalAlign:"middle",itemSorter:"value"},size:{width:0,height:0},payload:[]},gY=Ts({name:"legend",initialState:k0e,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=ol(t).payload.indexOf(n);i>-1&&(t.payload[i]=r)},prepare:Fr()},removeLegendPayload:{reducer(t,e){var n=ol(t).payload.indexOf(e.payload);n>-1&&t.payload.splice(n,1)},prepare:Fr()}}}),{setLegendSize:$8,setLegendSettings:j0e,addLegendPayload:xY,replaceLegendPayload:bY,removeLegendPayload:yY}=gY.actions,P0e=gY.reducer,R0e=["contextPayload"];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 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 Ng(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){D0e(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 D0e(t,e,n){return(e=O0e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function O0e(t){var e=L0e(t,"string");return typeof e=="symbol"?e:e+""}function L0e(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 I0e(t,e){if(t==null)return{};var n,r,i=F0e(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 F0e(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 U0e(t){return t.value}function z0e(t){var{contextPayload:e}=t,n=I0e(t,R0e),r=gX(e,t.payloadUniqBy,U0e),i=Ng(Ng({},n),{},{payload:r});return w.isValidElement(t.content)?w.cloneElement(t.content,i):typeof t.content=="function"?w.createElement(t.content,i):w.createElement(Dge,i)}function B0e(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}),Ng(Ng({},u),d)}function $0e(t){var e=Sr();return w.useEffect(()=>{e(j0e(t))},[e,t]),null}function H0e(t){var e=Sr();return w.useEffect(()=>(e($8(t)),()=>{e($8({width:0,height:0}))}),[e,t]),null}function V0e(t,e,n,r){return t==="vertical"&&e!=null?{height:e}:t==="horizontal"?{width:n||r}:null}var G0e={align:"center",iconSize:14,inactiveColor:"#ccc",itemSorter:"value",layout:"horizontal",verticalAlign:"bottom"};function SO(t){var e=Xr(t,G0e),n=Exe(),r=Epe(),i=x0e(),{width:a,height:o,wrapperStyle:l,portal:c}=e,[u,d]=wX([n]),f=bO(),m=yO();if(f==null||m==null)return null;var p=f-(i?.left||0)-(i?.right||0),b=V0e(e.layout,o,a,p),y=c?l:Ng(Ng({position:"absolute",width:b?.width||a||"auto",height:b?.height||o||"auto"},B0e(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($0e,{layout:e.layout,align:e.align,verticalAlign:e.verticalAlign,itemSorter:e.itemSorter}),!c&&w.createElement(H0e,{width:u.width,height:u.height}),w.createElement(z0e,JP({},e,b,{margin:i,chartWidth:f,chartHeight:m,contextPayload:n})));return Jc.createPortal(v,x)}SO.displayName="Legend";function e3(){return e3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},e3.apply(null,arguments)}function 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 db(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){W0e(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 W0e(t,e,n){return(e=q0e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function q0e(t){var e=K0e(t,"string");return typeof e=="symbol"?e:e+""}function K0e(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 X0e(t){return Array.isArray(t)&&Fo(t[0])&&Fo(t[1])?t.join(" ~ "):t}var tp={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},Y0e=t=>{var{separator:e=tp.separator,contentStyle:n,itemStyle:r,labelStyle:i=tp.labelStyle,payload:a,formatter:o,itemSorter:l,wrapperClassName:c,labelClassName:u,label:d,labelFormatter:f,accessibilityLayer:m=tp.accessibilityLayer}=t,p=()=>{if(a&&a.length){var T={padding:0,margin:0},k=(l?vN(a,l):a).map((E,O)=>{if(E.type==="none")return null;var C=E.formatter||o||X0e,{value:D,name:U}=E,L=D,q=U;if(C){var P=C(D,U,E,O,a);if(Array.isArray(P))[L,q]=P;else if(P!=null)L=P;else return null}var W=db(db({},tp.itemStyle),{},{color:E.color||tp.itemStyle.color},r);return w.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(O),style:W},Fo(q)?w.createElement("span",{className:"recharts-tooltip-item-name"},q):null,Fo(q)?w.createElement("span",{className:"recharts-tooltip-item-separator"},e):null,w.createElement("span",{className:"recharts-tooltip-item-value"},L),w.createElement("span",{className:"recharts-tooltip-item-unit"},E.unit||""))});return w.createElement("ul",{className:"recharts-tooltip-item-list",style:T},k)}return null},b=db(db({},tp.contentStyle),n),y=db({margin:0},i),x=!Vr(d),v=x?d:"",S=Vn("recharts-default-tooltip",c),M=Vn("recharts-tooltip-label",u);x&&f&&a!==void 0&&a!==null&&(v=f(d,a));var A=m?{role:"status","aria-live":"assertive"}:{};return w.createElement("div",e3({className:S,style:b},A),w.createElement("p",{className:M,style:y},w.isValidElement(v)?v:"".concat(v)),p())},hb="recharts-tooltip-wrapper",Z0e={visibility:"hidden"};function Q0e(t){var{coordinate:e,translateX:n,translateY:r}=t;return Vn(hb,{["".concat(hb,"-right")]:Bt(n)&&e&&Bt(e.x)&&n>=e.x,["".concat(hb,"-left")]:Bt(n)&&e&&Bt(e.x)&&n<e.x,["".concat(hb,"-bottom")]:Bt(r)&&e&&Bt(e.y)&&r>=e.y,["".concat(hb,"-top")]:Bt(r)&&e&&Bt(e.y)&&r<e.y})}function G8(t){var{allowEscapeViewBox:e,coordinate:n,key:r,offset:i,position:a,reverseDirection:o,tooltipDimension:l,viewBox:c,viewBoxDimension:u}=t;if(a&&Bt(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 J0e(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 eye(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=G8({allowEscapeViewBox:e,coordinate:n,key:"x",offset:i,position:a,reverseDirection:o,tooltipDimension:l.width,viewBox:u,viewBoxDimension:u.width}),m=G8({allowEscapeViewBox:e,coordinate:n,key:"y",offset:r,position:a,reverseDirection:o,tooltipDimension:l.height,viewBox:u,viewBoxDimension:u.height}),d=J0e({translateX:f,translateY:m,useTranslate3d:c})):d=Z0e,{cssProperties:d,cssClasses:Q0e({translateX:f,translateY:m,coordinate:n})}}function W8(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?W8(Object(n),!0).forEach(function(r){t3(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):W8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function t3(t,e,n){return(e=tye(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function tye(t){var e=nye(t,"string");return typeof e=="symbol"?e:e+""}function nye(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 rye extends w.PureComponent{constructor(){super(...arguments),t3(this,"state",{dismissed:!1,dismissedAtCoordinate:{x:0,y:0}}),t3(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:A,cssProperties:T}=eye({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?{}:T_(T_({transition:c&&e?"transform ".concat(r,"ms ").concat(i):void 0},T),{},{pointerEvents:"none",visibility:!this.state.dismissed&&e&&l?"visible":"hidden",position:"absolute",top:0,left:0}),E=T_(T_({},k),{},{visibility:!this.state.dismissed&&e&&l?"visible":"hidden"},b);return w.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",tabIndex:-1,className:A,style:E,ref:x},a)}}var vY=()=>{var t;return(t=Wt(e=>e.rootProps.accessibilityLayer))!==null&&t!==void 0?t:!0};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 q8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function K8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?q8(Object(n),!0).forEach(function(r){iye(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):q8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function iye(t,e,n){return(e=aye(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function aye(t){var e=sye(t,"string");return typeof e=="symbol"?e:e+""}function sye(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var X8={curveBasisClosed:Gpe,curveBasisOpen:Wpe,curveBasis:Vpe,curveBumpX:kpe,curveBumpY:jpe,curveLinearClosed:qpe,curveLinear:bN,curveMonotoneX:Kpe,curveMonotoneY:Xpe,curveNatural:Ype,curveStep:Zpe,curveStepAfter:Jpe,curveStepBefore:Qpe},lS=t=>pn(t.x)&&pn(t.y),Y8=t=>t.base!=null&&lS(t.base)&&lS(t),fb=t=>t.x,mb=t=>t.y,oye=(t,e)=>{if(typeof t=="function")return t;var n="curve".concat(Ey(t));if((n==="curveMonotone"||n==="curveBump")&&e){var r=X8["".concat(n).concat(e==="vertical"?"Y":"X")];if(r)return r}return X8[n]||bN},Z8={connectNulls:!1,type:"linear"},lye=t=>{var{type:e=Z8.type,points:n=[],baseLine:r,layout:i,connectNulls:a=Z8.connectNulls}=t,o=oye(e,i),l=a?n.filter(lS):n;if(Array.isArray(r)){var c,u=n.map((b,y)=>K8(K8({},b),{},{base:r[y]}));i==="vertical"?c=v_().y(mb).x1(fb).x0(b=>b.base.x):c=v_().x(fb).y1(mb).y0(b=>b.base.y);var d=c.defined(Y8).curve(o),f=a?u.filter(Y8):u;return d(f)}var m;i==="vertical"&&Bt(r)?m=v_().y(mb).x1(fb).x0(r):Bt(r)?m=v_().x(fb).y1(mb).y0(r):m=WK().x(fb).y(mb);var p=m.defined(lS).curve(o);return p(l)},og=t=>{var{className:e,points:n,path:r,pathRef:i}=t,a=gh();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?lye(o):r;return w.createElement("path",n3({},rs(t),aO(t),{className:Vn("recharts-curve",e),d:l===null?void 0:l,ref:i}))},cye=["x","y","top","left","width","height","className"];function r3(){return r3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},r3.apply(null,arguments)}function Q8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function uye(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Q8(Object(n),!0).forEach(function(r){dye(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Q8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function dye(t,e,n){return(e=hye(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function hye(t){var e=fye(t,"string");return typeof e=="symbol"?e:e+""}function fye(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 mye(t,e){if(t==null)return{};var n,r,i=pye(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 pye(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 gye=(t,e,n,r,i,a)=>"M".concat(t,",").concat(i,"v").concat(r,"M").concat(a,",").concat(e,"h").concat(n),xye=t=>{var{x:e=0,y:n=0,top:r=0,left:i=0,width:a=0,height:o=0,className:l}=t,c=mye(t,cye),u=uye({x:e,y:n,top:r,left:i,width:a,height:o},c);return!Bt(e)||!Bt(n)||!Bt(a)||!Bt(o)||!Bt(r)||!Bt(i)?null:w.createElement("path",r3({},Ca(u),{className:Vn("recharts-cross",l),d:gye(e,n,a,o,r,i)}))};function bye(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 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 e6(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){yye(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 yye(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=_ye(t,"string");return typeof e=="symbol"?e:e+""}function _ye(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 wye=t=>t.replace(/([A-Z])/g,e=>"-".concat(e.toLowerCase())),_Y=(t,e,n)=>t.map(r=>"".concat(wye(r)," ").concat(e,"ms ").concat(n)).join(","),Sye=(t,e)=>[Object.keys(t),Object.keys(e)].reduce((n,r)=>n.filter(i=>r.includes(i))),H0=(t,e)=>Object.keys(e).reduce((n,r)=>e6(e6({},n),{},{[r]:t(r,e[r])}),{});function t6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Ri(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?t6(Object(n),!0).forEach(function(r){Mye(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):t6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Mye(t,e,n){return(e=Nye(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Nye(t){var e=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)}var cS=(t,e,n)=>t+(e-t)*n,i3=t=>{var{from:e,to:n}=t;return e!==n},wY=(t,e,n)=>{var r=H0((i,a)=>{if(i3(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?H0((i,a)=>i3(a)&&r[i]!=null?Ri(Ri({},a),{},{velocity:cS(a.velocity,r[i].velocity,n),from:cS(a.from,r[i].from,n)}):a,e):wY(t,r,n-1)};function Aye(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=()=>H0((m,p)=>p.from,l),u=()=>!Object.values(l).filter(i3).length,d=null,f=m=>{o||(o=m);var p=m-o,b=p/n.dt;l=wY(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 Tye(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=H0((y,x)=>cS(...x,n(m)),c);if(a(Ri(Ri(Ri({},t),e),p)),m<1)l=o.setTimeout(d);else{var b=H0((y,x)=>cS(...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 Cye=(t,e,n,r,i,a)=>{var o=Sye(t,e);return n==null?()=>(i(Ri(Ri({},t),e)),()=>{}):n.isStepper===!0?Aye(t,e,n,o,i,a):Tye(t,e,n,r,o,i,a)};var uS=1e-4,SY=(t,e)=>[0,3*t,3*e-6*t,3*t-3*e+1],MY=(t,e)=>t.map((n,r)=>n*e**r).reduce((n,r)=>n+r),n6=(t,e)=>n=>{var r=SY(t,e);return MY(r,n)},kye=(t,e)=>n=>{var r=SY(t,e),i=[...r.map((a,o)=>a*o).slice(1),0];return MY(i,n)},jye=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]]},Pye=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=jye(n[0]);if(i)return i}}return n.length===4?n:[0,0,1,1]},Rye=(t,e,n,r)=>{var i=n6(t,n),a=n6(e,r),o=kye(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)<uS||b<uS)return a(f);f=l(f-p/b)}return a(f)};return c.isStepper=!1,c},r6=function(){return Rye(...Pye(...arguments))},Dye=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)<uS&&Math.abs(f)<uS?[l,0]:[m,f]};return a.isStepper=!0,a.dt=i,a},Oye=t=>{if(typeof t=="string")switch(t){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return r6(t);case"spring":return Dye();default:if(t.split("(")[0]==="cubic-bezier")return r6(t)}return typeof t=="function"?t:null};function Lye(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 Iye{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 Fye(){return Lye(new Iye)}var Uye=w.createContext(Fye);function zye(t,e){var n=w.useContext(Uye);return w.useMemo(()=>e??n(t),[t,e,n])}var Bye=()=>!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout),Dy={isSsr:Bye()},$ye={begin:0,duration:1e3,easing:"ease",isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},i6={t:0},mC={t:1};function tx(t){var e=Xr(t,$ye),{isActive:n,canBegin:r,duration:i,easing:a,begin:o,onAnimationEnd:l,onAnimationStart:c,children:u}=e,d=n==="auto"?!Dy.isSsr:n,f=zye(e.animationId,e.animationManager),[m,p]=w.useState(d?i6:mC),b=w.useRef(null);return w.useEffect(()=>{d||p(mC)},[d]),w.useEffect(()=>{if(!d||!r)return mh;var y=Cye(i6,mC,Oye(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 nx(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"animation-",n=w.useRef(L0(e)),r=w.useRef(t);return r.current!==t&&(n.current=L0(e),r.current=t),n.current}var Hye=["radius"],Vye=["radius"],a6,s6,o6,l6,c6,u6,d6,h6,f6,m6;function p6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function g6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?p6(Object(n),!0).forEach(function(r){Gye(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):p6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Gye(t,e,n){return(e=Wye(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Wye(t){var e=qye(t,"string");return typeof e=="symbol"?e:e+""}function qye(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function dS(){return dS=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},dS.apply(null,arguments)}function x6(t,e){if(t==null)return{};var n,r,i=Kye(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 Kye(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function El(t,e){return e||(e=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}var b6=(t,e,n,r,i)=>{var a=Pd(n),o=Pd(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=ri(a6||(a6=El(["M",",",""])),t,e+c*m[0]),m[0]>0&&(f+=ri(s6||(s6=El(["A ",",",",0,0,",",",",",""])),m[0],m[0],d,t+u*m[0],e)),f+=ri(o6||(o6=El(["L ",",",""])),t+n-u*m[1],e),m[1]>0&&(f+=ri(l6||(l6=El(["A ",",",",0,0,",`,
- `,",",""])),m[1],m[1],d,t+n,e+c*m[1])),f+=ri(c6||(c6=El(["L ",",",""])),t+n,e+r-c*m[2]),m[2]>0&&(f+=ri(u6||(u6=El(["A ",",",",0,0,",`,
- `,",",""])),m[2],m[2],d,t+n-u*m[2],e+r)),f+=ri(d6||(d6=El(["L ",",",""])),t+u*m[3],e+r),m[3]>0&&(f+=ri(h6||(h6=El(["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=ri(f6||(f6=El(["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=ri(m6||(m6=El(["M ",","," h "," v "," h "," Z"])),t,e,n,r,-n);return f},y6={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},NY=t=>{var e=Xr(t,y6),n=w.useRef(null),[r,i]=w.useState(-1);w.useEffect(()=>{if(n.current&&n.current.getTotalLength)try{var V=n.current.getTotalLength();V&&i(V)}catch{}},[]);var{x:a,y:o,width:l,height:c,radius:u,className:d}=e,{animationEasing:f,animationDuration:m,animationBegin:p,isAnimationActive:b,isUpdateAnimationActive:y}=e,x=w.useRef(l),v=w.useRef(c),S=w.useRef(a),M=w.useRef(o),A=w.useMemo(()=>({x:a,y:o,width:l,height:c,radius:u}),[a,o,l,c,u]),T=nx(A,"rectangle-");if(a!==+a||o!==+o||l!==+l||c!==+c||l===0||c===0)return null;var k=Vn("recharts-rectangle",d);if(!y){var E=Ca(e),{radius:O}=E,C=x6(E,Hye);return w.createElement("path",dS({},C,{x:Pd(a),y:Pd(o),width:Pd(l),height:Pd(c),radius:typeof u=="number"?u:void 0,className:k,d:b6(a,o,l,c,u)}))}var D=x.current,U=v.current,L=S.current,q=M.current,P="0px ".concat(r===-1?1:r,"px"),W="".concat(r,"px 0px"),K=_Y(["strokeDasharray"],m,typeof f=="string"?f:y6.animationEasing);return w.createElement(tx,{animationId:T,key:T,canBegin:r>0,duration:m,easing:f,isActive:y,begin:p},V=>{var Q=tr(D,l,V),re=tr(U,c,V),J=tr(L,a,V),z=tr(q,o,V);n.current&&(x.current=Q,v.current=re,S.current=J,M.current=z);var G;b?V>0?G={transition:K,strokeDasharray:W}:G={strokeDasharray:P}:G={strokeDasharray:W};var ne=Ca(e),{radius:ae}=ne,de=x6(ne,Vye);return w.createElement("path",dS({},de,{radius:typeof u=="number"?u:void 0,className:k,d:b6(J,z,Q,re,u),ref:n,style:g6(g6({},G),e.style)}))})};function v6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function _6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?v6(Object(n),!0).forEach(function(r){Xye(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):v6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Xye(t,e,n){return(e=Yye(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Yye(t){var e=Zye(t,"string");return typeof e=="symbol"?e:e+""}function Zye(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 hS=Math.PI/180,Qye=t=>t*180/Math.PI,Ai=(t,e,n,r)=>({x:t+Math.cos(-hS*r)*n,y:e+Math.sin(-hS*r)*n}),EY=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},Jye=(t,e)=>{var{x:n,y:r}=t,{x:i,y:a}=e;return Math.sqrt((n-i)**2+(r-a)**2)},eve=(t,e)=>{var{x:n,y:r}=t,{cx:i,cy:a}=e,o=Jye({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:Qye(c),angleInRadian:c}},tve=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}},nve=(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},rve=(t,e)=>{var{chartX:n,chartY:r}=t,{radius:i,angle:a}=eve({x:n,y:r},e),{innerRadius:o,outerRadius:l}=e;if(i<o||i>l||i===0)return null;var{startAngle:c,endAngle:u}=tve(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?_6(_6({},e),{},{radius:i,angle:nve(d,e)}):null};function AY(t){var{cx:e,cy:n,radius:r,startAngle:i,endAngle:a}=t,o=Ai(e,n,r,i),l=Ai(e,n,r,a);return{points:[o,l],cx:e,cy:n,radius:r,startAngle:i,endAngle:a}}var w6,S6,M6,N6,E6,A6,T6;function a3(){return a3=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},a3.apply(null,arguments)}function gf(t,e){return e||(e=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}var ive=(t,e)=>{var n=ta(e-t),r=Math.min(Math.abs(e-t),359.999);return n*r},C_=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)/hS,f=c?i:i+a*d,m=Ai(e,n,u,f),p=Ai(e,n,r,f),b=c?i-a*d:i,y=Ai(e,n,u*Math.cos(d*hS),b);return{center:m,circleTangency:p,lineTangency:y,theta:d}},TY=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:a,endAngle:o}=t,l=ive(a,o),c=a+l,u=Ai(e,n,i,a),d=Ai(e,n,i,c),f=ri(w6||(w6=gf(["M ",",",`
- A `,",",`,0,
- `,",",`,
- `,",",`
- `])),u.x,u.y,i,i,+(Math.abs(l)>180),+(a>c),d.x,d.y);if(r>0){var m=Ai(e,n,r,a),p=Ai(e,n,r,c);f+=ri(S6||(S6=gf(["L ",",",`
- A `,",",`,0,
- `,",",`,
- `,","," Z"])),p.x,p.y,r,r,+(Math.abs(l)>180),+(a<=c),m.x,m.y)}else f+=ri(M6||(M6=gf(["L ",","," Z"])),e,n);return f},ave=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,cornerRadius:a,forceCornerRadius:o,cornerIsExternal:l,startAngle:c,endAngle:u}=t,d=ta(u-c),{circleTangency:f,lineTangency:m,theta:p}=C_({cx:e,cy:n,radius:i,angle:c,sign:d,cornerRadius:a,cornerIsExternal:l}),{circleTangency:b,lineTangency:y,theta:x}=C_({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?ri(N6||(N6=gf(["M ",",",`
- a`,",",",0,0,1,",`,0
- a`,",",",0,0,1,",`,0
- `])),m.x,m.y,a,a,a*2,a,a,-a*2):TY({cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:c,endAngle:u});var S=ri(E6||(E6=gf(["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:A,theta:T}=C_({cx:e,cy:n,radius:r,angle:c,sign:d,isExternal:!0,cornerRadius:a,cornerIsExternal:l}),{circleTangency:k,lineTangency:E,theta:O}=C_({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)-T-O;if(C<0&&a===0)return"".concat(S,"L").concat(e,",").concat(n,"Z");S+=ri(A6||(A6=gf(["L",",",`
- A`,",",",0,0,",",",",",`
- A`,",",",0,",",",",",",",`
- A`,",",",0,0,",",",",","Z"])),E.x,E.y,a,a,+(d<0),k.x,k.y,r,r,+(C>180),+(d>0),M.x,M.y,a,a,+(d<0),A.x,A.y)}else S+=ri(T6||(T6=gf(["L",",","Z"])),e,n);return S},sve={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},CY=t=>{var e=Xr(t,sve),{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=Vn("recharts-sector",f),p=a-i,b=$a(o,p,0,!0),y;return b>0&&Math.abs(u-d)<360?y=ave({cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:Math.min(b,p/2),forceCornerRadius:l,cornerIsExternal:c,startAngle:u,endAngle:d}):y=TY({cx:n,cy:r,innerRadius:i,outerRadius:a,startAngle:u,endAngle:d}),w.createElement("path",a3({},Ca(e),{className:m,d:y}))};function ove(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(oX(e)){if(t==="centric"){var{cx:r,cy:i,innerRadius:a,outerRadius:o,angle:l}=e,c=Ai(r,i,a,l),u=Ai(r,i,o,l);return[{x:c.x,y:c.y},{x:u.x,y:u.y}]}return AY(e)}}var pC={},gC={},xC={},C6;function lve(){return C6||(C6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=yX();function n(r){return e.isSymbol(r)?NaN:Number(r)}t.toNumber=n})(xC)),xC}var k6;function cve(){return k6||(k6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=lve();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})(gC)),gC}var j6;function uve(){return j6||(j6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=vX(),n=cve();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})(pC)),pC}var bC,P6;function dve(){return P6||(P6=1,bC=uve().range),bC}var hve=dve();const kY=pl(hve);function Hd(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function fve(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function MO(t){let e,n,r;t.length!==2?(e=Hd,n=(l,c)=>Hd(t(l),c),r=(l,c)=>t(l)-c):(e=t===Hd||t===fve?t:mve,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 mve(){return 0}function jY(t){return t===null?NaN:+t}function*pve(t,e){for(let n of t)n!=null&&(n=+n)>=n&&(yield n)}const gve=MO(Hd),Oy=gve.right;MO(jY).center;class R6 extends Map{constructor(e,n=yve){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(D6(this,e))}has(e){return super.has(D6(this,e))}set(e,n){return super.set(xve(this,e),n)}delete(e){return super.delete(bve(this,e))}}function D6({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function xve({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}function bve({_intern:t,_key:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}function yve(t){return t!==null&&typeof t=="object"?t.valueOf():t}function vve(t=Hd){if(t===Hd)return PY;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 PY(t,e){return(t==null||!(t>=t))-(e==null||!(e>=e))||(t<e?-1:t>e?1:0)}const _ve=Math.sqrt(50),wve=Math.sqrt(10),Sve=Math.sqrt(2);function fS(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>=_ve?10:a>=wve?5:a>=Sve?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?fS(t,e,n*2):[l,c,u]}function s3(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?fS(e,t,n):fS(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 o3(t,e,n){return e=+e,t=+t,n=+n,fS(t,e,n)[2]}function l3(t,e,n){e=+e,t=+t,n=+n;const r=e<t,i=r?o3(e,t,n):o3(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}function O6(t,e){let n;for(const r of t)r!=null&&(n<r||n===void 0&&r>=r)&&(n=r);return n}function L6(t,e){let n;for(const r of t)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);return n}function RY(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?PY:vve(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));RY(t,e,p,b,i)}const a=t[e];let o=n,l=r;for(pb(t,n,e),i(t[r],a)>0&&pb(t,n,r);o<l;){for(pb(t,o,l),++o,--l;i(t[o],a)<0;)++o;for(;i(t[l],a)>0;)--l}i(t[n],a)===0?pb(t,n,l):(++l,pb(t,l,r)),l<=e&&(n=l+1),e<=l&&(r=l-1)}return t}function pb(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function Mve(t,e,n){if(t=Float64Array.from(pve(t)),!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return L6(t);if(e>=1)return O6(t);var r,i=(r-1)*e,a=Math.floor(i),o=O6(RY(t,a).subarray(0,a+1)),l=L6(t.subarray(a+1));return o+(l-o)*(i-a)}}function Nve(t,e,n=jY){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 Eve(t,e,n){t=+t,e=+e,n=(i=arguments.length)<2?(e=t,t=0,1):i<3?1:+n;for(var r=-1,i=Math.max(0,Math.ceil((e-t)/n))|0,a=new Array(i);++r<i;)a[r]=t+r*n;return a}function $o(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function Cu(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 c3=Symbol("implicit");function NO(){var t=new R6,e=[],n=[],r=c3;function i(a){let o=t.get(a);if(o===void 0){if(r!==c3)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 R6;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 NO(e,n).unknown(r)},$o.apply(i,arguments),i}function EO(){var t=NO().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=Eve(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 EO(e(),[r,i]).round(l).paddingInner(c).paddingOuter(u).align(d)},$o.apply(f(),arguments)}function DY(t){var e=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,delete t.paddingOuter,t.copy=function(){return DY(e())},t}function Ave(){return DY(EO.apply(null,arguments).paddingInner(1))}function AO(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function OY(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function Ly(){}var V0=.7,mS=1/V0,lg="\\s*([+-]?\\d+)\\s*",G0="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ql="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Tve=/^#([0-9a-f]{3,8})$/,Cve=new RegExp(`^rgb\\(${lg},${lg},${lg}\\)$`),kve=new RegExp(`^rgb\\(${ql},${ql},${ql}\\)$`),jve=new RegExp(`^rgba\\(${lg},${lg},${lg},${G0}\\)$`),Pve=new RegExp(`^rgba\\(${ql},${ql},${ql},${G0}\\)$`),Rve=new RegExp(`^hsl\\(${G0},${ql},${ql}\\)$`),Dve=new RegExp(`^hsla\\(${G0},${ql},${ql},${G0}\\)$`),I6={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};AO(Ly,W0,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:F6,formatHex:F6,formatHex8:Ove,formatHsl:Lve,formatRgb:U6,toString:U6});function F6(){return this.rgb().formatHex()}function Ove(){return this.rgb().formatHex8()}function Lve(){return LY(this).formatHsl()}function U6(){return this.rgb().formatRgb()}function W0(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=Tve.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?z6(e):n===3?new Ss(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?k_(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?k_(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=Cve.exec(t))?new Ss(e[1],e[2],e[3],1):(e=kve.exec(t))?new Ss(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=jve.exec(t))?k_(e[1],e[2],e[3],e[4]):(e=Pve.exec(t))?k_(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=Rve.exec(t))?H6(e[1],e[2]/100,e[3]/100,1):(e=Dve.exec(t))?H6(e[1],e[2]/100,e[3]/100,e[4]):I6.hasOwnProperty(t)?z6(I6[t]):t==="transparent"?new Ss(NaN,NaN,NaN,0):null}function z6(t){return new Ss(t>>16&255,t>>8&255,t&255,1)}function k_(t,e,n,r){return r<=0&&(t=e=n=NaN),new Ss(t,e,n,r)}function Ive(t){return t instanceof Ly||(t=W0(t)),t?(t=t.rgb(),new Ss(t.r,t.g,t.b,t.opacity)):new Ss}function u3(t,e,n,r){return arguments.length===1?Ive(t):new Ss(t,e,n,r??1)}function Ss(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}AO(Ss,u3,OY(Ly,{brighter(t){return t=t==null?mS:Math.pow(mS,t),new Ss(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?V0:Math.pow(V0,t),new Ss(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Ss(Cf(this.r),Cf(this.g),Cf(this.b),pS(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:B6,formatHex:B6,formatHex8:Fve,formatRgb:$6,toString:$6}));function B6(){return`#${xf(this.r)}${xf(this.g)}${xf(this.b)}`}function Fve(){return`#${xf(this.r)}${xf(this.g)}${xf(this.b)}${xf((isNaN(this.opacity)?1:this.opacity)*255)}`}function $6(){const t=pS(this.opacity);return`${t===1?"rgb(":"rgba("}${Cf(this.r)}, ${Cf(this.g)}, ${Cf(this.b)}${t===1?")":`, ${t})`}`}function pS(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Cf(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function xf(t){return t=Cf(t),(t<16?"0":"")+t.toString(16)}function H6(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new tl(t,e,n,r)}function LY(t){if(t instanceof tl)return new tl(t.h,t.s,t.l,t.opacity);if(t instanceof Ly||(t=W0(t)),!t)return new tl;if(t instanceof tl)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 tl(o,l,c,t.opacity)}function Uve(t,e,n,r){return arguments.length===1?LY(t):new tl(t,e,n,r??1)}function tl(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}AO(tl,Uve,OY(Ly,{brighter(t){return t=t==null?mS:Math.pow(mS,t),new tl(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?V0:Math.pow(V0,t),new tl(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 Ss(yC(t>=240?t-240:t+120,i,r),yC(t,i,r),yC(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new tl(V6(this.h),j_(this.s),j_(this.l),pS(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=pS(this.opacity);return`${t===1?"hsl(":"hsla("}${V6(this.h)}, ${j_(this.s)*100}%, ${j_(this.l)*100}%${t===1?")":`, ${t})`}`}}));function V6(t){return t=(t||0)%360,t<0?t+360:t}function j_(t){return Math.max(0,Math.min(1,t||0))}function yC(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 TO=t=>()=>t;function zve(t,e){return function(n){return t+n*e}}function Bve(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 $ve(t){return(t=+t)==1?IY:function(e,n){return n-e?Bve(e,n,t):TO(isNaN(e)?n:e)}}function IY(t,e){var n=e-t;return n?zve(t,n):TO(isNaN(t)?e:t)}const G6=(function t(e){var n=$ve(e);function r(i,a){var o=n((i=u3(i)).r,(a=u3(a)).r),l=n(i.g,a.g),c=n(i.b,a.b),u=IY(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 Hve(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 Vve(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Gve(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]=rx(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 Wve(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function gS(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function qve(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]=rx(t[i],e[i]):r[i]=e[i];return function(a){for(i in n)r[i]=n[i](a);return r}}var d3=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,vC=new RegExp(d3.source,"g");function Kve(t){return function(){return t}}function Xve(t){return function(e){return t(e)+""}}function Yve(t,e){var n=d3.lastIndex=vC.lastIndex=0,r,i,a,o=-1,l=[],c=[];for(t=t+"",e=e+"";(r=d3.exec(t))&&(i=vC.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:gS(r,i)})),n=vC.lastIndex;return n<e.length&&(a=e.slice(n),l[o]?l[o]+=a:l[++o]=a),l.length<2?c[0]?Xve(c[0].x):Kve(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 rx(t,e){var n=typeof e,r;return e==null||n==="boolean"?TO(e):(n==="number"?gS:n==="string"?(r=W0(e))?(e=r,G6):Yve:e instanceof W0?G6:e instanceof Date?Wve:Vve(e)?Hve:Array.isArray(e)?Gve:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?qve:gS)(t,e)}function CO(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}function Zve(t,e){e===void 0&&(e=t,t=rx);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 Qve(t){return function(){return t}}function xS(t){return+t}var W6=[0,1];function Qa(t){return t}function h3(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:Qve(isNaN(e)?NaN:.5)}function Jve(t,e){var n;return t>e&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function e_e(t,e,n){var r=t[0],i=t[1],a=e[0],o=e[1];return i<r?(r=h3(i,r),a=n(o,a)):(r=h3(r,i),a=n(a,o)),function(l){return a(r(l))}}function t_e(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]=h3(t[o],t[o+1]),a[o]=n(e[o],e[o+1]);return function(l){var c=Oy(t,l,1,r)-1;return a[c](i[c](l))}}function Iy(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function IN(){var t=W6,e=W6,n=rx,r,i,a,o=Qa,l,c,u;function d(){var m=Math.min(t.length,e.length);return o!==Qa&&(o=Jve(t[0],t[m-1])),l=m>2?t_e:e_e,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),gS)))(m)))},f.domain=function(m){return arguments.length?(t=Array.from(m,xS),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=CO,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 kO(){return IN()(Qa,Qa)}function n_e(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function bS(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 Eg(t){return t=bS(Math.abs(t)),t?t[1]:NaN}function r_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 i_e(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var a_e=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function q0(t){if(!(e=a_e.exec(t)))throw new Error("invalid format: "+t);var e;return new jO({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]})}q0.prototype=jO.prototype;function jO(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+""}jO.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 s_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 yS;function o_e(t,e){var n=bS(t,e);if(!n)return yS=void 0,t.toPrecision(e);var r=n[0],i=n[1],a=i-(yS=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")+bS(t,Math.max(0,e+a-1))[0]}function q6(t,e){var n=bS(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 K6={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:n_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)=>q6(t*100,e),r:q6,s:o_e,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function X6(t){return t}var Y6=Array.prototype.map,Z6=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function l_e(t){var e=t.grouping===void 0||t.thousands===void 0?X6:r_e(Y6.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?X6:i_e(Y6.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=q0(f);var p=f.fill,b=f.align,y=f.sign,x=f.symbol,v=f.zero,S=f.width,M=f.comma,A=f.precision,T=f.trim,k=f.type;k==="n"?(M=!0,k="g"):K6[k]||(A===void 0&&(A=12),T=!0,k="g"),(v||p==="0"&&b==="=")&&(v=!0,p="0",b="=");var E=(m&&m.prefix!==void 0?m.prefix:"")+(x==="$"?n:x==="#"&&/[boxX]/.test(k)?"0"+k.toLowerCase():""),O=(x==="$"?r:/[%p]/.test(k)?o:"")+(m&&m.suffix!==void 0?m.suffix:""),C=K6[k],D=/[defgprs%]/.test(k);A=A===void 0?6:/[gprs]/.test(k)?Math.max(1,Math.min(21,A)):Math.max(0,Math.min(20,A));function U(L){var q=E,P=O,W,K,V;if(k==="c")P=C(L)+P,L="";else{L=+L;var Q=L<0||1/L<0;if(L=isNaN(L)?c:C(Math.abs(L),A),T&&(L=s_e(L)),Q&&+L==0&&y!=="+"&&(Q=!1),q=(Q?y==="("?y:l:y==="-"||y==="("?"":y)+q,P=(k==="s"&&!isNaN(L)&&yS!==void 0?Z6[8+yS/3]:"")+P+(Q&&y==="("?")":""),D){for(W=-1,K=L.length;++W<K;)if(V=L.charCodeAt(W),48>V||V>57){P=(V===46?i+L.slice(W+1):L.slice(W))+P,L=L.slice(0,W);break}}}M&&!v&&(L=e(L,1/0));var re=q.length+L.length+P.length,J=re<S?new Array(S-re+1).join(p):"";switch(M&&v&&(L=e(J+L,J.length?S-P.length:1/0),J=""),b){case"<":L=q+L+P+J;break;case"=":L=q+J+L+P;break;case"^":L=J.slice(0,re=J.length>>1)+q+L+P+J.slice(re);break;default:L=J+q+L+P;break}return a(L)}return U.toString=function(){return f+""},U}function d(f,m){var p=Math.max(-8,Math.min(8,Math.floor(Eg(m)/3)))*3,b=Math.pow(10,-p),y=u((f=q0(f),f.type="f",f),{suffix:Z6[8+p/3]});return function(x){return y(b*x)}}return{format:u,formatPrefix:d}}var P_,PO,FY;c_e({thousands:",",grouping:[3],currency:["$",""]});function c_e(t){return P_=l_e(t),PO=P_.format,FY=P_.formatPrefix,P_}function u_e(t){return Math.max(0,-Eg(Math.abs(t)))}function d_e(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Eg(e)/3)))*3-Eg(Math.abs(t)))}function h_e(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,Eg(e)-Eg(t))+1}function UY(t,e,n,r){var i=l3(t,e,n),a;switch(r=q0(r??",f"),r.type){case"s":{var o=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(a=d_e(i,o))&&(r.precision=a),FY(r,o)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(a=h_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=u_e(i))&&(r.precision=a-(r.type==="%")*2);break}}return PO(r)}function xh(t){var e=t.domain;return t.ticks=function(n){var r=e();return s3(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var i=e();return UY(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=o3(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 zY(){var t=kO();return t.copy=function(){return Iy(t,zY())},$o.apply(t,arguments),xh(t)}function BY(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,xS),n):t.slice()},n.unknown=function(r){return arguments.length?(e=r,n):e},n.copy=function(){return BY(t).unknown(e)},t=arguments.length?Array.from(t,xS):[0,1],xh(n)}function $Y(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 Q6(t){return Math.log(t)}function J6(t){return Math.exp(t)}function f_e(t){return-Math.log(-t)}function m_e(t){return-Math.exp(-t)}function p_e(t){return isFinite(t)?+("1e"+t):t<0?0:t}function g_e(t){return t===10?p_e:t===Math.E?Math.exp:e=>Math.pow(t,e)}function x_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 e$(t){return(e,n)=>-t(-e,n)}function RO(t){const e=t(Q6,J6),n=e.domain;let r=10,i,a;function o(){return i=x_e(r),a=g_e(r),n()[0]<0?(i=e$(i),a=e$(a),t(f_e,m_e)):t(Q6,J6),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=s3(u,d,x))}else v=s3(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=q0(c)).precision==null&&(c.trim=!0),c=PO(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($Y(n(),{floor:l=>a(Math.floor(i(l))),ceil:l=>a(Math.ceil(i(l)))})),e}function HY(){const t=RO(IN()).domain([1,10]);return t.copy=()=>Iy(t,HY()).base(t.base()),$o.apply(t,arguments),t}function t$(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function n$(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function DO(t){var e=1,n=t(t$(e),n$(e));return n.constant=function(r){return arguments.length?t(t$(e=+r),n$(e)):e},xh(n)}function VY(){var t=DO(IN());return t.copy=function(){return Iy(t,VY()).constant(t.constant())},$o.apply(t,arguments)}function r$(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function b_e(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function y_e(t){return t<0?-t*t:t*t}function OO(t){var e=t(Qa,Qa),n=1;function r(){return n===1?t(Qa,Qa):n===.5?t(b_e,y_e):t(r$(n),r$(1/n))}return e.exponent=function(i){return arguments.length?(n=+i,r()):n},xh(e)}function LO(){var t=OO(IN());return t.copy=function(){return Iy(t,LO()).exponent(t.exponent())},$o.apply(t,arguments),t}function v_e(){return LO.apply(null,arguments).exponent(.5)}function i$(t){return Math.sign(t)*t*t}function __e(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function GY(){var t=kO(),e=[0,1],n=!1,r;function i(a){var o=__e(t(a));return isNaN(o)?r:n?Math.round(o):o}return i.invert=function(a){return t.invert(i$(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,xS)).map(i$)),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 GY(t.domain(),e).round(n).clamp(t.clamp()).unknown(r)},$o.apply(i,arguments),xh(i)}function WY(){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]=Nve(t,o/l);return a}function a(o){return o==null||isNaN(o=+o)?r:e[Oy(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(Hd),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 WY().domain(t).range(e).unknown(r)},$o.apply(a,arguments)}function qY(){var t=0,e=1,n=1,r=[.5],i=[0,1],a;function o(c){return c!=null&&c<=c?i[Oy(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 qY().domain([t,e]).range(i).unknown(a)},$o.apply(xh(o),arguments)}function KY(){var t=[.5],e=[0,1],n,r=1;function i(a){return a!=null&&a<=a?e[Oy(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 KY().domain(t).range(e).unknown(n)},$o.apply(i,arguments)}const _C=new Date,wC=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)=>(_C.setTime(+a),wC.setTime(+o),t(_C),t(wC),Math.floor(n(_C,wC))),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 vS=$i(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);vS.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):vS);vS.range;const eu=1e3,Co=eu*60,tu=Co*60,xu=tu*24,IO=xu*7,a$=xu*30,SC=xu*365,bf=$i(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*eu)},(t,e)=>(e-t)/eu,t=>t.getUTCSeconds());bf.range;const FO=$i(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*eu)},(t,e)=>{t.setTime(+t+e*Co)},(t,e)=>(e-t)/Co,t=>t.getMinutes());FO.range;const UO=$i(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*Co)},(t,e)=>(e-t)/Co,t=>t.getUTCMinutes());UO.range;const zO=$i(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*eu-t.getMinutes()*Co)},(t,e)=>{t.setTime(+t+e*tu)},(t,e)=>(e-t)/tu,t=>t.getHours());zO.range;const BO=$i(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*tu)},(t,e)=>(e-t)/tu,t=>t.getUTCHours());BO.range;const Fy=$i(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*Co)/xu,t=>t.getDate()-1);Fy.range;const FN=$i(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/xu,t=>t.getUTCDate()-1);FN.range;const XY=$i(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/xu,t=>Math.floor(t/xu));XY.range;function pm(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())*Co)/IO)}const UN=pm(0),_S=pm(1),w_e=pm(2),S_e=pm(3),Ag=pm(4),M_e=pm(5),N_e=pm(6);UN.range;_S.range;w_e.range;S_e.range;Ag.range;M_e.range;N_e.range;function gm(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)/IO)}const zN=gm(0),wS=gm(1),E_e=gm(2),A_e=gm(3),Tg=gm(4),T_e=gm(5),C_e=gm(6);zN.range;wS.range;E_e.range;A_e.range;Tg.range;T_e.range;C_e.range;const $O=$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());$O.range;const HO=$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());HO.range;const bu=$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());bu.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)});bu.range;const yu=$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());yu.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)});yu.range;function YY(t,e,n,r,i,a){const o=[[bf,1,eu],[bf,5,5*eu],[bf,15,15*eu],[bf,30,30*eu],[a,1,Co],[a,5,5*Co],[a,15,15*Co],[a,30,30*Co],[i,1,tu],[i,3,3*tu],[i,6,6*tu],[i,12,12*tu],[r,1,xu],[r,2,2*xu],[n,1,IO],[e,1,a$],[e,3,3*a$],[t,1,SC]];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=MO(([,,x])=>x).right(o,m);if(p===o.length)return t.every(l3(u/SC,d/SC,f));if(p===0)return vS.every(Math.max(l3(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[k_e,j_e]=YY(yu,HO,zN,XY,BO,UO),[P_e,R_e]=YY(bu,$O,UN,Fy,zO,FO);function MC(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 NC(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 gb(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function D_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=xb(i),d=bb(i),f=xb(a),m=bb(a),p=xb(o),b=bb(o),y=xb(l),x=bb(l),v=xb(c),S=bb(c),M={a:V,A:Q,b:re,B:J,c:null,d:d$,e:d$,f:rwe,g:fwe,G:pwe,H:ewe,I:twe,j:nwe,L:ZY,m:iwe,M:awe,p:z,q:G,Q:m$,s:p$,S:swe,u:owe,U:lwe,V:cwe,w:uwe,W:dwe,x:null,X:null,y:hwe,Y:mwe,Z:gwe,"%":f$},A={a:ne,A:ae,b:de,B:fe,c:null,d:h$,e:h$,f:vwe,g:kwe,G:Pwe,H:xwe,I:bwe,j:ywe,L:JY,m:_we,M:wwe,p:ie,q:Ae,Q:m$,s:p$,S:Swe,u:Mwe,U:Nwe,V:Ewe,w:Awe,W:Twe,x:null,X:null,y:Cwe,Y:jwe,Z:Rwe,"%":f$},T={a:D,A:U,b:L,B:q,c:P,d:c$,e:c$,f:Y_e,g:l$,G:o$,H:u$,I:u$,j:W_e,L:X_e,m:G_e,M:q_e,p:C,q:V_e,Q:Q_e,s:J_e,S:K_e,u:U_e,U:z_e,V:B_e,w:F_e,W:$_e,x:W,X:K,y:l$,Y:o$,Z:H_e,"%":Z_e};M.x=k(n,M),M.X=k(r,M),M.c=k(e,M),A.x=k(n,A),A.X=k(r,A),A.c=k(e,A);function k(me,Ne){return function(ye){var le=[],$e=-1,H=0,ee=me.length,X,B,I;for(ye instanceof Date||(ye=new Date(+ye));++$e<ee;)me.charCodeAt($e)===37&&(le.push(me.slice(H,$e)),(B=s$[X=me.charAt(++$e)])!=null?X=me.charAt(++$e):B=X==="e"?" ":"0",(I=Ne[X])&&(X=I(ye,B)),le.push(X),H=$e+1);return le.push(me.slice(H,$e)),le.join("")}}function E(me,Ne){return function(ye){var le=gb(1900,void 0,1),$e=O(le,me,ye+="",0),H,ee;if($e!=ye.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=NC(gb(le.y,0,1)),ee=H.getUTCDay(),H=ee>4||ee===0?wS.ceil(H):wS(H),H=FN.offset(H,(le.V-1)*7),le.y=H.getUTCFullYear(),le.m=H.getUTCMonth(),le.d=H.getUTCDate()+(le.w+6)%7):(H=MC(gb(le.y,0,1)),ee=H.getDay(),H=ee>4||ee===0?_S.ceil(H):_S(H),H=Fy.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),ee="Z"in le?NC(gb(le.y,0,1)).getUTCDay():MC(gb(le.y,0,1)).getDay(),le.m=0,le.d="W"in le?(le.w+6)%7+le.W*7-(ee+5)%7:le.w+le.U*7-(ee+6)%7);return"Z"in le?(le.H+=le.Z/100|0,le.M+=le.Z%100,NC(le)):MC(le)}}function O(me,Ne,ye,le){for(var $e=0,H=Ne.length,ee=ye.length,X,B;$e<H;){if(le>=ee)return-1;if(X=Ne.charCodeAt($e++),X===37){if(X=Ne.charAt($e++),B=T[X in s$?Ne.charAt($e++):X],!B||(le=B(me,ye,le))<0)return-1}else if(X!=ye.charCodeAt(le++))return-1}return le}function C(me,Ne,ye){var le=u.exec(Ne.slice(ye));return le?(me.p=d.get(le[0].toLowerCase()),ye+le[0].length):-1}function D(me,Ne,ye){var le=p.exec(Ne.slice(ye));return le?(me.w=b.get(le[0].toLowerCase()),ye+le[0].length):-1}function U(me,Ne,ye){var le=f.exec(Ne.slice(ye));return le?(me.w=m.get(le[0].toLowerCase()),ye+le[0].length):-1}function L(me,Ne,ye){var le=v.exec(Ne.slice(ye));return le?(me.m=S.get(le[0].toLowerCase()),ye+le[0].length):-1}function q(me,Ne,ye){var le=y.exec(Ne.slice(ye));return le?(me.m=x.get(le[0].toLowerCase()),ye+le[0].length):-1}function P(me,Ne,ye){return O(me,e,Ne,ye)}function W(me,Ne,ye){return O(me,n,Ne,ye)}function K(me,Ne,ye){return O(me,r,Ne,ye)}function V(me){return o[me.getDay()]}function Q(me){return a[me.getDay()]}function re(me){return c[me.getMonth()]}function J(me){return l[me.getMonth()]}function z(me){return i[+(me.getHours()>=12)]}function G(me){return 1+~~(me.getMonth()/3)}function ne(me){return o[me.getUTCDay()]}function ae(me){return a[me.getUTCDay()]}function de(me){return c[me.getUTCMonth()]}function fe(me){return l[me.getUTCMonth()]}function ie(me){return i[+(me.getUTCHours()>=12)]}function Ae(me){return 1+~~(me.getUTCMonth()/3)}return{format:function(me){var Ne=k(me+="",M);return Ne.toString=function(){return me},Ne},parse:function(me){var Ne=E(me+="",!1);return Ne.toString=function(){return me},Ne},utcFormat:function(me){var Ne=k(me+="",A);return Ne.toString=function(){return me},Ne},utcParse:function(me){var Ne=E(me+="",!0);return Ne.toString=function(){return me},Ne}}}var s$={"-":"",_:" ",0:"0"},ca=/^\s*\d+/,O_e=/^%/,L_e=/[\\^$*+?|[\]().{}]/g;function Qn(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 I_e(t){return t.replace(L_e,"\\$&")}function xb(t){return new RegExp("^(?:"+t.map(I_e).join("|")+")","i")}function bb(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function F_e(t,e,n){var r=ca.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function U_e(t,e,n){var r=ca.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function z_e(t,e,n){var r=ca.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function B_e(t,e,n){var r=ca.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function $_e(t,e,n){var r=ca.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function o$(t,e,n){var r=ca.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function l$(t,e,n){var r=ca.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function H_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 V_e(t,e,n){var r=ca.exec(e.slice(n,n+1));return r?(t.q=r[0]*3-3,n+r[0].length):-1}function G_e(t,e,n){var r=ca.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function c$(t,e,n){var r=ca.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function W_e(t,e,n){var r=ca.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function u$(t,e,n){var r=ca.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function q_e(t,e,n){var r=ca.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function K_e(t,e,n){var r=ca.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function X_e(t,e,n){var r=ca.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function Y_e(t,e,n){var r=ca.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function Z_e(t,e,n){var r=O_e.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function Q_e(t,e,n){var r=ca.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function J_e(t,e,n){var r=ca.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function d$(t,e){return Qn(t.getDate(),e,2)}function ewe(t,e){return Qn(t.getHours(),e,2)}function twe(t,e){return Qn(t.getHours()%12||12,e,2)}function nwe(t,e){return Qn(1+Fy.count(bu(t),t),e,3)}function ZY(t,e){return Qn(t.getMilliseconds(),e,3)}function rwe(t,e){return ZY(t,e)+"000"}function iwe(t,e){return Qn(t.getMonth()+1,e,2)}function awe(t,e){return Qn(t.getMinutes(),e,2)}function swe(t,e){return Qn(t.getSeconds(),e,2)}function owe(t){var e=t.getDay();return e===0?7:e}function lwe(t,e){return Qn(UN.count(bu(t)-1,t),e,2)}function QY(t){var e=t.getDay();return e>=4||e===0?Ag(t):Ag.ceil(t)}function cwe(t,e){return t=QY(t),Qn(Ag.count(bu(t),t)+(bu(t).getDay()===4),e,2)}function uwe(t){return t.getDay()}function dwe(t,e){return Qn(_S.count(bu(t)-1,t),e,2)}function hwe(t,e){return Qn(t.getFullYear()%100,e,2)}function fwe(t,e){return t=QY(t),Qn(t.getFullYear()%100,e,2)}function mwe(t,e){return Qn(t.getFullYear()%1e4,e,4)}function pwe(t,e){var n=t.getDay();return t=n>=4||n===0?Ag(t):Ag.ceil(t),Qn(t.getFullYear()%1e4,e,4)}function gwe(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+Qn(e/60|0,"0",2)+Qn(e%60,"0",2)}function h$(t,e){return Qn(t.getUTCDate(),e,2)}function xwe(t,e){return Qn(t.getUTCHours(),e,2)}function bwe(t,e){return Qn(t.getUTCHours()%12||12,e,2)}function ywe(t,e){return Qn(1+FN.count(yu(t),t),e,3)}function JY(t,e){return Qn(t.getUTCMilliseconds(),e,3)}function vwe(t,e){return JY(t,e)+"000"}function _we(t,e){return Qn(t.getUTCMonth()+1,e,2)}function wwe(t,e){return Qn(t.getUTCMinutes(),e,2)}function Swe(t,e){return Qn(t.getUTCSeconds(),e,2)}function Mwe(t){var e=t.getUTCDay();return e===0?7:e}function Nwe(t,e){return Qn(zN.count(yu(t)-1,t),e,2)}function eZ(t){var e=t.getUTCDay();return e>=4||e===0?Tg(t):Tg.ceil(t)}function Ewe(t,e){return t=eZ(t),Qn(Tg.count(yu(t),t)+(yu(t).getUTCDay()===4),e,2)}function Awe(t){return t.getUTCDay()}function Twe(t,e){return Qn(wS.count(yu(t)-1,t),e,2)}function Cwe(t,e){return Qn(t.getUTCFullYear()%100,e,2)}function kwe(t,e){return t=eZ(t),Qn(t.getUTCFullYear()%100,e,2)}function jwe(t,e){return Qn(t.getUTCFullYear()%1e4,e,4)}function Pwe(t,e){var n=t.getUTCDay();return t=n>=4||n===0?Tg(t):Tg.ceil(t),Qn(t.getUTCFullYear()%1e4,e,4)}function Rwe(){return"+0000"}function f$(){return"%"}function m$(t){return+t}function p$(t){return Math.floor(+t/1e3)}var np,tZ,nZ;Dwe({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 Dwe(t){return np=D_e(t),tZ=np.format,np.parse,nZ=np.utcFormat,np.utcParse,np}function Owe(t){return new Date(t)}function Lwe(t){return t instanceof Date?+t:+new Date(+t)}function VO(t,e,n,r,i,a,o,l,c,u){var d=kO(),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"),A=u("%Y");function T(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:A)(k)}return d.invert=function(k){return new Date(f(k))},d.domain=function(k){return arguments.length?m(Array.from(k,Lwe)):m().map(Owe)},d.ticks=function(k){var E=m();return t(E[0],E[E.length-1],k??10)},d.tickFormat=function(k,E){return E==null?T:u(E)},d.nice=function(k){var E=m();return(!k||typeof k.range!="function")&&(k=e(E[0],E[E.length-1],k??10)),k?m($Y(E,k)):d},d.copy=function(){return Iy(d,VO(t,e,n,r,i,a,o,l,c,u))},d}function Iwe(){return $o.apply(VO(P_e,R_e,bu,$O,UN,Fy,zO,FO,bf,tZ).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function Fwe(){return $o.apply(VO(k_e,j_e,yu,HO,zN,FN,BO,UO,bf,nZ).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function BN(){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(rx),u.rangeRound=d(CO),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 bh(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function rZ(){var t=xh(BN()(Qa));return t.copy=function(){return bh(t,rZ())},Cu.apply(t,arguments)}function iZ(){var t=RO(BN()).domain([1,10]);return t.copy=function(){return bh(t,iZ()).base(t.base())},Cu.apply(t,arguments)}function aZ(){var t=DO(BN());return t.copy=function(){return bh(t,aZ()).constant(t.constant())},Cu.apply(t,arguments)}function GO(){var t=OO(BN());return t.copy=function(){return bh(t,GO()).exponent(t.exponent())},Cu.apply(t,arguments)}function Uwe(){return GO.apply(null,arguments).exponent(.5)}function sZ(){var t=[],e=Qa;function n(r){if(r!=null&&!isNaN(r=+r))return e((Oy(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(Hd),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)=>Mve(t,a/r))},n.copy=function(){return sZ(e).domain(t)},Cu.apply(n,arguments)}function $N(){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=Zve(y,[v,S,M]),p):[u(0),u(.5),u(1)]}}return p.range=b(rx),p.rangeRound=b(CO),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 oZ(){var t=xh($N()(Qa));return t.copy=function(){return bh(t,oZ())},Cu.apply(t,arguments)}function lZ(){var t=RO($N()).domain([.1,1,10]);return t.copy=function(){return bh(t,lZ()).base(t.base())},Cu.apply(t,arguments)}function cZ(){var t=DO($N());return t.copy=function(){return bh(t,cZ()).constant(t.constant())},Cu.apply(t,arguments)}function WO(){var t=OO($N());return t.copy=function(){return bh(t,WO()).exponent(t.exponent())},Cu.apply(t,arguments)}function zwe(){return WO.apply(null,arguments).exponent(.5)}const $b=Object.freeze(Object.defineProperty({__proto__:null,scaleBand:EO,scaleDiverging:oZ,scaleDivergingLog:lZ,scaleDivergingPow:WO,scaleDivergingSqrt:zwe,scaleDivergingSymlog:cZ,scaleIdentity:BY,scaleImplicit:c3,scaleLinear:zY,scaleLog:HY,scaleOrdinal:NO,scalePoint:Ave,scalePow:LO,scaleQuantile:WY,scaleQuantize:qY,scaleRadial:GY,scaleSequential:rZ,scaleSequentialLog:iZ,scaleSequentialPow:GO,scaleSequentialQuantile:sZ,scaleSequentialSqrt:Uwe,scaleSequentialSymlog:aZ,scaleSqrt:v_e,scaleSymlog:VY,scaleThreshold:KY,scaleTime:Iwe,scaleUtc:Fwe,tickFormat:UY},Symbol.toStringTag,{value:"Module"}));var ku=t=>t.chartData,HN=et([ku],t=>{var e=t.chartData!=null?t.chartData.length-1:0;return{chartData:t.chartData,computedData:t.computedData,dataEndIndex:e,dataStartIndex:0}}),qO=(t,e,n,r)=>r?HN(t):ku(t),uZ=(t,e,n)=>n?HN(t):ku(t);function vu(t){if(Array.isArray(t)&&t.length===2){var[e,n]=t;if(pn(e)&&pn(n))return!0}return!1}function g$(t,e,n){return n?t:[Math.min(t[0],e[0]),Math.max(t[1],e[1])]}function dZ(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(vu(o))return o}}function Bwe(t,e,n){if(!(!n&&e==null)){if(typeof t=="function"&&e!=null)try{var r=t(e,n);if(vu(r))return g$(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(Bt(i))o=i;else if(typeof i=="function")try{e!=null&&(o=i(e?.[0]))}catch{}else if(typeof i=="string"&&E8.test(i)){var c=E8.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(Bt(a))l=a;else if(typeof a=="function")try{e!=null&&(l=a(e?.[1]))}catch{}else if(typeof a=="string"&&A8.test(a)){var d=A8.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(vu(m))return e==null?m:g$(m,e,n)}}}var ix=1e9,$we={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},XO,Br=!0,zo="[DecimalError] ",kf=zo+"Invalid argument: ",KO=zo+"Exponent out of range: ",ax=Math.floor,rf=Math.pow,Hwe=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Vs,Qi=1e7,jr=7,hZ=9007199254740991,SS=ax(hZ/jr),qt={};qt.absoluteValue=qt.abs=function(){var t=new this.constructor(this);return t.s&&(t.s=1),t};qt.comparedTo=qt.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};qt.decimalPlaces=qt.dp=function(){var t=this,e=t.d.length-1,n=(e-t.e)*jr;if(e=t.d[e],e)for(;e%10==0;e/=10)n--;return n<0?0:n};qt.dividedBy=qt.div=function(t){return ou(this,new this.constructor(t))};qt.dividedToIntegerBy=qt.idiv=function(t){var e=this,n=e.constructor;return wr(ou(e,new n(t),0,1),n.precision)};qt.equals=qt.eq=function(t){return!this.cmp(t)};qt.exponent=function(){return Ci(this)};qt.greaterThan=qt.gt=function(t){return this.cmp(t)>0};qt.greaterThanOrEqualTo=qt.gte=function(t){return this.cmp(t)>=0};qt.isInteger=qt.isint=function(){return this.e>this.d.length-2};qt.isNegative=qt.isneg=function(){return this.s<0};qt.isPositive=qt.ispos=function(){return this.s>0};qt.isZero=function(){return this.s===0};qt.lessThan=qt.lt=function(t){return this.cmp(t)<0};qt.lessThanOrEqualTo=qt.lte=function(t){return this.cmp(t)<1};qt.logarithm=qt.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(Vs))throw Error(zo+"NaN");if(n.s<1)throw Error(zo+(n.s?"NaN":"-Infinity"));return n.eq(Vs)?new r(0):(Br=!1,e=ou(K0(n,a),K0(t,a),a),Br=!0,wr(e,i))};qt.minus=qt.sub=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?pZ(e,t):fZ(e,(t.s=-t.s,t))};qt.modulo=qt.mod=function(t){var e,n=this,r=n.constructor,i=r.precision;if(t=new r(t),!t.s)throw Error(zo+"NaN");return n.s?(Br=!1,e=ou(n,t,0,1).times(t),Br=!0,n.minus(e)):wr(new r(n),i)};qt.naturalExponential=qt.exp=function(){return mZ(this)};qt.naturalLogarithm=qt.ln=function(){return K0(this)};qt.negated=qt.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};qt.plus=qt.add=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?fZ(e,t):pZ(e,(t.s=-t.s,t))};qt.precision=qt.sd=function(t){var e,n,r,i=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(kf+t);if(e=Ci(i)+1,r=i.d.length-1,n=r*jr+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};qt.squareRoot=qt.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(zo+"NaN")}for(t=Ci(l),Br=!1,i=Math.sqrt(+l),i==0||i==1/0?(e=$l(l.d),(e.length+t)%2==0&&(e+="0"),i=Math.sqrt(e),t=ax((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(ou(l,a,o+2)).times(.5),$l(a.d).slice(0,o)===(e=$l(r.d)).slice(0,o)){if(e=e.slice(o-3,o+1),i==o&&e=="4999"){if(wr(a,n+1,0),a.times(a).eq(l)){r=a;break}}else if(e!="9999")break;o+=4}return Br=!0,wr(r,n)};qt.times=qt.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,Br?wr(t,f.precision):t};qt.toDecimalPlaces=qt.todp=function(t,e){var n=this,r=n.constructor;return n=new r(n),t===void 0?n:(tc(t,0,ix),e===void 0?e=r.rounding:tc(e,0,8),wr(n,t+Ci(n)+1,e))};qt.toExponential=function(t,e){var n,r=this,i=r.constructor;return t===void 0?n=tm(r,!0):(tc(t,0,ix),e===void 0?e=i.rounding:tc(e,0,8),r=wr(new i(r),t+1,e),n=tm(r,!0,t+1)),n};qt.toFixed=function(t,e){var n,r,i=this,a=i.constructor;return t===void 0?tm(i):(tc(t,0,ix),e===void 0?e=a.rounding:tc(e,0,8),r=wr(new a(i),t+Ci(i)+1,e),n=tm(r.abs(),!1,t+Ci(r)+1),i.isneg()&&!i.isZero()?"-"+n:n)};qt.toInteger=qt.toint=function(){var t=this,e=t.constructor;return wr(new e(t),Ci(t)+1,e.rounding)};qt.toNumber=function(){return+this};qt.toPower=qt.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(Vs);if(l=new c(l),!l.s){if(t.s<1)throw Error(zo+"Infinity");return l}if(l.eq(Vs))return l;if(r=c.precision,t.eq(Vs))return wr(l,r);if(e=t.e,n=t.d.length-1,o=e>=n,a=l.s,o){if((n=d<0?-d:d)<=hZ){for(i=new c(Vs),e=Math.ceil(r/jr+4),Br=!1;n%2&&(i=i.times(l),b$(i.d,e)),n=ax(n/2),n!==0;)l=l.times(l),b$(l.d,e);return Br=!0,t.s<0?new c(Vs).div(i):wr(i,r)}}else if(a<0)throw Error(zo+"NaN");return a=a<0&&t.d[Math.max(e,n)]&1?-1:1,l.s=1,Br=!1,i=t.times(K0(l,r+u)),Br=!0,i=mZ(i),i.s=a,i};qt.toPrecision=function(t,e){var n,r,i=this,a=i.constructor;return t===void 0?(n=Ci(i),r=tm(i,n<=a.toExpNeg||n>=a.toExpPos)):(tc(t,1,ix),e===void 0?e=a.rounding:tc(e,0,8),i=wr(new a(i),t,e),n=Ci(i),r=tm(i,t<=n||n<=a.toExpNeg,t)),r};qt.toSignificantDigits=qt.tosd=function(t,e){var n=this,r=n.constructor;return t===void 0?(t=r.precision,e=r.rounding):(tc(t,1,ix),e===void 0?e=r.rounding:tc(e,0,8)),wr(new r(n),t,e)};qt.toString=qt.valueOf=qt.val=qt.toJSON=qt[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,e=Ci(t),n=t.constructor;return tm(t,e<=n.toExpNeg||e>=n.toExpPos)};function fZ(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)),Br?wr(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/jr),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,Br?wr(e,f):e}function tc(t,e,n){if(t!==~~t||t<e||t>n)throw Error(kf+t)}function $l(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=jr-r.length,n&&(a+=yd(n)),a+=r;o=t[e],r=o+"",n=jr-r.length,n&&(a+=yd(n))}else if(o===0)return"0";for(;o%10===0;)o/=10;return a+o}var ou=(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,A,T,k,E,O,C=r.constructor,D=r.s==i.s?1:-1,U=r.d,L=i.d;if(!r.s)return new C(r);if(!i.s)throw Error(zo+"Division by zero");for(c=r.e-i.e,E=L.length,T=U.length,p=new C(D),b=p.d=[],u=0;L[u]==(U[u]||0);)++u;if(L[u]>(U[u]||0)&&--c,a==null?S=a=C.precision:o?S=a+(Ci(r)-Ci(i))+1:S=a,S<0)return new C(0);if(S=S/jr+2|0,u=0,E==1)for(d=0,L=L[0],S++;(u<T||d)&&S--;u++)M=d*Qi+(U[u]||0),b[u]=M/L|0,d=M%L|0;else{for(d=Qi/(L[0]+1)|0,d>1&&(L=t(L,d),U=t(U,d),E=L.length,T=U.length),A=E,y=U.slice(0,E),x=y.length;x<E;)y[x++]=0;O=L.slice(),O.unshift(0),k=L[0],L[1]>=Qi/2&&++k;do d=0,l=e(L,y,E,x),l<0?(v=y[0],E!=x&&(v=v*Qi+(y[1]||0)),d=v/k|0,d>1?(d>=Qi&&(d=Qi-1),f=t(L,d),m=f.length,x=y.length,l=e(f,y,m,x),l==1&&(d--,n(f,E<m?O:L,m))):(d==0&&(l=d=1),f=L.slice()),m=f.length,m<x&&f.unshift(0),n(y,f,x),l==-1&&(x=y.length,l=e(L,y,E,x),l<1&&(d++,n(y,E<x?O:L,x))),x=y.length):l===0&&(d++,y=[0]),b[u++]=d,l&&y[0]?y[x++]=U[A]||0:(y=[U[A]],x=1);while((A++<T||y[0]!==void 0)&&S--)}return b[0]||b.shift(),p.e=c,wr(p,o?a+Ci(p)+1:a)}})();function mZ(t,e){var n,r,i,a,o,l,c=0,u=0,d=t.constructor,f=d.precision;if(Ci(t)>16)throw Error(KO+Ci(t));if(!t.s)return new d(Vs);for(Br=!1,l=f,o=new d(.03125);t.abs().gte(.1);)t=t.times(o),u+=5;for(r=Math.log(rf(2,u))/Math.LN10*2+5|0,l+=r,n=i=a=new d(Vs),d.precision=l;;){if(i=wr(i.times(t),l),n=n.times(++c),o=a.plus(ou(i,n,l)),$l(o.d).slice(0,l)===$l(a.d).slice(0,l)){for(;u--;)a=wr(a.times(a),l);return d.precision=f,e==null?(Br=!0,wr(a,f)):a}a=o}}function Ci(t){for(var e=t.e*jr,n=t.d[0];n>=10;n/=10)e++;return e}function EC(t,e,n){if(e>t.LN10.sd())throw Br=!0,n&&(t.precision=n),Error(zo+"LN10 precision limit exceeded");return wr(new t(t.LN10),e)}function yd(t){for(var e="";t--;)e+="0";return e}function K0(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(zo+(p.s?"NaN":"-Infinity"));if(p.eq(Vs))return new y(0);if(e==null?(Br=!1,u=x):u=e,p.eq(10))return e==null&&(Br=!0),EC(y,u);if(u+=m,y.precision=u,n=$l(b),r=n.charAt(0),a=Ci(p),Math.abs(a)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)p=p.times(t),n=$l(p.d),r=n.charAt(0),f++;a=Ci(p),r>1?(p=new y("0."+n),a++):p=new y(r+"."+n.slice(1))}else return c=EC(y,u+2,x).times(a+""),p=K0(new y(r+"."+n.slice(1)),u-m).plus(c),y.precision=x,e==null?(Br=!0,wr(p,x)):p;for(l=o=p=ou(p.minus(Vs),p.plus(Vs),u),d=wr(p.times(p),u),i=3;;){if(o=wr(o.times(d),u),c=l.plus(ou(o,new y(i),u)),$l(c.d).slice(0,u)===$l(l.d).slice(0,u))return l=l.times(2),a!==0&&(l=l.plus(EC(y,u+2,x).times(a+""))),l=ou(l,new y(f),u),y.precision=x,e==null?(Br=!0,wr(l,x)):l;l=c,i+=2}}function x$(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=ax(n/jr),t.d=[],r=(n+1)%jr,n<0&&(r+=jr),r<i){for(r&&t.d.push(+e.slice(0,r)),i-=jr;r<i;)t.d.push(+e.slice(r,r+=jr));e=e.slice(r),r=jr-e.length}else r-=i;for(;r--;)e+="0";if(t.d.push(+e),Br&&(t.e>SS||t.e<-SS))throw Error(KO+n)}else t.s=0,t.e=0,t.d=[0];return t}function wr(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+=jr,i=e,u=f[d=0];else{if(d=Math.ceil((r+1)/jr),a=f.length,d>=a)return t;for(u=a=f[d],o=1;a>=10;a/=10)o++;r%=jr,i=r-jr+o}if(n!==void 0&&(a=rf(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/rf(10,o-i):0:f[d-1])%10&1||n==(t.s<0?8:7))),e<1||!f[0])return c?(a=Ci(t),f.length=1,e=e-a-1,f[0]=rf(10,(jr-e%jr)%jr),t.e=ax(-e/jr)||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=rf(10,jr-r),f[d]=i>0?(u/rf(10,o-i)%rf(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(Br&&(t.e>SS||t.e<-SS))throw Error(KO+Ci(t));return t}function pZ(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),Br?wr(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/jr),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,Br?wr(e,p):e):new m(0)}function tm(t,e,n){var r,i=Ci(t),a=$l(t.d),o=a.length;return e?(n&&(r=n-o)>0?a=a.charAt(0)+"."+a.slice(1)+yd(r):o>1&&(a=a.charAt(0)+"."+a.slice(1)),a=a+(i<0?"e":"e+")+i):i<0?(a="0."+yd(-i-1)+a,n&&(r=n-o)>0&&(a+=yd(r))):i>=o?(a+=yd(i+1-o),n&&(r=n-i-1)>0&&(a=a+"."+yd(r))):((r=i+1)<o&&(a=a.slice(0,r)+"."+a.slice(r)),n&&(r=n-o)>0&&(i+1===o&&(a+="."),a+=yd(r))),t.s<0?"-"+a:a}function b$(t,e){if(t.length>e)return t.length=e,!0}function gZ(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(kf+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 x$(o,a.toString())}else if(typeof a!="string")throw Error(kf+a);if(a.charCodeAt(0)===45?(a=a.slice(1),o.s=-1):o.s=1,Hwe.test(a))x$(o,a);else throw Error(kf+a)}if(i.prototype=qt,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=gZ,i.config=i.set=Vwe,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 Vwe(t){if(!t||typeof t!="object")throw Error(zo+"Object expected");var e,n,r,i=["precision",1,ix,"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(ax(r)===r&&r>=i[e+1]&&r<=i[e+2])this[n]=r;else throw Error(kf+n+": "+r);if((r=t[n="LN10"])!==void 0)if(r==Math.LN10)this[n]=new this(r);else throw Error(kf+n+": "+r);return this}var XO=gZ($we);Vs=new XO(1);const lr=XO;function xZ(t){var e;return t===0?e=1:e=Math.floor(new lr(t).abs().log(10).toNumber())+1,e}function bZ(t,e,n){for(var r=new lr(t),i=0,a=[];r.lt(e)&&i<1e5;)a.push(r.toNumber()),r=r.add(n),i++;return a}var yZ=t=>{var[e,n]=t,[r,i]=[e,n];return e>n&&([r,i]=[n,e]),[r,i]},vZ=(t,e,n)=>{if(t.lte(0))return new lr(0);var r=xZ(t.toNumber()),i=new lr(10).pow(r),a=t.div(i),o=r!==1?.05:.1,l=new lr(Math.ceil(a.div(o).toNumber())).add(n).mul(o),c=l.mul(i);return e?new lr(c.toNumber()):new lr(Math.ceil(c.toNumber()))},Gwe=(t,e,n)=>{var r=new lr(1),i=new lr(t);if(!i.isint()&&n){var a=Math.abs(t);a<1?(r=new lr(10).pow(xZ(t)-1),i=new lr(Math.floor(i.div(r).toNumber())).mul(r)):a>1&&(i=new lr(Math.floor(t)))}else t===0?i=new lr(Math.floor((e-1)/2)):n||(i=new lr(Math.floor(t)));for(var o=Math.floor((e-1)/2),l=[],c=0;c<e;c++)l.push(i.add(new lr(c-o).mul(r)).toNumber());return l},_Z=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 lr(0),tickMin:new lr(0),tickMax:new lr(0)};var o=vZ(new lr(n).sub(e).div(r-1),i,a),l;e<=0&&n>=0?l=new lr(0):(l=new lr(e).add(n).div(2),l=l.sub(new lr(l).mod(o)));var c=Math.ceil(l.sub(e).div(o).toNumber()),u=Math.ceil(new lr(n).sub(l).div(o).toNumber()),d=c+u+1;return d>r?_Z(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 lr(c).mul(o)),tickMax:l.add(new lr(u).mul(o))})},Wwe=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]=yZ([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 Gwe(l,i,a);var{step:d,tickMin:f,tickMax:m}=_Z(l,c,o,a,0),p=bZ(f,m.add(new lr(.1).mul(d)),d);return n>r?p.reverse():p},qwe=function(e,n){var[r,i]=e,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,[o,l]=yZ([r,i]);if(o===-1/0||l===1/0)return[r,i];if(o===l)return[o];var c=Math.max(n,2),u=vZ(new lr(l).sub(o).div(c-1),a,0),d=[...bZ(new lr(o),new lr(l),u),l];return a===!1&&(d=d.map(f=>Math.round(f))),r>i?d.reverse():d},wZ=t=>t.rootProps.maxBarSize,Kwe=t=>t.rootProps.barGap,SZ=t=>t.rootProps.barCategoryGap,Xwe=t=>t.rootProps.barSize,Uy=t=>t.rootProps.stackOffset,MZ=t=>t.rootProps.reverseStackOrder,YO=t=>t.options.chartName,ZO=t=>t.rootProps.syncId,NZ=t=>t.rootProps.syncMethod,QO=t=>t.options.eventEmitter,Ywe=t=>t.rootProps.baseValue,li={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},Bh={allowDecimals:!1,allowDataOverflow:!1,angleAxisId:0,reversed:!1,scale:"auto",tick:!0,type:"auto"},Al={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!0,includeHidden:!1,radiusAxisId:0,reversed:!1,scale:"auto",tick:!0,tickCount:5,type:"auto"},VN=(t,e)=>{if(!(!t||!e))return t!=null&&t.reversed?[e[1],e[0]]:e};function GN(t,e,n){if(n!=="auto")return n;if(t!=null)return bl(t,e)?"category":"number"}function y$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function MS(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?y$(Object(n),!0).forEach(function(r){Zwe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):y$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Zwe(t,e,n){return(e=Qwe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Qwe(t){var e=Jwe(t,"string");return typeof e=="symbol"?e:e+""}function Jwe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var v$={allowDataOverflow:Bh.allowDataOverflow,allowDecimals:Bh.allowDecimals,allowDuplicatedCategory:!1,dataKey:void 0,domain:void 0,id:Bh.angleAxisId,includeHidden:!1,name:void 0,reversed:Bh.reversed,scale:Bh.scale,tick:Bh.tick,tickCount:void 0,ticks:void 0,type:Bh.type,unit:void 0},_$={allowDataOverflow:Al.allowDataOverflow,allowDecimals:Al.allowDecimals,allowDuplicatedCategory:Al.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:Al.radiusAxisId,includeHidden:Al.includeHidden,name:void 0,reversed:Al.reversed,scale:Al.scale,tick:Al.tick,tickCount:Al.tickCount,ticks:void 0,type:Al.type,unit:void 0},e1e=(t,e)=>{if(e!=null)return t.polarAxis.angleAxis[e]},JO=et([e1e,cY],(t,e)=>{var n;if(t!=null)return t;var r=(n=GN(e,"angleAxis",v$.type))!==null&&n!==void 0?n:"category";return MS(MS({},v$),{},{type:r})}),t1e=(t,e)=>t.polarAxis.radiusAxis[e],e4=et([t1e,cY],(t,e)=>{var n;if(t!=null)return t;var r=(n=GN(e,"radiusAxis",_$.type))!==null&&n!==void 0?n:"category";return MS(MS({},_$),{},{type:r})}),WN=t=>t.polarOptions,t4=et([Au,Tu,zi],EY),EZ=et([WN,t4],(t,e)=>{if(t!=null)return $a(t.innerRadius,e,0)}),AZ=et([WN,t4],(t,e)=>{if(t!=null)return $a(t.outerRadius,e,e*.8)}),n1e=t=>{if(t==null)return[0,0];var{startAngle:e,endAngle:n}=t;return[e,n]},TZ=et([WN],n1e);et([JO,TZ],VN);var CZ=et([t4,EZ,AZ],(t,e,n)=>{if(!(t==null||e==null||n==null))return[e,n]});et([e4,CZ],VN);var kZ=et([$n,WN,EZ,AZ,Au,Tu],(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:$a(o,i,i/2),cy:$a(l,a,a/2),innerRadius:n,outerRadius:r,startAngle:c,endAngle:u,clockWise:!1}}}),Yr=(t,e)=>e,zy=(t,e,n)=>n;function qN(t){return t?.id}function jZ(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=qN(l);u.forEach((f,m)=>{var p=a==null||i?m:String(rr(f,a,null)),b=rr(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 KN(t){return"stackId"in t&&t.stackId!=null&&t.dataKey!=null}var XN=(t,e)=>t===e?!0:t==null||e==null?!1:t[0]===e[0]&&t[1]===e[1];function YN(t,e){return Array.isArray(t)&&Array.isArray(e)&&t.length===0&&e.length===0?!0:t===e}function r1e(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 ua=t=>{var e=$n(t);return e==="horizontal"?"xAxis":e==="vertical"?"yAxis":e==="centric"?"angleAxis":"radiusAxis"},sx=t=>t.tooltip.settings.axisId;function i1e(t){if(t in $b)return $b[t]();var e="scale".concat(Ey(t));if(e in $b)return $b[e]()}function w$(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 S$(t,e,n){if(typeof t=="function")return w$(t.copy().domain(e).range(n));if(t!=null){var r=i1e(t);if(r!=null)return r.domain(e).range(n),w$(r)}}var PZ=(t,e)=>{if(e!=null)switch(t){case"linear":{if(!vu(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 M$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function NS(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?M$(Object(n),!0).forEach(function(r){a1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):M$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function a1e(t,e,n){return(e=s1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function s1e(t){var e=o1e(t,"string");return typeof e=="symbol"?e:e+""}function o1e(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 f3=[0,"auto"],Yi={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},RZ=(t,e)=>t.cartesianAxis.xAxis[e],uc=(t,e)=>{var n=RZ(t,e);return n??Yi},Zi={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:f3,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:ky},DZ=(t,e)=>t.cartesianAxis.yAxis[e],dc=(t,e)=>{var n=DZ(t,e);return n??Zi},l1e={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:""},n4=(t,e)=>{var n=t.cartesianAxis.zAxis[e];return n??l1e},ui=(t,e,n)=>{switch(e){case"xAxis":return uc(t,n);case"yAxis":return dc(t,n);case"zAxis":return n4(t,n);case"angleAxis":return JO(t,n);case"radiusAxis":return e4(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},c1e=(t,e,n)=>{switch(e){case"xAxis":return uc(t,n);case"yAxis":return dc(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},ox=(t,e,n)=>{switch(e){case"xAxis":return uc(t,n);case"yAxis":return dc(t,n);case"angleAxis":return JO(t,n);case"radiusAxis":return e4(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},OZ=t=>t.graphicalItems.cartesianItems.some(e=>e.type==="bar")||t.graphicalItems.polarItems.some(e=>e.type==="radialBar");function r4(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 By=t=>t.graphicalItems.cartesianItems,u1e=et([Yr,zy],r4),i4=(t,e,n)=>t.filter(n).filter(r=>e?.includeHidden===!0?!0:!r.hide),$y=et([By,ui,u1e],i4,{memoizeOptions:{resultEqualityCheck:YN}}),LZ=et([$y],t=>t.filter(e=>e.type==="area"||e.type==="bar").filter(KN)),IZ=t=>t.filter(e=>!("stackId"in e)||e.stackId===void 0),d1e=et([$y],IZ),a4=t=>t.map(e=>e.data).filter(Boolean).flat(1),h1e=et([$y],a4,{memoizeOptions:{resultEqualityCheck:YN}}),s4=(t,e)=>{var{chartData:n=[],dataStartIndex:r,dataEndIndex:i}=e;return t.length>0?t:n.slice(r,i+1)},o4=et([h1e,qO],s4),l4=(t,e,n)=>e?.dataKey!=null?t.map(r=>({value:rr(r,e.dataKey)})):n.length>0?n.map(r=>r.dataKey).flatMap(r=>t.map(i=>({value:rr(i,r)}))):t.map(r=>({value:r})),ZN=et([o4,ui,$y],l4);function FZ(t,e){switch(t){case"xAxis":return e.direction==="x";case"yAxis":return e.direction==="y";default:return!1}}function c1(t){if(Fo(t)||t instanceof Date){var e=Number(t);if(pn(e))return e}}function N$(t){if(Array.isArray(t)){var e=[c1(t[0]),c1(t[1])];return vu(e)?e:void 0}var n=c1(t);if(n!=null)return[n,n]}function _u(t){return t.map(c1).filter(ws)}function f1e(t,e,n){return!n||typeof e!="number"||dl(e)?[]:n.length?_u(n.flatMap(r=>{var i=rr(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=ua(t),n=sx(t);return ox(t,e,n)},Hy=et([Hi],t=>t?.dataKey),m1e=et([LZ,qO,Hi],jZ),UZ=(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(qN);return[l,{stackedData:Obe(t,d,n),graphicalItems:u}]}))},ES=et([m1e,LZ,Uy,MZ],UZ),zZ=(t,e,n,r)=>{var{dataStartIndex:i,dataEndIndex:a}=e;if(r==null&&n!=="zAxis"){var o=Ube(t,i,a);if(!(o!=null&&o[0]===0&&o[1]===0))return o}},p1e=et([ui],t=>t.allowDataOverflow),c4=t=>{var e;if(t==null||!("domain"in t))return f3;if(t.domain!=null)return t.domain;if("ticks"in t&&t.ticks!=null){if(t.type==="number"){var n=_u(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:f3},u4=et([ui],c4),d4=et([u4,p1e],dZ),g1e=et([ES,ku,Yr,d4],zZ,{memoizeOptions:{resultEqualityCheck:XN}}),QN=t=>t.errorBars,x1e=(t,e,n)=>t.flatMap(r=>e[r.id]).filter(Boolean).filter(r=>FZ(n,r)),AS=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]}},h4=(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=>FZ(i,v)),m=rr(l,(d=e.dataKey)!==null&&d!==void 0?d:c.dataKey),p=f1e(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=N$(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=N$(rr(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]},b1e=et([o4,ui,d1e,QN,Yr],h4,{memoizeOptions:{resultEqualityCheck:XN}});function y1e(t){var{value:e}=t;if(Fo(e)||e instanceof Date)return e}var v1e=(t,e,n)=>{var r=t.map(y1e).filter(i=>i!=null);return n&&(e.dataKey==null||e.allowDuplicatedCategory&&iX(r))?kY(0,t.length):e.allowDuplicatedCategory?r:Array.from(new Set(r))},BZ=t=>t.referenceElements.dots,lx=(t,e,n)=>t.filter(r=>r.ifOverflow==="extendDomain").filter(r=>e==="xAxis"?r.xAxisId===n:r.yAxisId===n),_1e=et([BZ,Yr,zy],lx),$Z=t=>t.referenceElements.areas,w1e=et([$Z,Yr,zy],lx),HZ=t=>t.referenceElements.lines,S1e=et([HZ,Yr,zy],lx),VZ=(t,e)=>{if(t!=null){var n=_u(t.map(r=>e==="xAxis"?r.x:r.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]}},M1e=et(_1e,Yr,VZ),GZ=(t,e)=>{if(t!=null){var n=_u(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)]}},N1e=et([w1e,Yr],GZ);function E1e(t){var e;if(t.x!=null)return _u([t.x]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.x);return n==null||n.length===0?[]:_u(n)}function A1e(t){var e;if(t.y!=null)return _u([t.y]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.y);return n==null||n.length===0?[]:_u(n)}var WZ=(t,e)=>{if(t!=null){var n=t.flatMap(r=>e==="xAxis"?E1e(r):A1e(r));if(n.length!==0)return[Math.min(...n),Math.max(...n)]}},T1e=et([S1e,Yr],WZ),C1e=et(M1e,T1e,N1e,(t,e,n)=>AS(t,n,e)),f4=(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?AS(r,a,i):AS(a,i);return Bwe(e,u,t.allowDataOverflow)},k1e=et([ui,u4,d4,g1e,b1e,C1e,$n,Yr],f4,{memoizeOptions:{resultEqualityCheck:XN}}),j1e=[0,1],m4=(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=bl(e,a);if(u&&l==null){var d;return kY(0,(d=n?.length)!==null&&d!==void 0?d:0)}return c==="category"?v1e(r,t,u):i==="expand"?j1e:o}},p4=et([ui,$n,o4,ZN,Uy,Yr,k1e],m4);function P1e(t){return t in $b}var qZ=(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(Ey(r));return P1e(a)?a:"point"}}},yh=et([ui,OZ,YO],qZ);function g4(t,e,n,r){if(!(n==null||r==null))return typeof t.scale=="function"?S$(t.scale,n,r):S$(e,n,r)}var x4=(t,e,n)=>{var r=c4(e);if(!(n!=="auto"&&n!=="linear")){if(e!=null&&e.tickCount&&Array.isArray(r)&&(r[0]==="auto"||r[1]==="auto")&&vu(t))return Wwe(t,e.tickCount,e.allowDecimals);if(e!=null&&e.tickCount&&e.type==="number"&&vu(t))return qwe(t,e.tickCount,e.allowDecimals)}},b4=et([p4,ox,yh],x4),y4=(t,e,n,r)=>{if(r!=="angleAxis"&&t?.type==="number"&&vu(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},R1e=et([ui,p4,b4,Yr],y4),D1e=et(ZN,ui,(t,e)=>{if(!(!e||e.type!=="number")){var n=1/0,r=Array.from(_u(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}}),KZ=et(D1e,$n,SZ,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=$a(n,t*a),l=t*a/2;return l-o-(l-o)/a*o}return 0}),O1e=(t,e,n)=>{var r=uc(t,e);return r==null||typeof r.padding!="string"?0:KZ(t,"xAxis",e,n,r.padding)},L1e=(t,e,n)=>{var r=dc(t,e);return r==null||typeof r.padding!="string"?0:KZ(t,"yAxis",e,n,r.padding)},I1e=et(uc,O1e,(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}}),F1e=et(dc,L1e,(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}}),U1e=et([zi,I1e,RN,PN,(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]}),z1e=et([zi,$n,F1e,RN,PN,(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]}),Vy=(t,e,n,r)=>{var i;switch(e){case"xAxis":return U1e(t,n,r);case"yAxis":return z1e(t,n,r);case"zAxis":return(i=n4(t,n))===null||i===void 0?void 0:i.range;case"angleAxis":return TZ(t);case"radiusAxis":return CZ(t,n);default:return}},XZ=et([ui,Vy],VN),B1e=et([yh,R1e],PZ),Cg=et([ui,yh,B1e,XZ],g4);et([$y,QN,Yr],x1e);function YZ(t,e){return t.id<e.id?-1:t.id>e.id?1:0}var JN=(t,e)=>e,eE=(t,e,n)=>n,$1e=et(kN,JN,eE,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(YZ)),H1e=et(jN,JN,eE,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(YZ)),ZZ=(t,e)=>({width:t.width,height:e.height}),V1e=(t,e)=>{var n=typeof e.width=="number"?e.width:ky;return{width:n,height:t.height}},QZ=et(zi,uc,ZZ),G1e=(t,e,n)=>{switch(e){case"top":return t.top;case"bottom":return n-t.bottom;default:return 0}},W1e=(t,e,n)=>{switch(e){case"left":return t.left;case"right":return n-t.right;default:return 0}},q1e=et(Tu,zi,$1e,JN,eE,(t,e,n,r,i)=>{var a={},o;return n.forEach(l=>{var c=ZZ(e,l);o==null&&(o=G1e(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}),K1e=et(Au,zi,H1e,JN,eE,(t,e,n,r,i)=>{var a={},o;return n.forEach(l=>{var c=V1e(e,l);o==null&&(o=W1e(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}),X1e=(t,e)=>{var n=uc(t,e);if(n!=null)return q1e(t,n.orientation,n.mirror)},Y1e=et([zi,uc,X1e,(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}}}),Z1e=(t,e)=>{var n=dc(t,e);if(n!=null)return K1e(t,n.orientation,n.mirror)},Q1e=et([zi,dc,Z1e,(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}}}),JZ=et(zi,dc,(t,e)=>{var n=typeof e.width=="number"?e.width:ky;return{width:n,height:t.height}}),E$=(t,e,n)=>{switch(e){case"xAxis":return QZ(t,n).width;case"yAxis":return JZ(t,n).height;default:return}},eQ=(t,e,n,r)=>{if(n!=null){var{allowDuplicatedCategory:i,type:a,dataKey:o}=n,l=bl(t,r),c=e.map(u=>u.value);if(o&&l&&a==="category"&&i&&iX(c))return c}},v4=et([$n,ZN,ui,Yr],eQ),tQ=(t,e,n,r)=>{if(!(n==null||n.dataKey==null)){var{type:i,scale:a}=n,o=bl(t,r);if(o&&(i==="number"||a!=="auto"))return e.map(l=>l.value)}},_4=et([$n,ZN,ox,Yr],tQ),A$=et([$n,c1e,yh,Cg,v4,_4,Vy,b4,Yr],(t,e,n,r,i,a,o,l,c)=>{if(e!=null){var u=bl(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}}}),J1e=(t,e,n,r,i,a,o,l,c)=>{if(!(e==null||r==null)){var u=bl(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?ta(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(ws):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(ws):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(ws):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(ws)}},nQ=et([$n,ox,yh,Cg,b4,Vy,v4,_4,Yr],J1e),eSe=(t,e,n,r,i,a,o)=>{if(!(e==null||n==null||r==null||r[0]===r[1])){var l=bl(t,o),{tickCount:c}=e,u=0;return u=o==="angleAxis"&&r?.length>=2?ta(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(ws):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(ws):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(ws)}},nc=et([$n,ox,Cg,Vy,v4,_4,Yr],eSe),rc=et(ui,Cg,(t,e)=>{if(!(t==null||e==null))return NS(NS({},t),{},{scale:e})}),tSe=et([ui,yh,p4,XZ],g4);et((t,e,n)=>n4(t,n),tSe,(t,e)=>{if(!(t==null||e==null))return NS(NS({},t),{},{scale:e})});var nSe=et([$n,kN,jN],(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}}),rQ=t=>t.options.defaultTooltipEventType,iQ=t=>t.options.validateTooltipEventTypes;function aQ(t,e,n){if(t==null)return e;var r=t?"axis":"item";return n==null?e:n.includes(r)?r:e}function w4(t,e){var n=rQ(t),r=iQ(t);return aQ(e,n,r)}function rSe(t){return Wt(e=>w4(e,t))}var sQ=(t,e)=>{var n,r=Number(e);if(!(dl(r)||e==null))return r>=0?t==null||(n=t[r])===null||n===void 0?void 0:n.value:void 0},iSe=t=>t.tooltip.settings,Ad={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},aSe={itemInteraction:{click:Ad,hover:Ad},axisInteraction:{click:Ad,hover:Ad},keyboardInteraction:Ad,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}},oQ=Ts({name:"tooltip",initialState:aSe,reducers:{addTooltipEntrySettings:{reducer(t,e){t.tooltipItemPayloads.push(e.payload)},prepare:Fr()},replaceTooltipEntrySettings:{reducer(t,e){var{prev:n,next:r}=e.payload,i=ol(t).tooltipItemPayloads.indexOf(n);i>-1&&(t.tooltipItemPayloads[i]=r)},prepare:Fr()},removeTooltipEntrySettings:{reducer(t,e){var n=ol(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:sSe,replaceTooltipEntrySettings:oSe,removeTooltipEntrySettings:lSe,setTooltipSettingsState:cSe,setActiveMouseOverItemIndex:lQ,mouseLeaveItem:uSe,mouseLeaveChart:cQ,setActiveClickItemIndex:dSe,setMouseOverAxisIndex:uQ,setMouseClickAxisIndex:hSe,setSyncInteraction:m3,setKeyboardInteraction:p3}=oQ.actions,fSe=oQ.reducer;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 R_(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){mSe(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 mSe(t,e,n){return(e=pSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function pSe(t){var e=gSe(t,"string");return typeof e=="symbol"?e:e+""}function gSe(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 xSe(t,e,n){return e==="axis"?n==="click"?t.axisInteraction.click:t.axisInteraction.hover:n==="click"?t.itemInteraction.click:t.itemInteraction.hover}function bSe(t){return t.index!=null}var dQ=(t,e,n,r)=>{if(e==null)return Ad;var i=xSe(t,e,n);if(i==null)return Ad;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(bSe(i)){if(a)return R_(R_({},i),{},{active:!0})}else if(r!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:r,graphicalItemId:void 0};return R_(R_({},Ad),{},{coordinate:i.coordinate})};function ySe(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 vSe(t,e){var n=ySe(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 _Se(t,e,n){if(n==null||e==null)return!0;var r=rr(t,e);return r==null||!vu(n)?!0:vSe(r,n)}var S4=(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||_Se(u,n,r)?String(c):null},hQ=(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}}},fQ=(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})},mQ=t=>t.options.tooltipPayloadSearcher,cx=t=>t.tooltip;function C$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function k$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?C$(Object(n),!0).forEach(function(r){wSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):C$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function wSe(t,e,n){return(e=SSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function SSe(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 NSe(t,e){return t??e}var pQ=(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=NSe(y,l),S=Array.isArray(v)?QX(v,u,d):v,M=(b=x?.dataKey)!==null&&b!==void 0?b:r,A=x?.nameKey,T;if(r&&Array.isArray(S)&&!Array.isArray(S[0])&&o==="axis"?T=aX(S,r,i):T=a(S,e,c,A),Array.isArray(T))T.forEach(E=>{var O=k$(k$({},x),{},{name:E.name,unit:E.unit,color:void 0,fill:void 0});m.push(T8({tooltipEntrySettings:O,dataKey:E.dataKey,payload:E.payload,value:rr(E.payload,E.dataKey),name:E.name}))});else{var k;m.push(T8({tooltipEntrySettings:x,dataKey:M,payload:T,value:rr(T,M),name:(k=rr(T,A))!==null&&k!==void 0?k:x?.name}))}return m},f)}},M4=et([Hi,OZ,YO],qZ),ESe=et([t=>t.graphicalItems.cartesianItems,t=>t.graphicalItems.polarItems],(t,e)=>[...t,...e]),ASe=et([ua,sx],r4),ux=et([ESe,Hi,ASe],i4,{memoizeOptions:{resultEqualityCheck:YN}}),TSe=et([ux],t=>t.filter(KN)),CSe=et([ux],a4,{memoizeOptions:{resultEqualityCheck:YN}}),dx=et([CSe,ku],s4),kSe=et([TSe,ku,Hi],jZ),N4=et([dx,Hi,ux],l4),gQ=et([Hi],c4),jSe=et([Hi],t=>t.allowDataOverflow),xQ=et([gQ,jSe],dZ),PSe=et([ux],t=>t.filter(KN)),RSe=et([kSe,PSe,Uy,MZ],UZ),DSe=et([RSe,ku,ua,xQ],zZ),OSe=et([ux],IZ),LSe=et([dx,Hi,OSe,QN,ua],h4,{memoizeOptions:{resultEqualityCheck:XN}}),ISe=et([BZ,ua,sx],lx),FSe=et([ISe,ua],VZ),USe=et([$Z,ua,sx],lx),zSe=et([USe,ua],GZ),BSe=et([HZ,ua,sx],lx),$Se=et([BSe,ua],WZ),HSe=et([FSe,$Se,zSe],AS),VSe=et([Hi,gQ,xQ,DSe,LSe,HSe,$n,ua],f4),Gy=et([Hi,$n,dx,N4,Uy,ua,VSe],m4),GSe=et([Gy,Hi,M4],x4),WSe=et([Hi,Gy,GSe,ua],y4),bQ=t=>{var e=ua(t),n=sx(t),r=!1;return Vy(t,e,n,r)},yQ=et([Hi,bQ],VN),vQ=et([Hi,M4,WSe,yQ],g4),qSe=et([$n,N4,Hi,ua],eQ),KSe=et([$n,N4,Hi,ua],tQ),XSe=(t,e,n,r,i,a,o,l)=>{if(e){var{type:c}=e,u=bl(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?ta(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(ws):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(ws)}}},ju=et([$n,Hi,M4,vQ,bQ,qSe,KSe,ua],XSe),E4=et([rQ,iQ,iSe],(t,e,n)=>aQ(n.shared,t,e)),_Q=t=>t.tooltip.settings.trigger,A4=t=>t.tooltip.settings.defaultIndex,Wy=et([cx,E4,_Q,A4],dQ),nh=et([Wy,dx,Hy,Gy],S4),wQ=et([ju,nh],sQ),T4=et([Wy],t=>{if(t)return t.dataKey}),YSe=et([Wy],t=>{if(t)return t.graphicalItemId}),SQ=et([cx,E4,_Q,A4],fQ),ZSe=et([Au,Tu,$n,zi,ju,A4,SQ],hQ),QSe=et([Wy,ZSe],(t,e)=>t!=null&&t.coordinate?t.coordinate:e),JSe=et([Wy],t=>{var e;return(e=t?.active)!==null&&e!==void 0?e:!1}),eMe=et([SQ,nh,ku,Hy,wQ,mQ,E4],pQ),tMe=et([eMe],t=>{if(t!=null){var e=t.map(n=>n.payload).filter(n=>n!=null);return Array.from(new Set(e))}});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){nMe(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 nMe(t,e,n){return(e=rMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function rMe(t){var e=iMe(t,"string");return typeof e=="symbol"?e:e+""}function iMe(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 aMe=()=>Wt(Hi),sMe=()=>{var t=aMe(),e=Wt(ju),n=Wt(vQ);return th(!t||!n?void 0:P$(P$({},t),{},{scale:n}),e)};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 rp(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){oMe(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 oMe(t,e,n){return(e=lMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function lMe(t){var e=cMe(t,"string");return typeof e=="symbol"?e:e+""}function cMe(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 uMe=(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}},dMe=(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 rp(rp(rp({},r),Ai(r.cx,r.cy,o,a)),{},{angle:a,radius:o})}var l=i.coordinate,{angle:c}=r;return rp(rp(rp({},r),Ai(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 hMe(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 MQ=(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(ta(b-p)!==ta(y-b)){var v=[];if(ta(y-b)===ta(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 A=[Math.min(b,(x+b)/2),Math.max(b,(x+b)/2)];if(t>A[0]&&t<=A[1]||t>=v[0]&&t<=v[1]){var T;return(T=n[l])===null||T===void 0?void 0:T.index}}else{var k=Math.min(p,y),E=Math.max(p,y);if(t>(k+b)/2&&t<=(E+b)/2){var O;return(O=n[l])===null||O===void 0?void 0:O.index}}}else if(e)for(var C=0;C<o;C++){var D=e[C];if(D!=null){var U=e[C+1],L=e[C-1];if(C===0&&U!=null&&t<=(D.coordinate+U.coordinate)/2||C===o-1&&L!=null&&t>(D.coordinate+L.coordinate)/2||C>0&&C<o-1&&L!=null&&U!=null&&t>(D.coordinate+L.coordinate)/2&&t<=(D.coordinate+U.coordinate)/2)return D.index}}return-1},NQ=()=>Wt(YO),C4=(t,e)=>e,EQ=(t,e,n)=>n,k4=(t,e,n,r)=>r,fMe=et(ju,t=>vN(t,e=>e.coordinate)),j4=et([cx,C4,EQ,k4],dQ),P4=et([j4,dx,Hy,Gy],S4),mMe=(t,e,n)=>{if(e!=null){var r=cx(t);return e==="axis"?n==="hover"?r.axisInteraction.hover.dataKey:r.axisInteraction.click.dataKey:n==="hover"?r.itemInteraction.hover.dataKey:r.itemInteraction.click.dataKey}},AQ=et([cx,C4,EQ,k4],fQ),TS=et([Au,Tu,$n,zi,ju,k4,AQ],hQ),pMe=et([j4,TS],(t,e)=>{var n;return(n=t.coordinate)!==null&&n!==void 0?n:e}),TQ=et([ju,P4],sQ),gMe=et([AQ,P4,ku,Hy,TQ,mQ,C4],pQ),xMe=et([j4,P4],(t,e)=>({isActive:t.active&&e!=null,activeIndex:e})),bMe=(t,e,n,r,i,a,o)=>{if(!(!t||!n||!r||!i)&&hMe(t,o)){var l=zbe(t,e),c=MQ(l,a,i,n,r),u=uMe(e,i,c,t);return{activeIndex:String(c),activeCoordinate:u}}},yMe=(t,e,n,r,i,a,o)=>{if(!(!t||!r||!i||!a||!n)){var l=rve(t,n);if(l){var c=Bbe(l,e),u=MQ(c,o,a,r,i),d=dMe(e,a,u,l);return{activeIndex:String(u),activeCoordinate:d}}}},vMe=(t,e,n,r,i,a,o,l)=>{if(!(!t||!e||!r||!i||!a))return e==="horizontal"||e==="vertical"?bMe(t,e,r,i,a,o,l):yMe(t,e,n,r,i,a,o)},_Me=et(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}}),wMe=et(t=>t.zIndex.zIndexMap,t=>{var e=Object.keys(t).map(r=>parseInt(r,10)).concat(Object.values(li)),n=Array.from(new Set(e));return n.sort((r,i)=>r-i)},{memoizeOptions:{resultEqualityCheck:r1e}});function D$(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 O$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?D$(Object(n),!0).forEach(function(r){SMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):D$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function SMe(t,e,n){return(e=MMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function MMe(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 EMe={},AMe={zIndexMap:Object.values(li).reduce((t,e)=>O$(O$({},t),{},{[e]:{element:void 0,panoramaElement:void 0,consumers:0}}),EMe)},TMe=new Set(Object.values(li));function CMe(t){return TMe.has(t)}var CQ=Ts({name:"zIndex",initialState:AMe,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&&!CMe(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:kMe,unregisterZIndexPortal:jMe,registerZIndexPortalElement:PMe,unregisterZIndexPortalElement:RMe}=CQ.actions,DMe=CQ.reducer;function Ha(t){var{zIndex:e,children:n}=t,r=b0e(),i=r&&e!==void 0&&e!==0,a=Bi(),o=Sr();w.useLayoutEffect(()=>i?(o(kMe({zIndex:e})),()=>{o(jMe({zIndex:e}))}):mh,[o,e,i]);var l=Wt(c=>_Me(c,e,a));return i?l?Jc.createPortal(n,l):null:n}function g3(){return g3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},g3.apply(null,arguments)}function L$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function D_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?L$(Object(n),!0).forEach(function(r){OMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):L$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function OMe(t,e,n){return(e=LMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function LMe(t){var e=IMe(t,"string");return typeof e=="symbol"?e:e+""}function IMe(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 FMe(t){var{cursor:e,cursorComp:n,cursorProps:r}=t;return w.isValidElement(e)?w.cloneElement(e,r):w.createElement(n,r)}function UMe(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=xye,x=li.cursorLine;else if(d==="BarChart")b=bye(l,f,a,o),y=NY,x=li.cursorRectangle;else if(l==="radial"&&oX(f)){var{cx:v,cy:S,radius:M,startAngle:A,endAngle:T}=AY(f);b={cx:v,cy:S,startAngle:A,endAngle:T,innerRadius:M,outerRadius:M},y=CY,x=li.cursorLine}else b={points:ove(l,f,a)},y=og,x=li.cursorLine;var k=typeof c=="object"&&"className"in c?c.className:void 0,E=D_(D_(D_(D_({stroke:"#ccc",pointerEvents:"none"},a),b),Kf(c)),{},{payload:m,payloadIndex:p,className:Vn("recharts-tooltip-cursor",k)});return w.createElement(Ha,{zIndex:(e=t.zIndex)!==null&&e!==void 0?e:x},w.createElement(FMe,{cursor:c,cursorComp:y,cursorProps:E}))}function zMe(t){var e=sMe(),n=lY(),r=gh(),i=NQ();return e==null||n==null||r==null||i==null?null:w.createElement(UMe,g3({},t,{offset:n,layout:r,tooltipAxisBandSize:e,chartName:i}))}var kQ=w.createContext(null),BMe=()=>w.useContext(kQ),AC={exports:{}},I$;function $Me(){return I$||(I$=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 A=x.length,T;for(M=0;M<A;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(T=1,S=new Array(v-1);T<v;T++)S[T-1]=arguments[T];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})(AC)),AC.exports}var HMe=$Me();const VMe=pl(HMe);var X0=new VMe,x3="recharts.syncEvent.tooltip",F$="recharts.syncEvent.brush",tE=(t,e)=>{if(e&&Array.isArray(t)){var n=Number.parseInt(e,10);if(!dl(n))return t[n]}},GMe={chartName:"",tooltipPayloadSearcher:()=>{},eventEmitter:void 0,defaultTooltipEventType:"axis"},jQ=Ts({name:"options",initialState:GMe,reducers:{createEventEmitter:t=>{t.eventEmitter==null&&(t.eventEmitter=Symbol("rechartsEventEmitter"))}}}),WMe=jQ.reducer,{createEventEmitter:qMe}=jQ.actions;function KMe(t){return t.tooltip.syncInteraction}var XMe={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},PQ=Ts({name:"chartData",initialState:XMe,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:U$,setDataStartEndIndexes:YMe,setComputedData:nQe}=PQ.actions,ZMe=PQ.reducer,QMe=["x","y"];function z$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ip(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?z$(Object(n),!0).forEach(function(r){JMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):z$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function JMe(t,e,n){return(e=eNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function eNe(t){var e=tNe(t,"string");return typeof e=="symbol"?e:e+""}function tNe(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 nNe(t,e){if(t==null)return{};var n,r,i=rNe(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 rNe(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 iNe(){var t=Wt(ZO),e=Wt(QO),n=Sr(),r=Wt(NZ),i=Wt(ju),a=gh(),o=jy(),l=Wt(c=>c.rootProps.className);w.useEffect(()=>{if(t==null)return mh;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=nNe(p,QMe),{x:v,y:S,width:M,height:A}=d.payload.sourceViewBox,T=ip(ip({},x),{},{x:o.x+(M?(b-v)/M:0)*o.width,y:o.y+(A?(y-S)/A:0)*o.height});n(ip(ip({},d),{},{payload:ip(ip({},d.payload),{},{coordinate:T})}))}else n(d);return}if(i!=null){var k;if(typeof r=="function"){var E={activeTooltipIndex:d.payload.index==null?void 0:Number(d.payload.index),isTooltipActive:d.payload.active,activeIndex:d.payload.index==null?void 0:Number(d.payload.index),activeLabel:d.payload.label,activeDataKey:d.payload.dataKey,activeCoordinate:d.payload.coordinate},O=r(i,E);k=i[O]}else r==="value"&&(k=i.find(K=>String(K.value)===d.payload.label));var{coordinate:C}=d.payload;if(k==null||d.payload.active===!1||C==null||o==null){n(m3({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}var{x:D,y:U}=C,L=Math.min(D,o.x+o.width),q=Math.min(U,o.y+o.height),P={x:a==="horizontal"?k.coordinate:L,y:a==="horizontal"?q:k.coordinate},W=m3({active:d.payload.active,coordinate:P,dataKey:d.payload.dataKey,index:String(k.index),label:d.payload.label,sourceViewBox:d.payload.sourceViewBox,graphicalItemId:d.payload.graphicalItemId});n(W)}}};return X0.on(x3,c),()=>{X0.off(x3,c)}},[l,n,e,t,r,i,a,o])}function aNe(){var t=Wt(ZO),e=Wt(QO),n=Sr();w.useEffect(()=>{if(t==null)return mh;var r=(i,a,o)=>{e!==o&&t===i&&n(YMe(a))};return X0.on(F$,r),()=>{X0.off(F$,r)}},[n,e,t])}function sNe(){var t=Sr();w.useEffect(()=>{t(qMe())},[t]),iNe(),aNe()}function oNe(t,e,n,r,i,a){var o=Wt(p=>mMe(p,t,e)),l=Wt(QO),c=Wt(ZO),u=Wt(NZ),d=Wt(KMe),f=d?.active,m=jy();w.useEffect(()=>{if(!f&&c!=null&&l!=null){var p=m3({active:a,coordinate:n,dataKey:o,index:i,label:typeof r=="number"?String(r):r,sourceViewBox:m,graphicalItemId:void 0});X0.emit(x3,c,p,l)}},[f,n,o,i,r,l,c,u,a,m])}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 $$(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){lNe(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 lNe(t,e,n){return(e=cNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function cNe(t){var e=uNe(t,"string");return typeof e=="symbol"?e:e+""}function uNe(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 dNe(t){return t.dataKey}function hNe(t,e){return w.isValidElement(t)?w.cloneElement(t,e):typeof t=="function"?w.createElement(t,e):w.createElement(Y0e,e)}var H$=[],fNe={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 u1(t){var e,n,r=Xr(t,fNe),{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:A,portal:T,axisId:k}=r,E=Sr(),O=typeof A=="number"?String(A):A;w.useEffect(()=>{E(cSe({shared:S,trigger:M,axisId:k,active:i,defaultIndex:O}))},[E,S,M,k,i,O]);var C=jy(),D=vY(),U=rSe(S),{activeIndex:L,isActive:q}=(e=Wt(ie=>xMe(ie,U,M,O)))!==null&&e!==void 0?e:{},P=Wt(ie=>gMe(ie,U,M,O)),W=Wt(ie=>TQ(ie,U,M,O)),K=Wt(ie=>pMe(ie,U,M,O)),V=P,Q=BMe(),re=(n=i??q)!==null&&n!==void 0?n:!1,[J,z]=wX([V,re]),G=U==="axis"?W:void 0;oNe(U,M,K,G,L,re);var ne=T??Q;if(ne==null||C==null||U==null)return null;var ae=V??H$;re||(ae=H$),u&&ae.length&&(ae=gX(ae.filter(ie=>ie.value!=null&&(ie.hide!==!0||r.includeHidden)),m,dNe));var de=ae.length>0,fe=w.createElement(rye,{allowEscapeViewBox:a,animationDuration:o,animationEasing:l,isAnimationActive:d,active:re,coordinate:K,hasPayload:de,offset:f,position:p,reverseDirection:b,useTranslate3d:y,viewBox:C,wrapperStyle:x,lastBoundingBox:J,innerRef:z,hasPortalFromProps:!!T},hNe(c,$$($$({},r),{},{payload:ae,label:G,active:re,activeIndex:L,coordinate:K,accessibilityLayer:D})));return w.createElement(w.Fragment,null,Jc.createPortal(fe,ne),re&&w.createElement(zMe,{cursor:v,tooltipEventType:U,coordinate:K,payload:ae,index:L}))}var qy=t=>null;qy.displayName="Cell";function mNe(t,e,n){return(e=pNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function pNe(t){var e=gNe(t,"string");return typeof e=="symbol"?e:e+""}function gNe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}class xNe{constructor(e){mNe(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 V$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function bNe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?V$(Object(n),!0).forEach(function(r){yNe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):V$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function yNe(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=_Ne(t,"string");return typeof e=="symbol"?e:e+""}function _Ne(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={cacheSize:2e3,enableCache:!0},RQ=bNe({},wNe),G$=new xNe(RQ.cacheSize),SNe={position:"absolute",top:"-20000px",left:0,padding:0,margin:0,border:"none",whiteSpace:"pre"},W$="recharts_measurement_span";function MNe(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 q$=(t,e)=>{try{var n=document.getElementById(W$);n||(n=document.createElement("span"),n.setAttribute("id",W$),n.setAttribute("aria-hidden","true"),document.body.appendChild(n)),Object.assign(n.style,SNe,e),n.textContent="".concat(t);var r=n.getBoundingClientRect();return{width:r.width,height:r.height}}catch{return{width:0,height:0}}},s0=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null||Dy.isSsr)return{width:0,height:0};if(!RQ.enableCache)return q$(e,n);var r=MNe(e,n),i=G$.get(r);if(i)return i;var a=q$(e,n);return G$.set(r,a),a},DQ;function NNe(t,e,n){return(e=ENe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ENe(t){var e=ANe(t,"string");return typeof e=="symbol"?e:e+""}function ANe(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 K$=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,X$=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,TNe=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,CNe=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,kNe={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},jNe=["cm","mm","pt","pc","in","Q","px"];function PNe(t){return jNe.includes(t)}var Qp="NaN";function RNe(t,e){return t*kNe[e]}class va{static parse(e){var n,[,r,i]=(n=CNe.exec(e))!==null&&n!==void 0?n:[];return r==null?va.NaN:new va(parseFloat(r),i??"")}constructor(e,n){this.num=e,this.unit=n,this.num=e,this.unit=n,dl(e)&&(this.unit=""),n!==""&&!TNe.test(n)&&(this.num=NaN,this.unit=""),PNe(n)&&(this.num=RNe(e,n),this.unit="px")}add(e){return this.unit!==e.unit?new va(NaN,""):new va(this.num+e.num,this.unit)}subtract(e){return this.unit!==e.unit?new va(NaN,""):new va(this.num-e.num,this.unit)}multiply(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new va(NaN,""):new va(this.num*e.num,this.unit||e.unit)}divide(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new va(NaN,""):new va(this.num/e.num,this.unit||e.unit)}toString(){return"".concat(this.num).concat(this.unit)}isNaN(){return dl(this.num)}}DQ=va;NNe(va,"NaN",new DQ(NaN,""));function OQ(t){if(t==null||t.includes(Qp))return Qp;for(var e=t;e.includes("*")||e.includes("/");){var n,[,r,i,a]=(n=K$.exec(e))!==null&&n!==void 0?n:[],o=va.parse(r??""),l=va.parse(a??""),c=i==="*"?o.multiply(l):o.divide(l);if(c.isNaN())return Qp;e=e.replace(K$,c.toString())}for(;e.includes("+")||/.-\d+(?:\.\d+)?/.test(e);){var u,[,d,f,m]=(u=X$.exec(e))!==null&&u!==void 0?u:[],p=va.parse(d??""),b=va.parse(m??""),y=f==="+"?p.add(b):p.subtract(b);if(y.isNaN())return Qp;e=e.replace(X$,y.toString())}return e}var Y$=/\(([^()]*)\)/;function DNe(t){for(var e=t,n;(n=Y$.exec(e))!=null;){var[,r]=n;e=e.replace(Y$,OQ(r))}return e}function ONe(t){var e=t.replace(/\s+/g,"");return e=DNe(e),e=OQ(e),e}function LNe(t){try{return ONe(t)}catch{return Qp}}function TC(t){var e=LNe(t.slice(5,-1));return e===Qp?"":e}var INe=["x","y","lineHeight","capHeight","fill","scaleToFit","textAnchor","verticalAnchor"],FNe=["dx","dy","angle","className","breakAll"];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 Z$(t,e){if(t==null)return{};var n,r,i=UNe(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 UNe(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 LQ=/[ \f\n\r\t\v\u2028\u2029]+/,IQ=t=>{var{children:e,breakAll:n,style:r}=t;try{var i=[];Vr(e)||(n?i=e.toString().split(""):i=e.toString().split(LQ));var a=i.map(l=>({word:l,width:s0(l,r).width})),o=n?0:s0(" ",r).width;return{wordsWithComputedWidth:a,spaceWidth:o}}catch{return null}};function zNe(t){return t==="start"||t==="middle"||t==="end"||t==="inherit"}var FQ=(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},[]),UQ=t=>t.reduce((e,n)=>e.width>n.width?e:n),BNe="…",Q$=(t,e,n,r,i,a,o,l)=>{var c=t.slice(0,e),u=IQ({breakAll:n,style:r,children:c+BNe});if(!u)return[!1,[]];var d=FQ(u.wordsWithComputedWidth,a,o,l),f=d.length>i||UQ(d).width>Number(a);return[f,d]},$Ne=(t,e,n,r,i)=>{var{maxLines:a,children:o,style:l,breakAll:c}=t,u=Bt(a),d=String(o),f=FQ(e,r,n,i);if(!u||i)return f;var m=f.length>a||UQ(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,A]=Q$(d,S,c,l,a,r,n,i),[T]=Q$(d,v,c,l,a,r,n,i);if(!M&&!T&&(p=v+1),M&&T&&(b=v-1),!M&&T){x=A;break}y++}return x||f},J$=t=>{var e=Vr(t)?[]:t.toString().split(LQ);return[{words:e,width:void 0}]},HNe=t=>{var{width:e,scaleToFit:n,children:r,style:i,breakAll:a,maxLines:o}=t;if((e||n)&&!Dy.isSsr){var l,c,u=IQ({breakAll:a,children:r,style:i});if(u){var{wordsWithComputedWidth:d,spaceWidth:f}=u;l=d,c=f}else return J$(r);return $Ne({breakAll:a,children:r,maxLines:o,style:i},l,c,e,!!n)}return J$(r)},zQ="#808080",VNe={angle:0,breakAll:!1,capHeight:"0.71em",fill:zQ,lineHeight:"1em",scaleToFit:!1,textAnchor:"start",verticalAnchor:"end",x:0,y:0},nE=w.forwardRef((t,e)=>{var n=Xr(t,VNe),{x:r,y:i,lineHeight:a,capHeight:o,fill:l,scaleToFit:c,textAnchor:u,verticalAnchor:d}=n,f=Z$(n,INe),m=w.useMemo(()=>HNe({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=Z$(f,FNe);if(!Fo(r)||!Fo(i)||m.length===0)return null;var M=Number(r)+(Bt(p)?p:0),A=Number(i)+(Bt(b)?b:0);if(!pn(M)||!pn(A))return null;var T;switch(d){case"start":T=TC("calc(".concat(o,")"));break;case"middle":T=TC("calc(".concat((m.length-1)/2," * -").concat(a," + (").concat(o," / 2))"));break;default:T=TC("calc(".concat(m.length-1," * -").concat(a,")"));break}var k=[],E=m[0];if(c&&E!=null){var O=E.width,{width:C}=f;k.push("scale(".concat(Bt(C)&&Bt(O)?C/O:1,")"))}return y&&k.push("rotate(".concat(y,", ").concat(M,", ").concat(A,")")),k.length&&(S.transform=k.join(" ")),w.createElement("text",b3({},Ca(S),{ref:e,x:M,y:A,className:Vn("recharts-text",x),textAnchor:u,fill:l.includes("url")?zQ:l}),m.map((D,U)=>{var L=D.words.join(v?"":" ");return w.createElement("tspan",{x:M,dy:U===0?T:a,key:"".concat(L,"-").concat(U)},L)}))});nE.displayName="Text";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 Tl(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){GNe(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 GNe(t,e,n){return(e=WNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function WNe(t){var e=qNe(t,"string");return typeof e=="symbol"?e:e+""}function qNe(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 KNe=t=>{var{viewBox:e,position:n,offset:r=0,parentViewBox:i}=t,{x:a,y:o,height:l,upperWidth:c,lowerWidth:u}=xO(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,A=M*r,T=M>0?"end":"start",k=M>0?"start":"end",E=i;if(n==="top"){var O={x:d+c/2,y:o-x,horizontalAnchor:"middle",verticalAnchor:v};return E&&(O.height=Math.max(o-E.y,0),O.width=c),O}if(n==="bottom"){var C={x:f+u/2,y:o+l+x,horizontalAnchor:"middle",verticalAnchor:S};return E&&(C.height=Math.max(E.y+E.height-(o+l),0),C.width=u),C}if(n==="left"){var D={x:m-A,y:o+l/2,horizontalAnchor:T,verticalAnchor:"middle"};return E&&(D.width=Math.max(D.x-E.x,0),D.height=l),D}if(n==="right"){var U={x:m+p+A,y:o+l/2,horizontalAnchor:k,verticalAnchor:"middle"};return E&&(U.width=Math.max(E.x+E.width-U.x,0),U.height=l),U}var L=E?{width:p,height:l}:{};return n==="insideLeft"?Tl({x:m+A,y:o+l/2,horizontalAnchor:k,verticalAnchor:"middle"},L):n==="insideRight"?Tl({x:m+p-A,y:o+l/2,horizontalAnchor:T,verticalAnchor:"middle"},L):n==="insideTop"?Tl({x:d+c/2,y:o+x,horizontalAnchor:"middle",verticalAnchor:S},L):n==="insideBottom"?Tl({x:f+u/2,y:o+l-x,horizontalAnchor:"middle",verticalAnchor:v},L):n==="insideTopLeft"?Tl({x:d+A,y:o+x,horizontalAnchor:k,verticalAnchor:S},L):n==="insideTopRight"?Tl({x:d+c-A,y:o+x,horizontalAnchor:T,verticalAnchor:S},L):n==="insideBottomLeft"?Tl({x:f+A,y:o+l-x,horizontalAnchor:k,verticalAnchor:v},L):n==="insideBottomRight"?Tl({x:f+u-A,y:o+l-x,horizontalAnchor:T,verticalAnchor:v},L):n&&typeof n=="object"&&(Bt(n.x)||Zf(n.x))&&(Bt(n.y)||Zf(n.y))?Tl({x:a+$a(n.x,p),y:o+$a(n.y,l),horizontalAnchor:"end",verticalAnchor:"end"},L):Tl({x:b,y:o+l/2,horizontalAnchor:"middle",verticalAnchor:"middle"},L)},XNe=["labelRef"],YNe=["content"];function tH(t,e){if(t==null)return{};var n,r,i=ZNe(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 ZNe(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 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 Hb(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?nH(Object(n),!0).forEach(function(r){QNe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):nH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function QNe(t,e,n){return(e=JNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function JNe(t){var e=eEe(t,"string");return typeof e=="symbol"?e:e+""}function eEe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Yc(){return Yc=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},Yc.apply(null,arguments)}var BQ=w.createContext(null),$Q=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(BQ.Provider,{value:c},l)},HQ=()=>{var t=w.useContext(BQ),e=jy();return t||(e?xO(e):void 0)},tEe=w.createContext(null),nEe=()=>{var t=w.useContext(tEe),e=Wt(kZ);return t||e},rEe=t=>{var{value:e,formatter:n}=t,r=Vr(t.children)?e:t.children;return typeof n=="function"?n(r):r},R4=t=>t!=null&&typeof t=="function",iEe=(t,e)=>{var n=ta(e-t),r=Math.min(Math.abs(e-t),360);return n*r},aEe=(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=iEe(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=Ai(l,c,b,v),A=Ai(l,c,b,v+(S?1:-1)*359),T="M".concat(M.x,",").concat(M.y,`
- A`).concat(b,",").concat(b,",0,1,").concat(S?0:1,`,
- `).concat(A.x,",").concat(A.y),k=Vr(t.id)?L0("recharts-radial-line-"):t.id;return w.createElement("text",Yc({},r,{dominantBaseline:"central",className:Vn("recharts-radial-bar-label",o)}),w.createElement("defs",null,w.createElement("path",{id:k,d:T})),w.createElement("textPath",{xlinkHref:"#".concat(k)},n))},sEe=(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}=Ai(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}=Ai(r,i,m,u);return{x:p,y:b,textAnchor:"middle",verticalAnchor:"middle"}},d1=t=>t!=null&&"cx"in t&&Bt(t.cx),oEe={angle:0,offset:5,zIndex:li.label,position:"middle",textBreakAll:!1};function lEe(t){if(!d1(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 vd(t){var e=Xr(t,oEe),{viewBox:n,parentViewBox:r,position:i,value:a,children:o,content:l,className:c="",textBreakAll:u,labelRef:d}=e,f=nEe(),m=HQ(),p=i==="center"?m:f??m,b,y,x;n==null?b=p:d1(n)?b=n:b=xO(n);var v=lEe(b);if(!b||Vr(a)&&Vr(o)&&!w.isValidElement(l)&&typeof l!="function")return null;var S=Hb(Hb({},e),{},{viewBox:b});if(w.isValidElement(l)){var{labelRef:M}=S,A=tH(S,XNe);return w.cloneElement(l,A)}if(typeof l=="function"){var{content:T}=S,k=tH(S,YNe);if(y=w.createElement(l,k),w.isValidElement(y))return y}else y=rEe(e);var E=Ca(e);if(d1(b)){if(i==="insideStart"||i==="insideEnd"||i==="end")return aEe(e,i,y,E,b);x=sEe(b,e.offset,e.position)}else{if(!v)return null;var O=KNe({viewBox:v,position:i,offset:e.offset,parentViewBox:d1(r)?void 0:r});x=Hb(Hb({x:O.x,y:O.y,textAnchor:O.horizontalAnchor,verticalAnchor:O.verticalAnchor},O.width!==void 0?{width:O.width}:{}),O.height!==void 0?{height:O.height}:{})}return w.createElement(Ha,{zIndex:e.zIndex},w.createElement(nE,Yc({ref:d,className:Vn("recharts-label",c)},E,x,{textAnchor:zNe(E.textAnchor)?E.textAnchor:x.textAnchor,breakAll:u}),y))}vd.displayName="Label";var cEe=(t,e,n)=>{if(!t)return null;var r={viewBox:e,labelRef:n};return t===!0?w.createElement(vd,Yc({key:"label-implicit"},r)):Fo(t)?w.createElement(vd,Yc({key:"label-implicit",value:t},r)):w.isValidElement(t)?t.type===vd?w.cloneElement(t,Hb({key:"label-implicit"},r)):w.createElement(vd,Yc({key:"label-implicit",content:t},r)):R4(t)?w.createElement(vd,Yc({key:"label-implicit",content:t},r)):t&&typeof t=="object"?w.createElement(vd,Yc({},t,{key:"label-implicit"},r)):null};function VQ(t){var{label:e,labelRef:n}=t,r=HQ();return cEe(e,r,n)||null}var CC={},kC={},rH;function uEe(){return rH||(rH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n[n.length-1]}t.last=e})(kC)),kC}var jC={},iH;function dEe(){return iH||(iH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Array.isArray(n)?n:Array.from(n)}t.toArray=e})(jC)),jC}var aH;function hEe(){return aH||(aH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=uEe(),n=dEe(),r=sO();function i(a){if(r.isArrayLike(a))return e.last(n.toArray(a))}t.last=i})(CC)),CC}var PC,sH;function fEe(){return sH||(sH=1,PC=hEe().last),PC}var mEe=fEe();const pEe=pl(mEe);var gEe=["valueAccessor"],xEe=["dataKey","clockWise","id","textBreakAll","zIndex"];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 oH(t,e){if(t==null)return{};var n,r,i=bEe(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 bEe(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 yEe=t=>Array.isArray(t.value)?pEe(t.value):t.value,GQ=w.createContext(void 0),D4=GQ.Provider,WQ=w.createContext(void 0),vEe=WQ.Provider;function _Ee(){return w.useContext(GQ)}function wEe(){return w.useContext(WQ)}function h1(t){var{valueAccessor:e=yEe}=t,n=oH(t,gEe),{dataKey:r,clockWise:i,id:a,textBreakAll:o,zIndex:l}=n,c=oH(n,xEe),u=_Ee(),d=wEe(),f=u||d;return!f||!f.length?null:w.createElement(Ha,{zIndex:l??li.label},w.createElement(Kr,{className:"recharts-label-list"},f.map((m,p)=>{var b,y=Vr(r)?e(m,p):rr(m.payload,r),x=Vr(a)?{}:{id:"".concat(a,"-").concat(p)};return w.createElement(vd,CS({key:"label-".concat(p)},Ca(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}))})))}h1.displayName="LabelList";function rE(t){var{label:e}=t;return e?e===!0?w.createElement(h1,{key:"labelList-implicit"}):w.isValidElement(e)||R4(e)?w.createElement(h1,{key:"labelList-implicit",content:e}):typeof e=="object"?w.createElement(h1,CS({key:"labelList-implicit"},e,{type:String(e.type)})):null:null}function y3(){return y3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},y3.apply(null,arguments)}var qQ=t=>{var{cx:e,cy:n,r,className:i}=t,a=Vn("recharts-dot",i);return Bt(e)&&Bt(n)&&Bt(r)?w.createElement("circle",y3({},rs(t),aO(t),{className:a,cx:e,cy:n,r})):null},KQ=t=>t.graphicalItems.polarItems,SEe=et([Yr,zy],r4),iE=et([KQ,ui,SEe],i4),MEe=et([iE],a4),aE=et([MEe,HN],s4),NEe=et([aE,ui,iE],l4);et([aE,ui,iE],(t,e,n)=>n.length>0?t.flatMap(r=>n.flatMap(i=>{var a,o=rr(r,(a=e.dataKey)!==null&&a!==void 0?a:i.dataKey);return{value:o,errorDomain:[]}})).filter(Boolean):e?.dataKey!=null?t.map(r=>({value:rr(r,e.dataKey),errorDomain:[]})):t.map(r=>({value:r,errorDomain:[]})));var lH=()=>{},EEe=et([aE,ui,iE,QN,Yr],h4),AEe=et([ui,u4,d4,lH,EEe,lH,$n,Yr],f4),XQ=et([ui,$n,aE,NEe,Uy,Yr,AEe],m4),TEe=et([XQ,ox,yh],x4),CEe=et([ui,XQ,TEe,Yr],y4);et([yh,CEe],PZ);var kEe={radiusAxis:{},angleAxis:{}},YQ=Ts({name:"polarAxis",initialState:kEe,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:rQe,removeRadiusAxis:iQe,addAngleAxis:aQe,removeAngleAxis:sQe}=YQ.actions,jEe=YQ.reducer;function ZQ(t){return t&&typeof t=="object"&&"className"in t&&typeof t.className=="string"?t.className:""}function cH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function uH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?cH(Object(n),!0).forEach(function(r){PEe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):cH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function PEe(t,e,n){return(e=REe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function REe(t){var e=DEe(t,"string");return typeof e=="symbol"?e:e+""}function DEe(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 OEe=(t,e)=>e,O4=et([KQ,OEe],(t,e)=>t.filter(n=>n.type==="pie").find(n=>n.id===e)),LEe=[],L4=(t,e,n)=>n?.length===0?LEe:n,QQ=et([HN,O4,L4],(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=>uH(uH({},e.presentationProps),a.props))),i!=null)return i}}),IEe=et([QQ,O4,L4],(t,e,n)=>{if(!(t==null||e==null))return t.map((r,i)=>{var a,o=rr(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:ph(o,e.dataKey),color:l,payload:r,type:e.legendType}})}),FEe=et([QQ,O4,L4,zi],(t,e,n,r)=>{if(!(e==null||t==null))return U2e({offset:r,pieSettings:e,displayedData:t,cells:n})}),RC={exports:{}},hr={};var dH;function UEe(){if(dH)return hr;dH=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 hr.ContextConsumer=a,hr.ContextProvider=o,hr.Element=t,hr.ForwardRef=l,hr.Fragment=n,hr.Lazy=f,hr.Memo=d,hr.Portal=e,hr.Profiler=i,hr.StrictMode=r,hr.Suspense=c,hr.SuspenseList=u,hr.isContextConsumer=function(y){return b(y)===a},hr.isContextProvider=function(y){return b(y)===o},hr.isElement=function(y){return typeof y=="object"&&y!==null&&y.$$typeof===t},hr.isForwardRef=function(y){return b(y)===l},hr.isFragment=function(y){return b(y)===n},hr.isLazy=function(y){return b(y)===f},hr.isMemo=function(y){return b(y)===d},hr.isPortal=function(y){return b(y)===e},hr.isProfiler=function(y){return b(y)===i},hr.isStrictMode=function(y){return b(y)===r},hr.isSuspense=function(y){return b(y)===c},hr.isSuspenseList=function(y){return b(y)===u},hr.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)},hr.typeOf=b,hr}var hH;function zEe(){return hH||(hH=1,RC.exports=UEe()),RC.exports}var BEe=zEe(),fH=t=>typeof t=="string"?t:t?t.displayName||t.name||"Component":"",mH=null,DC=null,JQ=t=>{if(t===mH&&Array.isArray(DC))return DC;var e=[];return w.Children.forEach(t,n=>{Vr(n)||(BEe.isFragment(n)?e=e.concat(JQ(n.props.children)):e.push(n))}),DC=e,mH=t,e};function I4(t,e){var n=[],r=[];return Array.isArray(e)?r=e.map(i=>fH(i)):r=[fH(e)],JQ(t).forEach(i=>{var a=Yf(i,"type.displayName")||Yf(i,"type.name");a&&r.indexOf(a)!==-1&&n.push(i)}),n}var F4=t=>t&&typeof t=="object"&&"clipDot"in t?!!t.clipDot:!0,OC={},pH;function $Ee(){return pH||(pH=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})(OC)),OC}var LC,gH;function HEe(){return gH||(gH=1,LC=$Ee().isPlainObject),LC}var VEe=HEe();const GEe=pl(VEe);var xH,bH,yH,vH,_H;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 SH(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){WEe(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 WEe(t,e,n){return(e=qEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function qEe(t){var e=KEe(t,"string");return typeof e=="symbol"?e:e+""}function KEe(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)}function yb(t,e){return e||(e=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}var MH=(t,e,n,r,i)=>{var a=n-r,o;return o=ri(xH||(xH=yb(["M ",",",""])),t,e),o+=ri(bH||(bH=yb(["L ",",",""])),t+n,e),o+=ri(yH||(yH=yb(["L ",",",""])),t+n-a/2,e+i),o+=ri(vH||(vH=yb(["L ",",",""])),t+n-a/2-r,e+i),o+=ri(_H||(_H=yb(["L ",","," Z"])),t,e),o},XEe={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},YEe=t=>{var e=Xr(t,XEe),{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),A=nx(t,"trapezoid-");if(w.useEffect(()=>{if(m.current&&m.current.getTotalLength)try{var P=m.current.getTotalLength();P&&b(P)}catch{}},[]),n!==+n||r!==+r||i!==+i||a!==+a||o!==+o||i===0&&a===0||o===0)return null;var T=Vn("recharts-trapezoid",l);if(!f)return w.createElement("g",null,w.createElement("path",kS({},Ca(e),{className:T,d:MH(n,r,i,a,o)})));var k=y.current,E=x.current,O=v.current,C=S.current,D=M.current,U="0px ".concat(p===-1?1:p,"px"),L="".concat(p,"px 0px"),q=_Y(["strokeDasharray"],u,c);return w.createElement(tx,{animationId:A,key:A,canBegin:p>0,duration:u,easing:c,isActive:f,begin:d},P=>{var W=tr(k,i,P),K=tr(E,a,P),V=tr(O,o,P),Q=tr(C,n,P),re=tr(D,r,P);m.current&&(y.current=W,x.current=K,v.current=V,S.current=Q,M.current=re);var J=P>0?{transition:q,strokeDasharray:L}:{strokeDasharray:U};return w.createElement("path",kS({},Ca(e),{className:T,d:MH(Q,re,W,K,V),ref:m,style:SH(SH({},J),e.style)}))})},ZEe=["option","shapeType","activeClassName"];function QEe(t,e){if(t==null)return{};var n,r,i=JEe(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 JEe(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 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 jS(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){e2e(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 e2e(t,e,n){return(e=t2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function t2e(t){var e=n2e(t,"string");return typeof e=="symbol"?e:e+""}function n2e(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 r2e(t,e){return jS(jS({},e),t)}function i2e(t,e){return t==="symbols"}function EH(t){var{shapeType:e,elementProps:n}=t;switch(e){case"rectangle":return w.createElement(NY,n);case"trapezoid":return w.createElement(YEe,n);case"sector":return w.createElement(CY,n);case"symbols":if(i2e(e))return w.createElement(iO,n);break;case"curve":return w.createElement(og,n);default:return null}}function a2e(t){return w.isValidElement(t)?t.props:t}function U4(t){var{option:e,shapeType:n,activeClassName:r="recharts-active-shape"}=t,i=QEe(t,ZEe),a;if(w.isValidElement(e))a=w.cloneElement(e,jS(jS({},i),a2e(e)));else if(typeof e=="function")a=e(i,i.index);else if(GEe(e)&&typeof e!="boolean"){var o=r2e(e,i);a=w.createElement(EH,{shapeType:n,elementProps:o})}else{var l=i;a=w.createElement(EH,{shapeType:n,elementProps:l})}return i.isActive?w.createElement(Kr,{className:r},a):a}var z4=(t,e,n)=>{var r=Sr();return(i,a)=>o=>{t?.(i,a,o),r(lQ({activeIndex:String(a),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}},B4=t=>{var e=Sr();return(n,r)=>i=>{t?.(n,r,i),e(uSe())}},$4=(t,e,n)=>{var r=Sr();return(i,a)=>o=>{t?.(i,a,o),r(dSe({activeIndex:String(a),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function sE(t){var{tooltipEntrySettings:e}=t,n=Sr(),r=Bi(),i=w.useRef(null);return w.useLayoutEffect(()=>{r||(i.current===null?n(sSe(e)):i.current!==e&&n(oSe({prev:i.current,next:e})),i.current=e)},[e,n,r]),w.useLayoutEffect(()=>()=>{i.current&&(n(lSe(i.current)),i.current=null)},[n]),null}function H4(t){var{legendPayload:e}=t,n=Sr(),r=Bi(),i=w.useRef(null);return w.useLayoutEffect(()=>{r||(i.current===null?n(xY(e)):i.current!==e&&n(bY({prev:i.current,next:e})),i.current=e)},[n,r,e]),w.useLayoutEffect(()=>()=>{i.current&&(n(yY(i.current)),i.current=null)},[n]),null}function s2e(t){var{legendPayload:e}=t,n=Sr(),r=Wt($n),i=w.useRef(null);return w.useLayoutEffect(()=>{r!=="centric"&&r!=="radial"||(i.current===null?n(xY(e)):i.current!==e&&n(bY({prev:i.current,next:e})),i.current=e)},[n,r,e]),w.useLayoutEffect(()=>()=>{i.current&&(n(yY(i.current)),i.current=null)},[n]),null}var IC,o2e=()=>{var[t]=w.useState(()=>L0("uid-"));return t},l2e=(IC=roe.useId)!==null&&IC!==void 0?IC:o2e;function c2e(t,e){var n=l2e();return e||(t?"".concat(t,"-").concat(n):n)}var u2e=w.createContext(void 0),oE=t=>{var{id:e,type:n,children:r}=t,i=c2e("recharts-".concat(n),e);return w.createElement(u2e.Provider,{value:i},r(i))},d2e={cartesianItems:[],polarItems:[]},eJ=Ts({name:"graphicalItems",initialState:d2e,reducers:{addCartesianGraphicalItem:{reducer(t,e){t.cartesianItems.push(e.payload)},prepare:Fr()},replaceCartesianGraphicalItem:{reducer(t,e){var{prev:n,next:r}=e.payload,i=ol(t).cartesianItems.indexOf(n);i>-1&&(t.cartesianItems[i]=r)},prepare:Fr()},removeCartesianGraphicalItem:{reducer(t,e){var n=ol(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=ol(t).polarItems.indexOf(e.payload);n>-1&&t.polarItems.splice(n,1)},prepare:Fr()}}}),{addCartesianGraphicalItem:h2e,replaceCartesianGraphicalItem:f2e,removeCartesianGraphicalItem:m2e,addPolarGraphicalItem:p2e,removePolarGraphicalItem:g2e}=eJ.actions,x2e=eJ.reducer,b2e=t=>{var e=Sr(),n=w.useRef(null);return w.useLayoutEffect(()=>{n.current===null?e(h2e(t)):n.current!==t&&e(f2e({prev:n.current,next:t})),n.current=t},[e,t]),w.useLayoutEffect(()=>()=>{n.current&&(e(m2e(n.current)),n.current=null)},[e]),null},V4=w.memo(b2e);function y2e(t){var e=Sr();return w.useLayoutEffect(()=>(e(p2e(t)),()=>{e(g2e(t))}),[e,t]),null}var v2e=["key"],_2e=["onMouseEnter","onClick","onMouseLeave"],w2e=["id"],S2e=["id"];function AH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ii(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?AH(Object(n),!0).forEach(function(r){M2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):AH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function M2e(t,e,n){return(e=N2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function N2e(t){var e=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 rh(){return rh=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},rh.apply(null,arguments)}function lE(t,e){if(t==null)return{};var n,r,i=A2e(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 A2e(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function T2e(t){var e=w.useMemo(()=>I4(t.children,qy),[t.children]),n=Wt(r=>IEe(r,t.id,e));return n==null?null:w.createElement(s2e,{legendPayload:n})}var C2e=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:ph(l,e),hide:c,type:u,color:o,unit:"",graphicalItemId:d}};return w.createElement(sE,{tooltipEntrySettings:f})}),k2e=(t,e)=>t>e?"start":t<e?"end":"middle",j2e=(t,e,n)=>$a(typeof e=="function"?e(t):e,n,n*.8),P2e=(t,e,n)=>{var{top:r,left:i,width:a,height:o}=e,l=EY(a,o),c=i+$a(t.cx,a,a/2),u=r+$a(t.cy,o,o/2),d=$a(t.innerRadius,l,0),f=j2e(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}},R2e=(t,e)=>{var n=ta(e-t),r=Math.min(Math.abs(e-t),360);return n*r},D2e=(t,e)=>{if(w.isValidElement(t))return w.cloneElement(t,e);if(typeof t=="function")return t(e);var n=Vn("recharts-pie-label-line",typeof t!="boolean"?t.className:""),{key:r}=e,i=lE(e,v2e);return w.createElement(og,rh({},i,{type:"linear",className:n}))},O2e=(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=Vn("recharts-pie-label-text",ZQ(t));return w.createElement(nE,rh({},e,{alignmentBaseline:"middle",className:i}),r)};function L2e(t){var{sectors:e,props:n,showLabels:r}=t,{label:i,labelLine:a,dataKey:o}=n;if(!r||!i||!e)return null;var l=rs(n),c=Kf(i),u=Kf(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=Ai(m.cx,m.cy,m.outerRadius+d,b),x=ii(ii(ii(ii({},l),m),{},{stroke:"none"},c),{},{index:p,textAnchor:k2e(y.x,m.cx)},y),v=ii(ii(ii(ii({},l),m),{},{fill:"none",stroke:m.fill},u),{},{index:p,points:[Ai(m.cx,m.cy,m.outerRadius,b),y],key:"line"});return w.createElement(Ha,{zIndex:li.label,key:"label-".concat(m.startAngle,"-").concat(m.endAngle,"-").concat(m.midAngle,"-").concat(p)},w.createElement(Kr,null,a&&D2e(a,v),O2e(i,x,rr(m,o))))});return w.createElement(Kr,{className:"recharts-pie-labels"},f)}function I2e(t){var{sectors:e,props:n,showLabels:r}=t,{label:i}=n;return typeof i=="object"&&i!=null&&"position"in i?w.createElement(rE,{label:i}):w.createElement(L2e,{sectors:e,props:n,showLabels:r})}function F2e(t){var{sectors:e,activeShape:n,inactiveShape:r,allOtherPieProps:i,shape:a,id:o}=t,l=Wt(nh),c=Wt(T4),u=Wt(YSe),{onMouseEnter:d,onClick:f,onMouseLeave:m}=i,p=lE(i,_2e),b=z4(d,i.dataKey,o),y=B4(m),x=$4(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,A=String(S)===l&&(c==null||i.dataKey===c)&&M,T=l?r:null,k=n&&A?n:T,E=ii(ii({},v),{},{stroke:v.stroke,tabIndex:-1,[rY]:S,[iY]:o});return w.createElement(Kr,rh({key:"sector-".concat(v?.startAngle,"-").concat(v?.endAngle,"-").concat(v.midAngle,"-").concat(S),tabIndex:-1,className:"recharts-pie-sector"},Ay(p,v,S),{onMouseEnter:b(v,S),onMouseLeave:y(v,S),onClick:x(v,S)}),w.createElement(U4,rh({option:a??k,index:S,shapeType:"sector",isActive:A},E)))}))}function U2e(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=R2e(l,c),b=Math.abs(p),y=r.length<=1?0:(e=n.paddingAngle)!==null&&e!==void 0?e:0,x=r.filter(k=>rr(k,u,0)!==0).length,v=(b>=360?x:x-1)*y,S=b-x*m-v,M=r.reduce((k,E)=>{var O=rr(E,u,0);return k+(Bt(O)?O:0)},0),A;if(M>0){var T;A=r.map((k,E)=>{var O=rr(k,u,0),C=rr(k,d,E),D=P2e(n,a,k),U=(Bt(O)?O:0)/M,L,q=ii(ii({},k),i&&i[E]&&i[E].props);E?L=T.endAngle+ta(p)*y*(O!==0?1:0):L=l;var P=L+ta(p)*((O!==0?m:0)+U*S),W=(L+P)/2,K=(D.innerRadius+D.outerRadius)/2,V=[{name:C,value:O,payload:q,dataKey:u,type:f,graphicalItemId:n.id}],Q=Ai(D.cx,D.cy,K,W);return T=ii(ii(ii(ii({},n.presentationProps),{},{percent:U,cornerRadius:typeof o=="string"?parseFloat(o):o,name:C,tooltipPayload:V,midAngle:W,middleRadius:K,tooltipPosition:Q},q),D),{},{value:O,dataKey:u,startAngle:L,endAngle:P,payload:q,paddingAngle:ta(p)*y}),T})}return A}function z2e(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(vEe,{value:e?i:void 0},r)}function B2e(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=nx(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(z2e,{showLabels:!y,sectors:i},w.createElement(tx,{animationId:p,begin:o,duration:l,isActive:a,easing:c,onAnimationStart:S,onAnimationEnd:v,key:p},M=>{var A,T=[],k=i&&i[0],E=(A=k?.startAngle)!==null&&A!==void 0?A:0;return i?.forEach((O,C)=>{var D=b&&b[C],U=C>0?Yf(O,"paddingAngle",0):0;if(D){var L=tr(D.endAngle-D.startAngle,O.endAngle-O.startAngle,M),q=ii(ii({},O),{},{startAngle:E+U,endAngle:E+L+U});T.push(q),E=q.endAngle}else{var{endAngle:P,startAngle:W}=O,K=tr(0,P-W,M),V=ii(ii({},O),{},{startAngle:E+U,endAngle:E+K+U});T.push(V),E=V.endAngle}}),n.current=T,w.createElement(Kr,null,w.createElement(F2e,{sectors:T,activeShape:u,inactiveShape:d,allOtherPieProps:e,shape:e.shape,id:r}))}),w.createElement(I2e,{showLabels:!y,sectors:i,props:e}),e.children)}var $2e={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:li.area};function H2e(t){var{id:e}=t,n=lE(t,w2e),{hide:r,className:i,rootTabIndex:a}=t,o=w.useMemo(()=>I4(t.children,qy),[t.children]),l=Wt(d=>FEe(d,e,o)),c=w.useRef(null),u=Vn("recharts-pie",i);return r||l==null?(c.current=null,w.createElement(Kr,{tabIndex:a,className:u})):w.createElement(Ha,{zIndex:t.zIndex},w.createElement(C2e,{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(Kr,{tabIndex:a,className:u},w.createElement(B2e,{props:ii(ii({},n),{},{sectors:l}),previousSectorsRef:c,id:e})))}function tJ(t){var e=Xr(t,$2e),{id:n}=e,r=lE(e,S2e),i=rs(r);return w.createElement(oE,{id:n,type:"pie"},a=>w.createElement(w.Fragment,null,w.createElement(y2e,{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(T2e,rh({},r,{id:a})),w.createElement(H2e,rh({},r,{id:a}))))}tJ.displayName="Pie";var V2e=["points"];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 FC(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){G2e(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 G2e(t,e,n){return(e=W2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function W2e(t){var e=q2e(t,"string");return typeof e=="symbol"?e:e+""}function q2e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function PS(){return PS=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},PS.apply(null,arguments)}function K2e(t,e){if(t==null)return{};var n,r,i=X2e(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 X2e(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 Y2e(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=Vn(r,typeof e!="boolean"?e.className:""),a=n??{},{points:o}=a,l=K2e(a,V2e);return w.createElement(qQ,PS({},l,{className:i}))}function Z2e(t,e){return t==null?!1:e?!0:t.length===1}function nJ(t){var{points:e,dot:n,className:r,dotClassName:i,dataKey:a,baseProps:o,needClip:l,clipPathId:c,zIndex:u=li.scatter}=t;if(!Z2e(e,n))return null;var d=F4(n),f=ype(n),m=e.map((b,y)=>{var x,v,S=FC(FC(FC({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(Y2e,{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(Ha,{zIndex:u},w.createElement(Kr,PS({className:r},p),m))}function CH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function kH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?CH(Object(n),!0).forEach(function(r){Q2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):CH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Q2e(t,e,n){return(e=J2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function J2e(t){var e=eAe(t,"string");return typeof e=="symbol"?e:e+""}function eAe(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 rJ=0,tAe={xAxis:{},yAxis:{},zAxis:{}},iJ=Ts({name:"cartesianAxis",initialState:tAe,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]=kH(kH({},i),{},{width:r,widthHistory:l})}}}}),{addXAxis:nAe,replaceXAxis:rAe,removeXAxis:iAe,addYAxis:aAe,replaceYAxis:sAe,removeYAxis:oAe,addZAxis:oQe,replaceZAxis:lQe,removeZAxis:cQe,updateYAxisWidth:lAe}=iJ.actions,cAe=iJ.reducer,uAe=et([zi],t=>({top:t.top,bottom:t.bottom,left:t.left,right:t.right})),dAe=et([uAe,Au,Tu],(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)}}),cE=()=>Wt(dAe),hAe=()=>Wt(tMe);function jH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function UC(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?jH(Object(n),!0).forEach(function(r){fAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):jH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function fAe(t,e,n){return(e=mAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function mAe(t){var e=pAe(t,"string");return typeof e=="symbol"?e:e+""}function pAe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var gAe=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=UC(UC(UC({},l),Kf(i)),aO(i)),u;return w.isValidElement(i)?u=w.cloneElement(i,c):typeof i=="function"?u=i(c):u=w.createElement(qQ,c),w.createElement(Kr,{className:"recharts-active-dot",clipPath:o},u)};function v3(t){var{points:e,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:o=li.activeDot}=t,l=Wt(nh),c=hAe();if(e==null||c==null)return null;var u=e.find(d=>c.includes(d.payload));return Vr(u)?null:w.createElement(Ha,{zIndex:o},w.createElement(gAe,{point:u,childIndex:Number(l),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var PH=(t,e,n)=>{var r=n??t;if(!Vr(r))return $a(r,e,0)},xAe=(t,e,n)=>{var r={},i=t.filter(KN),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=PH(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=PH(e,n,u.barSize);return{stackId:void 0,dataKeys:d,barSize:f}});return[...l,...c]};function RH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function O_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?RH(Object(n),!0).forEach(function(r){bAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):RH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function bAe(t,e,n){return(e=yAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function yAe(t){var e=vAe(t,"string");return typeof e=="symbol"?e:e+""}function vAe(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 _Ae(t,e,n,r,i){var a,o=r.length;if(!(o<1)){var l=$a(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 A,T={stackId:M.stackId,dataKeys:M.dataKeys,position:{offset:b.offset+b.size+l,size:d?f:(A=M.barSize)!==null&&A!==void 0?A:0}},k=[...S,T];return b=T.position,k},u)}else{var y=$a(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,A)=>[...S,{stackId:M.stackId,dataKeys:M.dataKeys,position:{offset:y+(x+l)*A+(x-v)/2,size:v}}],u)}return c}}var wAe=(t,e,n,r,i,a,o)=>{var l=Vr(o)?e:o,c=_Ae(n,r,i!==a?i:a,t,l);return i!==a&&c!=null&&(c=c.map(u=>O_(O_({},u),{},{position:O_(O_({},u.position),{},{offset:u.position.offset-i/2})}))),c},SAe=(t,e)=>{var n=qN(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)}}}},MAe=(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 NAe(t,e){return t&&typeof t=="object"&&"zIndex"in t&&typeof t.zIndex=="number"&&pn(t.zIndex)?t.zIndex:e}var aJ=t=>{var{chartData:e}=t,n=Sr(),r=Bi();return w.useEffect(()=>r?()=>{}:(n(U$(e)),()=>{n(U$(void 0))}),[e,n,r]),null},DH={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},sJ=Ts({name:"brush",initialState:DH,reducers:{setBrushSettings(t,e){return e.payload==null?DH:e.payload}}}),{setBrushSettings:uQe}=sJ.actions,EAe=sJ.reducer,AAe=(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)}},TAe=t=>{var{x1:e,y1:n,x2:r,y2:i}=t;return AAe({x:e,y:n},{x:r,y:i})};function CAe(t){return(t%180+180)%180}var kAe=function(e){var{width:n,height:r}=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,a=CAe(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)},jAe={dots:[],areas:[],lines:[]},oJ=Ts({name:"referenceElements",initialState:jAe,reducers:{addDot:(t,e)=>{t.dots.push(e.payload)},removeDot:(t,e)=>{var n=ol(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=ol(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=ol(t).lines.findIndex(r=>r===e.payload);n!==-1&&t.lines.splice(n,1)}}}),{addDot:dQe,removeDot:hQe,addArea:fQe,removeArea:mQe,addLine:PAe,removeLine:RAe}=oJ.actions,DAe=oJ.reducer,lJ=w.createContext(void 0),OAe=t=>{var{children:e}=t,[n]=w.useState("".concat(L0("recharts"),"-clip")),r=cE();if(r==null)return null;var{x:i,y:a,width:o,height:l}=r;return w.createElement(lJ.Provider,{value:n},w.createElement("defs",null,w.createElement("clipPath",{id:n},w.createElement("rect",{x:i,y:a,height:l,width:o}))),e)},LAe=()=>w.useContext(lJ);class IAe{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 OH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function LH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?OH(Object(n),!0).forEach(function(r){FAe(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 FAe(t,e,n){return(e=UAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function UAe(t){var e=zAe(t,"string");return typeof e=="symbol"?e:e+""}function zAe(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(){return RS=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},RS.apply(null,arguments)}var BAe=(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",RS({},e,{className:"recharts-reference-line-line"}))}return n},$Ae=(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},HAe=(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},VAe=(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},GAe=(t,e,n,r,i,a,o)=>{var{x:l,y:c,segment:u,ifOverflow:d}=o,f=Fo(l),m=Fo(c);return m?$Ae(c,d,r,a,e,n):f?HAe(l,d,r,i,t,n):u!=null&&u.length===2?VAe(u,d,r,new IAe({x:t,y:e})):null};function WAe(t){var e=Sr();return w.useEffect(()=>(e(PAe(t)),()=>{e(RAe(t))})),null}function qAe(t){var{xAxisId:e,yAxisId:n,shape:r,className:i,ifOverflow:a}=t,o=Bi(),l=LAe(),c=Wt(E=>uc(E,e)),u=Wt(E=>dc(E,n)),d=Wt(E=>Cg(E,"xAxis",e,o)),f=Wt(E=>Cg(E,"yAxis",n,o)),m=jy();if(!l||!m||c==null||u==null||d==null||f==null)return null;var p=GAe(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,A=a==="hidden"?"url(#".concat(l,")"):void 0,T=LH(LH({clipPath:A},Ca(t)),{},{x1:x,y1:v,x2:S,y2:M}),k=TAe({x1:x,y1:v,x2:S,y2:M});return w.createElement(Ha,{zIndex:t.zIndex},w.createElement(Kr,{className:Vn("recharts-reference-line",i)},BAe(r,T),w.createElement($Q,RS({},k,{lowerWidth:k.width,upperWidth:k.width}),w.createElement(VQ,{label:t.label}),t.children)))}var KAe={ifOverflow:"discard",xAxisId:0,yAxisId:0,fill:"none",label:!1,stroke:"#ccc",fillOpacity:1,strokeWidth:1,position:"middle",zIndex:li.line};function Vb(t){var e=Xr(t,KAe);return w.createElement(w.Fragment,null,w.createElement(WAe,{yAxisId:e.yAxisId,xAxisId:e.xAxisId,ifOverflow:e.ifOverflow,x:e.x,y:e.y,segment:e.segment}),w.createElement(qAe,e))}Vb.displayName="ReferenceLine";function cJ(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 XAe(t,e,n){var r={width:t.width+e.width,height:t.height+e.height};return kAe(r,n)}function YAe(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 Y0(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 ZAe(t,e){return cJ(t,e+1)}function QAe(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:cJ(r,u)};var y=c,x,v=()=>(x===void 0&&(x=n(b,y)),x),S=b.coordinate,M=c===0||Y0(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 JAe(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 A=r[y];if(A==null)return 0;var T=y,k,E=()=>(k===void 0&&(k=n(A,T)),k),O=A.coordinate,C=y===d||Y0(t,O,E,f,c);if(!C)return m=!1,1;C&&(f=O+t*(E()/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 IH(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 Ia(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?IH(Object(n),!0).forEach(function(r){eTe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):IH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function eTe(t,e,n){return(e=tTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function tTe(t){var e=nTe(t,"string");return typeof e=="symbol"?e:e+""}function nTe(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 rTe(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=Ia(Ia({},b),{},{tickCoord:v>0?b.coordinate-v*t:b.coordinate})}else a[m]=b=Ia(Ia({},b),{},{tickCoord:b.coordinate});if(b.tickCoord!=null){var S=Y0(t,b.tickCoord,x,l,c);S&&(c=b.tickCoord-t*(x()/2+i),a[m]=Ia(Ia({},b),{},{isShow:!0}))}},d=o-1;d>=0;d--)u(d);return a}function iTe(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=Ia(Ia({},d),{},{tickCoord:m>0?d.coordinate-m*t:d.coordinate}),d.tickCoord!=null){var p=Y0(t,d.tickCoord,()=>f,c,u);p&&(u=d.tickCoord-t*(f/2+i),o[l-1]=Ia(Ia({},d),{},{isShow:!0}))}}}for(var b=a?l-1:l,y=function(S){var M=o[S];if(M==null)return 1;var A=M,T,k=()=>(T===void 0&&(T=n(M,S)),T);if(S===0){var E=t*(A.coordinate-t*k()/2-c);o[S]=A=Ia(Ia({},A),{},{tickCoord:E<0?A.coordinate-E*t:A.coordinate})}else o[S]=A=Ia(Ia({},A),{},{tickCoord:A.coordinate});if(A.tickCoord!=null){var O=Y0(t,A.tickCoord,k,c,u);O&&(c=A.tickCoord+t*(k()/2+i),o[S]=Ia(Ia({},A),{},{isShow:!0}))}},x=0;x<b;x++)y(x);return o}function G4(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(Bt(c)||Dy.isSsr){var m;return(m=ZAe(i,Bt(c)?c:0))!==null&&m!==void 0?m:[]}var p=[],b=l==="top"||l==="bottom"?"width":"height",y=d&&b==="width"?s0(d,{fontSize:e,letterSpacing:n}):{width:0,height:0},x=(T,k)=>{var E=typeof u=="function"?u(T.value,k):T.value;return b==="width"?XAe(s0(E,{fontSize:e,letterSpacing:n}),y,f):s0(E,{fontSize:e,letterSpacing:n})[b]},v=i[0],S=i[1],M=i.length>=2&&v!=null&&S!=null?ta(S.coordinate-v.coordinate):1,A=YAe(a,M,b);return c==="equidistantPreserveStart"?QAe(M,A,x,i,o):c==="equidistantPreserveEnd"?JAe(M,A,x,i,o):(c==="preserveStart"||c==="preserveStartEnd"?p=iTe(M,A,x,i,o,c==="preserveStartEnd"):p=rTe(M,A,x,i,o),p.filter(T=>T.isShow))}var aTe=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},sTe=["axisLine","width","height","className","hide","ticks","axisType"];function oTe(t,e){if(t==null)return{};var n,r,i=lTe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function lTe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function nm(){return nm=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},nm.apply(null,arguments)}function FH(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 ni(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?FH(Object(n),!0).forEach(function(r){cTe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):FH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function cTe(t,e,n){return(e=uTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function uTe(t){var e=dTe(t,"string");return typeof e=="symbol"?e:e+""}function dTe(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 lu={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:li.axis};function hTe(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=ni(ni(ni({},c),rs(l)),{},{fill:"none"});if(a==="top"||a==="bottom"){var d=+(a==="top"&&!o||a==="bottom"&&o);u=ni(ni({},u),{},{x1:e,y1:n+d*i,x2:e+r,y2:n+d*i})}else{var f=+(a==="left"&&!o||a==="right"&&o);u=ni(ni({},u),{},{x1:e+f*r,y1:n,x2:e+f*r,y2:n+i})}return w.createElement("line",nm({},u,{className:Vn("recharts-cartesian-axis-line",Yf(l,"className"))}))}function fTe(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=Bt(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 mTe(t,e){switch(t){case"left":return e?"start":"end";case"right":return e?"end":"start";default:return"middle"}}function pTe(t,e){switch(t){case"left":case"right":return"middle";case"top":return e?"start":"end";default:return e?"end":"start"}}function gTe(t){var{option:e,tickProps:n,value:r}=t,i,a=Vn(n.className,"recharts-cartesian-axis-tick-value");if(w.isValidElement(e))i=w.cloneElement(e,ni(ni({},n),{},{className:a}));else if(typeof e=="function")i=e(ni(ni({},n),{},{className:a}));else{var o="recharts-cartesian-axis-tick-value";typeof e!="boolean"&&(o=Vn(o,ZQ(e))),i=w.createElement(nE,nm({},n,{className:o}),r)}return i}var xTe=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:A,events:T,axisType:k}=t,E=G4(ni(ni({},A),{},{ticks:n}),S,M),O=mTe(d,f),C=pTe(d,f),D=rs(A),U=Kf(r),L={};typeof i=="object"&&(L=i);var q=ni(ni({},D),{},{fill:"none"},L),P=E.map(V=>ni({entry:V},fTe(V,m,p,b,y,d,x,f,v))),W=P.map(V=>{var{entry:Q,line:re}=V;return w.createElement(Kr,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(Q.value,"-").concat(Q.coordinate,"-").concat(Q.tickCoord)},i&&w.createElement("line",nm({},q,re,{className:Vn("recharts-cartesian-axis-tick-line",Yf(i,"className"))})))}),K=P.map((V,Q)=>{var re,J,{entry:z,tick:G}=V,ne=ni(ni(ni(ni({verticalAnchor:C},D),{},{textAnchor:O,stroke:"none",fill:a},G),{},{index:Q,payload:z,visibleTicksCount:E.length,tickFormatter:o,padding:c},u),{},{angle:(re=(J=u?.angle)!==null&&J!==void 0?J:D.angle)!==null&&re!==void 0?re:0}),ae=ni(ni({},ne),U);return w.createElement(Kr,nm({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(z.value,"-").concat(z.coordinate,"-").concat(z.tickCoord)},Ay(T,z,Q)),r&&w.createElement(gTe,{option:r,tickProps:ae,value:"".concat(typeof o=="function"?o(z.value,Q):z.value).concat(l||"")}))});return w.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(k,"-ticks")},K.length>0&&w.createElement(Ha,{zIndex:li.label},w.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(k,"-tick-labels"),ref:e},K)),W.length>0&&w.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(k,"-tick-lines")},W))}),bTe=w.forwardRef((t,e)=>{var{axisLine:n,width:r,height:i,className:a,hide:o,ticks:l,axisType:c}=t,u=oTe(t,sTe),[d,f]=w.useState(""),[m,p]=w.useState(""),b=w.useRef(null);w.useImperativeHandle(e,()=>({getCalculatedWidth:()=>{var x;return aTe({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),A=M.fontSize,T=M.letterSpacing;(A!==d||T!==m)&&(f(A),p(T))}}},[d,m]);return o||r!=null&&r<=0||i!=null&&i<=0?null:w.createElement(Ha,{zIndex:t.zIndex},w.createElement(Kr,{className:Vn("recharts-cartesian-axis",a)},w.createElement(hTe,{x:t.x,y:t.y,width:r,height:i,orientation:t.orientation,mirror:t.mirror,axisLine:n,otherSvgProps:rs(t)}),w.createElement(xTe,{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($Q,{x:t.x,y:t.y,width:t.width,height:t.height,lowerWidth:t.width,upperWidth:t.width},w.createElement(VQ,{label:t.label,labelRef:t.labelRef}),t.children)))}),W4=w.forwardRef((t,e)=>{var n=Xr(t,lu);return w.createElement(bTe,nm({},n,{ref:e}))});W4.displayName="CartesianAxis";var yTe=["x1","y1","x2","y2","key"],vTe=["offset"],_Te=["xAxisId","yAxisId"],wTe=["xAxisId","yAxisId"];function UH(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 za(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?UH(Object(n),!0).forEach(function(r){STe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):UH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function STe(t,e,n){return(e=MTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function MTe(t){var e=NTe(t,"string");return typeof e=="symbol"?e:e+""}function NTe(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 yf(){return yf=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},yf.apply(null,arguments)}function DS(t,e){if(t==null)return{};var n,r,i=ETe(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 ETe(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 ATe=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 uJ(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=DS(n,yTe),f=(i=rs(d))!==null&&i!==void 0?i:{},{offset:m}=f,p=DS(f,vTe);r=w.createElement("line",yf({},p,{x1:a,y1:o,x2:l,y2:c,fill:"none",key:u}))}return r}function TTe(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=DS(t,_Te),c=i.map((u,d)=>{var f=za(za({},l),{},{x1:e,y1:u,x2:e+n,y2:u,key:"line-".concat(d),index:d});return w.createElement(uJ,{key:"line-".concat(d),option:r,lineItemProps:f})});return w.createElement("g",{className:"recharts-cartesian-grid-horizontal"},c)}function CTe(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=DS(t,wTe),c=i.map((u,d)=>{var f=za(za({},l),{},{x1:u,y1:e,x2:u,y2:e+n,key:"line-".concat(d),index:d});return w.createElement(uJ,{option:r,lineItemProps:f,key:"line-".concat(d)})});return w.createElement("g",{className:"recharts-cartesian-grid-vertical"},c)}function kTe(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 jTe(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 PTe=(t,e)=>{var{xAxis:n,width:r,height:i,offset:a}=t;return JX(G4(za(za(za({},lu),n),{},{ticks:eY(n),viewBox:{x:0,y:0,width:r,height:i}})),a.left,a.left+a.width,e)},RTe=(t,e)=>{var{yAxis:n,width:r,height:i,offset:a}=t;return JX(G4(za(za(za({},lu),n),{},{ticks:eY(n),viewBox:{x:0,y:0,width:r,height:i}})),a.top,a.top+a.height,e)},DTe={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:li.grid};function OS(t){var e=bO(),n=yO(),r=lY(),i=za(za({},Xr(t,DTe)),{},{x:Bt(t.x)?t.x:r.left,y:Bt(t.y)?t.y:r.top,width:Bt(t.width)?t.width:r.width,height:Bt(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=Wt(C=>A$(C,"xAxis",a,b)),x=Wt(C=>A$(C,"yAxis",o,b));if(!ec(u)||!ec(d)||!Bt(l)||!Bt(c))return null;var v=i.verticalCoordinatesGenerator||PTe,S=i.horizontalCoordinatesGenerator||RTe,{horizontalPoints:M,verticalPoints:A}=i;if((!M||!M.length)&&typeof S=="function"){var T=m&&m.length,k=S({yAxis:x?za(za({},x),{},{ticks:T?m:x.ticks}):void 0,width:e??u,height:n??d,offset:r},T?!0:f);iS(Array.isArray(k),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof k,"]")),Array.isArray(k)&&(M=k)}if((!A||!A.length)&&typeof v=="function"){var E=p&&p.length,O=v({xAxis:y?za(za({},y),{},{ticks:E?p:y.ticks}):void 0,width:e??u,height:n??d,offset:r},E?!0:f);iS(Array.isArray(O),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof O,"]")),Array.isArray(O)&&(A=O)}return w.createElement(Ha,{zIndex:i.zIndex},w.createElement("g",{className:"recharts-cartesian-grid"},w.createElement(ATe,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),w.createElement(kTe,yf({},i,{horizontalPoints:M})),w.createElement(jTe,yf({},i,{verticalPoints:A})),w.createElement(TTe,yf({},i,{offset:r,horizontalPoints:M,xAxis:y,yAxis:x})),w.createElement(CTe,yf({},i,{offset:r,verticalPoints:A,xAxis:y,yAxis:x}))))}OS.displayName="CartesianGrid";var OTe={},dJ=Ts({name:"errorBars",initialState:OTe,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:pQe,replaceErrorBar:gQe,removeErrorBar:xQe}=dJ.actions,LTe=dJ.reducer,ITe=["children"];function FTe(t,e){if(t==null)return{};var n,r,i=UTe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function UTe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var zTe={data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0},BTe=w.createContext(zTe);function hJ(t){var{children:e}=t,n=FTe(t,ITe);return w.createElement(BTe.Provider,{value:n},e)}function uE(t,e){var n,r,i=Wt(u=>uc(u,t)),a=Wt(u=>dc(u,e)),o=(n=i?.allowDataOverflow)!==null&&n!==void 0?n:Yi.allowDataOverflow,l=(r=a?.allowDataOverflow)!==null&&r!==void 0?r:Zi.allowDataOverflow,c=o||l;return{needClip:c,needClipX:o,needClipY:l}}function q4(t){var{xAxisId:e,yAxisId:n,clipPathId:r}=t,i=cE(),{needClipX:a,needClipY:o,needClip:l}=uE(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 fJ=(t,e,n,r)=>rc(t,"xAxis",e,r),mJ=(t,e,n,r)=>nc(t,"xAxis",e,r),pJ=(t,e,n,r)=>rc(t,"yAxis",n,r),gJ=(t,e,n,r)=>nc(t,"yAxis",n,r),$Te=et([$n,fJ,pJ,mJ,gJ],(t,e,n,r,i)=>bl(t,"xAxis")?th(e,r,!1):th(n,i,!1)),HTe=(t,e,n,r,i)=>i;function VTe(t){return t.type==="line"}var GTe=et([By,HTe],(t,e)=>t.filter(VTe).find(n=>n.id===e)),WTe=et([$n,fJ,pJ,mJ,gJ,GTe,$Te,qO],(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 PCe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:f,bandSize:o,displayedData:p})}});function xJ(t){var e=Kf(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 zC={exports:{}},BC={};var zH;function qTe(){if(zH)return BC;zH=1;var t=Kg();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 BC.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(T){if(!v){if(v=!0,S=T,T=f(T),m!==void 0&&b.hasValue){var k=b.value;if(m(k,T))return M=k}return M=T}if(k=M,n(S,T))return k;var E=f(T);return m!==void 0&&m(k,E)?(S=T,k):(S=T,M=E)}var v=!1,S,M,A=d===void 0?null:d;return[function(){return x(u())},A===null?void 0:function(){return x(A())}]},[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},BC}var BH;function KTe(){return BH||(BH=1,zC.exports=qTe()),zC.exports}KTe();function XTe(t){t()}function YTe(){let t=null,e=null;return{clear(){t=null,e=null},notify(){XTe(()=>{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 $H={notify(){},get:()=>[]};function ZTe(t,e){let n,r=$H,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=YTe())}function f(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=$H)}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 QTe=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",JTe=QTe(),eCe=()=>typeof navigator<"u"&&navigator.product==="ReactNative",tCe=eCe(),nCe=()=>JTe||tCe?w.useLayoutEffect:w.useEffect,rCe=nCe();function HH(t,e){return t===e?t!==0||e!==0||1/t===1/e:t!==t&&e!==e}function iCe(t,e){if(HH(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])||!HH(t[n[i]],e[n[i]]))return!1;return!0}var aCe=Symbol.for("react-redux-context"),sCe=typeof globalThis<"u"?globalThis:{};function oCe(){if(!w.createContext)return{};const t=sCe[aCe]??=new Map;let e=t.get(w.createContext);return e||(e=w.createContext(null),t.set(w.createContext,e)),e}var lCe=oCe();function cCe(t){const{children:e,context:n,serverState:r,store:i}=t,a=w.useMemo(()=>{const c=ZTe(i);return{store:i,subscription:c,getServerState:r?()=>r:void 0}},[i,r]),o=w.useMemo(()=>i.getState(),[i]);rCe(()=>{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||lCe;return w.createElement(l.Provider,{value:a},e)}var uCe=cCe,dCe=new Set(["axisLine","tickLine","activeBar","activeDot","activeLabel","activeShape","allowEscapeViewBox","background","cursor","dot","label","line","margin","padding","position","shape","style","tick","wrapperStyle","radius"]);function hCe(t,e){return t==null&&e==null?!0:typeof t=="number"&&typeof e=="number"?t===e||t!==t&&e!==e:t===e}function Ky(t,e){var n=new Set([...Object.keys(t),...Object.keys(e)]);for(var r of n)if(dCe.has(r)){if(t[r]==null&&e[r]==null)continue;if(!iCe(t[r],e[r]))return!1}else if(!hCe(t[r],e[r]))return!1;return!0}var fCe=["id"],mCe=["type","layout","connectNulls","needClip","shape"],pCe=["activeDot","animateNewValues","animationBegin","animationDuration","animationEasing","connectNulls","dot","hide","isAnimationActive","label","legendType","xAxisId","yAxisId","id"];function Z0(){return Z0=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},Z0.apply(null,arguments)}function VH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Ll(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?VH(Object(n),!0).forEach(function(r){gCe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):VH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function gCe(t,e,n){return(e=xCe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function xCe(t){var e=bCe(t,"string");return typeof e=="symbol"?e:e+""}function bCe(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 K4(t,e){if(t==null)return{};var n,r,i=yCe(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 yCe(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 vCe=t=>{var{dataKey:e,name:n,stroke:r,legendType:i,hide:a}=t;return[{inactive:a,dataKey:e,type:i,color:r,value:ph(n,e),payload:t}]},_Ce=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:mh,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:e,nameKey:void 0,name:ph(o,e),hide:l,type:u,color:r,unit:c,graphicalItemId:d}};return w.createElement(sE,{tooltipEntrySettings:f})}),bJ=(t,e)=>"".concat(e,"px ").concat(t-e,"px");function wCe(t,e){for(var n=t.length%2!==0?[...t,0]:t,r=[],i=0;i<e;++i)r=[...r,...n];return r}var SCe=(t,e,n)=>{var r=n.reduce((p,b)=>p+b);if(!r)return bJ(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[...wCe(n,i),...l,...m].map(p=>"".concat(p,"px")).join(", ")};function MCe(t){var{clipPathId:e,points:n,props:r}=t,{dot:i,dataKey:a,needClip:o}=r,{id:l}=r,c=K4(r,fCe),u=rs(c);return w.createElement(nJ,{points:n,dot:i,className:"recharts-line-dots",dotClassName:"recharts-line-dot",dataKey:a,baseProps:u,needClip:o,clipPathId:e})}function NCe(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 Ll(Ll({},c),{},{value:a.value,payload:a.payload,viewBox:c,parentViewBox:void 0,fill:void 0})}),[r]);return w.createElement(D4,{value:e?i:void 0},n)}function GH(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=K4(a,mCe),m=Ll(Ll({},Ca(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(U4,Z0({shapeType:"curve",option:d},m,{pathRef:n})),w.createElement(MCe,{points:r,clipPathId:e,props:a}))}function ECe(t){try{return t&&t.getTotalLength&&t.getTotalLength()||0}catch{return 0}}function ACe(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=nx(o,"recharts-line-"),M=w.useRef(S),[A,T]=w.useState(!1),k=!A,E=w.useCallback(()=>{typeof y=="function"&&y(),T(!1)},[y]),O=w.useCallback(()=>{typeof x=="function"&&x(),T(!0)},[x]),C=ECe(r.current),D=w.useRef(0);M.current!==S&&(D.current=a.current,M.current=S);var U=D.current;return w.createElement(NCe,{points:o,showLabels:k},n.children,w.createElement(tx,{animationId:S,begin:u,duration:d,isActive:c,easing:f,onAnimationEnd:E,onAnimationStart:O,key:S},L=>{var q=tr(U,C+U,L),P=Math.min(q,C),W;if(c)if(l){var K="".concat(l).split(/[,\s]+/gim).map(re=>parseFloat(re));W=SCe(P,C,K)}else W=bJ(C,P);else W=l==null?void 0:String(l);if(L>0&&C>0&&(i.current=o,a.current=Math.max(a.current,P)),v){var V=v.length/o.length,Q=L===1?o:o.map((re,J)=>{var z=Math.floor(J*V);if(v[z]){var G=v[z];return Ll(Ll({},re),{},{x:tr(G.x,re.x,L),y:tr(G.y,re.y,L)})}return m?Ll(Ll({},re),{},{x:tr(p*2,re.x,L),y:tr(b/2,re.y,L)}):Ll(Ll({},re),{},{x:re.x,y:re.y})});return i.current=Q,w.createElement(GH,{props:n,points:Q,clipPathId:e,pathRef:r,strokeDasharray:W})}return w.createElement(GH,{props:n,points:o,clipPathId:e,pathRef:r,strokeDasharray:W})}),w.createElement(rE,{label:n.label}))}function TCe(t){var{clipPathId:e,props:n}=t,r=w.useRef(null),i=w.useRef(0),a=w.useRef(null);return w.createElement(ACe,{props:n,clipPathId:e,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:a})}var CCe=(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:rr(t.payload,e)}};class kCe 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=Vn("recharts-line",i),y=f,{r:x,strokeWidth:v}=xJ(n),S=F4(n),M=x*2+v,A=m?"url(#clipPath-".concat(S?"":"dots-").concat(y,")"):void 0;return w.createElement(Ha,{zIndex:p},w.createElement(Kr,{className:b},m&&w.createElement("defs",null,w.createElement(q4,{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(hJ,{xAxisId:a,yAxisId:o,data:r,dataPointFormatter:CCe,errorBarOffset:0},w.createElement(TCe,{props:this.props,clipPathId:y}))),w.createElement(v3,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:A}))}}var yJ={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:li.line,type:"linear"};function jCe(t){var e=Xr(t,yJ),{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=K4(e,pCe),{needClip:v}=uE(p,b),S=cE(),M=gh(),A=Bi(),T=Wt(D=>WTe(D,p,b,A,y));if(M!=="horizontal"&&M!=="vertical"||T==null||S==null)return null;var{height:k,width:E,x:O,y:C}=S;return w.createElement(kCe,Z0({},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:T,layout:M,height:k,width:E,left:O,top:C,needClip:v}))}function PCe(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=rr(u,o);if(e==="horizontal"){var m=rS({axis:n,ticks:i,bandSize:l,entry:u,index:d}),p=Vr(f)?null:r.scale.map(f);return{x:m,y:p??null,value:f,payload:u}}var b=Vr(f)?null:n.scale.map(f),y=rS({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 RCe(t){var e=Xr(t,yJ),n=Bi();return w.createElement(oE,{id:e.id,type:"line"},r=>w.createElement(w.Fragment,null,w.createElement(H4,{legendPayload:vCe(e)}),w.createElement(_Ce,{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(V4,{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(jCe,Z0({},e,{id:r}))))}var vJ=w.memo(RCe,Ky);vJ.displayName="Line";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.xAxisId)!==null&&n!==void 0?n:rJ}function fc(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:rJ}var _J=(t,e,n)=>rc(t,"xAxis",hc(t,e),n),wJ=(t,e,n)=>nc(t,"xAxis",hc(t,e),n),SJ=(t,e,n)=>rc(t,"yAxis",fc(t,e),n),MJ=(t,e,n)=>nc(t,"yAxis",fc(t,e),n),DCe=et([$n,_J,SJ,wJ,MJ],(t,e,n,r,i)=>bl(t,"xAxis")?th(e,r,!1):th(n,i,!1)),OCe=(t,e)=>e,NJ=et([By,OCe],(t,e)=>t.filter(n=>n.type==="area").find(n=>n.id===e)),EJ=t=>{var e=$n(t),n=bl(e,"xAxis");return n?"yAxis":"xAxis"},LCe=(t,e)=>{var n=EJ(t);return n==="yAxis"?fc(t,e):hc(t,e)},ICe=(t,e,n)=>ES(t,EJ(t),LCe(t,e),n),FCe=et([NJ,ICe],(t,e)=>{var n;if(!(t==null||e==null)){var{stackId:r}=t,i=qN(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]])}}}),UCe=et([$n,_J,SJ,wJ,MJ,FCe,uZ,DCe,NJ,Ywe],(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 ike({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:f,areaSettings:c,stackedData:a,displayedData:b,chartBaseValue:u,bandSize:l})}}),zCe=["id"],BCe=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function jf(){return jf=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},jf.apply(null,arguments)}function AJ(t,e){if(t==null)return{};var n,r,i=$Ce(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 $Ce(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 Jp(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){HCe(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 HCe(t,e,n){return(e=VCe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function VCe(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 LS(t,e){return t&&t!=="none"?t:e}var WCe=t=>{var{dataKey:e,name:n,stroke:r,fill:i,legendType:a,hide:o}=t;return[{inactive:o,dataKey:e,type:a,color:LS(r,i),value:ph(n,e),payload:t}]},qCe=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:mh,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:e,nameKey:void 0,name:ph(o,e),hide:l,type:u,color:LS(r,a),unit:c,graphicalItemId:d}};return w.createElement(sE,{tooltipEntrySettings:f})});function KCe(t){var{clipPathId:e,points:n,props:r}=t,{needClip:i,dot:a,dataKey:o}=r,l=rs(r);return w.createElement(nJ,{points:n,dot:a,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:o,baseProps:l,needClip:i,clipPathId:e})}function XCe(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 Jp(Jp({},c),{},{value:a.value,payload:a.payload,parentViewBox:void 0,viewBox:c,fill:void 0})});return w.createElement(D4,{value:e?i:void 0},n)}function qH(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=AJ(a,zCe),p=rs(m),b=Ca(m);return w.createElement(w.Fragment,null,e?.length>1&&w.createElement(Kr,{clipPath:r?"url(#clipPath-".concat(i,")"):void 0},w.createElement(og,jf({},b,{id:f,points:e,connectNulls:u,type:l,baseLine:n,layout:o,stroke:"none",className:"recharts-area-area"})),c!=="none"&&w.createElement(og,jf({},p,{className:"recharts-area-curve",layout:o,type:l,connectNulls:u,fill:"none",points:e})),c!=="none"&&d&&w.createElement(og,jf({},p,{className:"recharts-area-curve",layout:o,type:l,connectNulls:u,fill:"none",points:n}))),w.createElement(KCe,{points:e,props:m,clipPathId:i}))}function YCe(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 Bt(i)?d=Math.max(i,d):i&&Array.isArray(i)&&i.length&&(d=Math.max(...i.map(f=>f.x||0),d)),Bt(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 ZCe(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 Bt(i)?d=Math.max(i,d):i&&Array.isArray(i)&&i.length&&(d=Math.max(...i.map(f=>f.y||0),d)),Bt(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 QCe(t){var{alpha:e,layout:n,points:r,baseLine:i,strokeWidth:a}=t;return n==="vertical"?w.createElement(YCe,{alpha:e,points:r,baseLine:i,strokeWidth:a}):w.createElement(ZCe,{alpha:e,points:r,baseLine:i,strokeWidth:a})}function JCe(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=nx(b,"recharts-area-"),x=vO(),[v,S]=w.useState(!1),M=!v,A=w.useCallback(()=>{typeof p=="function"&&p(),S(!1)},[p]),T=w.useCallback(()=>{typeof m=="function"&&m(),S(!0)},[m]);if(x==null)return null;var k=i.current,E=a.current;return w.createElement(XCe,{showLabels:M,points:o},r.children,w.createElement(tx,{animationId:y,begin:u,duration:d,isActive:c,easing:f,onAnimationEnd:A,onAnimationStart:T,key:y},O=>{if(k){var C=k.length/o.length,D=O===1?o:o.map((L,q)=>{var P=Math.floor(q*C);if(k[P]){var W=k[P];return Jp(Jp({},L),{},{x:tr(W.x,L.x,O),y:tr(W.y,L.y,O)})}return L}),U;return Bt(l)?U=tr(E,l,O):Vr(l)||dl(l)?U=tr(E,0,O):U=l.map((L,q)=>{var P=Math.floor(q*C);if(Array.isArray(E)&&E[P]){var W=E[P];return Jp(Jp({},L),{},{x:tr(W.x,L.x,O),y:tr(W.y,L.y,O)})}return L}),O>0&&(i.current=D,a.current=U),w.createElement(qH,{points:D,baseLine:U,needClip:e,clipPathId:n,props:r})}return O>0&&(i.current=o,a.current=l),w.createElement(Kr,null,c&&w.createElement("defs",null,w.createElement("clipPath",{id:"animationClipPath-".concat(n)},w.createElement(QCe,{alpha:O,points:o,baseLine:l,layout:x,strokeWidth:r.strokeWidth}))),w.createElement(Kr,{clipPath:"url(#animationClipPath-".concat(n,")")},w.createElement(qH,{points:o,baseLine:l,needClip:e,clipPathId:n,props:r})))}),w.createElement(rE,{label:r.label}))}function eke(t){var{needClip:e,clipPathId:n,props:r}=t,i=w.useRef(null),a=w.useRef();return w.createElement(JCe,{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}class tke 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=Vn("recharts-area",i),x=m,{r:v,strokeWidth:S}=xJ(n),M=F4(n),A=v*2+S,T=l?"url(#clipPath-".concat(M?"":"dots-").concat(x,")"):void 0;return w.createElement(Ha,{zIndex:b},w.createElement(Kr,{className:y},l&&w.createElement("defs",null,w.createElement(q4,{clipPathId:x,xAxisId:c,yAxisId:u}),!M&&w.createElement("clipPath",{id:"clipPath-dots-".concat(x)},w.createElement("rect",{x:o-A/2,y:a-A/2,width:d+A,height:f+A}))),w.createElement(eke,{needClip:l,clipPathId:x,props:this.props})),w.createElement(v3,{points:r,mainColor:LS(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:T}),this.props.isRange&&Array.isArray(p)&&w.createElement(v3,{points:p,mainColor:LS(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:T}))}}var TJ={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:li.area};function nke(t){var e,n=Xr(t,TJ),{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=AJ(n,BCe),S=gh(),M=NQ(),{needClip:A}=uE(y,x),T=Bi(),{points:k,isRange:E,baseLine:O}=(e=Wt(P=>UCe(P,t.id,T)))!==null&&e!==void 0?e:{},C=cE();if(S!=="horizontal"&&S!=="vertical"||C==null||M!=="AreaChart"&&M!=="ComposedChart")return null;var{height:D,width:U,x:L,y:q}=C;return!k||!k.length?null:w.createElement(tke,jf({},v,{activeDot:r,animationBegin:i,animationDuration:a,animationEasing:o,baseLine:O,connectNulls:l,dot:c,fill:u,fillOpacity:d,height:D,hide:f,layout:S,isAnimationActive:m==="auto"?!Dy.isSsr:m,isRange:E,legendType:p,needClip:A,points:k,stroke:b,width:U,left:L,top:q,xAxisId:y,yAxisId:x}))}var rke=(t,e,n,r,i)=>{var a=n??e;if(Bt(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 ike(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=rke(a,o,n,l,c),x=a==="horizontal",v=!1,S=u.map((A,T)=>{var k,E,O,C;if(b)C=i[d+T];else{var D=rr(A,r);Array.isArray(D)?(C=D,v=!0):C=[y,D]}var U=(k=(E=C)===null||E===void 0?void 0:E[1])!==null&&k!==void 0?k:null,L=U==null||b&&!e&&rr(A,r)==null;if(x){var q;return{x:rS({axis:l,ticks:f,bandSize:p,entry:A,index:T}),y:L?null:(q=c.scale.map(U))!==null&&q!==void 0?q:null,value:C,payload:A}}return{x:L?null:(O=l.scale.map(U))!==null&&O!==void 0?O:null,y:rS({axis:c,ticks:m,bandSize:p,entry:A,index:T}),value:C,payload:A}}),M;return b||v?M=S.map(A=>{var T,k=Array.isArray(A.value)?A.value[0]:null;if(x){var E;return{x:A.x,y:k!=null&&A.y!=null&&(E=c.scale.map(k))!==null&&E!==void 0?E:null,payload:A.payload}}return{x:k!=null&&(T=l.scale.map(k))!==null&&T!==void 0?T:null,y:A.y,payload:A.payload}}):M=x?c.scale.map(y):l.scale.map(y),{points:S,baseLine:M??0,isRange:v}}function ake(t){var e=Xr(t,TJ),n=Bi();return w.createElement(oE,{id:e.id,type:"area"},r=>w.createElement(w.Fragment,null,w.createElement(H4,{legendPayload:WCe(e)}),w.createElement(qCe,{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(V4,{type:"area",id:r,data:e.data,dataKey:e.dataKey,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,stackId:tY(e.stackId),hide:e.hide,barSize:void 0,baseValue:e.baseValue,isPanorama:n,connectNulls:e.connectNulls}),w.createElement(nke,jf({},e,{id:r}))))}var CJ=w.memo(ake,Ky);CJ.displayName="Area";var ske="Invariant failed";function oke(t,e){throw new Error(ske)}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 IS(t){return w.createElement(U4,_3({shapeType:"rectangle",activeClassName:"recharts-active-bar"},t))}var lke=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(r,i)=>{if(Bt(e))return e;var a=Bt(r)||Vr(r);return a?e(r,i):(a||oke(),n)}},cke=(t,e,n)=>n,uke=(t,e)=>e,Xy=et([By,uke],(t,e)=>t.filter(n=>n.type==="bar").find(n=>n.id===e)),dke=et([Xy],t=>t?.maxBarSize),hke=(t,e,n,r)=>r,fke=et([$n,By,hc,fc,cke],(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")),mke=(t,e,n)=>{var r=$n(t),i=hc(t,e),a=fc(t,e);if(!(i==null||a==null))return r==="horizontal"?ES(t,"yAxis",a,n):ES(t,"xAxis",i,n)},pke=(t,e)=>{var n=$n(t),r=hc(t,e),i=fc(t,e);if(!(r==null||i==null))return n==="horizontal"?E$(t,"xAxis",r):E$(t,"yAxis",i)},gke=et([fke,Xwe,pke],xAe),xke=(t,e,n)=>{var r,i,a=Xy(t,e);if(a==null)return 0;var o=hc(t,e),l=fc(t,e);if(o==null||l==null)return 0;var c=$n(t),u=wZ(t),{maxBarSize:d}=a,f=Vr(d)?u:d,m,p;return c==="horizontal"?(m=rc(t,"xAxis",o,n),p=nc(t,"xAxis",o,n)):(m=rc(t,"yAxis",l,n),p=nc(t,"yAxis",l,n)),(r=(i=th(m,p,!0))!==null&&i!==void 0?i:f)!==null&&r!==void 0?r:0},kJ=(t,e,n)=>{var r=$n(t),i=hc(t,e),a=fc(t,e);if(!(i==null||a==null)){var o,l;return r==="horizontal"?(o=rc(t,"xAxis",i,n),l=nc(t,"xAxis",i,n)):(o=rc(t,"yAxis",a,n),l=nc(t,"yAxis",a,n)),th(o,l)}},bke=et([gke,wZ,Kwe,SZ,xke,kJ,dke],wAe),yke=(t,e,n)=>{var r=hc(t,e);if(r!=null)return rc(t,"xAxis",r,n)},vke=(t,e,n)=>{var r=fc(t,e);if(r!=null)return rc(t,"yAxis",r,n)},_ke=(t,e,n)=>{var r=hc(t,e);if(r!=null)return nc(t,"xAxis",r,n)},wke=(t,e,n)=>{var r=fc(t,e);if(r!=null)return nc(t,"yAxis",r,n)},Ske=et([bke,Xy],MAe),Mke=et([mke,Xy],SAe),Nke=et([zi,pO,yke,vke,_ke,wke,Ske,$n,uZ,kJ,Mke,Xy,hke],(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 Jke({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})}}),Eke=["index"];function w3(){return w3=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},w3.apply(null,arguments)}function Ake(t,e){if(t==null)return{};var n,r,i=Tke(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 Tke(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 jJ=w.createContext(void 0),Cke=t=>{var e=w.useContext(jJ);if(e!=null)return e.stackId;if(t!=null)return tY(t)},kke=(t,e)=>"recharts-bar-stack-clip-path-".concat(t,"-").concat(e),jke=t=>{var e=w.useContext(jJ);if(e!=null){var{stackId:n}=e;return"url(#".concat(kke(n,t),")")}},PJ=t=>{var{index:e}=t,n=Ake(t,Eke),r=jke(e);return w.createElement(Kr,w3({className:"recharts-bar-stack-layer",clipPath:r},n))},Pke=["onMouseEnter","onMouseLeave","onClick"],Rke=["value","background","tooltipPosition"],Dke=["id"],Oke=["onMouseEnter","onClick","onMouseLeave"];function wu(){return wu=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},wu.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 Ya(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){Lke(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 Lke(t,e,n){return(e=Ike(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Ike(t){var e=Fke(t,"string");return typeof e=="symbol"?e:e+""}function Fke(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 FS(t,e){if(t==null)return{};var n,r,i=Uke(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 Uke(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 zke=t=>{var{dataKey:e,name:n,fill:r,legendType:i,hide:a}=t;return[{inactive:a,dataKey:e,type:i,color:r,value:ph(n,e),payload:t}]},Bke=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:mh,settings:{stroke:n,strokeWidth:r,fill:i,dataKey:e,nameKey:void 0,name:ph(a,e),hide:o,type:c,color:i,unit:l,graphicalItemId:u}};return w.createElement(sE,{tooltipEntrySettings:d})});function $ke(t){var e=Wt(nh),{data:n,dataKey:r,background:i,allOtherBarProps:a}=t,{onMouseEnter:o,onMouseLeave:l,onClick:c}=a,u=FS(a,Pke),d=z4(o,r,a.id),f=B4(l),m=$4(c,r,a.id);if(!i||n==null)return null;var p=Kf(i);return w.createElement(Ha,{zIndex:NAe(i,li.barBackground)},n.map((b,y)=>{var{value:x,background:v,tooltipPosition:S}=b,M=FS(b,Rke);if(!v)return null;var A=d(b,y),T=f(b,y),k=m(b,y),E=Ya(Ya(Ya(Ya(Ya({option:i,isActive:String(y)===e},M),{},{fill:"#eee"},v),p),Ay(u,b,y)),{},{onMouseEnter:A,onMouseLeave:T,onClick:k,dataKey:r,index:y,className:"recharts-bar-background-rectangle"});return w.createElement(IS,wu({key:"background-bar-".concat(y)},E))}))}function Hke(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 Ya(Ya({},o),{},{value:a.value,payload:a.payload,parentViewBox:a.parentViewBox,viewBox:o,fill:a.fill})});return w.createElement(D4,{value:e?i:void 0},n)}function Vke(t){var{shape:e,activeBar:n,baseProps:r,entry:i,index:a,dataKey:o}=t,l=Wt(nh),c=Wt(T4),u=n&&String(a)===l&&(c==null||o===c),d=u?n:e;return u?w.createElement(Ha,{zIndex:li.activeBar},w.createElement(PJ,{index:a},w.createElement(IS,wu({},r,{name:String(r.name)},i,{isActive:u,option:d,index:a,dataKey:o})))):w.createElement(IS,wu({},r,{name:String(r.name)},i,{isActive:u,option:d,index:a,dataKey:o}))}function Gke(t){var{shape:e,baseProps:n,entry:r,index:i,dataKey:a}=t;return w.createElement(IS,wu({},n,{name:String(n.name)},r,{isActive:!1,option:e,index:i,dataKey:a}))}function Wke(t){var e,{data:n,props:r}=t,i=(e=rs(r))!==null&&e!==void 0?e:{},{id:a}=i,o=FS(i,Dke),{shape:l,dataKey:c,activeBar:u}=r,{onMouseEnter:d,onClick:f,onMouseLeave:m}=r,p=FS(r,Oke),b=z4(d,c,a),y=B4(m),x=$4(f,c,a);return n?w.createElement(w.Fragment,null,n.map((v,S)=>w.createElement(PJ,wu({index:S,key:"rectangle-".concat(v?.x,"-").concat(v?.y,"-").concat(v?.value,"-").concat(S),className:"recharts-bar-rectangle"},Ay(p,v,S),{onMouseEnter:b(v,S),onMouseLeave:y(v,S),onClick:x(v,S)}),u?w.createElement(Vke,{shape:l,activeBar:u,baseProps:o,entry:v,index:S,dataKey:c}):w.createElement(Gke,{shape:l,baseProps:o,entry:v,index:S,dataKey:c})))):null}function qke(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=nx(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(Hke,{showLabels:y,rects:r},w.createElement(tx,{animationId:m,begin:o,duration:l,isActive:a,easing:c,onAnimationEnd:x,onAnimationStart:v,key:m},S=>{var M=S===1?r:r?.map((A,T)=>{var k=f&&f[T];if(k)return Ya(Ya({},A),{},{x:tr(k.x,A.x,S),y:tr(k.y,A.y,S),width:tr(k.width,A.width,S),height:tr(k.height,A.height,S)});if(i==="horizontal"){var E=tr(0,A.height,S),O=tr(A.stackedBarStart,A.y,S);return Ya(Ya({},A),{},{y:O,height:E})}var C=tr(0,A.width,S),D=tr(A.stackedBarStart,A.x,S);return Ya(Ya({},A),{},{width:C,x:D})});return S>0&&(n.current=M??null),M==null?null:w.createElement(Kr,null,w.createElement(Wke,{props:e,data:M}))}),w.createElement(rE,{label:e.label}),e.children)}function Kke(t){var e=w.useRef(null);return w.createElement(qke,{previousRectanglesRef:e,props:t})}var RJ=0,Xke=(t,e)=>{var n=Array.isArray(t.value)?t.value[1]:t.value;return{x:t.x,y:t.y,value:n,errorVal:rr(t,e)}};class Yke 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=Vn("recharts-bar",i),f=u;return w.createElement(Kr,{className:d,id:u},l&&w.createElement("defs",null,w.createElement(q4,{clipPathId:f,xAxisId:a,yAxisId:o})),w.createElement(Kr,{className:"recharts-bar-rectangles",clipPath:l?"url(#clipPath-".concat(f,")"):void 0},w.createElement($ke,{data:n,dataKey:r,background:c,allOtherBarProps:this.props}),w.createElement(Kke,this.props)))}}var Zke={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:RJ,xAxisId:0,yAxisId:0,zIndex:li.bar};function Qke(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}=uE(e,n),m=gh(),p=Bi(),b=I4(t.children,qy),y=Wt(S=>Nke(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(hJ,{xAxisId:e,yAxisId:n,data:y,dataPointFormatter:Xke,errorBarOffset:x},w.createElement(Yke,wu({},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 Jke(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=Lbe({numericAxis:x}),M=x.scale.map(S);return f.map((A,T)=>{var k,E,O,C,D,U;if(d){var L=d[T+y];if(L==null)return null;k=jbe(L,v)}else k=rr(A,n),Array.isArray(k)||(k=[S,k]);var q=lke(r,RJ)(k[1],T);if(e==="horizontal"){var P,W=l.scale.map(k[0]),K=l.scale.map(k[1]);if(W==null||K==null)return null;E=N8({axis:o,ticks:c,bandSize:a,offset:i.offset,entry:A,index:T}),O=(P=K??W)!==null&&P!==void 0?P:void 0,C=i.size;var V=W-K;if(D=dl(V)?0:V,U={x:E,y:m.top,width:C,height:m.height},Math.abs(q)>0&&Math.abs(D)<Math.abs(q)){var Q=ta(D||q)*(Math.abs(q)-Math.abs(D));O-=Q,D+=Q}}else{var re=o.scale.map(k[0]),J=o.scale.map(k[1]);if(re==null||J==null)return null;if(E=re,O=N8({axis:l,ticks:u,bandSize:a,offset:i.offset,entry:A,index:T}),C=J-re,D=i.size,U={x:m.left,y:O,width:m.width,height:D},Math.abs(q)>0&&Math.abs(C)<Math.abs(q)){var z=ta(C||q)*(Math.abs(q)-Math.abs(C));C+=z}}if(E==null||O==null||C==null||D==null)return null;var G=Ya(Ya({},A),{},{stackedBarStart:M,x:E,y:O,width:C,height:D,value:d?k:k[1],payload:A,background:U,tooltipPosition:{x:E+C/2,y:O+D/2},parentViewBox:b},p&&p[T]&&p[T].props);return G}).filter(Boolean)}function eje(t){var e=Xr(t,Zke),n=Cke(e.stackId),r=Bi();return w.createElement(oE,{id:e.id,type:"bar"},i=>w.createElement(w.Fragment,null,w.createElement(H4,{legendPayload:zke(e)}),w.createElement(Bke,{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(V4,{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(Ha,{zIndex:e.zIndex},w.createElement(Qke,wu({},e,{id:i})))))}var DJ=w.memo(eje,Ky);DJ.displayName="Bar";var tje=["domain","range"],nje=["domain","range"];function XH(t,e){if(t==null)return{};var n,r,i=rje(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 rje(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 YH(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 OJ(t,e){if(t===e)return!0;var{domain:n,range:r}=t,i=XH(t,tje),{domain:a,range:o}=e,l=XH(e,nje);return!YH(n,a)||!YH(r,o)?!1:Ky(i,l)}var ije=["type"],aje=["dangerouslySetInnerHTML","ticks","scale"],sje=["id","scale"];function S3(){return S3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},S3.apply(null,arguments)}function ZH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function QH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?ZH(Object(n),!0).forEach(function(r){oje(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ZH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function oje(t,e,n){return(e=lje(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function lje(t){var e=cje(t,"string");return typeof e=="symbol"?e:e+""}function cje(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 M3(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 dje(t){var e=Sr(),n=w.useRef(null),r=vO(),{type:i}=t,a=M3(t,ije),o=GN(r,"xAxis",i),l=w.useMemo(()=>{if(o!=null)return QH(QH({},a),{},{type:o})},[a,o]);return w.useLayoutEffect(()=>{l!=null&&(n.current===null?e(nAe(l)):n.current!==l&&e(rAe({prev:n.current,next:l})),n.current=l)},[l,e]),w.useLayoutEffect(()=>()=>{n.current&&(e(iAe(n.current)),n.current=null)},[e]),null}var hje=t=>{var{xAxisId:e,className:n}=t,r=Wt(pO),i=Bi(),a="xAxis",o=Wt(v=>nQ(v,a,e,i)),l=Wt(v=>QZ(v,e)),c=Wt(v=>Y1e(v,e)),u=Wt(v=>RZ(v,e));if(l==null||c==null||u==null)return null;var{dangerouslySetInnerHTML:d,ticks:f,scale:m}=t,p=M3(t,aje),{id:b,scale:y}=u,x=M3(u,sje);return w.createElement(W4,S3({},p,x,{x:c.x,y:c.y,width:l.width,height:l.height,className:Vn("recharts-".concat(a," ").concat(a),n),viewBox:r,ticks:o,axisType:a}))},fje={allowDataOverflow:Yi.allowDataOverflow,allowDecimals:Yi.allowDecimals,allowDuplicatedCategory:Yi.allowDuplicatedCategory,angle:Yi.angle,axisLine:lu.axisLine,height:Yi.height,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:lu.tickLine,tickSize:lu.tickSize,type:Yi.type,xAxisId:0},mje=t=>{var e=Xr(t,fje);return w.createElement(w.Fragment,null,w.createElement(dje,{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(hje,e))},US=w.memo(mje,OJ);US.displayName="XAxis";var pje=["type"],gje=["dangerouslySetInnerHTML","ticks","scale"],xje=["id","scale"];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 JH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function eV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?JH(Object(n),!0).forEach(function(r){bje(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):JH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function bje(t,e,n){return(e=yje(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function yje(t){var e=vje(t,"string");return typeof e=="symbol"?e:e+""}function vje(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 E3(t,e){if(t==null)return{};var n,r,i=_je(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 _je(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 wje(t){var e=Sr(),n=w.useRef(null),r=vO(),{type:i}=t,a=E3(t,pje),o=GN(r,"yAxis",i),l=w.useMemo(()=>{if(o!=null)return eV(eV({},a),{},{type:o})},[o,a]);return w.useLayoutEffect(()=>{l!=null&&(n.current===null?e(aAe(l)):n.current!==l&&e(sAe({prev:n.current,next:l})),n.current=l)},[l,e]),w.useLayoutEffect(()=>()=>{n.current&&(e(oAe(n.current)),n.current=null)},[e]),null}function Sje(t){var{yAxisId:e,className:n,width:r,label:i}=t,a=w.useRef(null),o=w.useRef(null),l=Wt(pO),c=Bi(),u=Sr(),d="yAxis",f=Wt(k=>JZ(k,e)),m=Wt(k=>Q1e(k,e)),p=Wt(k=>nQ(k,d,e,c)),b=Wt(k=>DZ(k,e));if(w.useLayoutEffect(()=>{if(!(r!=="auto"||!f||R4(i)||w.isValidElement(i)||b==null)){var k=a.current;if(k){var E=k.getCalculatedWidth();Math.round(f.width)!==Math.round(E)&&u(lAe({id:e,width:E}))}}},[p,f,u,i,e,r,b]),f==null||m==null||b==null)return null;var{dangerouslySetInnerHTML:y,ticks:x,scale:v}=t,S=E3(t,gje),{id:M,scale:A}=b,T=E3(b,xje);return w.createElement(W4,N3({},S,T,{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:Vn("recharts-".concat(d," ").concat(d),n),viewBox:l,ticks:p,axisType:d}))}var Mje={allowDataOverflow:Zi.allowDataOverflow,allowDecimals:Zi.allowDecimals,allowDuplicatedCategory:Zi.allowDuplicatedCategory,angle:Zi.angle,axisLine:lu.axisLine,hide:!1,includeHidden:Zi.includeHidden,interval:Zi.interval,label:!1,minTickGap:Zi.minTickGap,mirror:Zi.mirror,orientation:Zi.orientation,padding:Zi.padding,reversed:Zi.reversed,scale:Zi.scale,tick:Zi.tick,tickCount:Zi.tickCount,tickLine:lu.tickLine,tickSize:lu.tickSize,type:Zi.type,width:Zi.width,yAxisId:0},Nje=t=>{var e=Xr(t,Mje);return w.createElement(w.Fragment,null,w.createElement(wje,{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(Sje,e))},zS=w.memo(Nje,OJ);zS.displayName="YAxis";var Eje=(t,e)=>e,X4=et([Eje,$n,kZ,ua,yQ,ju,fMe,zi],vMe),Y4=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)}},LJ=Uo("mouseClick"),IJ=Cy();IJ.startListening({actionCreator:LJ,effect:(t,e)=>{var n=t.payload,r=X4(e.getState(),Y4(n));r?.activeIndex!=null&&e.dispatch(hSe({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var A3=Uo("mouseMove"),FJ=Cy(),L_=null;FJ.startListening({actionCreator:A3,effect:(t,e)=>{var n=t.payload;L_!==null&&cancelAnimationFrame(L_);var r=Y4(n);L_=requestAnimationFrame(()=>{var i=e.getState(),a=w4(i,i.tooltip.settings.shared);if(a==="axis"){var o=X4(i,r);o?.activeIndex!=null?e.dispatch(uQ({activeIndex:o.activeIndex,activeDataKey:void 0,activeCoordinate:o.activeCoordinate})):e.dispatch(cQ())}L_=null})}});function Aje(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 tV={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},UJ=Ts({name:"rootProps",initialState:tV,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:tV.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}}}),Tje=UJ.reducer,{updateOptions:Cje}=UJ.actions,kje=null,jje={updatePolarOptions:(t,e)=>e.payload},zJ=Ts({name:"polarOptions",initialState:kje,reducers:jje}),{updatePolarOptions:Pje}=zJ.actions,Rje=zJ.reducer,BJ=Uo("keyDown"),$J=Uo("focus"),Z4=Cy();Z4.startListening({actionCreator:BJ,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=S4(i,dx(n),Hy(n),Gy(n)),l=o==null?-1:Number(o);if(!(!Number.isFinite(l)||l<0)){var c=ju(n);if(a==="Enter"){var u=TS(n,"axis","hover",String(i.index));e.dispatch(p3({active:!i.active,activeIndex:i.index,activeCoordinate:u}));return}var d=nSe(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=TS(n,"axis","hover",String(p));e.dispatch(p3({active:!0,activeIndex:p.toString(),activeCoordinate:b}))}}}}}});Z4.startListening({actionCreator:$J,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=TS(n,"axis","hover",String(a));e.dispatch(p3({active:!0,activeIndex:a,activeCoordinate:o}))}}}});var xo=Uo("externalEvent"),HJ=Cy(),$C=new Map;HJ.startListening({actionCreator:xo,effect:(t,e)=>{var{handler:n,reactEvent:r}=t.payload;if(n!=null){r.persist();var i=r.type,a=$C.get(i);a!==void 0&&cancelAnimationFrame(a);var o=requestAnimationFrame(()=>{try{var l=e.getState(),c={activeCoordinate:QSe(l),activeDataKey:T4(l),activeIndex:nh(l),activeLabel:wQ(l),activeTooltipIndex:nh(l),isTooltipActive:JSe(l)};n(c,r)}finally{$C.delete(i)}});$C.set(i,o)}}});var Dje=et([cx],t=>t.tooltipItemPayloads),Oje=et([Dje,(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)}}}),VJ=Uo("touchMove"),GJ=Cy();GJ.startListening({actionCreator:VJ,effect:(t,e)=>{var n=t.payload;if(!(n.touches==null||n.touches.length===0)){var r=e.getState(),i=w4(r,r.tooltip.settings.shared);if(i==="axis"){var a=n.touches[0];if(a==null)return;var o=X4(r,Y4({clientX:a.clientX,clientY:a.clientY,currentTarget:n.currentTarget}));o?.activeIndex!=null&&e.dispatch(uQ({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(rY),f=(l=u.getAttribute(iY))!==null&&l!==void 0?l:void 0,m=ux(r).find(y=>y.id===f);if(d==null||m==null||f==null)return;var{dataKey:p}=m,b=Oje(r,d,f);e.dispatch(lQ({activeDataKey:p,activeIndex:d,activeCoordinate:b,activeGraphicalItemId:f}))}}}});var Lje=MX({brush:EAe,cartesianAxis:cAe,chartData:ZMe,errorBars:LTe,graphicalItems:x2e,layout:Ebe,legend:P0e,options:WMe,polarAxis:jEe,polarOptions:Rje,referenceElements:DAe,rootProps:Tje,tooltip:fSe,zIndex:DMe}),Ije=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"Chart";return Zxe({reducer:Lje,preloadedState:e,middleware:r=>{var i;return r({serializableCheck:!1,immutableCheck:!["commonjs","es6","production"].includes((i="es6")!==null&&i!==void 0?i:"")}).concat([IJ.middleware,FJ.middleware,Z4.middleware,HJ.middleware,GJ.middleware])},enhancers:r=>{var i=r;return typeof r=="function"&&(i=r()),i.concat(UX({type:"raf"}))},devTools:{serialize:{replacer:Aje},name:"recharts-".concat(n)}})};function WJ(t){var{preloadedState:e,children:n,reduxStoreName:r}=t,i=Bi(),a=w.useRef(null);if(i)return n;a.current==null&&(a.current=Ije(e,r));var o=lO;return w.createElement(uCe,{context:o,store:a.current},n)}function Fje(t){var{layout:e,margin:n}=t,r=Sr(),i=Bi();return w.useEffect(()=>{i||(r(Sbe(e)),r(wbe(n)))},[r,i,e,n]),null}var qJ=w.memo(Fje,Ky);function KJ(t){var e=Sr();return w.useEffect(()=>{e(Cje(t))},[e,t]),null}function nV(t){var{zIndex:e,isPanorama:n}=t,r=w.useRef(null),i=Sr();return w.useLayoutEffect(()=>(r.current&&i(PMe({zIndex:e,element:r.current,isPanorama:n})),()=>{i(RMe({zIndex:e,isPanorama:n}))}),[i,e,n]),w.createElement("g",{tabIndex:-1,ref:r})}function rV(t){var{children:e,isPanorama:n}=t,r=Wt(wMe);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(nV,{key:o,zIndex:o,isPanorama:n})),e,a.map(o=>w.createElement(nV,{key:o,zIndex:o,isPanorama:n})))}var Uje=["children"];function zje(t,e){if(t==null)return{};var n,r,i=Bje(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Bje(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function BS(){return BS=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},BS.apply(null,arguments)}var $je={width:"100%",height:"100%",display:"block"},Hje=w.forwardRef((t,e)=>{var n=bO(),r=yO(),i=vY();if(!ec(n)||!ec(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(ZD,BS({},o,{title:l,desc:c,role:d,tabIndex:u,width:n,height:r,style:$je,ref:e}),a)}),Vje=t=>{var{children:e}=t,n=Wt(RN);if(!n)return null;var{width:r,height:i,y:a,x:o}=n;return w.createElement(ZD,{width:r,height:i,x:o,y:a},e)},iV=w.forwardRef((t,e)=>{var{children:n}=t,r=zje(t,Uje),i=Bi();return i?w.createElement(Vje,null,w.createElement(rV,{isPanorama:!0},n)):w.createElement(Hje,BS({ref:e},r),w.createElement(rV,{isPanorama:!1},n))});function Gje(){var t=Sr(),[e,n]=w.useState(null),r=Wt($be);return w.useEffect(()=>{if(e!=null){var i=e.getBoundingClientRect(),a=i.width/e.offsetWidth;pn(a)&&a!==r&&t(Nbe(a))}},[e,t,r]),n}function aV(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 Wje(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?aV(Object(n),!0).forEach(function(r){qje(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):aV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function qje(t,e,n){return(e=Kje(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Kje(t){var e=Xje(t,"string");return typeof e=="symbol"?e:e+""}function Xje(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Vd(){return Vd=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},Vd.apply(null,arguments)}var Yje=()=>(sNe(),null);function $S(t){if(typeof t=="number")return t;if(typeof t=="string"){var e=parseFloat(t);if(!Number.isNaN(e))return e}return 0}var Zje=w.forwardRef((t,e)=>{var n,r,i=w.useRef(null),[a,o]=w.useState({containerWidth:$S((n=t.style)===null||n===void 0?void 0:n.width),containerHeight:$S((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(Py,{width:a.containerWidth,height:a.containerHeight}),w.createElement("div",Vd({ref:c},t)))}),Qje=w.forwardRef((t,e)=>{var{width:n,height:r}=t,[i,a]=w.useState({containerWidth:$S(n),containerHeight:$S(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(Py,{width:i.containerWidth,height:i.containerHeight}),w.createElement("div",Vd({ref:l},t)))}),Jje=w.forwardRef((t,e)=>{var{width:n,height:r}=t;return w.createElement(w.Fragment,null,w.createElement(Py,{width:n,height:r}),w.createElement("div",Vd({ref:e},t)))}),ePe=w.forwardRef((t,e)=>{var{width:n,height:r}=t;return typeof n=="string"||typeof r=="string"?w.createElement(Qje,Vd({},t,{ref:e})):typeof n=="number"&&typeof r=="number"?w.createElement(Jje,Vd({},t,{width:n,height:r,ref:e})):w.createElement(w.Fragment,null,w.createElement(Py,{width:n,height:r}),w.createElement("div",Vd({ref:e},t)))});function tPe(t){return t?Zje:ePe}var nPe=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,A=w.useRef(null),T=Sr(),[k,E]=w.useState(null),[O,C]=w.useState(null),D=Gje(),U=gO(),L=U?.width>0?U.width:v,q=U?.height>0?U.height:i,P=w.useCallback(me=>{D(me),typeof e=="function"&&e(me),E(me),C(me),me!=null&&(A.current=me)},[D,e,E,C]),W=w.useCallback(me=>{T(LJ(me)),T(xo({handler:a,reactEvent:me}))},[T,a]),K=w.useCallback(me=>{T(A3(me)),T(xo({handler:u,reactEvent:me}))},[T,u]),V=w.useCallback(me=>{T(cQ()),T(xo({handler:d,reactEvent:me}))},[T,d]),Q=w.useCallback(me=>{T(A3(me)),T(xo({handler:f,reactEvent:me}))},[T,f]),re=w.useCallback(()=>{T($J())},[T]),J=w.useCallback(me=>{T(BJ(me.key))},[T]),z=w.useCallback(me=>{T(xo({handler:o,reactEvent:me}))},[T,o]),G=w.useCallback(me=>{T(xo({handler:l,reactEvent:me}))},[T,l]),ne=w.useCallback(me=>{T(xo({handler:c,reactEvent:me}))},[T,c]),ae=w.useCallback(me=>{T(xo({handler:m,reactEvent:me}))},[T,m]),de=w.useCallback(me=>{T(xo({handler:y,reactEvent:me}))},[T,y]),fe=w.useCallback(me=>{M&&T(VJ(me)),T(xo({handler:b,reactEvent:me}))},[T,M,b]),ie=w.useCallback(me=>{T(xo({handler:p,reactEvent:me}))},[T,p]),Ae=tPe(S);return w.createElement(kQ.Provider,{value:k},w.createElement(zK.Provider,{value:O},w.createElement(Ae,{width:L??x?.width,height:q??x?.height,className:Vn("recharts-wrapper",r),style:Wje({position:"relative",cursor:"default",width:L,height:q},x),onClick:W,onContextMenu:z,onDoubleClick:G,onFocus:re,onKeyDown:J,onMouseDown:ne,onMouseEnter:K,onMouseLeave:V,onMouseMove:Q,onMouseUp:ae,onTouchEnd:ie,onTouchMove:fe,onTouchStart:de,ref:P},w.createElement(Yje,null),n)))}),rPe=["width","height","responsive","children","className","style","compact","title","desc"];function iPe(t,e){if(t==null)return{};var n,r,i=aPe(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 aPe(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 XJ=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=iPe(t,rPe),m=rs(f);return c?w.createElement(w.Fragment,null,w.createElement(Py,{width:n,height:r}),w.createElement(iV,{otherAttributes:m,title:u,desc:d},a)):w.createElement(nPe,{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(iV,{otherAttributes:m,title:u,desc:d,ref:e},w.createElement(OAe,null,a)))});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)}var sPe={top:5,right:5,bottom:5,left:5},oPe={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:sPe,responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},Q4=w.forwardRef(function(e,n){var r,i=Xr(e.categoricalChartProps,oPe),{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(WJ,{preloadedState:{options:d},reduxStoreName:(r=u.id)!==null&&r!==void 0?r:a},w.createElement(aJ,{chartData:u.data}),w.createElement(qJ,{layout:i.layout,margin:i.margin}),w.createElement(KJ,{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(XJ,T3({},i,{ref:n})))}),lPe=["axis"],cPe=w.forwardRef((t,e)=>w.createElement(Q4,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:lPe,tooltipPayloadSearcher:tE,categoricalChartProps:t,ref:e})),uPe=["axis","item"],dPe=w.forwardRef((t,e)=>w.createElement(Q4,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:uPe,tooltipPayloadSearcher:tE,categoricalChartProps:t,ref:e}));function hPe(t){var e=Sr();return w.useEffect(()=>{e(Pje(t))},[e,t]),null}var fPe=["layout"];function C3(){return C3=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},C3.apply(null,arguments)}function mPe(t,e){if(t==null)return{};var n,r,i=pPe(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 pPe(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 gPe={top:5,right:5,bottom:5,left:5},YJ={accessibilityLayer:!0,stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:gPe,reverseStackOrder:!1,syncMethod:"index",layout:"radial",responsive:!1,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"},xPe=w.forwardRef(function(e,n){var r,i=Xr(e.categoricalChartProps,YJ),{layout:a}=i,o=mPe(i,fPe),{chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d}=e,f={chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d,eventEmitter:void 0};return w.createElement(WJ,{preloadedState:{options:f},reduxStoreName:(r=i.id)!==null&&r!==void 0?r:l},w.createElement(aJ,{chartData:i.data}),w.createElement(qJ,{layout:a,margin:i.margin}),w.createElement(KJ,{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(hPe,{cx:i.cx,cy:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius}),w.createElement(XJ,C3({},o,{ref:n})))});function sV(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 oV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?sV(Object(n),!0).forEach(function(r){bPe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):sV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function bPe(t,e,n){return(e=yPe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function yPe(t){var e=vPe(t,"string");return typeof e=="symbol"?e:e+""}function vPe(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 _Pe=["item"],wPe=oV(oV({},YJ),{},{layout:"centric",startAngle:0,endAngle:360}),SPe=w.forwardRef((t,e)=>{var n=Xr(t,wPe);return w.createElement(xPe,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:_Pe,tooltipPayloadSearcher:tE,categoricalChartProps:n,ref:e})}),MPe=["axis"],NPe=w.forwardRef((t,e)=>w.createElement(Q4,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:MPe,tooltipPayloadSearcher:tE,categoricalChartProps:t,ref:e}));const lV=[{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 EPe({isOpen:t,onClose:e,printerId:n,printerName:r,amsId:i,amsLabel:a,initialMode:o="humidity",thresholds:l}){const{t:c}=Xg(),{mode:u}=hh(),[d,f]=w.useState("24h"),[m,p]=w.useState(o),b=u==="dark",{data:y}=ut({queryKey:["settings"],queryFn:he.getSettings}),x=y?.time_format||"system";w.useEffect(()=>{if(!t)return;const ae=de=>{de.key==="Escape"&&e()};return window.addEventListener("keydown",ae),()=>window.removeEventListener("keydown",ae)},[t,e]);const v=lV.find(ae=>ae.value===d)?.hours||24,{data:S,isLoading:M,error:A}=ut({queryKey:["ams-history",n,i,v],queryFn:()=>he.getAMSHistory(n,i,v),enabled:t,refetchInterval:6e4});if(!t)return null;const T=S?.data.map(ae=>{const de=Ni(ae.recorded_at)||new Date,fe={hour:"2-digit",minute:"2-digit",...v>24?{day:"numeric",month:"short"}:{}};return{time:de.getTime(),humidity:ae.humidity,temperature:ae.temperature,timeLabel:de.toLocaleTimeString([],a0(fe,x))}})||[],k=l?.humidityGood||40,E=l?.humidityFair||60,O=l?.tempGood||30,C=l?.tempFair||35,D=T[T.length-1],U=D?.humidity,L=D?.temperature,q=ae=>{const de=ae.filter(ye=>ye!=null);if(de.length<4)return"stable";const fe=de.slice(0,Math.floor(de.length/4)),ie=de.slice(-Math.floor(de.length/4)),Ae=fe.reduce((ye,le)=>ye+le,0)/fe.length,Ne=ie.reduce((ye,le)=>ye+le,0)/ie.length-Ae;return Math.abs(Ne)<2?"stable":Ne>0?"up":"down"},P=q(T.map(ae=>ae.humidity)),W=q(T.map(ae=>ae.temperature)),K=({trend:ae})=>ae==="up"?s.jsx(NP,{className:"w-4 h-4 text-red-400"}):ae==="down"?s.jsx(CK,{className:"w-4 h-4 text-green-400"}):s.jsx(wP,{className:"w-4 h-4 text-gray-400 dark:text-bambu-gray"}),V=ae=>ae==null?"#9ca3af":ae<=k?"#22a352":ae<=E?"#d4a017":"#c62828",Q=ae=>ae==null?"#9ca3af":ae<=O?"#22a352":ae<=C?"#d4a017":"#c62828",re=b?"#2d2d2d":"#ffffff",J=b?"#1d1d1d":"#f3f4f6",z=b?"#3d3d3d":"#e5e7eb",G=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:re},onClick:ae=>ae.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:G},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(Vt,{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:J},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($D,{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(pN,{className:"w-4 h-4"}),c("common.temperature","Temperature")]})]}),s.jsx("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor:J},children:lV.map(ae=>s.jsx("button",{onClick:()=>f(ae.value),className:`px-3 py-1 text-sm rounded-md transition-colors ${d===ae.value?"bg-bambu-green text-white":""}`,style:d!==ae.value?{color:ne}:void 0,children:ae.label},ae.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:J},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:V(U)},children:U!=null?`${U}%`:"—"}),s.jsx(K,{trend:P})]})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:J},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:G},children:S?.avg_humidity!=null?`${S.avg_humidity}%`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:J},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:J},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:J},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:Q(L)},children:L!=null?`${L}°C`:"—"}),s.jsx(K,{trend:W})]})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:J},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:G},children:S?.avg_temperature!=null?`${S.avg_temperature}°C`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:J},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:J},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:J},children:M?s.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:ne},children:c("common.loading","Loading...")}):A?s.jsx("div",{className:"h-[300px] flex items-center justify-center text-red-500",children:c("common.error","Error loading data")}):T.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(l1,{width:"100%",height:300,children:s.jsxs(cPe,{data:T,children:[s.jsx(OS,{strokeDasharray:"3 3",stroke:b?"#3d3d3d":"#e5e7eb"}),s.jsx(US,{dataKey:"time",type:"number",domain:["dataMin","dataMax"],tickFormatter:ae=>{const de=new Date(ae);return v>24?de.toLocaleDateString([],{day:"numeric",month:"short"}):de.toLocaleTimeString([],a0({hour:"2-digit",minute:"2-digit"},x))},stroke:b?"#9ca3af":"#6b7280",tick:{fontSize:12}}),s.jsx(zS,{stroke:b?"#9ca3af":"#6b7280",tick:{fontSize:12},domain:m==="humidity"?[0,100]:["auto","auto"],tickFormatter:ae=>m==="humidity"?`${ae}%`:`${ae}°C`}),s.jsx(u1,{contentStyle:{backgroundColor:b?"#2d2d2d":"#ffffff",border:`1px solid ${b?"#3d3d3d":"#e5e7eb"}`,borderRadius:"8px",color:b?"#fff":"#000"},labelFormatter:ae=>new Date(ae).toLocaleString(void 0,a0({year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"},x)),formatter:ae=>[m==="humidity"?`${ae??0}%`:`${ae??0}°C`,m==="humidity"?"Humidity":"Temperature"]}),s.jsx(SO,{}),m==="humidity"?s.jsxs(s.Fragment,{children:[s.jsx(Vb,{y:k,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),s.jsx(Vb,{y:E,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}):s.jsxs(s.Fragment,{children:[s.jsx(Vb,{y:O,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),s.jsx(Vb,{y:C,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}),s.jsx(vJ,{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 HC({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 E=document.createElement("textarea");E.value=k,E.style.position="fixed",E.style.opacity="0",document.body.appendChild(E),E.select();try{document.execCommand("copy"),f(!0),setTimeout(()=>f(!1),2e3)}catch{console.error("Failed to copy to clipboard")}document.body.removeChild(E)};w.useEffect(()=>{if(o&&m.current&&p.current){const k=m.current.getBoundingClientRect(),E=p.current.offsetHeight,O=k.top,C=window.innerHeight-k.bottom;O<E+12&&C>O?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",A=k=>{if(!k)return!1;const E=k.replace("#",""),O=parseInt(E.slice(0,2),16),C=parseInt(E.slice(2,4),16),D=parseInt(E.slice(4,6),16);return(.299*O+.587*C+.114*D)/255>.6},T=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:T||"#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
- ${A(T)?"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($D,{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(ns,{className:"w-3 h-3 text-bambu-green"}):s.jsx(ll,{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(Wl,{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(Jd,{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 cV({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(Jd,{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 APe({isOpen:t,onClose:e,trayUuid:n,trayInfo:r}){const i=on(),[a,o]=w.useState(null),{data:l,isLoading:c}=ut({queryKey:["unlinked-spools"],queryFn:he.getUnlinkedSpools,enabled:t}),u=mt({mutationFn:f=>he.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(Wl,{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(Vt,{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(dt,{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(ns,{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(Se,{variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(Se,{onClick:d,disabled:!a||u.isPending,children:u.isPending?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 animate-spin"}),"Linking..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Wl,{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 TPe(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 uV(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 CPe=["PLA","PETG","ABS","ASA","TPU","PC","PA","NYLON","PVA","HIPS","PP","PET"];function dV(t){const e=t.replace(/@.+$/,"").trim(),n=e.toUpperCase();for(const i of CPe){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 VC(t){return!t.startsWith("GF")&&!t.startsWith("P1")}const kPe={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"},jPe=[{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"}],PPe=[{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 RPe(t){const e=t.toLowerCase().trim();return kPe[e]||null}function DPe({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:A,isLoading:T}=ut({queryKey:["cloudSettings"],queryFn:()=>he.getCloudSettings(),enabled:t}),{data:k,isLoading:E}=ut({queryKey:["kprofiles",n,i],queryFn:()=>he.getKProfiles(n,i),enabled:t&&!!n}),O=mt({mutationFn:async()=>{if(!o)throw new Error("No filament preset selected");const Q=A?.filament.find(me=>me.setting_id===o);if(!Q)throw new Error("Selected preset not found");const re=dV(Q.name),J=c?.slot_id??-1,z=d||r.trayColor?.slice(0,6)||"FFFFFF",G=Q.name.replace(/@.+$/,"").trim();let ne=uV(o);if(!o.startsWith("GFS"))try{const me=await he.getCloudSettingDetail(o);me.filament_id?ne=me.filament_id:me.base_id&&(ne=uV(me.base_id),console.log(`Derived tray_info_idx from base_id: ${me.base_id} -> ${ne}`))}catch(me){console.warn("Failed to fetch preset detail for filament_id:",me)}let ae=190,de=230;const fe=re.material.toUpperCase();fe.includes("PLA")?(ae=190,de=230):fe.includes("PETG")?(ae=220,de=260):fe.includes("ABS")||fe.includes("ASA")?(ae=240,de=280):fe.includes("TPU")?(ae=200,de=240):fe.includes("PC")?(ae=260,de=300):(fe.includes("PA")||fe.includes("NYLON"))&&(ae=250,de=290);const ie=c?.k_value?parseFloat(c.k_value):0,Ae=await he.configureAmsSlot(n,r.amsId,r.trayId,{tray_info_idx:ne,tray_type:re.material||"PLA",tray_sub_brands:G,tray_color:z+"FF",nozzle_temp_min:ae,nozzle_temp_max:de,cali_idx:J,nozzle_diameter:i,setting_id:o,kprofile_filament_id:c?.filament_id,kprofile_setting_id:c?.setting_id||void 0,k_value:ie});try{await he.saveSlotPreset(n,r.amsId,r.trayId,o,G)}catch(me){console.warn("Failed to save slot preset mapping:",me)}return Ae},onSuccess:()=>{v(!0),a?.(),setTimeout(()=>{v(!1),e()},1500)}}),C=mt({mutationFn:async()=>he.resetAmsSlot(n,r.amsId,r.trayId),onSuccess:()=>{v(!0),a?.(),setTimeout(()=>{v(!1),e()},1500)}}),D=w.useMemo(()=>{if(!A?.filament)return[];const Q=b.toLowerCase();return A.filament.filter(re=>Q?re.name.toLowerCase().includes(Q):!0).sort((re,J)=>{const z=VC(re.setting_id),G=VC(J.setting_id);return z&&!G?-1:!z&&G?1:re.name.localeCompare(J.name)})},[A?.filament,b]),U=w.useMemo(()=>{if(!o||!A?.filament)return null;const Q=A.filament.find(z=>z.setting_id===o);if(!Q)return null;let re=Q.name.replace(/@.+$/,"").trim();re.startsWith("# ")&&(re=re.slice(2).trim());const J=dV(re);return{fullName:re,material:J.material,brand:J.brand}},[o,A?.filament]),L=U?.fullName||"",q=w.useMemo(()=>{if(!k?.profiles||!U)return[];const{fullName:Q,material:re,brand:J}=U,z=Q.toUpperCase(),G=re.toUpperCase(),ne=J.toUpperCase();if(!G||G.length<2)return[];const ae=k.profiles.filter(fe=>{const ie=fe.name.toUpperCase();if(ne)return!(!ie.includes(ne)||!ie.includes(G));if(ie.includes(z)||ie.includes(G))return!0;const me={NYLON:["PA","PA-CF","PA6"],PA:["NYLON"]}[G]||[];for(const Ne of me)if(ie.includes(Ne))return!0;return!1}),de=new Map;for(const fe of ae){const ie=`${fe.name}|${fe.k_value}`,Ae=de.get(ie);Ae?fe.extruder_id===1&&Ae.extruder_id===0&&de.set(ie,fe):de.set(ie,fe)}return Array.from(de.values())},[k?.profiles,U]);w.useEffect(()=>{if(t&&A?.filament){if(r.trayInfoIdx){const Q=A.filament.find(re=>re.setting_id===r.trayInfoIdx);Q&&l(Q.setting_id)}}else t||(l(""),u(null),f(""),p(""),y(""),v(!1))},[t,A?.filament,r.trayInfoIdx]),w.useEffect(()=>{q.length>0?u(q[0]):u(null)},[o,q]);const P=w.useCallback(Q=>{Q.key==="Escape"&&e()},[e]);if(w.useEffect(()=>{if(t)return document.addEventListener("keydown",P),()=>document.removeEventListener("keydown",P)},[t,P]),!t)return null;const W=T||E,K=o&&!O.isPending,V=d||r.trayColor?.slice(0,6)||"FFFFFF";return s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[s.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:e}),s.jsxs("div",{className:"relative w-full max-w-lg mx-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Jd,{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(Vt,{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(rN,{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:[TPe(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(dt,{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:Q=>y(Q.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:D.length===0?s.jsx("p",{className:"text-center py-4 text-bambu-gray",children:A?.filament?.length===0?"No cloud presets. Login to Bambu Cloud to sync.":"No matching presets found."}):D.map(Q=>s.jsx("button",{onClick:()=>l(Q.setting_id),className:`w-full p-2 rounded-lg border text-left transition-colors ${o===Q.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:Q.name}),VC(Q.setting_id)&&s.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-bambu-blue/20 text-bambu-blue",children:"Custom"})]})},Q.setting_id))})]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-2",children:["K Profile (Pressure Advance)",L&&s.jsxs("span",{className:"ml-2 text-xs text-bambu-blue",children:["Filtering for: ",L]})]}),q.length>0?s.jsxs("div",{className:"relative",children:[s.jsxs("select",{value:c?.name||"",onChange:Q=>{const re=q.find(J=>J.name===Q.target.value);u(re||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(Q=>s.jsxs("option",{value:Q.name,children:[Q.name," (K=",Q.k_value,")"]},`${Q.name}-${Q.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:[jPe.map(Q=>s.jsx("button",{onClick:()=>{f(Q.hex),p(Q.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${d===Q.hex?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:`#${Q.hex}`},title:Q.name},Q.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:PPe.map(Q=>s.jsx("button",{onClick:()=>{f(Q.hex),p(Q.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${d===Q.hex?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:`#${Q.hex}`},title:Q.name},Q.hex))}),s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsx("div",{className:"w-10 h-10 rounded-lg border-2 border-white/20 flex-shrink-0",style:{backgroundColor:`#${V}`}}),s.jsx("input",{type:"text",placeholder:"Color name or hex (e.g., brown, FF8800)",value:m,onChange:Q=>{const re=Q.target.value;p(re);const J=RPe(re);if(J)f(J);else{const z=re.replace(/[^0-9A-Fa-f]/g,"").toUpperCase();z.length===6?f(z):z.length===3&&f(z.split("").map(G=>G+G).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(Se,{variant:"secondary",onClick:()=>C.mutate(),disabled:C.isPending||O.isPending,className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:C.isPending?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 animate-spin"}),"Resetting..."]}):s.jsxs(s.Fragment,{children:[s.jsx(mm,{className:"w-4 h-4"}),"Reset Slot"]})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Se,{variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(Se,{onClick:()=>O.mutate(),disabled:!K,children:O.isPending?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 animate-spin"}),"Configuring..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Jd,{className:"w-4 h-4"}),"Configure Slot"]})})]})]}),(O.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:O.error?.message||C.error?.message})]})]})}function OPe({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 hV=({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"})]}),fV={"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"},LPe={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 GC(t){if(!t)return null;if(fV[t])return fV[t];const e=t.split("-");if(e.length<2)return null;const n=e[1];return LPe[n]||null}function WC(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 qC(t){return(t??.02).toFixed(3)}function mV({side:t}){const{mode:e}=hh(),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 pV({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 IPe({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 FPe({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 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("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 zPe({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 BPe({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 KC({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 gV({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=pV:a<=l?d=IPe:d=FPe,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 xV({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=UPe):t<=o?(l="#d4a017",c="Fair",u=zPe):(l="#c62828",c="Bad",u=BPe),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 nd(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 bV(t){return t>50?"#00ae42":t>=15?"#f59e0b":"#ef4444"}function $Pe(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function HPe(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 VPe(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 GPe(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 XC(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 WPe({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(Hs,{className:"w-8 h-8 text-bambu-gray"})]}):s.jsx(Hs,{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 qPe({printers:t}){const e=on(),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 yV(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 vV({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=on(),m=gl(),{showToast:p}=qn(),[b,y]=w.useState(!1),[x,v]=w.useState(!1),[S,M]=w.useState(!0),[A,T]=w.useState(!1),[k,E]=w.useState(!1),[O,C]=w.useState(!1),[D,U]=w.useState(!1),[L,q]=w.useState(!1),[P,W]=w.useState(!1),[K,V]=w.useState(!1),[Q,re]=w.useState(!1),[J,z]=w.useState(!1),[G,ne]=w.useState(!1),[ae,de]=w.useState(null),[fe,ie]=w.useState(null),[Ae,me]=w.useState(null),[Ne,ye]=w.useState(!1),[le,$e]=w.useState(null),[H,ee]=w.useState(!1),[X,B]=w.useState(!1),[I,ce]=w.useState(null),[Te,Le]=w.useState(!1),[Ee,$]=w.useState(!1),{data:j}=ut({queryKey:["printerStatus",t.id],queryFn:()=>he.getPrinterStatus(t.id),refetchInterval:3e4}),{data:Y}=ut({queryKey:["firmwareUpdate",t.id],queryFn:()=>i1.checkPrinterUpdate(t.id),staleTime:300*1e3,refetchInterval:300*1e3}),ge=w.useMemo(()=>{const Pe=new Set;if(j?.ams)for(const wt of j.ams)for(const Mt of wt.tray||[])Mt.tray_info_idx&&Pe.add(Mt.tray_info_idx);return j?.vt_tray?.tray_info_idx&&Pe.add(j.vt_tray.tray_info_idx),Array.from(Pe)},[j?.ams,j?.vt_tray]),{data:we}=ut({queryKey:["filamentInfo",ge],queryFn:()=>he.getFilamentInfo(ge),enabled:ge.length>0,staleTime:300*1e3}),{data:ve}=ut({queryKey:["slotPresets",t.id],queryFn:()=>he.getSlotPresets(t.id),staleTime:120*1e3}),[Ze,Ie]=w.useState(null);w.useEffect(()=>{j?.wifi_signal!=null&&Ie(j.wifi_signal)},[j?.wifi_signal]);const qe=j?.wifi_signal??Ze,Je=w.useRef(void 0);w.useEffect(()=>{j?.connected!==void 0&&(Je.current=j.connected)},[j?.connected]);const Qe=j?.connected??Je.current,oe=w.useRef({});w.useEffect(()=>{j?.ams_extruder_map&&Object.keys(j.ams_extruder_map).length>0&&(oe.current=j.ams_extruder_map)},[j?.ams_extruder_map]);const te=j?.ams_extruder_map&&Object.keys(j.ams_extruder_map).length>0?j.ams_extruder_map:oe.current,Me=w.useRef([]);w.useEffect(()=>{j?.ams&&j.ams.length>0&&(Me.current=j.ams)},[j?.ams]);const Fe=j?.ams&&j.ams.length>0?j.ams:Me.current,ot=w.useRef(255),se=j?.tray_now;se!==void 0&&se!==255&&(ot.current=se);const je=se===void 0||se===255?ot.current:se,{data:xe}=ut({queryKey:["smartPlugByPrinter",t.id],queryFn:()=>he.getSmartPlugByPrinter(t.id)}),{data:Oe}=ut({queryKey:["smartPlugStatus",xe?.id],queryFn:()=>xe?he.getSmartPlugStatus(xe.id):null,enabled:!!xe,refetchInterval:1e4}),{data:Ue}=ut({queryKey:["queue",t.id,"pending"],queryFn:()=>he.getQueue(t.id,"pending")}),Ce=Ue?.length||0,{data:We}=ut({queryKey:["archives",t.id,"last"],queryFn:()=>he.getArchives(t.id,1,0),enabled:j?.connected&&j?.state!=="RUNNING"}),pt=We?.[0],kt=e&&Qe===!1,Lt=mt({mutationFn:Pe=>he.deletePrinter(t.id,Pe.deleteArchives),onSuccess:()=>{f.invalidateQueries({queryKey:["printers"]}),f.invalidateQueries({queryKey:["archives"]}),f.invalidateQueries({queryKey:["maintenanceOverview"]})}}),ln=mt({mutationFn:()=>he.connectPrinter(t.id),onSuccess:()=>{f.invalidateQueries({queryKey:["printerStatus",t.id]})}}),Gt=mt({mutationFn:Pe=>xe?he.controlSmartPlug(xe.id,Pe):Promise.reject("No plug"),onSuccess:()=>{f.invalidateQueries({queryKey:["smartPlugStatus",xe?.id]})}}),_n=mt({mutationFn:Pe=>xe?he.updateSmartPlug(xe.id,{auto_off:Pe}):Promise.reject("No plug"),onSuccess:()=>{f.invalidateQueries({queryKey:["smartPlugByPrinter",t.id]}),f.invalidateQueries({queryKey:["smart-plugs"]})}}),gt=mt({mutationFn:()=>he.stopPrint(t.id),onSuccess:()=>{p("Print stopped"),f.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:Pe=>p(Pe.message||"Failed to stop print","error")}),Kt=mt({mutationFn:()=>he.pausePrint(t.id),onSuccess:()=>{p("Print paused"),f.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:Pe=>p(Pe.message||"Failed to pause print","error")}),bn=mt({mutationFn:()=>he.resumePrint(t.id),onSuccess:()=>{p("Print resumed"),f.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:Pe=>p(Pe.message||"Failed to resume print","error")}),At=mt({mutationFn:Pe=>he.setChamberLight(t.id,Pe),onMutate:async Pe=>{await f.cancelQueries({queryKey:["printerStatus",t.id]});const wt=f.getQueryData(["printerStatus",t.id]);return f.setQueryData(["printerStatus",t.id],Mt=>({...Mt,chamber_light:Pe})),{previousStatus:wt}},onSuccess:(Pe,wt)=>{p(`Chamber light ${wt?"on":"off"}`)},onError:(Pe,wt,Mt)=>{Mt?.previousStatus&&f.setQueryData(["printerStatus",t.id],Mt.previousStatus),p(Pe.message||"Failed to control chamber light","error")}}),Pr=mt({mutationFn:Pe=>he.updatePrinter(t.id,{plate_detection_enabled:Pe}),onSuccess:()=>{f.invalidateQueries({queryKey:["printers"]}),p(Pr.variables?"Plate check enabled":"Plate check disabled")},onError:Pe=>p(Pe.message||"Failed to update setting","error")}),yr=(j?.state==="RUNNING"||j?.state==="PAUSE"||j?.state==="PAUSED")&&(j?.printable_objects_count??0)>=2,{data:jn,refetch:sn}=ut({queryKey:["printableObjects",t.id],queryFn:()=>he.getPrintableObjects(t.id),enabled:G||yr,refetchInterval:G?5e3:yr?3e4:!1}),Rr=mt({mutationFn:Pe=>he.skipObjects(t.id,Pe),onSuccess:Pe=>{p(Pe.message||"Objects skipped"),sn()},onError:Pe=>p(Pe.message||"Failed to skip objects","error")}),[Gr,Dr]=w.useState(null),_e=w.useRef(!1),Ve=w.useRef(null),at=w.useRef(!1),ct=mt({mutationFn:({amsId:Pe,slotId:wt})=>he.refreshAmsSlot(t.id,Pe,wt),onMutate:({amsId:Pe,slotId:wt})=>{Ve.current&&clearTimeout(Ve.current),_e.current=!1,at.current=!1,Dr({amsId:Pe,slotId:wt}),setTimeout(()=>{at.current=!0},2e3),Ve.current=setTimeout(()=>{Dr(null)},3e4)},onSuccess:Pe=>{p(Pe.message||"RFID re-read initiated")},onError:Pe=>{p(Pe.message||"Failed to re-read RFID","error"),Ve.current&&clearTimeout(Ve.current),Dr(null)}}),[rt,jt]=w.useState(null),[zt,Xt]=w.useState(null),Yt=async()=>{try{const Pe=await he.getPlateReferences(t.id);jt(Pe)}catch{}},ue=()=>{Pr.mutate(!t.plate_detection_enabled)},Re=async()=>{ee(!0),$e(null);const Pe=j?.chamber_light===!1;$(Pe),Pe&&(await he.setChamberLight(t.id,!0),await new Promise(wt=>setTimeout(wt,2500)));try{const wt=await he.checkPlateEmpty(t.id,{includeDebugImage:!0});$e(wt),Yt()}catch(wt){p(wt instanceof Error?wt.message:"Failed to check plate","error"),Pe&&(await he.setChamberLight(t.id,!1),$(!1))}finally{ee(!1)}},He=w.useCallback(async()=>{$e(null),Ee&&(await he.setChamberLight(t.id,!1),$(!1))},[Ee,t.id]),Xe=async Pe=>{B(!0);try{const wt=await he.calibratePlateDetection(t.id,{label:Pe});if(wt.success){p(wt.message||"Calibration saved!","success"),Yt();const Mt=await he.checkPlateEmpty(t.id,{includeDebugImage:!0});$e(Mt)}else p(wt.message||"Calibration failed","error")}catch(wt){p(wt instanceof Error?wt.message:"Calibration failed","error")}finally{B(!1)}},Ge=async(Pe,wt)=>{try{await he.updatePlateReferenceLabel(t.id,Pe,wt),Xt(null),Yt()}catch(Mt){p(Mt instanceof Error?Mt.message:"Failed to update label","error")}},ht=async Pe=>{try{await he.deletePlateReference(t.id,Pe),p("Reference deleted","success"),Yt();const wt=await he.checkPlateEmpty(t.id,{includeDebugImage:!0});$e(wt)}catch(wt){p(wt instanceof Error?wt.message:"Failed to delete reference","error")}},Pt=async()=>{if(I){Le(!0);try{await he.updatePrinter(t.id,{plate_detection_roi:I}),p("Detection area saved","success"),ce(null);const Pe=await he.checkPlateEmpty(t.id,{includeDebugImage:!0});$e(Pe)}catch(Pe){p(Pe instanceof Error?Pe.message:"Failed to save detection area","error")}finally{Le(!1)}}};w.useEffect(()=>{const Pe=wt=>{wt.key==="Escape"&&le&&He()};return window.addEventListener("keydown",Pe),()=>window.removeEventListener("keydown",Pe)},[le,He]);const _t=w.useRef(null);w.useEffect(()=>{if(!Gr)return;const Pe=j?.ams_status_main??0;return Pe!==0&&(_e.current=!0,_t.current&&(clearTimeout(_t.current),_t.current=null)),_e.current&&Pe===0&&(at.current?(Ve.current&&clearTimeout(Ve.current),Dr(null)):_t.current||(_t.current=setTimeout(()=>{Ve.current&&clearTimeout(Ve.current),Dr(null)},2e3))),()=>{_t.current&&clearTimeout(_t.current)}},[j?.ams_status_main,Gr]);const[yt,It]=w.useState(null);if(kt)return null;const Ot=()=>{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"}},Ft=()=>{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"}},be=()=>{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(St,{className:"relative",children:[s.jsxs(Nt,{className:i>=3?"p-5":"",children:[s.jsxs("div",{className:be(),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:VPe(t.model),alt:t.model||"Printer",className:`object-contain rounded-lg bg-bambu-dark flex-shrink-0 ${Ot()}`}),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 ${Ft()}`,children:t.name}),r==="compact"&&s.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${j?.connected?"bg-status-ok":"bg-status-error"}`,title:j?.connected?"Connected":"Offline"})]}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:[t.model||"Unknown Model",r==="expanded"&&j?.nozzles&&j.nozzles[0]?.nozzle_diameter&&s.jsxs("span",{className:"ml-1.5 text-bambu-gray",title:j.nozzles[0].nozzle_type||"Nozzle",children:["• ",j.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(Zn,{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(Se,{variant:"ghost",size:"sm",onClick:()=>y(!b),children:s.jsx(zd,{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:()=>{T(!0),y(!1)},children:[s.jsx(la,{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:()=>{ln.mutate(),y(!1)},children:[s.jsx(xr,{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(TK,{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(dn,{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 ${j?.connected?"bg-status-ok/20 text-status-ok":"bg-status-error/20 text-status-error"}`,children:[j?.connected?s.jsx(Jg,{className:"w-3 h-3"}):s.jsx(WD,{className:"w-3 h-3"}),j?.connected?"Connected":"Offline"]}),j?.connected&&qe!=null&&s.jsxs("span",{className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs ${qe>=-50||qe>=-60?"bg-status-ok/20 text-status-ok":qe>=-70?"bg-status-warning/20 text-status-warning":qe>=-80?"bg-orange-500/20 text-orange-600":"bg-status-error/20 text-status-error"}`,title:`WiFi: ${qe} dBm - ${GPe(qe).label}`,children:[s.jsx(Gfe,{className:"w-3 h-3"}),qe,"dBm"]}),j?.connected&&(()=>{const Pe=j.hms_errors?dpe(j.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 ${Pe.length>0?Pe.some(wt=>wt.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(kn,{className:"w-3 h-3"}),Pe.length>0?Pe.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(eh,{className:"w-3 h-3"}),n.due_count>0||n.warning_count>0?n.due_count+n.warning_count:"OK"]}),Ce>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:`${Ce} print${Ce>1?"s":""} in queue`,children:[s.jsx(ul,{className:"w-3 h-3"}),Ce]}),Y?.update_available&&s.jsxs("button",{onClick:()=>ye(!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: ${Y.current_version} → ${Y.latest_version}`,children:[s.jsx(Hr,{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(St,{className:"w-full max-w-md mx-4",children:s.jsxs(Nt,{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(kn,{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:Pe=>M(Pe.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(Se,{variant:"secondary",onClick:()=>{v(!1),M(!0)},children:"Cancel"}),s.jsx(Se,{variant:"danger",onClick:()=>{Lt.mutate({deleteArchives:S}),v(!1),M(!0)},children:"Delete"})]})]})})}),j?.connected&&s.jsxs(s.Fragment,{children:[r==="compact"?s.jsx("div",{className:"mt-2",children:j.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:`${j.progress||0}%`}})}),s.jsxs("span",{className:"text-xs text-white",children:[Math.round(j.progress||0),"%"]})]}):s.jsx("p",{className:"text-xs text-bambu-gray",children:yV(j.state,j.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:!(j.state==="RUNNING"||j.state==="PAUSE"||j.state==="PAUSED")||(j.printable_objects_count??0)<2,className:`absolute top-2 right-2 p-1.5 rounded transition-colors z-10 ${(j.state==="RUNNING"||j.state==="PAUSE"||j.state==="PAUSED")&&(j.printable_objects_count??0)>=2?"text-bambu-gray hover:text-white hover:bg-white/10":"text-bambu-gray/30 cursor-not-allowed"}`,title:j.state==="RUNNING"||j.state==="PAUSE"||j.state==="PAUSED"?(j.printable_objects_count??0)>=2?"Skip objects":"Skip objects (requires 2+ objects)":"Skip objects (only while printing)",children:[s.jsx(hV,{className:"w-4 h-4"}),jn&&jn.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:jn.skipped_count})]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx(WPe,{url:j.state==="RUNNING"?j.cover_url:null,printName:j.state==="RUNNING"&&(j.subtask_name||j.current_print)||void 0}),s.jsx("div",{className:"flex-1 min-w-0",children:j.current_print&&j.state==="RUNNING"?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:j.stg_cur_name||"Printing"}),s.jsx("p",{className:"text-white text-sm mb-2 truncate",children:j.subtask_name||j.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:`${j.progress||0}%`}})}),s.jsxs("span",{className:"text-white",children:[Math.round(j.progress||0),"%"]})]}),s.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-bambu-gray",children:[j.remaining_time!=null&&j.remaining_time>0&&s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(Zn,{className:"w-3 h-3"}),$Pe(j.remaining_time*60)]}),s.jsxs("span",{className:"text-bambu-green font-medium",title:"Estimated completion time",children:["ETA ",HPe(j.remaining_time,c)]})]}),j.layer_num!=null&&j.total_layers!=null&&j.total_layers>0&&s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(ul,{className:"w-3 h-3"}),j.layer_num,"/",j.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:yV(j.state,j.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:"—"})]}),pt?s.jsxs("p",{className:"text-xs text-bambu-gray mt-2 truncate",title:pt.print_name||pt.filename,children:["Last: ",pt.print_name||pt.filename,pt.completed_at&&s.jsxs("span",{className:"ml-1 text-bambu-gray/60",children:["• ",_g(pt.completed_at,{month:"short",day:"numeric"})]})]}):s.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:"Ready to print"})]})})]})]}),j.state!=="RUNNING"&&s.jsx(ppe,{printerId:t.id})]}),j.temperatures&&r==="expanded"&&(()=>{const Pe=j.temperatures.nozzle_heating||j.temperatures.nozzle_2_heating||!1,wt=j.temperatures.bed_heating||!1,Mt=j.temperatures.chamber_heating||!1,lt=t.nozzle_count===2||j.temperatures.nozzle_2!==void 0,Tt=j.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(KC,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-orange-400",isHeating:Pe}),j.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(j.temperatures.nozzle||0),"° / ",Math.round(j.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(j.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(KC,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-blue-400",isHeating:wt}),s.jsx("p",{className:"text-[9px] text-bambu-gray",children:"Bed"}),s.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(j.temperatures.bed||0),"°C"]})]}),j.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(KC,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-green-400",isHeating:Mt}),s.jsx("p",{className:"text-[9px] text-bambu-gray",children:"Chamber"}),s.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(j.temperatures.chamber||0),"°C"]})]}),lt&&s.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg",title:`Active: ${Tt==="L"?"Left":"Right"} nozzle`,children:[s.jsx("p",{className:`text-[11px] font-bold ${Tt==="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 ${Tt==="R"?"text-amber-400":"text-gray-500"}`,children:"R"})]})]})})(),r==="expanded"&&(()=>{const Pe=j.state==="RUNNING",wt=j.state==="PAUSED"||j.state==="PAUSE",Mt=Pe||wt,lt=gt.isPending||Kt.isPending||bn.isPending,Tt=j.cooling_fan_speed,Rt=j.big_fan1_speed,$t=j.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 ${Tt&&Tt>0?"bg-cyan-500/10":"bg-bambu-dark"}`,title:"Part Cooling Fan",children:[s.jsx(xK,{className:`w-3.5 h-3.5 ${Tt&&Tt>0?"text-cyan-400":"text-bambu-gray/50"}`}),s.jsxs("span",{className:`text-[10px] ${Tt&&Tt>0?"text-cyan-400":"text-bambu-gray/50"}`,children:[Tt??0,"%"]})]}),s.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${Rt&&Rt>0?"bg-blue-500/10":"bg-bambu-dark"}`,title:"Auxiliary Fan",children:[s.jsx(kK,{className:`w-3.5 h-3.5 ${Rt&&Rt>0?"text-blue-400":"text-bambu-gray/50"}`}),s.jsxs("span",{className:`text-[10px] ${Rt&&Rt>0?"text-blue-400":"text-bambu-gray/50"}`,children:[Rt??0,"%"]})]}),s.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${$t&&$t>0?"bg-green-500/10":"bg-bambu-dark"}`,title:"Chamber Fan",children:[s.jsx(Aue,{className:`w-3.5 h-3.5 ${$t&&$t>0?"text-green-400":"text-bambu-gray/50"}`}),s.jsxs("span",{className:`text-[10px] ${$t&&$t>0?"text-green-400":"text-bambu-gray/50"}`,children:[$t??0,"%"]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{onClick:()=>V(!0),disabled:!Mt||lt,className:`
- flex items-center justify-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium
- transition-colors
- ${Mt?"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(Io,{className:"w-3 h-3"}),"Stop"]}),s.jsxs("button",{onClick:()=>wt?z(!0):re(!0),disabled:!Mt||lt,className:`
- flex items-center justify-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium
- transition-colors
- ${Mt?wt?"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:wt?"Resume print":"Pause print",children:[wt?s.jsx(Oo,{className:"w-3 h-3"}):s.jsx(VD,{className:"w-3 h-3"}),wt?"Resume":"Pause"]})]})]})]})})(),Fe&&Fe.length>0&&r==="expanded"&&(()=>{const Pe=Fe.filter(lt=>lt.tray.length>1),wt=Fe.filter(lt=>lt.tray.length===1),Mt=t.nozzle_count===2||j?.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:[Pe.length>0&&s.jsx("div",{className:"grid grid-cols-2 gap-3",children:Pe.map(lt=>{const Tt=te[String(lt.id)],Rt=lt.id>=128?lt.id-128:lt.id,$t=Tt!==void 0?Tt:Rt,Ln=$t===1,bi=$t===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:nd(lt.id,lt.tray.length)}),Mt&&(Ln||bi)&&s.jsx(mV,{side:Ln?"L":"R"})]}),(lt.humidity!=null||lt.temp!=null)&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[lt.humidity!=null&&s.jsx(gV,{humidity:lt.humidity,goodThreshold:a?.humidityGood,fairThreshold:a?.humidityFair,onClick:()=>de({amsId:lt.id,amsLabel:nd(lt.id,lt.tray.length),mode:"humidity"}),compact:!0}),lt.temp!=null&&s.jsx(xV,{temp:lt.temp,goodThreshold:a?.tempGood,fairThreshold:a?.tempFair,onClick:()=>de({amsId:lt.id,amsLabel:nd(lt.id,lt.tray.length),mode:"temperature"}),compact:!0})]})]}),s.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:[0,1,2,3].map(Qt=>{const cn=lt.tray[Qt]||lt.tray.find(Gi=>Gi.id===Qt),An=cn?.tray_type&&cn.remain>=0,Or=!cn?.tray_type,Lr=lt.id*4+Qt,di=je===Lr,hi=cn?.tray_info_idx?we?.[cn.tray_info_idx]:null,cs=ve?.[Lr],Er=cn?.tray_type?{vendor:XC(cn)?"Bambu Lab":"Generic",profile:hi?.name||cs?.preset_name||cn.tray_sub_brands||cn.tray_type,colorName:GC(cn.tray_id_name)||WC(cn.tray_color),colorHex:cn.tray_color||null,kFactor:qC(cn.k),fillLevel:An?cn.remain:null,trayUuid:cn.tray_uuid||null}:null,mc=Gr?.amsId===lt.id&&Gr?.slotId===Qt,Mh=s.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${Or?"opacity-50":""} ${di?"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:cn?.tray_color?`#${cn.tray_color}`:cn?.tray_type?"#333":"transparent",borderColor:Or?"#666":"rgba(255,255,255,0.1)",borderStyle:Or?"dashed":"solid"}}),s.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:cn?.tray_type||"—"}),s.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:An&&cn?s.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${cn.remain}%`,backgroundColor:bV(cn.remain)}}):cn?.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:[mc&&s.jsx("div",{className:"absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20",children:s.jsx(xr,{className:"w-4 h-4 text-bambu-green animate-spin"})}),j?.state!=="RUNNING"&&s.jsx("button",{onClick:Gi=>{Gi.stopPropagation(),It(yt?.amsId===lt.id&&yt?.slotId===Qt?null:{amsId:lt.id,slotId:Qt})},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(zd,{className:"w-2.5 h-2.5 text-bambu-gray"})}),j?.state!=="RUNNING"&&yt?.amsId===lt.id&&yt?.slotId===Qt&&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:Gi=>{Gi.stopPropagation(),ct.mutate({amsId:lt.id,slotId:Qt}),It(null)},disabled:mc,children:[s.jsx(xr,{className:`w-3 h-3 ${mc?"animate-spin":""}`}),"Re-read RFID"]})}),Er?s.jsx(HC,{data:Er,spoolman:{enabled:o,hasUnlinkedSpools:l,onLinkSpool:o&&Er.trayUuid?Gi=>{ie({trayUuid:Gi,trayInfo:{type:Er.profile,color:Er.colorHex||"",location:`${nd(lt.id,lt.tray.length)} Slot ${Qt+1}`}})}:void 0},configureSlot:{enabled:!0,onConfigure:()=>me({amsId:lt.id,trayId:Qt,trayCount:lt.tray.length,trayType:cn?.tray_type||void 0,trayColor:cn?.tray_color||void 0,traySubBrands:cn?.tray_sub_brands||void 0,trayInfoIdx:cn?.tray_info_idx||void 0})},children:Mh}):s.jsx(cV,{configureSlot:{enabled:!0,onConfigure:()=>me({amsId:lt.id,trayId:Qt,trayCount:lt.tray.length})},children:Mh})]},Qt)})})]},lt.id)})}),(wt.length>0||j.vt_tray&&j.vt_tray.tray_type)&&s.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[wt.map(lt=>{const Tt=te[String(lt.id)],Rt=lt.id>=128?lt.id-128:lt.id,$t=Tt!==void 0?Tt:Rt,Ln=$t===1,bi=$t===0,Qt=lt.tray[0],cn=Qt?.tray_type&&Qt.remain>=0,An=!Qt?.tray_type,Or=lt.id*4+(Qt?.id??0),Lr=je===Or,di=Qt?.tray_info_idx?we?.[Qt.tray_info_idx]:null,hi=ve?.[Or],cs=Qt?.tray_type?{vendor:XC(Qt)?"Bambu Lab":"Generic",profile:di?.name||hi?.preset_name||Qt.tray_sub_brands||Qt.tray_type,colorName:GC(Qt.tray_id_name)||WC(Qt.tray_color),colorHex:Qt.tray_color||null,kFactor:qC(Qt.k),fillLevel:cn?Qt.remain:null,trayUuid:Qt.tray_uuid||null}:null,Er=Qt?.id??0,mc=Gr?.amsId===lt.id&&Gr?.slotId===Er,Mh=s.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${An?"opacity-50":""} ${Lr?"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:Qt?.tray_color?`#${Qt.tray_color}`:Qt?.tray_type?"#333":"transparent",borderColor:An?"#666":"rgba(255,255,255,0.1)",borderStyle:An?"dashed":"solid"}}),s.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:Qt?.tray_type||"—"}),s.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:cn?s.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${Qt.remain}%`,backgroundColor:bV(Qt.remain)}}):Qt?.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:nd(lt.id,lt.tray.length)}),Mt&&(Ln||bi)&&s.jsx(mV,{side:Ln?"L":"R"})]}),s.jsxs("div",{className:"flex gap-1.5",children:[s.jsxs("div",{className:"relative group flex-1",children:[mc&&s.jsx("div",{className:"absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20",children:s.jsx(xr,{className:"w-4 h-4 text-bambu-green animate-spin"})}),j?.state!=="RUNNING"&&s.jsx("button",{onClick:Gi=>{Gi.stopPropagation(),It(yt?.amsId===lt.id&&yt?.slotId===Er?null:{amsId:lt.id,slotId:Er})},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(zd,{className:"w-2.5 h-2.5 text-bambu-gray"})}),j?.state!=="RUNNING"&&yt?.amsId===lt.id&&yt?.slotId===Er&&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:Gi=>{Gi.stopPropagation(),ct.mutate({amsId:lt.id,slotId:Er}),It(null)},disabled:mc,children:[s.jsx(xr,{className:`w-3 h-3 ${mc?"animate-spin":""}`}),"Re-read RFID"]})}),cs?s.jsx(HC,{data:cs,spoolman:{enabled:o,hasUnlinkedSpools:l,onLinkSpool:o&&cs.trayUuid?Gi=>{ie({trayUuid:Gi,trayInfo:{type:cs.profile,color:cs.colorHex||"",location:nd(lt.id,lt.tray.length)}})}:void 0},configureSlot:{enabled:!0,onConfigure:()=>me({amsId:lt.id,trayId:Er,trayCount:lt.tray.length,trayType:Qt?.tray_type||void 0,trayColor:Qt?.tray_color||void 0,traySubBrands:Qt?.tray_sub_brands||void 0,trayInfoIdx:Qt?.tray_info_idx||void 0})},children:Mh}):s.jsx(cV,{configureSlot:{enabled:!0,onConfigure:()=>me({amsId:lt.id,trayId:Er,trayCount:lt.tray.length})},children:Mh})]}),(lt.humidity!=null||lt.temp!=null)&&s.jsxs("div",{className:"flex flex-col justify-center gap-1 shrink-0",children:[lt.temp!=null&&s.jsx(xV,{temp:lt.temp,goodThreshold:a?.tempGood,fairThreshold:a?.tempFair,onClick:()=>de({amsId:lt.id,amsLabel:nd(lt.id,lt.tray.length),mode:"temperature"}),compact:!0}),lt.humidity!=null&&s.jsx(gV,{humidity:lt.humidity,goodThreshold:a?.humidityGood,fairThreshold:a?.humidityFair,onClick:()=>de({amsId:lt.id,amsLabel:nd(lt.id,lt.tray.length),mode:"humidity"}),compact:!0})]})]})]},lt.id)}),j.vt_tray&&j.vt_tray.tray_type&&(()=>{const lt=j.vt_tray,Tt=je===254,Rt=lt.tray_info_idx?we?.[lt.tray_info_idx]:null,$t=ve?.[1020],Ln={vendor:XC(lt)?"Bambu Lab":"Generic",profile:Rt?.name||$t?.preset_name||lt.tray_sub_brands||lt.tray_type||"Unknown",colorName:GC(lt.tray_id_name)||WC(lt.tray_color),colorHex:lt.tray_color||null,kFactor:qC(lt.k),fillLevel:null,trayUuid:lt.tray_uuid||null},bi=s.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center cursor-default ${Tt?"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:lt.tray_color?`#${lt.tray_color}`:"#333",borderColor:Tt?"var(--accent)":"rgba(255,255,255,0.1)"}}),s.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:lt.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(HC,{data:Ln,spoolman:{enabled:o,hasUnlinkedSpools:l,onLinkSpool:o&&Ln.trayUuid?Qt=>{ie({trayUuid:Qt,trayInfo:{type:Ln.profile,color:Ln.colorHex||"",location:"External Spool"}})}:void 0},configureSlot:{enabled:!0,onConfigure:()=>me({amsId:255,trayId:0,trayCount:1,trayType:lt.tray_type||void 0,trayColor:lt.tray_color||void 0,traySubBrands:lt.tray_sub_brands||void 0,trayInfoIdx:lt.tray_info_idx||void 0})},children:bi})]})})()]})]})]})})()]}),xe&&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(qf,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"text-sm text-white truncate",children:xe.name}),Oe&&s.jsxs("span",{className:`text-xs px-1.5 py-0.5 rounded flex-shrink-0 ${Oe.state==="ON"?"bg-bambu-green/20 text-bambu-green":Oe.state==="OFF"?"bg-red-500/20 text-red-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:[Oe.state||"?",Oe.state==="ON"&&Oe.energy?.power!=null&&s.jsxs("span",{className:"text-yellow-400 ml-1.5",children:["· ",Oe.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:Gt.isPending||Oe?.state==="ON",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${Oe?.state==="ON"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[s.jsx(Eu,{className:"w-3 h-3"}),"On"]}),s.jsxs("button",{onClick:()=>q(!0),disabled:Gt.isPending||Oe?.state==="OFF",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${Oe?.state==="OFF"?"bg-red-500/30 text-red-400":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[s.jsx(fN,{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 ${xe.auto_off_executed?"text-bambu-green":"text-bambu-gray"}`,children:xe.auto_off_executed?"Auto-off done":"Auto-off"}),s.jsx("button",{onClick:()=>_n.mutate(!xe.auto_off),disabled:_n.isPending||xe.auto_off_executed,title:xe.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 ${xe.auto_off_executed?"bg-bambu-green/50 cursor-not-allowed":xe.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 ${xe.auto_off||xe.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(Se,{variant:"secondary",size:"sm",onClick:()=>At.mutate(!j?.chamber_light),disabled:!j?.connected||At.isPending,title:j?.chamber_light?"Turn off chamber light":"Turn on chamber light",className:j?.chamber_light?"bg-yellow-500/20 hover:bg-yellow-500/30 border-yellow-500/30":"",children:s.jsx(OPe,{on:j?.chamber_light??!1,className:"w-4 h-4"})}),s.jsx(Se,{variant:"secondary",size:"sm",onClick:()=>{if(u==="embedded"&&d)d(t.id,t.name);else{const Pe=localStorage.getItem("cameraWindowState"),wt=Pe?JSON.parse(Pe):{width:640,height:400},Mt=[`width=${wt.width}`,`height=${wt.height}`,wt.left!==void 0?`left=${wt.left}`:"",wt.top!==void 0?`top=${wt.top}`:"","menubar=no,toolbar=no,location=no,status=no,noopener"].filter(Boolean).join(",");window.open(`/camera/${t.id}`,`camera-${t.id}`,Mt)}},disabled:!j?.connected,title:u==="embedded"?"Open camera overlay":"Open camera in new window",children:s.jsx(qD,{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(Se,{variant:"secondary",size:"sm",onClick:ue,disabled:!j?.connected||Pr.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:Pr.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(U1,{className:"w-4 h-4"})}),s.jsx(Se,{variant:"secondary",size:"sm",onClick:Re,disabled:!j?.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(dt,{className:"w-3 h-3 animate-spin"}):s.jsx(Oi,{className:"w-3 h-3"})})]}),s.jsxs(Se,{variant:"secondary",size:"sm",onClick:()=>E(!0),title:"Browse printer files",children:[s.jsx(lN,{className:"w-4 h-4"}),"Files"]})]})]})]}),k&&s.jsx(rpe,{printerId:t.id,printerName:t.name,onClose:()=>E(!1)}),O&&s.jsx(cpe,{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(),children:s.jsxs("div",{className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl max-w-lg w-full",onClick:Pe=>Pe.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(U1,{className:"w-5 h-5 text-blue-500"}):le.is_empty?s.jsx(Un,{className:"w-5 h-5 text-green-500"}):s.jsx(ia,{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(),className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:s.jsx(Vt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[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"}),", 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})]}),rt&&rt.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 (",rt.references.length,"/",rt.max_references,")"]}),s.jsx("div",{className:"grid grid-cols-5 gap-2",children:rt.references.map(Pe=>s.jsxs("div",{className:"relative group",children:[s.jsx("img",{src:he.getPlateReferenceThumbnailUrl(t.id,Pe.index),alt:Pe.label||`Reference ${Pe.index+1}`,className:"w-full aspect-video object-cover rounded border border-bambu-dark-tertiary"}),s.jsx("button",{onClick:()=>ht(Pe.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(Vt,{className:"w-3 h-3 text-white"})}),zt?.index===Pe.index?s.jsx("input",{type:"text",value:zt.label,onChange:wt=>Xt({...zt,label:wt.target.value}),onBlur:()=>Ge(Pe.index,zt.label),onKeyDown:wt=>{wt.key==="Enter"&&Ge(Pe.index,zt.label),wt.key==="Escape"&&Xt(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:()=>Xt({index:Pe.index,label:Pe.label}),title:Pe.label?`${Pe.label} - Click to edit`:"Click to add label",children:Pe.label||s.jsx("span",{className:"italic opacity-50",children:"No label"})}),s.jsx("p",{className:"text-[10px] text-bambu-gray/60",children:Pe.timestamp?new Date(Pe.timestamp).toLocaleDateString():""})]},Pe.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(Se,{variant:"ghost",size:"sm",onClick:()=>ce(null),disabled:Te,children:"Cancel"}),s.jsx(Se,{size:"sm",onClick:Pt,disabled:Te,children:Te?s.jsx(dt,{className:"w-3 h-3 animate-spin"}):"Save"})]}):s.jsxs(Se,{variant:"ghost",size:"sm",onClick:()=>ce(le.roi||{x:.15,y:.35,w:.7,h:.55}),children:[s.jsx(la,{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:Pe=>ce({...I,x:parseFloat(Pe.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:Pe=>ce({...I,y:parseFloat(Pe.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:Pe=>ce({...I,w:parseFloat(Pe.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:Pe=>ce({...I,h:parseFloat(Pe.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(Se,{variant:"ghost",onClick:()=>He(),children:"Cancel"}),s.jsx(Se,{onClick:()=>Xe(),disabled:X,children:X?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 mr-2 animate-spin"}),"Calibrating..."]}):"Calibrate Empty Plate"})]}):s.jsxs(s.Fragment,{children:[s.jsx(Se,{variant:"ghost",onClick:()=>Xe(),disabled:X,children:X?"Adding...":`Add Reference (${rt?.references.length||0}/${rt?.max_references||5})`}),s.jsx(Se,{onClick:()=>He(),children:"Close"})]})})]})}),D&&xe&&s.jsx(Hn,{title:"Power On Printer",message:`Are you sure you want to turn ON the power for "${t.name}"?`,confirmText:"Power On",variant:"default",onConfirm:()=>{Gt.mutate("on"),U(!1)},onCancel:()=>U(!1)}),L&&xe&&s.jsx(Hn,{title:"Power Off Printer",message:j?.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:()=>{Gt.mutate("off"),q(!1)},onCancel:()=>q(!1)}),K&&s.jsx(Hn,{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:()=>{gt.mutate(),V(!1)},onCancel:()=>V(!1)}),Q&&s.jsx(Hn,{title:"Pause Print",message:`Are you sure you want to pause the current print on "${t.name}"?`,confirmText:"Pause Print",variant:"default",onConfirm:()=>{Kt.mutate(),re(!1)},onCancel:()=>re(!1)}),J&&s.jsx(Hn,{title:"Resume Print",message:`Are you sure you want to resume the print on "${t.name}"?`,confirmText:"Resume Print",variant:"default",onConfirm:()=>{bn.mutate(),z(!1)},onCancel:()=>z(!1)}),G&&s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:()=>ne(!1),onKeyDown:Pe=>Pe.key==="Escape"&&ne(!1),tabIndex:-1,ref:Pe=>Pe?.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:Pe=>Pe.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(hV,{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(Vt,{className:"w-4 h-4"})})]}),jn?jn.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(cfe,{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:[jn.skipped_count,"/",jn.total," skipped"]})]}),(j?.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(oa,{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 ",j?.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:[j?.cover_url?s.jsx("img",{src:`${j.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(Hs,{className:"w-8 h-8 text-gray-300 dark:text-bambu-gray/30"})}),jn.objects.length>0&&s.jsx("div",{className:"absolute inset-0 pointer-events-none",children:jn.objects.map((Pe,wt)=>{let Mt,lt;if(Pe.x!=null&&Pe.y!=null&&jn.bbox_all){const[Tt,Rt,$t,Ln]=jn.bbox_all,bi=$t-Tt,Qt=Ln-Rt,cn=8,An=100-cn*2;Mt=cn+(Pe.x-Tt)/bi*An,lt=cn+(Ln-Pe.y)/Qt*An,Mt=Math.max(5,Math.min(95,Mt)),lt=Math.max(5,Math.min(95,lt))}else if(Pe.x!=null&&Pe.y!=null)Mt=Pe.x/256*100,lt=100-Pe.y/256*100,Mt=Math.max(5,Math.min(95,Mt)),lt=Math.max(5,Math.min(95,lt));else{const Tt=Math.ceil(Math.sqrt(jn.objects.length)),Rt=Math.floor(wt/Tt),$t=wt%Tt,Ln=Math.ceil(jn.objects.length/Tt);Mt=15+$t*(70/Tt)+35/Tt,lt=15+Rt*(70/Ln)+35/Ln}return s.jsx("div",{className:`absolute flex items-center justify-center w-6 h-6 rounded-full text-[10px] font-bold shadow-lg ${Pe.skipped?"bg-red-500 text-white line-through":"bg-bambu-green text-black"}`,style:{left:`${Mt}%`,top:`${lt}%`,transform:"translate(-50%, -50%)"},title:Pe.name,children:Pe.id},Pe.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:[jn.objects.filter(Pe=>!Pe.skipped).length," active"]})]})}),s.jsx("div",{className:"flex-1 min-w-0 overflow-y-auto",children:jn.objects.map(Pe=>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
- ${Pe.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
- ${Pe.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 ${Pe.skipped?"text-red-500 dark:text-red-400":"text-green-600 dark:text-bambu-green"}`,children:Pe.id}),s.jsx("span",{className:`text-[8px] uppercase tracking-wider ${Pe.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 ${Pe.skipped?"text-red-500 dark:text-red-400 line-through":"text-gray-900 dark:text-white"}`,children:Pe.name}),Pe.skipped&&s.jsx("span",{className:"text-[10px] text-red-400/60",children:"Will be skipped"})]}),Pe.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:()=>Rr.mutate([Pe.id]),disabled:Rr.isPending||(j?.layer_num??0)<=1,className:`px-4 py-2 text-xs font-medium rounded-lg transition-colors ${(j?.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:(j?.layer_num??0)<=1?"Wait for layer 2+":"Skip this object",children:"Skip"})]},Pe.id))})]})]}):s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(dt,{className:"w-5 h-5 animate-spin text-bambu-gray"})})]})]}),P&&s.jsx(fpe,{printerName:t.name,errors:j?.hms_errors||[],onClose:()=>W(!1)}),ae&&s.jsx(EPe,{isOpen:!!ae,onClose:()=>de(null),printerId:t.id,printerName:t.name,amsId:ae.amsId,amsLabel:ae.amsLabel,initialMode:ae.mode,thresholds:a}),fe&&s.jsx(APe,{isOpen:!!fe,onClose:()=>ie(null),trayUuid:fe.trayUuid,trayInfo:fe.trayInfo}),Ae&&s.jsx(DPe,{isOpen:!!Ae,onClose:()=>me(null),printerId:t.id,slotInfo:Ae,onSuccess:()=>{f.invalidateQueries({queryKey:["slotPresets",t.id]}),f.invalidateQueries({queryKey:["printerStatus",t.id]})}}),A&&s.jsx(YPe,{printer:t,onClose:()=>T(!1)}),Ne&&Y&&s.jsx(XPe,{printer:t,firmwareInfo:Y,onClose:()=>ye(!1)}),yt&&s.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>It(null)})]})}function KPe({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(()=>{Nl.getInfo().then(E=>{b(E.is_docker)}).catch(()=>{})},[]);const M=l.filter(E=>!n.includes(E.serial)),A=async()=>{d(""),c([]),o(!0),m(!1),S({scanned:0,total:0});try{if(p){await Nl.startSubnetScan(y);const E=setInterval(async()=>{try{const O=await Nl.getScanStatus();S({scanned:O.scanned,total:O.total});const C=await Nl.getDiscoveredPrinters();c(C),O.running||(clearInterval(E),o(!1),m(!0))}catch(O){console.error("Failed to get scan status:",O)}},500)}else{await Nl.startDiscovery(10);const E=setInterval(async()=>{try{const O=await Nl.getDiscoveredPrinters();c(O)}catch(O){console.error("Failed to get discovered printers:",O)}},1e3);setTimeout(async()=>{clearInterval(E);try{await Nl.stopDiscovery()}catch{}o(!1),m(!0);try{const O=await Nl.getDiscoveredPrinters();c(O)}catch(O){console.error("Failed to get final discovered printers:",O)}},1e4)}}catch(E){console.error("Failed to start discovery:",E),d(E instanceof Error?E.message:"Failed to start discovery"),o(!1),m(!0)}},T=E=>E?{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"}[E]||E:"",k=E=>{const O=E.serial.startsWith("unknown-")?"":E.serial;i({...r,name:E.name||"",serial_number:O,ip_address:E.ip_address,model:T(E.model)}),c([])};return w.useEffect(()=>()=>{Nl.stopDiscovery().catch(()=>{}),Nl.stopSubnetScan().catch(()=>{})},[]),w.useEffect(()=>{const E=O=>{O.key==="Escape"&&t()};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[t]),s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:t,children:s.jsx(St,{className:"w-full max-w-md",onClick:E=>E.stopPropagation(),children:s.jsxs(Nt,{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:E=>x(E.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(Se,{type:"button",variant:"secondary",onClick:A,disabled:a,className:"w-full",children:a?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 animate-spin"}),p&&v.total>0?`Scanning... ${v.scanned}/${v.total}`:"Scanning..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Ea,{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(E=>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(E),children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"font-medium text-white text-sm truncate",children:E.name||E.serial}),s.jsxs("p",{className:"text-xs text-bambu-gray truncate",children:[T(E.model)||"Unknown"," • ",E.ip_address,E.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"})]},E.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:E=>{E.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:E=>i({...r,name:E.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:E=>i({...r,ip_address:E.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:E=>i({...r,serial_number:E.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:E=>i({...r,access_code:E.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:E=>i({...r,model:E.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:E=>i({...r,auto_archive:E.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(Se,{type:"button",variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),s.jsx(Se,{type:"submit",className:"flex-1",children:"Add Printer"})]})]})]})})})}function XPe({printer:t,firmwareInfo:e,onClose:n}){const r=on(),{showToast:i}=qn(),[a,o]=w.useState(null),[l,c]=w.useState(!1),[u,d]=w.useState(null),{data:f,isLoading:m}=ut({queryKey:["firmwarePrepare",t.id],queryFn:()=>i1.prepareUpload(t.id),staleTime:3e4}),p=mt({mutationFn:()=>i1.startUpload(t.id),onSuccess:()=>{c(!0);const y=setInterval(async()=>{try{const x=await i1.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(St,{className:"w-full max-w-md mx-4",children:s.jsxs(Nt,{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(Hr,{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(dt,{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(Hs,{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(oa,{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(Se,{variant:"secondary",onClick:n,children:a?.status==="complete"?"Done":"Cancel"}),f?.can_proceed&&!l&&a?.status!=="complete"&&s.jsx(Se,{onClick:b,disabled:p.isPending,children:p.isPending?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 animate-spin mr-2"}),"Starting..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Hr,{className:"w-4 h-4 mr-2"}),"Upload Firmware"]})})]})]})})})}function YPe({printer:t,onClose:e}){const n=on(),[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=mt({mutationFn:l=>he.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(St,{className:"w-full max-w-md",onClick:l=>l.stopPropagation(),children:s.jsxs(Nt,{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(Se,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsx(Se,{type:"submit",className:"flex-1",disabled:a.isPending,children:a.isPending?"Saving...":"Save Changes"})]})]})]})})})}function ZPe(t){const{data:e}=ut({queryKey:["printerStatus",t],queryFn:()=>he.getPrinterStatus(t),refetchInterval:3e4});return!e?.connected}function QPe({printer:t,plug:e,onPowerOn:n,isPowering:r}){const i=ZPe(t.id),{data:a}=ut({queryKey:["smartPlugStatus",e.id],queryFn:()=>he.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(Eu,{className:"w-3 h-3"}),r?"...":"On"]})]}):null}function JPe(){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 G=localStorage.getItem("printerCardSize");return G?parseInt(G,10):2}),b=m===1?"compact":"expanded",y=on(),[x,v]=w.useState(()=>{const G=localStorage.getItem("openEmbeddedCameras");if(G)try{const ne=JSON.parse(G);return new Map(ne.map(ae=>[ae.id,ae]))}catch{return new Map}return new Map});w.useEffect(()=>{const G=Array.from(x.values());G.length>0?localStorage.setItem("openEmbeddedCameras",JSON.stringify(G)):localStorage.removeItem("openEmbeddedCameras")},[x]);const{data:S,isLoading:M}=ut({queryKey:["printers"],queryFn:he.getPrinters}),{data:A}=ut({queryKey:["settings"],queryFn:he.getSettings});w.useEffect(()=>{A?.camera_view_mode==="window"&&x.size>0&&v(new Map)},[A?.camera_view_mode,x.size]);const{data:T}=ut({queryKey:["smart-plugs"],queryFn:he.getSmartPlugs}),{data:k}=ut({queryKey:["maintenanceOverview"],queryFn:he.getMaintenanceOverview,staleTime:60*1e3}),{data:E}=ut({queryKey:["spoolman-status"],queryFn:he.getSpoolmanStatus,staleTime:60*1e3}),O=E?.enabled&&E?.connected,{data:C}=ut({queryKey:["unlinked-spools"],queryFn:he.getUnlinkedSpools,enabled:!!O,staleTime:30*1e3}),D=C&&C.length>0,U=k?.reduce((G,ne)=>(G[ne.printer_id]={due_count:ne.due_count,warning_count:ne.warning_count,total_print_hours:ne.total_print_hours},G),{})||{},L=T?.reduce((G,ne)=>(ne.printer_id&&(G[ne.printer_id]=ne),G),{})||{},q=mt({mutationFn:he.createPrinter,onSuccess:()=>{y.invalidateQueries({queryKey:["printers"]}),y.invalidateQueries({queryKey:["maintenanceOverview"]}),e(!1)}}),P=mt({mutationFn:G=>he.controlSmartPlug(G,"on"),onSuccess:()=>{y.invalidateQueries({queryKey:["smart-plugs"]}),l(null)},onError:()=>{l(null)}}),W=()=>{const G=!n;r(G),localStorage.setItem("hideDisconnectedPrinters",String(G))},K=G=>{u(G),localStorage.setItem("printerSortBy",G)},V=()=>{const G=!d;f(G),localStorage.setItem("printerSortAsc",String(G))},Q=()=>{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"}},re=["S","M","L","XL"],J=w.useMemo(()=>{if(!S)return[];const G=[...S];switch(c){case"name":G.sort((ne,ae)=>ne.name.localeCompare(ae.name));break;case"model":G.sort((ne,ae)=>(ne.model||"").localeCompare(ae.model||""));break;case"location":G.sort((ne,ae)=>{const de=ne.location||"",fe=ae.location||"";return!de&&fe?1:de&&!fe?-1:de.localeCompare(fe)||ne.name.localeCompare(ae.name)});break;case"status":G.sort((ne,ae)=>{const de=y.getQueryData(["printerStatus",ne.id]),fe=y.getQueryData(["printerStatus",ae.id]),ie=Ae=>Ae?.connected?Ae.state==="RUNNING"?0:1:2;return ie(de)-ie(fe)});break}return d||G.reverse(),G},[S,c,d,y]),z=w.useMemo(()=>{if(c!=="location")return null;const G={};return J.forEach(ne=>{const ae=ne.location||"Ungrouped";G[ae]||(G[ae]=[]),G[ae].push(ne)}),G},[c,J]);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(qPe,{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:G=>K(G.target.value),className:"text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg px-2 py-1.5 text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"name",children:"Name"}),s.jsx("option",{value:"status",children:"Status"}),s.jsx("option",{value:"model",children:"Model"}),s.jsx("option",{value:"location",children:"Location"})]}),s.jsx("button",{onClick:V,className:"p-1.5 rounded-lg hover:bg-bambu-dark-tertiary transition-colors",title:d?"Sort descending":"Sort ascending",children:d?s.jsx(bg,{className:"w-4 h-4 text-bambu-gray"}):s.jsx(j0,{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:re.map((G,ne)=>{const ae=ne+1,de=m===ae;return s.jsx("button",{onClick:()=>{p(ae),localStorage.setItem("printerCardSize",String(ae))},className:`px-2 py-1.5 text-xs font-medium transition-colors ${ne===0?"rounded-l-lg":""} ${ne===re.length-1?"rounded-r-lg":""} ${de?"bg-bambu-green text-white":"text-bambu-gray hover:bg-bambu-dark-tertiary hover:text-white"}`,title:`${G==="S"?"Small":G==="M"?"Medium":G==="L"?"Large":"Extra large"} cards`,children:G},G)})}),s.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),s.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:n,onChange:W,className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Hide offline"]}),n&&Object.keys(L).length>0&&s.jsxs("div",{className:"relative",children:[s.jsxs("button",{onClick:()=>a(!i),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-white dark:bg-bambu-dark-secondary border border-gray-200 dark:border-bambu-dark-tertiary rounded-lg text-gray-600 dark:text-bambu-gray hover:text-gray-900 dark:hover:text-white hover:border-bambu-green transition-colors",children:[s.jsx(Eu,{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(G=>L[G.id]).map(G=>s.jsx(QPe,{printer:G,plug:L[G.id],onPowerOn:ne=>{l(ne),P.mutate(ne)},isPowering:o===L[G.id]?.id},G.id)),S?.filter(G=>L[G.id]).length===0&&s.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No printers with smart plugs"})]})]})]}),s.jsxs(Se,{onClick:()=>e(!0),children:[s.jsx(nr,{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(St,{children:s.jsxs(Nt,{className:"text-center py-12",children:[s.jsx("p",{className:"text-bambu-gray mb-4",children:"No printers configured yet"}),s.jsxs(Se,{onClick:()=>e(!0),children:[s.jsx(nr,{className:"w-4 h-4"}),"Add Your First Printer"]})]})}):z?s.jsx("div",{className:"space-y-6",children:Object.entries(z).map(([G,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"}),G,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":""} ${Q()}`,children:ne.map(ae=>s.jsx(vV,{printer:ae,hideIfDisconnected:n,maintenanceInfo:U[ae.id],viewMode:b,cardSize:m,amsThresholds:A?{humidityGood:Number(A.ams_humidity_good)||40,humidityFair:Number(A.ams_humidity_fair)||60,tempGood:Number(A.ams_temp_good)||28,tempFair:Number(A.ams_temp_fair)||35}:void 0,spoolmanEnabled:O,hasUnlinkedSpools:D,timeFormat:A?.time_format||"system",cameraViewMode:A?.camera_view_mode||"window",onOpenEmbeddedCamera:(de,fe)=>v(ie=>new Map(ie).set(de,{id:de,name:fe}))},ae.id))})]},G))}):s.jsx("div",{className:`grid gap-4 ${m>=3?"gap-6":""} ${Q()}`,children:J.map(G=>s.jsx(vV,{printer:G,hideIfDisconnected:n,maintenanceInfo:U[G.id],viewMode:b,cardSize:m,spoolmanEnabled:O,hasUnlinkedSpools:D,amsThresholds:A?{humidityGood:Number(A.ams_humidity_good)||40,humidityFair:Number(A.ams_humidity_fair)||60,tempGood:Number(A.ams_temp_good)||28,tempFair:Number(A.ams_temp_fair)||35}:void 0,timeFormat:A?.time_format||"system",cameraViewMode:A?.camera_view_mode||"window",onOpenEmbeddedCamera:(ne,ae)=>v(de=>new Map(de).set(ne,{id:ne,name:ae}))},G.id))}),t&&s.jsx(KPe,{onClose:()=>e(!1),onAdd:G=>q.mutate(G),existingSerials:S?.map(G=>G.serial_number)||[]}),Array.from(x.values()).map((G,ne)=>s.jsx(lpe,{printerId:G.id,printerName:G.name,viewerIndex:ne,onClose:()=>v(ae=>{const de=new Map(ae);return de.delete(G.id),de})},G.id))]})}function e3e(){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 t3e(){return e3e()==="windows"?"bambustudio://":"bambustudioopen://"}function Zc(t){const e=t3e();window.location.href=`${e}${encodeURIComponent(t)}`}const J4="182",cg={ROTATE:0,DOLLY:1,PAN:2},eg={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},n3e=0,_V=1,r3e=2,f1=1,i3e=2,Gb=3,ih=0,Ms=1,Fl=2,cu=0,ug=1,wV=2,SV=3,MV=4,a3e=5,sf=100,s3e=101,o3e=102,l3e=103,c3e=104,u3e=200,d3e=201,h3e=202,f3e=203,k3=204,j3=205,m3e=206,p3e=207,g3e=208,x3e=209,b3e=210,y3e=211,v3e=212,_3e=213,w3e=214,P3=0,R3=1,D3=2,kg=3,O3=4,L3=5,I3=6,F3=7,eL=0,S3e=1,M3e=2,Kl=0,ZJ=1,QJ=2,JJ=3,eee=4,tee=5,nee=6,ree=7,iee=300,rm=301,jg=302,U3=303,z3=304,dE=306,B3=1e3,nu=1001,$3=1002,Aa=1003,N3e=1004,I_=1005,Ba=1006,YC=1007,vf=1008,Gs=1009,aee=1010,see=1011,Q0=1012,tL=1013,ic=1014,Hl=1015,Su=1016,nL=1017,rL=1018,J0=1020,oee=35902,lee=35899,cee=1021,uee=1022,il=1023,Mu=1026,_f=1027,dee=1028,iL=1029,Pg=1030,aL=1031,sL=1033,m1=33776,p1=33777,g1=33778,x1=33779,H3=35840,V3=35841,G3=35842,W3=35843,q3=36196,K3=37492,X3=37496,Y3=37488,Z3=37489,Q3=37490,J3=37491,eR=37808,tR=37809,nR=37810,rR=37811,iR=37812,aR=37813,sR=37814,oR=37815,lR=37816,cR=37817,uR=37818,dR=37819,hR=37820,fR=37821,mR=36492,pR=36494,gR=36495,xR=36283,bR=36284,yR=36285,vR=36286,E3e=3200,hee=0,A3e=1,Td="",_o="srgb",Rg="srgb-linear",HS="linear",or="srgb",ap=7680,NV=519,T3e=512,C3e=513,k3e=514,oL=515,j3e=516,P3e=517,lL=518,R3e=519,EV=35044,AV="300 es",Vl=2e3,VS=2001;function fee(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function GS(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function D3e(){const t=GS("canvas");return t.style.display="block",t}const TV={};function CV(...t){const e="THREE."+t.shift();console.log(e,...t)}function un(...t){const e="THREE."+t.shift();console.warn(e,...t)}function Yn(...t){const e="THREE."+t.shift();console.error(e,...t)}function ey(...t){const e=t.join(" ");e in TV||(TV[e]=!0,un(...t))}function O3e(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 xm=class{addEventListener(e,n){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[e]===void 0&&(r[e]=[]),r[e].indexOf(n)===-1&&r[e].push(n)}hasEventListener(e,n){const r=this._listeners;return r===void 0?!1:r[e]!==void 0&&r[e].indexOf(n)!==-1}removeEventListener(e,n){const r=this._listeners;if(r===void 0)return;const i=r[e];if(i!==void 0){const a=i.indexOf(n);a!==-1&&i.splice(a,1)}}dispatchEvent(e){const n=this._listeners;if(n===void 0)return;const r=n[e.type];if(r!==void 0){e.target=this;const i=r.slice(0);for(let a=0,o=i.length;a<o;a++)i[a].call(this,e);e.target=null}}};const Pa=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],b1=Math.PI/180,_R=180/Math.PI;function Yy(){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 Dn(t,e,n){return Math.max(e,Math.min(n,t))}function L3e(t,e){return(t%e+e)%e}function ZC(t,e,n){return(1-n)*t+n*e}function vb(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 gs(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 I3e={DEG2RAD:b1};let Nn=class mee{constructor(e=0,n=0){mee.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=Dn(this.x,e.x,n.x),this.y=Dn(this.y,e.y,n.y),this}clampScalar(e,n){return this.x=Dn(this.x,e,n),this.y=Dn(this.y,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Dn(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(Dn(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}},im=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(Dn(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}},tt=class pee{constructor(e=0,n=0,r=0){pee.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(kV.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(kV.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=Dn(this.x,e.x,n.x),this.y=Dn(this.y,e.y,n.y),this.z=Dn(this.z,e.z,n.z),this}clampScalar(e,n){return this.x=Dn(this.x,e,n),this.y=Dn(this.y,e,n),this.z=Dn(this.z,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Dn(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 QC.copy(this).projectOnVector(e),this.sub(QC)}reflect(e){return this.sub(QC.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(Dn(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 QC=new tt,kV=new im;let Tn=class gee{constructor(e,n,r,i,a,o,l,c,u){gee.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],A=i[7],T=i[2],k=i[5],E=i[8];return a[0]=o*y+l*S+c*T,a[3]=o*x+l*M+c*k,a[6]=o*v+l*A+c*E,a[1]=u*y+d*S+f*T,a[4]=u*x+d*M+f*k,a[7]=u*v+d*A+f*E,a[2]=m*y+p*S+b*T,a[5]=m*x+p*M+b*k,a[8]=m*v+p*A+b*E,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(JC.makeScale(e,n)),this}rotate(e){return this.premultiply(JC.makeRotation(-e)),this}translate(e,n){return this.premultiply(JC.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 JC=new Tn,jV=new Tn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),PV=new Tn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function F3e(){const t={enabled:!0,workingColorSpace:Rg,spaces:{},convert:function(i,a,o){return this.enabled===!1||a===o||!a||!o||(this.spaces[a].transfer===or&&(i.r=uu(i.r),i.g=uu(i.g),i.b=uu(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===or&&(i.r=dg(i.r),i.g=dg(i.g),i.b=dg(i.b))),i},workingToColorSpace:function(i,a){return this.convert(i,this.workingColorSpace,a)},colorSpaceToWorking:function(i,a){return this.convert(i,a,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===Td?HS: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 ey("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(i,a)},toWorkingColorSpace:function(i,a){return ey("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({[Rg]:{primaries:e,whitePoint:r,transfer:HS,toXYZ:jV,fromXYZ:PV,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:_o},outputColorSpaceConfig:{drawingBufferColorSpace:_o}},[_o]:{primaries:e,whitePoint:r,transfer:or,toXYZ:jV,fromXYZ:PV,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:_o}}}),t}const Wn=F3e();function uu(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function dg(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let sp,U3e=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{sp===void 0&&(sp=GS("canvas")),sp.width=e.width,sp.height=e.height;const i=sp.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),r=sp}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=GS("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]=uu(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(uu(n[r]/255)*255):n[r]=uu(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}},z3e=0,cL=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:z3e++}),this.uuid=Yy(),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(ek(i[o].image)):a.push(ek(i[o]))}else a=ek(i);r.url=a}return n||(e.images[this.uuid]=r),r}};function ek(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?U3e.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 B3e=0;const tk=new tt;let yl=class y1 extends xm{constructor(e=y1.DEFAULT_IMAGE,n=y1.DEFAULT_MAPPING,r=nu,i=nu,a=Ba,o=vf,l=il,c=Gs,u=y1.DEFAULT_ANISOTROPY,d=Td){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:B3e++}),this.uuid=Yy(),this.name="",this.source=new cL(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 Nn(0,0),this.repeat=new Nn(1,1),this.center=new Nn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Tn,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(tk).x}get height(){return this.source.getSize(tk).y}get depth(){return this.source.getSize(tk).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!==iee)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case B3:e.x=e.x-Math.floor(e.x);break;case nu:e.x=e.x<0?0:1;break;case $3: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 B3:e.y=e.y-Math.floor(e.y);break;case nu:e.y=e.y<0?0:1;break;case $3: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++}};yl.DEFAULT_IMAGE=null;yl.DEFAULT_MAPPING=iee;yl.DEFAULT_ANISOTROPY=1;let Ei=class xee{constructor(e=0,n=0,r=0,i=1){xee.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,A=(p+1)/2,T=(v+1)/2,k=(d+m)/4,E=(f+y)/4,O=(b+x)/4;return M>A&&M>T?M<.01?(r=0,i=.707106781,a=.707106781):(r=Math.sqrt(M),i=k/r,a=E/r):A>T?A<.01?(r=.707106781,i=0,a=.707106781):(i=Math.sqrt(A),r=k/i,a=O/i):T<.01?(r=.707106781,i=.707106781,a=0):(a=Math.sqrt(T),r=E/a,i=O/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=Dn(this.x,e.x,n.x),this.y=Dn(this.y,e.y,n.y),this.z=Dn(this.z,e.z,n.z),this.w=Dn(this.w,e.w,n.w),this}clampScalar(e,n){return this.x=Dn(this.x,e,n),this.y=Dn(this.y,e,n),this.z=Dn(this.z,e,n),this.w=Dn(this.w,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Dn(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}},$3e=class extends xm{constructor(e=1,n=1,r={}){super(),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Ba,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 Ei(0,0,e,n),this.scissorTest=!1,this.viewport=new Ei(0,0,e,n);const i={width:e,height:n,depth:r.depth},a=new yl(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:Ba,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 cL(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"})}},Xl=class extends $3e{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}},bee=class extends yl{constructor(e=null,n=1,r=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:n,height:r,depth:i},this.magFilter=Aa,this.minFilter=Aa,this.wrapR=nu,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},H3e=class extends yl{constructor(e=null,n=1,r=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:n,height:r,depth:i},this.magFilter=Aa,this.minFilter=Aa,this.wrapR=nu,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},am=class{constructor(e=new tt(1/0,1/0,1/0),n=new tt(-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(Wo.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(Wo.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=Wo.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,Wo):Wo.fromBufferAttribute(a,o),Wo.applyMatrix4(e.matrixWorld),this.expandByPoint(Wo);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),F_.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),F_.copy(r.boundingBox)),F_.applyMatrix4(e.matrixWorld),this.union(F_)}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,Wo),Wo.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(_b),U_.subVectors(this.max,_b),op.subVectors(e.a,_b),lp.subVectors(e.b,_b),cp.subVectors(e.c,_b),rd.subVectors(lp,op),id.subVectors(cp,lp),$h.subVectors(op,cp);let n=[0,-rd.z,rd.y,0,-id.z,id.y,0,-$h.z,$h.y,rd.z,0,-rd.x,id.z,0,-id.x,$h.z,0,-$h.x,-rd.y,rd.x,0,-id.y,id.x,0,-$h.y,$h.x,0];return!nk(n,op,lp,cp,U_)||(n=[1,0,0,0,1,0,0,0,1],!nk(n,op,lp,cp,U_))?!1:(z_.crossVectors(rd,id),n=[z_.x,z_.y,z_.z],nk(n,op,lp,cp,U_))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Wo).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Wo).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:(Pc[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Pc[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Pc[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Pc[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Pc[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Pc[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Pc[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Pc[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Pc),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 Pc=[new tt,new tt,new tt,new tt,new tt,new tt,new tt,new tt],Wo=new tt,F_=new am,op=new tt,lp=new tt,cp=new tt,rd=new tt,id=new tt,$h=new tt,_b=new tt,U_=new tt,z_=new tt,Hh=new tt;function nk(t,e,n,r,i){for(let a=0,o=t.length-3;a<=o;a+=3){Hh.fromArray(t,a);const l=i.x*Math.abs(Hh.x)+i.y*Math.abs(Hh.y)+i.z*Math.abs(Hh.z),c=e.dot(Hh),u=n.dot(Hh),d=r.dot(Hh);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>l)return!1}return!0}const V3e=new am,wb=new tt,rk=new tt;let hE=class{constructor(e=new tt,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):V3e.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;wb.subVectors(e,this.center);const n=wb.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(wb,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):(rk.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(wb.copy(e.center).add(rk)),this.expandByPoint(wb.copy(e.center).sub(rk))),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 Rc=new tt,ik=new tt,B_=new tt,ad=new tt,ak=new tt,$_=new tt,sk=new tt;let uL=class{constructor(e=new tt,n=new tt(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,Rc)),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=Rc.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(Rc.copy(this.origin).addScaledVector(this.direction,n),Rc.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){ik.copy(e).add(n).multiplyScalar(.5),B_.copy(n).sub(e).normalize(),ad.copy(this.origin).sub(ik);const a=e.distanceTo(n)*.5,o=-this.direction.dot(B_),l=ad.dot(this.direction),c=-ad.dot(B_),u=ad.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(ik).addScaledVector(B_,m),p}intersectSphere(e,n){Rc.subVectors(e.center,this.origin);const r=Rc.dot(this.direction),i=Rc.dot(Rc)-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,Rc)!==null}intersectTriangle(e,n,r,i,a){ak.subVectors(n,e),$_.subVectors(r,e),sk.crossVectors(ak,$_);let o=this.direction.dot(sk),l;if(o>0){if(i)return null;l=1}else if(o<0)l=-1,o=-o;else return null;ad.subVectors(this.origin,e);const c=l*this.direction.dot($_.crossVectors(ad,$_));if(c<0)return null;const u=l*this.direction.dot(ak.cross(ad));if(u<0||c+u>o)return null;const d=-l*ad.dot(sk);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)}},gi=class wR{constructor(e,n,r,i,a,o,l,c,u,d,f,m,p,b,y,x){wR.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 wR().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/up.setFromMatrixColumn(e,0).length(),a=1/up.setFromMatrixColumn(e,1).length(),o=1/up.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(G3e,e,W3e)}lookAt(e,n,r){const i=this.elements;return Fs.subVectors(e,n),Fs.lengthSq()===0&&(Fs.z=1),Fs.normalize(),sd.crossVectors(r,Fs),sd.lengthSq()===0&&(Math.abs(r.z)===1?Fs.x+=1e-4:Fs.z+=1e-4,Fs.normalize(),sd.crossVectors(r,Fs)),sd.normalize(),H_.crossVectors(Fs,sd),i[0]=sd.x,i[4]=H_.x,i[8]=Fs.x,i[1]=sd.y,i[5]=H_.y,i[9]=Fs.y,i[2]=sd.z,i[6]=H_.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],A=r[11],T=r[15],k=i[0],E=i[4],O=i[8],C=i[12],D=i[1],U=i[5],L=i[9],q=i[13],P=i[2],W=i[6],K=i[10],V=i[14],Q=i[3],re=i[7],J=i[11],z=i[15];return a[0]=o*k+l*D+c*P+u*Q,a[4]=o*E+l*U+c*W+u*re,a[8]=o*O+l*L+c*K+u*J,a[12]=o*C+l*q+c*V+u*z,a[1]=d*k+f*D+m*P+p*Q,a[5]=d*E+f*U+m*W+p*re,a[9]=d*O+f*L+m*K+p*J,a[13]=d*C+f*q+m*V+p*z,a[2]=b*k+y*D+x*P+v*Q,a[6]=b*E+y*U+x*W+v*re,a[10]=b*O+y*L+x*K+v*J,a[14]=b*C+y*q+x*V+v*z,a[3]=S*k+M*D+A*P+T*Q,a[7]=S*E+M*U+A*W+T*re,a[11]=S*O+M*L+A*K+T*J,a[15]=S*C+M*q+A*V+T*z,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[4],i=e[8],a=e[12],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,A=l*m-c*f,T=o*p-u*d,k=o*m-c*d,E=o*f-l*d;return n*(y*S-x*M+v*A)-r*(b*S-x*T+v*k)+i*(b*M-y*T+v*E)-a*(b*A-y*k+x*E)}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,A=d*y*u-b*f*u+b*l*p-o*y*p-d*l*v+o*f*v,T=b*f*c-d*y*c-b*l*m+o*y*m+d*l*x-o*f*x,k=n*S+r*M+i*A+a*T;if(k===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const E=1/k;return e[0]=S*E,e[1]=(y*m*a-f*x*a-y*i*p+r*x*p+f*i*v-r*m*v)*E,e[2]=(l*x*a-y*c*a+y*i*u-r*x*u-l*i*v+r*c*v)*E,e[3]=(f*c*a-l*m*a-f*i*u+r*m*u+l*i*p-r*c*p)*E,e[4]=M*E,e[5]=(d*x*a-b*m*a+b*i*p-n*x*p-d*i*v+n*m*v)*E,e[6]=(b*c*a-o*x*a-b*i*u+n*x*u+o*i*v-n*c*v)*E,e[7]=(o*m*a-d*c*a+d*i*u-n*m*u-o*i*p+n*c*p)*E,e[8]=A*E,e[9]=(b*f*a-d*y*a-b*r*p+n*y*p+d*r*v-n*f*v)*E,e[10]=(o*y*a-b*l*a+b*r*u-n*y*u-o*r*v+n*l*v)*E,e[11]=(d*l*a-o*f*a-d*r*u+n*f*u+o*r*p-n*l*p)*E,e[12]=T*E,e[13]=(d*y*i-b*f*i+b*r*m-n*y*m-d*r*x+n*f*x)*E,e[14]=(b*l*i-o*y*i-b*r*c+n*y*c+o*r*x-n*l*x)*E,e[15]=(o*f*i-d*l*i+d*r*c-n*f*c-o*r*m+n*l*m)*E,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,A=c*f,T=r.x,k=r.y,E=r.z;return i[0]=(1-(y+v))*T,i[1]=(p+A)*T,i[2]=(b-M)*T,i[3]=0,i[4]=(p-A)*k,i[5]=(1-(m+v))*k,i[6]=(x+S)*k,i[7]=0,i[8]=(b+M)*E,i[9]=(x-S)*E,i[10]=(1-(m+y))*E,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=up.set(i[0],i[1],i[2]).length();const o=up.set(i[4],i[5],i[6]).length(),l=up.set(i[8],i[9],i[10]).length();this.determinant()<0&&(a=-a),qo.copy(this);const u=1/a,d=1/o,f=1/l;return qo.elements[0]*=u,qo.elements[1]*=u,qo.elements[2]*=u,qo.elements[4]*=d,qo.elements[5]*=d,qo.elements[6]*=d,qo.elements[8]*=f,qo.elements[9]*=f,qo.elements[10]*=f,n.setFromRotationMatrix(qo),r.x=a,r.y=o,r.z=l,this}makePerspective(e,n,r,i,a,o,l=Vl,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===Vl)b=-(o+a)/(o-a),y=-2*o*a/(o-a);else if(l===VS)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=Vl,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===Vl)b=-2/(o-a),y=-(o+a)/(o-a);else if(l===VS)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 up=new tt,qo=new gi,G3e=new tt(0,0,0),W3e=new tt(1,1,1),sd=new tt,H_=new tt,Fs=new tt,RV=new gi,DV=new im;let ah=class yee{constructor(e=0,n=0,r=0,i=yee.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(Dn(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(-Dn(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(Dn(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(-Dn(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(Dn(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(-Dn(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 RV.makeRotationFromQuaternion(e),this.setFromRotationMatrix(RV,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return DV.setFromEuler(this),this.setFromQuaternion(DV,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};ah.DEFAULT_ORDER="XYZ";let vee=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}},q3e=0;const OV=new tt,dp=new im,Dc=new gi,V_=new tt,Sb=new tt,K3e=new tt,X3e=new im,LV=new tt(1,0,0),IV=new tt(0,1,0),FV=new tt(0,0,1),UV={type:"added"},Y3e={type:"removed"},hp={type:"childadded",child:null},ok={type:"childremoved",child:null};let to=class v1 extends xm{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:q3e++}),this.uuid=Yy(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=v1.DEFAULT_UP.clone();const e=new tt,n=new ah,r=new im,i=new tt(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 gi},normalMatrix:{value:new Tn}}),this.matrix=new gi,this.matrixWorld=new gi,this.matrixAutoUpdate=v1.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=v1.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new vee,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 dp.setFromAxisAngle(e,n),this.quaternion.multiply(dp),this}rotateOnWorldAxis(e,n){return dp.setFromAxisAngle(e,n),this.quaternion.premultiply(dp),this}rotateX(e){return this.rotateOnAxis(LV,e)}rotateY(e){return this.rotateOnAxis(IV,e)}rotateZ(e){return this.rotateOnAxis(FV,e)}translateOnAxis(e,n){return OV.copy(e).applyQuaternion(this.quaternion),this.position.add(OV.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(LV,e)}translateY(e){return this.translateOnAxis(IV,e)}translateZ(e){return this.translateOnAxis(FV,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Dc.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?V_.copy(e):V_.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),Sb.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Dc.lookAt(Sb,V_,this.up):Dc.lookAt(V_,Sb,this.up),this.quaternion.setFromRotationMatrix(Dc),i&&(Dc.extractRotation(i.matrixWorld),dp.setFromRotationMatrix(Dc),this.quaternion.premultiply(dp.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(Yn("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(UV),hp.child=e,this.dispatchEvent(hp),hp.child=null):Yn("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(Y3e),ok.child=e,this.dispatchEvent(ok),ok.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),Dc.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Dc.multiply(e.parent.matrixWorld)),e.applyMatrix4(Dc),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(UV),hp.child=e,this.dispatchEvent(hp),hp.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(Sb,e,K3e),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Sb,X3e,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}};to.DEFAULT_UP=new tt(0,1,0);to.DEFAULT_MATRIX_AUTO_UPDATE=!0;to.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Ko=new tt,Oc=new tt,lk=new tt,Lc=new tt,fp=new tt,mp=new tt,zV=new tt,ck=new tt,uk=new tt,dk=new tt,hk=new Ei,fk=new Ei,mk=new Ei;let Mb=class Wp{constructor(e=new tt,n=new tt,r=new tt){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),Ko.subVectors(e,n),i.cross(Ko);const a=i.lengthSq();return a>0?i.multiplyScalar(1/Math.sqrt(a)):i.set(0,0,0)}static getBarycoord(e,n,r,i,a){Ko.subVectors(i,n),Oc.subVectors(r,n),lk.subVectors(e,n);const o=Ko.dot(Ko),l=Ko.dot(Oc),c=Ko.dot(lk),u=Oc.dot(Oc),d=Oc.dot(lk),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,Lc)===null?!1:Lc.x>=0&&Lc.y>=0&&Lc.x+Lc.y<=1}static getInterpolation(e,n,r,i,a,o,l,c){return this.getBarycoord(e,n,r,i,Lc)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(a,Lc.x),c.addScaledVector(o,Lc.y),c.addScaledVector(l,Lc.z),c)}static getInterpolatedAttribute(e,n,r,i,a,o){return hk.setScalar(0),fk.setScalar(0),mk.setScalar(0),hk.fromBufferAttribute(e,n),fk.fromBufferAttribute(e,r),mk.fromBufferAttribute(e,i),o.setScalar(0),o.addScaledVector(hk,a.x),o.addScaledVector(fk,a.y),o.addScaledVector(mk,a.z),o}static isFrontFacing(e,n,r,i){return Ko.subVectors(r,n),Oc.subVectors(e,n),Ko.cross(Oc).dot(i)<0}set(e,n,r){return this.a.copy(e),this.b.copy(n),this.c.copy(r),this}setFromPointsAndIndices(e,n,r,i){return this.a.copy(e[n]),this.b.copy(e[r]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,n,r,i){return this.a.fromBufferAttribute(e,n),this.b.fromBufferAttribute(e,r),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Ko.subVectors(this.c,this.b),Oc.subVectors(this.a,this.b),Ko.cross(Oc).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Wp.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return Wp.getBarycoord(e,this.a,this.b,this.c,n)}getInterpolation(e,n,r,i,a){return Wp.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}containsPoint(e){return Wp.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Wp.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;fp.subVectors(i,r),mp.subVectors(a,r),ck.subVectors(e,r);const c=fp.dot(ck),u=mp.dot(ck);if(c<=0&&u<=0)return n.copy(r);uk.subVectors(e,i);const d=fp.dot(uk),f=mp.dot(uk);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(fp,o);dk.subVectors(e,a);const p=fp.dot(dk),b=mp.dot(dk);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 zV.subVectors(a,i),l=(f-d)/(f-d+(p-b)),n.copy(i).addScaledVector(zV,l);const v=1/(x+y+m);return o=y*v,l=m*v,n.copy(r).addScaledVector(fp,o).addScaledVector(mp,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};const _ee={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},od={h:0,s:0,l:0},G_={h:0,s:0,l:0};function pk(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 On=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=_o){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Wn.colorSpaceToWorking(this,n),this}setRGB(e,n,r,i=Wn.workingColorSpace){return this.r=e,this.g=n,this.b=r,Wn.colorSpaceToWorking(this,i),this}setHSL(e,n,r,i=Wn.workingColorSpace){if(e=L3e(e,1),n=Dn(n,0,1),r=Dn(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=pk(o,a,e+1/3),this.g=pk(o,a,e),this.b=pk(o,a,e-1/3)}return Wn.colorSpaceToWorking(this,i),this}setStyle(e,n=_o){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=_o){const r=_ee[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=uu(e.r),this.g=uu(e.g),this.b=uu(e.b),this}copyLinearToSRGB(e){return this.r=dg(e.r),this.g=dg(e.g),this.b=dg(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=_o){return Wn.workingToColorSpace(Ra.copy(this),e),Math.round(Dn(Ra.r*255,0,255))*65536+Math.round(Dn(Ra.g*255,0,255))*256+Math.round(Dn(Ra.b*255,0,255))}getHexString(e=_o){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=Wn.workingColorSpace){Wn.workingToColorSpace(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=Wn.workingColorSpace){return Wn.workingToColorSpace(Ra.copy(this),n),e.r=Ra.r,e.g=Ra.g,e.b=Ra.b,e}getStyle(e=_o){Wn.workingToColorSpace(Ra.copy(this),e);const n=Ra.r,r=Ra.g,i=Ra.b;return e!==_o?`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(od),this.setHSL(od.h+e,od.s+n,od.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(od),e.getHSL(G_);const r=ZC(od.h,G_.h,n),i=ZC(od.s,G_.s,n),a=ZC(od.l,G_.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 On;On.NAMES=_ee;let Z3e=0,hx=class extends xm{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Z3e++}),this.uuid=Yy(),this.name="",this.type="Material",this.blending=ug,this.side=ih,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=k3,this.blendDst=j3,this.blendEquation=sf,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new On(0,0,0),this.blendAlpha=0,this.depthFunc=kg,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=NV,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=ap,this.stencilZFail=ap,this.stencilZPass=ap,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!==ug&&(r.blending=this.blending),this.side!==ih&&(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!==k3&&(r.blendSrc=this.blendSrc),this.blendDst!==j3&&(r.blendDst=this.blendDst),this.blendEquation!==sf&&(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!==kg&&(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!==NV&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==ap&&(r.stencilFail=this.stencilFail),this.stencilZFail!==ap&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==ap&&(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++}},dL=class extends hx{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new On(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 ah,this.combine=eL,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 Si=new tt,W_=new Nn;let Q3e=0,ko=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:Q3e++}),this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=r,this.usage=EV,this.updateRanges=[],this.gpuType=Hl,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++)W_.fromBufferAttribute(this,n),W_.applyMatrix3(e),this.setXY(n,W_.x,W_.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)Si.fromBufferAttribute(this,n),Si.applyMatrix3(e),this.setXYZ(n,Si.x,Si.y,Si.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)Si.fromBufferAttribute(this,n),Si.applyMatrix4(e),this.setXYZ(n,Si.x,Si.y,Si.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)Si.fromBufferAttribute(this,n),Si.applyNormalMatrix(e),this.setXYZ(n,Si.x,Si.y,Si.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)Si.fromBufferAttribute(this,n),Si.transformDirection(e),this.setXYZ(n,Si.x,Si.y,Si.z);return this}set(e,n=0){return this.array.set(e,n),this}getComponent(e,n){let r=this.array[e*this.itemSize+n];return this.normalized&&(r=vb(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=gs(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=vb(n,this.array)),n}setX(e,n){return this.normalized&&(n=gs(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=vb(n,this.array)),n}setY(e,n){return this.normalized&&(n=gs(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=vb(n,this.array)),n}setZ(e,n){return this.normalized&&(n=gs(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=vb(n,this.array)),n}setW(e,n){return this.normalized&&(n=gs(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=gs(n,this.array),r=gs(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=gs(n,this.array),r=gs(r,this.array),i=gs(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=gs(n,this.array),r=gs(r,this.array),i=gs(i,this.array),a=gs(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!==EV&&(e.usage=this.usage),e}},wee=class extends ko{constructor(e,n,r){super(new Uint16Array(e),n,r)}},See=class extends ko{constructor(e,n,r){super(new Uint32Array(e),n,r)}},Ys=class extends ko{constructor(e,n,r){super(new Float32Array(e),n,r)}},J3e=0;const mo=new gi,gk=new to,pp=new tt,Us=new am,Nb=new am,qi=new tt;let vl=class Mee extends xm{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:J3e++}),this.uuid=Yy(),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(fee(e)?See:wee)(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 Tn().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 gk.lookAt(e),gk.updateMatrix(),this.applyMatrix4(gk.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(pp).negate(),this.translate(pp.x,pp.y,pp.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 Ys(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 am);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Yn("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new tt(-1/0,-1/0,-1/0),new tt(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))&&Yn('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 hE);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Yn("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new tt,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];Nb.setFromBufferAttribute(l),this.morphTargetsRelative?(qi.addVectors(Us.min,Nb.min),Us.expandByPoint(qi),qi.addVectors(Us.max,Nb.max),Us.expandByPoint(qi)):(Us.expandByPoint(Nb.min),Us.expandByPoint(Nb.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&&(pp.fromBufferAttribute(e,u),qi.add(pp)),i=Math.max(i,r.distanceToSquared(qi))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&Yn('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){Yn("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 ko(new Float32Array(4*r.count),4));const o=this.getAttribute("tangent"),l=[],c=[];for(let O=0;O<r.count;O++)l[O]=new tt,c[O]=new tt;const u=new tt,d=new tt,f=new tt,m=new Nn,p=new Nn,b=new Nn,y=new tt,x=new tt;function v(O,C,D){u.fromBufferAttribute(r,O),d.fromBufferAttribute(r,C),f.fromBufferAttribute(r,D),m.fromBufferAttribute(a,O),p.fromBufferAttribute(a,C),b.fromBufferAttribute(a,D),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[O].add(y),l[C].add(y),l[D].add(y),c[O].add(x),c[C].add(x),c[D].add(x))}let S=this.groups;S.length===0&&(S=[{start:0,count:e.count}]);for(let O=0,C=S.length;O<C;++O){const D=S[O],U=D.start,L=D.count;for(let q=U,P=U+L;q<P;q+=3)v(e.getX(q+0),e.getX(q+1),e.getX(q+2))}const M=new tt,A=new tt,T=new tt,k=new tt;function E(O){T.fromBufferAttribute(i,O),k.copy(T);const C=l[O];M.copy(C),M.sub(T.multiplyScalar(T.dot(C))).normalize(),A.crossVectors(k,C);const U=A.dot(c[O])<0?-1:1;o.setXYZW(O,M.x,M.y,M.z,U)}for(let O=0,C=S.length;O<C;++O){const D=S[O],U=D.start,L=D.count;for(let q=U,P=U+L;q<P;q+=3)E(e.getX(q+0)),E(e.getX(q+1)),E(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 ko(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 tt,a=new tt,o=new tt,l=new tt,c=new tt,u=new tt,d=new tt,f=new tt;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 ko(m,d,f)}if(this.index===null)return un("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new Mee,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 BV=new gi,Vh=new uL,q_=new hE,$V=new tt,K_=new tt,X_=new tt,Y_=new tt,xk=new tt,Z_=new tt,HV=new tt,Q_=new tt;let fl=class extends to{constructor(e=new vl,n=new dL){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){Z_.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?Z_.addScaledVector(xk,d):Z_.addScaledVector(xk.sub(n),d))}n.add(Z_)}return n}raycast(e,n){const r=this.geometry,i=this.material,a=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),q_.copy(r.boundingSphere),q_.applyMatrix4(a),Vh.copy(e.ray).recast(e.near),!(q_.containsPoint(Vh.origin)===!1&&(Vh.intersectSphere(q_,$V)===null||Vh.origin.distanceToSquared($V)>(e.far-e.near)**2))&&(BV.copy(a).invert(),Vh.copy(e.ray).applyMatrix4(BV),!(r.boundingBox!==null&&Vh.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,Vh)))}_computeIntersections(e,n,r){let i;const a=this.geometry,o=this.material,l=a.index,c=a.attributes.position,u=a.attributes.uv,d=a.attributes.uv1,f=a.attributes.normal,m=a.groups,p=a.drawRange;if(l!==null)if(Array.isArray(o))for(let b=0,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 A=S,T=M;A<T;A+=3){const k=l.getX(A),E=l.getX(A+1),O=l.getX(A+2);i=J_(this,v,e,r,u,d,f,k,E,O),i&&(i.faceIndex=Math.floor(A/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),A=l.getX(x+2);i=J_(this,o,e,r,u,d,f,S,M,A),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 A=S,T=M;A<T;A+=3){const k=A,E=A+1,O=A+2;i=J_(this,v,e,r,u,d,f,k,E,O),i&&(i.faceIndex=Math.floor(A/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,A=x+2;i=J_(this,o,e,r,u,d,f,S,M,A),i&&(i.faceIndex=Math.floor(x/3),n.push(i))}}}};function eRe(t,e,n,r,i,a,o,l){let c;if(e.side===Ms?c=r.intersectTriangle(o,a,i,!0,l):c=r.intersectTriangle(i,a,o,e.side===ih,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 J_(t,e,n,r,i,a,o,l,c,u){t.getVertexPosition(l,K_),t.getVertexPosition(c,X_),t.getVertexPosition(u,Y_);const d=eRe(t,e,n,r,K_,X_,Y_,HV);if(d){const f=new tt;Mb.getBarycoord(HV,K_,X_,Y_,f),i&&(d.uv=Mb.getInterpolatedAttribute(i,l,c,u,f,new Nn)),a&&(d.uv1=Mb.getInterpolatedAttribute(a,l,c,u,f,new Nn)),o&&(d.normal=Mb.getInterpolatedAttribute(o,l,c,u,f,new tt),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const m={a:l,b:c,c:u,normal:new tt,materialIndex:0};Mb.getNormal(K_,X_,Y_,m.normal),d.face=m,d.barycoord=f}return d}let hL=class Nee extends vl{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 Ys(u,3)),this.setAttribute("normal",new Ys(d,3)),this.setAttribute("uv",new Ys(f,2));function b(y,x,v,S,M,A,T,k,E,O,C){const D=A/E,U=T/O,L=A/2,q=T/2,P=k/2,W=E+1,K=O+1;let V=0,Q=0;const re=new tt;for(let J=0;J<K;J++){const z=J*U-q;for(let G=0;G<W;G++){const ne=G*D-L;re[y]=ne*S,re[x]=z*M,re[v]=P,u.push(re.x,re.y,re.z),re[y]=0,re[x]=0,re[v]=k>0?1:-1,d.push(re.x,re.y,re.z),f.push(G/E),f.push(1-J/O),V+=1}}for(let J=0;J<O;J++)for(let z=0;z<E;z++){const G=m+z+W*J,ne=m+z+W*(J+1),ae=m+(z+1)+W*(J+1),de=m+(z+1)+W*J;c.push(G,ne,de),c.push(ne,ae,de),Q+=6}l.addGroup(p,Q,C),p+=Q,m+=V}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Nee(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function Dg(t){const e={};for(const n in t){e[n]={};for(const r in t[n]){const i=t[n][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(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 Ka(t){const e={};for(let n=0;n<t.length;n++){const r=Dg(t[n]);for(const i in r)e[i]=r[i]}return e}function tRe(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function Eee(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Wn.workingColorSpace}const nRe={clone:Dg,merge:Ka};var rRe=`void main() {
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
- }`,iRe=`void main() {
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
- }`;let ac=class extends hx{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=rRe,this.fragmentShader=iRe,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=Dg(e.uniforms),this.uniformsGroups=tRe(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}},Aee=class extends to{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new gi,this.projectionMatrix=new gi,this.projectionMatrixInverse=new gi,this.coordinateSystem=Vl,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 ld=new tt,VV=new Nn,GV=new Nn;let Mo=class extends Aee{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=_R*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(b1*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return _R*2*Math.atan(Math.tan(b1*.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){ld.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(ld.x,ld.y).multiplyScalar(-e/ld.z),ld.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),r.set(ld.x,ld.y).multiplyScalar(-e/ld.z)}getViewSize(e,n){return this.getViewBounds(e,VV,GV),n.subVectors(GV,VV)}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(b1*.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 gp=-90,xp=1;let aRe=class extends to{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new Mo(gp,xp,e,n);i.layers=this.layers,this.add(i);const a=new Mo(gp,xp,e,n);a.layers=this.layers,this.add(a);const o=new Mo(gp,xp,e,n);o.layers=this.layers,this.add(o);const l=new Mo(gp,xp,e,n);l.layers=this.layers,this.add(l);const c=new Mo(gp,xp,e,n);c.layers=this.layers,this.add(c);const u=new Mo(gp,xp,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===VS)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}},Tee=class extends yl{constructor(e=[],n=rm,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}},Cee=class extends Xl{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 Tee(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 hL(5,5,5),a=new ac({name:"CubemapFromEquirect",uniforms:Dg(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:Ms,blending:cu});a.uniforms.tEquirect.value=n;const o=new fl(i,a),l=n.minFilter;return n.minFilter===vf&&(n.minFilter=Ba),new aRe(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)}},Wb=class extends to{constructor(){super(),this.isGroup=!0,this.type="Group"}};const sRe={type:"move"};let bk=class{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 tt,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new tt),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 tt,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new tt),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(sRe)))}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]}},oRe=class extends to{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 ah,this.environmentIntensity=1,this.environmentRotation=new ah,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}},lRe=class extends yl{constructor(e=null,n=1,r=1,i,a,o,l,c,u=Aa,d=Aa,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 yk=new tt,cRe=new tt,uRe=new Tn;let _d=class{constructor(e=new tt(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(cRe.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||uRe.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 Gh=new hE,dRe=new Nn(.5,.5),ew=new tt;let fL=class{constructor(e=new _d,n=new _d,r=new _d,i=new _d,a=new _d,o=new _d){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,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],A=a[14],T=a[15];if(i[0].setComponents(u-o,p-d,v-b,T-S).normalize(),i[1].setComponents(u+o,p+d,v+b,T+S).normalize(),i[2].setComponents(u+l,p+f,v+y,T+M).normalize(),i[3].setComponents(u-l,p-f,v-y,T-M).normalize(),r)i[4].setComponents(c,m,x,A).normalize(),i[5].setComponents(u-c,p-m,v-x,T-A).normalize();else if(i[4].setComponents(u-c,p-m,v-x,T-A).normalize(),n===Vl)i[5].setComponents(u+c,p+m,v+x,T+A).normalize();else if(n===VS)i[5].setComponents(c,m,x,A).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+n);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Gh.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Gh.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Gh)}intersectsSprite(e){Gh.center.set(0,0,0);const n=dRe.distanceTo(e.center);return Gh.radius=.7071067811865476+n,Gh.applyMatrix4(e.matrixWorld),this.intersectsSphere(Gh)}intersectsSphere(e){const n=this.planes,r=e.center,i=-e.radius;for(let a=0;a<6;a++)if(n[a].distanceToPoint(r)<i)return!1;return!0}intersectsBox(e){const n=this.planes;for(let r=0;r<6;r++){const i=n[r];if(ew.x=i.normal.x>0?e.max.x:e.min.x,ew.y=i.normal.y>0?e.max.y:e.min.y,ew.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(ew)<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)}},kee=class extends hx{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new On(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 WS=new tt,qS=new tt,WV=new gi,Eb=new uL,tw=new hE,vk=new tt,qV=new tt;let hRe=class extends to{constructor(e=new vl,n=new kee){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++)WS.fromBufferAttribute(n,i-1),qS.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=WS.distanceTo(qS);e.setAttribute("lineDistance",new Ys(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(),tw.copy(r.boundingSphere),tw.applyMatrix4(i),tw.radius+=a,e.ray.intersectsSphere(tw)===!1)return;WV.copy(i).invert(),Eb.copy(e.ray).applyMatrix4(WV);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=nw(this,e,Eb,c,v,S,y);M&&n.push(M)}if(this.isLineLoop){const y=d.getX(b-1),x=d.getX(p),v=nw(this,e,Eb,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=nw(this,e,Eb,c,y,y+1,y);v&&n.push(v)}if(this.isLineLoop){const y=nw(this,e,Eb,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 nw(t,e,n,r,i,a,o){const l=t.geometry.attributes.position;if(WS.fromBufferAttribute(l,i),qS.fromBufferAttribute(l,a),n.distanceSqToSegment(WS,qS,vk,qV)>r)return;vk.applyMatrix4(t.matrixWorld);const u=e.ray.origin.distanceTo(vk);if(!(u<e.near||u>e.far))return{distance:u,point:qV.clone().applyMatrix4(t.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:t}}const KV=new tt,XV=new tt;let fRe=class extends hRe{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)KV.fromBufferAttribute(n,i),XV.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+KV.distanceTo(XV);e.setAttribute("lineDistance",new Ys(r,1))}else un("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},ty=class extends yl{constructor(e,n,r=ic,i,a,o,l=Aa,c=Aa,u,d=Mu,f=1){if(d!==Mu&&d!==_f)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 cL(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 mRe extends ty{constructor(e,n=ic,r=rm,i,a,o=Aa,l=Aa,c,u=Mu){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 jee extends yl{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}let mL=class Pee extends vl{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 A=M*f-a;b.push(A,-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,A=S+u*(v+1),T=S+1+u*(v+1),k=S+1+u*v;p.push(M,A,k),p.push(A,T,k)}this.setIndex(p),this.setAttribute("position",new Ys(b,3)),this.setAttribute("normal",new Ys(y,3)),this.setAttribute("uv",new Ys(x,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Pee(e.width,e.height,e.widthSegments,e.heightSegments)}};class pRe extends ac{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class gRe extends hx{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new On(16777215),this.specular=new On(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new On(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=hee,this.normalScale=new Nn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ah,this.combine=eL,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 xRe=class extends hx{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=E3e,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}},bRe=class extends hx{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}},Ree=class extends to{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new On(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 _k=new gi,YV=new tt,ZV=new tt;let yRe=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Nn(512,512),this.mapType=Gs,this.map=null,this.mapPass=null,this.matrix=new gi,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new fL,this._frameExtents=new Nn(1,1),this._viewportCount=1,this._viewports=[new Ei(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;YV.setFromMatrixPosition(e.matrixWorld),n.position.copy(YV),ZV.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(ZV),n.updateMatrixWorld(),_k.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(_k,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(_k)}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}},pL=class extends Aee{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 vRe extends yRe{constructor(){super(new pL(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class QV extends Ree{constructor(e,n){super(e,n),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(to.DEFAULT_UP),this.updateMatrix(),this.target=new to,this.shadow=new vRe}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 _Re=class extends Ree{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}},wRe=class extends Mo{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},JV=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=Dn(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(Dn(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};class SRe extends fRe{constructor(e=10,n=10,r=4473924,i=8947848){r=new On(r),i=new On(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 vl;d.setAttribute("position",new Ys(c,3)),d.setAttribute("color",new Ys(u,3));const f=new kee({vertexColors:!0,toneMapped:!1});super(d,f),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class MRe extends xm{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 eG(t,e,n,r){const i=NRe(r);switch(n){case cee:return t*e;case dee:return t*e/i.components*i.byteLength;case iL:return t*e/i.components*i.byteLength;case Pg:return t*e*2/i.components*i.byteLength;case aL:return t*e*2/i.components*i.byteLength;case uee:return t*e*3/i.components*i.byteLength;case il:return t*e*4/i.components*i.byteLength;case sL:return t*e*4/i.components*i.byteLength;case m1:case p1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case g1:case x1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case V3:case W3:return Math.max(t,16)*Math.max(e,8)/4;case H3:case G3:return Math.max(t,8)*Math.max(e,8)/2;case q3:case K3:case Y3:case Z3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case X3:case Q3:case J3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case eR:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case tR:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case nR:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case rR:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case iR:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case aR:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case sR:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case oR:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case lR:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case cR:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case uR:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case dR:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case hR:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case fR:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case mR:case pR:case gR:return Math.ceil(t/4)*Math.ceil(e/4)*16;case xR:case bR:return Math.ceil(t/4)*Math.ceil(e/4)*8;case yR:case vR:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}function NRe(t){switch(t){case Gs:case aee:return{byteLength:1,components:1};case Q0:case see:case Su:return{byteLength:2,components:1};case nL:case rL:return{byteLength:2,components:4};case ic:case tL:case Hl:return{byteLength:4,components:1};case oee:case lee:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:J4}}));typeof window<"u"&&(window.__THREE__?un("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=J4);function Dee(){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 ERe(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 ARe=`#ifdef USE_ALPHAHASH
- if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
- #endif`,TRe=`#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`,CRe=`#ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
- #endif`,kRe=`#ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,jRe=`#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`,PRe=`#ifdef USE_ALPHATEST
- uniform float alphaTest;
- #endif`,RRe=`#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`,DRe=`#ifdef USE_AOMAP
- uniform sampler2D aoMap;
- uniform float aoMapIntensity;
- #endif`,ORe=`#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`,LRe=`#ifdef USE_BATCHING
- mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
- #endif`,IRe=`vec3 transformed = vec3( position );
- #ifdef USE_ALPHAHASH
- vPosition = vec3( position );
- #endif`,FRe=`vec3 objectNormal = vec3( normal );
- #ifdef USE_TANGENT
- vec3 objectTangent = vec3( tangent.xyz );
- #endif`,URe=`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`,zRe=`#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`,BRe=`#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`,$Re=`#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`,HRe=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
- #endif`,VRe=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- #endif`,GRe=`#if NUM_CLIPPING_PLANES > 0
- vClipPosition = - mvPosition.xyz;
- #endif`,WRe=`#if defined( USE_COLOR_ALPHA )
- diffuseColor *= vColor;
- #elif defined( USE_COLOR )
- diffuseColor.rgb *= vColor;
- #endif`,qRe=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR )
- varying vec3 vColor;
- #endif`,KRe=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
- varying vec3 vColor;
- #endif`,XRe=`#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`,YRe=`#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`,ZRe=`#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`,QRe=`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`,JRe=`#ifdef USE_DISPLACEMENTMAP
- uniform sampler2D displacementMap;
- uniform float displacementScale;
- uniform float displacementBias;
- #endif`,eDe=`#ifdef USE_DISPLACEMENTMAP
- transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
- #endif`,tDe=`#ifdef USE_EMISSIVEMAP
- vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
- #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
- emissiveColor = sRGBTransferEOTF( emissiveColor );
- #endif
- totalEmissiveRadiance *= emissiveColor.rgb;
- #endif`,nDe=`#ifdef USE_EMISSIVEMAP
- uniform sampler2D emissiveMap;
- #endif`,rDe="gl_FragColor = linearToOutputTexel( gl_FragColor );",iDe=`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 );
- }`,aDe=`#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`,sDe=`#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`,oDe=`#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`,lDe=`#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`,cDe=`#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`,uDe=`#ifdef USE_FOG
- vFogDepth = - mvPosition.z;
- #endif`,dDe=`#ifdef USE_FOG
- varying float vFogDepth;
- #endif`,hDe=`#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`,fDe=`#ifdef USE_FOG
- uniform vec3 fogColor;
- varying float vFogDepth;
- #ifdef FOG_EXP2
- uniform float fogDensity;
- #else
- uniform float fogNear;
- uniform float fogFar;
- #endif
- #endif`,mDe=`#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
- }`,pDe=`#ifdef USE_LIGHTMAP
- uniform sampler2D lightMap;
- uniform float lightMapIntensity;
- #endif`,gDe=`LambertMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularStrength = specularStrength;`,xDe=`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`,bDe=`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`,yDe=`#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`,vDe=`ToonMaterial material;
- material.diffuseColor = diffuseColor.rgb;`,_De=`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`,wDe=`BlinnPhongMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularColor = specular;
- material.specularShininess = shininess;
- material.specularStrength = specularStrength;`,SDe=`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`,MDe=`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`,NDe=`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 );
- }`,EDe=`
- 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`,ADe=`#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`,TDe=`#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`,CDe=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
- gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
- #endif`,kDe=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
- uniform float logDepthBufFC;
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,jDe=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,PDe=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
- vFragDepth = 1.0 + gl_Position.w;
- vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
- #endif`,RDe=`#ifdef USE_MAP
- vec4 sampledDiffuseColor = texture2D( map, vMapUv );
- #ifdef DECODE_VIDEO_TEXTURE
- sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
- #endif
- diffuseColor *= sampledDiffuseColor;
- #endif`,DDe=`#ifdef USE_MAP
- uniform sampler2D map;
- #endif`,ODe=`#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`,LDe=`#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`,IDe=`float metalnessFactor = metalness;
- #ifdef USE_METALNESSMAP
- vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
- metalnessFactor *= texelMetalness.b;
- #endif`,FDe=`#ifdef USE_METALNESSMAP
- uniform sampler2D metalnessMap;
- #endif`,UDe=`#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`,zDe=`#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`,BDe=`#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`,$De=`#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`,HDe=`#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`,VDe=`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;`,GDe=`#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`,WDe=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,qDe=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,KDe=`#ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #ifdef USE_TANGENT
- vTangent = normalize( transformedTangent );
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
- #endif
- #endif`,XDe=`#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`,YDe=`#ifdef USE_CLEARCOAT
- vec3 clearcoatNormal = nonPerturbedNormal;
- #endif`,ZDe=`#ifdef USE_CLEARCOAT_NORMALMAP
- vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
- clearcoatMapN.xy *= clearcoatNormalScale;
- clearcoatNormal = normalize( tbn2 * clearcoatMapN );
- #endif`,QDe=`#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`,JDe=`#ifdef USE_IRIDESCENCEMAP
- uniform sampler2D iridescenceMap;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform sampler2D iridescenceThicknessMap;
- #endif`,eOe=`#ifdef OPAQUE
- diffuseColor.a = 1.0;
- #endif
- #ifdef USE_TRANSMISSION
- diffuseColor.a *= material.transmissionAlpha;
- #endif
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,tOe=`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 );
- }`,nOe=`#ifdef PREMULTIPLIED_ALPHA
- gl_FragColor.rgb *= gl_FragColor.a;
- #endif`,rOe=`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;`,iOe=`#ifdef DITHERING
- gl_FragColor.rgb = dithering( gl_FragColor.rgb );
- #endif`,aOe=`#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`,sOe=`float roughnessFactor = roughness;
- #ifdef USE_ROUGHNESSMAP
- vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
- roughnessFactor *= texelRoughness.g;
- #endif`,oOe=`#ifdef USE_ROUGHNESSMAP
- uniform sampler2D roughnessMap;
- #endif`,lOe=`#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`,cOe=`#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`,uOe=`#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`,dOe=`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;
- }`,hOe=`#ifdef USE_SKINNING
- mat4 boneMatX = getBoneMatrix( skinIndex.x );
- mat4 boneMatY = getBoneMatrix( skinIndex.y );
- mat4 boneMatZ = getBoneMatrix( skinIndex.z );
- mat4 boneMatW = getBoneMatrix( skinIndex.w );
- #endif`,fOe=`#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`,mOe=`#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`,pOe=`#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`,gOe=`float specularStrength;
- #ifdef USE_SPECULARMAP
- vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
- specularStrength = texelSpecular.r;
- #else
- specularStrength = 1.0;
- #endif`,xOe=`#ifdef USE_SPECULARMAP
- uniform sampler2D specularMap;
- #endif`,bOe=`#if defined( TONE_MAPPING )
- gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
- #endif`,yOe=`#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; }`,vOe=`#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`,_Oe=`#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`,wOe=`#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`,SOe=`#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`,MOe=`#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`,NOe=`#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 EOe=`varying vec2 vUv;
- uniform mat3 uvTransform;
- void main() {
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- gl_Position = vec4( position.xy, 1.0, 1.0 );
- }`,AOe=`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>
- }`,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=`#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>
- }`,kOe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,jOe=`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>
- }`,POe=`#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;
- }`,ROe=`#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
- }`,DOe=`#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;
- }`,OOe=`#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 );
- }`,LOe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }`,IOe=`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>
- }`,FOe=`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>
- }`,UOe=`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>
- }`,zOe=`#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>
- }`,BOe=`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>
- }`,$Oe=`#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>
- }`,HOe=`#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>
- }`,VOe=`#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;
- }`,GOe=`#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>
- }`,WOe=`#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
- }`,qOe=`#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
- }`,KOe=`#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>
- }`,XOe=`#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>
- }`,YOe=`#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
- }`,ZOe=`#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>
- }`,QOe=`#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>
- }`,JOe=`#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>
- }`,e4e=`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>
- }`,t4e=`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>
- }`,n4e=`#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>
- }`,r4e=`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>
- }`,i4e=`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>
- }`,a4e=`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>
- }`,Sn={alphahash_fragment:ARe,alphahash_pars_fragment:TRe,alphamap_fragment:CRe,alphamap_pars_fragment:kRe,alphatest_fragment:jRe,alphatest_pars_fragment:PRe,aomap_fragment:RRe,aomap_pars_fragment:DRe,batching_pars_vertex:ORe,batching_vertex:LRe,begin_vertex:IRe,beginnormal_vertex:FRe,bsdfs:URe,iridescence_fragment:zRe,bumpmap_pars_fragment:BRe,clipping_planes_fragment:$Re,clipping_planes_pars_fragment:HRe,clipping_planes_pars_vertex:VRe,clipping_planes_vertex:GRe,color_fragment:WRe,color_pars_fragment:qRe,color_pars_vertex:KRe,color_vertex:XRe,common:YRe,cube_uv_reflection_fragment:ZRe,defaultnormal_vertex:QRe,displacementmap_pars_vertex:JRe,displacementmap_vertex:eDe,emissivemap_fragment:tDe,emissivemap_pars_fragment:nDe,colorspace_fragment:rDe,colorspace_pars_fragment:iDe,envmap_fragment:aDe,envmap_common_pars_fragment:sDe,envmap_pars_fragment:oDe,envmap_pars_vertex:lDe,envmap_physical_pars_fragment:yDe,envmap_vertex:cDe,fog_vertex:uDe,fog_pars_vertex:dDe,fog_fragment:hDe,fog_pars_fragment:fDe,gradientmap_pars_fragment:mDe,lightmap_pars_fragment:pDe,lights_lambert_fragment:gDe,lights_lambert_pars_fragment:xDe,lights_pars_begin:bDe,lights_toon_fragment:vDe,lights_toon_pars_fragment:_De,lights_phong_fragment:wDe,lights_phong_pars_fragment:SDe,lights_physical_fragment:MDe,lights_physical_pars_fragment:NDe,lights_fragment_begin:EDe,lights_fragment_maps:ADe,lights_fragment_end:TDe,logdepthbuf_fragment:CDe,logdepthbuf_pars_fragment:kDe,logdepthbuf_pars_vertex:jDe,logdepthbuf_vertex:PDe,map_fragment:RDe,map_pars_fragment:DDe,map_particle_fragment:ODe,map_particle_pars_fragment:LDe,metalnessmap_fragment:IDe,metalnessmap_pars_fragment:FDe,morphinstance_vertex:UDe,morphcolor_vertex:zDe,morphnormal_vertex:BDe,morphtarget_pars_vertex:$De,morphtarget_vertex:HDe,normal_fragment_begin:VDe,normal_fragment_maps:GDe,normal_pars_fragment:WDe,normal_pars_vertex:qDe,normal_vertex:KDe,normalmap_pars_fragment:XDe,clearcoat_normal_fragment_begin:YDe,clearcoat_normal_fragment_maps:ZDe,clearcoat_pars_fragment:QDe,iridescence_pars_fragment:JDe,opaque_fragment:eOe,packing:tOe,premultiplied_alpha_fragment:nOe,project_vertex:rOe,dithering_fragment:iOe,dithering_pars_fragment:aOe,roughnessmap_fragment:sOe,roughnessmap_pars_fragment:oOe,shadowmap_pars_fragment:lOe,shadowmap_pars_vertex:cOe,shadowmap_vertex:uOe,shadowmask_pars_fragment:dOe,skinbase_vertex:hOe,skinning_pars_vertex:fOe,skinning_vertex:mOe,skinnormal_vertex:pOe,specularmap_fragment:gOe,specularmap_pars_fragment:xOe,tonemapping_fragment:bOe,tonemapping_pars_fragment:yOe,transmission_fragment:vOe,transmission_pars_fragment:_Oe,uv_pars_fragment:wOe,uv_pars_vertex:SOe,uv_vertex:MOe,worldpos_vertex:NOe,background_vert:EOe,background_frag:AOe,backgroundCube_vert:TOe,backgroundCube_frag:COe,cube_vert:kOe,cube_frag:jOe,depth_vert:POe,depth_frag:ROe,distance_vert:DOe,distance_frag:OOe,equirect_vert:LOe,equirect_frag:IOe,linedashed_vert:FOe,linedashed_frag:UOe,meshbasic_vert:zOe,meshbasic_frag:BOe,meshlambert_vert:$Oe,meshlambert_frag:HOe,meshmatcap_vert:VOe,meshmatcap_frag:GOe,meshnormal_vert:WOe,meshnormal_frag:qOe,meshphong_vert:KOe,meshphong_frag:XOe,meshphysical_vert:YOe,meshphysical_frag:ZOe,meshtoon_vert:QOe,meshtoon_frag:JOe,points_vert:e4e,points_frag:t4e,shadow_vert:n4e,shadow_frag:r4e,sprite_vert:i4e,sprite_frag:a4e},Ut={common:{diffuse:{value:new On(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Tn},alphaMap:{value:null},alphaMapTransform:{value:new Tn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Tn}},envmap:{envMap:{value:null},envMapRotation:{value:new Tn},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 Tn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Tn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Tn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Tn},normalScale:{value:new Nn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Tn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Tn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Tn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Tn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new On(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 On(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Tn},alphaTest:{value:0},uvTransform:{value:new Tn}},sprite:{diffuse:{value:new On(16777215)},opacity:{value:1},center:{value:new Nn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Tn},alphaMap:{value:null},alphaMapTransform:{value:new Tn},alphaTest:{value:0}}},Il={basic:{uniforms:Ka([Ut.common,Ut.specularmap,Ut.envmap,Ut.aomap,Ut.lightmap,Ut.fog]),vertexShader:Sn.meshbasic_vert,fragmentShader:Sn.meshbasic_frag},lambert:{uniforms:Ka([Ut.common,Ut.specularmap,Ut.envmap,Ut.aomap,Ut.lightmap,Ut.emissivemap,Ut.bumpmap,Ut.normalmap,Ut.displacementmap,Ut.fog,Ut.lights,{emissive:{value:new On(0)}}]),vertexShader:Sn.meshlambert_vert,fragmentShader:Sn.meshlambert_frag},phong:{uniforms:Ka([Ut.common,Ut.specularmap,Ut.envmap,Ut.aomap,Ut.lightmap,Ut.emissivemap,Ut.bumpmap,Ut.normalmap,Ut.displacementmap,Ut.fog,Ut.lights,{emissive:{value:new On(0)},specular:{value:new On(1118481)},shininess:{value:30}}]),vertexShader:Sn.meshphong_vert,fragmentShader:Sn.meshphong_frag},standard:{uniforms:Ka([Ut.common,Ut.envmap,Ut.aomap,Ut.lightmap,Ut.emissivemap,Ut.bumpmap,Ut.normalmap,Ut.displacementmap,Ut.roughnessmap,Ut.metalnessmap,Ut.fog,Ut.lights,{emissive:{value:new On(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Sn.meshphysical_vert,fragmentShader:Sn.meshphysical_frag},toon:{uniforms:Ka([Ut.common,Ut.aomap,Ut.lightmap,Ut.emissivemap,Ut.bumpmap,Ut.normalmap,Ut.displacementmap,Ut.gradientmap,Ut.fog,Ut.lights,{emissive:{value:new On(0)}}]),vertexShader:Sn.meshtoon_vert,fragmentShader:Sn.meshtoon_frag},matcap:{uniforms:Ka([Ut.common,Ut.bumpmap,Ut.normalmap,Ut.displacementmap,Ut.fog,{matcap:{value:null}}]),vertexShader:Sn.meshmatcap_vert,fragmentShader:Sn.meshmatcap_frag},points:{uniforms:Ka([Ut.points,Ut.fog]),vertexShader:Sn.points_vert,fragmentShader:Sn.points_frag},dashed:{uniforms:Ka([Ut.common,Ut.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Sn.linedashed_vert,fragmentShader:Sn.linedashed_frag},depth:{uniforms:Ka([Ut.common,Ut.displacementmap]),vertexShader:Sn.depth_vert,fragmentShader:Sn.depth_frag},normal:{uniforms:Ka([Ut.common,Ut.bumpmap,Ut.normalmap,Ut.displacementmap,{opacity:{value:1}}]),vertexShader:Sn.meshnormal_vert,fragmentShader:Sn.meshnormal_frag},sprite:{uniforms:Ka([Ut.sprite,Ut.fog]),vertexShader:Sn.sprite_vert,fragmentShader:Sn.sprite_frag},background:{uniforms:{uvTransform:{value:new Tn},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},backgroundRotation:{value:new Tn}},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},distance:{uniforms:Ka([Ut.common,Ut.displacementmap,{referencePosition:{value:new tt},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Sn.distance_vert,fragmentShader:Sn.distance_frag},shadow:{uniforms:Ka([Ut.lights,Ut.fog,{color:{value:new On(0)},opacity:{value:1}}]),vertexShader:Sn.shadow_vert,fragmentShader:Sn.shadow_frag}};Il.physical={uniforms:Ka([Il.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Tn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Tn},clearcoatNormalScale:{value:new Nn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Tn},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Tn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Tn},sheen:{value:0},sheenColor:{value:new On(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Tn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Tn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Tn},transmissionSamplerSize:{value:new Nn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Tn},attenuationDistance:{value:0},attenuationColor:{value:new On(0)},specularColor:{value:new On(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Tn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Tn},anisotropyVector:{value:new Nn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Tn}}]),vertexShader:Sn.meshphysical_vert,fragmentShader:Sn.meshphysical_frag};const rw={r:0,b:0,g:0},Wh=new ah,s4e=new gi;function o4e(t,e,n,r,i,a,o){const l=new On(0);let c=a===!0?0:1,u,d,f=null,m=0,p=null;function b(M){let A=M.isScene===!0?M.background:null;return A&&A.isTexture&&(A=(M.backgroundBlurriness>0?n:e).get(A)),A}function y(M){let A=!1;const T=b(M);T===null?v(l,c):T&&T.isColor&&(v(T,1),A=!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||A)&&(r.buffers.depth.setTest(!0),r.buffers.depth.setMask(!0),r.buffers.color.setMask(!0),t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil))}function x(M,A){const T=b(A);T&&(T.isCubeTexture||T.mapping===dE)?(d===void 0&&(d=new fl(new hL(1,1,1),new ac({name:"BackgroundCubeMaterial",uniforms:Dg(Il.backgroundCube.uniforms),vertexShader:Il.backgroundCube.vertexShader,fragmentShader:Il.backgroundCube.fragmentShader,side:Ms,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(k,E,O){this.matrixWorld.copyPosition(O.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),Wh.copy(A.backgroundRotation),Wh.x*=-1,Wh.y*=-1,Wh.z*=-1,T.isCubeTexture&&T.isRenderTargetTexture===!1&&(Wh.y*=-1,Wh.z*=-1),d.material.uniforms.envMap.value=T,d.material.uniforms.flipEnvMap.value=T.isCubeTexture&&T.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=A.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,d.material.uniforms.backgroundRotation.value.setFromMatrix4(s4e.makeRotationFromEuler(Wh)),d.material.toneMapped=Wn.getTransfer(T.colorSpace)!==or,(f!==T||m!==T.version||p!==t.toneMapping)&&(d.material.needsUpdate=!0,f=T,m=T.version,p=t.toneMapping),d.layers.enableAll(),M.unshift(d,d.geometry,d.material,0,0,null)):T&&T.isTexture&&(u===void 0&&(u=new fl(new mL(2,2),new ac({name:"BackgroundMaterial",uniforms:Dg(Il.background.uniforms),vertexShader:Il.background.vertexShader,fragmentShader:Il.background.fragmentShader,side:ih,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),u.geometry.deleteAttribute("normal"),Object.defineProperty(u.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(u)),u.material.uniforms.t2D.value=T,u.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,u.material.toneMapped=Wn.getTransfer(T.colorSpace)!==or,T.matrixAutoUpdate===!0&&T.updateMatrix(),u.material.uniforms.uvTransform.value.copy(T.matrix),(f!==T||m!==T.version||p!==t.toneMapping)&&(u.material.needsUpdate=!0,f=T,m=T.version,p=t.toneMapping),u.layers.enableAll(),M.unshift(u,u.geometry,u.material,0,0,null))}function v(M,A){M.getRGB(rw,Eee(t)),r.buffers.color.setClear(rw.r,rw.g,rw.b,A,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,A=1){l.set(M),c=A,v(l,c)},getClearAlpha:function(){return c},setClearAlpha:function(M){c=M,v(l,c)},render:y,addToRenderList:x,dispose:S}}function l4e(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),r={},i=m(null);let a=i,o=!1;function l(D,U,L,q,P){let W=!1;const K=f(q,L,U);a!==K&&(a=K,u(a.object)),W=p(D,q,L,P),W&&b(D,q,L,P),P!==null&&e.update(P,t.ELEMENT_ARRAY_BUFFER),(W||o)&&(o=!1,A(D,U,L,q),P!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(P).buffer))}function c(){return t.createVertexArray()}function u(D){return t.bindVertexArray(D)}function d(D){return t.deleteVertexArray(D)}function f(D,U,L){const q=L.wireframe===!0;let P=r[D.id];P===void 0&&(P={},r[D.id]=P);let W=P[U.id];W===void 0&&(W={},P[U.id]=W);let K=W[q];return K===void 0&&(K=m(c()),W[q]=K),K}function m(D){const U=[],L=[],q=[];for(let P=0;P<n;P++)U[P]=0,L[P]=0,q[P]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:U,enabledAttributes:L,attributeDivisors:q,object:D,attributes:{},index:null}}function p(D,U,L,q){const P=a.attributes,W=U.attributes;let K=0;const V=L.getAttributes();for(const Q in V)if(V[Q].location>=0){const J=P[Q];let z=W[Q];if(z===void 0&&(Q==="instanceMatrix"&&D.instanceMatrix&&(z=D.instanceMatrix),Q==="instanceColor"&&D.instanceColor&&(z=D.instanceColor)),J===void 0||J.attribute!==z||z&&J.data!==z.data)return!0;K++}return a.attributesNum!==K||a.index!==q}function b(D,U,L,q){const P={},W=U.attributes;let K=0;const V=L.getAttributes();for(const Q in V)if(V[Q].location>=0){let J=W[Q];J===void 0&&(Q==="instanceMatrix"&&D.instanceMatrix&&(J=D.instanceMatrix),Q==="instanceColor"&&D.instanceColor&&(J=D.instanceColor));const z={};z.attribute=J,J&&J.data&&(z.data=J.data),P[Q]=z,K++}a.attributes=P,a.attributesNum=K,a.index=q}function y(){const D=a.newAttributes;for(let U=0,L=D.length;U<L;U++)D[U]=0}function x(D){v(D,0)}function v(D,U){const L=a.newAttributes,q=a.enabledAttributes,P=a.attributeDivisors;L[D]=1,q[D]===0&&(t.enableVertexAttribArray(D),q[D]=1),P[D]!==U&&(t.vertexAttribDivisor(D,U),P[D]=U)}function S(){const D=a.newAttributes,U=a.enabledAttributes;for(let L=0,q=U.length;L<q;L++)U[L]!==D[L]&&(t.disableVertexAttribArray(L),U[L]=0)}function M(D,U,L,q,P,W,K){K===!0?t.vertexAttribIPointer(D,U,L,P,W):t.vertexAttribPointer(D,U,L,q,P,W)}function A(D,U,L,q){y();const P=q.attributes,W=L.getAttributes(),K=U.defaultAttributeValues;for(const V in W){const Q=W[V];if(Q.location>=0){let re=P[V];if(re===void 0&&(V==="instanceMatrix"&&D.instanceMatrix&&(re=D.instanceMatrix),V==="instanceColor"&&D.instanceColor&&(re=D.instanceColor)),re!==void 0){const J=re.normalized,z=re.itemSize,G=e.get(re);if(G===void 0)continue;const ne=G.buffer,ae=G.type,de=G.bytesPerElement,fe=ae===t.INT||ae===t.UNSIGNED_INT||re.gpuType===tL;if(re.isInterleavedBufferAttribute){const ie=re.data,Ae=ie.stride,me=re.offset;if(ie.isInstancedInterleavedBuffer){for(let Ne=0;Ne<Q.locationSize;Ne++)v(Q.location+Ne,ie.meshPerAttribute);D.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=ie.meshPerAttribute*ie.count)}else for(let Ne=0;Ne<Q.locationSize;Ne++)x(Q.location+Ne);t.bindBuffer(t.ARRAY_BUFFER,ne);for(let Ne=0;Ne<Q.locationSize;Ne++)M(Q.location+Ne,z/Q.locationSize,ae,J,Ae*de,(me+z/Q.locationSize*Ne)*de,fe)}else{if(re.isInstancedBufferAttribute){for(let ie=0;ie<Q.locationSize;ie++)v(Q.location+ie,re.meshPerAttribute);D.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=re.meshPerAttribute*re.count)}else for(let ie=0;ie<Q.locationSize;ie++)x(Q.location+ie);t.bindBuffer(t.ARRAY_BUFFER,ne);for(let ie=0;ie<Q.locationSize;ie++)M(Q.location+ie,z/Q.locationSize,ae,J,z*de,z/Q.locationSize*ie*de,fe)}}else if(K!==void 0){const J=K[V];if(J!==void 0)switch(J.length){case 2:t.vertexAttrib2fv(Q.location,J);break;case 3:t.vertexAttrib3fv(Q.location,J);break;case 4:t.vertexAttrib4fv(Q.location,J);break;default:t.vertexAttrib1fv(Q.location,J)}}}}S()}function T(){O();for(const D in r){const U=r[D];for(const L in U){const q=U[L];for(const P in q)d(q[P].object),delete q[P];delete U[L]}delete r[D]}}function k(D){if(r[D.id]===void 0)return;const U=r[D.id];for(const L in U){const q=U[L];for(const P in q)d(q[P].object),delete q[P];delete U[L]}delete r[D.id]}function E(D){for(const U in r){const L=r[U];if(L[D.id]===void 0)continue;const q=L[D.id];for(const P in q)d(q[P].object),delete q[P];delete L[D.id]}}function O(){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:O,resetDefaultState:C,dispose:T,releaseStatesOfGeometry:k,releaseStatesOfProgram:E,initAttributes:y,enableAttribute:x,disableUnusedAttributes:S}}function c4e(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 u4e(t,e,n,r){let i;function a(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const E=e.get("EXT_texture_filter_anisotropic");i=t.getParameter(E.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function o(E){return!(E!==il&&r.convert(E)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT))}function l(E){const O=E===Su&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(E!==Gs&&r.convert(E)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&E!==Hl&&!O)}function c(E){if(E==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";E="mediump"}return E==="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),A=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),T=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:A,maxSamples:T,samples:k}}function d4e(t){const e=this;let n=null,r=0,i=!1,a=!1;const o=new _d,l=new Tn,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 A=v.clippingState||null;c.value=A,A=d(b,m,M,p);for(let T=0;T!==M;++T)A[T]=n[T];v.clippingState=A,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,A=p;M!==y;++M,A+=4)o.copy(f[M]).applyMatrix4(S,l),o.normal.toArray(x,A),x[A+3]=o.constant}c.value=x,c.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,x}}function h4e(t){let e=new WeakMap;function n(o,l){return l===U3?o.mapping=rm:l===z3&&(o.mapping=jg),o}function r(o){if(o&&o.isTexture){const l=o.mapping;if(l===U3||l===z3)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 Cee(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 Rd=4,tG=[.125,.215,.35,.446,.526,.582],of=20,f4e=256,Ab=new pL,nG=new On;let wk=null,Sk=0,Mk=0,Nk=!1;const m4e=new tt;let rG=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=m4e}=a;wk=this._renderer.getRenderTarget(),Sk=this._renderer.getActiveCubeFace(),Mk=this._renderer.getActiveMipmapLevel(),Nk=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=sG(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=aG(),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(wk,Sk,Mk),this._renderer.xr.enabled=Nk,e.scissorTest=!1,bp(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===rm||e.mapping===jg?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),wk=this._renderer.getRenderTarget(),Sk=this._renderer.getActiveCubeFace(),Mk=this._renderer.getActiveMipmapLevel(),Nk=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:Ba,minFilter:Ba,generateMipmaps:!1,type:Su,format:il,colorSpace:Rg,depthBuffer:!1},i=iG(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=iG(e,n,r);const{_lodMax:a}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=p4e(a)),this._blurMaterial=x4e(a,e,n),this._ggxMaterial=g4e(a,e,n)}return i}_compileMaterial(e){const n=new fl(new vl,e);this._renderer.compile(n,Ab)}_sceneToCubeUV(e,n,r,i,a){const c=new Mo(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(nG),f.toneMapping=Kl,f.autoClear=!1,f.state.buffers.depth.getReversed()&&(f.setRenderTarget(i),f.clearDepth(),f.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new fl(new hL,new dL({name:"PMREM.Background",side:Ms,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(nG),v=!0);for(let M=0;M<6;M++){const A=M%3;A===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)):A===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 T=this._cubeSize;bp(i,A*T,M>2?T:0,T,T),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===rm||e.mapping===jg;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=sG()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=aG());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;bp(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(o,Ab)}_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-Rd?r-b+Rd:0),v=4*(this._cubeSize-y);c.envMap.value=e.texture,c.roughness.value=p,c.mipInt.value=b-n,bp(a,x,v,3*y,2*y),i.setRenderTarget(a),i.render(l,Ab),c.envMap.value=a.texture,c.roughness.value=0,c.mipInt.value=b-r,bp(e,x,v,3*y,2*y),i.setRenderTarget(e),i.render(l,Ab)}_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"&&Yn("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*of-1),y=a/b,x=isFinite(a)?1+Math.floor(d*y):of;x>of&&un(`sigmaRadians, ${a}, is too large and will clip, as it requested ${x} samples when the maximum is set to ${of}`);const v=[];let S=0;for(let E=0;E<of;++E){const O=E/y,C=Math.exp(-O*O/2);v.push(C),E===0?S+=C:E<x&&(S+=2*C)}for(let E=0;E<v.length;E++)v[E]=v[E]/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 A=this._sizeLods[i],T=3*A*(i>M-Rd?i-M+Rd:0),k=4*(this._cubeSize-A);bp(n,T,k,3*A,2*A),c.setRenderTarget(n),c.render(f,Ab)}};function p4e(t){const e=[],n=[],r=[];let i=t;const a=t-Rd+1+tG.length;for(let o=0;o<a;o++){const l=Math.pow(2,i);e.push(l);let c=1/l;o>t-Rd?c=tG[o-t+Rd-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),A=new Float32Array(v*b*p);for(let k=0;k<p;k++){const E=k%3*2/3-1,O=k>2?0:-1,C=[E,O,0,E+2/3,O,0,E+2/3,O+1,0,E,O,0,E+2/3,O+1,0,E,O+1,0];S.set(C,y*b*k),M.set(m,x*b*k);const D=[k,k,k,k,k,k];A.set(D,v*b*k)}const T=new vl;T.setAttribute("position",new ko(S,y)),T.setAttribute("uv",new ko(M,x)),T.setAttribute("faceIndex",new ko(A,v)),r.push(new fl(T,null)),i>Rd&&i--}return{lodMeshes:r,sizeLods:e,sigmas:n}}function iG(t,e,n){const r=new Xl(t,e,n);return r.texture.mapping=dE,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function bp(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function g4e(t,e,n){return new ac({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:f4e,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:fE(),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:cu,depthTest:!1,depthWrite:!1})}function x4e(t,e,n){const r=new Float32Array(of),i=new tt(0,1,0);return new ac({name:"SphericalGaussianBlur",defines:{n:of,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:fE(),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:cu,depthTest:!1,depthWrite:!1})}function aG(){return new ac({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:fE(),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:cu,depthTest:!1,depthWrite:!1})}function sG(){return new ac({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:fE(),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:cu,depthTest:!1,depthWrite:!1})}function fE(){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 b4e(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,u=c===U3||c===z3,d=c===rm||c===jg;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 rG(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 rG(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 y4e(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&&ey("WebGLRenderer: "+r+" extension not supported."),i}}}function v4e(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,A=S.length;M<A;M+=3){const T=S[M+0],k=S[M+1],E=S[M+2];m.push(T,k,k,E,E,T)}}else if(b!==void 0){const S=b.array;y=b.version;for(let M=0,A=S.length/3-1;M<A;M+=3){const T=M+0,k=M+1,E=M+2;m.push(T,k,k,E,E,T)}}else return;const x=new(fee(m)?See:wee)(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 _4e(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 w4e(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:Yn("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 S4e(t,e,n){const r=new WeakMap,i=new Ei;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 D=function(){O.dispose(),r.delete(l),l.removeEventListener("dispose",D)};var p=D;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 A=0;b===!0&&(A=1),y===!0&&(A=2),x===!0&&(A=3);let T=l.attributes.position.count*A,k=1;T>e.maxTextureSize&&(k=Math.ceil(T/e.maxTextureSize),T=e.maxTextureSize);const E=new Float32Array(T*k*4*f),O=new bee(E,T,k,f);O.type=Hl,O.needsUpdate=!0;const C=A*4;for(let U=0;U<f;U++){const L=v[U],q=S[U],P=M[U],W=T*k*4*U;for(let K=0;K<L.count;K++){const V=K*C;b===!0&&(i.fromBufferAttribute(L,K),E[W+V+0]=i.x,E[W+V+1]=i.y,E[W+V+2]=i.z,E[W+V+3]=0),y===!0&&(i.fromBufferAttribute(q,K),E[W+V+4]=i.x,E[W+V+5]=i.y,E[W+V+6]=i.z,E[W+V+7]=0),x===!0&&(i.fromBufferAttribute(P,K),E[W+V+8]=i.x,E[W+V+9]=i.y,E[W+V+10]=i.z,E[W+V+11]=P.itemSize===4?i.w:1)}}m={count:f,texture:O,size:new Nn(T,k)},r.set(l,m),l.addEventListener("dispose",D)}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 M4e(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 N4e={[ZJ]:"LINEAR_TONE_MAPPING",[QJ]:"REINHARD_TONE_MAPPING",[JJ]:"CINEON_TONE_MAPPING",[eee]:"ACES_FILMIC_TONE_MAPPING",[nee]:"AGX_TONE_MAPPING",[ree]:"NEUTRAL_TONE_MAPPING",[tee]:"CUSTOM_TONE_MAPPING"};function E4e(t,e,n,r,i){const a=new Xl(e,n,{type:t,depthBuffer:r,stencilBuffer:i}),o=new Xl(e,n,{type:Su,depthBuffer:!1,stencilBuffer:!1}),l=new vl;l.setAttribute("position",new Ys([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new Ys([0,2,0,0,2,0],2));const c=new pRe({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 fl(l,c),d=new pL(-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 A=0;A<x.length;A++){const T=x[A];T.setSize&&T.setSize(S,M)}},this.setEffects=function(S){x=S,v=x.length>0&&x[0].isRenderPass===!0;const M=a.width,A=a.height;for(let T=0;T<x.length;T++){const k=x[T];k.setSize&&k.setSize(M,A)}},this.begin=function(S,M){if(p||S.toneMapping===Kl&&x.length===0)return!1;if(y=M,M!==null){const A=M.width,T=M.height;(a.width!==A||a.height!==T)&&this.setSize(A,T)}return v===!1&&S.setRenderTarget(a),b=S.toneMapping,S.toneMapping=Kl,!0},this.hasRenderPass=function(){return v},this.end=function(S,M){S.toneMapping=b,p=!0;let A=a,T=o;for(let k=0;k<x.length;k++){const E=x[k];if(E.enabled!==!1&&(E.render(S,T,A,M),E.needsSwap!==!1)){const O=A;A=T,T=O}}if(f!==S.outputColorSpace||m!==S.toneMapping){f=S.outputColorSpace,m=S.toneMapping,c.defines={},Wn.getTransfer(f)===or&&(c.defines.SRGB_TRANSFER="");const k=N4e[m];k&&(c.defines[k]=""),c.needsUpdate=!0}c.uniforms.tDiffuse.value=A.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 Oee=new yl,SR=new ty(1,1),Lee=new bee,Iee=new H3e,Fee=new Tee,oG=[],lG=[],cG=new Float32Array(16),uG=new Float32Array(9),dG=new Float32Array(4);function fx(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let a=oG[i];if(a===void 0&&(a=new Float32Array(i),oG[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 mE(t,e){let n=lG[e];n===void 0&&(n=new Int32Array(e),lG[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function A4e(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function T4e(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 C4e(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 k4e(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 j4e(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;dG.set(r),t.uniformMatrix2fv(this.addr,!1,dG),Ii(n,r)}}function P4e(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;uG.set(r),t.uniformMatrix3fv(this.addr,!1,uG),Ii(n,r)}}function R4e(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;cG.set(r),t.uniformMatrix4fv(this.addr,!1,cG),Ii(n,r)}}function D4e(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function O4e(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 L4e(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 I4e(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 F4e(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function U4e(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 z4e(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 B4e(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 $4e(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?(SR.compareFunction=n.isReversedDepthBuffer()?lL:oL,a=SR):a=Oee,n.setTexture2D(e||a,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.setTexture3D(e||Iee,i)}function V4e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||Fee,i)}function G4e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||Lee,i)}function W4e(t){switch(t){case 5126:return A4e;case 35664:return T4e;case 35665:return C4e;case 35666:return k4e;case 35674:return j4e;case 35675:return P4e;case 35676:return R4e;case 5124:case 35670:return D4e;case 35667:case 35671:return O4e;case 35668:case 35672:return L4e;case 35669:case 35673:return I4e;case 5125:return F4e;case 36294:return U4e;case 36295:return z4e;case 36296:return B4e;case 35678:case 36198:case 36298:case 36306:case 35682:return $4e;case 35679:case 36299:case 36307:return H4e;case 35680:case 36300:case 36308:case 36293:return V4e;case 36289:case 36303:case 36311:case 36292:return G4e}}function q4e(t,e){t.uniform1fv(this.addr,e)}function K4e(t,e){const n=fx(e,this.size,2);t.uniform2fv(this.addr,n)}function X4e(t,e){const n=fx(e,this.size,3);t.uniform3fv(this.addr,n)}function Y4e(t,e){const n=fx(e,this.size,4);t.uniform4fv(this.addr,n)}function Z4e(t,e){const n=fx(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function Q4e(t,e){const n=fx(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function J4e(t,e){const n=fx(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function eLe(t,e){t.uniform1iv(this.addr,e)}function tLe(t,e){t.uniform2iv(this.addr,e)}function nLe(t,e){t.uniform3iv(this.addr,e)}function rLe(t,e){t.uniform4iv(this.addr,e)}function iLe(t,e){t.uniform1uiv(this.addr,e)}function aLe(t,e){t.uniform2uiv(this.addr,e)}function sLe(t,e){t.uniform3uiv(this.addr,e)}function oLe(t,e){t.uniform4uiv(this.addr,e)}function lLe(t,e,n){const r=this.cache,i=e.length,a=mE(n,i);Li(r,a)||(t.uniform1iv(this.addr,a),Ii(r,a));let o;this.type===t.SAMPLER_2D_SHADOW?o=SR:o=Oee;for(let l=0;l!==i;++l)n.setTexture2D(e[l]||o,a[l])}function cLe(t,e,n){const r=this.cache,i=e.length,a=mE(n,i);Li(r,a)||(t.uniform1iv(this.addr,a),Ii(r,a));for(let o=0;o!==i;++o)n.setTexture3D(e[o]||Iee,a[o])}function uLe(t,e,n){const r=this.cache,i=e.length,a=mE(n,i);Li(r,a)||(t.uniform1iv(this.addr,a),Ii(r,a));for(let o=0;o!==i;++o)n.setTextureCube(e[o]||Fee,a[o])}function dLe(t,e,n){const r=this.cache,i=e.length,a=mE(n,i);Li(r,a)||(t.uniform1iv(this.addr,a),Ii(r,a));for(let o=0;o!==i;++o)n.setTexture2DArray(e[o]||Lee,a[o])}function hLe(t){switch(t){case 5126:return q4e;case 35664:return K4e;case 35665:return X4e;case 35666:return Y4e;case 35674:return Z4e;case 35675:return Q4e;case 35676:return J4e;case 5124:case 35670:return eLe;case 35667:case 35671:return tLe;case 35668:case 35672:return nLe;case 35669:case 35673:return rLe;case 5125:return iLe;case 36294:return aLe;case 36295:return sLe;case 36296:return oLe;case 35678:case 36198:case 36298:case 36306:case 35682:return lLe;case 35679:case 36299:case 36307:return cLe;case 35680:case 36300:case 36308:case 36293:return uLe;case 36289:case 36303:case 36311:case 36292:return dLe}}let fLe=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=W4e(n.type)}},mLe=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=hLe(n.type)}},pLe=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 Ek=/(\w+)(\])?(\[|\.)?/g;function hG(t,e){t.seq.push(e),t.map[e.id]=e}function gLe(t,e,n){const r=t.name,i=r.length;for(Ek.lastIndex=0;;){const a=Ek.exec(r),o=Ek.lastIndex;let l=a[1];const c=a[2]==="]",u=a[3];if(c&&(l=l|0),u===void 0||u==="["&&o+2===i){hG(n,u===void 0?new fLe(l,t,e):new mLe(l,t,e));break}else{let f=n.map[l];f===void 0&&(f=new pLe(l),hG(n,f)),n=f}}}let _1=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);gLe(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 fG(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const xLe=37297;let bLe=0;function yLe(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 mG=new Tn;function vLe(t){Wn._getMatrix(mG,Wn.workingColorSpace,t);const e=`mat3( ${mG.elements.map(n=>n.toFixed(4))} )`;switch(Wn.getTransfer(t)){case HS:return[e,"LinearTransferOETF"];case or:return[e,"sRGBTransferOETF"];default:return un("WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}function pG(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+`
- `+yLe(t.getShaderSource(e),l)}else return a}function _Le(t,e){const n=vLe(e);return[`vec4 ${t}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
- `)}const wLe={[ZJ]:"Linear",[QJ]:"Reinhard",[JJ]:"Cineon",[eee]:"ACESFilmic",[nee]:"AgX",[ree]:"Neutral",[tee]:"Custom"};function SLe(t,e){const n=wLe[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 iw=new tt;function MLe(){Wn.getLuminanceCoefficients(iw);const t=iw.x.toFixed(4),e=iw.y.toFixed(4),n=iw.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${t}, ${e}, ${n} );`," return dot( weights, rgb );","}"].join(`
- `)}function NLe(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(qb).join(`
- `)}function ELe(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
- `)}function ALe(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 qb(t){return t!==""}function gG(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 xG(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const TLe=/^[ \t]*#include +<([\w\d./]+)>/gm;function MR(t){return t.replace(TLe,kLe)}const CLe=new Map;function kLe(t,e){let n=Sn[e];if(n===void 0){const r=CLe.get(e);if(r!==void 0)n=Sn[r],un('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return MR(n)}const jLe=/#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 bG(t){return t.replace(jLe,PLe)}function PLe(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 yG(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 RLe={[f1]:"SHADOWMAP_TYPE_PCF",[Gb]:"SHADOWMAP_TYPE_VSM"};function DLe(t){return RLe[t.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}const OLe={[rm]:"ENVMAP_TYPE_CUBE",[jg]:"ENVMAP_TYPE_CUBE",[dE]:"ENVMAP_TYPE_CUBE_UV"};function LLe(t){return t.envMap===!1?"ENVMAP_TYPE_CUBE":OLe[t.envMapMode]||"ENVMAP_TYPE_CUBE"}const ILe={[jg]:"ENVMAP_MODE_REFRACTION"};function FLe(t){return t.envMap===!1?"ENVMAP_MODE_REFLECTION":ILe[t.envMapMode]||"ENVMAP_MODE_REFLECTION"}const ULe={[eL]:"ENVMAP_BLENDING_MULTIPLY",[S3e]:"ENVMAP_BLENDING_MIX",[M3e]:"ENVMAP_BLENDING_ADD"};function zLe(t){return t.envMap===!1?"ENVMAP_BLENDING_NONE":ULe[t.combine]||"ENVMAP_BLENDING_NONE"}function BLe(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 $Le(t,e,n,r){const i=t.getContext(),a=n.defines;let o=n.vertexShader,l=n.fragmentShader;const c=DLe(n),u=LLe(n),d=FLe(n),f=zLe(n),m=BLe(n),p=NLe(n),b=ELe(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(qb).join(`
- `),x.length>0&&(x+=`
- `),v=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(qb).join(`
- `),v.length>0&&(v+=`
- `)):(x=[yG(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(qb).join(`
- `),v=[yG(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!==Kl?"#define TONE_MAPPING":"",n.toneMapping!==Kl?Sn.tonemapping_pars_fragment:"",n.toneMapping!==Kl?SLe("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Sn.colorspace_pars_fragment,_Le("linearToOutputTexel",n.outputColorSpace),MLe(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
- `].filter(qb).join(`
- `)),o=MR(o),o=gG(o,n),o=xG(o,n),l=MR(l),l=gG(l,n),l=xG(l,n),o=bG(o),l=bG(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===AV?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===AV?"":"#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,A=S+v+l,T=fG(i,i.VERTEX_SHADER,M),k=fG(i,i.FRAGMENT_SHADER,A);i.attachShader(y,T),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 E(U){if(t.debug.checkShaderErrors){const L=i.getProgramInfoLog(y)||"",q=i.getShaderInfoLog(T)||"",P=i.getShaderInfoLog(k)||"",W=L.trim(),K=q.trim(),V=P.trim();let Q=!0,re=!0;if(i.getProgramParameter(y,i.LINK_STATUS)===!1)if(Q=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,y,T,k);else{const J=pG(i,T,"vertex"),z=pG(i,k,"fragment");Yn("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+`
- `+J+`
- `+z)}else W!==""?un("WebGLProgram: Program Info Log:",W):(K===""||V==="")&&(re=!1);re&&(U.diagnostics={runnable:Q,programLog:W,vertexShader:{log:K,prefix:x},fragmentShader:{log:V,prefix:v}})}i.deleteShader(T),i.deleteShader(k),O=new _1(i,y),C=ALe(i,y)}let O;this.getUniforms=function(){return O===void 0&&E(this),O};let C;this.getAttributes=function(){return C===void 0&&E(this),C};let D=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return D===!1&&(D=i.getProgramParameter(y,xLe)),D},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(y),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=bLe++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=T,this.fragmentShader=k,this}let HLe=0,VLe=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 GLe(e),n.set(e,r)),r}},GLe=class{constructor(e){this.id=HLe++,this.code=e,this.usedTimes=0}};function WLe(t,e,n,r,i,a,o){const l=new vee,c=new VLe,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,D,U,L,q){const P=L.fog,W=q.geometry,K=C.isMeshStandardMaterial?L.environment:null,V=(C.isMeshStandardMaterial?n:e).get(C.envMap||K),Q=V&&V.mapping===dE?V.image.height:null,re=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 J=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,z=J!==void 0?J.length:0;let G=0;W.morphAttributes.position!==void 0&&(G=1),W.morphAttributes.normal!==void 0&&(G=2),W.morphAttributes.color!==void 0&&(G=3);let ne,ae,de,fe;if(re){const Lt=Il[re];ne=Lt.vertexShader,ae=Lt.fragmentShader}else ne=C.vertexShader,ae=C.fragmentShader,c.update(C),de=c.getVertexShaderID(C),fe=c.getFragmentShaderID(C);const ie=t.getRenderTarget(),Ae=t.state.buffers.depth.getReversed(),me=q.isInstancedMesh===!0,Ne=q.isBatchedMesh===!0,ye=!!C.map,le=!!C.matcap,$e=!!V,H=!!C.aoMap,ee=!!C.lightMap,X=!!C.bumpMap,B=!!C.normalMap,I=!!C.displacementMap,ce=!!C.emissiveMap,Te=!!C.metalnessMap,Le=!!C.roughnessMap,Ee=C.anisotropy>0,$=C.clearcoat>0,j=C.dispersion>0,Y=C.iridescence>0,ge=C.sheen>0,we=C.transmission>0,ve=Ee&&!!C.anisotropyMap,Ze=$&&!!C.clearcoatMap,Ie=$&&!!C.clearcoatNormalMap,qe=$&&!!C.clearcoatRoughnessMap,Je=Y&&!!C.iridescenceMap,Qe=Y&&!!C.iridescenceThicknessMap,oe=ge&&!!C.sheenColorMap,te=ge&&!!C.sheenRoughnessMap,Me=!!C.specularMap,Fe=!!C.specularColorMap,ot=!!C.specularIntensityMap,se=we&&!!C.transmissionMap,je=we&&!!C.thicknessMap,xe=!!C.gradientMap,Oe=!!C.alphaMap,Ue=C.alphaTest>0,Ce=!!C.alphaHash,We=!!C.extensions;let pt=Kl;C.toneMapped&&(ie===null||ie.isXRRenderTarget===!0)&&(pt=t.toneMapping);const kt={shaderID:re,shaderType:C.type,shaderName:C.name,vertexShader:ne,fragmentShader:ae,defines:C.defines,customVertexShaderID:de,customFragmentShaderID:fe,isRawShaderMaterial:C.isRawShaderMaterial===!0,glslVersion:C.glslVersion,precision:p,batching:Ne,batchingColor:Ne&&q._colorsTexture!==null,instancing:me,instancingColor:me&&q.instanceColor!==null,instancingMorph:me&&q.morphTexture!==null,outputColorSpace:ie===null?t.outputColorSpace:ie.isXRRenderTarget===!0?ie.texture.colorSpace:Rg,alphaToCoverage:!!C.alphaToCoverage,map:ye,matcap:le,envMap:$e,envMapMode:$e&&V.mapping,envMapCubeUVHeight:Q,aoMap:H,lightMap:ee,bumpMap:X,normalMap:B,displacementMap:I,emissiveMap:ce,normalMapObjectSpace:B&&C.normalMapType===A3e,normalMapTangentSpace:B&&C.normalMapType===hee,metalnessMap:Te,roughnessMap:Le,anisotropy:Ee,anisotropyMap:ve,clearcoat:$,clearcoatMap:Ze,clearcoatNormalMap:Ie,clearcoatRoughnessMap:qe,dispersion:j,iridescence:Y,iridescenceMap:Je,iridescenceThicknessMap:Qe,sheen:ge,sheenColorMap:oe,sheenRoughnessMap:te,specularMap:Me,specularColorMap:Fe,specularIntensityMap:ot,transmission:we,transmissionMap:se,thicknessMap:je,gradientMap:xe,opaque:C.transparent===!1&&C.blending===ug&&C.alphaToCoverage===!1,alphaMap:Oe,alphaTest:Ue,alphaHash:Ce,combine:C.combine,mapUv:ye&&y(C.map.channel),aoMapUv:H&&y(C.aoMap.channel),lightMapUv:ee&&y(C.lightMap.channel),bumpMapUv:X&&y(C.bumpMap.channel),normalMapUv:B&&y(C.normalMap.channel),displacementMapUv:I&&y(C.displacementMap.channel),emissiveMapUv:ce&&y(C.emissiveMap.channel),metalnessMapUv:Te&&y(C.metalnessMap.channel),roughnessMapUv:Le&&y(C.roughnessMap.channel),anisotropyMapUv:ve&&y(C.anisotropyMap.channel),clearcoatMapUv:Ze&&y(C.clearcoatMap.channel),clearcoatNormalMapUv:Ie&&y(C.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:qe&&y(C.clearcoatRoughnessMap.channel),iridescenceMapUv:Je&&y(C.iridescenceMap.channel),iridescenceThicknessMapUv:Qe&&y(C.iridescenceThicknessMap.channel),sheenColorMapUv:oe&&y(C.sheenColorMap.channel),sheenRoughnessMapUv:te&&y(C.sheenRoughnessMap.channel),specularMapUv:Me&&y(C.specularMap.channel),specularColorMapUv:Fe&&y(C.specularColorMap.channel),specularIntensityMapUv:ot&&y(C.specularIntensityMap.channel),transmissionMapUv:se&&y(C.transmissionMap.channel),thicknessMapUv:je&&y(C.thicknessMap.channel),alphaMapUv:Oe&&y(C.alphaMap.channel),vertexTangents:!!W.attributes.tangent&&(B||Ee),vertexColors:C.vertexColors,vertexAlphas:C.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,pointsUvs:q.isPoints===!0&&!!W.attributes.uv&&(ye||Oe),fog:!!P,useFog:C.fog===!0,fogExp2:!!P&&P.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:G,numDirLights:D.directional.length,numPointLights:D.point.length,numSpotLights:D.spot.length,numSpotLightMaps:D.spotLightMap.length,numRectAreaLights:D.rectArea.length,numHemiLights:D.hemi.length,numDirLightShadows:D.directionalShadowMap.length,numPointLightShadows:D.pointShadowMap.length,numSpotLightShadows:D.spotShadowMap.length,numSpotLightShadowsWithMaps:D.numSpotLightShadowsWithMaps,numLightProbes:D.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:C.dithering,shadowMapEnabled:t.shadowMap.enabled&&U.length>0,shadowMapType:t.shadowMap.type,toneMapping:pt,decodeVideoTexture:ye&&C.map.isVideoTexture===!0&&Wn.getTransfer(C.map.colorSpace)===or,decodeVideoTextureEmissive:ce&&C.emissiveMap.isVideoTexture===!0&&Wn.getTransfer(C.emissiveMap.colorSpace)===or,premultipliedAlpha:C.premultipliedAlpha,doubleSided:C.side===Fl,flipSided:C.side===Ms,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 kt.vertexUv1s=u.has(1),kt.vertexUv2s=u.has(2),kt.vertexUv3s=u.has(3),u.clear(),kt}function v(C){const D=[];if(C.shaderID?D.push(C.shaderID):(D.push(C.customVertexShaderID),D.push(C.customFragmentShaderID)),C.defines!==void 0)for(const U in C.defines)D.push(U),D.push(C.defines[U]);return C.isRawShaderMaterial===!1&&(S(D,C),M(D,C),D.push(t.outputColorSpace)),D.push(C.customProgramCacheKey),D.join()}function S(C,D){C.push(D.precision),C.push(D.outputColorSpace),C.push(D.envMapMode),C.push(D.envMapCubeUVHeight),C.push(D.mapUv),C.push(D.alphaMapUv),C.push(D.lightMapUv),C.push(D.aoMapUv),C.push(D.bumpMapUv),C.push(D.normalMapUv),C.push(D.displacementMapUv),C.push(D.emissiveMapUv),C.push(D.metalnessMapUv),C.push(D.roughnessMapUv),C.push(D.anisotropyMapUv),C.push(D.clearcoatMapUv),C.push(D.clearcoatNormalMapUv),C.push(D.clearcoatRoughnessMapUv),C.push(D.iridescenceMapUv),C.push(D.iridescenceThicknessMapUv),C.push(D.sheenColorMapUv),C.push(D.sheenRoughnessMapUv),C.push(D.specularMapUv),C.push(D.specularColorMapUv),C.push(D.specularIntensityMapUv),C.push(D.transmissionMapUv),C.push(D.thicknessMapUv),C.push(D.combine),C.push(D.fogExp2),C.push(D.sizeAttenuation),C.push(D.morphTargetsCount),C.push(D.morphAttributeCount),C.push(D.numDirLights),C.push(D.numPointLights),C.push(D.numSpotLights),C.push(D.numSpotLightMaps),C.push(D.numHemiLights),C.push(D.numRectAreaLights),C.push(D.numDirLightShadows),C.push(D.numPointLightShadows),C.push(D.numSpotLightShadows),C.push(D.numSpotLightShadowsWithMaps),C.push(D.numLightProbes),C.push(D.shadowMapType),C.push(D.toneMapping),C.push(D.numClippingPlanes),C.push(D.numClipIntersection),C.push(D.depthPacking)}function M(C,D){l.disableAll(),D.instancing&&l.enable(0),D.instancingColor&&l.enable(1),D.instancingMorph&&l.enable(2),D.matcap&&l.enable(3),D.envMap&&l.enable(4),D.normalMapObjectSpace&&l.enable(5),D.normalMapTangentSpace&&l.enable(6),D.clearcoat&&l.enable(7),D.iridescence&&l.enable(8),D.alphaTest&&l.enable(9),D.vertexColors&&l.enable(10),D.vertexAlphas&&l.enable(11),D.vertexUv1s&&l.enable(12),D.vertexUv2s&&l.enable(13),D.vertexUv3s&&l.enable(14),D.vertexTangents&&l.enable(15),D.anisotropy&&l.enable(16),D.alphaHash&&l.enable(17),D.batching&&l.enable(18),D.dispersion&&l.enable(19),D.batchingColor&&l.enable(20),D.gradientMap&&l.enable(21),C.push(l.mask),l.disableAll(),D.fog&&l.enable(0),D.useFog&&l.enable(1),D.flatShading&&l.enable(2),D.logarithmicDepthBuffer&&l.enable(3),D.reversedDepthBuffer&&l.enable(4),D.skinning&&l.enable(5),D.morphTargets&&l.enable(6),D.morphNormals&&l.enable(7),D.morphColors&&l.enable(8),D.premultipliedAlpha&&l.enable(9),D.shadowMapEnabled&&l.enable(10),D.doubleSided&&l.enable(11),D.flipSided&&l.enable(12),D.useDepthPacking&&l.enable(13),D.dithering&&l.enable(14),D.transmission&&l.enable(15),D.sheen&&l.enable(16),D.opaque&&l.enable(17),D.pointsUvs&&l.enable(18),D.decodeVideoTexture&&l.enable(19),D.decodeVideoTextureEmissive&&l.enable(20),D.alphaToCoverage&&l.enable(21),C.push(l.mask)}function A(C){const D=b[C.type];let U;if(D){const L=Il[D];U=nRe.clone(L.uniforms)}else U=C.uniforms;return U}function T(C,D){let U=f.get(D);return U!==void 0?++U.usedTimes:(U=new $Le(t,D,C,a),d.push(U),f.set(D,U)),U}function k(C){if(--C.usedTimes===0){const D=d.indexOf(C);d[D]=d[d.length-1],d.pop(),f.delete(C.cacheKey),C.destroy()}}function E(C){c.remove(C)}function O(){c.dispose()}return{getParameters:x,getProgramCacheKey:v,getUniforms:A,acquireProgram:T,releaseProgram:k,releaseShaderCache:E,programs:d,dispose:O}}function qLe(){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 KLe(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 vG(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function _G(){const t=[];let e=0;const n=[],r=[],i=[];function a(){e=0,n.length=0,r.length=0,i.length=0}function 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||KLe),r.length>1&&r.sort(m||vG),i.length>1&&i.sort(m||vG)}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 XLe(){let t=new WeakMap;function e(r,i){const a=t.get(r);let o;return a===void 0?(o=new _G,t.set(r,[o])):i>=a.length?(o=new _G,a.push(o)):o=a[i],o}function n(){t=new WeakMap}return{get:e,dispose:n}}function YLe(){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 tt,color:new On};break;case"SpotLight":n={position:new tt,direction:new tt,color:new On,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new tt,color:new On,distance:0,decay:0};break;case"HemisphereLight":n={direction:new tt,skyColor:new On,groundColor:new On};break;case"RectAreaLight":n={color:new On,position:new tt,halfWidth:new tt,halfHeight:new tt};break}return t[e.id]=n,n}}}function ZLe(){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 Nn};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Nn};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Nn,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let QLe=0;function JLe(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function eIe(t){const e=new YLe,n=ZLe(),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 tt);const i=new tt,a=new gi,o=new gi;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,A=0,T=0,k=0,E=0;u.sort(JLe);for(let C=0,D=u.length;C<D;C++){const U=u[C],L=U.color,q=U.intensity,P=U.distance;let W=null;if(U.shadow&&U.shadow.map&&(U.shadow.map.texture.format===Pg?W=U.shadow.map.texture:W=U.shadow.map.depthTexture||U.shadow.map.texture),U.isAmbientLight)d+=L.r*q,f+=L.g*q,m+=L.b*q;else if(U.isLightProbe){for(let K=0;K<9;K++)r.probe[K].addScaledVector(U.sh.coefficients[K],q);E++}else if(U.isDirectionalLight){const K=e.get(U);if(K.color.copy(U.color).multiplyScalar(U.intensity),U.castShadow){const V=U.shadow,Q=n.get(U);Q.shadowIntensity=V.intensity,Q.shadowBias=V.bias,Q.shadowNormalBias=V.normalBias,Q.shadowRadius=V.radius,Q.shadowMapSize=V.mapSize,r.directionalShadow[p]=Q,r.directionalShadowMap[p]=W,r.directionalShadowMatrix[p]=U.shadow.matrix,S++}r.directional[p]=K,p++}else if(U.isSpotLight){const K=e.get(U);K.position.setFromMatrixPosition(U.matrixWorld),K.color.copy(L).multiplyScalar(q),K.distance=P,K.coneCos=Math.cos(U.angle),K.penumbraCos=Math.cos(U.angle*(1-U.penumbra)),K.decay=U.decay,r.spot[y]=K;const V=U.shadow;if(U.map&&(r.spotLightMap[T]=U.map,T++,V.updateMatrices(U),U.castShadow&&k++),r.spotLightMatrix[y]=V.matrix,U.castShadow){const Q=n.get(U);Q.shadowIntensity=V.intensity,Q.shadowBias=V.bias,Q.shadowNormalBias=V.normalBias,Q.shadowRadius=V.radius,Q.shadowMapSize=V.mapSize,r.spotShadow[y]=Q,r.spotShadowMap[y]=W,A++}y++}else if(U.isRectAreaLight){const K=e.get(U);K.color.copy(L).multiplyScalar(q),K.halfWidth.set(U.width*.5,0,0),K.halfHeight.set(0,U.height*.5,0),r.rectArea[x]=K,x++}else if(U.isPointLight){const K=e.get(U);if(K.color.copy(U.color).multiplyScalar(U.intensity),K.distance=U.distance,K.decay=U.decay,U.castShadow){const V=U.shadow,Q=n.get(U);Q.shadowIntensity=V.intensity,Q.shadowBias=V.bias,Q.shadowNormalBias=V.normalBias,Q.shadowRadius=V.radius,Q.shadowMapSize=V.mapSize,Q.shadowCameraNear=V.camera.near,Q.shadowCameraFar=V.camera.far,r.pointShadow[b]=Q,r.pointShadowMap[b]=W,r.pointShadowMatrix[b]=U.shadow.matrix,M++}r.point[b]=K,b++}else if(U.isHemisphereLight){const K=e.get(U);K.skyColor.copy(U.color).multiplyScalar(q),K.groundColor.copy(U.groundColor).multiplyScalar(q),r.hemi[v]=K,v++}}x>0&&(t.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=Ut.LTC_FLOAT_1,r.rectAreaLTC2=Ut.LTC_FLOAT_2):(r.rectAreaLTC1=Ut.LTC_HALF_1,r.rectAreaLTC2=Ut.LTC_HALF_2)),r.ambient[0]=d,r.ambient[1]=f,r.ambient[2]=m;const O=r.hash;(O.directionalLength!==p||O.pointLength!==b||O.spotLength!==y||O.rectAreaLength!==x||O.hemiLength!==v||O.numDirectionalShadows!==S||O.numPointShadows!==M||O.numSpotShadows!==A||O.numSpotMaps!==T||O.numLightProbes!==E)&&(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=A,r.spotShadowMap.length=A,r.directionalShadowMatrix.length=S,r.pointShadowMatrix.length=M,r.spotLightMatrix.length=A+T-k,r.spotLightMap.length=T,r.numSpotLightShadowsWithMaps=k,r.numLightProbes=E,O.directionalLength=p,O.pointLength=b,O.spotLength=y,O.rectAreaLength=x,O.hemiLength=v,O.numDirectionalShadows=S,O.numPointShadows=M,O.numSpotShadows=A,O.numSpotMaps=T,O.numLightProbes=E,r.version=QLe++)}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 A=r.directional[f];A.direction.setFromMatrixPosition(M.matrixWorld),i.setFromMatrixPosition(M.target.matrixWorld),A.direction.sub(i),A.direction.transformDirection(x),f++}else if(M.isSpotLight){const A=r.spot[p];A.position.setFromMatrixPosition(M.matrixWorld),A.position.applyMatrix4(x),A.direction.setFromMatrixPosition(M.matrixWorld),i.setFromMatrixPosition(M.target.matrixWorld),A.direction.sub(i),A.direction.transformDirection(x),p++}else if(M.isRectAreaLight){const A=r.rectArea[b];A.position.setFromMatrixPosition(M.matrixWorld),A.position.applyMatrix4(x),o.identity(),a.copy(M.matrixWorld),a.premultiply(x),o.extractRotation(a),A.halfWidth.set(M.width*.5,0,0),A.halfHeight.set(0,M.height*.5,0),A.halfWidth.applyMatrix4(o),A.halfHeight.applyMatrix4(o),b++}else if(M.isPointLight){const A=r.point[m];A.position.setFromMatrixPosition(M.matrixWorld),A.position.applyMatrix4(x),m++}else if(M.isHemisphereLight){const A=r.hemi[y];A.direction.setFromMatrixPosition(M.matrixWorld),A.direction.transformDirection(x),y++}}}return{setup:l,setupView:c,state:r}}function wG(t){const e=new eIe(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 tIe(t){let e=new WeakMap;function n(i,a=0){const o=e.get(i);let l;return o===void 0?(l=new wG(t),e.set(i,[l])):a>=o.length?(l=new wG(t),o.push(l)):l=o[a],l}function r(){e=new WeakMap}return{get:n,dispose:r}}const nIe=`void main() {
- gl_Position = vec4( position, 1.0 );
- }`,rIe=`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 );
- }`,iIe=[new tt(1,0,0),new tt(-1,0,0),new tt(0,1,0),new tt(0,-1,0),new tt(0,0,1),new tt(0,0,-1)],aIe=[new tt(0,-1,0),new tt(0,-1,0),new tt(0,0,1),new tt(0,0,-1),new tt(0,-1,0),new tt(0,-1,0)],SG=new gi,Tb=new tt,Ak=new tt;function sIe(t,e,n){let r=new fL;const i=new Nn,a=new Nn,o=new Ei,l=new xRe,c=new bRe,u={},d=n.maxTextureSize,f={[ih]:Ms,[Ms]:ih,[Fl]:Fl},m=new ac({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Nn},radius:{value:4}},vertexShader:nIe,fragmentShader:rIe}),p=m.clone();p.defines.HORIZONTAL_PASS=1;const b=new vl;b.setAttribute("position",new ko(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new fl(b,m),x=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=f1;let v=this.type;this.render=function(k,E,O){if(x.enabled===!1||x.autoUpdate===!1&&x.needsUpdate===!1||k.length===0)return;k.type===i3e&&(un("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),k.type=f1);const C=t.getRenderTarget(),D=t.getActiveCubeFace(),U=t.getActiveMipmapLevel(),L=t.state;L.setBlending(cu),L.buffers.depth.getReversed()===!0?L.buffers.color.setClear(0,0,0,0):L.buffers.color.setClear(1,1,1,1),L.buffers.depth.setTest(!0),L.setScissorTest(!1);const q=v!==this.type;q&&E.traverse(function(P){P.material&&(Array.isArray(P.material)?P.material.forEach(W=>W.needsUpdate=!0):P.material.needsUpdate=!0)});for(let P=0,W=k.length;P<W;P++){const K=k[P],V=K.shadow;if(V===void 0){un("WebGLShadowMap:",K,"has no shadow.");continue}if(V.autoUpdate===!1&&V.needsUpdate===!1)continue;i.copy(V.mapSize);const Q=V.getFrameExtents();if(i.multiply(Q),a.copy(V.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(a.x=Math.floor(d/Q.x),i.x=a.x*Q.x,V.mapSize.x=a.x),i.y>d&&(a.y=Math.floor(d/Q.y),i.y=a.y*Q.y,V.mapSize.y=a.y)),V.map===null||q===!0){if(V.map!==null&&(V.map.depthTexture!==null&&(V.map.depthTexture.dispose(),V.map.depthTexture=null),V.map.dispose()),this.type===Gb){if(K.isPointLight){un("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}V.map=new Xl(i.x,i.y,{format:Pg,type:Su,minFilter:Ba,magFilter:Ba,generateMipmaps:!1}),V.map.texture.name=K.name+".shadowMap",V.map.depthTexture=new ty(i.x,i.y,Hl),V.map.depthTexture.name=K.name+".shadowMapDepth",V.map.depthTexture.format=Mu,V.map.depthTexture.compareFunction=null,V.map.depthTexture.minFilter=Aa,V.map.depthTexture.magFilter=Aa}else{K.isPointLight?(V.map=new Cee(i.x),V.map.depthTexture=new mRe(i.x,ic)):(V.map=new Xl(i.x,i.y),V.map.depthTexture=new ty(i.x,i.y,ic)),V.map.depthTexture.name=K.name+".shadowMap",V.map.depthTexture.format=Mu;const J=t.state.buffers.depth.getReversed();this.type===f1?(V.map.depthTexture.compareFunction=J?lL:oL,V.map.depthTexture.minFilter=Ba,V.map.depthTexture.magFilter=Ba):(V.map.depthTexture.compareFunction=null,V.map.depthTexture.minFilter=Aa,V.map.depthTexture.magFilter=Aa)}V.camera.updateProjectionMatrix()}const re=V.map.isWebGLCubeRenderTarget?6:1;for(let J=0;J<re;J++){if(V.map.isWebGLCubeRenderTarget)t.setRenderTarget(V.map,J),t.clear();else{J===0&&(t.setRenderTarget(V.map),t.clear());const z=V.getViewport(J);o.set(a.x*z.x,a.y*z.y,a.x*z.z,a.y*z.w),L.viewport(o)}if(K.isPointLight){const z=V.camera,G=V.matrix,ne=K.distance||z.far;ne!==z.far&&(z.far=ne,z.updateProjectionMatrix()),Tb.setFromMatrixPosition(K.matrixWorld),z.position.copy(Tb),Ak.copy(z.position),Ak.add(iIe[J]),z.up.copy(aIe[J]),z.lookAt(Ak),z.updateMatrixWorld(),G.makeTranslation(-Tb.x,-Tb.y,-Tb.z),SG.multiplyMatrices(z.projectionMatrix,z.matrixWorldInverse),V._frustum.setFromProjectionMatrix(SG,z.coordinateSystem,z.reversedDepth)}else V.updateMatrices(K);r=V.getFrustum(),A(E,O,V.camera,K,this.type)}V.isPointLightShadow!==!0&&this.type===Gb&&S(V,O),V.needsUpdate=!1}v=this.type,x.needsUpdate=!1,t.setRenderTarget(C,D,U)};function S(k,E){const O=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 Xl(i.x,i.y,{format:Pg,type:Su})),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(E,null,O,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(E,null,O,p,y,null)}function M(k,E,O,C){let D=null;const U=O.isPointLight===!0?k.customDistanceMaterial:k.customDepthMaterial;if(U!==void 0)D=U;else if(D=O.isPointLight===!0?c:l,t.localClippingEnabled&&E.clipShadows===!0&&Array.isArray(E.clippingPlanes)&&E.clippingPlanes.length!==0||E.displacementMap&&E.displacementScale!==0||E.alphaMap&&E.alphaTest>0||E.map&&E.alphaTest>0||E.alphaToCoverage===!0){const L=D.uuid,q=E.uuid;let P=u[L];P===void 0&&(P={},u[L]=P);let W=P[q];W===void 0&&(W=D.clone(),P[q]=W,E.addEventListener("dispose",T)),D=W}if(D.visible=E.visible,D.wireframe=E.wireframe,C===Gb?D.side=E.shadowSide!==null?E.shadowSide:E.side:D.side=E.shadowSide!==null?E.shadowSide:f[E.side],D.alphaMap=E.alphaMap,D.alphaTest=E.alphaToCoverage===!0?.5:E.alphaTest,D.map=E.map,D.clipShadows=E.clipShadows,D.clippingPlanes=E.clippingPlanes,D.clipIntersection=E.clipIntersection,D.displacementMap=E.displacementMap,D.displacementScale=E.displacementScale,D.displacementBias=E.displacementBias,D.wireframeLinewidth=E.wireframeLinewidth,D.linewidth=E.linewidth,O.isPointLight===!0&&D.isMeshDistanceMaterial===!0){const L=t.properties.get(D);L.light=O}return D}function A(k,E,O,C,D){if(k.visible===!1)return;if(k.layers.test(E.layers)&&(k.isMesh||k.isLine||k.isPoints)&&(k.castShadow||k.receiveShadow&&D===Gb)&&(!k.frustumCulled||r.intersectsObject(k))){k.modelViewMatrix.multiplyMatrices(O.matrixWorldInverse,k.matrixWorld);const q=e.update(k),P=k.material;if(Array.isArray(P)){const W=q.groups;for(let K=0,V=W.length;K<V;K++){const Q=W[K],re=P[Q.materialIndex];if(re&&re.visible){const J=M(k,re,C,D);k.onBeforeShadow(t,k,E,O,q,J,Q),t.renderBufferDirect(O,null,q,J,k,Q),k.onAfterShadow(t,k,E,O,q,J,Q)}}}else if(P.visible){const W=M(k,P,C,D);k.onBeforeShadow(t,k,E,O,q,W,null),t.renderBufferDirect(O,null,q,W,k,null),k.onAfterShadow(t,k,E,O,q,W,null)}}const L=k.children;for(let q=0,P=L.length;q<P;q++)A(L[q],E,O,C,D)}function T(k){k.target.removeEventListener("dispose",T);for(const O in u){const C=u[O],D=k.target.uuid;D in C&&(C[D].dispose(),delete C[D])}}}const oIe={[P3]:R3,[D3]:I3,[O3]:F3,[kg]:L3,[R3]:P3,[I3]:D3,[F3]:O3,[L3]:kg};function lIe(t,e){function n(){let se=!1;const je=new Ei;let xe=null;const Oe=new Ei(0,0,0,0);return{setMask:function(Ue){xe!==Ue&&!se&&(t.colorMask(Ue,Ue,Ue,Ue),xe=Ue)},setLocked:function(Ue){se=Ue},setClear:function(Ue,Ce,We,pt,kt){kt===!0&&(Ue*=pt,Ce*=pt,We*=pt),je.set(Ue,Ce,We,pt),Oe.equals(je)===!1&&(t.clearColor(Ue,Ce,We,pt),Oe.copy(je))},reset:function(){se=!1,xe=null,Oe.set(-1,0,0,0)}}}function r(){let se=!1,je=!1,xe=null,Oe=null,Ue=null;return{setReversed:function(Ce){if(je!==Ce){const We=e.get("EXT_clip_control");Ce?We.clipControlEXT(We.LOWER_LEFT_EXT,We.ZERO_TO_ONE_EXT):We.clipControlEXT(We.LOWER_LEFT_EXT,We.NEGATIVE_ONE_TO_ONE_EXT),je=Ce;const pt=Ue;Ue=null,this.setClear(pt)}},getReversed:function(){return je},setTest:function(Ce){Ce?ie(t.DEPTH_TEST):Ae(t.DEPTH_TEST)},setMask:function(Ce){xe!==Ce&&!se&&(t.depthMask(Ce),xe=Ce)},setFunc:function(Ce){if(je&&(Ce=oIe[Ce]),Oe!==Ce){switch(Ce){case P3:t.depthFunc(t.NEVER);break;case R3:t.depthFunc(t.ALWAYS);break;case D3:t.depthFunc(t.LESS);break;case kg:t.depthFunc(t.LEQUAL);break;case O3:t.depthFunc(t.EQUAL);break;case L3:t.depthFunc(t.GEQUAL);break;case I3:t.depthFunc(t.GREATER);break;case F3:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}Oe=Ce}},setLocked:function(Ce){se=Ce},setClear:function(Ce){Ue!==Ce&&(je&&(Ce=1-Ce),t.clearDepth(Ce),Ue=Ce)},reset:function(){se=!1,xe=null,Oe=null,Ue=null,je=!1}}}function i(){let se=!1,je=null,xe=null,Oe=null,Ue=null,Ce=null,We=null,pt=null,kt=null;return{setTest:function(Lt){se||(Lt?ie(t.STENCIL_TEST):Ae(t.STENCIL_TEST))},setMask:function(Lt){je!==Lt&&!se&&(t.stencilMask(Lt),je=Lt)},setFunc:function(Lt,ln,Gt){(xe!==Lt||Oe!==ln||Ue!==Gt)&&(t.stencilFunc(Lt,ln,Gt),xe=Lt,Oe=ln,Ue=Gt)},setOp:function(Lt,ln,Gt){(Ce!==Lt||We!==ln||pt!==Gt)&&(t.stencilOp(Lt,ln,Gt),Ce=Lt,We=ln,pt=Gt)},setLocked:function(Lt){se=Lt},setClear:function(Lt){kt!==Lt&&(t.clearStencil(Lt),kt=Lt)},reset:function(){se=!1,je=null,xe=null,Oe=null,Ue=null,Ce=null,We=null,pt=null,kt=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,A=null,T=null,k=null,E=new On(0,0,0),O=0,C=!1,D=null,U=null,L=null,q=null,P=null;const W=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let K=!1,V=0;const Q=t.getParameter(t.VERSION);Q.indexOf("WebGL")!==-1?(V=parseFloat(/^WebGL (\d)/.exec(Q)[1]),K=V>=1):Q.indexOf("OpenGL ES")!==-1&&(V=parseFloat(/^OpenGL ES (\d)/.exec(Q)[1]),K=V>=2);let re=null,J={};const z=t.getParameter(t.SCISSOR_BOX),G=t.getParameter(t.VIEWPORT),ne=new Ei().fromArray(z),ae=new Ei().fromArray(G);function de(se,je,xe,Oe){const Ue=new Uint8Array(4),Ce=t.createTexture();t.bindTexture(se,Ce),t.texParameteri(se,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(se,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let We=0;We<xe;We++)se===t.TEXTURE_3D||se===t.TEXTURE_2D_ARRAY?t.texImage3D(je,0,t.RGBA,1,1,Oe,0,t.RGBA,t.UNSIGNED_BYTE,Ue):t.texImage2D(je+We,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Ue);return Ce}const fe={};fe[t.TEXTURE_2D]=de(t.TEXTURE_2D,t.TEXTURE_2D,1),fe[t.TEXTURE_CUBE_MAP]=de(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),fe[t.TEXTURE_2D_ARRAY]=de(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),fe[t.TEXTURE_3D]=de(t.TEXTURE_3D,t.TEXTURE_3D,1,1),a.setClear(0,0,0,1),o.setClear(1),l.setClear(0),ie(t.DEPTH_TEST),o.setFunc(kg),X(!1),B(_V),ie(t.CULL_FACE),H(cu);function ie(se){d[se]!==!0&&(t.enable(se),d[se]=!0)}function Ae(se){d[se]!==!1&&(t.disable(se),d[se]=!1)}function me(se,je){return f[se]!==je?(t.bindFramebuffer(se,je),f[se]=je,se===t.DRAW_FRAMEBUFFER&&(f[t.FRAMEBUFFER]=je),se===t.FRAMEBUFFER&&(f[t.DRAW_FRAMEBUFFER]=je),!0):!1}function Ne(se,je){let xe=p,Oe=!1;if(se){xe=m.get(je),xe===void 0&&(xe=[],m.set(je,xe));const Ue=se.textures;if(xe.length!==Ue.length||xe[0]!==t.COLOR_ATTACHMENT0){for(let Ce=0,We=Ue.length;Ce<We;Ce++)xe[Ce]=t.COLOR_ATTACHMENT0+Ce;xe.length=Ue.length,Oe=!0}}else xe[0]!==t.BACK&&(xe[0]=t.BACK,Oe=!0);Oe&&t.drawBuffers(xe)}function ye(se){return b!==se?(t.useProgram(se),b=se,!0):!1}const le={[sf]:t.FUNC_ADD,[s3e]:t.FUNC_SUBTRACT,[o3e]:t.FUNC_REVERSE_SUBTRACT};le[l3e]=t.MIN,le[c3e]=t.MAX;const $e={[u3e]:t.ZERO,[d3e]:t.ONE,[h3e]:t.SRC_COLOR,[k3]:t.SRC_ALPHA,[b3e]:t.SRC_ALPHA_SATURATE,[g3e]:t.DST_COLOR,[m3e]:t.DST_ALPHA,[f3e]:t.ONE_MINUS_SRC_COLOR,[j3]:t.ONE_MINUS_SRC_ALPHA,[x3e]:t.ONE_MINUS_DST_COLOR,[p3e]:t.ONE_MINUS_DST_ALPHA,[y3e]:t.CONSTANT_COLOR,[v3e]:t.ONE_MINUS_CONSTANT_COLOR,[_3e]:t.CONSTANT_ALPHA,[w3e]:t.ONE_MINUS_CONSTANT_ALPHA};function H(se,je,xe,Oe,Ue,Ce,We,pt,kt,Lt){if(se===cu){y===!0&&(Ae(t.BLEND),y=!1);return}if(y===!1&&(ie(t.BLEND),y=!0),se!==a3e){if(se!==x||Lt!==C){if((v!==sf||A!==sf)&&(t.blendEquation(t.FUNC_ADD),v=sf,A=sf),Lt)switch(se){case ug:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case wV:t.blendFunc(t.ONE,t.ONE);break;case SV:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case MV:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:Yn("WebGLState: Invalid blending: ",se);break}else switch(se){case ug:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case wV:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case SV:Yn("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case MV:Yn("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Yn("WebGLState: Invalid blending: ",se);break}S=null,M=null,T=null,k=null,E.set(0,0,0),O=0,x=se,C=Lt}return}Ue=Ue||je,Ce=Ce||xe,We=We||Oe,(je!==v||Ue!==A)&&(t.blendEquationSeparate(le[je],le[Ue]),v=je,A=Ue),(xe!==S||Oe!==M||Ce!==T||We!==k)&&(t.blendFuncSeparate($e[xe],$e[Oe],$e[Ce],$e[We]),S=xe,M=Oe,T=Ce,k=We),(pt.equals(E)===!1||kt!==O)&&(t.blendColor(pt.r,pt.g,pt.b,kt),E.copy(pt),O=kt),x=se,C=!1}function ee(se,je){se.side===Fl?Ae(t.CULL_FACE):ie(t.CULL_FACE);let xe=se.side===Ms;je&&(xe=!xe),X(xe),se.blending===ug&&se.transparent===!1?H(cu):H(se.blending,se.blendEquation,se.blendSrc,se.blendDst,se.blendEquationAlpha,se.blendSrcAlpha,se.blendDstAlpha,se.blendColor,se.blendAlpha,se.premultipliedAlpha),o.setFunc(se.depthFunc),o.setTest(se.depthTest),o.setMask(se.depthWrite),a.setMask(se.colorWrite);const Oe=se.stencilWrite;l.setTest(Oe),Oe&&(l.setMask(se.stencilWriteMask),l.setFunc(se.stencilFunc,se.stencilRef,se.stencilFuncMask),l.setOp(se.stencilFail,se.stencilZFail,se.stencilZPass)),ce(se.polygonOffset,se.polygonOffsetFactor,se.polygonOffsetUnits),se.alphaToCoverage===!0?ie(t.SAMPLE_ALPHA_TO_COVERAGE):Ae(t.SAMPLE_ALPHA_TO_COVERAGE)}function X(se){D!==se&&(se?t.frontFace(t.CW):t.frontFace(t.CCW),D=se)}function B(se){se!==n3e?(ie(t.CULL_FACE),se!==U&&(se===_V?t.cullFace(t.BACK):se===r3e?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):Ae(t.CULL_FACE),U=se}function I(se){se!==L&&(K&&t.lineWidth(se),L=se)}function ce(se,je,xe){se?(ie(t.POLYGON_OFFSET_FILL),(q!==je||P!==xe)&&(t.polygonOffset(je,xe),q=je,P=xe)):Ae(t.POLYGON_OFFSET_FILL)}function Te(se){se?ie(t.SCISSOR_TEST):Ae(t.SCISSOR_TEST)}function Le(se){se===void 0&&(se=t.TEXTURE0+W-1),re!==se&&(t.activeTexture(se),re=se)}function Ee(se,je,xe){xe===void 0&&(re===null?xe=t.TEXTURE0+W-1:xe=re);let Oe=J[xe];Oe===void 0&&(Oe={type:void 0,texture:void 0},J[xe]=Oe),(Oe.type!==se||Oe.texture!==je)&&(re!==xe&&(t.activeTexture(xe),re=xe),t.bindTexture(se,je||fe[se]),Oe.type=se,Oe.texture=je)}function $(){const se=J[re];se!==void 0&&se.type!==void 0&&(t.bindTexture(se.type,null),se.type=void 0,se.texture=void 0)}function j(){try{t.compressedTexImage2D(...arguments)}catch(se){Yn("WebGLState:",se)}}function Y(){try{t.compressedTexImage3D(...arguments)}catch(se){Yn("WebGLState:",se)}}function ge(){try{t.texSubImage2D(...arguments)}catch(se){Yn("WebGLState:",se)}}function we(){try{t.texSubImage3D(...arguments)}catch(se){Yn("WebGLState:",se)}}function ve(){try{t.compressedTexSubImage2D(...arguments)}catch(se){Yn("WebGLState:",se)}}function Ze(){try{t.compressedTexSubImage3D(...arguments)}catch(se){Yn("WebGLState:",se)}}function Ie(){try{t.texStorage2D(...arguments)}catch(se){Yn("WebGLState:",se)}}function qe(){try{t.texStorage3D(...arguments)}catch(se){Yn("WebGLState:",se)}}function Je(){try{t.texImage2D(...arguments)}catch(se){Yn("WebGLState:",se)}}function Qe(){try{t.texImage3D(...arguments)}catch(se){Yn("WebGLState:",se)}}function oe(se){ne.equals(se)===!1&&(t.scissor(se.x,se.y,se.z,se.w),ne.copy(se))}function te(se){ae.equals(se)===!1&&(t.viewport(se.x,se.y,se.z,se.w),ae.copy(se))}function Me(se,je){let xe=u.get(je);xe===void 0&&(xe=new WeakMap,u.set(je,xe));let Oe=xe.get(se);Oe===void 0&&(Oe=t.getUniformBlockIndex(je,se.name),xe.set(se,Oe))}function Fe(se,je){const Oe=u.get(je).get(se);c.get(je)!==Oe&&(t.uniformBlockBinding(je,Oe,se.__bindingPointIndex),c.set(je,Oe))}function ot(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),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={},re=null,J={},f={},m=new WeakMap,p=[],b=null,y=!1,x=null,v=null,S=null,M=null,A=null,T=null,k=null,E=new On(0,0,0),O=0,C=!1,D=null,U=null,L=null,q=null,P=null,ne.set(0,0,t.canvas.width,t.canvas.height),ae.set(0,0,t.canvas.width,t.canvas.height),a.reset(),o.reset(),l.reset()}return{buffers:{color:a,depth:o,stencil:l},enable:ie,disable:Ae,bindFramebuffer:me,drawBuffers:Ne,useProgram:ye,setBlending:H,setMaterial:ee,setFlipSided:X,setCullFace:B,setLineWidth:I,setPolygonOffset:ce,setScissorTest:Te,activeTexture:Le,bindTexture:Ee,unbindTexture:$,compressedTexImage2D:j,compressedTexImage3D:Y,texImage2D:Je,texImage3D:Qe,updateUBOMapping:Me,uniformBlockBinding:Fe,texStorage2D:Ie,texStorage3D:qe,texSubImage2D:ge,texSubImage3D:we,compressedTexSubImage2D:ve,compressedTexSubImage3D:Ze,scissor:oe,viewport:te,reset:ot}}function cIe(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 Nn,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($,j){return p?new OffscreenCanvas($,j):GS("canvas")}function y($,j,Y){let ge=1;const we=Ee($);if((we.width>Y||we.height>Y)&&(ge=Y/Math.max(we.width,we.height)),ge<1)if(typeof HTMLImageElement<"u"&&$ instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&$ instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&$ instanceof ImageBitmap||typeof VideoFrame<"u"&&$ instanceof VideoFrame){const ve=Math.floor(ge*we.width),Ze=Math.floor(ge*we.height);f===void 0&&(f=b(ve,Ze));const Ie=j?b(ve,Ze):f;return Ie.width=ve,Ie.height=Ze,Ie.getContext("2d").drawImage($,0,0,ve,Ze),un("WebGLRenderer: Texture has been resized from ("+we.width+"x"+we.height+") to ("+ve+"x"+Ze+")."),Ie}else return"data"in $&&un("WebGLRenderer: Image in DataTexture is too big ("+we.width+"x"+we.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($,j,Y,ge,we=!1){if($!==null){if(t[$]!==void 0)return t[$];un("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+$+"'")}let ve=j;if(j===t.RED&&(Y===t.FLOAT&&(ve=t.R32F),Y===t.HALF_FLOAT&&(ve=t.R16F),Y===t.UNSIGNED_BYTE&&(ve=t.R8)),j===t.RED_INTEGER&&(Y===t.UNSIGNED_BYTE&&(ve=t.R8UI),Y===t.UNSIGNED_SHORT&&(ve=t.R16UI),Y===t.UNSIGNED_INT&&(ve=t.R32UI),Y===t.BYTE&&(ve=t.R8I),Y===t.SHORT&&(ve=t.R16I),Y===t.INT&&(ve=t.R32I)),j===t.RG&&(Y===t.FLOAT&&(ve=t.RG32F),Y===t.HALF_FLOAT&&(ve=t.RG16F),Y===t.UNSIGNED_BYTE&&(ve=t.RG8)),j===t.RG_INTEGER&&(Y===t.UNSIGNED_BYTE&&(ve=t.RG8UI),Y===t.UNSIGNED_SHORT&&(ve=t.RG16UI),Y===t.UNSIGNED_INT&&(ve=t.RG32UI),Y===t.BYTE&&(ve=t.RG8I),Y===t.SHORT&&(ve=t.RG16I),Y===t.INT&&(ve=t.RG32I)),j===t.RGB_INTEGER&&(Y===t.UNSIGNED_BYTE&&(ve=t.RGB8UI),Y===t.UNSIGNED_SHORT&&(ve=t.RGB16UI),Y===t.UNSIGNED_INT&&(ve=t.RGB32UI),Y===t.BYTE&&(ve=t.RGB8I),Y===t.SHORT&&(ve=t.RGB16I),Y===t.INT&&(ve=t.RGB32I)),j===t.RGBA_INTEGER&&(Y===t.UNSIGNED_BYTE&&(ve=t.RGBA8UI),Y===t.UNSIGNED_SHORT&&(ve=t.RGBA16UI),Y===t.UNSIGNED_INT&&(ve=t.RGBA32UI),Y===t.BYTE&&(ve=t.RGBA8I),Y===t.SHORT&&(ve=t.RGBA16I),Y===t.INT&&(ve=t.RGBA32I)),j===t.RGB&&(Y===t.UNSIGNED_INT_5_9_9_9_REV&&(ve=t.RGB9_E5),Y===t.UNSIGNED_INT_10F_11F_11F_REV&&(ve=t.R11F_G11F_B10F)),j===t.RGBA){const Ze=we?HS:Wn.getTransfer(ge);Y===t.FLOAT&&(ve=t.RGBA32F),Y===t.HALF_FLOAT&&(ve=t.RGBA16F),Y===t.UNSIGNED_BYTE&&(ve=Ze===or?t.SRGB8_ALPHA8:t.RGBA8),Y===t.UNSIGNED_SHORT_4_4_4_4&&(ve=t.RGBA4),Y===t.UNSIGNED_SHORT_5_5_5_1&&(ve=t.RGB5_A1)}return(ve===t.R16F||ve===t.R32F||ve===t.RG16F||ve===t.RG32F||ve===t.RGBA16F||ve===t.RGBA32F)&&e.get("EXT_color_buffer_float"),ve}function A($,j){let Y;return $?j===null||j===ic||j===J0?Y=t.DEPTH24_STENCIL8:j===Hl?Y=t.DEPTH32F_STENCIL8:j===Q0&&(Y=t.DEPTH24_STENCIL8,un("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):j===null||j===ic||j===J0?Y=t.DEPTH_COMPONENT24:j===Hl?Y=t.DEPTH_COMPONENT32F:j===Q0&&(Y=t.DEPTH_COMPONENT16),Y}function T($,j){return x($)===!0||$.isFramebufferTexture&&$.minFilter!==Aa&&$.minFilter!==Ba?Math.log2(Math.max(j.width,j.height))+1:$.mipmaps!==void 0&&$.mipmaps.length>0?$.mipmaps.length:$.isCompressedTexture&&Array.isArray($.image)?j.mipmaps.length:1}function k($){const j=$.target;j.removeEventListener("dispose",k),O(j),j.isVideoTexture&&d.delete(j)}function E($){const j=$.target;j.removeEventListener("dispose",E),D(j)}function O($){const j=r.get($);if(j.__webglInit===void 0)return;const Y=$.source,ge=m.get(Y);if(ge){const we=ge[j.__cacheKey];we.usedTimes--,we.usedTimes===0&&C($),Object.keys(ge).length===0&&m.delete(Y)}r.remove($)}function C($){const j=r.get($);t.deleteTexture(j.__webglTexture);const Y=$.source,ge=m.get(Y);delete ge[j.__cacheKey],o.memory.textures--}function D($){const j=r.get($);if($.depthTexture&&($.depthTexture.dispose(),r.remove($.depthTexture)),$.isWebGLCubeRenderTarget)for(let ge=0;ge<6;ge++){if(Array.isArray(j.__webglFramebuffer[ge]))for(let we=0;we<j.__webglFramebuffer[ge].length;we++)t.deleteFramebuffer(j.__webglFramebuffer[ge][we]);else t.deleteFramebuffer(j.__webglFramebuffer[ge]);j.__webglDepthbuffer&&t.deleteRenderbuffer(j.__webglDepthbuffer[ge])}else{if(Array.isArray(j.__webglFramebuffer))for(let ge=0;ge<j.__webglFramebuffer.length;ge++)t.deleteFramebuffer(j.__webglFramebuffer[ge]);else t.deleteFramebuffer(j.__webglFramebuffer);if(j.__webglDepthbuffer&&t.deleteRenderbuffer(j.__webglDepthbuffer),j.__webglMultisampledFramebuffer&&t.deleteFramebuffer(j.__webglMultisampledFramebuffer),j.__webglColorRenderbuffer)for(let ge=0;ge<j.__webglColorRenderbuffer.length;ge++)j.__webglColorRenderbuffer[ge]&&t.deleteRenderbuffer(j.__webglColorRenderbuffer[ge]);j.__webglDepthRenderbuffer&&t.deleteRenderbuffer(j.__webglDepthRenderbuffer)}const Y=$.textures;for(let ge=0,we=Y.length;ge<we;ge++){const ve=r.get(Y[ge]);ve.__webglTexture&&(t.deleteTexture(ve.__webglTexture),o.memory.textures--),r.remove(Y[ge])}r.remove($)}let U=0;function L(){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 P($){const j=[];return j.push($.wrapS),j.push($.wrapT),j.push($.wrapR||0),j.push($.magFilter),j.push($.minFilter),j.push($.anisotropy),j.push($.internalFormat),j.push($.format),j.push($.type),j.push($.generateMipmaps),j.push($.premultiplyAlpha),j.push($.flipY),j.push($.unpackAlignment),j.push($.colorSpace),j.join()}function W($,j){const Y=r.get($);if($.isVideoTexture&&Te($),$.isRenderTargetTexture===!1&&$.isExternalTexture!==!0&&$.version>0&&Y.__version!==$.version){const ge=$.image;if(ge===null)un("WebGLRenderer: Texture marked for update but no image data found.");else if(ge.complete===!1)un("WebGLRenderer: Texture marked for update but image is incomplete");else{fe(Y,$,j);return}}else $.isExternalTexture&&(Y.__webglTexture=$.sourceTexture?$.sourceTexture:null);n.bindTexture(t.TEXTURE_2D,Y.__webglTexture,t.TEXTURE0+j)}function K($,j){const Y=r.get($);if($.isRenderTargetTexture===!1&&$.version>0&&Y.__version!==$.version){fe(Y,$,j);return}else $.isExternalTexture&&(Y.__webglTexture=$.sourceTexture?$.sourceTexture:null);n.bindTexture(t.TEXTURE_2D_ARRAY,Y.__webglTexture,t.TEXTURE0+j)}function V($,j){const Y=r.get($);if($.isRenderTargetTexture===!1&&$.version>0&&Y.__version!==$.version){fe(Y,$,j);return}n.bindTexture(t.TEXTURE_3D,Y.__webglTexture,t.TEXTURE0+j)}function Q($,j){const Y=r.get($);if($.isCubeDepthTexture!==!0&&$.version>0&&Y.__version!==$.version){ie(Y,$,j);return}n.bindTexture(t.TEXTURE_CUBE_MAP,Y.__webglTexture,t.TEXTURE0+j)}const re={[B3]:t.REPEAT,[nu]:t.CLAMP_TO_EDGE,[$3]:t.MIRRORED_REPEAT},J={[Aa]:t.NEAREST,[N3e]:t.NEAREST_MIPMAP_NEAREST,[I_]:t.NEAREST_MIPMAP_LINEAR,[Ba]:t.LINEAR,[YC]:t.LINEAR_MIPMAP_NEAREST,[vf]:t.LINEAR_MIPMAP_LINEAR},z={[T3e]:t.NEVER,[R3e]:t.ALWAYS,[C3e]:t.LESS,[oL]:t.LEQUAL,[k3e]:t.EQUAL,[lL]:t.GEQUAL,[j3e]:t.GREATER,[P3e]:t.NOTEQUAL};function G($,j){if(j.type===Hl&&e.has("OES_texture_float_linear")===!1&&(j.magFilter===Ba||j.magFilter===YC||j.magFilter===I_||j.magFilter===vf||j.minFilter===Ba||j.minFilter===YC||j.minFilter===I_||j.minFilter===vf)&&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,re[j.wrapS]),t.texParameteri($,t.TEXTURE_WRAP_T,re[j.wrapT]),($===t.TEXTURE_3D||$===t.TEXTURE_2D_ARRAY)&&t.texParameteri($,t.TEXTURE_WRAP_R,re[j.wrapR]),t.texParameteri($,t.TEXTURE_MAG_FILTER,J[j.magFilter]),t.texParameteri($,t.TEXTURE_MIN_FILTER,J[j.minFilter]),j.compareFunction&&(t.texParameteri($,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri($,t.TEXTURE_COMPARE_FUNC,z[j.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(j.magFilter===Aa||j.minFilter!==I_&&j.minFilter!==vf||j.type===Hl&&e.has("OES_texture_float_linear")===!1)return;if(j.anisotropy>1||r.get(j).__currentAnisotropy){const Y=e.get("EXT_texture_filter_anisotropic");t.texParameterf($,Y.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(j.anisotropy,i.getMaxAnisotropy())),r.get(j).__currentAnisotropy=j.anisotropy}}}function ne($,j){let Y=!1;$.__webglInit===void 0&&($.__webglInit=!0,j.addEventListener("dispose",k));const ge=j.source;let we=m.get(ge);we===void 0&&(we={},m.set(ge,we));const ve=P(j);if(ve!==$.__cacheKey){we[ve]===void 0&&(we[ve]={texture:t.createTexture(),usedTimes:0},o.memory.textures++,Y=!0),we[ve].usedTimes++;const Ze=we[$.__cacheKey];Ze!==void 0&&(we[$.__cacheKey].usedTimes--,Ze.usedTimes===0&&C(j)),$.__cacheKey=ve,$.__webglTexture=we[ve].texture}return Y}function ae($,j,Y){return Math.floor(Math.floor($/Y)/j)}function de($,j,Y,ge){const ve=$.updateRanges;if(ve.length===0)n.texSubImage2D(t.TEXTURE_2D,0,0,0,j.width,j.height,Y,ge,j.data);else{ve.sort((Qe,oe)=>Qe.start-oe.start);let Ze=0;for(let Qe=1;Qe<ve.length;Qe++){const oe=ve[Ze],te=ve[Qe],Me=oe.start+oe.count,Fe=ae(te.start,j.width,4),ot=ae(oe.start,j.width,4);te.start<=Me+1&&Fe===ot&&ae(te.start+te.count-1,j.width,4)===Fe?oe.count=Math.max(oe.count,te.start+te.count-oe.start):(++Ze,ve[Ze]=te)}ve.length=Ze+1;const Ie=t.getParameter(t.UNPACK_ROW_LENGTH),qe=t.getParameter(t.UNPACK_SKIP_PIXELS),Je=t.getParameter(t.UNPACK_SKIP_ROWS);t.pixelStorei(t.UNPACK_ROW_LENGTH,j.width);for(let Qe=0,oe=ve.length;Qe<oe;Qe++){const te=ve[Qe],Me=Math.floor(te.start/4),Fe=Math.ceil(te.count/4),ot=Me%j.width,se=Math.floor(Me/j.width),je=Fe,xe=1;t.pixelStorei(t.UNPACK_SKIP_PIXELS,ot),t.pixelStorei(t.UNPACK_SKIP_ROWS,se),n.texSubImage2D(t.TEXTURE_2D,0,ot,se,je,xe,Y,ge,j.data)}$.clearUpdateRanges(),t.pixelStorei(t.UNPACK_ROW_LENGTH,Ie),t.pixelStorei(t.UNPACK_SKIP_PIXELS,qe),t.pixelStorei(t.UNPACK_SKIP_ROWS,Je)}}function fe($,j,Y){let ge=t.TEXTURE_2D;(j.isDataArrayTexture||j.isCompressedArrayTexture)&&(ge=t.TEXTURE_2D_ARRAY),j.isData3DTexture&&(ge=t.TEXTURE_3D);const we=ne($,j),ve=j.source;n.bindTexture(ge,$.__webglTexture,t.TEXTURE0+Y);const Ze=r.get(ve);if(ve.version!==Ze.__version||we===!0){n.activeTexture(t.TEXTURE0+Y);const Ie=Wn.getPrimaries(Wn.workingColorSpace),qe=j.colorSpace===Td?null:Wn.getPrimaries(j.colorSpace),Je=j.colorSpace===Td||Ie===qe?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,j.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,j.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,j.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Je);let Qe=y(j.image,!1,i.maxTextureSize);Qe=Le(j,Qe);const oe=a.convert(j.format,j.colorSpace),te=a.convert(j.type);let Me=M(j.internalFormat,oe,te,j.colorSpace,j.isVideoTexture);G(ge,j);let Fe;const ot=j.mipmaps,se=j.isVideoTexture!==!0,je=Ze.__version===void 0||we===!0,xe=ve.dataReady,Oe=T(j,Qe);if(j.isDepthTexture)Me=A(j.format===_f,j.type),je&&(se?n.texStorage2D(t.TEXTURE_2D,1,Me,Qe.width,Qe.height):n.texImage2D(t.TEXTURE_2D,0,Me,Qe.width,Qe.height,0,oe,te,null));else if(j.isDataTexture)if(ot.length>0){se&&je&&n.texStorage2D(t.TEXTURE_2D,Oe,Me,ot[0].width,ot[0].height);for(let Ue=0,Ce=ot.length;Ue<Ce;Ue++)Fe=ot[Ue],se?xe&&n.texSubImage2D(t.TEXTURE_2D,Ue,0,0,Fe.width,Fe.height,oe,te,Fe.data):n.texImage2D(t.TEXTURE_2D,Ue,Me,Fe.width,Fe.height,0,oe,te,Fe.data);j.generateMipmaps=!1}else se?(je&&n.texStorage2D(t.TEXTURE_2D,Oe,Me,Qe.width,Qe.height),xe&&de(j,Qe,oe,te)):n.texImage2D(t.TEXTURE_2D,0,Me,Qe.width,Qe.height,0,oe,te,Qe.data);else if(j.isCompressedTexture)if(j.isCompressedArrayTexture){se&&je&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Oe,Me,ot[0].width,ot[0].height,Qe.depth);for(let Ue=0,Ce=ot.length;Ue<Ce;Ue++)if(Fe=ot[Ue],j.format!==il)if(oe!==null)if(se){if(xe)if(j.layerUpdates.size>0){const We=eG(Fe.width,Fe.height,j.format,j.type);for(const pt of j.layerUpdates){const kt=Fe.data.subarray(pt*We/Fe.data.BYTES_PER_ELEMENT,(pt+1)*We/Fe.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Ue,0,0,pt,Fe.width,Fe.height,1,oe,kt)}j.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Ue,0,0,0,Fe.width,Fe.height,Qe.depth,oe,Fe.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,Ue,Me,Fe.width,Fe.height,Qe.depth,0,Fe.data,0,0);else un("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else se?xe&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,Ue,0,0,0,Fe.width,Fe.height,Qe.depth,oe,te,Fe.data):n.texImage3D(t.TEXTURE_2D_ARRAY,Ue,Me,Fe.width,Fe.height,Qe.depth,0,oe,te,Fe.data)}else{se&&je&&n.texStorage2D(t.TEXTURE_2D,Oe,Me,ot[0].width,ot[0].height);for(let Ue=0,Ce=ot.length;Ue<Ce;Ue++)Fe=ot[Ue],j.format!==il?oe!==null?se?xe&&n.compressedTexSubImage2D(t.TEXTURE_2D,Ue,0,0,Fe.width,Fe.height,oe,Fe.data):n.compressedTexImage2D(t.TEXTURE_2D,Ue,Me,Fe.width,Fe.height,0,Fe.data):un("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):se?xe&&n.texSubImage2D(t.TEXTURE_2D,Ue,0,0,Fe.width,Fe.height,oe,te,Fe.data):n.texImage2D(t.TEXTURE_2D,Ue,Me,Fe.width,Fe.height,0,oe,te,Fe.data)}else if(j.isDataArrayTexture)if(se){if(je&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Oe,Me,Qe.width,Qe.height,Qe.depth),xe)if(j.layerUpdates.size>0){const Ue=eG(Qe.width,Qe.height,j.format,j.type);for(const Ce of j.layerUpdates){const We=Qe.data.subarray(Ce*Ue/Qe.data.BYTES_PER_ELEMENT,(Ce+1)*Ue/Qe.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,Ce,Qe.width,Qe.height,1,oe,te,We)}j.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,Qe.width,Qe.height,Qe.depth,oe,te,Qe.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,Me,Qe.width,Qe.height,Qe.depth,0,oe,te,Qe.data);else if(j.isData3DTexture)se?(je&&n.texStorage3D(t.TEXTURE_3D,Oe,Me,Qe.width,Qe.height,Qe.depth),xe&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,Qe.width,Qe.height,Qe.depth,oe,te,Qe.data)):n.texImage3D(t.TEXTURE_3D,0,Me,Qe.width,Qe.height,Qe.depth,0,oe,te,Qe.data);else if(j.isFramebufferTexture){if(je)if(se)n.texStorage2D(t.TEXTURE_2D,Oe,Me,Qe.width,Qe.height);else{let Ue=Qe.width,Ce=Qe.height;for(let We=0;We<Oe;We++)n.texImage2D(t.TEXTURE_2D,We,Me,Ue,Ce,0,oe,te,null),Ue>>=1,Ce>>=1}}else if(ot.length>0){if(se&&je){const Ue=Ee(ot[0]);n.texStorage2D(t.TEXTURE_2D,Oe,Me,Ue.width,Ue.height)}for(let Ue=0,Ce=ot.length;Ue<Ce;Ue++)Fe=ot[Ue],se?xe&&n.texSubImage2D(t.TEXTURE_2D,Ue,0,0,oe,te,Fe):n.texImage2D(t.TEXTURE_2D,Ue,Me,oe,te,Fe);j.generateMipmaps=!1}else if(se){if(je){const Ue=Ee(Qe);n.texStorage2D(t.TEXTURE_2D,Oe,Me,Ue.width,Ue.height)}xe&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,oe,te,Qe)}else n.texImage2D(t.TEXTURE_2D,0,Me,oe,te,Qe);x(j)&&v(ge),Ze.__version=ve.version,j.onUpdate&&j.onUpdate(j)}$.__version=j.version}function ie($,j,Y){if(j.image.length!==6)return;const ge=ne($,j),we=j.source;n.bindTexture(t.TEXTURE_CUBE_MAP,$.__webglTexture,t.TEXTURE0+Y);const ve=r.get(we);if(we.version!==ve.__version||ge===!0){n.activeTexture(t.TEXTURE0+Y);const Ze=Wn.getPrimaries(Wn.workingColorSpace),Ie=j.colorSpace===Td?null:Wn.getPrimaries(j.colorSpace),qe=j.colorSpace===Td||Ze===Ie?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,j.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,j.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,j.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,qe);const Je=j.isCompressedTexture||j.image[0].isCompressedTexture,Qe=j.image[0]&&j.image[0].isDataTexture,oe=[];for(let Ce=0;Ce<6;Ce++)!Je&&!Qe?oe[Ce]=y(j.image[Ce],!0,i.maxCubemapSize):oe[Ce]=Qe?j.image[Ce].image:j.image[Ce],oe[Ce]=Le(j,oe[Ce]);const te=oe[0],Me=a.convert(j.format,j.colorSpace),Fe=a.convert(j.type),ot=M(j.internalFormat,Me,Fe,j.colorSpace),se=j.isVideoTexture!==!0,je=ve.__version===void 0||ge===!0,xe=we.dataReady;let Oe=T(j,te);G(t.TEXTURE_CUBE_MAP,j);let Ue;if(Je){se&&je&&n.texStorage2D(t.TEXTURE_CUBE_MAP,Oe,ot,te.width,te.height);for(let Ce=0;Ce<6;Ce++){Ue=oe[Ce].mipmaps;for(let We=0;We<Ue.length;We++){const pt=Ue[We];j.format!==il?Me!==null?se?xe&&n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,We,0,0,pt.width,pt.height,Me,pt.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,We,ot,pt.width,pt.height,0,pt.data):un("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):se?xe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,We,0,0,pt.width,pt.height,Me,Fe,pt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,We,ot,pt.width,pt.height,0,Me,Fe,pt.data)}}}else{if(Ue=j.mipmaps,se&&je){Ue.length>0&&Oe++;const Ce=Ee(oe[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,Oe,ot,Ce.width,Ce.height)}for(let Ce=0;Ce<6;Ce++)if(Qe){se?xe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,0,0,0,oe[Ce].width,oe[Ce].height,Me,Fe,oe[Ce].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,0,ot,oe[Ce].width,oe[Ce].height,0,Me,Fe,oe[Ce].data);for(let We=0;We<Ue.length;We++){const kt=Ue[We].image[Ce].image;se?xe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,We+1,0,0,kt.width,kt.height,Me,Fe,kt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,We+1,ot,kt.width,kt.height,0,Me,Fe,kt.data)}}else{se?xe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,0,0,0,Me,Fe,oe[Ce]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,0,ot,Me,Fe,oe[Ce]);for(let We=0;We<Ue.length;We++){const pt=Ue[We];se?xe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,We+1,0,0,Me,Fe,pt.image[Ce]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,We+1,ot,Me,Fe,pt.image[Ce])}}}x(j)&&v(t.TEXTURE_CUBE_MAP),ve.__version=we.version,j.onUpdate&&j.onUpdate(j)}$.__version=j.version}function Ae($,j,Y,ge,we,ve){const Ze=a.convert(Y.format,Y.colorSpace),Ie=a.convert(Y.type),qe=M(Y.internalFormat,Ze,Ie,Y.colorSpace),Je=r.get(j),Qe=r.get(Y);if(Qe.__renderTarget=j,!Je.__hasExternalTextures){const oe=Math.max(1,j.width>>ve),te=Math.max(1,j.height>>ve);we===t.TEXTURE_3D||we===t.TEXTURE_2D_ARRAY?n.texImage3D(we,ve,qe,oe,te,j.depth,0,Ze,Ie,null):n.texImage2D(we,ve,qe,oe,te,0,Ze,Ie,null)}n.bindFramebuffer(t.FRAMEBUFFER,$),ce(j)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,ge,we,Qe.__webglTexture,0,I(j)):(we===t.TEXTURE_2D||we>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&we<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,ge,we,Qe.__webglTexture,ve),n.bindFramebuffer(t.FRAMEBUFFER,null)}function me($,j,Y){if(t.bindRenderbuffer(t.RENDERBUFFER,$),j.depthBuffer){const ge=j.depthTexture,we=ge&&ge.isDepthTexture?ge.type:null,ve=A(j.stencilBuffer,we),Ze=j.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;ce(j)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,I(j),ve,j.width,j.height):Y?t.renderbufferStorageMultisample(t.RENDERBUFFER,I(j),ve,j.width,j.height):t.renderbufferStorage(t.RENDERBUFFER,ve,j.width,j.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,Ze,t.RENDERBUFFER,$)}else{const ge=j.textures;for(let we=0;we<ge.length;we++){const ve=ge[we],Ze=a.convert(ve.format,ve.colorSpace),Ie=a.convert(ve.type),qe=M(ve.internalFormat,Ze,Ie,ve.colorSpace);ce(j)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,I(j),qe,j.width,j.height):Y?t.renderbufferStorageMultisample(t.RENDERBUFFER,I(j),qe,j.width,j.height):t.renderbufferStorage(t.RENDERBUFFER,qe,j.width,j.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function Ne($,j,Y){const ge=j.isWebGLCubeRenderTarget===!0;if(n.bindFramebuffer(t.FRAMEBUFFER,$),!(j.depthTexture&&j.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const we=r.get(j.depthTexture);if(we.__renderTarget=j,(!we.__webglTexture||j.depthTexture.image.width!==j.width||j.depthTexture.image.height!==j.height)&&(j.depthTexture.image.width=j.width,j.depthTexture.image.height=j.height,j.depthTexture.needsUpdate=!0),ge){if(we.__webglInit===void 0&&(we.__webglInit=!0,j.depthTexture.addEventListener("dispose",k)),we.__webglTexture===void 0){we.__webglTexture=t.createTexture(),n.bindTexture(t.TEXTURE_CUBE_MAP,we.__webglTexture),G(t.TEXTURE_CUBE_MAP,j.depthTexture);const Je=a.convert(j.depthTexture.format),Qe=a.convert(j.depthTexture.type);let oe;j.depthTexture.format===Mu?oe=t.DEPTH_COMPONENT24:j.depthTexture.format===_f&&(oe=t.DEPTH24_STENCIL8);for(let te=0;te<6;te++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,oe,j.width,j.height,0,Je,Qe,null)}}else W(j.depthTexture,0);const ve=we.__webglTexture,Ze=I(j),Ie=ge?t.TEXTURE_CUBE_MAP_POSITIVE_X+Y:t.TEXTURE_2D,qe=j.depthTexture.format===_f?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(j.depthTexture.format===Mu)ce(j)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,qe,Ie,ve,0,Ze):t.framebufferTexture2D(t.FRAMEBUFFER,qe,Ie,ve,0);else if(j.depthTexture.format===_f)ce(j)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,qe,Ie,ve,0,Ze):t.framebufferTexture2D(t.FRAMEBUFFER,qe,Ie,ve,0);else throw new Error("Unknown depthTexture format")}function ye($){const j=r.get($),Y=$.isWebGLCubeRenderTarget===!0;if(j.__boundDepthTexture!==$.depthTexture){const ge=$.depthTexture;if(j.__depthDisposeCallback&&j.__depthDisposeCallback(),ge){const we=()=>{delete j.__boundDepthTexture,delete j.__depthDisposeCallback,ge.removeEventListener("dispose",we)};ge.addEventListener("dispose",we),j.__depthDisposeCallback=we}j.__boundDepthTexture=ge}if($.depthTexture&&!j.__autoAllocateDepthBuffer)if(Y)for(let ge=0;ge<6;ge++)Ne(j.__webglFramebuffer[ge],$,ge);else{const ge=$.texture.mipmaps;ge&&ge.length>0?Ne(j.__webglFramebuffer[0],$,0):Ne(j.__webglFramebuffer,$,0)}else if(Y){j.__webglDepthbuffer=[];for(let ge=0;ge<6;ge++)if(n.bindFramebuffer(t.FRAMEBUFFER,j.__webglFramebuffer[ge]),j.__webglDepthbuffer[ge]===void 0)j.__webglDepthbuffer[ge]=t.createRenderbuffer(),me(j.__webglDepthbuffer[ge],$,!1);else{const we=$.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ve=j.__webglDepthbuffer[ge];t.bindRenderbuffer(t.RENDERBUFFER,ve),t.framebufferRenderbuffer(t.FRAMEBUFFER,we,t.RENDERBUFFER,ve)}}else{const ge=$.texture.mipmaps;if(ge&&ge.length>0?n.bindFramebuffer(t.FRAMEBUFFER,j.__webglFramebuffer[0]):n.bindFramebuffer(t.FRAMEBUFFER,j.__webglFramebuffer),j.__webglDepthbuffer===void 0)j.__webglDepthbuffer=t.createRenderbuffer(),me(j.__webglDepthbuffer,$,!1);else{const we=$.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ve=j.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,ve),t.framebufferRenderbuffer(t.FRAMEBUFFER,we,t.RENDERBUFFER,ve)}}n.bindFramebuffer(t.FRAMEBUFFER,null)}function le($,j,Y){const ge=r.get($);j!==void 0&&Ae(ge.__webglFramebuffer,$,$.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),Y!==void 0&&ye($)}function $e($){const j=$.texture,Y=r.get($),ge=r.get(j);$.addEventListener("dispose",E);const we=$.textures,ve=$.isWebGLCubeRenderTarget===!0,Ze=we.length>1;if(Ze||(ge.__webglTexture===void 0&&(ge.__webglTexture=t.createTexture()),ge.__version=j.version,o.memory.textures++),ve){Y.__webglFramebuffer=[];for(let Ie=0;Ie<6;Ie++)if(j.mipmaps&&j.mipmaps.length>0){Y.__webglFramebuffer[Ie]=[];for(let qe=0;qe<j.mipmaps.length;qe++)Y.__webglFramebuffer[Ie][qe]=t.createFramebuffer()}else Y.__webglFramebuffer[Ie]=t.createFramebuffer()}else{if(j.mipmaps&&j.mipmaps.length>0){Y.__webglFramebuffer=[];for(let Ie=0;Ie<j.mipmaps.length;Ie++)Y.__webglFramebuffer[Ie]=t.createFramebuffer()}else Y.__webglFramebuffer=t.createFramebuffer();if(Ze)for(let Ie=0,qe=we.length;Ie<qe;Ie++){const Je=r.get(we[Ie]);Je.__webglTexture===void 0&&(Je.__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 Ie=0;Ie<we.length;Ie++){const qe=we[Ie];Y.__webglColorRenderbuffer[Ie]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,Y.__webglColorRenderbuffer[Ie]);const Je=a.convert(qe.format,qe.colorSpace),Qe=a.convert(qe.type),oe=M(qe.internalFormat,Je,Qe,qe.colorSpace,$.isXRRenderTarget===!0),te=I($);t.renderbufferStorageMultisample(t.RENDERBUFFER,te,oe,$.width,$.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ie,t.RENDERBUFFER,Y.__webglColorRenderbuffer[Ie])}t.bindRenderbuffer(t.RENDERBUFFER,null),$.depthBuffer&&(Y.__webglDepthRenderbuffer=t.createRenderbuffer(),me(Y.__webglDepthRenderbuffer,$,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(ve){n.bindTexture(t.TEXTURE_CUBE_MAP,ge.__webglTexture),G(t.TEXTURE_CUBE_MAP,j);for(let Ie=0;Ie<6;Ie++)if(j.mipmaps&&j.mipmaps.length>0)for(let qe=0;qe<j.mipmaps.length;qe++)Ae(Y.__webglFramebuffer[Ie][qe],$,j,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ie,qe);else Ae(Y.__webglFramebuffer[Ie],$,j,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ie,0);x(j)&&v(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(Ze){for(let Ie=0,qe=we.length;Ie<qe;Ie++){const Je=we[Ie],Qe=r.get(Je);let oe=t.TEXTURE_2D;($.isWebGL3DRenderTarget||$.isWebGLArrayRenderTarget)&&(oe=$.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(oe,Qe.__webglTexture),G(oe,Je),Ae(Y.__webglFramebuffer,$,Je,t.COLOR_ATTACHMENT0+Ie,oe,0),x(Je)&&v(oe)}n.unbindTexture()}else{let Ie=t.TEXTURE_2D;if(($.isWebGL3DRenderTarget||$.isWebGLArrayRenderTarget)&&(Ie=$.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(Ie,ge.__webglTexture),G(Ie,j),j.mipmaps&&j.mipmaps.length>0)for(let qe=0;qe<j.mipmaps.length;qe++)Ae(Y.__webglFramebuffer[qe],$,j,t.COLOR_ATTACHMENT0,Ie,qe);else Ae(Y.__webglFramebuffer,$,j,t.COLOR_ATTACHMENT0,Ie,0);x(j)&&v(Ie),n.unbindTexture()}$.depthBuffer&&ye($)}function H($){const j=$.textures;for(let Y=0,ge=j.length;Y<ge;Y++){const we=j[Y];if(x(we)){const ve=S($),Ze=r.get(we).__webglTexture;n.bindTexture(ve,Ze),v(ve),n.unbindTexture()}}}const ee=[],X=[];function B($){if($.samples>0){if(ce($)===!1){const j=$.textures,Y=$.width,ge=$.height;let we=t.COLOR_BUFFER_BIT;const ve=$.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Ze=r.get($),Ie=j.length>1;if(Ie)for(let Je=0;Je<j.length;Je++)n.bindFramebuffer(t.FRAMEBUFFER,Ze.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Je,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,Ze.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Je,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,Ze.__webglMultisampledFramebuffer);const qe=$.texture.mipmaps;qe&&qe.length>0?n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ze.__webglFramebuffer[0]):n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ze.__webglFramebuffer);for(let Je=0;Je<j.length;Je++){if($.resolveDepthBuffer&&($.depthBuffer&&(we|=t.DEPTH_BUFFER_BIT),$.stencilBuffer&&$.resolveStencilBuffer&&(we|=t.STENCIL_BUFFER_BIT)),Ie){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,Ze.__webglColorRenderbuffer[Je]);const Qe=r.get(j[Je]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,Qe,0)}t.blitFramebuffer(0,0,Y,ge,0,0,Y,ge,we,t.NEAREST),c===!0&&(ee.length=0,X.length=0,ee.push(t.COLOR_ATTACHMENT0+Je),$.depthBuffer&&$.resolveDepthBuffer===!1&&(ee.push(ve),X.push(ve),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,X)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,ee))}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Ie)for(let Je=0;Je<j.length;Je++){n.bindFramebuffer(t.FRAMEBUFFER,Ze.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Je,t.RENDERBUFFER,Ze.__webglColorRenderbuffer[Je]);const Qe=r.get(j[Je]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,Ze.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Je,t.TEXTURE_2D,Qe,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ze.__webglMultisampledFramebuffer)}else if($.depthBuffer&&$.resolveDepthBuffer===!1&&c){const j=$.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[j])}}}function I($){return Math.min(i.maxSamples,$.samples)}function ce($){const j=r.get($);return $.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&j.__useRenderToTexture!==!1}function Te($){const j=o.render.frame;d.get($)!==j&&(d.set($,j),$.update())}function Le($,j){const Y=$.colorSpace,ge=$.format,we=$.type;return $.isCompressedTexture===!0||$.isVideoTexture===!0||Y!==Rg&&Y!==Td&&(Wn.getTransfer(Y)===or?(ge!==il||we!==Gs)&&un("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Yn("WebGLTextures: Unsupported texture color space:",Y)),j}function Ee($){return typeof HTMLImageElement<"u"&&$ instanceof HTMLImageElement?(u.width=$.naturalWidth||$.width,u.height=$.naturalHeight||$.height):typeof VideoFrame<"u"&&$ instanceof VideoFrame?(u.width=$.displayWidth,u.height=$.displayHeight):(u.width=$.width,u.height=$.height),u}this.allocateTextureUnit=q,this.resetTextureUnits=L,this.setTexture2D=W,this.setTexture2DArray=K,this.setTexture3D=V,this.setTextureCube=Q,this.rebindTextures=le,this.setupRenderTarget=$e,this.updateRenderTargetMipmap=H,this.updateMultisampleRenderTarget=B,this.setupDepthRenderbuffer=ye,this.setupFrameBufferTexture=Ae,this.useMultisampledRTT=ce,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function uIe(t,e){function n(r,i=Td){let a;const o=Wn.getTransfer(i);if(r===Gs)return t.UNSIGNED_BYTE;if(r===nL)return t.UNSIGNED_SHORT_4_4_4_4;if(r===rL)return t.UNSIGNED_SHORT_5_5_5_1;if(r===oee)return t.UNSIGNED_INT_5_9_9_9_REV;if(r===lee)return t.UNSIGNED_INT_10F_11F_11F_REV;if(r===aee)return t.BYTE;if(r===see)return t.SHORT;if(r===Q0)return t.UNSIGNED_SHORT;if(r===tL)return t.INT;if(r===ic)return t.UNSIGNED_INT;if(r===Hl)return t.FLOAT;if(r===Su)return t.HALF_FLOAT;if(r===cee)return t.ALPHA;if(r===uee)return t.RGB;if(r===il)return t.RGBA;if(r===Mu)return t.DEPTH_COMPONENT;if(r===_f)return t.DEPTH_STENCIL;if(r===dee)return t.RED;if(r===iL)return t.RED_INTEGER;if(r===Pg)return t.RG;if(r===aL)return t.RG_INTEGER;if(r===sL)return t.RGBA_INTEGER;if(r===m1||r===p1||r===g1||r===x1)if(o===or)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(r===m1)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===p1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===g1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===x1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(r===m1)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===p1)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===g1)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===x1)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===H3||r===V3||r===G3||r===W3)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(r===H3)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===V3)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===G3)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===W3)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===q3||r===K3||r===X3||r===Y3||r===Z3||r===Q3||r===J3)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(r===q3||r===K3)return o===or?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(r===X3)return o===or?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC;if(r===Y3)return a.COMPRESSED_R11_EAC;if(r===Z3)return a.COMPRESSED_SIGNED_R11_EAC;if(r===Q3)return a.COMPRESSED_RG11_EAC;if(r===J3)return a.COMPRESSED_SIGNED_RG11_EAC}else return null;if(r===eR||r===tR||r===nR||r===rR||r===iR||r===aR||r===sR||r===oR||r===lR||r===cR||r===uR||r===dR||r===hR||r===fR)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(r===eR)return o===or?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===tR)return o===or?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===nR)return o===or?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===rR)return o===or?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===iR)return o===or?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===aR)return o===or?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===sR)return o===or?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===oR)return o===or?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===lR)return o===or?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===cR)return o===or?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===uR)return o===or?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===dR)return o===or?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===hR)return o===or?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===fR)return o===or?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===mR||r===pR||r===gR)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(r===mR)return o===or?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===pR)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===gR)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===xR||r===bR||r===yR||r===vR)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(r===xR)return a.COMPRESSED_RED_RGTC1_EXT;if(r===bR)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===yR)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===vR)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===J0?t.UNSIGNED_INT_24_8:t[r]!==void 0?t[r]:null}return{convert:n}}const dIe=`
- void main() {
- gl_Position = vec4( position, 1.0 );
- }`,hIe=`
- 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 fIe{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,n){if(this.texture===null){const r=new jee(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 ac({vertexShader:dIe,fragmentShader:hIe,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new fl(new mL(20,20),r)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}let mIe=class extends xm{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 fIe,v={},S=n.getContextAttributes();let M=null,A=null;const T=[],k=[],E=new Nn;let O=null;const C=new Mo;C.viewport=new Ei;const D=new Mo;D.viewport=new Ei;const U=[C,D],L=new wRe;let q=null,P=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(fe){let ie=T[fe];return ie===void 0&&(ie=new bk,T[fe]=ie),ie.getTargetRaySpace()},this.getControllerGrip=function(fe){let ie=T[fe];return ie===void 0&&(ie=new bk,T[fe]=ie),ie.getGripSpace()},this.getHand=function(fe){let ie=T[fe];return ie===void 0&&(ie=new bk,T[fe]=ie),ie.getHandSpace()};function W(fe){const ie=k.indexOf(fe.inputSource);if(ie===-1)return;const Ae=T[ie];Ae!==void 0&&(Ae.update(fe.inputSource,fe.frame,u||o),Ae.dispatchEvent({type:fe.type,data:fe.inputSource}))}function K(){i.removeEventListener("select",W),i.removeEventListener("selectstart",W),i.removeEventListener("selectend",W),i.removeEventListener("squeeze",W),i.removeEventListener("squeezestart",W),i.removeEventListener("squeezeend",W),i.removeEventListener("end",K),i.removeEventListener("inputsourceschange",V);for(let fe=0;fe<T.length;fe++){const ie=k[fe];ie!==null&&(k[fe]=null,T[fe].disconnect(ie))}q=null,P=null,x.reset();for(const fe in v)delete v[fe];e.setRenderTarget(M),p=null,m=null,f=null,i=null,A=null,de.stop(),r.isPresenting=!1,e.setPixelRatio(O),e.setSize(E.width,E.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(fe){a=fe,r.isPresenting===!0&&un("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(fe){l=fe,r.isPresenting===!0&&un("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(fe){u=fe},this.getBaseLayer=function(){return m!==null?m:p},this.getBinding=function(){return f===null&&y&&(f=new XRWebGLBinding(i,n)),f},this.getFrame=function(){return b},this.getSession=function(){return i},this.setSession=async function(fe){if(i=fe,i!==null){if(M=e.getRenderTarget(),i.addEventListener("select",W),i.addEventListener("selectstart",W),i.addEventListener("selectend",W),i.addEventListener("squeeze",W),i.addEventListener("squeezestart",W),i.addEventListener("squeezeend",W),i.addEventListener("end",K),i.addEventListener("inputsourceschange",V),S.xrCompatible!==!0&&await n.makeXRCompatible(),O=e.getPixelRatio(),e.getSize(E),y&&"createProjectionLayer"in XRWebGLBinding.prototype){let Ae=null,me=null,Ne=null;S.depth&&(Ne=S.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,Ae=S.stencil?_f:Mu,me=S.stencil?J0:ic);const ye={colorFormat:n.RGBA8,depthFormat:Ne,scaleFactor:a};f=this.getBinding(),m=f.createProjectionLayer(ye),i.updateRenderState({layers:[m]}),e.setPixelRatio(1),e.setSize(m.textureWidth,m.textureHeight,!1),A=new Xl(m.textureWidth,m.textureHeight,{format:il,type:Gs,depthTexture:new ty(m.textureWidth,m.textureHeight,me,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),A=new Xl(p.framebufferWidth,p.framebufferHeight,{format:il,type:Gs,colorSpace:e.outputColorSpace,stencilBuffer:S.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}A.isXRRenderTarget=!0,this.setFoveation(c),u=null,o=await i.requestReferenceSpace(l),de.setContext(i),de.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return x.getDepthTexture()};function V(fe){for(let ie=0;ie<fe.removed.length;ie++){const Ae=fe.removed[ie],me=k.indexOf(Ae);me>=0&&(k[me]=null,T[me].disconnect(Ae))}for(let ie=0;ie<fe.added.length;ie++){const Ae=fe.added[ie];let me=k.indexOf(Ae);if(me===-1){for(let ye=0;ye<T.length;ye++)if(ye>=k.length){k.push(Ae),me=ye;break}else if(k[ye]===null){k[ye]=Ae,me=ye;break}if(me===-1)break}const Ne=T[me];Ne&&Ne.connect(Ae)}}const Q=new tt,re=new tt;function J(fe,ie,Ae){Q.setFromMatrixPosition(ie.matrixWorld),re.setFromMatrixPosition(Ae.matrixWorld);const me=Q.distanceTo(re),Ne=ie.projectionMatrix.elements,ye=Ae.projectionMatrix.elements,le=Ne[14]/(Ne[10]-1),$e=Ne[14]/(Ne[10]+1),H=(Ne[9]+1)/Ne[5],ee=(Ne[9]-1)/Ne[5],X=(Ne[8]-1)/Ne[0],B=(ye[8]+1)/ye[0],I=le*X,ce=le*B,Te=me/(-X+B),Le=Te*-X;if(ie.matrixWorld.decompose(fe.position,fe.quaternion,fe.scale),fe.translateX(Le),fe.translateZ(Te),fe.matrixWorld.compose(fe.position,fe.quaternion,fe.scale),fe.matrixWorldInverse.copy(fe.matrixWorld).invert(),Ne[10]===-1)fe.projectionMatrix.copy(ie.projectionMatrix),fe.projectionMatrixInverse.copy(ie.projectionMatrixInverse);else{const Ee=le+Te,$=$e+Te,j=I-Le,Y=ce+(me-Le),ge=H*$e/$*Ee,we=ee*$e/$*Ee;fe.projectionMatrix.makePerspective(j,Y,ge,we,Ee,$),fe.projectionMatrixInverse.copy(fe.projectionMatrix).invert()}}function z(fe,ie){ie===null?fe.matrixWorld.copy(fe.matrix):fe.matrixWorld.multiplyMatrices(ie.matrixWorld,fe.matrix),fe.matrixWorldInverse.copy(fe.matrixWorld).invert()}this.updateCamera=function(fe){if(i===null)return;let ie=fe.near,Ae=fe.far;x.texture!==null&&(x.depthNear>0&&(ie=x.depthNear),x.depthFar>0&&(Ae=x.depthFar)),L.near=D.near=C.near=ie,L.far=D.far=C.far=Ae,(q!==L.near||P!==L.far)&&(i.updateRenderState({depthNear:L.near,depthFar:L.far}),q=L.near,P=L.far),L.layers.mask=fe.layers.mask|6,C.layers.mask=L.layers.mask&3,D.layers.mask=L.layers.mask&5;const me=fe.parent,Ne=L.cameras;z(L,me);for(let ye=0;ye<Ne.length;ye++)z(Ne[ye],me);Ne.length===2?J(L,C,D):L.projectionMatrix.copy(C.projectionMatrix),G(fe,L,me)};function G(fe,ie,Ae){Ae===null?fe.matrix.copy(ie.matrixWorld):(fe.matrix.copy(Ae.matrixWorld),fe.matrix.invert(),fe.matrix.multiply(ie.matrixWorld)),fe.matrix.decompose(fe.position,fe.quaternion,fe.scale),fe.updateMatrixWorld(!0),fe.projectionMatrix.copy(ie.projectionMatrix),fe.projectionMatrixInverse.copy(ie.projectionMatrixInverse),fe.isPerspectiveCamera&&(fe.fov=_R*2*Math.atan(1/fe.projectionMatrix.elements[5]),fe.zoom=1)}this.getCamera=function(){return L},this.getFoveation=function(){if(!(m===null&&p===null))return c},this.setFoveation=function(fe){c=fe,m!==null&&(m.fixedFoveation=fe),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=fe)},this.hasDepthSensing=function(){return x.texture!==null},this.getDepthSensingMesh=function(){return x.getMesh(L)},this.getCameraTexture=function(fe){return v[fe]};let ne=null;function ae(fe,ie){if(d=ie.getViewerPose(u||o),b=ie,d!==null){const Ae=d.views;p!==null&&(e.setRenderTargetFramebuffer(A,p.framebuffer),e.setRenderTarget(A));let me=!1;Ae.length!==L.cameras.length&&(L.cameras.length=0,me=!0);for(let $e=0;$e<Ae.length;$e++){const H=Ae[$e];let ee=null;if(p!==null)ee=p.getViewport(H);else{const B=f.getViewSubImage(m,H);ee=B.viewport,$e===0&&(e.setRenderTargetTextures(A,B.colorTexture,B.depthStencilTexture),e.setRenderTarget(A))}let X=U[$e];X===void 0&&(X=new Mo,X.layers.enable($e),X.viewport=new Ei,U[$e]=X),X.matrix.fromArray(H.transform.matrix),X.matrix.decompose(X.position,X.quaternion,X.scale),X.projectionMatrix.fromArray(H.projectionMatrix),X.projectionMatrixInverse.copy(X.projectionMatrix).invert(),X.viewport.set(ee.x,ee.y,ee.width,ee.height),$e===0&&(L.matrix.copy(X.matrix),L.matrix.decompose(L.position,L.quaternion,L.scale)),me===!0&&L.cameras.push(X)}const Ne=i.enabledFeatures;if(Ne&&Ne.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&y){f=r.getBinding();const $e=f.getDepthInformation(Ae[0]);$e&&$e.isValid&&$e.texture&&x.init($e,i.renderState)}if(Ne&&Ne.includes("camera-access")&&y){e.state.unbindTexture(),f=r.getBinding();for(let $e=0;$e<Ae.length;$e++){const H=Ae[$e].camera;if(H){let ee=v[H];ee||(ee=new jee,v[H]=ee);const X=f.getCameraImage(H);ee.sourceTexture=X}}}}for(let Ae=0;Ae<T.length;Ae++){const me=k[Ae],Ne=T[Ae];me!==null&&Ne!==void 0&&Ne.update(me,ie,u||o)}ne&&ne(fe,ie),ie.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:ie}),b=null}const de=new Dee;de.setAnimationLoop(ae),this.setAnimationLoop=function(fe){ne=fe},this.dispose=function(){}}};const qh=new ah,pIe=new gi;function gIe(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,Eee(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,A){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,A)):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===Ms&&(x.bumpScale.value*=-1)),v.normalMap&&(x.normalMap.value=v.normalMap,n(v.normalMap,x.normalMapTransform),x.normalScale.value.copy(v.normalScale),v.side===Ms&&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,A=S.envMapRotation;M&&(x.envMap.value=M,qh.copy(A),qh.x*=-1,qh.y*=-1,qh.z*=-1,M.isCubeTexture&&M.isRenderTargetTexture===!1&&(qh.y*=-1,qh.z*=-1),x.envMapRotation.value.setFromMatrix4(pIe.makeRotationFromEuler(qh)),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===Ms&&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 xIe(t,e,n,r){let i={},a={},o=[];const l=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function c(S,M){const A=M.program;r.uniformBlockBinding(S,A)}function u(S,M){let A=i[S.id];A===void 0&&(b(S),A=d(S),i[S.id]=A,S.addEventListener("dispose",x));const T=M.program;r.updateUBOMapping(S,T);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 A=t.createBuffer(),T=S.__size,k=S.usage;return t.bindBuffer(t.UNIFORM_BUFFER,A),t.bufferData(t.UNIFORM_BUFFER,T,k),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,M,A),A}function f(){for(let S=0;S<l;S++)if(o.indexOf(S)===-1)return o.push(S),S;return Yn("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function m(S){const M=i[S.id],A=S.uniforms,T=S.__cache;t.bindBuffer(t.UNIFORM_BUFFER,M);for(let k=0,E=A.length;k<E;k++){const O=Array.isArray(A[k])?A[k]:[A[k]];for(let C=0,D=O.length;C<D;C++){const U=O[C];if(p(U,k,C,T)===!0){const L=U.__offset,q=Array.isArray(U.value)?U.value:[U.value];let P=0;for(let W=0;W<q.length;W++){const K=q[W],V=y(K);typeof K=="number"||typeof K=="boolean"?(U.__data[0]=K,t.bufferSubData(t.UNIFORM_BUFFER,L+P,U.__data)):K.isMatrix3?(U.__data[0]=K.elements[0],U.__data[1]=K.elements[1],U.__data[2]=K.elements[2],U.__data[3]=0,U.__data[4]=K.elements[3],U.__data[5]=K.elements[4],U.__data[6]=K.elements[5],U.__data[7]=0,U.__data[8]=K.elements[6],U.__data[9]=K.elements[7],U.__data[10]=K.elements[8],U.__data[11]=0):(K.toArray(U.__data,P),P+=V.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,L,U.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function p(S,M,A,T){const k=S.value,E=M+"_"+A;if(T[E]===void 0)return typeof k=="number"||typeof k=="boolean"?T[E]=k:T[E]=k.clone(),!0;{const O=T[E];if(typeof k=="number"||typeof k=="boolean"){if(O!==k)return T[E]=k,!0}else if(O.equals(k)===!1)return O.copy(k),!0}return!1}function b(S){const M=S.uniforms;let A=0;const T=16;for(let E=0,O=M.length;E<O;E++){const C=Array.isArray(M[E])?M[E]:[M[E]];for(let D=0,U=C.length;D<U;D++){const L=C[D],q=Array.isArray(L.value)?L.value:[L.value];for(let P=0,W=q.length;P<W;P++){const K=q[P],V=y(K),Q=A%T,re=Q%V.boundary,J=Q+re;A+=re,J!==0&&T-J<V.storage&&(A+=T-J),L.__data=new Float32Array(V.storage/Float32Array.BYTES_PER_ELEMENT),L.__offset=A,A+=V.storage}}}const k=A%T;return k>0&&(A+=T-k),S.__size=A,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 A=o.indexOf(M.__bindingPointIndex);o.splice(A,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 bIe=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 Cl=null;function yIe(){return Cl===null&&(Cl=new lRe(bIe,16,16,Pg,Su),Cl.name="DFG_LUT",Cl.minFilter=Ba,Cl.magFilter=Ba,Cl.wrapS=nu,Cl.wrapT=nu,Cl.generateMipmaps=!1,Cl.needsUpdate=!0),Cl}let vIe=class{constructor(e={}){const{canvas:n=D3e(),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=Gs}=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([sL,aL,iL]),v=new Set([Gs,ic,Q0,J0,nL,rL]),S=new Uint32Array(4),M=new Int32Array(4);let A=null,T=null;const k=[],E=[];let O=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=Kl,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const C=this;let D=!1;this._outputColorSpace=_o;let U=0,L=0,q=null,P=-1,W=null;const K=new Ei,V=new Ei;let Q=null;const re=new On(0);let J=0,z=n.width,G=n.height,ne=1,ae=null,de=null;const fe=new Ei(0,0,z,G),ie=new Ei(0,0,z,G);let Ae=!1;const me=new fL;let Ne=!1,ye=!1;const le=new gi,$e=new tt,H=new Ei,ee={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let X=!1;function B(){return q===null?ne:1}let I=r;function ce(ue,Re){return n.getContext(ue,Re)}try{const ue={alpha:!0,depth:i,stencil:a,antialias:l,premultipliedAlpha:c,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:f};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${J4}`),n.addEventListener("webglcontextlost",pt,!1),n.addEventListener("webglcontextrestored",kt,!1),n.addEventListener("webglcontextcreationerror",Lt,!1),I===null){const Re="webgl2";if(I=ce(Re,ue),I===null)throw ce(Re)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(ue){throw Yn("WebGLRenderer: "+ue.message),ue}let Te,Le,Ee,$,j,Y,ge,we,ve,Ze,Ie,qe,Je,Qe,oe,te,Me,Fe,ot,se,je,xe,Oe,Ue;function Ce(){Te=new y4e(I),Te.init(),xe=new uIe(I,Te),Le=new u4e(I,Te,e,xe),Ee=new lIe(I,Te),Le.reversedDepthBuffer&&m&&Ee.buffers.depth.setReversed(!0),$=new w4e(I),j=new qLe,Y=new cIe(I,Te,Ee,j,Le,xe,$),ge=new h4e(C),we=new b4e(C),ve=new ERe(I),Oe=new l4e(I,ve),Ze=new v4e(I,ve,$,Oe),Ie=new M4e(I,Ze,ve,$),ot=new S4e(I,Le,Y),te=new d4e(j),qe=new WLe(C,ge,we,Te,Le,Oe,te),Je=new gIe(C,j),Qe=new XLe,oe=new tIe(Te),Fe=new o4e(C,ge,we,Ee,Ie,b,c),Me=new sIe(C,Ie,Le),Ue=new xIe(I,$,Le,Ee),se=new c4e(I,Te,$),je=new _4e(I,Te,$),$.programs=qe.programs,C.capabilities=Le,C.extensions=Te,C.properties=j,C.renderLists=Qe,C.shadowMap=Me,C.state=Ee,C.info=$}Ce(),y!==Gs&&(O=new E4e(y,n.width,n.height,i,a));const We=new mIe(C,I);this.xr=We,this.getContext=function(){return I},this.getContextAttributes=function(){return I.getContextAttributes()},this.forceContextLoss=function(){const ue=Te.get("WEBGL_lose_context");ue&&ue.loseContext()},this.forceContextRestore=function(){const ue=Te.get("WEBGL_lose_context");ue&&ue.restoreContext()},this.getPixelRatio=function(){return ne},this.setPixelRatio=function(ue){ue!==void 0&&(ne=ue,this.setSize(z,G,!1))},this.getSize=function(ue){return ue.set(z,G)},this.setSize=function(ue,Re,He=!0){if(We.isPresenting){un("WebGLRenderer: Can't change size while VR device is presenting.");return}z=ue,G=Re,n.width=Math.floor(ue*ne),n.height=Math.floor(Re*ne),He===!0&&(n.style.width=ue+"px",n.style.height=Re+"px"),O!==null&&O.setSize(n.width,n.height),this.setViewport(0,0,ue,Re)},this.getDrawingBufferSize=function(ue){return ue.set(z*ne,G*ne).floor()},this.setDrawingBufferSize=function(ue,Re,He){z=ue,G=Re,ne=He,n.width=Math.floor(ue*He),n.height=Math.floor(Re*He),this.setViewport(0,0,ue,Re)},this.setEffects=function(ue){if(y===Gs){console.error("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(ue){for(let Re=0;Re<ue.length;Re++)if(ue[Re].isOutputPass===!0){console.warn("THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}O.setEffects(ue||[])},this.getCurrentViewport=function(ue){return ue.copy(K)},this.getViewport=function(ue){return ue.copy(fe)},this.setViewport=function(ue,Re,He,Xe){ue.isVector4?fe.set(ue.x,ue.y,ue.z,ue.w):fe.set(ue,Re,He,Xe),Ee.viewport(K.copy(fe).multiplyScalar(ne).round())},this.getScissor=function(ue){return ue.copy(ie)},this.setScissor=function(ue,Re,He,Xe){ue.isVector4?ie.set(ue.x,ue.y,ue.z,ue.w):ie.set(ue,Re,He,Xe),Ee.scissor(V.copy(ie).multiplyScalar(ne).round())},this.getScissorTest=function(){return Ae},this.setScissorTest=function(ue){Ee.setScissorTest(Ae=ue)},this.setOpaqueSort=function(ue){ae=ue},this.setTransparentSort=function(ue){de=ue},this.getClearColor=function(ue){return ue.copy(Fe.getClearColor())},this.setClearColor=function(){Fe.setClearColor(...arguments)},this.getClearAlpha=function(){return Fe.getClearAlpha()},this.setClearAlpha=function(){Fe.setClearAlpha(...arguments)},this.clear=function(ue=!0,Re=!0,He=!0){let Xe=0;if(ue){let Ge=!1;if(q!==null){const ht=q.texture.format;Ge=x.has(ht)}if(Ge){const ht=q.texture.type,Pt=v.has(ht),_t=Fe.getClearColor(),yt=Fe.getClearAlpha(),It=_t.r,Ot=_t.g,Ft=_t.b;Pt?(S[0]=It,S[1]=Ot,S[2]=Ft,S[3]=yt,I.clearBufferuiv(I.COLOR,0,S)):(M[0]=It,M[1]=Ot,M[2]=Ft,M[3]=yt,I.clearBufferiv(I.COLOR,0,M))}else Xe|=I.COLOR_BUFFER_BIT}Re&&(Xe|=I.DEPTH_BUFFER_BIT),He&&(Xe|=I.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),I.clear(Xe)},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",pt,!1),n.removeEventListener("webglcontextrestored",kt,!1),n.removeEventListener("webglcontextcreationerror",Lt,!1),Fe.dispose(),Qe.dispose(),oe.dispose(),j.dispose(),ge.dispose(),we.dispose(),Ie.dispose(),Oe.dispose(),Ue.dispose(),qe.dispose(),We.dispose(),We.removeEventListener("sessionstart",At),We.removeEventListener("sessionend",Pr),yr.stop()};function pt(ue){ue.preventDefault(),CV("WebGLRenderer: Context Lost."),D=!0}function kt(){CV("WebGLRenderer: Context Restored."),D=!1;const ue=$.autoReset,Re=Me.enabled,He=Me.autoUpdate,Xe=Me.needsUpdate,Ge=Me.type;Ce(),$.autoReset=ue,Me.enabled=Re,Me.autoUpdate=He,Me.needsUpdate=Xe,Me.type=Ge}function Lt(ue){Yn("WebGLRenderer: A WebGL context could not be created. Reason: ",ue.statusMessage)}function ln(ue){const Re=ue.target;Re.removeEventListener("dispose",ln),Gt(Re)}function Gt(ue){_n(ue),j.remove(ue)}function _n(ue){const Re=j.get(ue).programs;Re!==void 0&&(Re.forEach(function(He){qe.releaseProgram(He)}),ue.isShaderMaterial&&qe.releaseShaderCache(ue))}this.renderBufferDirect=function(ue,Re,He,Xe,Ge,ht){Re===null&&(Re=ee);const Pt=Ge.isMesh&&Ge.matrixWorld.determinant()<0,_t=ct(ue,Re,He,Xe,Ge);Ee.setMaterial(Xe,Pt);let yt=He.index,It=1;if(Xe.wireframe===!0){if(yt=Ze.getWireframeAttribute(He),yt===void 0)return;It=2}const Ot=He.drawRange,Ft=He.attributes.position;let be=Ot.start*It,Pe=(Ot.start+Ot.count)*It;ht!==null&&(be=Math.max(be,ht.start*It),Pe=Math.min(Pe,(ht.start+ht.count)*It)),yt!==null?(be=Math.max(be,0),Pe=Math.min(Pe,yt.count)):Ft!=null&&(be=Math.max(be,0),Pe=Math.min(Pe,Ft.count));const wt=Pe-be;if(wt<0||wt===1/0)return;Oe.setup(Ge,Xe,_t,He,yt);let Mt,lt=se;if(yt!==null&&(Mt=ve.get(yt),lt=je,lt.setIndex(Mt)),Ge.isMesh)Xe.wireframe===!0?(Ee.setLineWidth(Xe.wireframeLinewidth*B()),lt.setMode(I.LINES)):lt.setMode(I.TRIANGLES);else if(Ge.isLine){let Tt=Xe.linewidth;Tt===void 0&&(Tt=1),Ee.setLineWidth(Tt*B()),Ge.isLineSegments?lt.setMode(I.LINES):Ge.isLineLoop?lt.setMode(I.LINE_LOOP):lt.setMode(I.LINE_STRIP)}else Ge.isPoints?lt.setMode(I.POINTS):Ge.isSprite&<.setMode(I.TRIANGLES);if(Ge.isBatchedMesh)if(Ge._multiDrawInstances!==null)ey("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),lt.renderMultiDrawInstances(Ge._multiDrawStarts,Ge._multiDrawCounts,Ge._multiDrawCount,Ge._multiDrawInstances);else if(Te.get("WEBGL_multi_draw"))lt.renderMultiDraw(Ge._multiDrawStarts,Ge._multiDrawCounts,Ge._multiDrawCount);else{const Tt=Ge._multiDrawStarts,Rt=Ge._multiDrawCounts,$t=Ge._multiDrawCount,Ln=yt?ve.get(yt).bytesPerElement:1,bi=j.get(Xe).currentProgram.getUniforms();for(let Qt=0;Qt<$t;Qt++)bi.setValue(I,"_gl_DrawID",Qt),lt.render(Tt[Qt]/Ln,Rt[Qt])}else if(Ge.isInstancedMesh)lt.renderInstances(be,wt,Ge.count);else if(He.isInstancedBufferGeometry){const Tt=He._maxInstanceCount!==void 0?He._maxInstanceCount:1/0,Rt=Math.min(He.instanceCount,Tt);lt.renderInstances(be,wt,Rt)}else lt.render(be,wt)};function gt(ue,Re,He){ue.transparent===!0&&ue.side===Fl&&ue.forceSinglePass===!1?(ue.side=Ms,ue.needsUpdate=!0,_e(ue,Re,He),ue.side=ih,ue.needsUpdate=!0,_e(ue,Re,He),ue.side=Fl):_e(ue,Re,He)}this.compile=function(ue,Re,He=null){He===null&&(He=ue),T=oe.get(He),T.init(Re),E.push(T),He.traverseVisible(function(Ge){Ge.isLight&&Ge.layers.test(Re.layers)&&(T.pushLight(Ge),Ge.castShadow&&T.pushShadow(Ge))}),ue!==He&&ue.traverseVisible(function(Ge){Ge.isLight&&Ge.layers.test(Re.layers)&&(T.pushLight(Ge),Ge.castShadow&&T.pushShadow(Ge))}),T.setupLights();const Xe=new Set;return ue.traverse(function(Ge){if(!(Ge.isMesh||Ge.isPoints||Ge.isLine||Ge.isSprite))return;const ht=Ge.material;if(ht)if(Array.isArray(ht))for(let Pt=0;Pt<ht.length;Pt++){const _t=ht[Pt];gt(_t,He,Ge),Xe.add(_t)}else gt(ht,He,Ge),Xe.add(ht)}),T=E.pop(),Xe},this.compileAsync=function(ue,Re,He=null){const Xe=this.compile(ue,Re,He);return new Promise(Ge=>{function ht(){if(Xe.forEach(function(Pt){j.get(Pt).currentProgram.isReady()&&Xe.delete(Pt)}),Xe.size===0){Ge(ue);return}setTimeout(ht,10)}Te.get("KHR_parallel_shader_compile")!==null?ht():setTimeout(ht,10)})};let Kt=null;function bn(ue){Kt&&Kt(ue)}function At(){yr.stop()}function Pr(){yr.start()}const yr=new Dee;yr.setAnimationLoop(bn),typeof self<"u"&&yr.setContext(self),this.setAnimationLoop=function(ue){Kt=ue,We.setAnimationLoop(ue),ue===null?yr.stop():yr.start()},We.addEventListener("sessionstart",At),We.addEventListener("sessionend",Pr),this.render=function(ue,Re){if(Re!==void 0&&Re.isCamera!==!0){Yn("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(D===!0)return;const He=We.enabled===!0&&We.isPresenting===!0,Xe=O!==null&&(q===null||He)&&O.begin(C,q);if(ue.matrixWorldAutoUpdate===!0&&ue.updateMatrixWorld(),Re.parent===null&&Re.matrixWorldAutoUpdate===!0&&Re.updateMatrixWorld(),We.enabled===!0&&We.isPresenting===!0&&(O===null||O.isCompositing()===!1)&&(We.cameraAutoUpdate===!0&&We.updateCamera(Re),Re=We.getCamera()),ue.isScene===!0&&ue.onBeforeRender(C,ue,Re,q),T=oe.get(ue,E.length),T.init(Re),E.push(T),le.multiplyMatrices(Re.projectionMatrix,Re.matrixWorldInverse),me.setFromProjectionMatrix(le,Vl,Re.reversedDepth),ye=this.localClippingEnabled,Ne=te.init(this.clippingPlanes,ye),A=Qe.get(ue,k.length),A.init(),k.push(A),We.enabled===!0&&We.isPresenting===!0){const Pt=C.xr.getDepthSensingMesh();Pt!==null&&jn(Pt,Re,-1/0,C.sortObjects)}jn(ue,Re,0,C.sortObjects),A.finish(),C.sortObjects===!0&&A.sort(ae,de),X=We.enabled===!1||We.isPresenting===!1||We.hasDepthSensing()===!1,X&&Fe.addToRenderList(A,ue),this.info.render.frame++,Ne===!0&&te.beginShadows();const Ge=T.state.shadowsArray;if(Me.render(Ge,ue,Re),Ne===!0&&te.endShadows(),this.info.autoReset===!0&&this.info.reset(),(Xe&&O.hasRenderPass())===!1){const Pt=A.opaque,_t=A.transmissive;if(T.setupLights(),Re.isArrayCamera){const yt=Re.cameras;if(_t.length>0)for(let It=0,Ot=yt.length;It<Ot;It++){const Ft=yt[It];Rr(Pt,_t,ue,Ft)}X&&Fe.render(ue);for(let It=0,Ot=yt.length;It<Ot;It++){const Ft=yt[It];sn(A,ue,Ft,Ft.viewport)}}else _t.length>0&&Rr(Pt,_t,ue,Re),X&&Fe.render(ue),sn(A,ue,Re)}q!==null&&L===0&&(Y.updateMultisampleRenderTarget(q),Y.updateRenderTargetMipmap(q)),Xe&&O.end(C),ue.isScene===!0&&ue.onAfterRender(C,ue,Re),Oe.resetDefaultState(),P=-1,W=null,E.pop(),E.length>0?(T=E[E.length-1],Ne===!0&&te.setGlobalState(C.clippingPlanes,T.state.camera)):T=null,k.pop(),k.length>0?A=k[k.length-1]:A=null};function jn(ue,Re,He,Xe){if(ue.visible===!1)return;if(ue.layers.test(Re.layers)){if(ue.isGroup)He=ue.renderOrder;else if(ue.isLOD)ue.autoUpdate===!0&&ue.update(Re);else if(ue.isLight)T.pushLight(ue),ue.castShadow&&T.pushShadow(ue);else if(ue.isSprite){if(!ue.frustumCulled||me.intersectsSprite(ue)){Xe&&H.setFromMatrixPosition(ue.matrixWorld).applyMatrix4(le);const Pt=Ie.update(ue),_t=ue.material;_t.visible&&A.push(ue,Pt,_t,He,H.z,null)}}else if((ue.isMesh||ue.isLine||ue.isPoints)&&(!ue.frustumCulled||me.intersectsObject(ue))){const Pt=Ie.update(ue),_t=ue.material;if(Xe&&(ue.boundingSphere!==void 0?(ue.boundingSphere===null&&ue.computeBoundingSphere(),H.copy(ue.boundingSphere.center)):(Pt.boundingSphere===null&&Pt.computeBoundingSphere(),H.copy(Pt.boundingSphere.center)),H.applyMatrix4(ue.matrixWorld).applyMatrix4(le)),Array.isArray(_t)){const yt=Pt.groups;for(let It=0,Ot=yt.length;It<Ot;It++){const Ft=yt[It],be=_t[Ft.materialIndex];be&&be.visible&&A.push(ue,Pt,be,He,H.z,Ft)}}else _t.visible&&A.push(ue,Pt,_t,He,H.z,null)}}const ht=ue.children;for(let Pt=0,_t=ht.length;Pt<_t;Pt++)jn(ht[Pt],Re,He,Xe)}function sn(ue,Re,He,Xe){const{opaque:Ge,transmissive:ht,transparent:Pt}=ue;T.setupLightsView(He),Ne===!0&&te.setGlobalState(C.clippingPlanes,He),Xe&&Ee.viewport(K.copy(Xe)),Ge.length>0&&Gr(Ge,Re,He),ht.length>0&&Gr(ht,Re,He),Pt.length>0&&Gr(Pt,Re,He),Ee.buffers.depth.setTest(!0),Ee.buffers.depth.setMask(!0),Ee.buffers.color.setMask(!0),Ee.setPolygonOffset(!1)}function Rr(ue,Re,He,Xe){if((He.isScene===!0?He.overrideMaterial:null)!==null)return;if(T.state.transmissionRenderTarget[Xe.id]===void 0){const be=Te.has("EXT_color_buffer_half_float")||Te.has("EXT_color_buffer_float");T.state.transmissionRenderTarget[Xe.id]=new Xl(1,1,{generateMipmaps:!0,type:be?Su:Gs,minFilter:vf,samples:Le.samples,stencilBuffer:a,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Wn.workingColorSpace})}const ht=T.state.transmissionRenderTarget[Xe.id],Pt=Xe.viewport||K;ht.setSize(Pt.z*C.transmissionResolutionScale,Pt.w*C.transmissionResolutionScale);const _t=C.getRenderTarget(),yt=C.getActiveCubeFace(),It=C.getActiveMipmapLevel();C.setRenderTarget(ht),C.getClearColor(re),J=C.getClearAlpha(),J<1&&C.setClearColor(16777215,.5),C.clear(),X&&Fe.render(He);const Ot=C.toneMapping;C.toneMapping=Kl;const Ft=Xe.viewport;if(Xe.viewport!==void 0&&(Xe.viewport=void 0),T.setupLightsView(Xe),Ne===!0&&te.setGlobalState(C.clippingPlanes,Xe),Gr(ue,He,Xe),Y.updateMultisampleRenderTarget(ht),Y.updateRenderTargetMipmap(ht),Te.has("WEBGL_multisampled_render_to_texture")===!1){let be=!1;for(let Pe=0,wt=Re.length;Pe<wt;Pe++){const Mt=Re[Pe],{object:lt,geometry:Tt,material:Rt,group:$t}=Mt;if(Rt.side===Fl&<.layers.test(Xe.layers)){const Ln=Rt.side;Rt.side=Ms,Rt.needsUpdate=!0,Dr(lt,He,Xe,Tt,Rt,$t),Rt.side=Ln,Rt.needsUpdate=!0,be=!0}}be===!0&&(Y.updateMultisampleRenderTarget(ht),Y.updateRenderTargetMipmap(ht))}C.setRenderTarget(_t,yt,It),C.setClearColor(re,J),Ft!==void 0&&(Xe.viewport=Ft),C.toneMapping=Ot}function Gr(ue,Re,He){const Xe=Re.isScene===!0?Re.overrideMaterial:null;for(let Ge=0,ht=ue.length;Ge<ht;Ge++){const Pt=ue[Ge],{object:_t,geometry:yt,group:It}=Pt;let Ot=Pt.material;Ot.allowOverride===!0&&Xe!==null&&(Ot=Xe),_t.layers.test(He.layers)&&Dr(_t,Re,He,yt,Ot,It)}}function Dr(ue,Re,He,Xe,Ge,ht){ue.onBeforeRender(C,Re,He,Xe,Ge,ht),ue.modelViewMatrix.multiplyMatrices(He.matrixWorldInverse,ue.matrixWorld),ue.normalMatrix.getNormalMatrix(ue.modelViewMatrix),Ge.onBeforeRender(C,Re,He,Xe,ue,ht),Ge.transparent===!0&&Ge.side===Fl&&Ge.forceSinglePass===!1?(Ge.side=Ms,Ge.needsUpdate=!0,C.renderBufferDirect(He,Re,Xe,Ge,ue,ht),Ge.side=ih,Ge.needsUpdate=!0,C.renderBufferDirect(He,Re,Xe,Ge,ue,ht),Ge.side=Fl):C.renderBufferDirect(He,Re,Xe,Ge,ue,ht),ue.onAfterRender(C,Re,He,Xe,Ge,ht)}function _e(ue,Re,He){Re.isScene!==!0&&(Re=ee);const Xe=j.get(ue),Ge=T.state.lights,ht=T.state.shadowsArray,Pt=Ge.state.version,_t=qe.getParameters(ue,Ge.state,ht,Re,He),yt=qe.getProgramCacheKey(_t);let It=Xe.programs;Xe.environment=ue.isMeshStandardMaterial?Re.environment:null,Xe.fog=Re.fog,Xe.envMap=(ue.isMeshStandardMaterial?we:ge).get(ue.envMap||Xe.environment),Xe.envMapRotation=Xe.environment!==null&&ue.envMap===null?Re.environmentRotation:ue.envMapRotation,It===void 0&&(ue.addEventListener("dispose",ln),It=new Map,Xe.programs=It);let Ot=It.get(yt);if(Ot!==void 0){if(Xe.currentProgram===Ot&&Xe.lightsStateVersion===Pt)return at(ue,_t),Ot}else _t.uniforms=qe.getUniforms(ue),ue.onBeforeCompile(_t,C),Ot=qe.acquireProgram(_t,yt),It.set(yt,Ot),Xe.uniforms=_t.uniforms;const Ft=Xe.uniforms;return(!ue.isShaderMaterial&&!ue.isRawShaderMaterial||ue.clipping===!0)&&(Ft.clippingPlanes=te.uniform),at(ue,_t),Xe.needsLights=jt(ue),Xe.lightsStateVersion=Pt,Xe.needsLights&&(Ft.ambientLightColor.value=Ge.state.ambient,Ft.lightProbe.value=Ge.state.probe,Ft.directionalLights.value=Ge.state.directional,Ft.directionalLightShadows.value=Ge.state.directionalShadow,Ft.spotLights.value=Ge.state.spot,Ft.spotLightShadows.value=Ge.state.spotShadow,Ft.rectAreaLights.value=Ge.state.rectArea,Ft.ltc_1.value=Ge.state.rectAreaLTC1,Ft.ltc_2.value=Ge.state.rectAreaLTC2,Ft.pointLights.value=Ge.state.point,Ft.pointLightShadows.value=Ge.state.pointShadow,Ft.hemisphereLights.value=Ge.state.hemi,Ft.directionalShadowMap.value=Ge.state.directionalShadowMap,Ft.directionalShadowMatrix.value=Ge.state.directionalShadowMatrix,Ft.spotShadowMap.value=Ge.state.spotShadowMap,Ft.spotLightMatrix.value=Ge.state.spotLightMatrix,Ft.spotLightMap.value=Ge.state.spotLightMap,Ft.pointShadowMap.value=Ge.state.pointShadowMap,Ft.pointShadowMatrix.value=Ge.state.pointShadowMatrix),Xe.currentProgram=Ot,Xe.uniformsList=null,Ot}function Ve(ue){if(ue.uniformsList===null){const Re=ue.currentProgram.getUniforms();ue.uniformsList=_1.seqWithValue(Re.seq,ue.uniforms)}return ue.uniformsList}function at(ue,Re){const He=j.get(ue);He.outputColorSpace=Re.outputColorSpace,He.batching=Re.batching,He.batchingColor=Re.batchingColor,He.instancing=Re.instancing,He.instancingColor=Re.instancingColor,He.instancingMorph=Re.instancingMorph,He.skinning=Re.skinning,He.morphTargets=Re.morphTargets,He.morphNormals=Re.morphNormals,He.morphColors=Re.morphColors,He.morphTargetsCount=Re.morphTargetsCount,He.numClippingPlanes=Re.numClippingPlanes,He.numIntersection=Re.numClipIntersection,He.vertexAlphas=Re.vertexAlphas,He.vertexTangents=Re.vertexTangents,He.toneMapping=Re.toneMapping}function ct(ue,Re,He,Xe,Ge){Re.isScene!==!0&&(Re=ee),Y.resetTextureUnits();const ht=Re.fog,Pt=Xe.isMeshStandardMaterial?Re.environment:null,_t=q===null?C.outputColorSpace:q.isXRRenderTarget===!0?q.texture.colorSpace:Rg,yt=(Xe.isMeshStandardMaterial?we:ge).get(Xe.envMap||Pt),It=Xe.vertexColors===!0&&!!He.attributes.color&&He.attributes.color.itemSize===4,Ot=!!He.attributes.tangent&&(!!Xe.normalMap||Xe.anisotropy>0),Ft=!!He.morphAttributes.position,be=!!He.morphAttributes.normal,Pe=!!He.morphAttributes.color;let wt=Kl;Xe.toneMapped&&(q===null||q.isXRRenderTarget===!0)&&(wt=C.toneMapping);const Mt=He.morphAttributes.position||He.morphAttributes.normal||He.morphAttributes.color,lt=Mt!==void 0?Mt.length:0,Tt=j.get(Xe),Rt=T.state.lights;if(Ne===!0&&(ye===!0||ue!==W)){const di=ue===W&&Xe.id===P;te.setState(Xe,ue,di)}let $t=!1;Xe.version===Tt.__version?(Tt.needsLights&&Tt.lightsStateVersion!==Rt.state.version||Tt.outputColorSpace!==_t||Ge.isBatchedMesh&&Tt.batching===!1||!Ge.isBatchedMesh&&Tt.batching===!0||Ge.isBatchedMesh&&Tt.batchingColor===!0&&Ge.colorTexture===null||Ge.isBatchedMesh&&Tt.batchingColor===!1&&Ge.colorTexture!==null||Ge.isInstancedMesh&&Tt.instancing===!1||!Ge.isInstancedMesh&&Tt.instancing===!0||Ge.isSkinnedMesh&&Tt.skinning===!1||!Ge.isSkinnedMesh&&Tt.skinning===!0||Ge.isInstancedMesh&&Tt.instancingColor===!0&&Ge.instanceColor===null||Ge.isInstancedMesh&&Tt.instancingColor===!1&&Ge.instanceColor!==null||Ge.isInstancedMesh&&Tt.instancingMorph===!0&&Ge.morphTexture===null||Ge.isInstancedMesh&&Tt.instancingMorph===!1&&Ge.morphTexture!==null||Tt.envMap!==yt||Xe.fog===!0&&Tt.fog!==ht||Tt.numClippingPlanes!==void 0&&(Tt.numClippingPlanes!==te.numPlanes||Tt.numIntersection!==te.numIntersection)||Tt.vertexAlphas!==It||Tt.vertexTangents!==Ot||Tt.morphTargets!==Ft||Tt.morphNormals!==be||Tt.morphColors!==Pe||Tt.toneMapping!==wt||Tt.morphTargetsCount!==lt)&&($t=!0):($t=!0,Tt.__version=Xe.version);let Ln=Tt.currentProgram;$t===!0&&(Ln=_e(Xe,Re,Ge));let bi=!1,Qt=!1,cn=!1;const An=Ln.getUniforms(),Or=Tt.uniforms;if(Ee.useProgram(Ln.program)&&(bi=!0,Qt=!0,cn=!0),Xe.id!==P&&(P=Xe.id,Qt=!0),bi||W!==ue){Ee.buffers.depth.getReversed()&&ue.reversedDepth!==!0&&(ue._reversedDepth=!0,ue.updateProjectionMatrix()),An.setValue(I,"projectionMatrix",ue.projectionMatrix),An.setValue(I,"viewMatrix",ue.matrixWorldInverse);const hi=An.map.cameraPosition;hi!==void 0&&hi.setValue(I,$e.setFromMatrixPosition(ue.matrixWorld)),Le.logarithmicDepthBuffer&&An.setValue(I,"logDepthBufFC",2/(Math.log(ue.far+1)/Math.LN2)),(Xe.isMeshPhongMaterial||Xe.isMeshToonMaterial||Xe.isMeshLambertMaterial||Xe.isMeshBasicMaterial||Xe.isMeshStandardMaterial||Xe.isShaderMaterial)&&An.setValue(I,"isOrthographic",ue.isOrthographicCamera===!0),W!==ue&&(W=ue,Qt=!0,cn=!0)}if(Tt.needsLights&&(Rt.state.directionalShadowMap.length>0&&An.setValue(I,"directionalShadowMap",Rt.state.directionalShadowMap,Y),Rt.state.spotShadowMap.length>0&&An.setValue(I,"spotShadowMap",Rt.state.spotShadowMap,Y),Rt.state.pointShadowMap.length>0&&An.setValue(I,"pointShadowMap",Rt.state.pointShadowMap,Y)),Ge.isSkinnedMesh){An.setOptional(I,Ge,"bindMatrix"),An.setOptional(I,Ge,"bindMatrixInverse");const di=Ge.skeleton;di&&(di.boneTexture===null&&di.computeBoneTexture(),An.setValue(I,"boneTexture",di.boneTexture,Y))}Ge.isBatchedMesh&&(An.setOptional(I,Ge,"batchingTexture"),An.setValue(I,"batchingTexture",Ge._matricesTexture,Y),An.setOptional(I,Ge,"batchingIdTexture"),An.setValue(I,"batchingIdTexture",Ge._indirectTexture,Y),An.setOptional(I,Ge,"batchingColorTexture"),Ge._colorsTexture!==null&&An.setValue(I,"batchingColorTexture",Ge._colorsTexture,Y));const Lr=He.morphAttributes;if((Lr.position!==void 0||Lr.normal!==void 0||Lr.color!==void 0)&&ot.update(Ge,He,Ln),(Qt||Tt.receiveShadow!==Ge.receiveShadow)&&(Tt.receiveShadow=Ge.receiveShadow,An.setValue(I,"receiveShadow",Ge.receiveShadow)),Xe.isMeshGouraudMaterial&&Xe.envMap!==null&&(Or.envMap.value=yt,Or.flipEnvMap.value=yt.isCubeTexture&&yt.isRenderTargetTexture===!1?-1:1),Xe.isMeshStandardMaterial&&Xe.envMap===null&&Re.environment!==null&&(Or.envMapIntensity.value=Re.environmentIntensity),Or.dfgLUT!==void 0&&(Or.dfgLUT.value=yIe()),Qt&&(An.setValue(I,"toneMappingExposure",C.toneMappingExposure),Tt.needsLights&&rt(Or,cn),ht&&Xe.fog===!0&&Je.refreshFogUniforms(Or,ht),Je.refreshMaterialUniforms(Or,Xe,ne,G,T.state.transmissionRenderTarget[ue.id]),_1.upload(I,Ve(Tt),Or,Y)),Xe.isShaderMaterial&&Xe.uniformsNeedUpdate===!0&&(_1.upload(I,Ve(Tt),Or,Y),Xe.uniformsNeedUpdate=!1),Xe.isSpriteMaterial&&An.setValue(I,"center",Ge.center),An.setValue(I,"modelViewMatrix",Ge.modelViewMatrix),An.setValue(I,"normalMatrix",Ge.normalMatrix),An.setValue(I,"modelMatrix",Ge.matrixWorld),Xe.isShaderMaterial||Xe.isRawShaderMaterial){const di=Xe.uniformsGroups;for(let hi=0,cs=di.length;hi<cs;hi++){const Er=di[hi];Ue.update(Er,Ln),Ue.bind(Er,Ln)}}return Ln}function rt(ue,Re){ue.ambientLightColor.needsUpdate=Re,ue.lightProbe.needsUpdate=Re,ue.directionalLights.needsUpdate=Re,ue.directionalLightShadows.needsUpdate=Re,ue.pointLights.needsUpdate=Re,ue.pointLightShadows.needsUpdate=Re,ue.spotLights.needsUpdate=Re,ue.spotLightShadows.needsUpdate=Re,ue.rectAreaLights.needsUpdate=Re,ue.hemisphereLights.needsUpdate=Re}function jt(ue){return ue.isMeshLambertMaterial||ue.isMeshToonMaterial||ue.isMeshPhongMaterial||ue.isMeshStandardMaterial||ue.isShadowMaterial||ue.isShaderMaterial&&ue.lights===!0}this.getActiveCubeFace=function(){return U},this.getActiveMipmapLevel=function(){return L},this.getRenderTarget=function(){return q},this.setRenderTargetTextures=function(ue,Re,He){const Xe=j.get(ue);Xe.__autoAllocateDepthBuffer=ue.resolveDepthBuffer===!1,Xe.__autoAllocateDepthBuffer===!1&&(Xe.__useRenderToTexture=!1),j.get(ue.texture).__webglTexture=Re,j.get(ue.depthTexture).__webglTexture=Xe.__autoAllocateDepthBuffer?void 0:He,Xe.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(ue,Re){const He=j.get(ue);He.__webglFramebuffer=Re,He.__useDefaultFramebuffer=Re===void 0};const zt=I.createFramebuffer();this.setRenderTarget=function(ue,Re=0,He=0){q=ue,U=Re,L=He;let Xe=null,Ge=!1,ht=!1;if(ue){const _t=j.get(ue);if(_t.__useDefaultFramebuffer!==void 0){Ee.bindFramebuffer(I.FRAMEBUFFER,_t.__webglFramebuffer),K.copy(ue.viewport),V.copy(ue.scissor),Q=ue.scissorTest,Ee.viewport(K),Ee.scissor(V),Ee.setScissorTest(Q),P=-1;return}else if(_t.__webglFramebuffer===void 0)Y.setupRenderTarget(ue);else if(_t.__hasExternalTextures)Y.rebindTextures(ue,j.get(ue.texture).__webglTexture,j.get(ue.depthTexture).__webglTexture);else if(ue.depthBuffer){const Ot=ue.depthTexture;if(_t.__boundDepthTexture!==Ot){if(Ot!==null&&j.has(Ot)&&(ue.width!==Ot.image.width||ue.height!==Ot.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");Y.setupDepthRenderbuffer(ue)}}const yt=ue.texture;(yt.isData3DTexture||yt.isDataArrayTexture||yt.isCompressedArrayTexture)&&(ht=!0);const It=j.get(ue).__webglFramebuffer;ue.isWebGLCubeRenderTarget?(Array.isArray(It[Re])?Xe=It[Re][He]:Xe=It[Re],Ge=!0):ue.samples>0&&Y.useMultisampledRTT(ue)===!1?Xe=j.get(ue).__webglMultisampledFramebuffer:Array.isArray(It)?Xe=It[He]:Xe=It,K.copy(ue.viewport),V.copy(ue.scissor),Q=ue.scissorTest}else K.copy(fe).multiplyScalar(ne).floor(),V.copy(ie).multiplyScalar(ne).floor(),Q=Ae;if(He!==0&&(Xe=zt),Ee.bindFramebuffer(I.FRAMEBUFFER,Xe)&&Ee.drawBuffers(ue,Xe),Ee.viewport(K),Ee.scissor(V),Ee.setScissorTest(Q),Ge){const _t=j.get(ue.texture);I.framebufferTexture2D(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_CUBE_MAP_POSITIVE_X+Re,_t.__webglTexture,He)}else if(ht){const _t=Re;for(let yt=0;yt<ue.textures.length;yt++){const It=j.get(ue.textures[yt]);I.framebufferTextureLayer(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0+yt,It.__webglTexture,He,_t)}}else if(ue!==null&&He!==0){const _t=j.get(ue.texture);I.framebufferTexture2D(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,_t.__webglTexture,He)}P=-1},this.readRenderTargetPixels=function(ue,Re,He,Xe,Ge,ht,Pt,_t=0){if(!(ue&&ue.isWebGLRenderTarget)){Yn("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let yt=j.get(ue).__webglFramebuffer;if(ue.isWebGLCubeRenderTarget&&Pt!==void 0&&(yt=yt[Pt]),yt){Ee.bindFramebuffer(I.FRAMEBUFFER,yt);try{const It=ue.textures[_t],Ot=It.format,Ft=It.type;if(!Le.textureFormatReadable(Ot)){Yn("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Le.textureTypeReadable(Ft)){Yn("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Re>=0&&Re<=ue.width-Xe&&He>=0&&He<=ue.height-Ge&&(ue.textures.length>1&&I.readBuffer(I.COLOR_ATTACHMENT0+_t),I.readPixels(Re,He,Xe,Ge,xe.convert(Ot),xe.convert(Ft),ht))}finally{const It=q!==null?j.get(q).__webglFramebuffer:null;Ee.bindFramebuffer(I.FRAMEBUFFER,It)}}},this.readRenderTargetPixelsAsync=async function(ue,Re,He,Xe,Ge,ht,Pt,_t=0){if(!(ue&&ue.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let yt=j.get(ue).__webglFramebuffer;if(ue.isWebGLCubeRenderTarget&&Pt!==void 0&&(yt=yt[Pt]),yt)if(Re>=0&&Re<=ue.width-Xe&&He>=0&&He<=ue.height-Ge){Ee.bindFramebuffer(I.FRAMEBUFFER,yt);const It=ue.textures[_t],Ot=It.format,Ft=It.type;if(!Le.textureFormatReadable(Ot))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Le.textureTypeReadable(Ft))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const be=I.createBuffer();I.bindBuffer(I.PIXEL_PACK_BUFFER,be),I.bufferData(I.PIXEL_PACK_BUFFER,ht.byteLength,I.STREAM_READ),ue.textures.length>1&&I.readBuffer(I.COLOR_ATTACHMENT0+_t),I.readPixels(Re,He,Xe,Ge,xe.convert(Ot),xe.convert(Ft),0);const Pe=q!==null?j.get(q).__webglFramebuffer:null;Ee.bindFramebuffer(I.FRAMEBUFFER,Pe);const wt=I.fenceSync(I.SYNC_GPU_COMMANDS_COMPLETE,0);return I.flush(),await O3e(I,wt,4),I.bindBuffer(I.PIXEL_PACK_BUFFER,be),I.getBufferSubData(I.PIXEL_PACK_BUFFER,0,ht),I.deleteBuffer(be),I.deleteSync(wt),ht}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(ue,Re=null,He=0){const Xe=Math.pow(2,-He),Ge=Math.floor(ue.image.width*Xe),ht=Math.floor(ue.image.height*Xe),Pt=Re!==null?Re.x:0,_t=Re!==null?Re.y:0;Y.setTexture2D(ue,0),I.copyTexSubImage2D(I.TEXTURE_2D,He,0,0,Pt,_t,Ge,ht),Ee.unbindTexture()};const Xt=I.createFramebuffer(),Yt=I.createFramebuffer();this.copyTextureToTexture=function(ue,Re,He=null,Xe=null,Ge=0,ht=null){ht===null&&(Ge!==0?(ey("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),ht=Ge,Ge=0):ht=0);let Pt,_t,yt,It,Ot,Ft,be,Pe,wt;const Mt=ue.isCompressedTexture?ue.mipmaps[ht]:ue.image;if(He!==null)Pt=He.max.x-He.min.x,_t=He.max.y-He.min.y,yt=He.isBox3?He.max.z-He.min.z:1,It=He.min.x,Ot=He.min.y,Ft=He.isBox3?He.min.z:0;else{const Lr=Math.pow(2,-Ge);Pt=Math.floor(Mt.width*Lr),_t=Math.floor(Mt.height*Lr),ue.isDataArrayTexture?yt=Mt.depth:ue.isData3DTexture?yt=Math.floor(Mt.depth*Lr):yt=1,It=0,Ot=0,Ft=0}Xe!==null?(be=Xe.x,Pe=Xe.y,wt=Xe.z):(be=0,Pe=0,wt=0);const lt=xe.convert(Re.format),Tt=xe.convert(Re.type);let Rt;Re.isData3DTexture?(Y.setTexture3D(Re,0),Rt=I.TEXTURE_3D):Re.isDataArrayTexture||Re.isCompressedArrayTexture?(Y.setTexture2DArray(Re,0),Rt=I.TEXTURE_2D_ARRAY):(Y.setTexture2D(Re,0),Rt=I.TEXTURE_2D),I.pixelStorei(I.UNPACK_FLIP_Y_WEBGL,Re.flipY),I.pixelStorei(I.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Re.premultiplyAlpha),I.pixelStorei(I.UNPACK_ALIGNMENT,Re.unpackAlignment);const $t=I.getParameter(I.UNPACK_ROW_LENGTH),Ln=I.getParameter(I.UNPACK_IMAGE_HEIGHT),bi=I.getParameter(I.UNPACK_SKIP_PIXELS),Qt=I.getParameter(I.UNPACK_SKIP_ROWS),cn=I.getParameter(I.UNPACK_SKIP_IMAGES);I.pixelStorei(I.UNPACK_ROW_LENGTH,Mt.width),I.pixelStorei(I.UNPACK_IMAGE_HEIGHT,Mt.height),I.pixelStorei(I.UNPACK_SKIP_PIXELS,It),I.pixelStorei(I.UNPACK_SKIP_ROWS,Ot),I.pixelStorei(I.UNPACK_SKIP_IMAGES,Ft);const An=ue.isDataArrayTexture||ue.isData3DTexture,Or=Re.isDataArrayTexture||Re.isData3DTexture;if(ue.isDepthTexture){const Lr=j.get(ue),di=j.get(Re),hi=j.get(Lr.__renderTarget),cs=j.get(di.__renderTarget);Ee.bindFramebuffer(I.READ_FRAMEBUFFER,hi.__webglFramebuffer),Ee.bindFramebuffer(I.DRAW_FRAMEBUFFER,cs.__webglFramebuffer);for(let Er=0;Er<yt;Er++)An&&(I.framebufferTextureLayer(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,j.get(ue).__webglTexture,Ge,Ft+Er),I.framebufferTextureLayer(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,j.get(Re).__webglTexture,ht,wt+Er)),I.blitFramebuffer(It,Ot,Pt,_t,be,Pe,Pt,_t,I.DEPTH_BUFFER_BIT,I.NEAREST);Ee.bindFramebuffer(I.READ_FRAMEBUFFER,null),Ee.bindFramebuffer(I.DRAW_FRAMEBUFFER,null)}else if(Ge!==0||ue.isRenderTargetTexture||j.has(ue)){const Lr=j.get(ue),di=j.get(Re);Ee.bindFramebuffer(I.READ_FRAMEBUFFER,Xt),Ee.bindFramebuffer(I.DRAW_FRAMEBUFFER,Yt);for(let hi=0;hi<yt;hi++)An?I.framebufferTextureLayer(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,Lr.__webglTexture,Ge,Ft+hi):I.framebufferTexture2D(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,Lr.__webglTexture,Ge),Or?I.framebufferTextureLayer(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,di.__webglTexture,ht,wt+hi):I.framebufferTexture2D(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,di.__webglTexture,ht),Ge!==0?I.blitFramebuffer(It,Ot,Pt,_t,be,Pe,Pt,_t,I.COLOR_BUFFER_BIT,I.NEAREST):Or?I.copyTexSubImage3D(Rt,ht,be,Pe,wt+hi,It,Ot,Pt,_t):I.copyTexSubImage2D(Rt,ht,be,Pe,It,Ot,Pt,_t);Ee.bindFramebuffer(I.READ_FRAMEBUFFER,null),Ee.bindFramebuffer(I.DRAW_FRAMEBUFFER,null)}else Or?ue.isDataTexture||ue.isData3DTexture?I.texSubImage3D(Rt,ht,be,Pe,wt,Pt,_t,yt,lt,Tt,Mt.data):Re.isCompressedArrayTexture?I.compressedTexSubImage3D(Rt,ht,be,Pe,wt,Pt,_t,yt,lt,Mt.data):I.texSubImage3D(Rt,ht,be,Pe,wt,Pt,_t,yt,lt,Tt,Mt):ue.isDataTexture?I.texSubImage2D(I.TEXTURE_2D,ht,be,Pe,Pt,_t,lt,Tt,Mt.data):ue.isCompressedTexture?I.compressedTexSubImage2D(I.TEXTURE_2D,ht,be,Pe,Mt.width,Mt.height,lt,Mt.data):I.texSubImage2D(I.TEXTURE_2D,ht,be,Pe,Pt,_t,lt,Tt,Mt);I.pixelStorei(I.UNPACK_ROW_LENGTH,$t),I.pixelStorei(I.UNPACK_IMAGE_HEIGHT,Ln),I.pixelStorei(I.UNPACK_SKIP_PIXELS,bi),I.pixelStorei(I.UNPACK_SKIP_ROWS,Qt),I.pixelStorei(I.UNPACK_SKIP_IMAGES,cn),ht===0&&Re.generateMipmaps&&I.generateMipmap(Rt),Ee.unbindTexture()},this.initRenderTarget=function(ue){j.get(ue).__webglFramebuffer===void 0&&Y.setupRenderTarget(ue)},this.initTexture=function(ue){ue.isCubeTexture?Y.setTextureCube(ue,0):ue.isData3DTexture?Y.setTexture3D(ue,0):ue.isDataArrayTexture||ue.isCompressedArrayTexture?Y.setTexture2DArray(ue,0):Y.setTexture2D(ue,0),Ee.unbindTexture()},this.resetState=function(){U=0,L=0,q=null,Ee.reset(),Oe.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=Wn._getDrawingBufferColorSpace(e),n.unpackColorSpace=Wn._getUnpackColorSpace()}};const MG={type:"change"},gL={type:"start"},Uee={type:"end"},aw=new uL,NG=new _d,_Ie=Math.cos(70*I3e.DEG2RAD),Pi=new tt,xs=2*Math.PI,pr={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Tk=1e-6;class wIe extends MRe{constructor(e,n=null){super(e,n),this.state=pr.NONE,this.target=new tt,this.cursor=new tt,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:cg.ROTATE,MIDDLE:cg.DOLLY,RIGHT:cg.PAN},this.touches={ONE:eg.ROTATE,TWO:eg.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new tt,this._lastQuaternion=new im,this._lastTargetPosition=new tt,this._quat=new im().setFromUnitVectors(e.up,new tt(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new JV,this._sphericalDelta=new JV,this._scale=1,this._panOffset=new tt,this._rotateStart=new Nn,this._rotateEnd=new Nn,this._rotateDelta=new Nn,this._panStart=new Nn,this._panEnd=new Nn,this._panDelta=new Nn,this._dollyStart=new Nn,this._dollyEnd=new Nn,this._dollyDelta=new Nn,this._dollyDirection=new tt,this._mouse=new Nn,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=MIe.bind(this),this._onPointerDown=SIe.bind(this),this._onPointerUp=NIe.bind(this),this._onContextMenu=PIe.bind(this),this._onMouseWheel=TIe.bind(this),this._onKeyDown=CIe.bind(this),this._onTouchStart=kIe.bind(this),this._onTouchMove=jIe.bind(this),this._onMouseDown=EIe.bind(this),this._onMouseMove=AIe.bind(this),this._interceptControlDown=RIe.bind(this),this._interceptControlUp=DIe.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(MG),this.update(),this.state=pr.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===pr.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+=xs:r>Math.PI&&(r-=xs),i<-Math.PI?i+=xs:i>Math.PI&&(i-=xs),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 tt(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 tt(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):(aw.origin.copy(this.object.position),aw.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(aw.direction))<_Ie?this.object.lookAt(this.target):(NG.setFromNormalAndCoplanarPoint(this.object.up,this.target),aw.intersectPlane(NG,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)>Tk||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Tk||this._lastTargetPosition.distanceToSquared(this.target)>Tk?(this.dispatchEvent(MG),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?xs/60*this.autoRotateSpeed*e:xs/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(xs*this._rotateDelta.x/n.clientHeight),this._rotateUp(xs*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(xs*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(-xs*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(xs*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(-xs*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(xs*this._rotateDelta.x/n.clientHeight),this._rotateUp(xs*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 Nn,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 SIe(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 MIe(t){this.enabled!==!1&&(t.pointerType==="touch"?this._onTouchMove(t):this._onMouseMove(t))}function NIe(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(Uee),this.state=pr.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 EIe(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 cg.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(t),this.state=pr.DOLLY;break;case cg.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=pr.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=pr.ROTATE}break;case cg.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=pr.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=pr.PAN}break;default:this.state=pr.NONE}this.state!==pr.NONE&&this.dispatchEvent(gL)}function AIe(t){switch(this.state){case pr.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(t);break;case pr.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(t);break;case pr.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(t);break}}function TIe(t){this.enabled===!1||this.enableZoom===!1||this.state!==pr.NONE||(t.preventDefault(),this.dispatchEvent(gL),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(Uee))}function CIe(t){this.enabled!==!1&&this._handleKeyDown(t)}function kIe(t){switch(this._trackPointer(t),this._pointers.length){case 1:switch(this.touches.ONE){case eg.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(t),this.state=pr.TOUCH_ROTATE;break;case eg.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(t),this.state=pr.TOUCH_PAN;break;default:this.state=pr.NONE}break;case 2:switch(this.touches.TWO){case eg.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(t),this.state=pr.TOUCH_DOLLY_PAN;break;case eg.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(t),this.state=pr.TOUCH_DOLLY_ROTATE;break;default:this.state=pr.NONE}break;default:this.state=pr.NONE}this.state!==pr.NONE&&this.dispatchEvent(gL)}function jIe(t){switch(this._trackPointer(t),this.state){case pr.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(t),this.update();break;case pr.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(t),this.update();break;case pr.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(t),this.update();break;case pr.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(t),this.update();break;default:this.state=pr.NONE}}function PIe(t){this.enabled!==!1&&t.preventDefault()}function RIe(t){t.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function DIe(t){t.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function OIe(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 vl;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=EG(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=EG(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 EG(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 ko(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 sw(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 Ck={exports:{}};var AG;function LIe(){return AG||(AG=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 sw=="function"&&sw;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 sw=="function"&&sw,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,A=a.getTypeOf(c)!=="string";v<c.length;)M=S-v,f=A?(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,A,T=p.file,k=p.compression,E=S!==u.utf8encode,O=l.transformTo("string",S(T.name)),C=l.transformTo("string",u.utf8encode(T.name)),D=T.comment,U=l.transformTo("string",S(D)),L=l.transformTo("string",u.utf8encode(D)),q=C.length!==T.name.length,P=L.length!==D.length,W="",K="",V="",Q=T.dir,re=T.date,J={crc32:0,compressedSize:0,uncompressedSize:0};b&&!y||(J.crc32=p.crc32,J.compressedSize=p.compressedSize,J.uncompressedSize=p.uncompressedSize);var z=0;b&&(z|=8),E||!q&&!P||(z|=2048);var G=0,ne=0;Q&&(G|=16),v==="UNIX"?(ne=798,G|=(function(de,fe){var ie=de;return de||(ie=fe?16893:33204),(65535&ie)<<16})(T.unixPermissions,Q)):(ne=20,G|=(function(de){return 63&(de||0)})(T.dosPermissions)),M=re.getUTCHours(),M<<=6,M|=re.getUTCMinutes(),M<<=5,M|=re.getUTCSeconds()/2,A=re.getUTCFullYear()-1980,A<<=4,A|=re.getUTCMonth()+1,A<<=5,A|=re.getUTCDate(),q&&(K=a(1,1)+a(d(O),4)+C,W+="up"+a(K.length,2)+K),P&&(V=a(1,1)+a(d(U),4)+L,W+="uc"+a(V.length,2)+V);var ae="";return ae+=`
- \0`,ae+=a(z,2),ae+=k.magic,ae+=a(M,2),ae+=a(A,2),ae+=a(J.crc32,4),ae+=a(J.compressedSize,4),ae+=a(J.uncompressedSize,4),ae+=a(O.length,2),ae+=a(W.length,2),{fileRecord:f.LOCAL_FILE_HEADER+ae+O+W,dirRecord:f.CENTRAL_FILE_HEADER+a(ne,2)+ae+a(U.length,2)+"\0\0\0\0"+a(G,4)+a(x,4)+O+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,A,T){var k=l.transformTo("string",T(A));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 A=S||M,T=a[A];if(!T)throw new Error(A+" is not a valid compression method !");return T})(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],A=M.fileNameStr,T=a.resolve(M.fileNameStr);b.file(T,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(T).unsafeOriginalName=A)}return x.zipComment.length&&(b.comment=x.zipComment),b})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(n,r,i){var a=n("../utils"),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(T,k,E){var O,C=l.getTypeOf(k),D=l.extend(E||{},d);D.date=D.date||new Date,D.compression!==null&&(D.compression=D.compression.toUpperCase()),typeof D.unixPermissions=="string"&&(D.unixPermissions=parseInt(D.unixPermissions,8)),D.unixPermissions&&16384&D.unixPermissions&&(D.dir=!0),D.dosPermissions&&16&D.dosPermissions&&(D.dir=!0),D.dir&&(T=v(T)),D.createFolders&&(O=x(T))&&S.call(this,O,!0);var U=C==="string"&&D.binary===!1&&D.base64===!1;E&&E.binary!==void 0||(D.binary=!U),(k instanceof f&&k.uncompressedSize===0||D.dir||!k||k.length===0)&&(D.base64=!1,D.binary=!0,k="",D.compression="STORE",C="string");var L=null;L=k instanceof f||k instanceof c?k:b.isNode&&b.isStream(k)?new y(T,k):l.prepareContent(T,k,D.binary,D.optimizedBinaryString,D.base64);var q=new m(T,L,D);this.files[T]=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(T){T.slice(-1)==="/"&&(T=T.substring(0,T.length-1));var k=T.lastIndexOf("/");return 0<k?T.substring(0,k):""},v=function(T){return T.slice(-1)!=="/"&&(T+="/"),T},S=function(T,k){return k=k!==void 0?k:d.createFolders,T=v(T),this.files[T]||a.call(this,T,null,{dir:!0,createFolders:k}),this.files[T]};function M(T){return Object.prototype.toString.call(T)==="[object RegExp]"}var A={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(T){var k,E,O;for(k in this.files)O=this.files[k],(E=k.slice(this.root.length,k.length))&&k.slice(0,this.root.length)===this.root&&T(E,O)},filter:function(T){var k=[];return this.forEach(function(E,O){T(E,O)&&k.push(O)}),k},file:function(T,k,E){if(arguments.length!==1)return T=this.root+T,a.call(this,T,k,E),this;if(M(T)){var O=T;return this.filter(function(D,U){return!U.dir&&O.test(D)})}var C=this.files[this.root+T];return C&&!C.dir?C:null},folder:function(T){if(!T)return this;if(M(T))return this.filter(function(C,D){return D.dir&&T.test(C)});var k=this.root+T,E=S.call(this,k),O=this.clone();return O.root=E.name,O},remove:function(T){T=this.root+T;var k=this.files[T];if(k||(T.slice(-1)!=="/"&&(T+="/"),k=this.files[T]),k&&!k.dir)delete this.files[T];else for(var E=this.filter(function(C,D){return D.name.slice(0,T.length)===T}),O=0;O<E.length;O++)delete this.files[E[O].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(T){var k,E={};try{if((E=l.extend(T||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:o.utf8encode})).type=E.type.toLowerCase(),E.compression=E.compression.toUpperCase(),E.type==="binarystring"&&(E.type="string"),!E.type)throw new Error("No output type specified.");l.checkSupport(E.type),E.platform!=="darwin"&&E.platform!=="freebsd"&&E.platform!=="linux"&&E.platform!=="sunos"||(E.platform="UNIX"),E.platform==="win32"&&(E.platform="DOS");var O=E.comment||this.comment||"";k=p.generateWorker(this,E,O)}catch(C){(k=new c("error")).error(C)}return new u(k,E.type||"string",E.mimeType)},generateAsync:function(T,k){return this.generateInternalStream(T).accumulate(k)},generateNodeStream:function(T,k){return(T=T||{}).type||(T.type="nodebuffer"),this.generateInternalStream(T).toNodejsStream(k)}};r.exports=A},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(n,r,i){r.exports=n("stream")},{stream:void 0}],17:[function(n,r,i){var a=n("./DataReader");function 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,A=b._outputType,T=b._mimeType;b.on("data",function(k,E){S.push(k),y&&y(E)}).on("error",function(k){S=[],v(k)}).on("end",function(){try{var k=(function(E,O,C){switch(E){case"blob":return a.newBlob(a.transformTo("arraybuffer",O),C);case"base64":return c.encode(O);default:return a.transformTo(E,O)}})(A,(function(E,O){var C,D=0,U=null,L=0;for(C=0;C<O.length;C++)L+=O[C].length;switch(E){case"string":return O.join("");case"array":return Array.prototype.concat.apply([],O);case"uint8array":for(U=new Uint8Array(L),C=0;C<O.length;C++)U.set(O[C],D),D+=O[C].length;return U;case"nodebuffer":return Buffer.concat(O);default:throw new Error("concat : unsupported type '"+E+"'")}})(M,S),T);x(k)}catch(E){v(E)}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,A=b.length,T=0;for(S=0;S<A;S++)(64512&(x=b.charCodeAt(S)))==55296&&S+1<A&&(64512&(v=b.charCodeAt(S+1)))==56320&&(x=65536+(x-55296<<10)+(v-56320),S++),T+=x<128?1:x<2048?2:x<65536?3:4;for(y=o.uint8array?new Uint8Array(T):new Array(T),S=M=0;M<T;S++)(64512&(x=b.charCodeAt(S)))==55296&&S+1<A&&(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,A=new Array(2*M);for(y=x=0;y<M;)if((v=b[y++])<128)A[x++]=v;else if(4<(S=u[v]))A[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?A[x++]=65533:v<65536?A[x++]=v:(v-=65536,A[x++]=55296|v>>10&1023,A[x++]=56320|1023&v)}return A.length!==x&&(A.subarray?A=A.subarray(0,x):A.length=x),a.applyFromCharCode(A)})(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 A;for((M=M||S.length)>S.length&&(M=S.length),A=M-1;0<=A&&(192&S[A])==128;)A--;return A<0||A===0?M:A+u[S[A]]>M?A: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,A=y.length;if(A<=v)return String.fromCharCode.apply(null,y);for(;M<A;)x==="array"||x==="nodebuffer"?S.push(String.fromCharCode.apply(null,y.slice(M,Math.min(M+v,A)))):S.push(String.fromCharCode.apply(null,y.subarray(M,Math.min(M+v,A)))),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(A){return a.blob&&(A instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(A))!==-1)&&typeof FileReader<"u"?new c.Promise(function(T,k){var E=new FileReader;E.onload=function(O){T(O.target.result)},E.onerror=function(O){k(O.target.error)},E.readAsArrayBuffer(A)}):A}).then(function(A){var T=i.getTypeOf(A);return T?(T==="arraybuffer"?A=i.transformTo("uint8array",A):T==="string"&&(M?A=o.decode(A):v&&S!==!0&&(A=(function(k){return d(k,a.uint8array?new Uint8Array(k.length):new Array(k.length))})(A))),A):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 p_<"u"?p_: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 A;try{A=S(M)}catch(T){return l.reject(v,T)}A===v?l.reject(v,new TypeError("Cannot resolve promise with itself")):l.resolve(v,A)})}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 A(E){M||(M=!0,l.reject(v,E))}function T(E){M||(M=!0,l.resolve(v,E))}var k=x(function(){S(T,A)});k.status==="error"&&A(k.value)}function x(v,S){var M={};try{M.value=v(S),M.status="success"}catch(A){M.status="error",M.value=A}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 A=M.value;if(A)y(v,A);else{v.state=u,v.outcome=S;for(var T=-1,k=v.queue.length;++T<k;)v.queue[T].callFulfilled(S)}return v},l.reject=function(v,S){v.state=c,v.outcome=S;for(var M=-1,A=v.queue.length;++M<A;)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,A=!1;if(!M)return this.resolve([]);for(var T=new Array(M),k=0,E=-1,O=new this(o);++E<M;)C(v[E],E);return O;function C(D,U){S.resolve(D).then(function(L){T[U]=L,++k!==M||A||(A=!0,l.resolve(O,T))},function(L){A||(A=!0,l.reject(O,L))})}},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,A=!1;if(!M)return this.resolve([]);for(var T=-1,k=new this(o);++T<M;)E=v[T],S.resolve(E).then(function(O){A||(A=!0,l.resolve(k,O))},function(O){A||(A=!0,l.reject(k,O))});var E;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 A;if(A=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,A))!==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,A,T=this.strm,k=this.options.chunkSize;if(this.ended)return!1;A=S===~~S?S:S===!0?4:0,typeof v=="string"?T.input=l.string2buf(v):d.call(v)==="[object ArrayBuffer]"?T.input=new Uint8Array(v):T.input=v,T.next_in=0,T.avail_in=T.input.length;do{if(T.avail_out===0&&(T.output=new o.Buf8(k),T.next_out=0,T.avail_out=k),(M=a.deflate(T,A))!==1&&M!==f)return this.onEnd(M),!(this.ended=!0);T.avail_out!==0&&(T.avail_in!==0||A!==4&&A!==2)||(this.options.to==="string"?this.onData(l.buf2binstring(o.shrinkBuf(T.output,T.next_out))):this.onData(o.shrinkBuf(T.output,T.next_out)))}while((0<T.avail_in||T.avail_out===0)&&M!==1);return A===4?(M=a.deflateEnd(this.strm),this.onEnd(M),this.ended=!0,M===f):A!==2||(this.onEnd(f),!(T.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,A,T,k,E=this.strm,O=this.options.chunkSize,C=this.options.dictionary,D=!1;if(this.ended)return!1;S=x===~~x?x:x===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof y=="string"?E.input=l.binstring2buf(y):m.call(y)==="[object ArrayBuffer]"?E.input=new Uint8Array(y):E.input=y,E.next_in=0,E.avail_in=E.input.length;do{if(E.avail_out===0&&(E.output=new o.Buf8(O),E.next_out=0,E.avail_out=O),(v=a.inflate(E,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&&D===!0&&(v=c.Z_OK,D=!1),v!==c.Z_STREAM_END&&v!==c.Z_OK)return this.onEnd(v),!(this.ended=!0);E.next_out&&(E.avail_out!==0&&v!==c.Z_STREAM_END&&(E.avail_in!==0||S!==c.Z_FINISH&&S!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(M=l.utf8border(E.output,E.next_out),A=E.next_out-M,T=l.buf2string(E.output,M),E.next_out=A,E.avail_out=O-A,A&&o.arraySet(E.output,E.output,M,A,0),this.onData(T)):this.onData(o.shrinkBuf(E.output,E.next_out)))),E.avail_in===0&&E.avail_out===0&&(D=!0)}while((0<E.avail_in||E.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),!(E.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,A=286,T=30,k=19,E=2*A+1,O=15,C=3,D=258,U=D+C+1,L=42,q=113,P=1,W=2,K=3,V=4;function Q(H,ee){return H.msg=d[ee],ee}function re(H){return(H<<1)-(4<H?9:0)}function J(H){for(var ee=H.length;0<=--ee;)H[ee]=0}function z(H){var ee=H.state,X=ee.pending;X>H.avail_out&&(X=H.avail_out),X!==0&&(o.arraySet(H.output,ee.pending_buf,ee.pending_out,X,H.next_out),H.next_out+=X,ee.pending_out+=X,H.total_out+=X,H.avail_out-=X,ee.pending-=X,ee.pending===0&&(ee.pending_out=0))}function G(H,ee){l._tr_flush_block(H,0<=H.block_start?H.block_start:-1,H.strstart-H.block_start,ee),H.block_start=H.strstart,z(H.strm)}function ne(H,ee){H.pending_buf[H.pending++]=ee}function ae(H,ee){H.pending_buf[H.pending++]=ee>>>8&255,H.pending_buf[H.pending++]=255&ee}function de(H,ee){var X,B,I=H.max_chain_length,ce=H.strstart,Te=H.prev_length,Le=H.nice_match,Ee=H.strstart>H.w_size-U?H.strstart-(H.w_size-U):0,$=H.window,j=H.w_mask,Y=H.prev,ge=H.strstart+D,we=$[ce+Te-1],ve=$[ce+Te];H.prev_length>=H.good_match&&(I>>=2),Le>H.lookahead&&(Le=H.lookahead);do if($[(X=ee)+Te]===ve&&$[X+Te-1]===we&&$[X]===$[ce]&&$[++X]===$[ce+1]){ce+=2,X++;do;while($[++ce]===$[++X]&&$[++ce]===$[++X]&&$[++ce]===$[++X]&&$[++ce]===$[++X]&&$[++ce]===$[++X]&&$[++ce]===$[++X]&&$[++ce]===$[++X]&&$[++ce]===$[++X]&&ce<ge);if(B=D-(ge-ce),ce=ge-D,Te<B){if(H.match_start=ee,Le<=(Te=B))break;we=$[ce+Te-1],ve=$[ce+Te]}}while((ee=Y[ee&j])>Ee&&--I!=0);return Te<=H.lookahead?Te:H.lookahead}function fe(H){var ee,X,B,I,ce,Te,Le,Ee,$,j,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,ee=X=H.hash_size;B=H.head[--ee],H.head[ee]=Y<=B?B-Y:0,--X;);for(ee=X=Y;B=H.prev[--ee],H.prev[ee]=Y<=B?B-Y:0,--X;);I+=Y}if(H.strm.avail_in===0)break;if(Te=H.strm,Le=H.window,Ee=H.strstart+H.lookahead,$=I,j=void 0,j=Te.avail_in,$<j&&(j=$),X=j===0?0:(Te.avail_in-=j,o.arraySet(Le,Te.input,Te.next_in,j,Ee),Te.state.wrap===1?Te.adler=c(Te.adler,Le,j,Ee):Te.state.wrap===2&&(Te.adler=u(Te.adler,Le,j,Ee)),Te.next_in+=j,Te.total_in+=j,j),H.lookahead+=X,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 ie(H,ee){for(var X,B;;){if(H.lookahead<U){if(fe(H),H.lookahead<U&&ee===f)return P;if(H.lookahead===0)break}if(X=0,H.lookahead>=C&&(H.ins_h=(H.ins_h<<H.hash_shift^H.window[H.strstart+C-1])&H.hash_mask,X=H.prev[H.strstart&H.w_mask]=H.head[H.ins_h],H.head[H.ins_h]=H.strstart),X!==0&&H.strstart-X<=H.w_size-U&&(H.match_length=de(H,X)),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,X=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&&(G(H,!1),H.strm.avail_out===0))return P}return H.insert=H.strstart<C-1?H.strstart:C-1,ee===m?(G(H,!0),H.strm.avail_out===0?K:V):H.last_lit&&(G(H,!1),H.strm.avail_out===0)?P:W}function Ae(H,ee){for(var X,B,I;;){if(H.lookahead<U){if(fe(H),H.lookahead<U&&ee===f)return P;if(H.lookahead===0)break}if(X=0,H.lookahead>=C&&(H.ins_h=(H.ins_h<<H.hash_shift^H.window[H.strstart+C-1])&H.hash_mask,X=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,X!==0&&H.prev_length<H.max_lazy_match&&H.strstart-X<=H.w_size-U&&(H.match_length=de(H,X),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,X=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&&(G(H,!1),H.strm.avail_out===0))return P}else if(H.match_available){if((B=l._tr_tally(H,0,H.window[H.strstart-1]))&&G(H,!1),H.strstart++,H.lookahead--,H.strm.avail_out===0)return P}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,ee===m?(G(H,!0),H.strm.avail_out===0?K:V):H.last_lit&&(G(H,!1),H.strm.avail_out===0)?P:W}function me(H,ee,X,B,I){this.good_length=H,this.max_lazy=ee,this.nice_length=X,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*E),this.dyn_dtree=new o.Buf16(2*(2*T+1)),this.bl_tree=new o.Buf16(2*(2*k+1)),J(this.dyn_ltree),J(this.dyn_dtree),J(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new o.Buf16(O+1),this.heap=new o.Buf16(2*A+1),J(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new o.Buf16(2*A+1),J(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 ye(H){var ee;return H&&H.state?(H.total_in=H.total_out=0,H.data_type=v,(ee=H.state).pending=0,ee.pending_out=0,ee.wrap<0&&(ee.wrap=-ee.wrap),ee.status=ee.wrap?L:q,H.adler=ee.wrap===2?0:1,ee.last_flush=f,l._tr_init(ee),p):Q(H,b)}function le(H){var ee=ye(H);return ee===p&&(function(X){X.window_size=2*X.w_size,J(X.head),X.max_lazy_match=a[X.level].max_lazy,X.good_match=a[X.level].good_length,X.nice_match=a[X.level].nice_length,X.max_chain_length=a[X.level].max_chain,X.strstart=0,X.block_start=0,X.lookahead=0,X.insert=0,X.match_length=X.prev_length=C-1,X.match_available=0,X.ins_h=0})(H.state),ee}function $e(H,ee,X,B,I,ce){if(!H)return b;var Te=1;if(ee===y&&(ee=6),B<0?(Te=0,B=-B):15<B&&(Te=2,B-=16),I<1||M<I||X!==S||B<8||15<B||ee<0||9<ee||ce<0||x<ce)return Q(H,b);B===8&&(B=9);var Le=new Ne;return(H.state=Le).strm=H,Le.wrap=Te,Le.gzhead=null,Le.w_bits=B,Le.w_size=1<<Le.w_bits,Le.w_mask=Le.w_size-1,Le.hash_bits=I+7,Le.hash_size=1<<Le.hash_bits,Le.hash_mask=Le.hash_size-1,Le.hash_shift=~~((Le.hash_bits+C-1)/C),Le.window=new o.Buf8(2*Le.w_size),Le.head=new o.Buf16(Le.hash_size),Le.prev=new o.Buf16(Le.w_size),Le.lit_bufsize=1<<I+6,Le.pending_buf_size=4*Le.lit_bufsize,Le.pending_buf=new o.Buf8(Le.pending_buf_size),Le.d_buf=1*Le.lit_bufsize,Le.l_buf=3*Le.lit_bufsize,Le.level=ee,Le.strategy=ce,Le.method=X,le(H)}a=[new me(0,0,0,0,function(H,ee){var X=65535;for(X>H.pending_buf_size-5&&(X=H.pending_buf_size-5);;){if(H.lookahead<=1){if(fe(H),H.lookahead===0&&ee===f)return P;if(H.lookahead===0)break}H.strstart+=H.lookahead,H.lookahead=0;var B=H.block_start+X;if((H.strstart===0||H.strstart>=B)&&(H.lookahead=H.strstart-B,H.strstart=B,G(H,!1),H.strm.avail_out===0)||H.strstart-H.block_start>=H.w_size-U&&(G(H,!1),H.strm.avail_out===0))return P}return H.insert=0,ee===m?(G(H,!0),H.strm.avail_out===0?K:V):(H.strstart>H.block_start&&(G(H,!1),H.strm.avail_out),P)}),new me(4,4,8,4,ie),new me(4,5,16,8,ie),new me(4,6,32,32,ie),new me(4,4,16,16,Ae),new me(8,16,32,32,Ae),new me(8,16,128,128,Ae),new me(8,32,128,256,Ae),new me(32,128,258,1024,Ae),new me(32,258,258,4096,Ae)],i.deflateInit=function(H,ee){return $e(H,ee,S,15,8,0)},i.deflateInit2=$e,i.deflateReset=le,i.deflateResetKeep=ye,i.deflateSetHeader=function(H,ee){return H&&H.state?H.state.wrap!==2?b:(H.state.gzhead=ee,p):b},i.deflate=function(H,ee){var X,B,I,ce;if(!H||!H.state||5<ee||ee<0)return H?Q(H,b):b;if(B=H.state,!H.output||!H.input&&H.avail_in!==0||B.status===666&&ee!==m)return Q(H,H.avail_out===0?-5:b);if(B.strm=H,X=B.last_flush,B.last_flush=ee,B.status===L)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 Te=S+(B.w_bits-8<<4)<<8;Te|=(2<=B.strategy||B.level<2?0:B.level<6?1:B.level===6?2:3)<<6,B.strstart!==0&&(Te|=32),Te+=31-Te%31,B.status=q,ae(B,Te),B.strstart!==0&&(ae(B,H.adler>>>16),ae(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&&re(ee)<=re(X)&&ee!==m)return Q(H,-5);if(B.status===666&&H.avail_in!==0)return Q(H,-5);if(H.avail_in!==0||B.lookahead!==0||ee!==f&&B.status!==666){var Le=B.strategy===2?(function(Ee,$){for(var j;;){if(Ee.lookahead===0&&(fe(Ee),Ee.lookahead===0)){if($===f)return P;break}if(Ee.match_length=0,j=l._tr_tally(Ee,0,Ee.window[Ee.strstart]),Ee.lookahead--,Ee.strstart++,j&&(G(Ee,!1),Ee.strm.avail_out===0))return P}return Ee.insert=0,$===m?(G(Ee,!0),Ee.strm.avail_out===0?K:V):Ee.last_lit&&(G(Ee,!1),Ee.strm.avail_out===0)?P:W})(B,ee):B.strategy===3?(function(Ee,$){for(var j,Y,ge,we,ve=Ee.window;;){if(Ee.lookahead<=D){if(fe(Ee),Ee.lookahead<=D&&$===f)return P;if(Ee.lookahead===0)break}if(Ee.match_length=0,Ee.lookahead>=C&&0<Ee.strstart&&(Y=ve[ge=Ee.strstart-1])===ve[++ge]&&Y===ve[++ge]&&Y===ve[++ge]){we=Ee.strstart+D;do;while(Y===ve[++ge]&&Y===ve[++ge]&&Y===ve[++ge]&&Y===ve[++ge]&&Y===ve[++ge]&&Y===ve[++ge]&&Y===ve[++ge]&&Y===ve[++ge]&&ge<we);Ee.match_length=D-(we-ge),Ee.match_length>Ee.lookahead&&(Ee.match_length=Ee.lookahead)}if(Ee.match_length>=C?(j=l._tr_tally(Ee,1,Ee.match_length-C),Ee.lookahead-=Ee.match_length,Ee.strstart+=Ee.match_length,Ee.match_length=0):(j=l._tr_tally(Ee,0,Ee.window[Ee.strstart]),Ee.lookahead--,Ee.strstart++),j&&(G(Ee,!1),Ee.strm.avail_out===0))return P}return Ee.insert=0,$===m?(G(Ee,!0),Ee.strm.avail_out===0?K:V):Ee.last_lit&&(G(Ee,!1),Ee.strm.avail_out===0)?P:W})(B,ee):a[B.level].func(B,ee);if(Le!==K&&Le!==V||(B.status=666),Le===P||Le===K)return H.avail_out===0&&(B.last_flush=-1),p;if(Le===W&&(ee===1?l._tr_align(B):ee!==5&&(l._tr_stored_block(B,0,0,!1),ee===3&&(J(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 ee!==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)):(ae(B,H.adler>>>16),ae(B,65535&H.adler)),z(H),0<B.wrap&&(B.wrap=-B.wrap),B.pending!==0?p:1)},i.deflateEnd=function(H){var ee;return H&&H.state?(ee=H.state.status)!==L&&ee!==69&&ee!==73&&ee!==91&&ee!==103&&ee!==q&&ee!==666?Q(H,b):(H.state=null,ee===q?Q(H,-3):p):b},i.deflateSetDictionary=function(H,ee){var X,B,I,ce,Te,Le,Ee,$,j=ee.length;if(!H||!H.state||(ce=(X=H.state).wrap)===2||ce===1&&X.status!==L||X.lookahead)return b;for(ce===1&&(H.adler=c(H.adler,ee,j,0)),X.wrap=0,j>=X.w_size&&(ce===0&&(J(X.head),X.strstart=0,X.block_start=0,X.insert=0),$=new o.Buf8(X.w_size),o.arraySet($,ee,j-X.w_size,X.w_size,0),ee=$,j=X.w_size),Te=H.avail_in,Le=H.next_in,Ee=H.input,H.avail_in=j,H.next_in=0,H.input=ee,fe(X);X.lookahead>=C;){for(B=X.strstart,I=X.lookahead-(C-1);X.ins_h=(X.ins_h<<X.hash_shift^X.window[B+C-1])&X.hash_mask,X.prev[B&X.w_mask]=X.head[X.ins_h],X.head[X.ins_h]=B,B++,--I;);X.strstart=B,X.lookahead=C-1,fe(X)}return X.strstart+=X.lookahead,X.block_start=X.strstart,X.insert=X.lookahead,X.lookahead=0,X.match_length=X.prev_length=C-1,X.match_available=0,H.next_in=Le,H.input=Ee,H.avail_in=Te,X.wrap=ce,p},i.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(n,r,i){r.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(n,r,i){r.exports=function(a,o){var l,c,u,d,f,m,p,b,y,x,v,S,M,A,T,k,E,O,C,D,U,L,q,P,W;l=a.state,c=a.next_in,P=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,A=l.lencode,T=l.distcode,k=(1<<l.lenbits)-1,E=(1<<l.distbits)-1;e:do{M<15&&(S+=P[c++]<<M,M+=8,S+=P[c++]<<M,M+=8),O=A[S&k];t:for(;;){if(S>>>=C=O>>>24,M-=C,(C=O>>>16&255)===0)W[d++]=65535&O;else{if(!(16&C)){if((64&C)==0){O=A[(65535&O)+(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}D=65535&O,(C&=15)&&(M<C&&(S+=P[c++]<<M,M+=8),D+=S&(1<<C)-1,S>>>=C,M-=C),M<15&&(S+=P[c++]<<M,M+=8,S+=P[c++]<<M,M+=8),O=T[S&E];n:for(;;){if(S>>>=C=O>>>24,M-=C,!(16&(C=O>>>16&255))){if((64&C)==0){O=T[(65535&O)+(S&(1<<C)-1)];continue n}a.msg="invalid distance code",l.mode=30;break e}if(U=65535&O,M<(C&=15)&&(S+=P[c++]<<M,(M+=8)<C&&(S+=P[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,(L=0)===x){if(L+=b-C,C<D){for(D-=C;W[d++]=v[L++],--C;);L=d-U,q=W}}else if(x<C){if(L+=b+x-C,(C-=x)<D){for(D-=C;W[d++]=v[L++],--C;);if(L=0,x<D){for(D-=C=x;W[d++]=v[L++],--C;);L=d-U,q=W}}}else if(L+=x-C,C<D){for(D-=C;W[d++]=v[L++],--C;);L=d-U,q=W}for(;2<D;)W[d++]=q[L++],W[d++]=q[L++],W[d++]=q[L++],D-=3;D&&(W[d++]=q[L++],1<D&&(W[d++]=q[L++]))}else{for(L=d-U;W[d++]=W[L++],W[d++]=W[L++],W[d++]=W[L++],2<(D-=3););D&&(W[d++]=W[L++],1<D&&(W[d++]=W[L++]))}break}}break}}while(c<u&&d<m);c-=D=M>>3,S&=(1<<(M-=D<<3))-1,a.next_in=c,a.next_out=d,a.avail_in=c<u?u-c+5:5-(c-u),a.avail_out=d<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(L){return(L>>>24&255)+(L>>>8&65280)+((65280&L)<<8)+((255&L)<<24)}function S(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new a.Buf16(320),this.work=new a.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function M(L){var q;return L&&L.state?(q=L.state,L.total_in=L.total_out=q.total=0,L.msg="",q.wrap&&(L.adler=1&q.wrap),q.mode=b,q.last=0,q.havedict=0,q.dmax=32768,q.head=null,q.hold=0,q.bits=0,q.lencode=q.lendyn=new a.Buf32(y),q.distcode=q.distdyn=new a.Buf32(x),q.sane=1,q.back=-1,m):p}function A(L){var q;return L&&L.state?((q=L.state).wsize=0,q.whave=0,q.wnext=0,M(L)):p}function T(L,q){var P,W;return L&&L.state?(W=L.state,q<0?(P=0,q=-q):(P=1+(q>>4),q<48&&(q&=15)),q&&(q<8||15<q)?p:(W.window!==null&&W.wbits!==q&&(W.window=null),W.wrap=P,W.wbits=q,A(L))):p}function k(L,q){var P,W;return L?(W=new S,(L.state=W).window=null,(P=T(L,q))!==m&&(L.state=null),P):p}var E,O,C=!0;function D(L){if(C){var q;for(E=new a.Buf32(512),O=new a.Buf32(32),q=0;q<144;)L.lens[q++]=8;for(;q<256;)L.lens[q++]=9;for(;q<280;)L.lens[q++]=7;for(;q<288;)L.lens[q++]=8;for(u(d,L.lens,0,288,E,0,L.work,{bits:9}),q=0;q<32;)L.lens[q++]=5;u(f,L.lens,0,32,O,0,L.work,{bits:5}),C=!1}L.lencode=E,L.lenbits=9,L.distcode=O,L.distbits=5}function U(L,q,P,W){var K,V=L.state;return V.window===null&&(V.wsize=1<<V.wbits,V.wnext=0,V.whave=0,V.window=new a.Buf8(V.wsize)),W>=V.wsize?(a.arraySet(V.window,q,P-V.wsize,V.wsize,0),V.wnext=0,V.whave=V.wsize):(W<(K=V.wsize-V.wnext)&&(K=W),a.arraySet(V.window,q,P-W,K,V.wnext),(W-=K)?(a.arraySet(V.window,q,P-W,W,0),V.wnext=W,V.whave=V.wsize):(V.wnext+=K,V.wnext===V.wsize&&(V.wnext=0),V.whave<V.wsize&&(V.whave+=K))),0}i.inflateReset=A,i.inflateReset2=T,i.inflateResetKeep=M,i.inflateInit=function(L){return k(L,15)},i.inflateInit2=k,i.inflate=function(L,q){var P,W,K,V,Q,re,J,z,G,ne,ae,de,fe,ie,Ae,me,Ne,ye,le,$e,H,ee,X,B,I=0,ce=new a.Buf8(4),Te=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!L||!L.state||!L.output||!L.input&&L.avail_in!==0)return p;(P=L.state).mode===12&&(P.mode=13),Q=L.next_out,K=L.output,J=L.avail_out,V=L.next_in,W=L.input,re=L.avail_in,z=P.hold,G=P.bits,ne=re,ae=J,ee=m;e:for(;;)switch(P.mode){case b:if(P.wrap===0){P.mode=13;break}for(;G<16;){if(re===0)break e;re--,z+=W[V++]<<G,G+=8}if(2&P.wrap&&z===35615){ce[P.check=0]=255&z,ce[1]=z>>>8&255,P.check=l(P.check,ce,2,0),G=z=0,P.mode=2;break}if(P.flags=0,P.head&&(P.head.done=!1),!(1&P.wrap)||(((255&z)<<8)+(z>>8))%31){L.msg="incorrect header check",P.mode=30;break}if((15&z)!=8){L.msg="unknown compression method",P.mode=30;break}if(G-=4,H=8+(15&(z>>>=4)),P.wbits===0)P.wbits=H;else if(H>P.wbits){L.msg="invalid window size",P.mode=30;break}P.dmax=1<<H,L.adler=P.check=1,P.mode=512&z?10:12,G=z=0;break;case 2:for(;G<16;){if(re===0)break e;re--,z+=W[V++]<<G,G+=8}if(P.flags=z,(255&P.flags)!=8){L.msg="unknown compression method",P.mode=30;break}if(57344&P.flags){L.msg="unknown header flags set",P.mode=30;break}P.head&&(P.head.text=z>>8&1),512&P.flags&&(ce[0]=255&z,ce[1]=z>>>8&255,P.check=l(P.check,ce,2,0)),G=z=0,P.mode=3;case 3:for(;G<32;){if(re===0)break e;re--,z+=W[V++]<<G,G+=8}P.head&&(P.head.time=z),512&P.flags&&(ce[0]=255&z,ce[1]=z>>>8&255,ce[2]=z>>>16&255,ce[3]=z>>>24&255,P.check=l(P.check,ce,4,0)),G=z=0,P.mode=4;case 4:for(;G<16;){if(re===0)break e;re--,z+=W[V++]<<G,G+=8}P.head&&(P.head.xflags=255&z,P.head.os=z>>8),512&P.flags&&(ce[0]=255&z,ce[1]=z>>>8&255,P.check=l(P.check,ce,2,0)),G=z=0,P.mode=5;case 5:if(1024&P.flags){for(;G<16;){if(re===0)break e;re--,z+=W[V++]<<G,G+=8}P.length=z,P.head&&(P.head.extra_len=z),512&P.flags&&(ce[0]=255&z,ce[1]=z>>>8&255,P.check=l(P.check,ce,2,0)),G=z=0}else P.head&&(P.head.extra=null);P.mode=6;case 6:if(1024&P.flags&&(re<(de=P.length)&&(de=re),de&&(P.head&&(H=P.head.extra_len-P.length,P.head.extra||(P.head.extra=new Array(P.head.extra_len)),a.arraySet(P.head.extra,W,V,de,H)),512&P.flags&&(P.check=l(P.check,W,de,V)),re-=de,V+=de,P.length-=de),P.length))break e;P.length=0,P.mode=7;case 7:if(2048&P.flags){if(re===0)break e;for(de=0;H=W[V+de++],P.head&&H&&P.length<65536&&(P.head.name+=String.fromCharCode(H)),H&&de<re;);if(512&P.flags&&(P.check=l(P.check,W,de,V)),re-=de,V+=de,H)break e}else P.head&&(P.head.name=null);P.length=0,P.mode=8;case 8:if(4096&P.flags){if(re===0)break e;for(de=0;H=W[V+de++],P.head&&H&&P.length<65536&&(P.head.comment+=String.fromCharCode(H)),H&&de<re;);if(512&P.flags&&(P.check=l(P.check,W,de,V)),re-=de,V+=de,H)break e}else P.head&&(P.head.comment=null);P.mode=9;case 9:if(512&P.flags){for(;G<16;){if(re===0)break e;re--,z+=W[V++]<<G,G+=8}if(z!==(65535&P.check)){L.msg="header crc mismatch",P.mode=30;break}G=z=0}P.head&&(P.head.hcrc=P.flags>>9&1,P.head.done=!0),L.adler=P.check=0,P.mode=12;break;case 10:for(;G<32;){if(re===0)break e;re--,z+=W[V++]<<G,G+=8}L.adler=P.check=v(z),G=z=0,P.mode=11;case 11:if(P.havedict===0)return L.next_out=Q,L.avail_out=J,L.next_in=V,L.avail_in=re,P.hold=z,P.bits=G,2;L.adler=P.check=1,P.mode=12;case 12:if(q===5||q===6)break e;case 13:if(P.last){z>>>=7&G,G-=7&G,P.mode=27;break}for(;G<3;){if(re===0)break e;re--,z+=W[V++]<<G,G+=8}switch(P.last=1&z,G-=1,3&(z>>>=1)){case 0:P.mode=14;break;case 1:if(D(P),P.mode=20,q!==6)break;z>>>=2,G-=2;break e;case 2:P.mode=17;break;case 3:L.msg="invalid block type",P.mode=30}z>>>=2,G-=2;break;case 14:for(z>>>=7&G,G-=7&G;G<32;){if(re===0)break e;re--,z+=W[V++]<<G,G+=8}if((65535&z)!=(z>>>16^65535)){L.msg="invalid stored block lengths",P.mode=30;break}if(P.length=65535&z,G=z=0,P.mode=15,q===6)break e;case 15:P.mode=16;case 16:if(de=P.length){if(re<de&&(de=re),J<de&&(de=J),de===0)break e;a.arraySet(K,W,V,de,Q),re-=de,V+=de,J-=de,Q+=de,P.length-=de;break}P.mode=12;break;case 17:for(;G<14;){if(re===0)break e;re--,z+=W[V++]<<G,G+=8}if(P.nlen=257+(31&z),z>>>=5,G-=5,P.ndist=1+(31&z),z>>>=5,G-=5,P.ncode=4+(15&z),z>>>=4,G-=4,286<P.nlen||30<P.ndist){L.msg="too many length or distance symbols",P.mode=30;break}P.have=0,P.mode=18;case 18:for(;P.have<P.ncode;){for(;G<3;){if(re===0)break e;re--,z+=W[V++]<<G,G+=8}P.lens[Te[P.have++]]=7&z,z>>>=3,G-=3}for(;P.have<19;)P.lens[Te[P.have++]]=0;if(P.lencode=P.lendyn,P.lenbits=7,X={bits:P.lenbits},ee=u(0,P.lens,0,19,P.lencode,0,P.work,X),P.lenbits=X.bits,ee){L.msg="invalid code lengths set",P.mode=30;break}P.have=0,P.mode=19;case 19:for(;P.have<P.nlen+P.ndist;){for(;me=(I=P.lencode[z&(1<<P.lenbits)-1])>>>16&255,Ne=65535&I,!((Ae=I>>>24)<=G);){if(re===0)break e;re--,z+=W[V++]<<G,G+=8}if(Ne<16)z>>>=Ae,G-=Ae,P.lens[P.have++]=Ne;else{if(Ne===16){for(B=Ae+2;G<B;){if(re===0)break e;re--,z+=W[V++]<<G,G+=8}if(z>>>=Ae,G-=Ae,P.have===0){L.msg="invalid bit length repeat",P.mode=30;break}H=P.lens[P.have-1],de=3+(3&z),z>>>=2,G-=2}else if(Ne===17){for(B=Ae+3;G<B;){if(re===0)break e;re--,z+=W[V++]<<G,G+=8}G-=Ae,H=0,de=3+(7&(z>>>=Ae)),z>>>=3,G-=3}else{for(B=Ae+7;G<B;){if(re===0)break e;re--,z+=W[V++]<<G,G+=8}G-=Ae,H=0,de=11+(127&(z>>>=Ae)),z>>>=7,G-=7}if(P.have+de>P.nlen+P.ndist){L.msg="invalid bit length repeat",P.mode=30;break}for(;de--;)P.lens[P.have++]=H}}if(P.mode===30)break;if(P.lens[256]===0){L.msg="invalid code -- missing end-of-block",P.mode=30;break}if(P.lenbits=9,X={bits:P.lenbits},ee=u(d,P.lens,0,P.nlen,P.lencode,0,P.work,X),P.lenbits=X.bits,ee){L.msg="invalid literal/lengths set",P.mode=30;break}if(P.distbits=6,P.distcode=P.distdyn,X={bits:P.distbits},ee=u(f,P.lens,P.nlen,P.ndist,P.distcode,0,P.work,X),P.distbits=X.bits,ee){L.msg="invalid distances set",P.mode=30;break}if(P.mode=20,q===6)break e;case 20:P.mode=21;case 21:if(6<=re&&258<=J){L.next_out=Q,L.avail_out=J,L.next_in=V,L.avail_in=re,P.hold=z,P.bits=G,c(L,ae),Q=L.next_out,K=L.output,J=L.avail_out,V=L.next_in,W=L.input,re=L.avail_in,z=P.hold,G=P.bits,P.mode===12&&(P.back=-1);break}for(P.back=0;me=(I=P.lencode[z&(1<<P.lenbits)-1])>>>16&255,Ne=65535&I,!((Ae=I>>>24)<=G);){if(re===0)break e;re--,z+=W[V++]<<G,G+=8}if(me&&(240&me)==0){for(ye=Ae,le=me,$e=Ne;me=(I=P.lencode[$e+((z&(1<<ye+le)-1)>>ye)])>>>16&255,Ne=65535&I,!(ye+(Ae=I>>>24)<=G);){if(re===0)break e;re--,z+=W[V++]<<G,G+=8}z>>>=ye,G-=ye,P.back+=ye}if(z>>>=Ae,G-=Ae,P.back+=Ae,P.length=Ne,me===0){P.mode=26;break}if(32&me){P.back=-1,P.mode=12;break}if(64&me){L.msg="invalid literal/length code",P.mode=30;break}P.extra=15&me,P.mode=22;case 22:if(P.extra){for(B=P.extra;G<B;){if(re===0)break e;re--,z+=W[V++]<<G,G+=8}P.length+=z&(1<<P.extra)-1,z>>>=P.extra,G-=P.extra,P.back+=P.extra}P.was=P.length,P.mode=23;case 23:for(;me=(I=P.distcode[z&(1<<P.distbits)-1])>>>16&255,Ne=65535&I,!((Ae=I>>>24)<=G);){if(re===0)break e;re--,z+=W[V++]<<G,G+=8}if((240&me)==0){for(ye=Ae,le=me,$e=Ne;me=(I=P.distcode[$e+((z&(1<<ye+le)-1)>>ye)])>>>16&255,Ne=65535&I,!(ye+(Ae=I>>>24)<=G);){if(re===0)break e;re--,z+=W[V++]<<G,G+=8}z>>>=ye,G-=ye,P.back+=ye}if(z>>>=Ae,G-=Ae,P.back+=Ae,64&me){L.msg="invalid distance code",P.mode=30;break}P.offset=Ne,P.extra=15&me,P.mode=24;case 24:if(P.extra){for(B=P.extra;G<B;){if(re===0)break e;re--,z+=W[V++]<<G,G+=8}P.offset+=z&(1<<P.extra)-1,z>>>=P.extra,G-=P.extra,P.back+=P.extra}if(P.offset>P.dmax){L.msg="invalid distance too far back",P.mode=30;break}P.mode=25;case 25:if(J===0)break e;if(de=ae-J,P.offset>de){if((de=P.offset-de)>P.whave&&P.sane){L.msg="invalid distance too far back",P.mode=30;break}fe=de>P.wnext?(de-=P.wnext,P.wsize-de):P.wnext-de,de>P.length&&(de=P.length),ie=P.window}else ie=K,fe=Q-P.offset,de=P.length;for(J<de&&(de=J),J-=de,P.length-=de;K[Q++]=ie[fe++],--de;);P.length===0&&(P.mode=21);break;case 26:if(J===0)break e;K[Q++]=P.length,J--,P.mode=21;break;case 27:if(P.wrap){for(;G<32;){if(re===0)break e;re--,z|=W[V++]<<G,G+=8}if(ae-=J,L.total_out+=ae,P.total+=ae,ae&&(L.adler=P.check=P.flags?l(P.check,K,ae,Q-ae):o(P.check,K,ae,Q-ae)),ae=J,(P.flags?z:v(z))!==P.check){L.msg="incorrect data check",P.mode=30;break}G=z=0}P.mode=28;case 28:if(P.wrap&&P.flags){for(;G<32;){if(re===0)break e;re--,z+=W[V++]<<G,G+=8}if(z!==(4294967295&P.total)){L.msg="incorrect length check",P.mode=30;break}G=z=0}P.mode=29;case 29:ee=1;break e;case 30:ee=-3;break e;case 31:return-4;default:return p}return L.next_out=Q,L.avail_out=J,L.next_in=V,L.avail_in=re,P.hold=z,P.bits=G,(P.wsize||ae!==L.avail_out&&P.mode<30&&(P.mode<27||q!==4))&&U(L,L.output,L.next_out,ae-L.avail_out)?(P.mode=31,-4):(ne-=L.avail_in,ae-=L.avail_out,L.total_in+=ne,L.total_out+=ae,P.total+=ae,P.wrap&&ae&&(L.adler=P.check=P.flags?l(P.check,K,ae,L.next_out-ae):o(P.check,K,ae,L.next_out-ae)),L.data_type=P.bits+(P.last?64:0)+(P.mode===12?128:0)+(P.mode===20||P.mode===15?256:0),(ne==0&&ae===0||q===4)&&ee===m&&(ee=-5),ee)},i.inflateEnd=function(L){if(!L||!L.state)return p;var q=L.state;return q.window&&(q.window=null),L.state=null,m},i.inflateGetHeader=function(L,q){var P;return L&&L.state?(2&(P=L.state).wrap)==0?p:((P.head=q).done=!1,m):p},i.inflateSetDictionary=function(L,q){var P,W=q.length;return L&&L.state?(P=L.state).wrap!==0&&P.mode!==11?p:P.mode===11&&o(1,q,W,0)!==P.check?-3:U(L,q,W,W)?(P.mode=31,-4):(P.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,A,T,k,E,O,C,D,U=v.bits,L=0,q=0,P=0,W=0,K=0,V=0,Q=0,re=0,J=0,z=0,G=null,ne=0,ae=new a.Buf16(16),de=new a.Buf16(16),fe=null,ie=0;for(L=0;L<=15;L++)ae[L]=0;for(q=0;q<p;q++)ae[f[m+q]]++;for(K=U,W=15;1<=W&&ae[W]===0;W--);if(W<K&&(K=W),W===0)return b[y++]=20971520,b[y++]=20971520,v.bits=1,0;for(P=1;P<W&&ae[P]===0;P++);for(K<P&&(K=P),L=re=1;L<=15;L++)if(re<<=1,(re-=ae[L])<0)return-1;if(0<re&&(d===0||W!==1))return-1;for(de[1]=0,L=1;L<15;L++)de[L+1]=de[L]+ae[L];for(q=0;q<p;q++)f[m+q]!==0&&(x[de[f[m+q]]++]=q);if(E=d===0?(G=fe=x,19):d===1?(G=o,ne-=257,fe=l,ie-=257,256):(G=c,fe=u,-1),L=P,k=y,Q=q=z=0,A=-1,T=(J=1<<(V=K))-1,d===1&&852<J||d===2&&592<J)return 1;for(;;){for(O=L-Q,D=x[q]<E?(C=0,x[q]):x[q]>E?(C=fe[ie+x[q]],G[ne+x[q]]):(C=96,0),S=1<<L-Q,P=M=1<<V;b[k+(z>>Q)+(M-=S)]=O<<24|C<<16|D|0,M!==0;);for(S=1<<L-1;z&S;)S>>=1;if(S!==0?(z&=S-1,z+=S):z=0,q++,--ae[L]==0){if(L===W)break;L=f[m+x[q]]}if(K<L&&(z&T)!==A){for(Q===0&&(Q=K),k+=P,re=1<<(V=L-Q);V+Q<W&&!((re-=ae[V+Q])<=0);)V++,re<<=1;if(J+=1<<V,d===1&&852<J||d===2&&592<J)return 1;b[A=z&T]=K<<24|V<<16|k-y|0}}return z!==0&&(b[k+z]=L-Q<<24|64<<16|0),v.bits=K,0}},{"../utils/common":41}],51:[function(n,r,i){r.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(n,r,i){var a=n("../utils/common"),o=0,l=1;function c(I){for(var ce=I.length;0<=--ce;)I[ce]=0}var u=0,d=29,f=256,m=f+1+d,p=30,b=19,y=2*m+1,x=15,v=16,S=7,M=256,A=16,T=17,k=18,E=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],O=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],C=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],D=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],U=new Array(2*(m+2));c(U);var L=new Array(2*p);c(L);var q=new Array(512);c(q);var P=new Array(256);c(P);var W=new Array(d);c(W);var K,V,Q,re=new Array(p);function J(I,ce,Te,Le,Ee){this.static_tree=I,this.extra_bits=ce,this.extra_base=Te,this.elems=Le,this.max_length=Ee,this.has_stree=I&&I.length}function z(I,ce){this.dyn_tree=I,this.max_code=0,this.stat_desc=ce}function G(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 ae(I,ce,Te){I.bi_valid>v-Te?(I.bi_buf|=ce<<I.bi_valid&65535,ne(I,I.bi_buf),I.bi_buf=ce>>v-I.bi_valid,I.bi_valid+=Te-v):(I.bi_buf|=ce<<I.bi_valid&65535,I.bi_valid+=Te)}function de(I,ce,Te){ae(I,Te[2*ce],Te[2*ce+1])}function fe(I,ce){for(var Te=0;Te|=1&I,I>>>=1,Te<<=1,0<--ce;);return Te>>>1}function ie(I,ce,Te){var Le,Ee,$=new Array(x+1),j=0;for(Le=1;Le<=x;Le++)$[Le]=j=j+Te[Le-1]<<1;for(Ee=0;Ee<=ce;Ee++){var Y=I[2*Ee+1];Y!==0&&(I[2*Ee]=fe($[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 me(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,Te,Le){var Ee=2*ce,$=2*Te;return I[Ee]<I[$]||I[Ee]===I[$]&&Le[ce]<=Le[Te]}function ye(I,ce,Te){for(var Le=I.heap[Te],Ee=Te<<1;Ee<=I.heap_len&&(Ee<I.heap_len&&Ne(ce,I.heap[Ee+1],I.heap[Ee],I.depth)&&Ee++,!Ne(ce,Le,I.heap[Ee],I.depth));)I.heap[Te]=I.heap[Ee],Te=Ee,Ee<<=1;I.heap[Te]=Le}function le(I,ce,Te){var Le,Ee,$,j,Y=0;if(I.last_lit!==0)for(;Le=I.pending_buf[I.d_buf+2*Y]<<8|I.pending_buf[I.d_buf+2*Y+1],Ee=I.pending_buf[I.l_buf+Y],Y++,Le===0?de(I,Ee,ce):(de(I,($=P[Ee])+f+1,ce),(j=E[$])!==0&&ae(I,Ee-=W[$],j),de(I,$=G(--Le),Te),(j=O[$])!==0&&ae(I,Le-=re[$],j)),Y<I.last_lit;);de(I,M,ce)}function $e(I,ce){var Te,Le,Ee,$=ce.dyn_tree,j=ce.stat_desc.static_tree,Y=ce.stat_desc.has_stree,ge=ce.stat_desc.elems,we=-1;for(I.heap_len=0,I.heap_max=y,Te=0;Te<ge;Te++)$[2*Te]!==0?(I.heap[++I.heap_len]=we=Te,I.depth[Te]=0):$[2*Te+1]=0;for(;I.heap_len<2;)$[2*(Ee=I.heap[++I.heap_len]=we<2?++we:0)]=1,I.depth[Ee]=0,I.opt_len--,Y&&(I.static_len-=j[2*Ee+1]);for(ce.max_code=we,Te=I.heap_len>>1;1<=Te;Te--)ye(I,$,Te);for(Ee=ge;Te=I.heap[1],I.heap[1]=I.heap[I.heap_len--],ye(I,$,1),Le=I.heap[1],I.heap[--I.heap_max]=Te,I.heap[--I.heap_max]=Le,$[2*Ee]=$[2*Te]+$[2*Le],I.depth[Ee]=(I.depth[Te]>=I.depth[Le]?I.depth[Te]:I.depth[Le])+1,$[2*Te+1]=$[2*Le+1]=Ee,I.heap[1]=Ee++,ye(I,$,1),2<=I.heap_len;);I.heap[--I.heap_max]=I.heap[1],(function(ve,Ze){var Ie,qe,Je,Qe,oe,te,Me=Ze.dyn_tree,Fe=Ze.max_code,ot=Ze.stat_desc.static_tree,se=Ze.stat_desc.has_stree,je=Ze.stat_desc.extra_bits,xe=Ze.stat_desc.extra_base,Oe=Ze.stat_desc.max_length,Ue=0;for(Qe=0;Qe<=x;Qe++)ve.bl_count[Qe]=0;for(Me[2*ve.heap[ve.heap_max]+1]=0,Ie=ve.heap_max+1;Ie<y;Ie++)Oe<(Qe=Me[2*Me[2*(qe=ve.heap[Ie])+1]+1]+1)&&(Qe=Oe,Ue++),Me[2*qe+1]=Qe,Fe<qe||(ve.bl_count[Qe]++,oe=0,xe<=qe&&(oe=je[qe-xe]),te=Me[2*qe],ve.opt_len+=te*(Qe+oe),se&&(ve.static_len+=te*(ot[2*qe+1]+oe)));if(Ue!==0){do{for(Qe=Oe-1;ve.bl_count[Qe]===0;)Qe--;ve.bl_count[Qe]--,ve.bl_count[Qe+1]+=2,ve.bl_count[Oe]--,Ue-=2}while(0<Ue);for(Qe=Oe;Qe!==0;Qe--)for(qe=ve.bl_count[Qe];qe!==0;)Fe<(Je=ve.heap[--Ie])||(Me[2*Je+1]!==Qe&&(ve.opt_len+=(Qe-Me[2*Je+1])*Me[2*Je],Me[2*Je+1]=Qe),qe--)}})(I,ce),ie($,we,I.bl_count)}function H(I,ce,Te){var Le,Ee,$=-1,j=ce[1],Y=0,ge=7,we=4;for(j===0&&(ge=138,we=3),ce[2*(Te+1)+1]=65535,Le=0;Le<=Te;Le++)Ee=j,j=ce[2*(Le+1)+1],++Y<ge&&Ee===j||(Y<we?I.bl_tree[2*Ee]+=Y:Ee!==0?(Ee!==$&&I.bl_tree[2*Ee]++,I.bl_tree[2*A]++):Y<=10?I.bl_tree[2*T]++:I.bl_tree[2*k]++,$=Ee,we=(Y=0)===j?(ge=138,3):Ee===j?(ge=6,3):(ge=7,4))}function ee(I,ce,Te){var Le,Ee,$=-1,j=ce[1],Y=0,ge=7,we=4;for(j===0&&(ge=138,we=3),Le=0;Le<=Te;Le++)if(Ee=j,j=ce[2*(Le+1)+1],!(++Y<ge&&Ee===j)){if(Y<we)for(;de(I,Ee,I.bl_tree),--Y!=0;);else Ee!==0?(Ee!==$&&(de(I,Ee,I.bl_tree),Y--),de(I,A,I.bl_tree),ae(I,Y-3,2)):Y<=10?(de(I,T,I.bl_tree),ae(I,Y-3,3)):(de(I,k,I.bl_tree),ae(I,Y-11,7));$=Ee,we=(Y=0)===j?(ge=138,3):Ee===j?(ge=6,3):(ge=7,4)}}c(re);var X=!1;function B(I,ce,Te,Le){ae(I,(u<<1)+(Le?1:0),3),(function(Ee,$,j,Y){me(Ee),ne(Ee,j),ne(Ee,~j),a.arraySet(Ee.pending_buf,Ee.window,$,j,Ee.pending),Ee.pending+=j})(I,ce,Te)}i._tr_init=function(I){X||((function(){var ce,Te,Le,Ee,$,j=new Array(x+1);for(Ee=Le=0;Ee<d-1;Ee++)for(W[Ee]=Le,ce=0;ce<1<<E[Ee];ce++)P[Le++]=Ee;for(P[Le-1]=Ee,Ee=$=0;Ee<16;Ee++)for(re[Ee]=$,ce=0;ce<1<<O[Ee];ce++)q[$++]=Ee;for($>>=7;Ee<p;Ee++)for(re[Ee]=$<<7,ce=0;ce<1<<O[Ee]-7;ce++)q[256+$++]=Ee;for(Te=0;Te<=x;Te++)j[Te]=0;for(ce=0;ce<=143;)U[2*ce+1]=8,ce++,j[8]++;for(;ce<=255;)U[2*ce+1]=9,ce++,j[9]++;for(;ce<=279;)U[2*ce+1]=7,ce++,j[7]++;for(;ce<=287;)U[2*ce+1]=8,ce++,j[8]++;for(ie(U,m+1,j),ce=0;ce<p;ce++)L[2*ce+1]=5,L[2*ce]=fe(ce,5);K=new J(U,E,f+1,m,x),V=new J(L,O,0,p,x),Q=new J(new Array(0),C,0,b,S)})(),X=!0),I.l_desc=new z(I.dyn_ltree,K),I.d_desc=new z(I.dyn_dtree,V),I.bl_desc=new z(I.bl_tree,Q),I.bi_buf=0,I.bi_valid=0,Ae(I)},i._tr_stored_block=B,i._tr_flush_block=function(I,ce,Te,Le){var Ee,$,j=0;0<I.level?(I.strm.data_type===2&&(I.strm.data_type=(function(Y){var ge,we=4093624447;for(ge=0;ge<=31;ge++,we>>>=1)if(1&we&&Y.dyn_ltree[2*ge]!==0)return o;if(Y.dyn_ltree[18]!==0||Y.dyn_ltree[20]!==0||Y.dyn_ltree[26]!==0)return l;for(ge=32;ge<f;ge++)if(Y.dyn_ltree[2*ge]!==0)return l;return o})(I)),$e(I,I.l_desc),$e(I,I.d_desc),j=(function(Y){var ge;for(H(Y,Y.dyn_ltree,Y.l_desc.max_code),H(Y,Y.dyn_dtree,Y.d_desc.max_code),$e(Y,Y.bl_desc),ge=b-1;3<=ge&&Y.bl_tree[2*D[ge]+1]===0;ge--);return Y.opt_len+=3*(ge+1)+5+5+4,ge})(I),Ee=I.opt_len+3+7>>>3,($=I.static_len+3+7>>>3)<=Ee&&(Ee=$)):Ee=$=Te+5,Te+4<=Ee&&ce!==-1?B(I,ce,Te,Le):I.strategy===4||$===Ee?(ae(I,2+(Le?1:0),3),le(I,U,L)):(ae(I,4+(Le?1:0),3),(function(Y,ge,we,ve){var Ze;for(ae(Y,ge-257,5),ae(Y,we-1,5),ae(Y,ve-4,4),Ze=0;Ze<ve;Ze++)ae(Y,Y.bl_tree[2*D[Ze]+1],3);ee(Y,Y.dyn_ltree,ge-1),ee(Y,Y.dyn_dtree,we-1)})(I,I.l_desc.max_code+1,I.d_desc.max_code+1,j+1),le(I,I.dyn_ltree,I.dyn_dtree)),Ae(I),Le&&me(I)},i._tr_tally=function(I,ce,Te){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&Te,I.last_lit++,ce===0?I.dyn_ltree[2*Te]++:(I.matches++,ce--,I.dyn_ltree[2*(P[Te]+f+1)]++,I.dyn_dtree[2*G(ce)]++),I.last_lit===I.lit_bufsize-1},i._tr_align=function(I){ae(I,2,3),de(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(A){process.nextTick(function(){S(A)})}:(function(){if(o.postMessage&&!o.importScripts){var A=!0,T=o.onmessage;return o.onmessage=function(){A=!1},o.postMessage("","*"),o.onmessage=T,A}})()?(f="setImmediate$"+Math.random()+"$",o.addEventListener?o.addEventListener("message",M,!1):o.attachEvent("onmessage",M),function(A){o.postMessage(f+A,"*")}):o.MessageChannel?((d=new MessageChannel).port1.onmessage=function(A){S(A.data)},function(A){d.port2.postMessage(A)}):y&&"onreadystatechange"in y.createElement("script")?(u=y.documentElement,function(A){var T=y.createElement("script");T.onreadystatechange=function(){S(A),T.onreadystatechange=null,u.removeChild(T),T=null},u.appendChild(T)}):function(A){setTimeout(S,0,A)},x.setImmediate=function(A){typeof A!="function"&&(A=new Function(""+A));for(var T=new Array(arguments.length-1),k=0;k<T.length;k++)T[k]=arguments[k+1];var E={callback:A,args:T};return p[m]=E,c(m),m++},x.clearImmediate=v}function v(A){delete p[A]}function S(A){if(b)setTimeout(S,0,A);else{var T=p[A];if(T){b=!0;try{(function(k){var E=k.callback,O=k.args;switch(O.length){case 0:E();break;case 1:E(O[0]);break;case 2:E(O[0],O[1]);break;case 3:E(O[0],O[1],O[2]);break;default:E.apply(l,O)}})(T)}finally{v(A),b=!1}}}}function M(A){A.source===o&&typeof A.data=="string"&&A.data.indexOf(f)===0&&S(+A.data.slice(f.length))}})(typeof self>"u"?a===void 0?this:a:self)}).call(this,typeof p_<"u"?p_:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(Ck)),Ck.exports}var IIe=LIe();const FIe=pl(IIe);function UIe(t){const e=new gi;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 TG=UIe;async function CG(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 zIe(t){const e=await FIe.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(T=>T.tagName==="metadata"&&T.getAttribute("key")==="extruder");if(M.length>0){const T=M[0].getAttribute("value");T&&o.set(S,Math.max(0,parseInt(T,10)-1))}const A=v.getElementsByTagName("part");for(let T=0;T<A.length;T++){const k=A[T],E=k.getAttribute("id");if(!E)continue;const O=Array.from(k.children).filter(C=>C.tagName==="metadata"&&C.getAttribute("key")==="extruder");if(O.length>0){const C=O[0].getAttribute("value");C&&l.set(`${S}:${E}`,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 CG(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 A=b.getAttribute("p:extruder")||b.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","extruder")||"1";x=Math.max(0,parseInt(A,10)-1)}const v=[],S=b.getElementsByTagName("mesh");for(let A=0;A<S.length;A++){const T=S[A],k=[],E=[],O=T.getElementsByTagName("vertex");for(let D=0;D<O.length;D++){const U=O[D];k.push(parseFloat(U.getAttribute("x")||"0"),parseFloat(U.getAttribute("y")||"0"),parseFloat(U.getAttribute("z")||"0"))}const C=T.getElementsByTagName("triangle");for(let D=0;D<C.length;D++){const U=C[D];E.push(parseInt(U.getAttribute("v1")||"0"),parseInt(U.getAttribute("v2")||"0"),parseInt(U.getAttribute("v3")||"0"))}k.length>0&&E.length>0&&v.push({vertices:k,triangles:E,extruder:x})}const M=b.getElementsByTagName("component");for(let A=0;A<M.length;A++){const T=M[A],k=T.getAttribute("p:path")||T.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","path"),E=T.getAttribute("objectid");if(k){const O=await a(k);if(O){const C=E?`${y}:${E}`:null,D=C?l.get(C)??x:x,U=await CG(O,D),L=T.getAttribute("transform"),q=TG(L);for(const P of U)if(L){const W=[];for(let K=0;K<P.vertices.length;K+=3){const V=new tt(P.vertices[K],P.vertices[K+1],P.vertices[K+2]);V.applyMatrix4(q),W.push(V.x,V.y,V.z)}v.push({vertices:W,triangles:P.triangles,extruder:P.extruder})}else v.push(P)}}}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=TG(y.getAttribute("transform"));r.push({objectId:x,transform:v})}}return{objects:n,buildItems:r}}function kG(t){const e=new vl,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 ko(n,3)),e.setIndex(t.triangles),e.computeVertexNormals(),e}function BIe({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 oRe;S.background=new On(1710618),o.current=S;const M=new Mo(45,x/v,.1,1e4);M.position.set(150,150,150),l.current=M;const A=new vIe({antialias:!0});A.setSize(x,v),A.setPixelRatio(window.devicePixelRatio),y.appendChild(A.domElement),a.current=A;const T=new wIe(M,A.domElement);T.enableDamping=!0,T.dampingFactor=.05,c.current=T;const k=new _Re(16777215,.6);S.add(k);const E=new QV(16777215,.8);E.position.set(100,100,100),S.add(E);const O=new QV(16777215,.4);O.position.set(-100,50,-100),S.add(O);const C=Math.max(e.x,e.y),D=Math.ceil(C/16),U=new SRe(C,D,4473924,3355443);S.add(U);const L=new mL(e.x,e.y),q=new dL({color:44610,transparent:!0,opacity:.15,side:Fl}),P=new fl(L,q);P.rotation.x=-Math.PI/2,P.position.y=-.5,S.add(P);let W;const K=()=>{W=requestAnimationFrame(K),T.update(),A.render(S,M)};K(),fetch(t).then(Q=>{if(!Q.ok)throw new Error("Failed to load file");return Q.arrayBuffer()}).then(zIe).then(({objects:Q,buildItems:re})=>{if(Q.size===0)throw new Error("No meshes found in 3MF file");const J=Ne=>{const le=n?.[Ne]||"#00ae42",$e=new On(le);return new gRe({color:$e,shininess:30,flatShading:!1})},z=new Wb,G=new Map;if(re.length>0)for(const Ne of re){const ye=Q.get(Ne.objectId);if(ye)for(const le of ye.meshes){const $e=Ne.extruder??le.extruder,H=[];for(let X=0;X<le.vertices.length;X+=3){const B=new tt(le.vertices[X],le.vertices[X+1],le.vertices[X+2]);B.applyMatrix4(Ne.transform),H.push(B.x,B.y,B.z)}const ee=kG({vertices:H,triangles:le.triangles});G.has($e)||G.set($e,[]),G.get($e).push(ee)}}else for(const Ne of Q.values())for(const ye of Ne.meshes){const le=ye.extruder,$e=kG(ye);G.has(le)||G.set(le,[]),G.get(le).push($e)}for(const[Ne,ye]of G){if(ye.length===0)continue;const le=ye.length===1?ye[0]:OIe(ye,!1);if(le){const $e=J(Ne),H=new fl(le,$e);z.add(H)}if(ye.length>1)for(const $e of ye)$e.dispose()}const ne=new am().setFromObject(z),ae=ne.getCenter(new tt);z.position.y=-ne.min.y,re.length===0&&(z.position.x=-ae.x,z.position.z=-ae.z),S.add(z);const de=new am().setFromObject(z),fe=de.getCenter(new tt),ie=de.getSize(new tt),me=Math.max(ie.x,ie.y,ie.z)*1.8;M.position.set(fe.x+me*.7,fe.y+me*.5,fe.z+me*.7),T.target.copy(fe),T.update(),d(!1)}).catch(Q=>{m(Q.message),d(!1)});const V=()=>{if(!y)return;const Q=y.clientWidth,re=y.clientHeight;M.aspect=Q/re,M.updateProjectionMatrix(),A.setSize(Q,re)};return window.addEventListener("resize",V),()=>{window.removeEventListener("resize",V),cancelAnimationFrame(W),T.dispose(),A.dispose(),y.removeChild(A.domElement)}},[t,e,n]);const p=()=>{l.current&&c.current&&(l.current.position.set(150,150,150),c.current.target.set(0,50,0),c.current.update())},b=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(dt,{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(Se,{variant:"secondary",size:"sm",onClick:()=>b(.8),children:s.jsx(KD,{className:"w-4 h-4"})}),s.jsx(Se,{variant:"secondary",size:"sm",onClick:()=>b(1.25),children:s.jsx(XD,{className:"w-4 h-4"})}),s.jsx(Se,{variant:"secondary",size:"sm",onClick:p,children:s.jsx(mm,{className:"w-4 h-4"})})]})]})}const pE="159",yp={ROTATE:0,DOLLY:1,PAN:2},vp={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},$Ie=0,jG=1,HIe=2,zee=1,VIe=2,Wc=3,sh=0,Ns=1,Qc=2,Gd=0,hg=1,PG=2,RG=3,DG=4,GIe=5,lf=100,WIe=101,qIe=102,OG=103,LG=104,KIe=200,XIe=201,YIe=202,ZIe=203,NR=204,ER=205,QIe=206,JIe=207,eFe=208,tFe=209,nFe=210,rFe=211,iFe=212,aFe=213,sFe=214,oFe=0,lFe=1,cFe=2,KS=3,uFe=4,dFe=5,hFe=6,fFe=7,xL=0,mFe=1,pFe=2,Wd=0,gFe=1,xFe=2,bFe=3,yFe=4,vFe=5,Bee=300,Og=301,Lg=302,AR=303,TR=304,gE=306,CR=1e3,nl=1001,kR=1002,_a=1003,IG=1004,kk=1005,No=1006,_Fe=1007,ny=1008,qd=1009,wFe=1010,SFe=1011,bL=1012,$ee=1013,Dd=1014,ru=1015,ry=1016,Hee=1017,Vee=1018,Pf=1020,MFe=1021,Eo=1023,NFe=1024,EFe=1025,Rf=1026,Ig=1027,AFe=1028,Gee=1029,TFe=1030,Wee=1031,qee=1033,jk=33776,Pk=33777,Rk=33778,Dk=33779,FG=35840,UG=35841,zG=35842,BG=35843,Kee=36196,$G=37492,HG=37496,VG=37808,GG=37809,WG=37810,qG=37811,KG=37812,XG=37813,YG=37814,ZG=37815,QG=37816,JG=37817,e7=37818,t7=37819,n7=37820,r7=37821,Ok=36492,i7=36494,a7=36495,CFe=36283,s7=36284,o7=36285,l7=36286,Xee=3e3,Df=3001,kFe=3200,jFe=3201,Yee=0,PFe=1,Ao="",wa="srgb",Nu="srgb-linear",yL="display-p3",xE="display-p3-linear",XS="linear",Cr="srgb",YS="rec709",ZS="p3",_p=7680,c7=519,RFe=512,DFe=513,OFe=514,Zee=515,LFe=516,IFe=517,FFe=518,UFe=519,jR=35044,u7="300 es",PR=1035,Gl=2e3,iy=2001;class bm{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 Da=["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 d7=1234567;const o0=Math.PI/180,ay=180/Math.PI;function du(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(Da[t&255]+Da[t>>8&255]+Da[t>>16&255]+Da[t>>24&255]+"-"+Da[e&255]+Da[e>>8&255]+"-"+Da[e>>16&15|64]+Da[e>>24&255]+"-"+Da[n&63|128]+Da[n>>8&255]+"-"+Da[n>>16&255]+Da[n>>24&255]+Da[r&255]+Da[r>>8&255]+Da[r>>16&255]+Da[r>>24&255]).toLowerCase()}function Sa(t,e,n){return Math.max(e,Math.min(n,t))}function vL(t,e){return(t%e+e)%e}function zFe(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)}function BFe(t,e,n){return t!==e?(n-t)/(e-t):0}function l0(t,e,n){return(1-n)*t+n*e}function $Fe(t,e,n,r){return l0(t,e,1-Math.exp(-n*r))}function HFe(t,e=1){return e-Math.abs(vL(t,e*2)-e)}function VFe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*(3-2*t))}function GFe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*t*(t*(t*6-15)+10))}function WFe(t,e){return t+Math.floor(Math.random()*(e-t+1))}function qFe(t,e){return t+Math.random()*(e-t)}function KFe(t){return t*(.5-Math.random())}function XFe(t){t!==void 0&&(d7=t);let e=d7+=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 YFe(t){return t*o0}function ZFe(t){return t*ay}function RR(t){return(t&t-1)===0&&t!==0}function QFe(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function QS(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function JFe(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 Ul(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 fr(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(t*4294967295);case Uint16Array:return Math.round(t*65535);case Uint8Array:return Math.round(t*255);case Int32Array:return Math.round(t*2147483647);case Int16Array:return Math.round(t*32767);case Int8Array:return Math.round(t*127);default:throw new Error("Invalid component type.")}}const Qee={DEG2RAD:o0,RAD2DEG:ay,generateUUID:du,clamp:Sa,euclideanModulo:vL,mapLinear:zFe,inverseLerp:BFe,lerp:l0,damp:$Fe,pingpong:HFe,smoothstep:VFe,smootherstep:GFe,randInt:WFe,randFloat:qFe,randFloatSpread:KFe,seededRandom:XFe,degToRad:YFe,radToDeg:ZFe,isPowerOfTwo:RR,ceilPowerOfTwo:QFe,floorPowerOfTwo:QS,setQuaternionFromProperEuler:JFe,normalize:fr,denormalize:Ul};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(Sa(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 Cn{constructor(e,n,r,i,a,o,l,c,u){Cn.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],A=i[7],T=i[2],k=i[5],E=i[8];return a[0]=o*y+l*S+c*T,a[3]=o*x+l*M+c*k,a[6]=o*v+l*A+c*E,a[1]=u*y+d*S+f*T,a[4]=u*x+d*M+f*k,a[7]=u*v+d*A+f*E,a[2]=m*y+p*S+b*T,a[5]=m*x+p*M+b*k,a[8]=m*v+p*A+b*E,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(Lk.makeScale(e,n)),this}rotate(e){return this.premultiply(Lk.makeRotation(-e)),this}translate(e,n){return this.premultiply(Lk.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 Lk=new Cn;function Jee(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function JS(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function e5e(){const t=JS("canvas");return t.style.display="block",t}const h7={};function c0(t){t in h7||(h7[t]=!0,console.warn(t))}const f7=new Cn().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),m7=new Cn().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),ow={[Nu]:{transfer:XS,primaries:YS,toReference:t=>t,fromReference:t=>t},[wa]:{transfer:Cr,primaries:YS,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[xE]:{transfer:XS,primaries:ZS,toReference:t=>t.applyMatrix3(m7),fromReference:t=>t.applyMatrix3(f7)},[yL]:{transfer:Cr,primaries:ZS,toReference:t=>t.convertSRGBToLinear().applyMatrix3(m7),fromReference:t=>t.applyMatrix3(f7).convertLinearToSRGB()}},t5e=new Set([Nu,xE]),mr={enabled:!0,_workingColorSpace:Nu,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(!t5e.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=ow[e].toReference,i=ow[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 ow[t].primaries},getTransfer:function(t){return t===Ao?XS:ow[t].transfer}};function fg(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function Ik(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let wp;class ete{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{wp===void 0&&(wp=JS("canvas")),wp.width=e.width,wp.height=e.height;const r=wp.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=wp}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=JS("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]=fg(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(fg(n[r]/255)*255):n[r]=fg(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 n5e=0;class tte{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:n5e++}),this.uuid=du(),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(Fk(i[o].image)):a.push(Fk(i[o]))}else a=Fk(i);r.url=a}return n||(e.images[this.uuid]=r),r}}function Fk(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?ete.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 r5e=0;class Es extends bm{constructor(e=Es.DEFAULT_IMAGE,n=Es.DEFAULT_MAPPING,r=nl,i=nl,a=No,o=ny,l=Eo,c=qd,u=Es.DEFAULT_ANISOTROPY,d=Ao){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:r5e++}),this.uuid=du(),this.name="",this.source=new tte(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 Cn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,typeof d=="string"?this.colorSpace=d:(c0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=d===Df?wa:Ao),this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const r={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(r.userData=this.userData),n||(e.textures[this.uuid]=r),r}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Bee)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case CR:e.x=e.x-Math.floor(e.x);break;case nl:e.x=e.x<0?0:1;break;case kR: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 CR:e.y=e.y-Math.floor(e.y);break;case nl:e.y=e.y<0?0:1;break;case kR: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 c0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===wa?Df:Xee}set encoding(e){c0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===Df?wa:Ao}}Es.DEFAULT_IMAGE=null;Es.DEFAULT_MAPPING=Bee;Es.DEFAULT_ANISOTROPY=1;class gr{constructor(e=0,n=0,r=0,i=1){gr.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,A=(p+1)/2,T=(v+1)/2,k=(d+m)/4,E=(f+y)/4,O=(b+x)/4;return M>A&&M>T?M<.01?(r=0,i=.707106781,a=.707106781):(r=Math.sqrt(M),i=k/r,a=E/r):A>T?A<.01?(r=.707106781,i=0,a=.707106781):(i=Math.sqrt(A),r=k/i,a=O/i):T<.01?(r=.707106781,i=.707106781,a=0):(a=Math.sqrt(T),r=E/a,i=O/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 i5e extends bm{constructor(e=1,n=1,r={}){super(),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=1,this.scissor=new gr(0,0,e,n),this.scissorTest=!1,this.viewport=new gr(0,0,e,n);const i={width:e,height:n,depth:1};r.encoding!==void 0&&(c0("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),r.colorSpace=r.encoding===Df?wa:Ao),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:No,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},r),this.texture=new Es(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 tte(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 sm extends i5e{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}}class nte extends Es{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=_a,this.minFilter=_a,this.wrapR=nl,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class a5e extends Es{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=_a,this.minFilter=_a,this.wrapR=nl,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class om{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 T=Math.sqrt(M),k=Math.atan2(T,v*S);x=Math.sin(x*k)/T,l=Math.sin(l*k)/T}const A=l*S;if(c=c*x+m*A,u=u*x+p*A,d=d*x+b*A,f=f*x+y*A,x===1-l){const T=1/Math.sqrt(c*c+u*u+d*d+f*f);c*=T,u*=T,d*=T,f*=T}}e[n]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f}static multiplyQuaternionsFlat(e,n,r,i,a,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(Sa(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(p7.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(p7.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 Uk.copy(this).projectOnVector(e),this.sub(Uk)}reflect(e){return this.sub(Uk.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(Sa(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 Uk=new Be,p7=new om;class jo{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(Xo.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(Xo.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=Xo.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,Xo):Xo.fromBufferAttribute(a,o),Xo.applyMatrix4(e.matrixWorld),this.expandByPoint(Xo);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),lw.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),lw.copy(r.boundingBox)),lw.applyMatrix4(e.matrixWorld),this.union(lw)}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,Xo),Xo.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(Cb),cw.subVectors(this.max,Cb),Sp.subVectors(e.a,Cb),Mp.subVectors(e.b,Cb),Np.subVectors(e.c,Cb),cd.subVectors(Mp,Sp),ud.subVectors(Np,Mp),Kh.subVectors(Sp,Np);let n=[0,-cd.z,cd.y,0,-ud.z,ud.y,0,-Kh.z,Kh.y,cd.z,0,-cd.x,ud.z,0,-ud.x,Kh.z,0,-Kh.x,-cd.y,cd.x,0,-ud.y,ud.x,0,-Kh.y,Kh.x,0];return!zk(n,Sp,Mp,Np,cw)||(n=[1,0,0,0,1,0,0,0,1],!zk(n,Sp,Mp,Np,cw))?!1:(uw.crossVectors(cd,ud),n=[uw.x,uw.y,uw.z],zk(n,Sp,Mp,Np,cw))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Xo).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Xo).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Ic[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Ic[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Ic[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Ic[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Ic[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Ic[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Ic[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Ic[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Ic),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const Ic=[new Be,new Be,new Be,new Be,new Be,new Be,new Be,new Be],Xo=new Be,lw=new jo,Sp=new Be,Mp=new Be,Np=new Be,cd=new Be,ud=new Be,Kh=new Be,Cb=new Be,cw=new Be,uw=new Be,Xh=new Be;function zk(t,e,n,r,i){for(let a=0,o=t.length-3;a<=o;a+=3){Xh.fromArray(t,a);const l=i.x*Math.abs(Xh.x)+i.y*Math.abs(Xh.y)+i.z*Math.abs(Xh.z),c=e.dot(Xh),u=n.dot(Xh),d=r.dot(Xh);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>l)return!1}return!0}const s5e=new jo,kb=new Be,Bk=new Be;class Yl{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):s5e.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;kb.subVectors(e,this.center);const n=kb.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(kb,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):(Bk.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(kb.copy(e.center).add(Bk)),this.expandByPoint(kb.copy(e.center).sub(Bk))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Fc=new Be,$k=new Be,dw=new Be,dd=new Be,Hk=new Be,hw=new Be,Vk=new Be;class _L{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,Fc)),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=Fc.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(Fc.copy(this.origin).addScaledVector(this.direction,n),Fc.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){$k.copy(e).add(n).multiplyScalar(.5),dw.copy(n).sub(e).normalize(),dd.copy(this.origin).sub($k);const a=e.distanceTo(n)*.5,o=-this.direction.dot(dw),l=dd.dot(this.direction),c=-dd.dot(dw),u=dd.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($k).addScaledVector(dw,m),p}intersectSphere(e,n){Fc.subVectors(e.center,this.origin);const r=Fc.dot(this.direction),i=Fc.dot(Fc)-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,Fc)!==null}intersectTriangle(e,n,r,i,a){Hk.subVectors(n,e),hw.subVectors(r,e),Vk.crossVectors(Hk,hw);let o=this.direction.dot(Vk),l;if(o>0){if(i)return null;l=1}else if(o<0)l=-1,o=-o;else return null;dd.subVectors(this.origin,e);const c=l*this.direction.dot(hw.crossVectors(dd,hw));if(c<0)return null;const u=l*this.direction.dot(Hk.cross(dd));if(u<0||c+u>o)return null;const d=-l*dd.dot(Vk);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 Nr{constructor(e,n,r,i,a,o,l,c,u,d,f,m,p,b,y,x){Nr.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 Nr().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/Ep.setFromMatrixColumn(e,0).length(),a=1/Ep.setFromMatrixColumn(e,1).length(),o=1/Ep.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(o5e,e,l5e)}lookAt(e,n,r){const i=this.elements;return zs.subVectors(e,n),zs.lengthSq()===0&&(zs.z=1),zs.normalize(),hd.crossVectors(r,zs),hd.lengthSq()===0&&(Math.abs(r.z)===1?zs.x+=1e-4:zs.z+=1e-4,zs.normalize(),hd.crossVectors(r,zs)),hd.normalize(),fw.crossVectors(zs,hd),i[0]=hd.x,i[4]=fw.x,i[8]=zs.x,i[1]=hd.y,i[5]=fw.y,i[9]=zs.y,i[2]=hd.z,i[6]=fw.z,i[10]=zs.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],A=r[11],T=r[15],k=i[0],E=i[4],O=i[8],C=i[12],D=i[1],U=i[5],L=i[9],q=i[13],P=i[2],W=i[6],K=i[10],V=i[14],Q=i[3],re=i[7],J=i[11],z=i[15];return a[0]=o*k+l*D+c*P+u*Q,a[4]=o*E+l*U+c*W+u*re,a[8]=o*O+l*L+c*K+u*J,a[12]=o*C+l*q+c*V+u*z,a[1]=d*k+f*D+m*P+p*Q,a[5]=d*E+f*U+m*W+p*re,a[9]=d*O+f*L+m*K+p*J,a[13]=d*C+f*q+m*V+p*z,a[2]=b*k+y*D+x*P+v*Q,a[6]=b*E+y*U+x*W+v*re,a[10]=b*O+y*L+x*K+v*J,a[14]=b*C+y*q+x*V+v*z,a[3]=S*k+M*D+A*P+T*Q,a[7]=S*E+M*U+A*W+T*re,a[11]=S*O+M*L+A*K+T*J,a[15]=S*C+M*q+A*V+T*z,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[4],i=e[8],a=e[12],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,A=d*y*u-b*f*u+b*l*p-o*y*p-d*l*v+o*f*v,T=b*f*c-d*y*c-b*l*m+o*y*m+d*l*x-o*f*x,k=n*S+r*M+i*A+a*T;if(k===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const E=1/k;return e[0]=S*E,e[1]=(y*m*a-f*x*a-y*i*p+r*x*p+f*i*v-r*m*v)*E,e[2]=(l*x*a-y*c*a+y*i*u-r*x*u-l*i*v+r*c*v)*E,e[3]=(f*c*a-l*m*a-f*i*u+r*m*u+l*i*p-r*c*p)*E,e[4]=M*E,e[5]=(d*x*a-b*m*a+b*i*p-n*x*p-d*i*v+n*m*v)*E,e[6]=(b*c*a-o*x*a-b*i*u+n*x*u+o*i*v-n*c*v)*E,e[7]=(o*m*a-d*c*a+d*i*u-n*m*u-o*i*p+n*c*p)*E,e[8]=A*E,e[9]=(b*f*a-d*y*a-b*r*p+n*y*p+d*r*v-n*f*v)*E,e[10]=(o*y*a-b*l*a+b*r*u-n*y*u-o*r*v+n*l*v)*E,e[11]=(d*l*a-o*f*a-d*r*u+n*f*u+o*r*p-n*l*p)*E,e[12]=T*E,e[13]=(d*y*i-b*f*i+b*r*m-n*y*m-d*r*x+n*f*x)*E,e[14]=(b*l*i-o*y*i-b*r*c+n*y*c+o*r*x-n*l*x)*E,e[15]=(o*f*i-d*l*i+d*r*c-n*f*c-o*r*m+n*l*m)*E,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,A=c*f,T=r.x,k=r.y,E=r.z;return i[0]=(1-(y+v))*T,i[1]=(p+A)*T,i[2]=(b-M)*T,i[3]=0,i[4]=(p-A)*k,i[5]=(1-(m+v))*k,i[6]=(x+S)*k,i[7]=0,i[8]=(b+M)*E,i[9]=(x-S)*E,i[10]=(1-(m+y))*E,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=Ep.set(i[0],i[1],i[2]).length();const o=Ep.set(i[4],i[5],i[6]).length(),l=Ep.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],Yo.copy(this);const u=1/a,d=1/o,f=1/l;return Yo.elements[0]*=u,Yo.elements[1]*=u,Yo.elements[2]*=u,Yo.elements[4]*=d,Yo.elements[5]*=d,Yo.elements[6]*=d,Yo.elements[8]*=f,Yo.elements[9]*=f,Yo.elements[10]*=f,n.setFromRotationMatrix(Yo),r.x=a,r.y=o,r.z=l,this}makePerspective(e,n,r,i,a,o,l=Gl){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===Gl)p=-(o+a)/(o-a),b=-2*o*a/(o-a);else if(l===iy)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=Gl){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===Gl)b=(o+a)*f,y=-2*f;else if(l===iy)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 Ep=new Be,Yo=new Nr,o5e=new Be(0,0,0),l5e=new Be(1,1,1),hd=new Be,fw=new Be,zs=new Be,g7=new Nr,x7=new om;class Zy{constructor(e=0,n=0,r=0,i=Zy.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(Sa(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(-Sa(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(Sa(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(-Sa(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(Sa(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(-Sa(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 g7.makeRotationFromQuaternion(e),this.setFromRotationMatrix(g7,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return x7.setFromEuler(this),this.setFromQuaternion(x7,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}}Zy.DEFAULT_ORDER="XYZ";class rte{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 c5e=0;const b7=new Be,Ap=new om,Uc=new Nr,mw=new Be,jb=new Be,u5e=new Be,d5e=new om,y7=new Be(1,0,0),v7=new Be(0,1,0),_7=new Be(0,0,1),h5e={type:"added"},f5e={type:"removed"};class ts extends bm{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:c5e++}),this.uuid=du(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=ts.DEFAULT_UP.clone();const e=new Be,n=new Zy,r=new om,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 Nr},normalMatrix:{value:new Cn}}),this.matrix=new Nr,this.matrixWorld=new Nr,this.matrixAutoUpdate=ts.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=ts.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new rte,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 Ap.setFromAxisAngle(e,n),this.quaternion.multiply(Ap),this}rotateOnWorldAxis(e,n){return Ap.setFromAxisAngle(e,n),this.quaternion.premultiply(Ap),this}rotateX(e){return this.rotateOnAxis(y7,e)}rotateY(e){return this.rotateOnAxis(v7,e)}rotateZ(e){return this.rotateOnAxis(_7,e)}translateOnAxis(e,n){return b7.copy(e).applyQuaternion(this.quaternion),this.position.add(b7.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(y7,e)}translateY(e){return this.translateOnAxis(v7,e)}translateZ(e){return this.translateOnAxis(_7,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Uc.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?mw.copy(e):mw.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),jb.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Uc.lookAt(jb,mw,this.up):Uc.lookAt(mw,jb,this.up),this.quaternion.setFromRotationMatrix(Uc),i&&(Uc.extractRotation(i.matrixWorld),Ap.setFromRotationMatrix(Uc),this.quaternion.premultiply(Ap.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(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(h5e)):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(f5e)),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),Uc.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Uc.multiply(e.parent.matrixWorld)),e.applyMatrix4(Uc),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(jb,e,u5e),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(jb,d5e,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}}ts.DEFAULT_UP=new Be(0,1,0);ts.DEFAULT_MATRIX_AUTO_UPDATE=!0;ts.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Zo=new Be,zc=new Be,Gk=new Be,Bc=new Be,Tp=new Be,Cp=new Be,w7=new Be,Wk=new Be,qk=new Be,Kk=new Be;let pw=!1;class Qo{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),Zo.subVectors(e,n),i.cross(Zo);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){Zo.subVectors(i,n),zc.subVectors(r,n),Gk.subVectors(e,n);const o=Zo.dot(Zo),l=Zo.dot(zc),c=Zo.dot(Gk),u=zc.dot(zc),d=zc.dot(Gk),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,Bc),Bc.x>=0&&Bc.y>=0&&Bc.x+Bc.y<=1}static getUV(e,n,r,i,a,o,l,c){return pw===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),pw=!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,Bc),c.setScalar(0),c.addScaledVector(a,Bc.x),c.addScaledVector(o,Bc.y),c.addScaledVector(l,Bc.z),c}static isFrontFacing(e,n,r,i){return Zo.subVectors(r,n),zc.subVectors(e,n),Zo.cross(zc).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 Zo.subVectors(this.c,this.b),zc.subVectors(this.a,this.b),Zo.cross(zc).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Qo.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return Qo.getBarycoord(e,this.a,this.b,this.c,n)}getUV(e,n,r,i,a){return pw===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),pw=!0),Qo.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}getInterpolation(e,n,r,i,a){return Qo.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}containsPoint(e){return Qo.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Qo.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;Tp.subVectors(i,r),Cp.subVectors(a,r),Wk.subVectors(e,r);const c=Tp.dot(Wk),u=Cp.dot(Wk);if(c<=0&&u<=0)return n.copy(r);qk.subVectors(e,i);const d=Tp.dot(qk),f=Cp.dot(qk);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(Tp,o);Kk.subVectors(e,a);const p=Tp.dot(Kk),b=Cp.dot(Kk);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 w7.subVectors(a,i),l=(f-d)/(f-d+(p-b)),n.copy(i).addScaledVector(w7,l);const v=1/(x+y+m);return o=y*v,l=m*v,n.copy(r).addScaledVector(Tp,o).addScaledVector(Cp,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const ite={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},fd={h:0,s:0,l:0},gw={h:0,s:0,l:0};function Xk(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=wa){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,mr.toWorkingColorSpace(this,n),this}setRGB(e,n,r,i=mr.workingColorSpace){return this.r=e,this.g=n,this.b=r,mr.toWorkingColorSpace(this,i),this}setHSL(e,n,r,i=mr.workingColorSpace){if(e=vL(e,1),n=Sa(n,0,1),r=Sa(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=Xk(o,a,e+1/3),this.g=Xk(o,a,e),this.b=Xk(o,a,e-1/3)}return mr.toWorkingColorSpace(this,i),this}setStyle(e,n=wa){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=wa){const r=ite[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=fg(e.r),this.g=fg(e.g),this.b=fg(e.b),this}copyLinearToSRGB(e){return this.r=Ik(e.r),this.g=Ik(e.g),this.b=Ik(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=wa){return mr.fromWorkingColorSpace(Oa.copy(this),e),Math.round(Sa(Oa.r*255,0,255))*65536+Math.round(Sa(Oa.g*255,0,255))*256+Math.round(Sa(Oa.b*255,0,255))}getHexString(e=wa){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=mr.workingColorSpace){mr.fromWorkingColorSpace(Oa.copy(this),n);const r=Oa.r,i=Oa.g,a=Oa.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=mr.workingColorSpace){return mr.fromWorkingColorSpace(Oa.copy(this),n),e.r=Oa.r,e.g=Oa.g,e.b=Oa.b,e}getStyle(e=wa){mr.fromWorkingColorSpace(Oa.copy(this),e);const n=Oa.r,r=Oa.g,i=Oa.b;return e!==wa?`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(fd),this.setHSL(fd.h+e,fd.s+n,fd.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(fd),e.getHSL(gw);const r=l0(fd.h,gw.h,n),i=l0(fd.s,gw.s,n),a=l0(fd.l,gw.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 Oa=new rn;rn.NAMES=ite;let m5e=0;class mx extends bm{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:m5e++}),this.uuid=du(),this.name="",this.type="Material",this.blending=hg,this.side=sh,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=NR,this.blendDst=ER,this.blendEquation=lf,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new rn(0,0,0),this.blendAlpha=0,this.depthFunc=KS,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=c7,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=_p,this.stencilZFail=_p,this.stencilZPass=_p,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!==hg&&(r.blending=this.blending),this.side!==sh&&(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!==NR&&(r.blendSrc=this.blendSrc),this.blendDst!==ER&&(r.blendDst=this.blendDst),this.blendEquation!==lf&&(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!==KS&&(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!==c7&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==_p&&(r.stencilFail=this.stencilFail),this.stencilZFail!==_p&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==_p&&(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 ate extends mx{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=xL,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 Mi=new Be,xw=new mn;class Zs{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=jR,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=ru,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++)xw.fromBufferAttribute(this,n),xw.applyMatrix3(e),this.setXY(n,xw.x,xw.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)Mi.fromBufferAttribute(this,n),Mi.applyMatrix3(e),this.setXYZ(n,Mi.x,Mi.y,Mi.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)Mi.fromBufferAttribute(this,n),Mi.applyMatrix4(e),this.setXYZ(n,Mi.x,Mi.y,Mi.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)Mi.fromBufferAttribute(this,n),Mi.applyNormalMatrix(e),this.setXYZ(n,Mi.x,Mi.y,Mi.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)Mi.fromBufferAttribute(this,n),Mi.transformDirection(e),this.setXYZ(n,Mi.x,Mi.y,Mi.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=Ul(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=fr(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=Ul(n,this.array)),n}setX(e,n){return this.normalized&&(n=fr(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=Ul(n,this.array)),n}setY(e,n){return this.normalized&&(n=fr(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=Ul(n,this.array)),n}setZ(e,n){return this.normalized&&(n=fr(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=Ul(n,this.array)),n}setW(e,n){return this.normalized&&(n=fr(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=fr(n,this.array),r=fr(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=fr(n,this.array),r=fr(r,this.array),i=fr(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=fr(n,this.array),r=fr(r,this.array),i=fr(i,this.array),a=fr(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!==jR&&(e.usage=this.usage),e}}class ste extends Zs{constructor(e,n,r){super(new Uint16Array(e),n,r)}}class ote extends Zs{constructor(e,n,r){super(new Uint32Array(e),n,r)}}class xi extends Zs{constructor(e,n,r){super(new Float32Array(e),n,r)}}let p5e=0;const po=new Nr,Yk=new ts,kp=new Be,Bs=new jo,Pb=new jo,Ki=new Be;class Va extends bm{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:p5e++}),this.uuid=du(),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(Jee(e)?ote:ste)(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 Cn().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 po.makeRotationFromQuaternion(e),this.applyMatrix4(po),this}rotateX(e){return po.makeRotationX(e),this.applyMatrix4(po),this}rotateY(e){return po.makeRotationY(e),this.applyMatrix4(po),this}rotateZ(e){return po.makeRotationZ(e),this.applyMatrix4(po),this}translate(e,n,r){return po.makeTranslation(e,n,r),this.applyMatrix4(po),this}scale(e,n,r){return po.makeScale(e,n,r),this.applyMatrix4(po),this}lookAt(e){return Yk.lookAt(e),Yk.updateMatrix(),this.applyMatrix4(Yk.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(kp).negate(),this.translate(kp.x,kp.y,kp.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 xi(n,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new jo);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];Bs.setFromBufferAttribute(a),this.morphTargetsRelative?(Ki.addVectors(this.boundingBox.min,Bs.min),this.boundingBox.expandByPoint(Ki),Ki.addVectors(this.boundingBox.max,Bs.max),this.boundingBox.expandByPoint(Ki)):(this.boundingBox.expandByPoint(Bs.min),this.boundingBox.expandByPoint(Bs.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 Yl);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(Bs.setFromBufferAttribute(e),n)for(let a=0,o=n.length;a<o;a++){const l=n[a];Pb.setFromBufferAttribute(l),this.morphTargetsRelative?(Ki.addVectors(Bs.min,Pb.min),Bs.expandByPoint(Ki),Ki.addVectors(Bs.max,Pb.max),Bs.expandByPoint(Ki)):(Bs.expandByPoint(Pb.min),Bs.expandByPoint(Pb.max))}Bs.getCenter(r);let i=0;for(let a=0,o=e.count;a<o;a++)Ki.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(Ki));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++)Ki.fromBufferAttribute(l,u),c&&(kp.fromBufferAttribute(e,u),Ki.add(kp)),i=Math.max(i,r.distanceToSquared(Ki))}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 Zs(new Float32Array(4*l),4));const c=this.getAttribute("tangent").array,u=[],d=[];for(let D=0;D<l;D++)u[D]=new Be,d[D]=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(D,U,L){f.fromArray(i,D*3),m.fromArray(i,U*3),p.fromArray(i,L*3),b.fromArray(o,D*2),y.fromArray(o,U*2),x.fromArray(o,L*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[D].add(v),u[U].add(v),u[L].add(v),d[D].add(S),d[U].add(S),d[L].add(S))}let A=this.groups;A.length===0&&(A=[{start:0,count:r.length}]);for(let D=0,U=A.length;D<U;++D){const L=A[D],q=L.start,P=L.count;for(let W=q,K=q+P;W<K;W+=3)M(r[W+0],r[W+1],r[W+2])}const T=new Be,k=new Be,E=new Be,O=new Be;function C(D){E.fromArray(a,D*3),O.copy(E);const U=u[D];T.copy(U),T.sub(E.multiplyScalar(E.dot(U))).normalize(),k.crossVectors(O,U);const q=k.dot(d[D])<0?-1:1;c[D*4]=T.x,c[D*4+1]=T.y,c[D*4+2]=T.z,c[D*4+3]=q}for(let D=0,U=A.length;D<U;++D){const L=A[D],q=L.start,P=L.count;for(let W=q,K=q+P;W<K;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 Zs(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++)Ki.fromBufferAttribute(e,n),Ki.normalize(),e.setXYZ(n,Ki.x,Ki.y,Ki.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 Zs(m,d,f)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new Va,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 S7=new Nr,Yh=new _L,bw=new Yl,M7=new Be,jp=new Be,Pp=new Be,Rp=new Be,Zk=new Be,yw=new Be,vw=new mn,_w=new mn,ww=new mn,N7=new Be,E7=new Be,A7=new Be,Sw=new Be,Mw=new Be;class al extends ts{constructor(e=new Va,n=new ate){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){yw.set(0,0,0);for(let c=0,u=a.length;c<u;c++){const d=l[c],f=a[c];d!==0&&(Zk.fromBufferAttribute(f,e),o?yw.addScaledVector(Zk,d):yw.addScaledVector(Zk.sub(n),d))}n.add(yw)}return n}raycast(e,n){const r=this.geometry,i=this.material,a=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),bw.copy(r.boundingSphere),bw.applyMatrix4(a),Yh.copy(e.ray).recast(e.near),!(bw.containsPoint(Yh.origin)===!1&&(Yh.intersectSphere(bw,M7)===null||Yh.origin.distanceToSquared(M7)>(e.far-e.near)**2))&&(S7.copy(a).invert(),Yh.copy(e.ray).applyMatrix4(S7),!(r.boundingBox!==null&&Yh.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,Yh)))}_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 A=S,T=M;A<T;A+=3){const k=l.getX(A),E=l.getX(A+1),O=l.getX(A+2);i=Nw(this,v,e,r,u,d,f,k,E,O),i&&(i.faceIndex=Math.floor(A/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),A=l.getX(x+2);i=Nw(this,o,e,r,u,d,f,S,M,A),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 A=S,T=M;A<T;A+=3){const k=A,E=A+1,O=A+2;i=Nw(this,v,e,r,u,d,f,k,E,O),i&&(i.faceIndex=Math.floor(A/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,A=x+2;i=Nw(this,o,e,r,u,d,f,S,M,A),i&&(i.faceIndex=Math.floor(x/3),n.push(i))}}}}function g5e(t,e,n,r,i,a,o,l){let c;if(e.side===Ns?c=r.intersectTriangle(o,a,i,!0,l):c=r.intersectTriangle(i,a,o,e.side===sh,l),c===null)return null;Mw.copy(l),Mw.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(Mw);return u<n.near||u>n.far?null:{distance:u,point:Mw.clone(),object:t}}function Nw(t,e,n,r,i,a,o,l,c,u){t.getVertexPosition(l,jp),t.getVertexPosition(c,Pp),t.getVertexPosition(u,Rp);const d=g5e(t,e,n,r,jp,Pp,Rp,Sw);if(d){i&&(vw.fromBufferAttribute(i,l),_w.fromBufferAttribute(i,c),ww.fromBufferAttribute(i,u),d.uv=Qo.getInterpolation(Sw,jp,Pp,Rp,vw,_w,ww,new mn)),a&&(vw.fromBufferAttribute(a,l),_w.fromBufferAttribute(a,c),ww.fromBufferAttribute(a,u),d.uv1=Qo.getInterpolation(Sw,jp,Pp,Rp,vw,_w,ww,new mn),d.uv2=d.uv1),o&&(N7.fromBufferAttribute(o,l),E7.fromBufferAttribute(o,c),A7.fromBufferAttribute(o,u),d.normal=Qo.getInterpolation(Sw,jp,Pp,Rp,N7,E7,A7,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};Qo.getNormal(jp,Pp,Rp,f.normal),d.face=f}return d}class Qy extends Va{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 xi(u,3)),this.setAttribute("normal",new xi(d,3)),this.setAttribute("uv",new xi(f,2));function b(y,x,v,S,M,A,T,k,E,O,C){const D=A/E,U=T/O,L=A/2,q=T/2,P=k/2,W=E+1,K=O+1;let V=0,Q=0;const re=new Be;for(let J=0;J<K;J++){const z=J*U-q;for(let G=0;G<W;G++){const ne=G*D-L;re[y]=ne*S,re[x]=z*M,re[v]=P,u.push(re.x,re.y,re.z),re[y]=0,re[x]=0,re[v]=k>0?1:-1,d.push(re.x,re.y,re.z),f.push(G/E),f.push(1-J/O),V+=1}}for(let J=0;J<O;J++)for(let z=0;z<E;z++){const G=m+z+W*J,ne=m+z+W*(J+1),ae=m+(z+1)+W*(J+1),de=m+(z+1)+W*J;c.push(G,ne,de),c.push(ne,ae,de),Q+=6}l.addGroup(p,Q,C),p+=Q,m+=V}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Qy(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Fg(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 Xa(t){const e={};for(let n=0;n<t.length;n++){const r=Fg(t[n]);for(const i in r)e[i]=r[i]}return e}function x5e(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function lte(t){return t.getRenderTarget()===null?t.outputColorSpace:mr.workingColorSpace}const wL={clone:Fg,merge:Xa};var b5e=`void main() {
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
- }`,y5e=`void main() {
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
- }`;class oh extends mx{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=b5e,this.fragmentShader=y5e,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=Fg(e.uniforms),this.uniformsGroups=x5e(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 cte extends ts{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Nr,this.projectionMatrix=new Nr,this.projectionMatrixInverse=new Nr,this.coordinateSystem=Gl}copy(e,n){return super.copy(e,n),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,n){super.updateWorldMatrix(e,n),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}class $s extends cte{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=ay*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(o0*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return ay*2*Math.atan(Math.tan(o0*.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(o0*.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 Dp=-90,Op=1;class v5e extends ts{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new $s(Dp,Op,e,n);i.layers=this.layers,this.add(i);const a=new $s(Dp,Op,e,n);a.layers=this.layers,this.add(a);const o=new $s(Dp,Op,e,n);o.layers=this.layers,this.add(o);const l=new $s(Dp,Op,e,n);l.layers=this.layers,this.add(l);const c=new $s(Dp,Op,e,n);c.layers=this.layers,this.add(c);const u=new $s(Dp,Op,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===Gl)r.up.set(0,1,0),r.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),a.up.set(0,0,-1),a.lookAt(0,1,0),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===iy)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 ute extends Es{constructor(e,n,r,i,a,o,l,c,u,d){e=e!==void 0?e:[],n=n!==void 0?n:Og,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 _5e extends sm{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&&(c0("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===Df?wa:Ao),this.texture=new ute(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=n.generateMipmaps!==void 0?n.generateMipmaps:!1,this.texture.minFilter=n.minFilter!==void 0?n.minFilter:No}fromEquirectangularTexture(e,n){this.texture.type=n.type,this.texture.colorSpace=n.colorSpace,this.texture.generateMipmaps=n.generateMipmaps,this.texture.minFilter=n.minFilter,this.texture.magFilter=n.magFilter;const r={uniforms:{tEquirect:{value:null}},vertexShader:`
- varying vec3 vWorldDirection;
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
- }
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }
- `,fragmentShader:`
- uniform sampler2D tEquirect;
- varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vec3 direction = normalize( vWorldDirection );
- vec2 sampleUV = equirectUv( direction );
- gl_FragColor = texture2D( tEquirect, sampleUV );
- }
- `},i=new Qy(5,5,5),a=new oh({name:"CubemapFromEquirect",uniforms:Fg(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:Ns,blending:Gd});a.uniforms.tEquirect.value=n;const o=new al(i,a),l=n.minFilter;return n.minFilter===ny&&(n.minFilter=No),new v5e(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 Qk=new Be,w5e=new Be,S5e=new Cn;class wd{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=Qk.subVectors(r,n).cross(w5e.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(Qk),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||S5e.getNormalMatrix(e),i=this.coplanarPoint(Qk).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 Yl,Ew=new Be;class bE{constructor(e=new wd,n=new wd,r=new wd,i=new wd,a=new wd,o=new wd){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=Gl){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],A=i[15];if(r[0].setComponents(c-a,m-u,x-p,A-v).normalize(),r[1].setComponents(c+a,m+u,x+p,A+v).normalize(),r[2].setComponents(c+o,m+d,x+b,A+S).normalize(),r[3].setComponents(c-o,m-d,x-b,A-S).normalize(),r[4].setComponents(c-l,m-f,x-y,A-M).normalize(),n===Gl)r[5].setComponents(c+l,m+f,x+y,A+M).normalize();else if(n===iy)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(),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){return Zh.center.set(0,0,0),Zh.radius=.7071067811865476,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(Ew.x=i.normal.x>0?e.max.x:e.min.x,Ew.y=i.normal.y>0?e.max.y:e.min.y,Ew.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Ew)<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 dte(){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 M5e(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 SL extends Va{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 A=M*f-a;b.push(A,-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,A=S+u*(v+1),T=S+1+u*(v+1),k=S+1+u*v;p.push(M,A,k),p.push(A,T,k)}this.setIndex(p),this.setAttribute("position",new xi(b,3)),this.setAttribute("normal",new xi(y,3)),this.setAttribute("uv",new xi(x,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new SL(e.width,e.height,e.widthSegments,e.heightSegments)}}var N5e=`#ifdef USE_ALPHAHASH
- if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
- #endif`,E5e=`#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`,A5e=`#ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
- #endif`,T5e=`#ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,C5e=`#ifdef USE_ALPHATEST
- if ( diffuseColor.a < alphaTest ) discard;
- #endif`,k5e=`#ifdef USE_ALPHATEST
- uniform float alphaTest;
- #endif`,j5e=`#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`,P5e=`#ifdef USE_AOMAP
- uniform sampler2D aoMap;
- uniform float aoMapIntensity;
- #endif`,R5e=`#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`,D5e=`#ifdef USE_BATCHING
- mat4 batchingMatrix = getBatchingMatrix( batchId );
- #endif`,O5e=`vec3 transformed = vec3( position );
- #ifdef USE_ALPHAHASH
- vPosition = vec3( position );
- #endif`,L5e=`vec3 objectNormal = vec3( normal );
- #ifdef USE_TANGENT
- vec3 objectTangent = vec3( tangent.xyz );
- #endif`,I5e=`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`,F5e=`#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`,U5e=`#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`,z5e=`#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`,B5e=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
- #endif`,$5e=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- #endif`,H5e=`#if NUM_CLIPPING_PLANES > 0
- vClipPosition = - mvPosition.xyz;
- #endif`,V5e=`#if defined( USE_COLOR_ALPHA )
- diffuseColor *= vColor;
- #elif defined( USE_COLOR )
- diffuseColor.rgb *= vColor;
- #endif`,G5e=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR )
- varying vec3 vColor;
- #endif`,W5e=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
- varying vec3 vColor;
- #endif`,q5e=`#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`,K5e=`#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`,X5e=`#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`,Y5e=`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`,Z5e=`#ifdef USE_DISPLACEMENTMAP
- uniform sampler2D displacementMap;
- uniform float displacementScale;
- uniform float displacementBias;
- #endif`,Q5e=`#ifdef USE_DISPLACEMENTMAP
- transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
- #endif`,J5e=`#ifdef USE_EMISSIVEMAP
- vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
- totalEmissiveRadiance *= emissiveColor.rgb;
- #endif`,eUe=`#ifdef USE_EMISSIVEMAP
- uniform sampler2D emissiveMap;
- #endif`,tUe="gl_FragColor = linearToOutputTexel( gl_FragColor );",nUe=`
- 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 );
- }`,rUe=`#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`,iUe=`#ifdef USE_ENVMAP
- uniform float envMapIntensity;
- uniform float flipEnvMap;
- #ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #else
- uniform sampler2D envMap;
- #endif
-
- #endif`,aUe=`#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`,sUe=`#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`,oUe=`#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`,lUe=`#ifdef USE_FOG
- vFogDepth = - mvPosition.z;
- #endif`,cUe=`#ifdef USE_FOG
- varying float vFogDepth;
- #endif`,uUe=`#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`,dUe=`#ifdef USE_FOG
- uniform vec3 fogColor;
- varying float vFogDepth;
- #ifdef FOG_EXP2
- uniform float fogDensity;
- #else
- uniform float fogNear;
- uniform float fogFar;
- #endif
- #endif`,hUe=`#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
- }`,fUe=`#ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
- reflectedLight.indirectDiffuse += lightMapIrradiance;
- #endif`,mUe=`#ifdef USE_LIGHTMAP
- uniform sampler2D lightMap;
- uniform float lightMapIntensity;
- #endif`,pUe=`LambertMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularStrength = specularStrength;`,gUe=`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`,xUe=`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`,bUe=`#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`,yUe=`ToonMaterial material;
- material.diffuseColor = diffuseColor.rgb;`,vUe=`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`,_Ue=`BlinnPhongMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularColor = specular;
- material.specularShininess = shininess;
- material.specularStrength = specularStrength;`,wUe=`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`,SUe=`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`,MUe=`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 );
- }`,NUe=`
- 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`,EUe=`#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`,AUe=`#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`,TUe=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
- gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
- #endif`,CUe=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
- uniform float logDepthBufFC;
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,kUe=`#ifdef USE_LOGDEPTHBUF
- #ifdef USE_LOGDEPTHBUF_EXT
- varying float vFragDepth;
- varying float vIsPerspective;
- #else
- uniform float logDepthBufFC;
- #endif
- #endif`,jUe=`#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`,PUe=`#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`,RUe=`#ifdef USE_MAP
- uniform sampler2D map;
- #endif`,DUe=`#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`,OUe=`#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`,LUe=`float metalnessFactor = metalness;
- #ifdef USE_METALNESSMAP
- vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
- metalnessFactor *= texelMetalness.b;
- #endif`,IUe=`#ifdef USE_METALNESSMAP
- uniform sampler2D metalnessMap;
- #endif`,FUe=`#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`,UUe=`#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`,zUe=`#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`,BUe=`#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`,$Ue=`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;`,HUe=`#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`,VUe=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,GUe=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,WUe=`#ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #ifdef USE_TANGENT
- vTangent = normalize( transformedTangent );
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
- #endif
- #endif`,qUe=`#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`,KUe=`#ifdef USE_CLEARCOAT
- vec3 clearcoatNormal = nonPerturbedNormal;
- #endif`,XUe=`#ifdef USE_CLEARCOAT_NORMALMAP
- vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
- clearcoatMapN.xy *= clearcoatNormalScale;
- clearcoatNormal = normalize( tbn2 * clearcoatMapN );
- #endif`,YUe=`#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`,ZUe=`#ifdef USE_IRIDESCENCEMAP
- uniform sampler2D iridescenceMap;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform sampler2D iridescenceThicknessMap;
- #endif`,QUe=`#ifdef OPAQUE
- diffuseColor.a = 1.0;
- #endif
- #ifdef USE_TRANSMISSION
- diffuseColor.a *= material.transmissionAlpha;
- #endif
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,JUe=`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 );
- }`,eze=`#ifdef PREMULTIPLIED_ALPHA
- gl_FragColor.rgb *= gl_FragColor.a;
- #endif`,tze=`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;`,nze=`#ifdef DITHERING
- gl_FragColor.rgb = dithering( gl_FragColor.rgb );
- #endif`,rze=`#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`,ize=`float roughnessFactor = roughness;
- #ifdef USE_ROUGHNESSMAP
- vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
- roughnessFactor *= texelRoughness.g;
- #endif`,aze=`#ifdef USE_ROUGHNESSMAP
- uniform sampler2D roughnessMap;
- #endif`,sze=`#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`,oze=`#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`,lze=`#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`,cze=`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;
- }`,uze=`#ifdef USE_SKINNING
- mat4 boneMatX = getBoneMatrix( skinIndex.x );
- mat4 boneMatY = getBoneMatrix( skinIndex.y );
- mat4 boneMatZ = getBoneMatrix( skinIndex.z );
- mat4 boneMatW = getBoneMatrix( skinIndex.w );
- #endif`,dze=`#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`,hze=`#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`,fze=`#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`,mze=`float specularStrength;
- #ifdef USE_SPECULARMAP
- vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
- specularStrength = texelSpecular.r;
- #else
- specularStrength = 1.0;
- #endif`,pze=`#ifdef USE_SPECULARMAP
- uniform sampler2D specularMap;
- #endif`,gze=`#if defined( TONE_MAPPING )
- gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
- #endif`,xze=`#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; }`,bze=`#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`,yze=`#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`,vze=`#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`,_ze=`#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`,wze=`#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`,Sze=`#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 Mze=`varying vec2 vUv;
- uniform mat3 uvTransform;
- void main() {
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- gl_Position = vec4( position.xy, 1.0, 1.0 );
- }`,Nze=`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>
- }`,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=`#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>
- }`,Tze=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,Cze=`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>
- }`,kze=`#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;
- }`,jze=`#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
- }`,Pze=`#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;
- }`,Rze=`#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 );
- }`,Dze=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }`,Oze=`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>
- }`,Lze=`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>
- }`,Ize=`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>
- }`,Fze=`#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>
- }`,Uze=`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>
- }`,zze=`#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>
- }`,Bze=`#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>
- }`,$ze=`#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;
- }`,Hze=`#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>
- }`,Vze=`#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
- }`,Gze=`#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
- }`,Wze=`#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>
- }`,qze=`#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>
- }`,Kze=`#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
- }`,Xze=`#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>
- }`,Yze=`#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>
- }`,Zze=`#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>
- }`,Qze=`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>
- }`,Jze=`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>
- }`,eBe=`#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>
- }`,tBe=`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>
- }`,nBe=`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>
- }`,rBe=`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>
- }`,Mn={alphahash_fragment:N5e,alphahash_pars_fragment:E5e,alphamap_fragment:A5e,alphamap_pars_fragment:T5e,alphatest_fragment:C5e,alphatest_pars_fragment:k5e,aomap_fragment:j5e,aomap_pars_fragment:P5e,batching_pars_vertex:R5e,batching_vertex:D5e,begin_vertex:O5e,beginnormal_vertex:L5e,bsdfs:I5e,iridescence_fragment:F5e,bumpmap_pars_fragment:U5e,clipping_planes_fragment:z5e,clipping_planes_pars_fragment:B5e,clipping_planes_pars_vertex:$5e,clipping_planes_vertex:H5e,color_fragment:V5e,color_pars_fragment:G5e,color_pars_vertex:W5e,color_vertex:q5e,common:K5e,cube_uv_reflection_fragment:X5e,defaultnormal_vertex:Y5e,displacementmap_pars_vertex:Z5e,displacementmap_vertex:Q5e,emissivemap_fragment:J5e,emissivemap_pars_fragment:eUe,colorspace_fragment:tUe,colorspace_pars_fragment:nUe,envmap_fragment:rUe,envmap_common_pars_fragment:iUe,envmap_pars_fragment:aUe,envmap_pars_vertex:sUe,envmap_physical_pars_fragment:bUe,envmap_vertex:oUe,fog_vertex:lUe,fog_pars_vertex:cUe,fog_fragment:uUe,fog_pars_fragment:dUe,gradientmap_pars_fragment:hUe,lightmap_fragment:fUe,lightmap_pars_fragment:mUe,lights_lambert_fragment:pUe,lights_lambert_pars_fragment:gUe,lights_pars_begin:xUe,lights_toon_fragment:yUe,lights_toon_pars_fragment:vUe,lights_phong_fragment:_Ue,lights_phong_pars_fragment:wUe,lights_physical_fragment:SUe,lights_physical_pars_fragment:MUe,lights_fragment_begin:NUe,lights_fragment_maps:EUe,lights_fragment_end:AUe,logdepthbuf_fragment:TUe,logdepthbuf_pars_fragment:CUe,logdepthbuf_pars_vertex:kUe,logdepthbuf_vertex:jUe,map_fragment:PUe,map_pars_fragment:RUe,map_particle_fragment:DUe,map_particle_pars_fragment:OUe,metalnessmap_fragment:LUe,metalnessmap_pars_fragment:IUe,morphcolor_vertex:FUe,morphnormal_vertex:UUe,morphtarget_pars_vertex:zUe,morphtarget_vertex:BUe,normal_fragment_begin:$Ue,normal_fragment_maps:HUe,normal_pars_fragment:VUe,normal_pars_vertex:GUe,normal_vertex:WUe,normalmap_pars_fragment:qUe,clearcoat_normal_fragment_begin:KUe,clearcoat_normal_fragment_maps:XUe,clearcoat_pars_fragment:YUe,iridescence_pars_fragment:ZUe,opaque_fragment:QUe,packing:JUe,premultiplied_alpha_fragment:eze,project_vertex:tze,dithering_fragment:nze,dithering_pars_fragment:rze,roughnessmap_fragment:ize,roughnessmap_pars_fragment:aze,shadowmap_pars_fragment:sze,shadowmap_pars_vertex:oze,shadowmap_vertex:lze,shadowmask_pars_fragment:cze,skinbase_vertex:uze,skinning_pars_vertex:dze,skinning_vertex:hze,skinnormal_vertex:fze,specularmap_fragment:mze,specularmap_pars_fragment:pze,tonemapping_fragment:gze,tonemapping_pars_fragment:xze,transmission_fragment:bze,transmission_pars_fragment:yze,uv_pars_fragment:vze,uv_pars_vertex:_ze,uv_vertex:wze,worldpos_vertex:Sze,background_vert:Mze,background_frag:Nze,backgroundCube_vert:Eze,backgroundCube_frag:Aze,cube_vert:Tze,cube_frag:Cze,depth_vert:kze,depth_frag:jze,distanceRGBA_vert:Pze,distanceRGBA_frag:Rze,equirect_vert:Dze,equirect_frag:Oze,linedashed_vert:Lze,linedashed_frag:Ize,meshbasic_vert:Fze,meshbasic_frag:Uze,meshlambert_vert:zze,meshlambert_frag:Bze,meshmatcap_vert:$ze,meshmatcap_frag:Hze,meshnormal_vert:Vze,meshnormal_frag:Gze,meshphong_vert:Wze,meshphong_frag:qze,meshphysical_vert:Kze,meshphysical_frag:Xze,meshtoon_vert:Yze,meshtoon_frag:Zze,points_vert:Qze,points_frag:Jze,shadow_vert:eBe,shadow_frag:tBe,sprite_vert:nBe,sprite_frag:rBe},Dt={common:{diffuse:{value:new rn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Cn},alphaMap:{value:null},alphaMapTransform:{value:new Cn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Cn}},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 Cn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Cn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Cn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Cn},normalScale:{value:new mn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Cn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Cn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Cn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Cn}},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 Cn},alphaTest:{value:0},uvTransform:{value:new Cn}},sprite:{diffuse:{value:new rn(16777215)},opacity:{value:1},center:{value:new mn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Cn},alphaMap:{value:null},alphaMapTransform:{value:new Cn},alphaTest:{value:0}}},ys={basic:{uniforms:Xa([Dt.common,Dt.specularmap,Dt.envmap,Dt.aomap,Dt.lightmap,Dt.fog]),vertexShader:Mn.meshbasic_vert,fragmentShader:Mn.meshbasic_frag},lambert:{uniforms:Xa([Dt.common,Dt.specularmap,Dt.envmap,Dt.aomap,Dt.lightmap,Dt.emissivemap,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,Dt.fog,Dt.lights,{emissive:{value:new rn(0)}}]),vertexShader:Mn.meshlambert_vert,fragmentShader:Mn.meshlambert_frag},phong:{uniforms:Xa([Dt.common,Dt.specularmap,Dt.envmap,Dt.aomap,Dt.lightmap,Dt.emissivemap,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,Dt.fog,Dt.lights,{emissive:{value:new rn(0)},specular:{value:new rn(1118481)},shininess:{value:30}}]),vertexShader:Mn.meshphong_vert,fragmentShader:Mn.meshphong_frag},standard:{uniforms:Xa([Dt.common,Dt.envmap,Dt.aomap,Dt.lightmap,Dt.emissivemap,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,Dt.roughnessmap,Dt.metalnessmap,Dt.fog,Dt.lights,{emissive:{value:new rn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Mn.meshphysical_vert,fragmentShader:Mn.meshphysical_frag},toon:{uniforms:Xa([Dt.common,Dt.aomap,Dt.lightmap,Dt.emissivemap,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,Dt.gradientmap,Dt.fog,Dt.lights,{emissive:{value:new rn(0)}}]),vertexShader:Mn.meshtoon_vert,fragmentShader:Mn.meshtoon_frag},matcap:{uniforms:Xa([Dt.common,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,Dt.fog,{matcap:{value:null}}]),vertexShader:Mn.meshmatcap_vert,fragmentShader:Mn.meshmatcap_frag},points:{uniforms:Xa([Dt.points,Dt.fog]),vertexShader:Mn.points_vert,fragmentShader:Mn.points_frag},dashed:{uniforms:Xa([Dt.common,Dt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Mn.linedashed_vert,fragmentShader:Mn.linedashed_frag},depth:{uniforms:Xa([Dt.common,Dt.displacementmap]),vertexShader:Mn.depth_vert,fragmentShader:Mn.depth_frag},normal:{uniforms:Xa([Dt.common,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,{opacity:{value:1}}]),vertexShader:Mn.meshnormal_vert,fragmentShader:Mn.meshnormal_frag},sprite:{uniforms:Xa([Dt.sprite,Dt.fog]),vertexShader:Mn.sprite_vert,fragmentShader:Mn.sprite_frag},background:{uniforms:{uvTransform:{value:new Cn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Mn.background_vert,fragmentShader:Mn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:Mn.backgroundCube_vert,fragmentShader:Mn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Mn.cube_vert,fragmentShader:Mn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Mn.equirect_vert,fragmentShader:Mn.equirect_frag},distanceRGBA:{uniforms:Xa([Dt.common,Dt.displacementmap,{referencePosition:{value:new Be},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Mn.distanceRGBA_vert,fragmentShader:Mn.distanceRGBA_frag},shadow:{uniforms:Xa([Dt.lights,Dt.fog,{color:{value:new rn(0)},opacity:{value:1}}]),vertexShader:Mn.shadow_vert,fragmentShader:Mn.shadow_frag}};ys.physical={uniforms:Xa([ys.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Cn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Cn},clearcoatNormalScale:{value:new mn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Cn},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Cn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Cn},sheen:{value:0},sheenColor:{value:new rn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Cn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Cn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Cn},transmissionSamplerSize:{value:new mn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Cn},attenuationDistance:{value:0},attenuationColor:{value:new rn(0)},specularColor:{value:new rn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Cn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Cn},anisotropyVector:{value:new mn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Cn}}]),vertexShader:Mn.meshphysical_vert,fragmentShader:Mn.meshphysical_frag};const Aw={r:0,b:0,g:0};function iBe(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 A=t.xr.getEnvironmentBlendMode();A==="additive"?r.buffers.color.setClear(0,0,0,1,o):A==="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===gE)?(d===void 0&&(d=new al(new Qy(1,1,1),new oh({name:"BackgroundCubeMaterial",uniforms:Fg(ys.backgroundCube.uniforms),vertexShader:ys.backgroundCube.vertexShader,fragmentShader:ys.backgroundCube.fragmentShader,side:Ns,depthTest:!1,depthWrite:!1,fog:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(T,k,E){this.matrixWorld.copyPosition(E.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=mr.getTransfer(M.colorSpace)!==Cr,(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 al(new SL(2,2),new oh({name:"BackgroundMaterial",uniforms:Fg(ys.background.uniforms),vertexShader:ys.background.vertexShader,fragmentShader:ys.background.fragmentShader,side:sh,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=mr.getTransfer(M.colorSpace)!==Cr,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(Aw,lte(t)),r.buffers.color.setClear(Aw.r,Aw.g,Aw.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 aBe(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(P,W,K,V,Q){let re=!1;if(o){const J=y(V,K,W);u!==J&&(u=J,p(u.object)),re=v(P,V,K,Q),re&&S(P,V,K,Q)}else{const J=W.wireframe===!0;(u.geometry!==V.id||u.program!==K.id||u.wireframe!==J)&&(u.geometry=V.id,u.program=K.id,u.wireframe=J,re=!0)}Q!==null&&n.update(Q,t.ELEMENT_ARRAY_BUFFER),(re||d)&&(d=!1,O(P,W,K,V),Q!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n.get(Q).buffer))}function m(){return r.isWebGL2?t.createVertexArray():a.createVertexArrayOES()}function p(P){return r.isWebGL2?t.bindVertexArray(P):a.bindVertexArrayOES(P)}function b(P){return r.isWebGL2?t.deleteVertexArray(P):a.deleteVertexArrayOES(P)}function y(P,W,K){const V=K.wireframe===!0;let Q=l[P.id];Q===void 0&&(Q={},l[P.id]=Q);let re=Q[W.id];re===void 0&&(re={},Q[W.id]=re);let J=re[V];return J===void 0&&(J=x(m()),re[V]=J),J}function x(P){const W=[],K=[],V=[];for(let Q=0;Q<i;Q++)W[Q]=0,K[Q]=0,V[Q]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:W,enabledAttributes:K,attributeDivisors:V,object:P,attributes:{},index:null}}function v(P,W,K,V){const Q=u.attributes,re=W.attributes;let J=0;const z=K.getAttributes();for(const G in z)if(z[G].location>=0){const ae=Q[G];let de=re[G];if(de===void 0&&(G==="instanceMatrix"&&P.instanceMatrix&&(de=P.instanceMatrix),G==="instanceColor"&&P.instanceColor&&(de=P.instanceColor)),ae===void 0||ae.attribute!==de||de&&ae.data!==de.data)return!0;J++}return u.attributesNum!==J||u.index!==V}function S(P,W,K,V){const Q={},re=W.attributes;let J=0;const z=K.getAttributes();for(const G in z)if(z[G].location>=0){let ae=re[G];ae===void 0&&(G==="instanceMatrix"&&P.instanceMatrix&&(ae=P.instanceMatrix),G==="instanceColor"&&P.instanceColor&&(ae=P.instanceColor));const de={};de.attribute=ae,ae&&ae.data&&(de.data=ae.data),Q[G]=de,J++}u.attributes=Q,u.attributesNum=J,u.index=V}function M(){const P=u.newAttributes;for(let W=0,K=P.length;W<K;W++)P[W]=0}function A(P){T(P,0)}function T(P,W){const K=u.newAttributes,V=u.enabledAttributes,Q=u.attributeDivisors;K[P]=1,V[P]===0&&(t.enableVertexAttribArray(P),V[P]=1),Q[P]!==W&&((r.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](P,W),Q[P]=W)}function k(){const P=u.newAttributes,W=u.enabledAttributes;for(let K=0,V=W.length;K<V;K++)W[K]!==P[K]&&(t.disableVertexAttribArray(K),W[K]=0)}function E(P,W,K,V,Q,re,J){J===!0?t.vertexAttribIPointer(P,W,K,Q,re):t.vertexAttribPointer(P,W,K,V,Q,re)}function O(P,W,K,V){if(r.isWebGL2===!1&&(P.isInstancedMesh||V.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;M();const Q=V.attributes,re=K.getAttributes(),J=W.defaultAttributeValues;for(const z in re){const G=re[z];if(G.location>=0){let ne=Q[z];if(ne===void 0&&(z==="instanceMatrix"&&P.instanceMatrix&&(ne=P.instanceMatrix),z==="instanceColor"&&P.instanceColor&&(ne=P.instanceColor)),ne!==void 0){const ae=ne.normalized,de=ne.itemSize,fe=n.get(ne);if(fe===void 0)continue;const ie=fe.buffer,Ae=fe.type,me=fe.bytesPerElement,Ne=r.isWebGL2===!0&&(Ae===t.INT||Ae===t.UNSIGNED_INT||ne.gpuType===$ee);if(ne.isInterleavedBufferAttribute){const ye=ne.data,le=ye.stride,$e=ne.offset;if(ye.isInstancedInterleavedBuffer){for(let H=0;H<G.locationSize;H++)T(G.location+H,ye.meshPerAttribute);P.isInstancedMesh!==!0&&V._maxInstanceCount===void 0&&(V._maxInstanceCount=ye.meshPerAttribute*ye.count)}else for(let H=0;H<G.locationSize;H++)A(G.location+H);t.bindBuffer(t.ARRAY_BUFFER,ie);for(let H=0;H<G.locationSize;H++)E(G.location+H,de/G.locationSize,Ae,ae,le*me,($e+de/G.locationSize*H)*me,Ne)}else{if(ne.isInstancedBufferAttribute){for(let ye=0;ye<G.locationSize;ye++)T(G.location+ye,ne.meshPerAttribute);P.isInstancedMesh!==!0&&V._maxInstanceCount===void 0&&(V._maxInstanceCount=ne.meshPerAttribute*ne.count)}else for(let ye=0;ye<G.locationSize;ye++)A(G.location+ye);t.bindBuffer(t.ARRAY_BUFFER,ie);for(let ye=0;ye<G.locationSize;ye++)E(G.location+ye,de/G.locationSize,Ae,ae,de*me,de/G.locationSize*ye*me,Ne)}}else if(J!==void 0){const ae=J[z];if(ae!==void 0)switch(ae.length){case 2:t.vertexAttrib2fv(G.location,ae);break;case 3:t.vertexAttrib3fv(G.location,ae);break;case 4:t.vertexAttrib4fv(G.location,ae);break;default:t.vertexAttrib1fv(G.location,ae)}}}}k()}function C(){L();for(const P in l){const W=l[P];for(const K in W){const V=W[K];for(const Q in V)b(V[Q].object),delete V[Q];delete W[K]}delete l[P]}}function D(P){if(l[P.id]===void 0)return;const W=l[P.id];for(const K in W){const V=W[K];for(const Q in V)b(V[Q].object),delete V[Q];delete W[K]}delete l[P.id]}function U(P){for(const W in l){const K=l[W];if(K[P.id]===void 0)continue;const V=K[P.id];for(const Q in V)b(V[Q].object),delete V[Q];delete K[P.id]}}function L(){q(),d=!0,u!==c&&(u=c,p(u.object))}function q(){c.geometry=null,c.program=null,c.wireframe=!1}return{setup:f,reset:L,resetDefaultState:q,dispose:C,releaseStatesOfGeometry:D,releaseStatesOfProgram:U,initAttributes:M,enableAttribute:A,disableUnusedAttributes:k}}function sBe(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 oBe(t,e,n){let r;function i(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const E=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(E.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(E){if(E==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";E="mediump"}return E==="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,A=o||e.has("OES_texture_float"),T=M&&A,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:A,floatVertexTextures:T,maxSamples:k}}function lBe(t){const e=this;let n=null,r=0,i=!1,a=!1;const o=new wd,l=new Cn,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 A=v.clippingState||null;c.value=A,A=d(b,m,M,p);for(let T=0;T!==M;++T)A[T]=n[T];v.clippingState=A,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,A=p;M!==y;++M,A+=4)o.copy(f[M]).applyMatrix4(S,l),o.normal.toArray(x,A),x[A+3]=o.constant}c.value=x,c.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,x}}function cBe(t){let e=new WeakMap;function n(o,l){return l===AR?o.mapping=Og:l===TR&&(o.mapping=Lg),o}function r(o){if(o&&o.isTexture){const l=o.mapping;if(l===AR||l===TR)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 _5e(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 uBe extends cte{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 tg=4,T7=[.125,.215,.35,.446,.526,.582],cf=20,Jk=new uBe,C7=new rn;let ej=null,tj=0,nj=0;const af=(1+Math.sqrt(5))/2,Lp=1/af,k7=[new Be(1,1,1),new Be(-1,1,1),new Be(1,1,-1),new Be(-1,1,-1),new Be(0,af,Lp),new Be(0,af,-Lp),new Be(Lp,0,af),new Be(-Lp,0,af),new Be(af,Lp,0),new Be(-af,Lp,0)];class j7{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){ej=this._renderer.getRenderTarget(),tj=this._renderer.getActiveCubeFace(),nj=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=D7(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=R7(),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(ej,tj,nj),e.scissorTest=!1,Tw(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===Og||e.mapping===Lg?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),ej=this._renderer.getRenderTarget(),tj=this._renderer.getActiveCubeFace(),nj=this._renderer.getActiveMipmapLevel();const r=n||this._allocateTargets();return this._textureToCubeUV(e,r),this._applyPMREM(r),this._cleanup(r),r}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),n=4*this._cubeSize,r={magFilter:No,minFilter:No,generateMipmaps:!1,type:ry,format:Eo,colorSpace:Nu,depthBuffer:!1},i=P7(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=P7(e,n,r);const{_lodMax:a}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=dBe(a)),this._blurMaterial=hBe(a,e,n)}return i}_compileMaterial(e){const n=new al(this._lodPlanes[0],e);this._renderer.compile(n,Jk)}_sceneToCubeUV(e,n,r,i){const l=new $s(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(C7),d.toneMapping=Wd,d.autoClear=!1;const p=new ate({name:"PMREM.Background",side:Ns,depthWrite:!1,depthTest:!1}),b=new al(new Qy,p);let y=!1;const x=e.background;x?x.isColor&&(p.color.copy(x),e.background=null,y=!0):(p.color.copy(C7),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;Tw(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===Og||e.mapping===Lg;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=D7()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=R7());const a=i?this._cubemapMaterial:this._equirectMaterial,o=new al(this._lodPlanes[0],a),l=a.uniforms;l.envMap.value=e;const c=this._cubeSize;Tw(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(o,Jk)}_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=k7[(i-1)%k7.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 al(this._lodPlanes[i],u),m=u.uniforms,p=this._sizeLods[r]-1,b=isFinite(a)?Math.PI/(2*p):2*Math.PI/(2*cf-1),y=a/b,x=isFinite(a)?1+Math.floor(d*y):cf;x>cf&&console.warn(`sigmaRadians, ${a}, is too large and will clip, as it requested ${x} samples when the maximum is set to ${cf}`);const v=[];let S=0;for(let E=0;E<cf;++E){const O=E/y,C=Math.exp(-O*O/2);v.push(C),E===0?S+=C:E<x&&(S+=2*C)}for(let E=0;E<v.length;E++)v[E]=v[E]/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 A=this._sizeLods[i],T=3*A*(i>M-tg?i-M+tg:0),k=4*(this._cubeSize-A);Tw(n,T,k,3*A,2*A),c.setRenderTarget(n),c.render(f,Jk)}}function dBe(t){const e=[],n=[],r=[];let i=t;const a=t-tg+1+T7.length;for(let o=0;o<a;o++){const l=Math.pow(2,i);n.push(l);let c=1/l;o>t-tg?c=T7[o-t+tg-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),A=new Float32Array(v*b*p);for(let k=0;k<p;k++){const E=k%3*2/3-1,O=k>2?0:-1,C=[E,O,0,E+2/3,O,0,E+2/3,O+1,0,E,O,0,E+2/3,O+1,0,E,O+1,0];S.set(C,y*b*k),M.set(m,x*b*k);const D=[k,k,k,k,k,k];A.set(D,v*b*k)}const T=new Va;T.setAttribute("position",new Zs(S,y)),T.setAttribute("uv",new Zs(M,x)),T.setAttribute("faceIndex",new Zs(A,v)),e.push(T),i>tg&&i--}return{lodPlanes:e,sizeLods:n,sigmas:r}}function P7(t,e,n){const r=new sm(t,e,n);return r.texture.mapping=gE,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function Tw(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function hBe(t,e,n){const r=new Float32Array(cf),i=new Be(0,1,0);return new oh({name:"SphericalGaussianBlur",defines:{n:cf,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:ML(),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:Gd,depthTest:!1,depthWrite:!1})}function R7(){return new oh({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:ML(),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:Gd,depthTest:!1,depthWrite:!1})}function D7(){return new oh({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:ML(),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:Gd,depthTest:!1,depthWrite:!1})}function ML(){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 fBe(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,u=c===AR||c===TR,d=c===Og||c===Lg;if(u||d)if(l.isRenderTargetTexture&&l.needsPMREMUpdate===!0){l.needsPMREMUpdate=!1;let f=e.get(l);return n===null&&(n=new j7(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 j7(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 mBe(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 pBe(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,A=S.length;M<A;M+=3){const T=S[M+0],k=S[M+1],E=S[M+2];m.push(T,k,k,E,E,T)}}else if(b!==void 0){const S=b.array;y=b.version;for(let M=0,A=S.length/3-1;M<A;M+=3){const T=M+0,k=M+1,E=M+2;m.push(T,k,k,E,E,T)}}else return;const x=new(Jee(m)?ote:ste)(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 gBe(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 xBe(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 bBe(t,e){return t[0]-e[0]}function yBe(t,e){return Math.abs(e[1])-Math.abs(t[1])}function vBe(t,e,n){const r={},i=new Float32Array(8),a=new WeakMap,o=new gr,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,A=d.morphAttributes.normal!==void 0,T=d.morphAttributes.color!==void 0,k=d.morphAttributes.position||[],E=d.morphAttributes.normal||[],O=d.morphAttributes.color||[];let C=0;M===!0&&(C=1),A===!0&&(C=2),T===!0&&(C=3);let D=d.attributes.position.count*C,U=1;D>e.maxTextureSize&&(U=Math.ceil(D/e.maxTextureSize),D=e.maxTextureSize);const L=new Float32Array(D*U*4*y),q=new nte(L,D,U,y);q.type=ru,q.needsUpdate=!0;const P=C*4;for(let K=0;K<y;K++){const V=k[K],Q=E[K],re=O[K],J=D*U*4*K;for(let z=0;z<V.count;z++){const G=z*P;M===!0&&(o.fromBufferAttribute(V,z),L[J+G+0]=o.x,L[J+G+1]=o.y,L[J+G+2]=o.z,L[J+G+3]=0),A===!0&&(o.fromBufferAttribute(Q,z),L[J+G+4]=o.x,L[J+G+5]=o.y,L[J+G+6]=o.z,L[J+G+7]=0),T===!0&&(o.fromBufferAttribute(re,z),L[J+G+8]=o.x,L[J+G+9]=o.y,L[J+G+10]=o.z,L[J+G+11]=re.itemSize===4?o.w:1)}}x={count:y,texture:q,size:new mn(D,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 A=0;A<b;A++)y[A]=[A,0];r[d.id]=y}for(let A=0;A<b;A++){const T=y[A];T[0]=A,T[1]=m[A]}y.sort(yBe);for(let A=0;A<8;A++)A<b&&y[A][1]?(l[A][0]=y[A][0],l[A][1]=y[A][1]):(l[A][0]=Number.MAX_SAFE_INTEGER,l[A][1]=0);l.sort(bBe);const x=d.morphAttributes.position,v=d.morphAttributes.normal;let S=0;for(let A=0;A<8;A++){const T=l[A],k=T[0],E=T[1];k!==Number.MAX_SAFE_INTEGER&&E?(x&&d.getAttribute("morphTarget"+A)!==x[k]&&d.setAttribute("morphTarget"+A,x[k]),v&&d.getAttribute("morphNormal"+A)!==v[k]&&d.setAttribute("morphNormal"+A,v[k]),i[A]=E,S+=E):(x&&d.hasAttribute("morphTarget"+A)===!0&&d.deleteAttribute("morphTarget"+A),v&&d.hasAttribute("morphNormal"+A)===!0&&d.deleteAttribute("morphNormal"+A),i[A]=0)}const M=d.morphTargetsRelative?1:1-S;f.getUniforms().setValue(t,"morphTargetBaseInfluence",M),f.getUniforms().setValue(t,"morphTargetInfluences",i)}}return{update:c}}function _Be(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 hte extends Es{constructor(e,n,r,i,a,o,l,c,u,d){if(d=d!==void 0?d:Rf,d!==Rf&&d!==Ig)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&d===Rf&&(r=Dd),r===void 0&&d===Ig&&(r=Pf),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:_a,this.minFilter=c!==void 0?c:_a,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 fte=new Es,mte=new hte(1,1);mte.compareFunction=Zee;const pte=new nte,gte=new a5e,xte=new ute,O7=[],L7=[],I7=new Float32Array(16),F7=new Float32Array(9),U7=new Float32Array(4);function px(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let a=O7[i];if(a===void 0&&(a=new Float32Array(i),O7[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 yE(t,e){let n=L7[e];n===void 0&&(n=new Int32Array(e),L7[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function wBe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function SBe(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 MBe(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 NBe(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 EBe(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;U7.set(r),t.uniformMatrix2fv(this.addr,!1,U7),Ui(n,r)}}function ABe(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;F7.set(r),t.uniformMatrix3fv(this.addr,!1,F7),Ui(n,r)}}function TBe(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;I7.set(r),t.uniformMatrix4fv(this.addr,!1,I7),Ui(n,r)}}function CBe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function kBe(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 jBe(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 PBe(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 RBe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function DBe(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 OBe(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 LBe(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 IBe(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?mte:fte;n.setTexture2D(e||a,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.setTexture3D(e||gte,i)}function UBe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||xte,i)}function zBe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||pte,i)}function BBe(t){switch(t){case 5126:return wBe;case 35664:return SBe;case 35665:return MBe;case 35666:return NBe;case 35674:return EBe;case 35675:return ABe;case 35676:return TBe;case 5124:case 35670:return CBe;case 35667:case 35671:return kBe;case 35668:case 35672:return jBe;case 35669:case 35673:return PBe;case 5125:return RBe;case 36294:return DBe;case 36295:return OBe;case 36296:return LBe;case 35678:case 36198:case 36298:case 36306:case 35682:return IBe;case 35679:case 36299:case 36307:return FBe;case 35680:case 36300:case 36308:case 36293:return UBe;case 36289:case 36303:case 36311:case 36292:return zBe}}function $Be(t,e){t.uniform1fv(this.addr,e)}function HBe(t,e){const n=px(e,this.size,2);t.uniform2fv(this.addr,n)}function VBe(t,e){const n=px(e,this.size,3);t.uniform3fv(this.addr,n)}function GBe(t,e){const n=px(e,this.size,4);t.uniform4fv(this.addr,n)}function WBe(t,e){const n=px(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function qBe(t,e){const n=px(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function KBe(t,e){const n=px(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function XBe(t,e){t.uniform1iv(this.addr,e)}function YBe(t,e){t.uniform2iv(this.addr,e)}function ZBe(t,e){t.uniform3iv(this.addr,e)}function QBe(t,e){t.uniform4iv(this.addr,e)}function JBe(t,e){t.uniform1uiv(this.addr,e)}function e8e(t,e){t.uniform2uiv(this.addr,e)}function t8e(t,e){t.uniform3uiv(this.addr,e)}function n8e(t,e){t.uniform4uiv(this.addr,e)}function r8e(t,e,n){const r=this.cache,i=e.length,a=yE(n,i);Fi(r,a)||(t.uniform1iv(this.addr,a),Ui(r,a));for(let o=0;o!==i;++o)n.setTexture2D(e[o]||fte,a[o])}function i8e(t,e,n){const r=this.cache,i=e.length,a=yE(n,i);Fi(r,a)||(t.uniform1iv(this.addr,a),Ui(r,a));for(let o=0;o!==i;++o)n.setTexture3D(e[o]||gte,a[o])}function a8e(t,e,n){const r=this.cache,i=e.length,a=yE(n,i);Fi(r,a)||(t.uniform1iv(this.addr,a),Ui(r,a));for(let o=0;o!==i;++o)n.setTextureCube(e[o]||xte,a[o])}function s8e(t,e,n){const r=this.cache,i=e.length,a=yE(n,i);Fi(r,a)||(t.uniform1iv(this.addr,a),Ui(r,a));for(let o=0;o!==i;++o)n.setTexture2DArray(e[o]||pte,a[o])}function o8e(t){switch(t){case 5126:return $Be;case 35664:return HBe;case 35665:return VBe;case 35666:return GBe;case 35674:return WBe;case 35675:return qBe;case 35676:return KBe;case 5124:case 35670:return XBe;case 35667:case 35671:return YBe;case 35668:case 35672:return ZBe;case 35669:case 35673:return QBe;case 5125:return JBe;case 36294:return e8e;case 36295:return t8e;case 36296:return n8e;case 35678:case 36198:case 36298:case 36306:case 35682:return r8e;case 35679:case 36299:case 36307:return i8e;case 35680:case 36300:case 36308:case 36293:return a8e;case 36289:case 36303:case 36311:case 36292:return s8e}}class l8e{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=BBe(n.type)}}class c8e{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=o8e(n.type)}}class u8e{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 rj=/(\w+)(\])?(\[|\.)?/g;function z7(t,e){t.seq.push(e),t.map[e.id]=e}function d8e(t,e,n){const r=t.name,i=r.length;for(rj.lastIndex=0;;){const a=rj.exec(r),o=rj.lastIndex;let l=a[1];const c=a[2]==="]",u=a[3];if(c&&(l=l|0),u===void 0||u==="["&&o+2===i){z7(n,u===void 0?new l8e(l,t,e):new c8e(l,t,e));break}else{let f=n.map[l];f===void 0&&(f=new u8e(l),z7(n,f)),n=f}}}class w1{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);d8e(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 B7(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const h8e=37297;let f8e=0;function m8e(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 p8e(t){const e=mr.getPrimaries(mr.workingColorSpace),n=mr.getPrimaries(t);let r;switch(e===n?r="":e===ZS&&n===YS?r="LinearDisplayP3ToLinearSRGB":e===YS&&n===ZS&&(r="LinearSRGBToLinearDisplayP3"),t){case Nu:case xE:return[r,"LinearTransferOETF"];case wa:case yL:return[r,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",t),[r,"LinearTransferOETF"]}}function $7(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+`
- `+m8e(t.getShaderSource(e),o)}else return i}function g8e(t,e){const n=p8e(e);return`vec4 ${t}( vec4 value ) { return ${n[0]}( ${n[1]}( value ) ); }`}function x8e(t,e){let n;switch(e){case gFe:n="Linear";break;case xFe:n="Reinhard";break;case bFe:n="OptimizedCineon";break;case yFe:n="ACESFilmic";break;case vFe:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function b8e(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(Kb).join(`
- `)}function y8e(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
- `)}function v8e(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 Kb(t){return t!==""}function H7(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 V7(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const _8e=/^[ \t]*#include +<([\w\d./]+)>/gm;function DR(t){return t.replace(_8e,S8e)}const w8e=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function S8e(t,e){let n=Mn[e];if(n===void 0){const r=w8e.get(e);if(r!==void 0)n=Mn[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 DR(n)}const M8e=/#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 G7(t){return t.replace(M8e,N8e)}function N8e(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 W7(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 E8e(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===zee?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===VIe?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===Wc&&(e="SHADOWMAP_TYPE_VSM"),e}function A8e(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case Og:case Lg:e="ENVMAP_TYPE_CUBE";break;case gE:e="ENVMAP_TYPE_CUBE_UV";break}return e}function T8e(t){let e="ENVMAP_MODE_REFLECTION";return t.envMap&&t.envMapMode===Lg&&(e="ENVMAP_MODE_REFRACTION"),e}function C8e(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case xL:e="ENVMAP_BLENDING_MULTIPLY";break;case mFe:e="ENVMAP_BLENDING_MIX";break;case pFe:e="ENVMAP_BLENDING_ADD";break}return e}function k8e(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 j8e(t,e,n,r){const i=t.getContext(),a=n.defines;let o=n.vertexShader,l=n.fragmentShader;const c=E8e(n),u=A8e(n),d=T8e(n),f=C8e(n),m=k8e(n),p=n.isWebGL2?"":b8e(n),b=y8e(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(Kb).join(`
- `),x.length>0&&(x+=`
- `),v=[p,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(Kb).join(`
- `),v.length>0&&(v+=`
- `)):(x=[W7(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(Kb).join(`
- `),v=[p,W7(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!==Wd?"#define TONE_MAPPING":"",n.toneMapping!==Wd?Mn.tonemapping_pars_fragment:"",n.toneMapping!==Wd?x8e("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Mn.colorspace_pars_fragment,g8e("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
- `].filter(Kb).join(`
- `)),o=DR(o),o=H7(o,n),o=V7(o,n),l=DR(l),l=H7(l,n),l=V7(l,n),o=G7(o),l=G7(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===u7?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===u7?"":"#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,A=S+v+l,T=B7(i,i.VERTEX_SHADER,M),k=B7(i,i.FRAGMENT_SHADER,A);i.attachShader(y,T),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 E(U){if(t.debug.checkShaderErrors){const L=i.getProgramInfoLog(y).trim(),q=i.getShaderInfoLog(T).trim(),P=i.getShaderInfoLog(k).trim();let W=!0,K=!0;if(i.getProgramParameter(y,i.LINK_STATUS)===!1)if(W=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,y,T,k);else{const V=$7(i,T,"vertex"),Q=$7(i,k,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(y,i.VALIDATE_STATUS)+`
- Program Info Log: `+L+`
- `+V+`
- `+Q)}else L!==""?console.warn("THREE.WebGLProgram: Program Info Log:",L):(q===""||P==="")&&(K=!1);K&&(U.diagnostics={runnable:W,programLog:L,vertexShader:{log:q,prefix:x},fragmentShader:{log:P,prefix:v}})}i.deleteShader(T),i.deleteShader(k),O=new w1(i,y),C=v8e(i,y)}let O;this.getUniforms=function(){return O===void 0&&E(this),O};let C;this.getAttributes=function(){return C===void 0&&E(this),C};let D=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return D===!1&&(D=i.getProgramParameter(y,h8e)),D},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(y),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=f8e++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=T,this.fragmentShader=k,this}let P8e=0;class R8e{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 D8e(e),n.set(e,r)),r}}class D8e{constructor(e){this.id=P8e++,this.code=e,this.usedTimes=0}}function O8e(t,e,n,r,i,a,o){const l=new rte,c=new R8e,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,D,U,L,q){const P=L.fog,W=q.geometry,K=C.isMeshStandardMaterial?L.environment:null,V=(C.isMeshStandardMaterial?n:e).get(C.envMap||K),Q=V&&V.mapping===gE?V.image.height:null,re=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 J=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,z=J!==void 0?J.length:0;let G=0;W.morphAttributes.position!==void 0&&(G=1),W.morphAttributes.normal!==void 0&&(G=2),W.morphAttributes.color!==void 0&&(G=3);let ne,ae,de,fe;if(re){const ln=ys[re];ne=ln.vertexShader,ae=ln.fragmentShader}else ne=C.vertexShader,ae=C.fragmentShader,c.update(C),de=c.getVertexShaderID(C),fe=c.getFragmentShaderID(C);const ie=t.getRenderTarget(),Ae=q.isInstancedMesh===!0,me=q.isBatchedMesh===!0,Ne=!!C.map,ye=!!C.matcap,le=!!V,$e=!!C.aoMap,H=!!C.lightMap,ee=!!C.bumpMap,X=!!C.normalMap,B=!!C.displacementMap,I=!!C.emissiveMap,ce=!!C.metalnessMap,Te=!!C.roughnessMap,Le=C.anisotropy>0,Ee=C.clearcoat>0,$=C.iridescence>0,j=C.sheen>0,Y=C.transmission>0,ge=Le&&!!C.anisotropyMap,we=Ee&&!!C.clearcoatMap,ve=Ee&&!!C.clearcoatNormalMap,Ze=Ee&&!!C.clearcoatRoughnessMap,Ie=$&&!!C.iridescenceMap,qe=$&&!!C.iridescenceThicknessMap,Je=j&&!!C.sheenColorMap,Qe=j&&!!C.sheenRoughnessMap,oe=!!C.specularMap,te=!!C.specularColorMap,Me=!!C.specularIntensityMap,Fe=Y&&!!C.transmissionMap,ot=Y&&!!C.thicknessMap,se=!!C.gradientMap,je=!!C.alphaMap,xe=C.alphaTest>0,Oe=!!C.alphaHash,Ue=!!C.extensions,Ce=!!W.attributes.uv1,We=!!W.attributes.uv2,pt=!!W.attributes.uv3;let kt=Wd;return C.toneMapped&&(ie===null||ie.isXRRenderTarget===!0)&&(kt=t.toneMapping),{isWebGL2:d,shaderID:re,shaderType:C.type,shaderName:C.name,vertexShader:ne,fragmentShader:ae,defines:C.defines,customVertexShaderID:de,customFragmentShaderID:fe,isRawShaderMaterial:C.isRawShaderMaterial===!0,glslVersion:C.glslVersion,precision:p,batching:me,instancing:Ae,instancingColor:Ae&&q.instanceColor!==null,supportsVertexTextures:m,outputColorSpace:ie===null?t.outputColorSpace:ie.isXRRenderTarget===!0?ie.texture.colorSpace:Nu,map:Ne,matcap:ye,envMap:le,envMapMode:le&&V.mapping,envMapCubeUVHeight:Q,aoMap:$e,lightMap:H,bumpMap:ee,normalMap:X,displacementMap:m&&B,emissiveMap:I,normalMapObjectSpace:X&&C.normalMapType===PFe,normalMapTangentSpace:X&&C.normalMapType===Yee,metalnessMap:ce,roughnessMap:Te,anisotropy:Le,anisotropyMap:ge,clearcoat:Ee,clearcoatMap:we,clearcoatNormalMap:ve,clearcoatRoughnessMap:Ze,iridescence:$,iridescenceMap:Ie,iridescenceThicknessMap:qe,sheen:j,sheenColorMap:Je,sheenRoughnessMap:Qe,specularMap:oe,specularColorMap:te,specularIntensityMap:Me,transmission:Y,transmissionMap:Fe,thicknessMap:ot,gradientMap:se,opaque:C.transparent===!1&&C.blending===hg,alphaMap:je,alphaTest:xe,alphaHash:Oe,combine:C.combine,mapUv:Ne&&y(C.map.channel),aoMapUv:$e&&y(C.aoMap.channel),lightMapUv:H&&y(C.lightMap.channel),bumpMapUv:ee&&y(C.bumpMap.channel),normalMapUv:X&&y(C.normalMap.channel),displacementMapUv:B&&y(C.displacementMap.channel),emissiveMapUv:I&&y(C.emissiveMap.channel),metalnessMapUv:ce&&y(C.metalnessMap.channel),roughnessMapUv:Te&&y(C.roughnessMap.channel),anisotropyMapUv:ge&&y(C.anisotropyMap.channel),clearcoatMapUv:we&&y(C.clearcoatMap.channel),clearcoatNormalMapUv:ve&&y(C.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ze&&y(C.clearcoatRoughnessMap.channel),iridescenceMapUv:Ie&&y(C.iridescenceMap.channel),iridescenceThicknessMapUv:qe&&y(C.iridescenceThicknessMap.channel),sheenColorMapUv:Je&&y(C.sheenColorMap.channel),sheenRoughnessMapUv:Qe&&y(C.sheenRoughnessMap.channel),specularMapUv:oe&&y(C.specularMap.channel),specularColorMapUv:te&&y(C.specularColorMap.channel),specularIntensityMapUv:Me&&y(C.specularIntensityMap.channel),transmissionMapUv:Fe&&y(C.transmissionMap.channel),thicknessMapUv:ot&&y(C.thicknessMap.channel),alphaMapUv:je&&y(C.alphaMap.channel),vertexTangents:!!W.attributes.tangent&&(X||Le),vertexColors:C.vertexColors,vertexAlphas:C.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,vertexUv1s:Ce,vertexUv2s:We,vertexUv3s:pt,pointsUvs:q.isPoints===!0&&!!W.attributes.uv&&(Ne||je),fog:!!P,useFog:C.fog===!0,fogExp2:P&&P.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:G,numDirLights:D.directional.length,numPointLights:D.point.length,numSpotLights:D.spot.length,numSpotLightMaps:D.spotLightMap.length,numRectAreaLights:D.rectArea.length,numHemiLights:D.hemi.length,numDirLightShadows:D.directionalShadowMap.length,numPointLightShadows:D.pointShadowMap.length,numSpotLightShadows:D.spotShadowMap.length,numSpotLightShadowsWithMaps:D.numSpotLightShadowsWithMaps,numLightProbes:D.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:C.dithering,shadowMapEnabled:t.shadowMap.enabled&&U.length>0,shadowMapType:t.shadowMap.type,toneMapping:kt,useLegacyLights:t._useLegacyLights,decodeVideoTexture:Ne&&C.map.isVideoTexture===!0&&mr.getTransfer(C.map.colorSpace)===Cr,premultipliedAlpha:C.premultipliedAlpha,doubleSided:C.side===Qc,flipSided:C.side===Ns,useDepthPacking:C.depthPacking>=0,depthPacking:C.depthPacking||0,index0AttributeName:C.index0AttributeName,extensionDerivatives:Ue&&C.extensions.derivatives===!0,extensionFragDepth:Ue&&C.extensions.fragDepth===!0,extensionDrawBuffers:Ue&&C.extensions.drawBuffers===!0,extensionShaderTextureLOD:Ue&&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 D=[];if(C.shaderID?D.push(C.shaderID):(D.push(C.customVertexShaderID),D.push(C.customFragmentShaderID)),C.defines!==void 0)for(const U in C.defines)D.push(U),D.push(C.defines[U]);return C.isRawShaderMaterial===!1&&(S(D,C),M(D,C),D.push(t.outputColorSpace)),D.push(C.customProgramCacheKey),D.join()}function S(C,D){C.push(D.precision),C.push(D.outputColorSpace),C.push(D.envMapMode),C.push(D.envMapCubeUVHeight),C.push(D.mapUv),C.push(D.alphaMapUv),C.push(D.lightMapUv),C.push(D.aoMapUv),C.push(D.bumpMapUv),C.push(D.normalMapUv),C.push(D.displacementMapUv),C.push(D.emissiveMapUv),C.push(D.metalnessMapUv),C.push(D.roughnessMapUv),C.push(D.anisotropyMapUv),C.push(D.clearcoatMapUv),C.push(D.clearcoatNormalMapUv),C.push(D.clearcoatRoughnessMapUv),C.push(D.iridescenceMapUv),C.push(D.iridescenceThicknessMapUv),C.push(D.sheenColorMapUv),C.push(D.sheenRoughnessMapUv),C.push(D.specularMapUv),C.push(D.specularColorMapUv),C.push(D.specularIntensityMapUv),C.push(D.transmissionMapUv),C.push(D.thicknessMapUv),C.push(D.combine),C.push(D.fogExp2),C.push(D.sizeAttenuation),C.push(D.morphTargetsCount),C.push(D.morphAttributeCount),C.push(D.numDirLights),C.push(D.numPointLights),C.push(D.numSpotLights),C.push(D.numSpotLightMaps),C.push(D.numHemiLights),C.push(D.numRectAreaLights),C.push(D.numDirLightShadows),C.push(D.numPointLightShadows),C.push(D.numSpotLightShadows),C.push(D.numSpotLightShadowsWithMaps),C.push(D.numLightProbes),C.push(D.shadowMapType),C.push(D.toneMapping),C.push(D.numClippingPlanes),C.push(D.numClipIntersection),C.push(D.depthPacking)}function M(C,D){l.disableAll(),D.isWebGL2&&l.enable(0),D.supportsVertexTextures&&l.enable(1),D.instancing&&l.enable(2),D.instancingColor&&l.enable(3),D.matcap&&l.enable(4),D.envMap&&l.enable(5),D.normalMapObjectSpace&&l.enable(6),D.normalMapTangentSpace&&l.enable(7),D.clearcoat&&l.enable(8),D.iridescence&&l.enable(9),D.alphaTest&&l.enable(10),D.vertexColors&&l.enable(11),D.vertexAlphas&&l.enable(12),D.vertexUv1s&&l.enable(13),D.vertexUv2s&&l.enable(14),D.vertexUv3s&&l.enable(15),D.vertexTangents&&l.enable(16),D.anisotropy&&l.enable(17),D.alphaHash&&l.enable(18),D.batching&&l.enable(19),C.push(l.mask),l.disableAll(),D.fog&&l.enable(0),D.useFog&&l.enable(1),D.flatShading&&l.enable(2),D.logarithmicDepthBuffer&&l.enable(3),D.skinning&&l.enable(4),D.morphTargets&&l.enable(5),D.morphNormals&&l.enable(6),D.morphColors&&l.enable(7),D.premultipliedAlpha&&l.enable(8),D.shadowMapEnabled&&l.enable(9),D.useLegacyLights&&l.enable(10),D.doubleSided&&l.enable(11),D.flipSided&&l.enable(12),D.useDepthPacking&&l.enable(13),D.dithering&&l.enable(14),D.transmission&&l.enable(15),D.sheen&&l.enable(16),D.opaque&&l.enable(17),D.pointsUvs&&l.enable(18),D.decodeVideoTexture&&l.enable(19),C.push(l.mask)}function A(C){const D=b[C.type];let U;if(D){const L=ys[D];U=wL.clone(L.uniforms)}else U=C.uniforms;return U}function T(C,D){let U;for(let L=0,q=u.length;L<q;L++){const P=u[L];if(P.cacheKey===D){U=P,++U.usedTimes;break}}return U===void 0&&(U=new j8e(t,D,C,a),u.push(U)),U}function k(C){if(--C.usedTimes===0){const D=u.indexOf(C);u[D]=u[u.length-1],u.pop(),C.destroy()}}function E(C){c.remove(C)}function O(){c.dispose()}return{getParameters:x,getProgramCacheKey:v,getUniforms:A,acquireProgram:T,releaseProgram:k,releaseShaderCache:E,programs:u,dispose:O}}function L8e(){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 I8e(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 q7(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 K7(){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||I8e),r.length>1&&r.sort(m||q7),i.length>1&&i.sort(m||q7)}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 F8e(){let t=new WeakMap;function e(r,i){const a=t.get(r);let o;return a===void 0?(o=new K7,t.set(r,[o])):i>=a.length?(o=new K7,a.push(o)):o=a[i],o}function n(){t=new WeakMap}return{get:e,dispose:n}}function U8e(){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 z8e(){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 B8e=0;function $8e(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function H8e(t,e){const n=new U8e,r=z8e(),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 Nr,l=new Nr;function c(d,f){let m=0,p=0,b=0;for(let L=0;L<9;L++)i.probe[L].set(0,0,0);let y=0,x=0,v=0,S=0,M=0,A=0,T=0,k=0,E=0,O=0,C=0;d.sort($8e);const D=f===!0?Math.PI:1;for(let L=0,q=d.length;L<q;L++){const P=d[L],W=P.color,K=P.intensity,V=P.distance,Q=P.shadow&&P.shadow.map?P.shadow.map.texture:null;if(P.isAmbientLight)m+=W.r*K*D,p+=W.g*K*D,b+=W.b*K*D;else if(P.isLightProbe){for(let re=0;re<9;re++)i.probe[re].addScaledVector(P.sh.coefficients[re],K);C++}else if(P.isDirectionalLight){const re=n.get(P);if(re.color.copy(P.color).multiplyScalar(P.intensity*D),P.castShadow){const J=P.shadow,z=r.get(P);z.shadowBias=J.bias,z.shadowNormalBias=J.normalBias,z.shadowRadius=J.radius,z.shadowMapSize=J.mapSize,i.directionalShadow[y]=z,i.directionalShadowMap[y]=Q,i.directionalShadowMatrix[y]=P.shadow.matrix,A++}i.directional[y]=re,y++}else if(P.isSpotLight){const re=n.get(P);re.position.setFromMatrixPosition(P.matrixWorld),re.color.copy(W).multiplyScalar(K*D),re.distance=V,re.coneCos=Math.cos(P.angle),re.penumbraCos=Math.cos(P.angle*(1-P.penumbra)),re.decay=P.decay,i.spot[v]=re;const J=P.shadow;if(P.map&&(i.spotLightMap[E]=P.map,E++,J.updateMatrices(P),P.castShadow&&O++),i.spotLightMatrix[v]=J.matrix,P.castShadow){const z=r.get(P);z.shadowBias=J.bias,z.shadowNormalBias=J.normalBias,z.shadowRadius=J.radius,z.shadowMapSize=J.mapSize,i.spotShadow[v]=z,i.spotShadowMap[v]=Q,k++}v++}else if(P.isRectAreaLight){const re=n.get(P);re.color.copy(W).multiplyScalar(K),re.halfWidth.set(P.width*.5,0,0),re.halfHeight.set(0,P.height*.5,0),i.rectArea[S]=re,S++}else if(P.isPointLight){const re=n.get(P);if(re.color.copy(P.color).multiplyScalar(P.intensity*D),re.distance=P.distance,re.decay=P.decay,P.castShadow){const J=P.shadow,z=r.get(P);z.shadowBias=J.bias,z.shadowNormalBias=J.normalBias,z.shadowRadius=J.radius,z.shadowMapSize=J.mapSize,z.shadowCameraNear=J.camera.near,z.shadowCameraFar=J.camera.far,i.pointShadow[x]=z,i.pointShadowMap[x]=Q,i.pointShadowMatrix[x]=P.shadow.matrix,T++}i.point[x]=re,x++}else if(P.isHemisphereLight){const re=n.get(P);re.skyColor.copy(P.color).multiplyScalar(K*D),re.groundColor.copy(P.groundColor).multiplyScalar(K*D),i.hemi[M]=re,M++}}S>0&&(e.isWebGL2||t.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Dt.LTC_FLOAT_1,i.rectAreaLTC2=Dt.LTC_FLOAT_2):t.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=Dt.LTC_HALF_1,i.rectAreaLTC2=Dt.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!==A||U.numPointShadows!==T||U.numSpotShadows!==k||U.numSpotMaps!==E||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=A,i.directionalShadowMap.length=A,i.pointShadow.length=T,i.pointShadowMap.length=T,i.spotShadow.length=k,i.spotShadowMap.length=k,i.directionalShadowMatrix.length=A,i.pointShadowMatrix.length=T,i.spotLightMatrix.length=k+E-O,i.spotLightMap.length=E,i.numSpotLightShadowsWithMaps=O,i.numLightProbes=C,U.directionalLength=y,U.pointLength=x,U.spotLength=v,U.rectAreaLength=S,U.hemiLength=M,U.numDirectionalShadows=A,U.numPointShadows=T,U.numSpotShadows=k,U.numSpotMaps=E,U.numLightProbes=C,i.version=B8e++)}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 A=d[S];if(A.isDirectionalLight){const T=i.directional[m];T.direction.setFromMatrixPosition(A.matrixWorld),a.setFromMatrixPosition(A.target.matrixWorld),T.direction.sub(a),T.direction.transformDirection(v),m++}else if(A.isSpotLight){const T=i.spot[b];T.position.setFromMatrixPosition(A.matrixWorld),T.position.applyMatrix4(v),T.direction.setFromMatrixPosition(A.matrixWorld),a.setFromMatrixPosition(A.target.matrixWorld),T.direction.sub(a),T.direction.transformDirection(v),b++}else if(A.isRectAreaLight){const T=i.rectArea[y];T.position.setFromMatrixPosition(A.matrixWorld),T.position.applyMatrix4(v),l.identity(),o.copy(A.matrixWorld),o.premultiply(v),l.extractRotation(o),T.halfWidth.set(A.width*.5,0,0),T.halfHeight.set(0,A.height*.5,0),T.halfWidth.applyMatrix4(l),T.halfHeight.applyMatrix4(l),y++}else if(A.isPointLight){const T=i.point[p];T.position.setFromMatrixPosition(A.matrixWorld),T.position.applyMatrix4(v),p++}else if(A.isHemisphereLight){const T=i.hemi[x];T.direction.setFromMatrixPosition(A.matrixWorld),T.direction.transformDirection(v),x++}}}return{setup:c,setupView:u,state:i}}function X7(t,e){const n=new H8e(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 V8e(t,e){let n=new WeakMap;function r(a,o=0){const l=n.get(a);let c;return l===void 0?(c=new X7(t,e),n.set(a,[c])):o>=l.length?(c=new X7(t,e),l.push(c)):c=l[o],c}function i(){n=new WeakMap}return{get:r,dispose:i}}class G8e extends mx{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=kFe,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 W8e extends mx{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 q8e=`void main() {
- gl_Position = vec4( position, 1.0 );
- }`,K8e=`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 X8e(t,e,n){let r=new bE;const i=new mn,a=new mn,o=new gr,l=new G8e({depthPacking:jFe}),c=new W8e,u={},d=n.maxTextureSize,f={[sh]:Ns,[Ns]:sh,[Qc]:Qc},m=new oh({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new mn},radius:{value:4}},vertexShader:q8e,fragmentShader:K8e}),p=m.clone();p.defines.HORIZONTAL_PASS=1;const b=new Va;b.setAttribute("position",new Zs(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new al(b,m),x=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=zee;let v=this.type;this.render=function(T,k,E){if(x.enabled===!1||x.autoUpdate===!1&&x.needsUpdate===!1||T.length===0)return;const O=t.getRenderTarget(),C=t.getActiveCubeFace(),D=t.getActiveMipmapLevel(),U=t.state;U.setBlending(Gd),U.buffers.color.setClear(1,1,1,1),U.buffers.depth.setTest(!0),U.setScissorTest(!1);const L=v!==Wc&&this.type===Wc,q=v===Wc&&this.type!==Wc;for(let P=0,W=T.length;P<W;P++){const K=T[P],V=K.shadow;if(V===void 0){console.warn("THREE.WebGLShadowMap:",K,"has no shadow.");continue}if(V.autoUpdate===!1&&V.needsUpdate===!1)continue;i.copy(V.mapSize);const Q=V.getFrameExtents();if(i.multiply(Q),a.copy(V.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(a.x=Math.floor(d/Q.x),i.x=a.x*Q.x,V.mapSize.x=a.x),i.y>d&&(a.y=Math.floor(d/Q.y),i.y=a.y*Q.y,V.mapSize.y=a.y)),V.map===null||L===!0||q===!0){const J=this.type!==Wc?{minFilter:_a,magFilter:_a}:{};V.map!==null&&V.map.dispose(),V.map=new sm(i.x,i.y,J),V.map.texture.name=K.name+".shadowMap",V.camera.updateProjectionMatrix()}t.setRenderTarget(V.map),t.clear();const re=V.getViewportCount();for(let J=0;J<re;J++){const z=V.getViewport(J);o.set(a.x*z.x,a.y*z.y,a.x*z.z,a.y*z.w),U.viewport(o),V.updateMatrices(K,J),r=V.getFrustum(),A(k,E,V.camera,K,this.type)}V.isPointLightShadow!==!0&&this.type===Wc&&S(V,E),V.needsUpdate=!1}v=this.type,x.needsUpdate=!1,t.setRenderTarget(O,C,D)};function S(T,k){const E=e.update(y);m.defines.VSM_SAMPLES!==T.blurSamples&&(m.defines.VSM_SAMPLES=T.blurSamples,p.defines.VSM_SAMPLES=T.blurSamples,m.needsUpdate=!0,p.needsUpdate=!0),T.mapPass===null&&(T.mapPass=new sm(i.x,i.y)),m.uniforms.shadow_pass.value=T.map.texture,m.uniforms.resolution.value=T.mapSize,m.uniforms.radius.value=T.radius,t.setRenderTarget(T.mapPass),t.clear(),t.renderBufferDirect(k,null,E,m,y,null),p.uniforms.shadow_pass.value=T.mapPass.texture,p.uniforms.resolution.value=T.mapSize,p.uniforms.radius.value=T.radius,t.setRenderTarget(T.map),t.clear(),t.renderBufferDirect(k,null,E,p,y,null)}function M(T,k,E,O){let C=null;const D=E.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(D!==void 0)C=D;else if(C=E.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,L=k.uuid;let q=u[U];q===void 0&&(q={},u[U]=q);let P=q[L];P===void 0&&(P=C.clone(),q[L]=P),C=P}if(C.visible=k.visible,C.wireframe=k.wireframe,O===Wc?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,E.isPointLight===!0&&C.isMeshDistanceMaterial===!0){const U=t.properties.get(C);U.light=E}return C}function A(T,k,E,O,C){if(T.visible===!1)return;if(T.layers.test(k.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&C===Wc)&&(!T.frustumCulled||r.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(E.matrixWorldInverse,T.matrixWorld);const L=e.update(T),q=T.material;if(Array.isArray(q)){const P=L.groups;for(let W=0,K=P.length;W<K;W++){const V=P[W],Q=q[V.materialIndex];if(Q&&Q.visible){const re=M(T,Q,O,C);T.onBeforeShadow(t,T,k,E,L,re,V),t.renderBufferDirect(E,null,L,re,T,V),T.onAfterShadow(t,T,k,E,L,re,V)}}}else if(q.visible){const P=M(T,q,O,C);T.onBeforeShadow(t,T,k,E,L,P,null),t.renderBufferDirect(E,null,L,P,T,null),T.onAfterShadow(t,T,k,E,L,P,null)}}const U=T.children;for(let L=0,q=U.length;L<q;L++)A(U[L],k,E,O,C)}}function Y8e(t,e,n){const r=n.isWebGL2;function i(){let xe=!1;const Oe=new gr;let Ue=null;const Ce=new gr(0,0,0,0);return{setMask:function(We){Ue!==We&&!xe&&(t.colorMask(We,We,We,We),Ue=We)},setLocked:function(We){xe=We},setClear:function(We,pt,kt,Lt,ln){ln===!0&&(We*=Lt,pt*=Lt,kt*=Lt),Oe.set(We,pt,kt,Lt),Ce.equals(Oe)===!1&&(t.clearColor(We,pt,kt,Lt),Ce.copy(Oe))},reset:function(){xe=!1,Ue=null,Ce.set(-1,0,0,0)}}}function a(){let xe=!1,Oe=null,Ue=null,Ce=null;return{setTest:function(We){We?me(t.DEPTH_TEST):Ne(t.DEPTH_TEST)},setMask:function(We){Oe!==We&&!xe&&(t.depthMask(We),Oe=We)},setFunc:function(We){if(Ue!==We){switch(We){case oFe:t.depthFunc(t.NEVER);break;case lFe:t.depthFunc(t.ALWAYS);break;case cFe:t.depthFunc(t.LESS);break;case KS:t.depthFunc(t.LEQUAL);break;case uFe:t.depthFunc(t.EQUAL);break;case dFe:t.depthFunc(t.GEQUAL);break;case hFe:t.depthFunc(t.GREATER);break;case fFe:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}Ue=We}},setLocked:function(We){xe=We},setClear:function(We){Ce!==We&&(t.clearDepth(We),Ce=We)},reset:function(){xe=!1,Oe=null,Ue=null,Ce=null}}}function o(){let xe=!1,Oe=null,Ue=null,Ce=null,We=null,pt=null,kt=null,Lt=null,ln=null;return{setTest:function(Gt){xe||(Gt?me(t.STENCIL_TEST):Ne(t.STENCIL_TEST))},setMask:function(Gt){Oe!==Gt&&!xe&&(t.stencilMask(Gt),Oe=Gt)},setFunc:function(Gt,_n,gt){(Ue!==Gt||Ce!==_n||We!==gt)&&(t.stencilFunc(Gt,_n,gt),Ue=Gt,Ce=_n,We=gt)},setOp:function(Gt,_n,gt){(pt!==Gt||kt!==_n||Lt!==gt)&&(t.stencilOp(Gt,_n,gt),pt=Gt,kt=_n,Lt=gt)},setLocked:function(Gt){xe=Gt},setClear:function(Gt){ln!==Gt&&(t.clearStencil(Gt),ln=Gt)},reset:function(){xe=!1,Oe=null,Ue=null,Ce=null,We=null,pt=null,kt=null,Lt=null,ln=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,A=null,T=null,k=null,E=null,O=null,C=new rn(0,0,0),D=0,U=!1,L=null,q=null,P=null,W=null,K=null;const V=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let Q=!1,re=0;const J=t.getParameter(t.VERSION);J.indexOf("WebGL")!==-1?(re=parseFloat(/^WebGL (\d)/.exec(J)[1]),Q=re>=1):J.indexOf("OpenGL ES")!==-1&&(re=parseFloat(/^OpenGL ES (\d)/.exec(J)[1]),Q=re>=2);let z=null,G={};const ne=t.getParameter(t.SCISSOR_BOX),ae=t.getParameter(t.VIEWPORT),de=new gr().fromArray(ne),fe=new gr().fromArray(ae);function ie(xe,Oe,Ue,Ce){const We=new Uint8Array(4),pt=t.createTexture();t.bindTexture(xe,pt),t.texParameteri(xe,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(xe,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let kt=0;kt<Ue;kt++)r&&(xe===t.TEXTURE_3D||xe===t.TEXTURE_2D_ARRAY)?t.texImage3D(Oe,0,t.RGBA,1,1,Ce,0,t.RGBA,t.UNSIGNED_BYTE,We):t.texImage2D(Oe+kt,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,We);return pt}const Ae={};Ae[t.TEXTURE_2D]=ie(t.TEXTURE_2D,t.TEXTURE_2D,1),Ae[t.TEXTURE_CUBE_MAP]=ie(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),r&&(Ae[t.TEXTURE_2D_ARRAY]=ie(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),Ae[t.TEXTURE_3D]=ie(t.TEXTURE_3D,t.TEXTURE_3D,1,1)),l.setClear(0,0,0,1),c.setClear(1),u.setClear(0),me(t.DEPTH_TEST),c.setFunc(KS),I(!1),ce(jG),me(t.CULL_FACE),X(Gd);function me(xe){m[xe]!==!0&&(t.enable(xe),m[xe]=!0)}function Ne(xe){m[xe]!==!1&&(t.disable(xe),m[xe]=!1)}function ye(xe,Oe){return p[xe]!==Oe?(t.bindFramebuffer(xe,Oe),p[xe]=Oe,r&&(xe===t.DRAW_FRAMEBUFFER&&(p[t.FRAMEBUFFER]=Oe),xe===t.FRAMEBUFFER&&(p[t.DRAW_FRAMEBUFFER]=Oe)),!0):!1}function le(xe,Oe){let Ue=y,Ce=!1;if(xe)if(Ue=b.get(Oe),Ue===void 0&&(Ue=[],b.set(Oe,Ue)),xe.isWebGLMultipleRenderTargets){const We=xe.texture;if(Ue.length!==We.length||Ue[0]!==t.COLOR_ATTACHMENT0){for(let pt=0,kt=We.length;pt<kt;pt++)Ue[pt]=t.COLOR_ATTACHMENT0+pt;Ue.length=We.length,Ce=!0}}else Ue[0]!==t.COLOR_ATTACHMENT0&&(Ue[0]=t.COLOR_ATTACHMENT0,Ce=!0);else Ue[0]!==t.BACK&&(Ue[0]=t.BACK,Ce=!0);Ce&&(n.isWebGL2?t.drawBuffers(Ue):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(Ue))}function $e(xe){return x!==xe?(t.useProgram(xe),x=xe,!0):!1}const H={[lf]:t.FUNC_ADD,[WIe]:t.FUNC_SUBTRACT,[qIe]:t.FUNC_REVERSE_SUBTRACT};if(r)H[OG]=t.MIN,H[LG]=t.MAX;else{const xe=e.get("EXT_blend_minmax");xe!==null&&(H[OG]=xe.MIN_EXT,H[LG]=xe.MAX_EXT)}const ee={[KIe]:t.ZERO,[XIe]:t.ONE,[YIe]:t.SRC_COLOR,[NR]:t.SRC_ALPHA,[nFe]:t.SRC_ALPHA_SATURATE,[eFe]:t.DST_COLOR,[QIe]:t.DST_ALPHA,[ZIe]:t.ONE_MINUS_SRC_COLOR,[ER]:t.ONE_MINUS_SRC_ALPHA,[tFe]:t.ONE_MINUS_DST_COLOR,[JIe]:t.ONE_MINUS_DST_ALPHA,[rFe]:t.CONSTANT_COLOR,[iFe]:t.ONE_MINUS_CONSTANT_COLOR,[aFe]:t.CONSTANT_ALPHA,[sFe]:t.ONE_MINUS_CONSTANT_ALPHA};function X(xe,Oe,Ue,Ce,We,pt,kt,Lt,ln,Gt){if(xe===Gd){v===!0&&(Ne(t.BLEND),v=!1);return}if(v===!1&&(me(t.BLEND),v=!0),xe!==GIe){if(xe!==S||Gt!==U){if((M!==lf||k!==lf)&&(t.blendEquation(t.FUNC_ADD),M=lf,k=lf),Gt)switch(xe){case hg:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case PG:t.blendFunc(t.ONE,t.ONE);break;case RG:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case DG:t.blendFuncSeparate(t.ZERO,t.SRC_COLOR,t.ZERO,t.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",xe);break}else switch(xe){case hg:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case PG:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case RG:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case DG:t.blendFunc(t.ZERO,t.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",xe);break}A=null,T=null,E=null,O=null,C.set(0,0,0),D=0,S=xe,U=Gt}return}We=We||Oe,pt=pt||Ue,kt=kt||Ce,(Oe!==M||We!==k)&&(t.blendEquationSeparate(H[Oe],H[We]),M=Oe,k=We),(Ue!==A||Ce!==T||pt!==E||kt!==O)&&(t.blendFuncSeparate(ee[Ue],ee[Ce],ee[pt],ee[kt]),A=Ue,T=Ce,E=pt,O=kt),(Lt.equals(C)===!1||ln!==D)&&(t.blendColor(Lt.r,Lt.g,Lt.b,ln),C.copy(Lt),D=ln),S=xe,U=!1}function B(xe,Oe){xe.side===Qc?Ne(t.CULL_FACE):me(t.CULL_FACE);let Ue=xe.side===Ns;Oe&&(Ue=!Ue),I(Ue),xe.blending===hg&&xe.transparent===!1?X(Gd):X(xe.blending,xe.blendEquation,xe.blendSrc,xe.blendDst,xe.blendEquationAlpha,xe.blendSrcAlpha,xe.blendDstAlpha,xe.blendColor,xe.blendAlpha,xe.premultipliedAlpha),c.setFunc(xe.depthFunc),c.setTest(xe.depthTest),c.setMask(xe.depthWrite),l.setMask(xe.colorWrite);const Ce=xe.stencilWrite;u.setTest(Ce),Ce&&(u.setMask(xe.stencilWriteMask),u.setFunc(xe.stencilFunc,xe.stencilRef,xe.stencilFuncMask),u.setOp(xe.stencilFail,xe.stencilZFail,xe.stencilZPass)),Le(xe.polygonOffset,xe.polygonOffsetFactor,xe.polygonOffsetUnits),xe.alphaToCoverage===!0?me(t.SAMPLE_ALPHA_TO_COVERAGE):Ne(t.SAMPLE_ALPHA_TO_COVERAGE)}function I(xe){L!==xe&&(xe?t.frontFace(t.CW):t.frontFace(t.CCW),L=xe)}function ce(xe){xe!==$Ie?(me(t.CULL_FACE),xe!==q&&(xe===jG?t.cullFace(t.BACK):xe===HIe?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):Ne(t.CULL_FACE),q=xe}function Te(xe){xe!==P&&(Q&&t.lineWidth(xe),P=xe)}function Le(xe,Oe,Ue){xe?(me(t.POLYGON_OFFSET_FILL),(W!==Oe||K!==Ue)&&(t.polygonOffset(Oe,Ue),W=Oe,K=Ue)):Ne(t.POLYGON_OFFSET_FILL)}function Ee(xe){xe?me(t.SCISSOR_TEST):Ne(t.SCISSOR_TEST)}function $(xe){xe===void 0&&(xe=t.TEXTURE0+V-1),z!==xe&&(t.activeTexture(xe),z=xe)}function j(xe,Oe,Ue){Ue===void 0&&(z===null?Ue=t.TEXTURE0+V-1:Ue=z);let Ce=G[Ue];Ce===void 0&&(Ce={type:void 0,texture:void 0},G[Ue]=Ce),(Ce.type!==xe||Ce.texture!==Oe)&&(z!==Ue&&(t.activeTexture(Ue),z=Ue),t.bindTexture(xe,Oe||Ae[xe]),Ce.type=xe,Ce.texture=Oe)}function Y(){const xe=G[z];xe!==void 0&&xe.type!==void 0&&(t.bindTexture(xe.type,null),xe.type=void 0,xe.texture=void 0)}function ge(){try{t.compressedTexImage2D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function we(){try{t.compressedTexImage3D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function ve(){try{t.texSubImage2D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function Ze(){try{t.texSubImage3D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function Ie(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function qe(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function Je(){try{t.texStorage2D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function Qe(){try{t.texStorage3D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function oe(){try{t.texImage2D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function te(){try{t.texImage3D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function Me(xe){de.equals(xe)===!1&&(t.scissor(xe.x,xe.y,xe.z,xe.w),de.copy(xe))}function Fe(xe){fe.equals(xe)===!1&&(t.viewport(xe.x,xe.y,xe.z,xe.w),fe.copy(xe))}function ot(xe,Oe){let Ue=f.get(Oe);Ue===void 0&&(Ue=new WeakMap,f.set(Oe,Ue));let Ce=Ue.get(xe);Ce===void 0&&(Ce=t.getUniformBlockIndex(Oe,xe.name),Ue.set(xe,Ce))}function se(xe,Oe){const Ce=f.get(Oe).get(xe);d.get(Oe)!==Ce&&(t.uniformBlockBinding(Oe,Ce,xe.__bindingPointIndex),d.set(Oe,Ce))}function je(){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,G={},p={},b=new WeakMap,y=[],x=null,v=!1,S=null,M=null,A=null,T=null,k=null,E=null,O=null,C=new rn(0,0,0),D=0,U=!1,L=null,q=null,P=null,W=null,K=null,de.set(0,0,t.canvas.width,t.canvas.height),fe.set(0,0,t.canvas.width,t.canvas.height),l.reset(),c.reset(),u.reset()}return{buffers:{color:l,depth:c,stencil:u},enable:me,disable:Ne,bindFramebuffer:ye,drawBuffers:le,useProgram:$e,setBlending:X,setMaterial:B,setFlipSided:I,setCullFace:ce,setLineWidth:Te,setPolygonOffset:Le,setScissorTest:Ee,activeTexture:$,bindTexture:j,unbindTexture:Y,compressedTexImage2D:ge,compressedTexImage3D:we,texImage2D:oe,texImage3D:te,updateUBOMapping:ot,uniformBlockBinding:se,texStorage2D:Je,texStorage3D:Qe,texSubImage2D:ve,texSubImage3D:Ze,compressedTexSubImage2D:Ie,compressedTexSubImage3D:qe,scissor:Me,viewport:Fe,reset:je}}function Z8e(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($,j){return v?new OffscreenCanvas($,j):JS("canvas")}function M($,j,Y,ge){let we=1;if(($.width>ge||$.height>ge)&&(we=ge/Math.max($.width,$.height)),we<1||j===!0)if(typeof HTMLImageElement<"u"&&$ instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&$ instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&$ instanceof ImageBitmap){const ve=j?QS:Math.floor,Ze=ve(we*$.width),Ie=ve(we*$.height);y===void 0&&(y=S(Ze,Ie));const qe=Y?S(Ze,Ie):y;return qe.width=Ze,qe.height=Ie,qe.getContext("2d").drawImage($,0,0,Ze,Ie),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+$.width+"x"+$.height+") to ("+Ze+"x"+Ie+")."),qe}else return"data"in $&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+$.width+"x"+$.height+")."),$;return $}function A($){return RR($.width)&&RR($.height)}function T($){return l?!1:$.wrapS!==nl||$.wrapT!==nl||$.minFilter!==_a&&$.minFilter!==No}function k($,j){return $.generateMipmaps&&j&&$.minFilter!==_a&&$.minFilter!==No}function E($){t.generateMipmap($)}function O($,j,Y,ge,we=!1){if(l===!1)return j;if($!==null){if(t[$]!==void 0)return t[$];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+$+"'")}let ve=j;if(j===t.RED&&(Y===t.FLOAT&&(ve=t.R32F),Y===t.HALF_FLOAT&&(ve=t.R16F),Y===t.UNSIGNED_BYTE&&(ve=t.R8)),j===t.RED_INTEGER&&(Y===t.UNSIGNED_BYTE&&(ve=t.R8UI),Y===t.UNSIGNED_SHORT&&(ve=t.R16UI),Y===t.UNSIGNED_INT&&(ve=t.R32UI),Y===t.BYTE&&(ve=t.R8I),Y===t.SHORT&&(ve=t.R16I),Y===t.INT&&(ve=t.R32I)),j===t.RG&&(Y===t.FLOAT&&(ve=t.RG32F),Y===t.HALF_FLOAT&&(ve=t.RG16F),Y===t.UNSIGNED_BYTE&&(ve=t.RG8)),j===t.RGBA){const Ze=we?XS:mr.getTransfer(ge);Y===t.FLOAT&&(ve=t.RGBA32F),Y===t.HALF_FLOAT&&(ve=t.RGBA16F),Y===t.UNSIGNED_BYTE&&(ve=Ze===Cr?t.SRGB8_ALPHA8:t.RGBA8),Y===t.UNSIGNED_SHORT_4_4_4_4&&(ve=t.RGBA4),Y===t.UNSIGNED_SHORT_5_5_5_1&&(ve=t.RGB5_A1)}return(ve===t.R16F||ve===t.R32F||ve===t.RG16F||ve===t.RG32F||ve===t.RGBA16F||ve===t.RGBA32F)&&e.get("EXT_color_buffer_float"),ve}function C($,j,Y){return k($,Y)===!0||$.isFramebufferTexture&&$.minFilter!==_a&&$.minFilter!==No?Math.log2(Math.max(j.width,j.height))+1:$.mipmaps!==void 0&&$.mipmaps.length>0?$.mipmaps.length:$.isCompressedTexture&&Array.isArray($.image)?j.mipmaps.length:1}function D($){return $===_a||$===IG||$===kk?t.NEAREST:t.LINEAR}function U($){const j=$.target;j.removeEventListener("dispose",U),q(j),j.isVideoTexture&&b.delete(j)}function L($){const j=$.target;j.removeEventListener("dispose",L),W(j)}function q($){const j=r.get($);if(j.__webglInit===void 0)return;const Y=$.source,ge=x.get(Y);if(ge){const we=ge[j.__cacheKey];we.usedTimes--,we.usedTimes===0&&P($),Object.keys(ge).length===0&&x.delete(Y)}r.remove($)}function P($){const j=r.get($);t.deleteTexture(j.__webglTexture);const Y=$.source,ge=x.get(Y);delete ge[j.__cacheKey],o.memory.textures--}function W($){const j=$.texture,Y=r.get($),ge=r.get(j);if(ge.__webglTexture!==void 0&&(t.deleteTexture(ge.__webglTexture),o.memory.textures--),$.depthTexture&&$.depthTexture.dispose(),$.isWebGLCubeRenderTarget)for(let we=0;we<6;we++){if(Array.isArray(Y.__webglFramebuffer[we]))for(let ve=0;ve<Y.__webglFramebuffer[we].length;ve++)t.deleteFramebuffer(Y.__webglFramebuffer[we][ve]);else t.deleteFramebuffer(Y.__webglFramebuffer[we]);Y.__webglDepthbuffer&&t.deleteRenderbuffer(Y.__webglDepthbuffer[we])}else{if(Array.isArray(Y.__webglFramebuffer))for(let we=0;we<Y.__webglFramebuffer.length;we++)t.deleteFramebuffer(Y.__webglFramebuffer[we]);else t.deleteFramebuffer(Y.__webglFramebuffer);if(Y.__webglDepthbuffer&&t.deleteRenderbuffer(Y.__webglDepthbuffer),Y.__webglMultisampledFramebuffer&&t.deleteFramebuffer(Y.__webglMultisampledFramebuffer),Y.__webglColorRenderbuffer)for(let we=0;we<Y.__webglColorRenderbuffer.length;we++)Y.__webglColorRenderbuffer[we]&&t.deleteRenderbuffer(Y.__webglColorRenderbuffer[we]);Y.__webglDepthRenderbuffer&&t.deleteRenderbuffer(Y.__webglDepthRenderbuffer)}if($.isWebGLMultipleRenderTargets)for(let we=0,ve=j.length;we<ve;we++){const Ze=r.get(j[we]);Ze.__webglTexture&&(t.deleteTexture(Ze.__webglTexture),o.memory.textures--),r.remove(j[we])}r.remove(j),r.remove($)}let K=0;function V(){K=0}function Q(){const $=K;return $>=c&&console.warn("THREE.WebGLTextures: Trying to use "+$+" texture units while this GPU supports only "+c),K+=1,$}function re($){const j=[];return j.push($.wrapS),j.push($.wrapT),j.push($.wrapR||0),j.push($.magFilter),j.push($.minFilter),j.push($.anisotropy),j.push($.internalFormat),j.push($.format),j.push($.type),j.push($.generateMipmaps),j.push($.premultiplyAlpha),j.push($.flipY),j.push($.unpackAlignment),j.push($.colorSpace),j.join()}function J($,j){const Y=r.get($);if($.isVideoTexture&&Le($),$.isRenderTargetTexture===!1&&$.version>0&&Y.__version!==$.version){const ge=$.image;if(ge===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ge.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{me(Y,$,j);return}}n.bindTexture(t.TEXTURE_2D,Y.__webglTexture,t.TEXTURE0+j)}function z($,j){const Y=r.get($);if($.version>0&&Y.__version!==$.version){me(Y,$,j);return}n.bindTexture(t.TEXTURE_2D_ARRAY,Y.__webglTexture,t.TEXTURE0+j)}function G($,j){const Y=r.get($);if($.version>0&&Y.__version!==$.version){me(Y,$,j);return}n.bindTexture(t.TEXTURE_3D,Y.__webglTexture,t.TEXTURE0+j)}function ne($,j){const Y=r.get($);if($.version>0&&Y.__version!==$.version){Ne(Y,$,j);return}n.bindTexture(t.TEXTURE_CUBE_MAP,Y.__webglTexture,t.TEXTURE0+j)}const ae={[CR]:t.REPEAT,[nl]:t.CLAMP_TO_EDGE,[kR]:t.MIRRORED_REPEAT},de={[_a]:t.NEAREST,[IG]:t.NEAREST_MIPMAP_NEAREST,[kk]:t.NEAREST_MIPMAP_LINEAR,[No]:t.LINEAR,[_Fe]:t.LINEAR_MIPMAP_NEAREST,[ny]:t.LINEAR_MIPMAP_LINEAR},fe={[RFe]:t.NEVER,[UFe]:t.ALWAYS,[DFe]:t.LESS,[Zee]:t.LEQUAL,[OFe]:t.EQUAL,[FFe]:t.GEQUAL,[LFe]:t.GREATER,[IFe]:t.NOTEQUAL};function ie($,j,Y){if(Y?(t.texParameteri($,t.TEXTURE_WRAP_S,ae[j.wrapS]),t.texParameteri($,t.TEXTURE_WRAP_T,ae[j.wrapT]),($===t.TEXTURE_3D||$===t.TEXTURE_2D_ARRAY)&&t.texParameteri($,t.TEXTURE_WRAP_R,ae[j.wrapR]),t.texParameteri($,t.TEXTURE_MAG_FILTER,de[j.magFilter]),t.texParameteri($,t.TEXTURE_MIN_FILTER,de[j.minFilter])):(t.texParameteri($,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri($,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),($===t.TEXTURE_3D||$===t.TEXTURE_2D_ARRAY)&&t.texParameteri($,t.TEXTURE_WRAP_R,t.CLAMP_TO_EDGE),(j.wrapS!==nl||j.wrapT!==nl)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),t.texParameteri($,t.TEXTURE_MAG_FILTER,D(j.magFilter)),t.texParameteri($,t.TEXTURE_MIN_FILTER,D(j.minFilter)),j.minFilter!==_a&&j.minFilter!==No&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),j.compareFunction&&(t.texParameteri($,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri($,t.TEXTURE_COMPARE_FUNC,fe[j.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const ge=e.get("EXT_texture_filter_anisotropic");if(j.magFilter===_a||j.minFilter!==kk&&j.minFilter!==ny||j.type===ru&&e.has("OES_texture_float_linear")===!1||l===!1&&j.type===ry&&e.has("OES_texture_half_float_linear")===!1)return;(j.anisotropy>1||r.get(j).__currentAnisotropy)&&(t.texParameterf($,ge.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(j.anisotropy,i.getMaxAnisotropy())),r.get(j).__currentAnisotropy=j.anisotropy)}}function Ae($,j){let Y=!1;$.__webglInit===void 0&&($.__webglInit=!0,j.addEventListener("dispose",U));const ge=j.source;let we=x.get(ge);we===void 0&&(we={},x.set(ge,we));const ve=re(j);if(ve!==$.__cacheKey){we[ve]===void 0&&(we[ve]={texture:t.createTexture(),usedTimes:0},o.memory.textures++,Y=!0),we[ve].usedTimes++;const Ze=we[$.__cacheKey];Ze!==void 0&&(we[$.__cacheKey].usedTimes--,Ze.usedTimes===0&&P(j)),$.__cacheKey=ve,$.__webglTexture=we[ve].texture}return Y}function me($,j,Y){let ge=t.TEXTURE_2D;(j.isDataArrayTexture||j.isCompressedArrayTexture)&&(ge=t.TEXTURE_2D_ARRAY),j.isData3DTexture&&(ge=t.TEXTURE_3D);const we=Ae($,j),ve=j.source;n.bindTexture(ge,$.__webglTexture,t.TEXTURE0+Y);const Ze=r.get(ve);if(ve.version!==Ze.__version||we===!0){n.activeTexture(t.TEXTURE0+Y);const Ie=mr.getPrimaries(mr.workingColorSpace),qe=j.colorSpace===Ao?null:mr.getPrimaries(j.colorSpace),Je=j.colorSpace===Ao||Ie===qe?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,j.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,j.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,j.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Je);const Qe=T(j)&&A(j.image)===!1;let oe=M(j.image,Qe,!1,d);oe=Ee(j,oe);const te=A(oe)||l,Me=a.convert(j.format,j.colorSpace);let Fe=a.convert(j.type),ot=O(j.internalFormat,Me,Fe,j.colorSpace,j.isVideoTexture);ie(ge,j,te);let se;const je=j.mipmaps,xe=l&&j.isVideoTexture!==!0&&ot!==Kee,Oe=Ze.__version===void 0||we===!0,Ue=C(j,oe,te);if(j.isDepthTexture)ot=t.DEPTH_COMPONENT,l?j.type===ru?ot=t.DEPTH_COMPONENT32F:j.type===Dd?ot=t.DEPTH_COMPONENT24:j.type===Pf?ot=t.DEPTH24_STENCIL8:ot=t.DEPTH_COMPONENT16:j.type===ru&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),j.format===Rf&&ot===t.DEPTH_COMPONENT&&j.type!==bL&&j.type!==Dd&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),j.type=Dd,Fe=a.convert(j.type)),j.format===Ig&&ot===t.DEPTH_COMPONENT&&(ot=t.DEPTH_STENCIL,j.type!==Pf&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),j.type=Pf,Fe=a.convert(j.type))),Oe&&(xe?n.texStorage2D(t.TEXTURE_2D,1,ot,oe.width,oe.height):n.texImage2D(t.TEXTURE_2D,0,ot,oe.width,oe.height,0,Me,Fe,null));else if(j.isDataTexture)if(je.length>0&&te){xe&&Oe&&n.texStorage2D(t.TEXTURE_2D,Ue,ot,je[0].width,je[0].height);for(let Ce=0,We=je.length;Ce<We;Ce++)se=je[Ce],xe?n.texSubImage2D(t.TEXTURE_2D,Ce,0,0,se.width,se.height,Me,Fe,se.data):n.texImage2D(t.TEXTURE_2D,Ce,ot,se.width,se.height,0,Me,Fe,se.data);j.generateMipmaps=!1}else xe?(Oe&&n.texStorage2D(t.TEXTURE_2D,Ue,ot,oe.width,oe.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,oe.width,oe.height,Me,Fe,oe.data)):n.texImage2D(t.TEXTURE_2D,0,ot,oe.width,oe.height,0,Me,Fe,oe.data);else if(j.isCompressedTexture)if(j.isCompressedArrayTexture){xe&&Oe&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Ue,ot,je[0].width,je[0].height,oe.depth);for(let Ce=0,We=je.length;Ce<We;Ce++)se=je[Ce],j.format!==Eo?Me!==null?xe?n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Ce,0,0,0,se.width,se.height,oe.depth,Me,se.data,0,0):n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,Ce,ot,se.width,se.height,oe.depth,0,se.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):xe?n.texSubImage3D(t.TEXTURE_2D_ARRAY,Ce,0,0,0,se.width,se.height,oe.depth,Me,Fe,se.data):n.texImage3D(t.TEXTURE_2D_ARRAY,Ce,ot,se.width,se.height,oe.depth,0,Me,Fe,se.data)}else{xe&&Oe&&n.texStorage2D(t.TEXTURE_2D,Ue,ot,je[0].width,je[0].height);for(let Ce=0,We=je.length;Ce<We;Ce++)se=je[Ce],j.format!==Eo?Me!==null?xe?n.compressedTexSubImage2D(t.TEXTURE_2D,Ce,0,0,se.width,se.height,Me,se.data):n.compressedTexImage2D(t.TEXTURE_2D,Ce,ot,se.width,se.height,0,se.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):xe?n.texSubImage2D(t.TEXTURE_2D,Ce,0,0,se.width,se.height,Me,Fe,se.data):n.texImage2D(t.TEXTURE_2D,Ce,ot,se.width,se.height,0,Me,Fe,se.data)}else if(j.isDataArrayTexture)xe?(Oe&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Ue,ot,oe.width,oe.height,oe.depth),n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,oe.width,oe.height,oe.depth,Me,Fe,oe.data)):n.texImage3D(t.TEXTURE_2D_ARRAY,0,ot,oe.width,oe.height,oe.depth,0,Me,Fe,oe.data);else if(j.isData3DTexture)xe?(Oe&&n.texStorage3D(t.TEXTURE_3D,Ue,ot,oe.width,oe.height,oe.depth),n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,oe.width,oe.height,oe.depth,Me,Fe,oe.data)):n.texImage3D(t.TEXTURE_3D,0,ot,oe.width,oe.height,oe.depth,0,Me,Fe,oe.data);else if(j.isFramebufferTexture){if(Oe)if(xe)n.texStorage2D(t.TEXTURE_2D,Ue,ot,oe.width,oe.height);else{let Ce=oe.width,We=oe.height;for(let pt=0;pt<Ue;pt++)n.texImage2D(t.TEXTURE_2D,pt,ot,Ce,We,0,Me,Fe,null),Ce>>=1,We>>=1}}else if(je.length>0&&te){xe&&Oe&&n.texStorage2D(t.TEXTURE_2D,Ue,ot,je[0].width,je[0].height);for(let Ce=0,We=je.length;Ce<We;Ce++)se=je[Ce],xe?n.texSubImage2D(t.TEXTURE_2D,Ce,0,0,Me,Fe,se):n.texImage2D(t.TEXTURE_2D,Ce,ot,Me,Fe,se);j.generateMipmaps=!1}else xe?(Oe&&n.texStorage2D(t.TEXTURE_2D,Ue,ot,oe.width,oe.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,Me,Fe,oe)):n.texImage2D(t.TEXTURE_2D,0,ot,Me,Fe,oe);k(j,te)&&E(ge),Ze.__version=ve.version,j.onUpdate&&j.onUpdate(j)}$.__version=j.version}function Ne($,j,Y){if(j.image.length!==6)return;const ge=Ae($,j),we=j.source;n.bindTexture(t.TEXTURE_CUBE_MAP,$.__webglTexture,t.TEXTURE0+Y);const ve=r.get(we);if(we.version!==ve.__version||ge===!0){n.activeTexture(t.TEXTURE0+Y);const Ze=mr.getPrimaries(mr.workingColorSpace),Ie=j.colorSpace===Ao?null:mr.getPrimaries(j.colorSpace),qe=j.colorSpace===Ao||Ze===Ie?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,j.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,j.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,j.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,qe);const Je=j.isCompressedTexture||j.image[0].isCompressedTexture,Qe=j.image[0]&&j.image[0].isDataTexture,oe=[];for(let Ce=0;Ce<6;Ce++)!Je&&!Qe?oe[Ce]=M(j.image[Ce],!1,!0,u):oe[Ce]=Qe?j.image[Ce].image:j.image[Ce],oe[Ce]=Ee(j,oe[Ce]);const te=oe[0],Me=A(te)||l,Fe=a.convert(j.format,j.colorSpace),ot=a.convert(j.type),se=O(j.internalFormat,Fe,ot,j.colorSpace),je=l&&j.isVideoTexture!==!0,xe=ve.__version===void 0||ge===!0;let Oe=C(j,te,Me);ie(t.TEXTURE_CUBE_MAP,j,Me);let Ue;if(Je){je&&xe&&n.texStorage2D(t.TEXTURE_CUBE_MAP,Oe,se,te.width,te.height);for(let Ce=0;Ce<6;Ce++){Ue=oe[Ce].mipmaps;for(let We=0;We<Ue.length;We++){const pt=Ue[We];j.format!==Eo?Fe!==null?je?n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,We,0,0,pt.width,pt.height,Fe,pt.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,We,se,pt.width,pt.height,0,pt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):je?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,We,0,0,pt.width,pt.height,Fe,ot,pt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,We,se,pt.width,pt.height,0,Fe,ot,pt.data)}}}else{Ue=j.mipmaps,je&&xe&&(Ue.length>0&&Oe++,n.texStorage2D(t.TEXTURE_CUBE_MAP,Oe,se,oe[0].width,oe[0].height));for(let Ce=0;Ce<6;Ce++)if(Qe){je?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,0,0,0,oe[Ce].width,oe[Ce].height,Fe,ot,oe[Ce].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,0,se,oe[Ce].width,oe[Ce].height,0,Fe,ot,oe[Ce].data);for(let We=0;We<Ue.length;We++){const kt=Ue[We].image[Ce].image;je?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,We+1,0,0,kt.width,kt.height,Fe,ot,kt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,We+1,se,kt.width,kt.height,0,Fe,ot,kt.data)}}else{je?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,0,0,0,Fe,ot,oe[Ce]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,0,se,Fe,ot,oe[Ce]);for(let We=0;We<Ue.length;We++){const pt=Ue[We];je?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,We+1,0,0,Fe,ot,pt.image[Ce]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,We+1,se,Fe,ot,pt.image[Ce])}}}k(j,Me)&&E(t.TEXTURE_CUBE_MAP),ve.__version=we.version,j.onUpdate&&j.onUpdate(j)}$.__version=j.version}function ye($,j,Y,ge,we,ve){const Ze=a.convert(Y.format,Y.colorSpace),Ie=a.convert(Y.type),qe=O(Y.internalFormat,Ze,Ie,Y.colorSpace);if(!r.get(j).__hasExternalTextures){const Qe=Math.max(1,j.width>>ve),oe=Math.max(1,j.height>>ve);we===t.TEXTURE_3D||we===t.TEXTURE_2D_ARRAY?n.texImage3D(we,ve,qe,Qe,oe,j.depth,0,Ze,Ie,null):n.texImage2D(we,ve,qe,Qe,oe,0,Ze,Ie,null)}n.bindFramebuffer(t.FRAMEBUFFER,$),Te(j)?m.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,ge,we,r.get(Y).__webglTexture,0,ce(j)):(we===t.TEXTURE_2D||we>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&we<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,ge,we,r.get(Y).__webglTexture,ve),n.bindFramebuffer(t.FRAMEBUFFER,null)}function le($,j,Y){if(t.bindRenderbuffer(t.RENDERBUFFER,$),j.depthBuffer&&!j.stencilBuffer){let ge=l===!0?t.DEPTH_COMPONENT24:t.DEPTH_COMPONENT16;if(Y||Te(j)){const we=j.depthTexture;we&&we.isDepthTexture&&(we.type===ru?ge=t.DEPTH_COMPONENT32F:we.type===Dd&&(ge=t.DEPTH_COMPONENT24));const ve=ce(j);Te(j)?m.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ve,ge,j.width,j.height):t.renderbufferStorageMultisample(t.RENDERBUFFER,ve,ge,j.width,j.height)}else t.renderbufferStorage(t.RENDERBUFFER,ge,j.width,j.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,$)}else if(j.depthBuffer&&j.stencilBuffer){const ge=ce(j);Y&&Te(j)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,ge,t.DEPTH24_STENCIL8,j.width,j.height):Te(j)?m.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ge,t.DEPTH24_STENCIL8,j.width,j.height):t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,j.width,j.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,$)}else{const ge=j.isWebGLMultipleRenderTargets===!0?j.texture:[j.texture];for(let we=0;we<ge.length;we++){const ve=ge[we],Ze=a.convert(ve.format,ve.colorSpace),Ie=a.convert(ve.type),qe=O(ve.internalFormat,Ze,Ie,ve.colorSpace),Je=ce(j);Y&&Te(j)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,Je,qe,j.width,j.height):Te(j)?m.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Je,qe,j.width,j.height):t.renderbufferStorage(t.RENDERBUFFER,qe,j.width,j.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function $e($,j){if(j&&j.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,$),!(j.depthTexture&&j.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(j.depthTexture).__webglTexture||j.depthTexture.image.width!==j.width||j.depthTexture.image.height!==j.height)&&(j.depthTexture.image.width=j.width,j.depthTexture.image.height=j.height,j.depthTexture.needsUpdate=!0),J(j.depthTexture,0);const ge=r.get(j.depthTexture).__webglTexture,we=ce(j);if(j.depthTexture.format===Rf)Te(j)?m.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ge,0,we):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ge,0);else if(j.depthTexture.format===Ig)Te(j)?m.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ge,0,we):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ge,0);else throw new Error("Unknown depthTexture format")}function H($){const j=r.get($),Y=$.isWebGLCubeRenderTarget===!0;if($.depthTexture&&!j.__autoAllocateDepthBuffer){if(Y)throw new Error("target.depthTexture not supported in Cube render targets");$e(j.__webglFramebuffer,$)}else if(Y){j.__webglDepthbuffer=[];for(let ge=0;ge<6;ge++)n.bindFramebuffer(t.FRAMEBUFFER,j.__webglFramebuffer[ge]),j.__webglDepthbuffer[ge]=t.createRenderbuffer(),le(j.__webglDepthbuffer[ge],$,!1)}else n.bindFramebuffer(t.FRAMEBUFFER,j.__webglFramebuffer),j.__webglDepthbuffer=t.createRenderbuffer(),le(j.__webglDepthbuffer,$,!1);n.bindFramebuffer(t.FRAMEBUFFER,null)}function ee($,j,Y){const ge=r.get($);j!==void 0&&ye(ge.__webglFramebuffer,$,$.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),Y!==void 0&&H($)}function X($){const j=$.texture,Y=r.get($),ge=r.get(j);$.addEventListener("dispose",L),$.isWebGLMultipleRenderTargets!==!0&&(ge.__webglTexture===void 0&&(ge.__webglTexture=t.createTexture()),ge.__version=j.version,o.memory.textures++);const we=$.isWebGLCubeRenderTarget===!0,ve=$.isWebGLMultipleRenderTargets===!0,Ze=A($)||l;if(we){Y.__webglFramebuffer=[];for(let Ie=0;Ie<6;Ie++)if(l&&j.mipmaps&&j.mipmaps.length>0){Y.__webglFramebuffer[Ie]=[];for(let qe=0;qe<j.mipmaps.length;qe++)Y.__webglFramebuffer[Ie][qe]=t.createFramebuffer()}else Y.__webglFramebuffer[Ie]=t.createFramebuffer()}else{if(l&&j.mipmaps&&j.mipmaps.length>0){Y.__webglFramebuffer=[];for(let Ie=0;Ie<j.mipmaps.length;Ie++)Y.__webglFramebuffer[Ie]=t.createFramebuffer()}else Y.__webglFramebuffer=t.createFramebuffer();if(ve)if(i.drawBuffers){const Ie=$.texture;for(let qe=0,Je=Ie.length;qe<Je;qe++){const Qe=r.get(Ie[qe]);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&&Te($)===!1){const Ie=ve?j:[j];Y.__webglMultisampledFramebuffer=t.createFramebuffer(),Y.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,Y.__webglMultisampledFramebuffer);for(let qe=0;qe<Ie.length;qe++){const Je=Ie[qe];Y.__webglColorRenderbuffer[qe]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,Y.__webglColorRenderbuffer[qe]);const Qe=a.convert(Je.format,Je.colorSpace),oe=a.convert(Je.type),te=O(Je.internalFormat,Qe,oe,Je.colorSpace,$.isXRRenderTarget===!0),Me=ce($);t.renderbufferStorageMultisample(t.RENDERBUFFER,Me,te,$.width,$.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+qe,t.RENDERBUFFER,Y.__webglColorRenderbuffer[qe])}t.bindRenderbuffer(t.RENDERBUFFER,null),$.depthBuffer&&(Y.__webglDepthRenderbuffer=t.createRenderbuffer(),le(Y.__webglDepthRenderbuffer,$,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(we){n.bindTexture(t.TEXTURE_CUBE_MAP,ge.__webglTexture),ie(t.TEXTURE_CUBE_MAP,j,Ze);for(let Ie=0;Ie<6;Ie++)if(l&&j.mipmaps&&j.mipmaps.length>0)for(let qe=0;qe<j.mipmaps.length;qe++)ye(Y.__webglFramebuffer[Ie][qe],$,j,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ie,qe);else ye(Y.__webglFramebuffer[Ie],$,j,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ie,0);k(j,Ze)&&E(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(ve){const Ie=$.texture;for(let qe=0,Je=Ie.length;qe<Je;qe++){const Qe=Ie[qe],oe=r.get(Qe);n.bindTexture(t.TEXTURE_2D,oe.__webglTexture),ie(t.TEXTURE_2D,Qe,Ze),ye(Y.__webglFramebuffer,$,Qe,t.COLOR_ATTACHMENT0+qe,t.TEXTURE_2D,0),k(Qe,Ze)&&E(t.TEXTURE_2D)}n.unbindTexture()}else{let Ie=t.TEXTURE_2D;if(($.isWebGL3DRenderTarget||$.isWebGLArrayRenderTarget)&&(l?Ie=$.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(Ie,ge.__webglTexture),ie(Ie,j,Ze),l&&j.mipmaps&&j.mipmaps.length>0)for(let qe=0;qe<j.mipmaps.length;qe++)ye(Y.__webglFramebuffer[qe],$,j,t.COLOR_ATTACHMENT0,Ie,qe);else ye(Y.__webglFramebuffer,$,j,t.COLOR_ATTACHMENT0,Ie,0);k(j,Ze)&&E(Ie),n.unbindTexture()}$.depthBuffer&&H($)}function B($){const j=A($)||l,Y=$.isWebGLMultipleRenderTargets===!0?$.texture:[$.texture];for(let ge=0,we=Y.length;ge<we;ge++){const ve=Y[ge];if(k(ve,j)){const Ze=$.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,Ie=r.get(ve).__webglTexture;n.bindTexture(Ze,Ie),E(Ze),n.unbindTexture()}}}function I($){if(l&&$.samples>0&&Te($)===!1){const j=$.isWebGLMultipleRenderTargets?$.texture:[$.texture],Y=$.width,ge=$.height;let we=t.COLOR_BUFFER_BIT;const ve=[],Ze=$.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Ie=r.get($),qe=$.isWebGLMultipleRenderTargets===!0;if(qe)for(let Je=0;Je<j.length;Je++)n.bindFramebuffer(t.FRAMEBUFFER,Ie.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Je,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,Ie.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Je,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,Ie.__webglMultisampledFramebuffer),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ie.__webglFramebuffer);for(let Je=0;Je<j.length;Je++){ve.push(t.COLOR_ATTACHMENT0+Je),$.depthBuffer&&ve.push(Ze);const Qe=Ie.__ignoreDepthValues!==void 0?Ie.__ignoreDepthValues:!1;if(Qe===!1&&($.depthBuffer&&(we|=t.DEPTH_BUFFER_BIT),$.stencilBuffer&&(we|=t.STENCIL_BUFFER_BIT)),qe&&t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,Ie.__webglColorRenderbuffer[Je]),Qe===!0&&(t.invalidateFramebuffer(t.READ_FRAMEBUFFER,[Ze]),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[Ze])),qe){const oe=r.get(j[Je]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,oe,0)}t.blitFramebuffer(0,0,Y,ge,0,0,Y,ge,we,t.NEAREST),p&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,ve)}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),qe)for(let Je=0;Je<j.length;Je++){n.bindFramebuffer(t.FRAMEBUFFER,Ie.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Je,t.RENDERBUFFER,Ie.__webglColorRenderbuffer[Je]);const Qe=r.get(j[Je]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,Ie.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Je,t.TEXTURE_2D,Qe,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ie.__webglMultisampledFramebuffer)}}function ce($){return Math.min(f,$.samples)}function Te($){const j=r.get($);return l&&$.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&j.__useRenderToTexture!==!1}function Le($){const j=o.render.frame;b.get($)!==j&&(b.set($,j),$.update())}function Ee($,j){const Y=$.colorSpace,ge=$.format,we=$.type;return $.isCompressedTexture===!0||$.isVideoTexture===!0||$.format===PR||Y!==Nu&&Y!==Ao&&(mr.getTransfer(Y)===Cr?l===!1?e.has("EXT_sRGB")===!0&&ge===Eo?($.format=PR,$.minFilter=No,$.generateMipmaps=!1):j=ete.sRGBToLinear(j):(ge!==Eo||we!==qd)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",Y)),j}this.allocateTextureUnit=Q,this.resetTextureUnits=V,this.setTexture2D=J,this.setTexture2DArray=z,this.setTexture3D=G,this.setTextureCube=ne,this.rebindTextures=ee,this.setupRenderTarget=X,this.updateRenderTargetMipmap=B,this.updateMultisampleRenderTarget=I,this.setupDepthRenderbuffer=H,this.setupFrameBufferTexture=ye,this.useMultisampledRTT=Te}function Q8e(t,e,n){const r=n.isWebGL2;function i(a,o=Ao){let l;const c=mr.getTransfer(o);if(a===qd)return t.UNSIGNED_BYTE;if(a===Hee)return t.UNSIGNED_SHORT_4_4_4_4;if(a===Vee)return t.UNSIGNED_SHORT_5_5_5_1;if(a===wFe)return t.BYTE;if(a===SFe)return t.SHORT;if(a===bL)return t.UNSIGNED_SHORT;if(a===$ee)return t.INT;if(a===Dd)return t.UNSIGNED_INT;if(a===ru)return t.FLOAT;if(a===ry)return r?t.HALF_FLOAT:(l=e.get("OES_texture_half_float"),l!==null?l.HALF_FLOAT_OES:null);if(a===MFe)return t.ALPHA;if(a===Eo)return t.RGBA;if(a===NFe)return t.LUMINANCE;if(a===EFe)return t.LUMINANCE_ALPHA;if(a===Rf)return t.DEPTH_COMPONENT;if(a===Ig)return t.DEPTH_STENCIL;if(a===PR)return l=e.get("EXT_sRGB"),l!==null?l.SRGB_ALPHA_EXT:null;if(a===AFe)return t.RED;if(a===Gee)return t.RED_INTEGER;if(a===TFe)return t.RG;if(a===Wee)return t.RG_INTEGER;if(a===qee)return t.RGBA_INTEGER;if(a===jk||a===Pk||a===Rk||a===Dk)if(c===Cr)if(l=e.get("WEBGL_compressed_texture_s3tc_srgb"),l!==null){if(a===jk)return l.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(a===Pk)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(a===Rk)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(a===Dk)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(l=e.get("WEBGL_compressed_texture_s3tc"),l!==null){if(a===jk)return l.COMPRESSED_RGB_S3TC_DXT1_EXT;if(a===Pk)return l.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(a===Rk)return l.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(a===Dk)return l.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(a===FG||a===UG||a===zG||a===BG)if(l=e.get("WEBGL_compressed_texture_pvrtc"),l!==null){if(a===FG)return l.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(a===UG)return l.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(a===zG)return l.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(a===BG)return l.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(a===Kee)return l=e.get("WEBGL_compressed_texture_etc1"),l!==null?l.COMPRESSED_RGB_ETC1_WEBGL:null;if(a===$G||a===HG)if(l=e.get("WEBGL_compressed_texture_etc"),l!==null){if(a===$G)return c===Cr?l.COMPRESSED_SRGB8_ETC2:l.COMPRESSED_RGB8_ETC2;if(a===HG)return c===Cr?l.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:l.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(a===VG||a===GG||a===WG||a===qG||a===KG||a===XG||a===YG||a===ZG||a===QG||a===JG||a===e7||a===t7||a===n7||a===r7)if(l=e.get("WEBGL_compressed_texture_astc"),l!==null){if(a===VG)return c===Cr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:l.COMPRESSED_RGBA_ASTC_4x4_KHR;if(a===GG)return c===Cr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:l.COMPRESSED_RGBA_ASTC_5x4_KHR;if(a===WG)return c===Cr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:l.COMPRESSED_RGBA_ASTC_5x5_KHR;if(a===qG)return c===Cr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:l.COMPRESSED_RGBA_ASTC_6x5_KHR;if(a===KG)return c===Cr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:l.COMPRESSED_RGBA_ASTC_6x6_KHR;if(a===XG)return c===Cr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:l.COMPRESSED_RGBA_ASTC_8x5_KHR;if(a===YG)return c===Cr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:l.COMPRESSED_RGBA_ASTC_8x6_KHR;if(a===ZG)return c===Cr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:l.COMPRESSED_RGBA_ASTC_8x8_KHR;if(a===QG)return c===Cr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:l.COMPRESSED_RGBA_ASTC_10x5_KHR;if(a===JG)return c===Cr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:l.COMPRESSED_RGBA_ASTC_10x6_KHR;if(a===e7)return c===Cr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:l.COMPRESSED_RGBA_ASTC_10x8_KHR;if(a===t7)return c===Cr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:l.COMPRESSED_RGBA_ASTC_10x10_KHR;if(a===n7)return c===Cr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:l.COMPRESSED_RGBA_ASTC_12x10_KHR;if(a===r7)return c===Cr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:l.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(a===Ok||a===i7||a===a7)if(l=e.get("EXT_texture_compression_bptc"),l!==null){if(a===Ok)return c===Cr?l.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:l.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(a===i7)return l.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(a===a7)return l.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(a===CFe||a===s7||a===o7||a===l7)if(l=e.get("EXT_texture_compression_rgtc"),l!==null){if(a===Ok)return l.COMPRESSED_RED_RGTC1_EXT;if(a===s7)return l.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(a===o7)return l.COMPRESSED_RED_GREEN_RGTC2_EXT;if(a===l7)return l.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return a===Pf?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 J8e extends $s{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Xb extends ts{constructor(){super(),this.isGroup=!0,this.type="Group"}}const e6e={type:"move"};class ij{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Xb,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 Xb,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 Xb,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(e6e)))}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 Xb;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}}class t6e extends bm{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=[],A=new mn;let T=null;const k=new $s;k.layers.enable(1),k.viewport=new gr;const E=new $s;E.layers.enable(2),E.viewport=new gr;const O=[k,E],C=new J8e;C.layers.enable(1),C.layers.enable(2);let D=null,U=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(ne){let ae=S[ne];return ae===void 0&&(ae=new ij,S[ne]=ae),ae.getTargetRaySpace()},this.getControllerGrip=function(ne){let ae=S[ne];return ae===void 0&&(ae=new ij,S[ne]=ae),ae.getGripSpace()},this.getHand=function(ne){let ae=S[ne];return ae===void 0&&(ae=new ij,S[ne]=ae),ae.getHandSpace()};function L(ne){const ae=M.indexOf(ne.inputSource);if(ae===-1)return;const de=S[ae];de!==void 0&&(de.update(ne.inputSource,ne.frame,u||o),de.dispatchEvent({type:ne.type,data:ne.inputSource}))}function q(){i.removeEventListener("select",L),i.removeEventListener("selectstart",L),i.removeEventListener("selectend",L),i.removeEventListener("squeeze",L),i.removeEventListener("squeezestart",L),i.removeEventListener("squeezeend",L),i.removeEventListener("end",q),i.removeEventListener("inputsourceschange",P);for(let ne=0;ne<S.length;ne++){const ae=M[ne];ae!==null&&(M[ne]=null,S[ne].disconnect(ae))}D=null,U=null,e.setRenderTarget(x),p=null,m=null,f=null,i=null,v=null,G.stop(),r.isPresenting=!1,e.setPixelRatio(T),e.setSize(A.width,A.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ne){a=ne,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ne){l=ne,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||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",L),i.addEventListener("selectstart",L),i.addEventListener("selectend",L),i.addEventListener("squeeze",L),i.addEventListener("squeezestart",L),i.addEventListener("squeezeend",L),i.addEventListener("end",q),i.addEventListener("inputsourceschange",P),y.xrCompatible!==!0&&await n.makeXRCompatible(),T=e.getPixelRatio(),e.getSize(A),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const ae={antialias:i.renderState.layers===void 0?y.antialias:!0,alpha:!0,depth:y.depth,stencil:y.stencil,framebufferScaleFactor:a};p=new XRWebGLLayer(i,n,ae),i.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),v=new sm(p.framebufferWidth,p.framebufferHeight,{format:Eo,type:qd,colorSpace:e.outputColorSpace,stencilBuffer:y.stencil})}else{let ae=null,de=null,fe=null;y.depth&&(fe=y.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,ae=y.stencil?Ig:Rf,de=y.stencil?Pf:Dd);const ie={colorFormat:n.RGBA8,depthFormat:fe,scaleFactor:a};f=new XRWebGLBinding(i,n),m=f.createProjectionLayer(ie),i.updateRenderState({layers:[m]}),e.setPixelRatio(1),e.setSize(m.textureWidth,m.textureHeight,!1),v=new sm(m.textureWidth,m.textureHeight,{format:Eo,type:qd,depthTexture:new hte(m.textureWidth,m.textureHeight,de,void 0,void 0,void 0,void 0,void 0,void 0,ae),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),G.setContext(i),G.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode};function P(ne){for(let ae=0;ae<ne.removed.length;ae++){const de=ne.removed[ae],fe=M.indexOf(de);fe>=0&&(M[fe]=null,S[fe].disconnect(de))}for(let ae=0;ae<ne.added.length;ae++){const de=ne.added[ae];let fe=M.indexOf(de);if(fe===-1){for(let Ae=0;Ae<S.length;Ae++)if(Ae>=M.length){M.push(de),fe=Ae;break}else if(M[Ae]===null){M[Ae]=de,fe=Ae;break}if(fe===-1)break}const ie=S[fe];ie&&ie.connect(de)}}const W=new Be,K=new Be;function V(ne,ae,de){W.setFromMatrixPosition(ae.matrixWorld),K.setFromMatrixPosition(de.matrixWorld);const fe=W.distanceTo(K),ie=ae.projectionMatrix.elements,Ae=de.projectionMatrix.elements,me=ie[14]/(ie[10]-1),Ne=ie[14]/(ie[10]+1),ye=(ie[9]+1)/ie[5],le=(ie[9]-1)/ie[5],$e=(ie[8]-1)/ie[0],H=(Ae[8]+1)/Ae[0],ee=me*$e,X=me*H,B=fe/(-$e+H),I=B*-$e;ae.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=me+B,Te=Ne+B,Le=ee-I,Ee=X+(fe-I),$=ye*Ne/Te*ce,j=le*Ne/Te*ce;ne.projectionMatrix.makePerspective(Le,Ee,$,j,ce,Te),ne.projectionMatrixInverse.copy(ne.projectionMatrix).invert()}function Q(ne,ae){ae===null?ne.matrixWorld.copy(ne.matrix):ne.matrixWorld.multiplyMatrices(ae.matrixWorld,ne.matrix),ne.matrixWorldInverse.copy(ne.matrixWorld).invert()}this.updateCamera=function(ne){if(i===null)return;C.near=E.near=k.near=ne.near,C.far=E.far=k.far=ne.far,(D!==C.near||U!==C.far)&&(i.updateRenderState({depthNear:C.near,depthFar:C.far}),D=C.near,U=C.far);const ae=ne.parent,de=C.cameras;Q(C,ae);for(let fe=0;fe<de.length;fe++)Q(de[fe],ae);de.length===2?V(C,k,E):C.projectionMatrix.copy(k.projectionMatrix),re(ne,C,ae)};function re(ne,ae,de){de===null?ne.matrix.copy(ae.matrixWorld):(ne.matrix.copy(de.matrixWorld),ne.matrix.invert(),ne.matrix.multiply(ae.matrixWorld)),ne.matrix.decompose(ne.position,ne.quaternion,ne.scale),ne.updateMatrixWorld(!0),ne.projectionMatrix.copy(ae.projectionMatrix),ne.projectionMatrixInverse.copy(ae.projectionMatrixInverse),ne.isPerspectiveCamera&&(ne.fov=ay*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 J=null;function z(ne,ae){if(d=ae.getViewerPose(u||o),b=ae,d!==null){const de=d.views;p!==null&&(e.setRenderTargetFramebuffer(v,p.framebuffer),e.setRenderTarget(v));let fe=!1;de.length!==C.cameras.length&&(C.cameras.length=0,fe=!0);for(let ie=0;ie<de.length;ie++){const Ae=de[ie];let me=null;if(p!==null)me=p.getViewport(Ae);else{const ye=f.getViewSubImage(m,Ae);me=ye.viewport,ie===0&&(e.setRenderTargetTextures(v,ye.colorTexture,m.ignoreDepthValues?void 0:ye.depthStencilTexture),e.setRenderTarget(v))}let Ne=O[ie];Ne===void 0&&(Ne=new $s,Ne.layers.enable(ie),Ne.viewport=new gr,O[ie]=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(me.x,me.y,me.width,me.height),ie===0&&(C.matrix.copy(Ne.matrix),C.matrix.decompose(C.position,C.quaternion,C.scale)),fe===!0&&C.cameras.push(Ne)}}for(let de=0;de<S.length;de++){const fe=M[de],ie=S[de];fe!==null&&ie!==void 0&&ie.update(fe,ae,u||o)}J&&J(ne,ae),ae.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:ae}),b=null}const G=new dte;G.setAnimationLoop(z),this.setAnimationLoop=function(ne){J=ne},this.dispose=function(){}}}function n6e(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,lte(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,A){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,A)):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===Ns&&(x.bumpScale.value*=-1)),v.normalMap&&(x.normalMap.value=v.normalMap,n(v.normalMap,x.normalMapTransform),x.normalScale.value.copy(v.normalScale),v.side===Ns&&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===Ns&&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 r6e(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 A=M.program;r.uniformBlockBinding(S,A)}function u(S,M){let A=i[S.id];A===void 0&&(b(S),A=d(S),i[S.id]=A,S.addEventListener("dispose",x));const T=M.program;r.updateUBOMapping(S,T);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 A=t.createBuffer(),T=S.__size,k=S.usage;return t.bindBuffer(t.UNIFORM_BUFFER,A),t.bufferData(t.UNIFORM_BUFFER,T,k),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,M,A),A}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],A=S.uniforms,T=S.__cache;t.bindBuffer(t.UNIFORM_BUFFER,M);for(let k=0,E=A.length;k<E;k++){const O=A[k];if(p(O,k,T)===!0){const C=O.__offset,D=Array.isArray(O.value)?O.value:[O.value];let U=0;for(let L=0;L<D.length;L++){const q=D[L],P=y(q);typeof q=="number"?(O.__data[0]=q,t.bufferSubData(t.UNIFORM_BUFFER,C+U,O.__data)):q.isMatrix3?(O.__data[0]=q.elements[0],O.__data[1]=q.elements[1],O.__data[2]=q.elements[2],O.__data[3]=q.elements[0],O.__data[4]=q.elements[3],O.__data[5]=q.elements[4],O.__data[6]=q.elements[5],O.__data[7]=q.elements[0],O.__data[8]=q.elements[6],O.__data[9]=q.elements[7],O.__data[10]=q.elements[8],O.__data[11]=q.elements[0]):(q.toArray(O.__data,U),U+=P.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,C,O.__data)}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function p(S,M,A){const T=S.value;if(A[M]===void 0){if(typeof T=="number")A[M]=T;else{const k=Array.isArray(T)?T:[T],E=[];for(let O=0;O<k.length;O++)E.push(k[O].clone());A[M]=E}return!0}else if(typeof T=="number"){if(A[M]!==T)return A[M]=T,!0}else{const k=Array.isArray(A[M])?A[M]:[A[M]],E=Array.isArray(T)?T:[T];for(let O=0;O<k.length;O++){const C=k[O];if(C.equals(E[O])===!1)return C.copy(E[O]),!0}}return!1}function b(S){const M=S.uniforms;let A=0;const T=16;let k=0;for(let E=0,O=M.length;E<O;E++){const C=M[E],D={boundary:0,storage:0},U=Array.isArray(C.value)?C.value:[C.value];for(let L=0,q=U.length;L<q;L++){const P=U[L],W=y(P);D.boundary+=W.boundary,D.storage+=W.storage}if(C.__data=new Float32Array(D.storage/Float32Array.BYTES_PER_ELEMENT),C.__offset=A,E>0){k=A%T;const L=T-k;k!==0&&L-D.boundary<0&&(A+=T-k,C.__offset=A)}A+=D.storage}return k=A%T,k>0&&(A+=T-k),S.__size=A,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 A=o.indexOf(M.__bindingPointIndex);o.splice(A,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 OR{constructor(e={}){const{canvas:n=e5e(),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=wa,this._useLegacyLights=!1,this.toneMapping=Wd,this.toneMappingExposure=1;const M=this;let A=!1,T=0,k=0,E=null,O=-1,C=null;const D=new gr,U=new gr;let L=null;const q=new rn(0);let P=0,W=n.width,K=n.height,V=1,Q=null,re=null;const J=new gr(0,0,W,K),z=new gr(0,0,W,K);let G=!1;const ne=new bE;let ae=!1,de=!1,fe=null;const ie=new Nr,Ae=new mn,me=new Be,Ne={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function ye(){return E===null?V:1}let le=r;function $e(_e,Ve){for(let at=0;at<_e.length;at++){const ct=_e[at],rt=n.getContext(ct,Ve);if(rt!==null)return rt}return null}try{const _e={alpha:!0,depth:i,stencil:a,antialias:l,premultipliedAlpha:c,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:f};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${pE}`),n.addEventListener("webglcontextlost",je,!1),n.addEventListener("webglcontextrestored",xe,!1),n.addEventListener("webglcontextcreationerror",Oe,!1),le===null){const Ve=["webgl2","webgl","experimental-webgl"];if(M.isWebGL1Renderer===!0&&Ve.shift(),le=$e(Ve,_e),le===null)throw $e(Ve)?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(_e){throw console.error("THREE.WebGLRenderer: "+_e.message),_e}let H,ee,X,B,I,ce,Te,Le,Ee,$,j,Y,ge,we,ve,Ze,Ie,qe,Je,Qe,oe,te,Me,Fe;function ot(){H=new mBe(le),ee=new oBe(le,H,e),H.init(ee),te=new Q8e(le,H,ee),X=new Y8e(le,H,ee),B=new xBe(le),I=new L8e,ce=new Z8e(le,H,X,I,ee,te,B),Te=new cBe(M),Le=new fBe(M),Ee=new M5e(le,ee),Me=new aBe(le,H,Ee,ee),$=new pBe(le,Ee,B,Me),j=new _Be(le,$,Ee,B),Je=new vBe(le,ee,ce),Ze=new lBe(I),Y=new O8e(M,Te,Le,H,ee,Me,Ze),ge=new n6e(M,I),we=new F8e,ve=new V8e(H,ee),qe=new iBe(M,Te,Le,X,j,m,c),Ie=new X8e(M,j,ee),Fe=new r6e(le,B,ee,X),Qe=new sBe(le,H,B,ee),oe=new gBe(le,H,B,ee),B.programs=Y.programs,M.capabilities=ee,M.extensions=H,M.properties=I,M.renderLists=we,M.shadowMap=Ie,M.state=X,M.info=B}ot();const se=new t6e(M,le);this.xr=se,this.getContext=function(){return le},this.getContextAttributes=function(){return le.getContextAttributes()},this.forceContextLoss=function(){const _e=H.get("WEBGL_lose_context");_e&&_e.loseContext()},this.forceContextRestore=function(){const _e=H.get("WEBGL_lose_context");_e&&_e.restoreContext()},this.getPixelRatio=function(){return V},this.setPixelRatio=function(_e){_e!==void 0&&(V=_e,this.setSize(W,K,!1))},this.getSize=function(_e){return _e.set(W,K)},this.setSize=function(_e,Ve,at=!0){if(se.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}W=_e,K=Ve,n.width=Math.floor(_e*V),n.height=Math.floor(Ve*V),at===!0&&(n.style.width=_e+"px",n.style.height=Ve+"px"),this.setViewport(0,0,_e,Ve)},this.getDrawingBufferSize=function(_e){return _e.set(W*V,K*V).floor()},this.setDrawingBufferSize=function(_e,Ve,at){W=_e,K=Ve,V=at,n.width=Math.floor(_e*at),n.height=Math.floor(Ve*at),this.setViewport(0,0,_e,Ve)},this.getCurrentViewport=function(_e){return _e.copy(D)},this.getViewport=function(_e){return _e.copy(J)},this.setViewport=function(_e,Ve,at,ct){_e.isVector4?J.set(_e.x,_e.y,_e.z,_e.w):J.set(_e,Ve,at,ct),X.viewport(D.copy(J).multiplyScalar(V).floor())},this.getScissor=function(_e){return _e.copy(z)},this.setScissor=function(_e,Ve,at,ct){_e.isVector4?z.set(_e.x,_e.y,_e.z,_e.w):z.set(_e,Ve,at,ct),X.scissor(U.copy(z).multiplyScalar(V).floor())},this.getScissorTest=function(){return G},this.setScissorTest=function(_e){X.setScissorTest(G=_e)},this.setOpaqueSort=function(_e){Q=_e},this.setTransparentSort=function(_e){re=_e},this.getClearColor=function(_e){return _e.copy(qe.getClearColor())},this.setClearColor=function(){qe.setClearColor.apply(qe,arguments)},this.getClearAlpha=function(){return qe.getClearAlpha()},this.setClearAlpha=function(){qe.setClearAlpha.apply(qe,arguments)},this.clear=function(_e=!0,Ve=!0,at=!0){let ct=0;if(_e){let rt=!1;if(E!==null){const jt=E.texture.format;rt=jt===qee||jt===Wee||jt===Gee}if(rt){const jt=E.texture.type,zt=jt===qd||jt===Dd||jt===bL||jt===Pf||jt===Hee||jt===Vee,Xt=qe.getClearColor(),Yt=qe.getClearAlpha(),ue=Xt.r,Re=Xt.g,He=Xt.b;zt?(p[0]=ue,p[1]=Re,p[2]=He,p[3]=Yt,le.clearBufferuiv(le.COLOR,0,p)):(b[0]=ue,b[1]=Re,b[2]=He,b[3]=Yt,le.clearBufferiv(le.COLOR,0,b))}else ct|=le.COLOR_BUFFER_BIT}Ve&&(ct|=le.DEPTH_BUFFER_BIT),at&&(ct|=le.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),le.clear(ct)},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",je,!1),n.removeEventListener("webglcontextrestored",xe,!1),n.removeEventListener("webglcontextcreationerror",Oe,!1),we.dispose(),ve.dispose(),I.dispose(),Te.dispose(),Le.dispose(),j.dispose(),Me.dispose(),Fe.dispose(),Y.dispose(),se.dispose(),se.removeEventListener("sessionstart",ln),se.removeEventListener("sessionend",Gt),fe&&(fe.dispose(),fe=null),_n.stop()};function je(_e){_e.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),A=!0}function xe(){console.log("THREE.WebGLRenderer: Context Restored."),A=!1;const _e=B.autoReset,Ve=Ie.enabled,at=Ie.autoUpdate,ct=Ie.needsUpdate,rt=Ie.type;ot(),B.autoReset=_e,Ie.enabled=Ve,Ie.autoUpdate=at,Ie.needsUpdate=ct,Ie.type=rt}function Oe(_e){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",_e.statusMessage)}function Ue(_e){const Ve=_e.target;Ve.removeEventListener("dispose",Ue),Ce(Ve)}function Ce(_e){We(_e),I.remove(_e)}function We(_e){const Ve=I.get(_e).programs;Ve!==void 0&&(Ve.forEach(function(at){Y.releaseProgram(at)}),_e.isShaderMaterial&&Y.releaseShaderCache(_e))}this.renderBufferDirect=function(_e,Ve,at,ct,rt,jt){Ve===null&&(Ve=Ne);const zt=rt.isMesh&&rt.matrixWorld.determinant()<0,Xt=Rr(_e,Ve,at,ct,rt);X.setMaterial(ct,zt);let Yt=at.index,ue=1;if(ct.wireframe===!0){if(Yt=$.getWireframeAttribute(at),Yt===void 0)return;ue=2}const Re=at.drawRange,He=at.attributes.position;let Xe=Re.start*ue,Ge=(Re.start+Re.count)*ue;jt!==null&&(Xe=Math.max(Xe,jt.start*ue),Ge=Math.min(Ge,(jt.start+jt.count)*ue)),Yt!==null?(Xe=Math.max(Xe,0),Ge=Math.min(Ge,Yt.count)):He!=null&&(Xe=Math.max(Xe,0),Ge=Math.min(Ge,He.count));const ht=Ge-Xe;if(ht<0||ht===1/0)return;Me.setup(rt,ct,Xt,at,Yt);let Pt,_t=Qe;if(Yt!==null&&(Pt=Ee.get(Yt),_t=oe,_t.setIndex(Pt)),rt.isMesh)ct.wireframe===!0?(X.setLineWidth(ct.wireframeLinewidth*ye()),_t.setMode(le.LINES)):_t.setMode(le.TRIANGLES);else if(rt.isLine){let yt=ct.linewidth;yt===void 0&&(yt=1),X.setLineWidth(yt*ye()),rt.isLineSegments?_t.setMode(le.LINES):rt.isLineLoop?_t.setMode(le.LINE_LOOP):_t.setMode(le.LINE_STRIP)}else rt.isPoints?_t.setMode(le.POINTS):rt.isSprite&&_t.setMode(le.TRIANGLES);if(rt.isBatchedMesh)_t.renderMultiDraw(rt._multiDrawStarts,rt._multiDrawCounts,rt._multiDrawCount);else if(rt.isInstancedMesh)_t.renderInstances(Xe,ht,rt.count);else if(at.isInstancedBufferGeometry){const yt=at._maxInstanceCount!==void 0?at._maxInstanceCount:1/0,It=Math.min(at.instanceCount,yt);_t.renderInstances(Xe,ht,It)}else _t.render(Xe,ht)};function pt(_e,Ve,at){_e.transparent===!0&&_e.side===Qc&&_e.forceSinglePass===!1?(_e.side=Ns,_e.needsUpdate=!0,yr(_e,Ve,at),_e.side=sh,_e.needsUpdate=!0,yr(_e,Ve,at),_e.side=Qc):yr(_e,Ve,at)}this.compile=function(_e,Ve,at=null){at===null&&(at=_e),x=ve.get(at),x.init(),S.push(x),at.traverseVisible(function(rt){rt.isLight&&rt.layers.test(Ve.layers)&&(x.pushLight(rt),rt.castShadow&&x.pushShadow(rt))}),_e!==at&&_e.traverseVisible(function(rt){rt.isLight&&rt.layers.test(Ve.layers)&&(x.pushLight(rt),rt.castShadow&&x.pushShadow(rt))}),x.setupLights(M._useLegacyLights);const ct=new Set;return _e.traverse(function(rt){const jt=rt.material;if(jt)if(Array.isArray(jt))for(let zt=0;zt<jt.length;zt++){const Xt=jt[zt];pt(Xt,at,rt),ct.add(Xt)}else pt(jt,at,rt),ct.add(jt)}),S.pop(),x=null,ct},this.compileAsync=function(_e,Ve,at=null){const ct=this.compile(_e,Ve,at);return new Promise(rt=>{function jt(){if(ct.forEach(function(zt){I.get(zt).currentProgram.isReady()&&ct.delete(zt)}),ct.size===0){rt(_e);return}setTimeout(jt,10)}H.get("KHR_parallel_shader_compile")!==null?jt():setTimeout(jt,10)})};let kt=null;function Lt(_e){kt&&kt(_e)}function ln(){_n.stop()}function Gt(){_n.start()}const _n=new dte;_n.setAnimationLoop(Lt),typeof self<"u"&&_n.setContext(self),this.setAnimationLoop=function(_e){kt=_e,se.setAnimationLoop(_e),_e===null?_n.stop():_n.start()},se.addEventListener("sessionstart",ln),se.addEventListener("sessionend",Gt),this.render=function(_e,Ve){if(Ve!==void 0&&Ve.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(A===!0)return;_e.matrixWorldAutoUpdate===!0&&_e.updateMatrixWorld(),Ve.parent===null&&Ve.matrixWorldAutoUpdate===!0&&Ve.updateMatrixWorld(),se.enabled===!0&&se.isPresenting===!0&&(se.cameraAutoUpdate===!0&&se.updateCamera(Ve),Ve=se.getCamera()),_e.isScene===!0&&_e.onBeforeRender(M,_e,Ve,E),x=ve.get(_e,S.length),x.init(),S.push(x),ie.multiplyMatrices(Ve.projectionMatrix,Ve.matrixWorldInverse),ne.setFromProjectionMatrix(ie),de=this.localClippingEnabled,ae=Ze.init(this.clippingPlanes,de),y=we.get(_e,v.length),y.init(),v.push(y),gt(_e,Ve,0,M.sortObjects),y.finish(),M.sortObjects===!0&&y.sort(Q,re),this.info.render.frame++,ae===!0&&Ze.beginShadows();const at=x.state.shadowsArray;if(Ie.render(at,_e,Ve),ae===!0&&Ze.endShadows(),this.info.autoReset===!0&&this.info.reset(),qe.render(y,_e),x.setupLights(M._useLegacyLights),Ve.isArrayCamera){const ct=Ve.cameras;for(let rt=0,jt=ct.length;rt<jt;rt++){const zt=ct[rt];Kt(y,_e,zt,zt.viewport)}}else Kt(y,_e,Ve);E!==null&&(ce.updateMultisampleRenderTarget(E),ce.updateRenderTargetMipmap(E)),_e.isScene===!0&&_e.onAfterRender(M,_e,Ve),Me.resetDefaultState(),O=-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 gt(_e,Ve,at,ct){if(_e.visible===!1)return;if(_e.layers.test(Ve.layers)){if(_e.isGroup)at=_e.renderOrder;else if(_e.isLOD)_e.autoUpdate===!0&&_e.update(Ve);else if(_e.isLight)x.pushLight(_e),_e.castShadow&&x.pushShadow(_e);else if(_e.isSprite){if(!_e.frustumCulled||ne.intersectsSprite(_e)){ct&&me.setFromMatrixPosition(_e.matrixWorld).applyMatrix4(ie);const zt=j.update(_e),Xt=_e.material;Xt.visible&&y.push(_e,zt,Xt,at,me.z,null)}}else if((_e.isMesh||_e.isLine||_e.isPoints)&&(!_e.frustumCulled||ne.intersectsObject(_e))){const zt=j.update(_e),Xt=_e.material;if(ct&&(_e.boundingSphere!==void 0?(_e.boundingSphere===null&&_e.computeBoundingSphere(),me.copy(_e.boundingSphere.center)):(zt.boundingSphere===null&&zt.computeBoundingSphere(),me.copy(zt.boundingSphere.center)),me.applyMatrix4(_e.matrixWorld).applyMatrix4(ie)),Array.isArray(Xt)){const Yt=zt.groups;for(let ue=0,Re=Yt.length;ue<Re;ue++){const He=Yt[ue],Xe=Xt[He.materialIndex];Xe&&Xe.visible&&y.push(_e,zt,Xe,at,me.z,He)}}else Xt.visible&&y.push(_e,zt,Xt,at,me.z,null)}}const jt=_e.children;for(let zt=0,Xt=jt.length;zt<Xt;zt++)gt(jt[zt],Ve,at,ct)}function Kt(_e,Ve,at,ct){const rt=_e.opaque,jt=_e.transmissive,zt=_e.transparent;x.setupLightsView(at),ae===!0&&Ze.setGlobalState(M.clippingPlanes,at),jt.length>0&&bn(rt,jt,Ve,at),ct&&X.viewport(D.copy(ct)),rt.length>0&&At(rt,Ve,at),jt.length>0&&At(jt,Ve,at),zt.length>0&&At(zt,Ve,at),X.buffers.depth.setTest(!0),X.buffers.depth.setMask(!0),X.buffers.color.setMask(!0),X.setPolygonOffset(!1)}function bn(_e,Ve,at,ct){if((at.isScene===!0?at.overrideMaterial:null)!==null)return;const jt=ee.isWebGL2;fe===null&&(fe=new sm(1,1,{generateMipmaps:!0,type:H.has("EXT_color_buffer_half_float")?ry:qd,minFilter:ny,samples:jt?4:0})),M.getDrawingBufferSize(Ae),jt?fe.setSize(Ae.x,Ae.y):fe.setSize(QS(Ae.x),QS(Ae.y));const zt=M.getRenderTarget();M.setRenderTarget(fe),M.getClearColor(q),P=M.getClearAlpha(),P<1&&M.setClearColor(16777215,.5),M.clear();const Xt=M.toneMapping;M.toneMapping=Wd,At(_e,at,ct),ce.updateMultisampleRenderTarget(fe),ce.updateRenderTargetMipmap(fe);let Yt=!1;for(let ue=0,Re=Ve.length;ue<Re;ue++){const He=Ve[ue],Xe=He.object,Ge=He.geometry,ht=He.material,Pt=He.group;if(ht.side===Qc&&Xe.layers.test(ct.layers)){const _t=ht.side;ht.side=Ns,ht.needsUpdate=!0,Pr(Xe,at,ct,Ge,ht,Pt),ht.side=_t,ht.needsUpdate=!0,Yt=!0}}Yt===!0&&(ce.updateMultisampleRenderTarget(fe),ce.updateRenderTargetMipmap(fe)),M.setRenderTarget(zt),M.setClearColor(q,P),M.toneMapping=Xt}function At(_e,Ve,at){const ct=Ve.isScene===!0?Ve.overrideMaterial:null;for(let rt=0,jt=_e.length;rt<jt;rt++){const zt=_e[rt],Xt=zt.object,Yt=zt.geometry,ue=ct===null?zt.material:ct,Re=zt.group;Xt.layers.test(at.layers)&&Pr(Xt,Ve,at,Yt,ue,Re)}}function Pr(_e,Ve,at,ct,rt,jt){_e.onBeforeRender(M,Ve,at,ct,rt,jt),_e.modelViewMatrix.multiplyMatrices(at.matrixWorldInverse,_e.matrixWorld),_e.normalMatrix.getNormalMatrix(_e.modelViewMatrix),rt.onBeforeRender(M,Ve,at,ct,_e,jt),rt.transparent===!0&&rt.side===Qc&&rt.forceSinglePass===!1?(rt.side=Ns,rt.needsUpdate=!0,M.renderBufferDirect(at,Ve,ct,rt,_e,jt),rt.side=sh,rt.needsUpdate=!0,M.renderBufferDirect(at,Ve,ct,rt,_e,jt),rt.side=Qc):M.renderBufferDirect(at,Ve,ct,rt,_e,jt),_e.onAfterRender(M,Ve,at,ct,rt,jt)}function yr(_e,Ve,at){Ve.isScene!==!0&&(Ve=Ne);const ct=I.get(_e),rt=x.state.lights,jt=x.state.shadowsArray,zt=rt.state.version,Xt=Y.getParameters(_e,rt.state,jt,Ve,at),Yt=Y.getProgramCacheKey(Xt);let ue=ct.programs;ct.environment=_e.isMeshStandardMaterial?Ve.environment:null,ct.fog=Ve.fog,ct.envMap=(_e.isMeshStandardMaterial?Le:Te).get(_e.envMap||ct.environment),ue===void 0&&(_e.addEventListener("dispose",Ue),ue=new Map,ct.programs=ue);let Re=ue.get(Yt);if(Re!==void 0){if(ct.currentProgram===Re&&ct.lightsStateVersion===zt)return sn(_e,Xt),Re}else Xt.uniforms=Y.getUniforms(_e),_e.onBuild(at,Xt,M),_e.onBeforeCompile(Xt,M),Re=Y.acquireProgram(Xt,Yt),ue.set(Yt,Re),ct.uniforms=Xt.uniforms;const He=ct.uniforms;return(!_e.isShaderMaterial&&!_e.isRawShaderMaterial||_e.clipping===!0)&&(He.clippingPlanes=Ze.uniform),sn(_e,Xt),ct.needsLights=Dr(_e),ct.lightsStateVersion=zt,ct.needsLights&&(He.ambientLightColor.value=rt.state.ambient,He.lightProbe.value=rt.state.probe,He.directionalLights.value=rt.state.directional,He.directionalLightShadows.value=rt.state.directionalShadow,He.spotLights.value=rt.state.spot,He.spotLightShadows.value=rt.state.spotShadow,He.rectAreaLights.value=rt.state.rectArea,He.ltc_1.value=rt.state.rectAreaLTC1,He.ltc_2.value=rt.state.rectAreaLTC2,He.pointLights.value=rt.state.point,He.pointLightShadows.value=rt.state.pointShadow,He.hemisphereLights.value=rt.state.hemi,He.directionalShadowMap.value=rt.state.directionalShadowMap,He.directionalShadowMatrix.value=rt.state.directionalShadowMatrix,He.spotShadowMap.value=rt.state.spotShadowMap,He.spotLightMatrix.value=rt.state.spotLightMatrix,He.spotLightMap.value=rt.state.spotLightMap,He.pointShadowMap.value=rt.state.pointShadowMap,He.pointShadowMatrix.value=rt.state.pointShadowMatrix),ct.currentProgram=Re,ct.uniformsList=null,Re}function jn(_e){if(_e.uniformsList===null){const Ve=_e.currentProgram.getUniforms();_e.uniformsList=w1.seqWithValue(Ve.seq,_e.uniforms)}return _e.uniformsList}function sn(_e,Ve){const at=I.get(_e);at.outputColorSpace=Ve.outputColorSpace,at.batching=Ve.batching,at.instancing=Ve.instancing,at.instancingColor=Ve.instancingColor,at.skinning=Ve.skinning,at.morphTargets=Ve.morphTargets,at.morphNormals=Ve.morphNormals,at.morphColors=Ve.morphColors,at.morphTargetsCount=Ve.morphTargetsCount,at.numClippingPlanes=Ve.numClippingPlanes,at.numIntersection=Ve.numClipIntersection,at.vertexAlphas=Ve.vertexAlphas,at.vertexTangents=Ve.vertexTangents,at.toneMapping=Ve.toneMapping}function Rr(_e,Ve,at,ct,rt){Ve.isScene!==!0&&(Ve=Ne),ce.resetTextureUnits();const jt=Ve.fog,zt=ct.isMeshStandardMaterial?Ve.environment:null,Xt=E===null?M.outputColorSpace:E.isXRRenderTarget===!0?E.texture.colorSpace:Nu,Yt=(ct.isMeshStandardMaterial?Le:Te).get(ct.envMap||zt),ue=ct.vertexColors===!0&&!!at.attributes.color&&at.attributes.color.itemSize===4,Re=!!at.attributes.tangent&&(!!ct.normalMap||ct.anisotropy>0),He=!!at.morphAttributes.position,Xe=!!at.morphAttributes.normal,Ge=!!at.morphAttributes.color;let ht=Wd;ct.toneMapped&&(E===null||E.isXRRenderTarget===!0)&&(ht=M.toneMapping);const Pt=at.morphAttributes.position||at.morphAttributes.normal||at.morphAttributes.color,_t=Pt!==void 0?Pt.length:0,yt=I.get(ct),It=x.state.lights;if(ae===!0&&(de===!0||_e!==C)){const Rt=_e===C&&ct.id===O;Ze.setState(ct,_e,Rt)}let Ot=!1;ct.version===yt.__version?(yt.needsLights&&yt.lightsStateVersion!==It.state.version||yt.outputColorSpace!==Xt||rt.isBatchedMesh&&yt.batching===!1||!rt.isBatchedMesh&&yt.batching===!0||rt.isInstancedMesh&&yt.instancing===!1||!rt.isInstancedMesh&&yt.instancing===!0||rt.isSkinnedMesh&&yt.skinning===!1||!rt.isSkinnedMesh&&yt.skinning===!0||rt.isInstancedMesh&&yt.instancingColor===!0&&rt.instanceColor===null||rt.isInstancedMesh&&yt.instancingColor===!1&&rt.instanceColor!==null||yt.envMap!==Yt||ct.fog===!0&&yt.fog!==jt||yt.numClippingPlanes!==void 0&&(yt.numClippingPlanes!==Ze.numPlanes||yt.numIntersection!==Ze.numIntersection)||yt.vertexAlphas!==ue||yt.vertexTangents!==Re||yt.morphTargets!==He||yt.morphNormals!==Xe||yt.morphColors!==Ge||yt.toneMapping!==ht||ee.isWebGL2===!0&&yt.morphTargetsCount!==_t)&&(Ot=!0):(Ot=!0,yt.__version=ct.version);let Ft=yt.currentProgram;Ot===!0&&(Ft=yr(ct,Ve,rt));let be=!1,Pe=!1,wt=!1;const Mt=Ft.getUniforms(),lt=yt.uniforms;if(X.useProgram(Ft.program)&&(be=!0,Pe=!0,wt=!0),ct.id!==O&&(O=ct.id,Pe=!0),be||C!==_e){Mt.setValue(le,"projectionMatrix",_e.projectionMatrix),Mt.setValue(le,"viewMatrix",_e.matrixWorldInverse);const Rt=Mt.map.cameraPosition;Rt!==void 0&&Rt.setValue(le,me.setFromMatrixPosition(_e.matrixWorld)),ee.logarithmicDepthBuffer&&Mt.setValue(le,"logDepthBufFC",2/(Math.log(_e.far+1)/Math.LN2)),(ct.isMeshPhongMaterial||ct.isMeshToonMaterial||ct.isMeshLambertMaterial||ct.isMeshBasicMaterial||ct.isMeshStandardMaterial||ct.isShaderMaterial)&&Mt.setValue(le,"isOrthographic",_e.isOrthographicCamera===!0),C!==_e&&(C=_e,Pe=!0,wt=!0)}if(rt.isSkinnedMesh){Mt.setOptional(le,rt,"bindMatrix"),Mt.setOptional(le,rt,"bindMatrixInverse");const Rt=rt.skeleton;Rt&&(ee.floatVertexTextures?(Rt.boneTexture===null&&Rt.computeBoneTexture(),Mt.setValue(le,"boneTexture",Rt.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."))}rt.isBatchedMesh&&(Mt.setOptional(le,rt,"batchingTexture"),Mt.setValue(le,"batchingTexture",rt._matricesTexture,ce));const Tt=at.morphAttributes;if((Tt.position!==void 0||Tt.normal!==void 0||Tt.color!==void 0&&ee.isWebGL2===!0)&&Je.update(rt,at,Ft),(Pe||yt.receiveShadow!==rt.receiveShadow)&&(yt.receiveShadow=rt.receiveShadow,Mt.setValue(le,"receiveShadow",rt.receiveShadow)),ct.isMeshGouraudMaterial&&ct.envMap!==null&&(lt.envMap.value=Yt,lt.flipEnvMap.value=Yt.isCubeTexture&&Yt.isRenderTargetTexture===!1?-1:1),Pe&&(Mt.setValue(le,"toneMappingExposure",M.toneMappingExposure),yt.needsLights&&Gr(lt,wt),jt&&ct.fog===!0&&ge.refreshFogUniforms(lt,jt),ge.refreshMaterialUniforms(lt,ct,V,K,fe),w1.upload(le,jn(yt),lt,ce)),ct.isShaderMaterial&&ct.uniformsNeedUpdate===!0&&(w1.upload(le,jn(yt),lt,ce),ct.uniformsNeedUpdate=!1),ct.isSpriteMaterial&&Mt.setValue(le,"center",rt.center),Mt.setValue(le,"modelViewMatrix",rt.modelViewMatrix),Mt.setValue(le,"normalMatrix",rt.normalMatrix),Mt.setValue(le,"modelMatrix",rt.matrixWorld),ct.isShaderMaterial||ct.isRawShaderMaterial){const Rt=ct.uniformsGroups;for(let $t=0,Ln=Rt.length;$t<Ln;$t++)if(ee.isWebGL2){const bi=Rt[$t];Fe.update(bi,Ft),Fe.bind(bi,Ft)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return Ft}function Gr(_e,Ve){_e.ambientLightColor.needsUpdate=Ve,_e.lightProbe.needsUpdate=Ve,_e.directionalLights.needsUpdate=Ve,_e.directionalLightShadows.needsUpdate=Ve,_e.pointLights.needsUpdate=Ve,_e.pointLightShadows.needsUpdate=Ve,_e.spotLights.needsUpdate=Ve,_e.spotLightShadows.needsUpdate=Ve,_e.rectAreaLights.needsUpdate=Ve,_e.hemisphereLights.needsUpdate=Ve}function Dr(_e){return _e.isMeshLambertMaterial||_e.isMeshToonMaterial||_e.isMeshPhongMaterial||_e.isMeshStandardMaterial||_e.isShadowMaterial||_e.isShaderMaterial&&_e.lights===!0}this.getActiveCubeFace=function(){return T},this.getActiveMipmapLevel=function(){return k},this.getRenderTarget=function(){return E},this.setRenderTargetTextures=function(_e,Ve,at){I.get(_e.texture).__webglTexture=Ve,I.get(_e.depthTexture).__webglTexture=at;const ct=I.get(_e);ct.__hasExternalTextures=!0,ct.__hasExternalTextures&&(ct.__autoAllocateDepthBuffer=at===void 0,ct.__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"),ct.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(_e,Ve){const at=I.get(_e);at.__webglFramebuffer=Ve,at.__useDefaultFramebuffer=Ve===void 0},this.setRenderTarget=function(_e,Ve=0,at=0){E=_e,T=Ve,k=at;let ct=!0,rt=null,jt=!1,zt=!1;if(_e){const Yt=I.get(_e);Yt.__useDefaultFramebuffer!==void 0?(X.bindFramebuffer(le.FRAMEBUFFER,null),ct=!1):Yt.__webglFramebuffer===void 0?ce.setupRenderTarget(_e):Yt.__hasExternalTextures&&ce.rebindTextures(_e,I.get(_e.texture).__webglTexture,I.get(_e.depthTexture).__webglTexture);const ue=_e.texture;(ue.isData3DTexture||ue.isDataArrayTexture||ue.isCompressedArrayTexture)&&(zt=!0);const Re=I.get(_e).__webglFramebuffer;_e.isWebGLCubeRenderTarget?(Array.isArray(Re[Ve])?rt=Re[Ve][at]:rt=Re[Ve],jt=!0):ee.isWebGL2&&_e.samples>0&&ce.useMultisampledRTT(_e)===!1?rt=I.get(_e).__webglMultisampledFramebuffer:Array.isArray(Re)?rt=Re[at]:rt=Re,D.copy(_e.viewport),U.copy(_e.scissor),L=_e.scissorTest}else D.copy(J).multiplyScalar(V).floor(),U.copy(z).multiplyScalar(V).floor(),L=G;if(X.bindFramebuffer(le.FRAMEBUFFER,rt)&&ee.drawBuffers&&ct&&X.drawBuffers(_e,rt),X.viewport(D),X.scissor(U),X.setScissorTest(L),jt){const Yt=I.get(_e.texture);le.framebufferTexture2D(le.FRAMEBUFFER,le.COLOR_ATTACHMENT0,le.TEXTURE_CUBE_MAP_POSITIVE_X+Ve,Yt.__webglTexture,at)}else if(zt){const Yt=I.get(_e.texture),ue=Ve||0;le.framebufferTextureLayer(le.FRAMEBUFFER,le.COLOR_ATTACHMENT0,Yt.__webglTexture,at||0,ue)}O=-1},this.readRenderTargetPixels=function(_e,Ve,at,ct,rt,jt,zt){if(!(_e&&_e.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Xt=I.get(_e).__webglFramebuffer;if(_e.isWebGLCubeRenderTarget&&zt!==void 0&&(Xt=Xt[zt]),Xt){X.bindFramebuffer(le.FRAMEBUFFER,Xt);try{const Yt=_e.texture,ue=Yt.format,Re=Yt.type;if(ue!==Eo&&te.convert(ue)!==le.getParameter(le.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const He=Re===ry&&(H.has("EXT_color_buffer_half_float")||ee.isWebGL2&&H.has("EXT_color_buffer_float"));if(Re!==qd&&te.convert(Re)!==le.getParameter(le.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Re===ru&&(ee.isWebGL2||H.has("OES_texture_float")||H.has("WEBGL_color_buffer_float")))&&!He){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Ve>=0&&Ve<=_e.width-ct&&at>=0&&at<=_e.height-rt&&le.readPixels(Ve,at,ct,rt,te.convert(ue),te.convert(Re),jt)}finally{const Yt=E!==null?I.get(E).__webglFramebuffer:null;X.bindFramebuffer(le.FRAMEBUFFER,Yt)}}},this.copyFramebufferToTexture=function(_e,Ve,at=0){const ct=Math.pow(2,-at),rt=Math.floor(Ve.image.width*ct),jt=Math.floor(Ve.image.height*ct);ce.setTexture2D(Ve,0),le.copyTexSubImage2D(le.TEXTURE_2D,at,0,0,_e.x,_e.y,rt,jt),X.unbindTexture()},this.copyTextureToTexture=function(_e,Ve,at,ct=0){const rt=Ve.image.width,jt=Ve.image.height,zt=te.convert(at.format),Xt=te.convert(at.type);ce.setTexture2D(at,0),le.pixelStorei(le.UNPACK_FLIP_Y_WEBGL,at.flipY),le.pixelStorei(le.UNPACK_PREMULTIPLY_ALPHA_WEBGL,at.premultiplyAlpha),le.pixelStorei(le.UNPACK_ALIGNMENT,at.unpackAlignment),Ve.isDataTexture?le.texSubImage2D(le.TEXTURE_2D,ct,_e.x,_e.y,rt,jt,zt,Xt,Ve.image.data):Ve.isCompressedTexture?le.compressedTexSubImage2D(le.TEXTURE_2D,ct,_e.x,_e.y,Ve.mipmaps[0].width,Ve.mipmaps[0].height,zt,Ve.mipmaps[0].data):le.texSubImage2D(le.TEXTURE_2D,ct,_e.x,_e.y,zt,Xt,Ve.image),ct===0&&at.generateMipmaps&&le.generateMipmap(le.TEXTURE_2D),X.unbindTexture()},this.copyTextureToTexture3D=function(_e,Ve,at,ct,rt=0){if(M.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const jt=_e.max.x-_e.min.x+1,zt=_e.max.y-_e.min.y+1,Xt=_e.max.z-_e.min.z+1,Yt=te.convert(ct.format),ue=te.convert(ct.type);let Re;if(ct.isData3DTexture)ce.setTexture3D(ct,0),Re=le.TEXTURE_3D;else if(ct.isDataArrayTexture)ce.setTexture2DArray(ct,0),Re=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,ct.flipY),le.pixelStorei(le.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ct.premultiplyAlpha),le.pixelStorei(le.UNPACK_ALIGNMENT,ct.unpackAlignment);const He=le.getParameter(le.UNPACK_ROW_LENGTH),Xe=le.getParameter(le.UNPACK_IMAGE_HEIGHT),Ge=le.getParameter(le.UNPACK_SKIP_PIXELS),ht=le.getParameter(le.UNPACK_SKIP_ROWS),Pt=le.getParameter(le.UNPACK_SKIP_IMAGES),_t=at.isCompressedTexture?at.mipmaps[0]:at.image;le.pixelStorei(le.UNPACK_ROW_LENGTH,_t.width),le.pixelStorei(le.UNPACK_IMAGE_HEIGHT,_t.height),le.pixelStorei(le.UNPACK_SKIP_PIXELS,_e.min.x),le.pixelStorei(le.UNPACK_SKIP_ROWS,_e.min.y),le.pixelStorei(le.UNPACK_SKIP_IMAGES,_e.min.z),at.isDataTexture||at.isData3DTexture?le.texSubImage3D(Re,rt,Ve.x,Ve.y,Ve.z,jt,zt,Xt,Yt,ue,_t.data):at.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),le.compressedTexSubImage3D(Re,rt,Ve.x,Ve.y,Ve.z,jt,zt,Xt,Yt,_t.data)):le.texSubImage3D(Re,rt,Ve.x,Ve.y,Ve.z,jt,zt,Xt,Yt,ue,_t),le.pixelStorei(le.UNPACK_ROW_LENGTH,He),le.pixelStorei(le.UNPACK_IMAGE_HEIGHT,Xe),le.pixelStorei(le.UNPACK_SKIP_PIXELS,Ge),le.pixelStorei(le.UNPACK_SKIP_ROWS,ht),le.pixelStorei(le.UNPACK_SKIP_IMAGES,Pt),rt===0&&ct.generateMipmaps&&le.generateMipmap(Re),X.unbindTexture()},this.initTexture=function(_e){_e.isCubeTexture?ce.setTextureCube(_e,0):_e.isData3DTexture?ce.setTexture3D(_e,0):_e.isDataArrayTexture||_e.isCompressedArrayTexture?ce.setTexture2DArray(_e,0):ce.setTexture2D(_e,0),X.unbindTexture()},this.resetState=function(){T=0,k=0,E=null,X.reset(),Me.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Gl}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=e===yL?"display-p3":"srgb",n.unpackColorSpace=mr.workingColorSpace===xE?"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===wa?Df:Xee}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===Df?wa:Nu}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 i6e extends OR{}i6e.prototype.isWebGL1Renderer=!0;class NL{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 NL(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class a6e extends ts{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 s6e{constructor(e,n){this.isInterleavedBuffer=!0,this.array=e,this.stride=n,this.count=e!==void 0?e.length/n:0,this.usage=jR,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=du()}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=du()),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=du()),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 qa=new Be;class Od{constructor(e,n,r,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=n,this.offset=r,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let n=0,r=this.data.count;n<r;n++)qa.fromBufferAttribute(this,n),qa.applyMatrix4(e),this.setXYZ(n,qa.x,qa.y,qa.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)qa.fromBufferAttribute(this,n),qa.applyNormalMatrix(e),this.setXYZ(n,qa.x,qa.y,qa.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)qa.fromBufferAttribute(this,n),qa.transformDirection(e),this.setXYZ(n,qa.x,qa.y,qa.z);return this}setX(e,n){return this.normalized&&(n=fr(n,this.array)),this.data.array[e*this.data.stride+this.offset]=n,this}setY(e,n){return this.normalized&&(n=fr(n,this.array)),this.data.array[e*this.data.stride+this.offset+1]=n,this}setZ(e,n){return this.normalized&&(n=fr(n,this.array)),this.data.array[e*this.data.stride+this.offset+2]=n,this}setW(e,n){return this.normalized&&(n=fr(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=Ul(n,this.array)),n}getY(e){let n=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(n=Ul(n,this.array)),n}getZ(e){let n=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(n=Ul(n,this.array)),n}getW(e){let n=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(n=Ul(n,this.array)),n}setXY(e,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(n=fr(n,this.array),r=fr(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=fr(n,this.array),r=fr(r,this.array),i=fr(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=fr(n,this.array),r=fr(r,this.array),i=fr(i,this.array),a=fr(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 Zs(new this.array.constructor(n),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new Od(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const n=[];for(let r=0;r<this.count;r++){const i=r*this.data.stride+this.offset;for(let a=0;a<this.itemSize;a++)n.push(this.data.array[i+a])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:n,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class o6e extends Es{constructor(e=null,n=1,r=1,i,a,o,l,c,u=_a,d=_a,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 l6e(t,e){return t.z-e.z}function c6e(t,e){return e.z-t.z}class u6e{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 Ip="batchId",md=new Nr,Y7=new Nr,d6e=new Nr,Z7=new Nr,aj=new bE,Cw=new jo,Qh=new Yl,Rb=new Be,sj=new u6e,La=new al,kw=[];function h6e(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 f6e extends al{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,n,r=n*2,i){super(new Va,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 o6e(n,e,e,Eo,ru);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 Zs(l,1))}const o=i>65536?new Uint32Array(r):new Uint16Array(r);n.setAttribute(Ip,new Zs(o,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(Ip))throw new Error(`BatchedMesh: Geometry cannot use attribute "${Ip}"`);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===Ip)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 jo);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,md),this.getBoundingBoxAt(i,Cw).applyMatrix4(md),n.union(Cw))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Yl);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,md),this.getBoundingSphereAt(i,Qh).applyMatrix4(md),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++,d6e.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 jo,sphereInitialized:!1,sphere:new Yl});const x=this.geometry.getAttribute(Ip);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===Ip)continue;const b=n.getAttribute(p),y=r.getAttribute(p);h6e(b,y,c);const x=b.itemSize;for(let v=b.count,S=u;v<S;v++){const M=c+v;for(let A=0;A<x;A++)y.setComponent(M,A,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(Rb.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,Cw),Cw.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)),Rb.fromBufferAttribute(c,p),d=Math.max(d,a.center.distanceToSquared(Rb))}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;La.material=this.material,La.geometry.index=c.index,La.geometry.attributes=c.attributes,La.geometry.boundingBox===null&&(La.geometry.boundingBox=new jo),La.geometry.boundingSphere===null&&(La.geometry.boundingSphere=new Yl);for(let u=0;u<o;u++){if(!r[u]||!i[u])continue;const d=a[u];La.geometry.setDrawRange(d.start,d.count),this.getMatrixAt(u,La.matrixWorld).premultiply(l),this.getBoundingBoxAt(u,La.geometry.boundingBox),this.getBoundingSphereAt(u,La.geometry.boundingSphere),La.raycast(e,kw);for(let f=0,m=kw.length;f<m;f++){const p=kw[f];p.object=this,p.batchId=u,n.push(p)}kw.length=0}La.material=null,La.geometry.index=null,La.geometry.attributes={},La.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&&(Z7.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse).multiply(this.matrixWorld),aj.setFromProjectionMatrix(Z7,e.isWebGPURenderer?iy:Gl));let p=0;if(this.sortObjects){Y7.copy(this.matrixWorld).invert(),Rb.setFromMatrixPosition(r.matrixWorld).applyMatrix4(Y7);for(let x=0,v=c.length;x<v;x++)if(c[x]){this.getMatrixAt(x,md),this.getBoundingSphereAt(x,Qh).applyMatrix4(md);let S=!1;if(m&&(S=!aj.intersectsSphere(Qh)),!S){const M=Rb.distanceTo(Qh.center);sj.push(f[x],M)}}const b=sj.list,y=this.customSort;y===null?b.sort(a.transparent?c6e:l6e):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++}sj.reset()}else for(let b=0,y=c.length;b<y;b++)if(c[b]){let x=!1;if(m&&(this.getMatrixAt(b,md),this.getBoundingSphereAt(b,Qh).applyMatrix4(md),x=!aj.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 Jy extends mx{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 Q7=new Be,J7=new Be,e9=new Nr,oj=new _L,jw=new Yl;class m6e extends ts{constructor(e=new Va,n=new Jy){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++)Q7.fromBufferAttribute(n,i-1),J7.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=Q7.distanceTo(J7);e.setAttribute("lineDistance",new xi(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(),jw.copy(r.boundingSphere),jw.applyMatrix4(i),jw.radius+=a,e.ray.intersectsSphere(jw)===!1)return;e9.copy(i).invert(),oj.copy(e.ray).applyMatrix4(e9);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,A=S-1;M<A;M+=p){const T=b.getX(M),k=b.getX(M+1);if(u.fromBufferAttribute(x,T),d.fromBufferAttribute(x,k),oj.distanceSqToSegment(u,d,m,f)>c)continue;m.applyMatrix4(this.matrixWorld);const O=e.ray.origin.distanceTo(m);O<e.near||O>e.far||n.push({distance:O,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,A=S-1;M<A;M+=p){if(u.fromBufferAttribute(x,M),d.fromBufferAttribute(x,M+1),oj.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 t9=new Be,n9=new Be;class vE extends m6e{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)t9.fromBufferAttribute(n,i),n9.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+t9.distanceTo(n9);e.setAttribute("lineDistance",new xi(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class p6e extends Va{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),r9(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),r9(i,a,r)===!0&&(n.push(i.x,i.y,i.z),n.push(a.x,a.y,a.z))}}this.setAttribute("position",new xi(n,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function r9(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 g6e extends mx{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=Yee,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=xL,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 x6e extends Jy{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 bte extends ts{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 lj=new Nr,i9=new Be,a9=new Be;class b6e{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 Nr,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new bE,this._frameExtents=new mn(1,1),this._viewportCount=1,this._viewports=[new gr(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;i9.setFromMatrixPosition(e.matrixWorld),n.position.copy(i9),a9.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(a9),n.updateMatrixWorld(),lj.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(lj),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(lj)}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 s9=new Nr,Db=new Be,cj=new Be;class y6e extends b6e{constructor(){super(new $s(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new mn(4,2),this._viewportCount=6,this._viewports=[new gr(2,1,1,1),new gr(0,1,1,1),new gr(3,1,1,1),new gr(1,1,1,1),new gr(3,0,1,1),new gr(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()),Db.setFromMatrixPosition(e.matrixWorld),r.position.copy(Db),cj.copy(r.position),cj.add(this._cubeDirections[n]),r.up.copy(this._cubeUps[n]),r.lookAt(cj),r.updateMatrixWorld(),i.makeTranslation(-Db.x,-Db.y,-Db.z),s9.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(s9)}}class v6e extends bte{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 y6e}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 _6e extends bte{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}}class w6e extends Va{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 LR extends s6e{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 o9{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(Sa(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const l9=new Be,Pw=new Be;class S6e{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){l9.subVectors(e,this.start),Pw.subVectors(this.end,this.start);const r=Pw.dot(Pw);let a=Pw.dot(l9)/r;return n&&(a=Sa(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 M6e extends vE{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 Va;i.setAttribute("position",new xi(n,3)),i.setAttribute("color",new xi(r,3));const a=new Jy({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:pE}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=pE);class Zl{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"),Zl.nextNameID=Zl.nextNameID||0,this.$name.id=`lil-gui-name-${++Zl.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 N6e extends Zl{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 IR(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 E6e={isPrimitive:!0,match:t=>typeof t=="string",fromHexString:IR,toHexString:IR},sy={isPrimitive:!0,match:t=>typeof t=="number",fromHexString:t=>parseInt(t.substring(1),16),toHexString:t=>"#"+t.toString(16).padStart(6,0)},A6e={isPrimitive:!1,match:t=>Array.isArray(t),fromHexString(t,e,n=1){const r=sy.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 sy.toHexString(i)}},T6e={isPrimitive:!1,match:t=>Object(t)===t,fromHexString(t,e,n=1){const r=sy.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 sy.toHexString(i)}},C6e=[E6e,sy,A6e,T6e];function k6e(t){return C6e.find(e=>e.match(t))}class j6e extends Zl{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=k6e(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=IR(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 uj extends Zl{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 P6e extends Zl{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,A=S.clientY-c;Math.abs(A)>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,A,T)=>(v-S)/(M-S)*(T-A)+A,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 R6e extends Zl{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 D6e extends Zl{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 O6e=`.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 L6e(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 c9=!1;class eM{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"),!c9&&l&&(L6e(O6e),c9=!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 R6e(this,e,n,r);const o=e[n];switch(typeof o){case"number":return new P6e(this,e,n,r,i,a);case"boolean":return new N6e(this,e,n);case"string":return new D6e(this,e,n);case"function":return new uj(this,e,n)}console.error(`gui.add failed
- property:`,n,`
- object:`,e,`
- value:`,o)}addColor(e,n,r=1){return new j6e(this,e,n,r)}addFolder(e){const n=new eM({parent:this,title:e});return this.root._closeFolders&&n.close(),n}load(e,n=!0){return e.controllers&&this.controllers.forEach(r=>{r instanceof uj||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 uj)){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 dj(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 EL{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 EL(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 AL{constructor(e,n,r,i){this.src=e,this.gcode=n,this.params=r,this.comment=i}}class u9 extends AL{constructor(e,n,r,i){super(e,n,r,i),this.params=r}}class pd extends AL{constructor(e,n,r,i){super(e,n,void 0,r),this.toolIndex=i}}class d9{constructor(e,n,r,i=0){this.layer=e,this.commands=n,this.lineNumber=r,this.height=i}}class tM{constructor(e){this.lines=[],this.preamble=new d9(-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 u9(e,c,u,o);case"t0":return new pd(e,c,o,0);case"t1":return new pd(e,c,o,1);case"t2":return new pd(e,c,o,2);case"t3":return new pd(e,c,o,3);case"t4":return new pd(e,c,o,4);case"t5":return new pd(e,c,o,5);case"t6":return new pd(e,c,o,6);case"t7":return new pd(e,c,o,7);default:return new AL(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 u9){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 d9(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=EL.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}}}tM.prototype.parseGcode=tM.prototype.parseGCode;const h9={type:"change"},hj={type:"start"},f9={type:"end"},Rw=new _L,m9=new wd,I6e=Math.cos(70*Qee.DEG2RAD);class F6e extends bm{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:yp.ROTATE,MIDDLE:yp.DOLLY,RIGHT:yp.PAN},this.touches={ONE:vp.ROTATE,TWO:vp.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(ee){ee.addEventListener("keydown",ye),this._domElementKeyEvents=ee},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",ye),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(h9),r.update(),a=i.NONE},this.update=(function(){const ee=new Be,X=new om().setFromUnitVectors(e.up,new Be(0,1,0)),B=X.clone().invert(),I=new Be,ce=new om,Te=new Be,Le=2*Math.PI;return function(Ee=null){const $=r.object.position;ee.copy($).sub(r.target),ee.applyQuaternion(X),l.setFromVector3(ee),r.autoRotate&&a===i.NONE&&D((function(we){return we!==null?2*Math.PI/60*r.autoRotateSpeed*we:2*Math.PI/60/60*r.autoRotateSpeed})(Ee)),r.enableDamping?(l.theta+=c.theta*r.dampingFactor,l.phi+=c.phi*r.dampingFactor):(l.theta+=c.theta,l.phi+=c.phi);let j=r.minAzimuthAngle,Y=r.maxAzimuthAngle;isFinite(j)&&isFinite(Y)&&(j<-Math.PI?j+=Le:j>Math.PI&&(j-=Le),Y<-Math.PI?Y+=Le:Y>Math.PI&&(Y-=Le),l.theta=j<=Y?Math.max(j,Math.min(Y,l.theta)):l.theta>(j+Y)/2?Math.max(j,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=Q(l.radius):l.radius=Q(l.radius*u),ee.setFromSpherical(l),ee.applyQuaternion(B),$.copy(r.target).add(ee),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 ge=!1;if(r.zoomToCursor&&k){let we=null;if(r.object.isPerspectiveCamera){const ve=ee.length();we=Q(ve*u);const Ze=ve-we;r.object.position.addScaledVector(A,Ze),r.object.updateMatrixWorld()}else if(r.object.isOrthographicCamera){const ve=new Be(T.x,T.y,0);ve.unproject(r.object),r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),ge=!0;const Ze=new Be(T.x,T.y,0);Ze.unproject(r.object),r.object.position.sub(Ze).add(ve),r.object.updateMatrixWorld(),we=ee.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),r.zoomToCursor=!1;we!==null&&(this.screenSpacePanning?r.target.set(0,0,-1).transformDirection(r.object.matrix).multiplyScalar(we).add(r.object.position):(Rw.origin.copy(r.object.position),Rw.direction.set(0,0,-1).transformDirection(r.object.matrix),Math.abs(r.object.up.dot(Rw.direction))<I6e?e.lookAt(r.target):(m9.setFromNormalAndCoplanarPoint(r.object.up,r.target),Rw.intersectPlane(m9,r.target))))}else r.object.isOrthographicCamera&&(r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),ge=!0);return u=1,k=!1,!!(ge||I.distanceToSquared(r.object.position)>o||8*(1-ce.dot(r.object.quaternion))>o||Te.distanceToSquared(r.target)>0)&&(r.dispatchEvent(h9),I.copy(r.object.position),ce.copy(r.object.quaternion),Te.copy(r.target),!0)}})(),this.dispose=function(){r.domElement.removeEventListener("contextmenu",le),r.domElement.removeEventListener("pointerdown",ie),r.domElement.removeEventListener("pointercancel",me),r.domElement.removeEventListener("wheel",Ne),r.domElement.removeEventListener("pointermove",Ae),r.domElement.removeEventListener("pointerup",me),r._domElementKeyEvents!==null&&(r._domElementKeyEvents.removeEventListener("keydown",ye),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 o9,c=new o9;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,A=new Be,T=new mn;let k=!1;const E=[],O={};function C(){return Math.pow(.95,r.zoomSpeed)}function D(ee){c.theta-=ee}function U(ee){c.phi-=ee}const L=(function(){const ee=new Be;return function(X,B){ee.setFromMatrixColumn(B,0),ee.multiplyScalar(-X),d.add(ee)}})(),q=(function(){const ee=new Be;return function(X,B){r.screenSpacePanning===!0?ee.setFromMatrixColumn(B,1):(ee.setFromMatrixColumn(B,0),ee.crossVectors(r.object.up,ee)),ee.multiplyScalar(X),d.add(ee)}})(),P=(function(){const ee=new Be;return function(X,B){const I=r.domElement;if(r.object.isPerspectiveCamera){const ce=r.object.position;ee.copy(ce).sub(r.target);let Te=ee.length();Te*=Math.tan(r.object.fov/2*Math.PI/180),L(2*X*Te/I.clientHeight,r.object.matrix),q(2*B*Te/I.clientHeight,r.object.matrix)}else r.object.isOrthographicCamera?(L(X*(r.object.right-r.object.left)/r.object.zoom/I.clientWidth,r.object.matrix),q(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(ee){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u/=ee:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function K(ee){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u*=ee:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function V(ee){if(!r.zoomToCursor)return;k=!0;const X=r.domElement.getBoundingClientRect(),B=ee.clientX-X.left,I=ee.clientY-X.top,ce=X.width,Te=X.height;T.x=B/ce*2-1,T.y=-I/Te*2+1,A.set(T.x,T.y,1).unproject(r.object).sub(r.object.position).normalize()}function Q(ee){return Math.max(r.minDistance,Math.min(r.maxDistance,ee))}function re(ee){f.set(ee.clientX,ee.clientY)}function J(ee){b.set(ee.clientX,ee.clientY)}function z(){if(E.length===1)f.set(E[0].pageX,E[0].pageY);else{const ee=.5*(E[0].pageX+E[1].pageX),X=.5*(E[0].pageY+E[1].pageY);f.set(ee,X)}}function G(){if(E.length===1)b.set(E[0].pageX,E[0].pageY);else{const ee=.5*(E[0].pageX+E[1].pageX),X=.5*(E[0].pageY+E[1].pageY);b.set(ee,X)}}function ne(){const ee=E[0].pageX-E[1].pageX,X=E[0].pageY-E[1].pageY,B=Math.sqrt(ee*ee+X*X);v.set(0,B)}function ae(ee){if(E.length==1)m.set(ee.pageX,ee.pageY);else{const B=H(ee),I=.5*(ee.pageX+B.x),ce=.5*(ee.pageY+B.y);m.set(I,ce)}p.subVectors(m,f).multiplyScalar(r.rotateSpeed);const X=r.domElement;D(2*Math.PI*p.x/X.clientHeight),U(2*Math.PI*p.y/X.clientHeight),f.copy(m)}function de(ee){if(E.length===1)y.set(ee.pageX,ee.pageY);else{const X=H(ee),B=.5*(ee.pageX+X.x),I=.5*(ee.pageY+X.y);y.set(B,I)}x.subVectors(y,b).multiplyScalar(r.panSpeed),P(x.x,x.y),b.copy(y)}function fe(ee){const X=H(ee),B=ee.pageX-X.x,I=ee.pageY-X.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 ie(ee){r.enabled!==!1&&(E.length===0&&(r.domElement.setPointerCapture(ee.pointerId),r.domElement.addEventListener("pointermove",Ae),r.domElement.addEventListener("pointerup",me)),(function(X){E.push(X)})(ee),ee.pointerType==="touch"?(function(X){switch($e(X),E.length){case 1:switch(r.touches.ONE){case vp.ROTATE:if(r.enableRotate===!1)return;z(),a=i.TOUCH_ROTATE;break;case vp.PAN:if(r.enablePan===!1)return;G(),a=i.TOUCH_PAN;break;default:a=i.NONE}break;case 2:switch(r.touches.TWO){case vp.DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;r.enableZoom&&ne(),r.enablePan&&G(),a=i.TOUCH_DOLLY_PAN;break;case vp.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(hj)})(ee):(function(X){let B;switch(X.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 yp.DOLLY:if(r.enableZoom===!1)return;(function(I){V(I),v.set(I.clientX,I.clientY)})(X),a=i.DOLLY;break;case yp.ROTATE:if(X.ctrlKey||X.metaKey||X.shiftKey){if(r.enablePan===!1)return;J(X),a=i.PAN}else{if(r.enableRotate===!1)return;re(X),a=i.ROTATE}break;case yp.PAN:if(X.ctrlKey||X.metaKey||X.shiftKey){if(r.enableRotate===!1)return;re(X),a=i.ROTATE}else{if(r.enablePan===!1)return;J(X),a=i.PAN}break;default:a=i.NONE}a!==i.NONE&&r.dispatchEvent(hj)})(ee))}function Ae(ee){r.enabled!==!1&&(ee.pointerType==="touch"?(function(X){switch($e(X),a){case i.TOUCH_ROTATE:if(r.enableRotate===!1)return;ae(X),r.update();break;case i.TOUCH_PAN:if(r.enablePan===!1)return;de(X),r.update();break;case i.TOUCH_DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;(function(B){r.enableZoom&&fe(B),r.enablePan&&de(B)})(X),r.update();break;case i.TOUCH_DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;(function(B){r.enableZoom&&fe(B),r.enableRotate&&ae(B)})(X),r.update();break;default:a=i.NONE}})(ee):(function(X){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;D(2*Math.PI*p.x/I.clientHeight),U(2*Math.PI*p.y/I.clientHeight),f.copy(m),r.update()})(X);break;case i.DOLLY:if(r.enableZoom===!1)return;(function(B){S.set(B.clientX,B.clientY),M.subVectors(S,v),M.y>0?W(C()):M.y<0&&K(C()),v.copy(S),r.update()})(X);break;case i.PAN:if(r.enablePan===!1)return;(function(B){y.set(B.clientX,B.clientY),x.subVectors(y,b).multiplyScalar(r.panSpeed),P(x.x,x.y),b.copy(y),r.update()})(X)}})(ee))}function me(ee){(function(X){delete O[X.pointerId];for(let B=0;B<E.length;B++)if(E[B].pointerId==X.pointerId)return void E.splice(B,1)})(ee),E.length===0&&(r.domElement.releasePointerCapture(ee.pointerId),r.domElement.removeEventListener("pointermove",Ae),r.domElement.removeEventListener("pointerup",me)),r.dispatchEvent(f9),a=i.NONE}function Ne(ee){r.enabled!==!1&&r.enableZoom!==!1&&a===i.NONE&&(ee.preventDefault(),r.dispatchEvent(hj),(function(X){V(X),X.deltaY<0?K(C()):X.deltaY>0&&W(C()),r.update()})(ee),r.dispatchEvent(f9))}function ye(ee){r.enabled!==!1&&r.enablePan!==!1&&(function(X){let B=!1;switch(X.code){case r.keys.UP:X.ctrlKey||X.metaKey||X.shiftKey?U(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):P(0,r.keyPanSpeed),B=!0;break;case r.keys.BOTTOM:X.ctrlKey||X.metaKey||X.shiftKey?U(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):P(0,-r.keyPanSpeed),B=!0;break;case r.keys.LEFT:X.ctrlKey||X.metaKey||X.shiftKey?D(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):P(r.keyPanSpeed,0),B=!0;break;case r.keys.RIGHT:X.ctrlKey||X.metaKey||X.shiftKey?D(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):P(-r.keyPanSpeed,0),B=!0}B&&(X.preventDefault(),r.update())})(ee)}function le(ee){r.enabled!==!1&&ee.preventDefault()}function $e(ee){let X=O[ee.pointerId];X===void 0&&(X=new mn,O[ee.pointerId]=X),X.set(ee.pageX,ee.pageY)}function H(ee){const X=ee.pointerId===E[0].pointerId?E[1]:E[0];return O[X.pointerId]}r.domElement.addEventListener("contextmenu",le),r.domElement.addEventListener("pointerdown",ie),r.domElement.addEventListener("pointercancel",me),r.domElement.addEventListener("wheel",Ne,{passive:!1}),this.update()}}Dt.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}},ys.line={uniforms:wL.merge([Dt.common,Dt.fog,Dt.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 yte extends oh{constructor(e){super({type:"LineMaterial",uniforms:wL.clone(ys.line.uniforms),vertexShader:ys.line.vertexShader,fragmentShader:ys.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 p9=new jo,Dw=new Be;class vte extends w6e{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 xi([-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 xi([-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 LR(n,6,1);return this.setAttribute("instanceStart",new Od(r,3,0)),this.setAttribute("instanceEnd",new Od(r,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let n;e instanceof Float32Array?n=e:Array.isArray(e)&&(n=new Float32Array(e));const r=new LR(n,6,1);return this.setAttribute("instanceColorStart",new Od(r,3,0)),this.setAttribute("instanceColorEnd",new Od(r,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new p6e(e.geometry)),this}fromLineSegments(e){const n=e.geometry;return this.setPositions(n.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new jo);const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;e!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(e),p9.setFromBufferAttribute(n),this.boundingBox.union(p9))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Yl),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++)Dw.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(Dw)),Dw.fromBufferAttribute(n,a),i=Math.max(i,r.distanceToSquared(Dw));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 g9=new Be,x9=new Be,pa=new gr,ga=new gr,kl=new gr,fj=new Be,mj=new Nr,xa=new S6e,b9=new Be,Ow=new jo,Lw=new Yl,jl=new gr;let Pl,uf;function y9(t,e,n){return jl.set(0,0,-e,1).applyMatrix4(t.projectionMatrix),jl.multiplyScalar(1/jl.w),jl.x=uf/n.width,jl.y=uf/n.height,jl.applyMatrix4(t.projectionMatrixInverse),jl.multiplyScalar(1/jl.w),Math.abs(Math.max(jl.x,jl.y))}class U6e extends al{constructor(e=new vte,n=new yte({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)g9.fromBufferAttribute(n,o),x9.fromBufferAttribute(r,o),i[l]=l===0?0:i[l-1],i[l+1]=i[l]+g9.distanceTo(x9);const a=new LR(i,2,1);return e.setAttribute("instanceDistanceStart",new Od(a,1,0)),e.setAttribute("instanceDistanceEnd",new Od(a,1,1)),this}raycast(e,n){const r=this.material.worldUnits,i=e.camera;i!==null||r||console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const a=e.params.Line2!==void 0&&e.params.Line2.threshold||0;Pl=e.ray;const o=this.matrixWorld,l=this.geometry,c=this.material;let u,d;uf=c.linewidth+a,l.boundingSphere===null&&l.computeBoundingSphere(),Lw.copy(l.boundingSphere).applyMatrix4(o),r?u=.5*uf:u=y9(i,Math.max(i.near,Lw.distanceToPoint(Pl.origin)),c.resolution),Lw.radius+=u,Pl.intersectsSphere(Lw)!==!1&&(l.boundingBox===null&&l.computeBoundingBox(),Ow.copy(l.boundingBox).applyMatrix4(o),r?d=.5*uf:d=y9(i,Math.max(i.near,Ow.distanceToPoint(Pl.origin)),c.resolution),Ow.expandByScalar(d),Pl.intersectsBox(Ow)!==!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++){xa.start.fromBufferAttribute(y,v),xa.end.fromBufferAttribute(x,v),xa.applyMatrix4(p);const M=new Be,A=new Be;Pl.distanceSqToSegment(xa.start,xa.end,A,M),A.distanceTo(M)<.5*uf&&m.push({point:A,pointOnLine:M,distance:Pl.origin.distanceTo(A),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,A=Math.min(v.instanceCount,S.count),T=-m.near;Pl.at(1,kl),kl.w=1,kl.applyMatrix4(m.matrixWorldInverse),kl.applyMatrix4(b),kl.multiplyScalar(1/kl.w),kl.x*=y.x/2,kl.y*=y.y/2,kl.z=0,fj.copy(kl),mj.multiplyMatrices(m.matrixWorldInverse,x);for(let k=0,E=A;k<E;k++){if(pa.fromBufferAttribute(S,k),ga.fromBufferAttribute(M,k),pa.w=1,ga.w=1,pa.applyMatrix4(mj),ga.applyMatrix4(mj),pa.z>T&&ga.z>T)continue;if(pa.z>T){const L=pa.z-ga.z,q=(pa.z-T)/L;pa.lerp(ga,q)}else if(ga.z>T){const L=ga.z-pa.z,q=(ga.z-T)/L;ga.lerp(pa,q)}pa.applyMatrix4(b),ga.applyMatrix4(b),pa.multiplyScalar(1/pa.w),ga.multiplyScalar(1/ga.w),pa.x*=y.x/2,pa.y*=y.y/2,ga.x*=y.x/2,ga.y*=y.y/2,xa.start.copy(pa),xa.start.z=0,xa.end.copy(ga),xa.end.z=0;const O=xa.closestPointToPointParameter(fj,!0);xa.at(O,b9);const C=Qee.lerp(pa.z,ga.z,O),D=C>=-1&&C<=1,U=fj.distanceTo(b9)<.5*uf;if(D&&U){xa.start.fromBufferAttribute(S,k),xa.end.fromBufferAttribute(M,k),xa.start.applyMatrix4(x),xa.end.applyMatrix4(x);const L=new Be,q=new Be;Pl.distanceSqToSegment(xa.start,xa.end,q,L),p.push({point:q,pointOnLine:L,distance:Pl.origin.distanceTo(q),object:f,face:null,faceIndex:k,uv:null,uv1:null})}}})(this,i,n)))}}class z6e extends vE{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 Va;f.setAttribute("position",new xi(c,3)),f.setAttribute("color",new xi(u,3)),super(f,new Jy({vertexColors:!0,toneMapped:!1}))}}function B6e(t,e,n,r){const i=(function(o,l,c){o*=.5,l*=.5,c*=.5;const u=new Va,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 xi(d,3)),u})(t,e,n),a=new vE(i,new x6e({color:new rn(r),dashSize:3,gapSize:1}));return a.computeLineDistances(),a}var u0=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 u0.Panel("FPS","#0ff","#002")),c=n(new u0.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var u=n(new u0.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}};u0.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 $6e=u0;class v9{constructor(e,n){this.openFolders=[],this.watchedObject=e,this.options=n,this.gui=new eM,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 eM,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 H6e extends Va{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,A=new Be,T=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 E=Number.MAX_VALUE;const O=Math.abs(M.x),C=Math.abs(M.y),D=Math.abs(M.z);return O<=E&&(E=O,A.set(1,0,0)),C<=E&&(E=C,A.set(0,1,0)),D<=E&&A.set(0,0,1),k.crossVectors(M,A).normalize(),A.crossVectors(M,k),T.crossVectors(M,A),[S,A,T]})(p);for(let v=0;v<=i;v++){const S=v/i*Math.PI*2,M=Math.sin(S),A=-Math.cos(S);o.x=A*y.x+M*x.x,o.y=A*y.y+M*x.y,o.z=A*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 xi(c,3)),this.setAttribute("normal",new xi(u,3)),this.setAttribute("uv",new xi(d,2))}}class d0{static get initial(){const e=new d0;return Object.assign(e,{x:0,y:0,z:0,r:0,e:0,i:0,j:0,t:0}),e}}const pj={h:0,s:0,l:0};class mg{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=d0.initial,this.beyondFirstMove=!1,this.disposables=[],this._extrusionColor=mg.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 tM(this.minLayerThreshold),this.scene=new a6e,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 $6e: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"+pE),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 OR({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 OR({preserveDrawingBuffer:!0}),this.canvas=this.renderer.domElement,p.appendChild(this.canvas)}this.camera=new $s(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 NL(this._backgroundColor,m,f),this.resize(),this.controls=new F6e(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?mg.defaultExtrusionColor:this._extrusionColor instanceof rn?this._extrusionColor:(e=this._extrusionColor[this.state.t])!==null&&e!==void 0?e:mg.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 M6e(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 _6e(13421772,.3*Math.PI),n=new v6e(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 Xb;return n.name=e,n.quaternion.setFromEuler(new Zy(-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=d0.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 dj(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(pj),a=new rn().setHSL(pj.h,pj.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 z6e(this.buildVolume.x,10,this.buildVolume.y,10));const e=B6e(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 tM(this.minLayerThreshold)}resetState(){var e;this.startLayer=1,this.endLayer=1/0,this.singleLayerMode=!1,this.beyondFirstMove=!1,this.state=d0.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,K=f-c,V=Math.sqrt(Math.pow(W/2,2)+Math.pow(K/2,2));p=Math.max(p,V);const Q=Math.pow(W,2)+Math.pow(K,2),re=Math.pow(p,2)-Q/4;let J=Math.sqrt(re/Q);(a&&p<0||!a&&p>0)&&(J=-J),b=W/2+K*J,y=K/2-W*J}const x=l==d&&c==f,v=l+b,S=c+y,M=Math.sqrt(b*b+y*y),A=Math.atan2(-y,-b),T=Math.atan2(f-S,d-v);let k;x?k=2*Math.PI:(k=a?A-T:T-A,k<0&&(k+=2*Math.PI));let E=M*k/1.8;this.inches&&(E*=25),E<1&&(E=1);let O=k/E;O*=a?-1:1;const C=[];C.push({x:l,y:c,z:u});const D=(u-m)/E;let U=l,L=c,q=u,P=A;for(let W=0;W<E-1;W++)P+=O,U=v+M*Math.cos(P),L=S+M*Math.sin(P),q+=D,C.push({x:U,y:L,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 Va;i.setAttribute("position",new xi(e,3)),this.disposables.push(i);const a=new Jy({color:n});this.disposables.push(a);const o=new vE(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 H6e(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 vte;this.disposables.push(i);const a=new yte({color:n,linewidth:this.lineWidth/(1e3*window.devicePixelRatio)});this.disposables.push(a),i.setPositions(e);const o=new U6e(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=>dj(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 g6e({color:e,wireframe:this._wireframe});this.disposables.push(i);const a=r.reduce(((l,c)=>3*c.attributes.position.count+l),0),o=new f6e(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 dj(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 v9(this):typeof this.devMode=="object"&&(this.devGui=new v9(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())}}mg.defaultExtrusionColor=new rn("hotpink");function V6e({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 T=i.current,k=T.parentElement?.getBoundingClientRect();k&&(T.width=k.width,T.height=k.height);const E=n&&n.length>1,O=n?.[0]||"#00ae42",C=new mg({canvas:T,buildVolume:e,backgroundColor:1710618,extrusionColor:E?n:O,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 L=new Set,q=/^(\s*)T(\d+)(\s*;.*)?$/gim;let P;for(;(P=q.exec(U))!==null;){const J=parseInt(P[2],10);J<=15&&L.add(J)}const W=new Map,K=Array.from(L).sort((J,z)=>J-z);K.forEach((J,z)=>{W.set(J,z%8)});const V=[];K.forEach((J,z)=>{const G=n?.[J]||"#00ae42";V[z%8]=G});const Q=U.split(`
- `).map(J=>{const z=J.match(/^(\s*)T(\d+)(\s*;.*)?$/i);if(z){const G=parseInt(z[2],10);if(G>15)return`; FILTERED: ${J.trim()}`;const ne=W.get(G)??0;return`${z[1]}T${ne}${z[3]||""}`}return J}).join(`
- `);V.length>0&&(C.extrusionColor=V),C.processGCode(Q);const re=C.layers?.length||0;v(re),y(re),C.render(),u(!1)}).catch(U=>{U.message!=="not_sliced"&&f(U.message),u(!1)});const D=()=>{if(T.parentElement&&a.current){const U=T.parentElement.getBoundingClientRect();T.width=U.width,T.height=U.height,a.current.resize()}};return window.addEventListener("resize",D),()=>{window.removeEventListener("resize",D),o.current&&cancelAnimationFrame(o.current),a.current&&(a.current.dispose(),a.current=null),l.current=!1}},[t,S]);const M=w.useCallback(T=>{if(!a.current)return;const k=Math.max(1,Math.min(T,x));y(k),o.current&&cancelAnimationFrame(o.current),o.current=requestAnimationFrame(()=>{a.current&&(a.current.endLayer=k,a.current.render())})},[x]),A=T=>{M(parseInt(T.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(dt,{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(Kde,{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(ul,{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(Vf,{className:"w-4 h-4"})}),s.jsx("input",{type:"range",min:1,max:x,value:b,onChange:A,className:"flex-1 h-2 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer accent-bambu-green"}),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(Js,{className:"w-4 h-4"})}),s.jsxs("span",{className:"text-sm text-bambu-gray min-w-[80px] text-right",children:[b," / ",x]})]})})]})}function _te({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(()=>{he.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}${he.getArchiveForSlicer(t,d)}`;Zc(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(Se,{variant:"secondary",size:"sm",onClick:u,children:[s.jsx(zr,{className:"w-4 h-4"}),"Open in Slicer"]}),s.jsx(Se,{variant:"ghost",size:"sm",onClick:n,children:s.jsx(Vt,{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(Hs,{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(wde,{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(dt,{className:"w-8 h-8 animate-spin text-bambu-green"})}):r==="3d"&&a?s.jsx(BIe,{url:a.has_source?he.getSource3mfDownloadUrl(t):he.getArchiveDownload(t),buildVolume:a.build_volume,filamentColors:a.filament_colors,className:"w-full h-full"}):r==="gcode"&&a?s.jsx(V6e,{gcodeUrl:he.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 _9={"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 G6e(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 Ug(t){const e=t.replace("#","").toLowerCase().substring(0,6);return _9[e]?_9[e]:G6e(t)}function nM(t){return t?`#${t.replace("#","").substring(0,6)}`:"#808080"}function na(t){return t?t.replace("#","").toLowerCase().substring(0,6):""}function lh(t,e,n=40){const r=na(t),i=na(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 wte(t,e,n,r){const i=String.fromCharCode(65+(t>=128?t-128:t));return n?`HT-${i}`:`AMS-${i} Slot ${e+1}`}function Ste(t,e,n){return t*4+e}function W6e(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 q6e(){const t=new Date;return t.setMinutes(t.getMinutes()+1),t.toISOString().slice(0,16)}function w9(t){if(!t)return!1;const e=Date.now()+4320*60*60*1e3;return new Date(t).getTime()>e}function TL(t){const e=[];if(t?.ams?.forEach(n=>{const r=n.tray.length===1;n.tray.forEach(i=>{if(i.tray_type){const a=nM(i.tray_color);e.push({type:i.tray_type,color:a,colorName:Ug(a),amsId:n.id,trayId:i.id,isHt:r,isExternal:!1,label:wte(n.id,i.id,r),globalTrayId:Ste(n.id,i.id)})}})}),t?.vt_tray?.tray_type){const n=nM(t.vt_tray.tray_color);e.push({type:t.vt_tray.tray_type,color:n,colorName:Ug(n),amsId:-1,trayId:0,isHt:!1,isExternal:!0,label:"External",globalTrayId:254})}return e}function S9(t,e){if(!t?.filaments||t.filaments.length===0)return;const n=TL(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()&&na(m.color)===na(l.color)),u=!c&&n.find(m=>!r.has(m.globalTrayId)&&m.type?.toUpperCase()===l.type?.toUpperCase()&&lh(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 K6e(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=nM(i.tray_color);e.push({type:i.tray_type,color:a,colorName:Ug(a),amsId:n.id,trayId:i.id,isHt:r,isExternal:!1,label:wte(n.id,i.id,r),globalTrayId:Ste(n.id,i.id)})}})}),t?.vt_tray?.tray_type){const n=nM(t.vt_tray.tray_color);e.push({type:t.vt_tray.tray_type,color:n,colorName:Ug(n),amsId:-1,trayId:0,isHt:!1,isExternal:!0,label:"External",globalTrayId:254})}return e},[t])}function Mte(t,e,n){const r=K6e(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],A=r.find(T=>T.globalTrayId===M);if(A){const T=A.type?.toUpperCase()===u.type?.toUpperCase(),k=na(A.color)===na(u.color)||lh(A.color,u.color);let E;return T&&k?E="match":T?E="type_only":E="mismatch",{...u,loaded:A,hasFilament:!0,typeMatch:T,colorMatch:k,status:E,isManual:!0}}}const f=r.find(M=>!c.has(M.globalTrayId)&&M.type?.toUpperCase()===u.type?.toUpperCase()&&na(M.color)===na(u.color)),m=!f&&r.find(M=>!c.has(M.globalTrayId)&&M.type?.toUpperCase()===u.type?.toUpperCase()&&lh(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 X6e(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=na(x.color)===na(u.color)||lh(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()&&na(y.color)===na(u.color)),m=f?void 0:e.find(y=>!o.has(y.globalTrayId)&&y.type?.toUpperCase()===u.type?.toUpperCase()&&lh(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 Y6e(t,e,n){if(!t?.filaments||t.filaments.length===0)return;const r=TL(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()&&na(b.color)===na(c.color)),f=d?void 0:r.find(b=>!i.has(b.globalTrayId)&&b.type?.toUpperCase()===c.type?.toUpperCase()&&lh(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 M9={useDefault:!0,manualMappings:{},autoConfigured:!1};function Z6e(t,e,n,r,i,a){const o=yue({queries:t.map(b=>({queryKey:["printer-status",b],queryFn:()=>he.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(D=>D.id===b)?.name||`Printer ${b}`,A=TL(v),T=i[b]||M9,k=S9(n,v),E=T.useDefault?r:T.manualMappings,O=Y6e(n,v,E),C=X6e(n?.filaments,A,E);return{printerId:b,printerName:M,status:v,isLoading:x?.isLoading??!1,loadedFilaments:A,autoMapping:k,finalMapping:O,matchStatus:C.status,exactMatches:C.exactMatches,typeOnlyMatches:C.typeOnlyMatches,missingTypes:C.missingTypes,totalSlots:C.totalSlots,config:T}}),[t,o,e,n,i,r]),c=o.some(b=>b.isLoading),u=(b,y)=>{a(x=>({...x,[b]:{...x[b]||M9,...y}}))},d=b=>{const y=l.find(S=>S.printerId===b);if(!y||!y.status||!n?.filaments)return;const x=S9(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 Q6e({printerResult:t,filamentReqs:e,onUpdateConfig:n}){const r=on(),[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 he.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()&&na(M.color)===na(u.color)),v=x?void 0:t.loadedFilaments.find(M=>!y.has(M.globalTrayId)&&M.type?.toUpperCase()===u.type?.toUpperCase()&&lh(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=na(m.color)===na(u.color)||lh(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(xr,{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} - ${Ug(u.color)}`,children:s.jsx(gP,{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(ns,{className:"w-3 h-3 text-bambu-green"}):f==="type_only"?s.jsx("span",{title:"Same type, different color",children:s.jsx(kn,{className:"w-3 h-3 text-yellow-400"})}):s.jsx("span",{title:"Filament type not loaded",children:s.jsx(kn,{className:"w-3 h-3 text-orange-400"})})]},p))]})}function J6e({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(dt,{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(oa,{className:"w-4 h-4"}),"No ",a?"":"active ","printers available"]});const m=M=>{i?e.includes(M)?n(e.filter(A=>A!==M)):n([...e,M]):n([M])},p=()=>{n(d.map(M=>M.id))},b=()=>{n([])},y=(M,A,T)=>{T.stopPropagation(),!(!c||!u)&&(A?c(M):u(M,{useDefault:!0,manualMappings:{},autoConfigured:!1}))},x=M=>e.includes(M),v=e.length,S=M=>o?.find(A=>A.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 A=x(M.id),T=S(M.id),k=T&&!T.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 ${A?"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 ${A?"bg-bambu-green/20":"bg-bambu-dark-tertiary"}`,children:s.jsx(qr,{className:`w-5 h-5 ${A?"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 ${A?"bg-bambu-green border-bambu-green":"border-bambu-gray/50"}`,children:A&&s.jsx(ns,{className:"w-3 h-3 text-white"})})]}),A&&f&&T&&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:E=>E.stopPropagation(),children:[s.jsx("input",{type:"checkbox",checked:k,onChange:E=>y(M.id,E.target.checked,E),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 ${T.matchStatus==="full"?"text-bambu-green":T.matchStatus==="partial"?"text-yellow-400":"text-orange-400"}`,children:["(",T.exactMatches,"/",T.totalSlots," matched)"]}),T.isLoading&&s.jsx(xr,{className:"w-3 h-3 text-bambu-gray animate-spin"}),k&&s.jsxs("button",{type:"button",onClick:E=>{E.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(jme,{className:"w-3 h-3"}),"Auto"]})]}),k&&s.jsx(Q6e,{printerResult:T,filamentReqs:l.filaments,onUpdateConfig:E=>u(M.id,E)})]})]},M.id)}),v===0&&s.jsxs("p",{className:"text-xs text-orange-400 mt-1 flex items-center gap-1",children:[s.jsx(oa,{className:"w-3 h-3"}),"Select at least one printer"]})]})}function e$e({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(ul,{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(kn,{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(ul,{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?` • ${W6e(i.print_time_seconds)}`:""]})]}),n===i.index&&s.jsx(ns,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]},i.index))})]})}function t$e({printerId:t,filamentReqs:e,manualMappings:n,onManualMappingChange:r,defaultExpanded:i=!1}){const a=on(),[o,l]=w.useState(!1),[c,u]=w.useState(i),{data:d}=ut({queryKey:["printer-status",t],queryFn:()=>he.getPrinterStatus(t),enabled:!!t}),{loadedFilaments:f,filamentComparison:m,hasTypeMismatch:p,hasColorMismatch:b}=Mte(e,d,n);if(!(e?.filaments&&e.filaments.length>0)||!d)return null;const x=p?"#f97316":b?"#facc15":"#00ae42",v=(M,A)=>{if(M>0)if(A===""){const T={...n};delete T[M],r(T)}else r({...n,[M]:parseInt(A,10)})},S=async()=>{l(!0);try{await he.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(gP,{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(pu,{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(xr,{className:`w-3 h-3 ${o?"animate-spin":""}`}),s.jsx("span",{children:"Re-read"})]})]}),m.map((M,A)=>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} - ${Ug(M.color)}`,children:s.jsx(gP,{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:T=>v(M.slot_id||0,T.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(T=>s.jsxs("option",{value:T.globalTrayId,className:"bg-bambu-dark text-white",children:[T.label,": ",T.type," (",T.colorName,")"]},T.globalTrayId))]}),M.status==="match"?s.jsx(ns,{className:"w-3 h-3 text-bambu-green"}):M.status==="type_only"?s.jsx("span",{title:"Same type, different color",children:s.jsx(kn,{className:"w-3 h-3 text-yellow-400"})}):s.jsx("span",{title:"Filament type not loaded",children:s.jsx(kn,{className:"w-3 h-3 text-orange-400"})})]},A)),p&&s.jsx("p",{className:"text-xs text-orange-400 mt-2",children:"Required filament type not found in printer."})]})]})}const n$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 r$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(mN,{className:"w-4 h-4"}),s.jsx("span",{children:"Print Options"}),r?s.jsx(pu,{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:n$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 i$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(Zn,{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(oi,{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(yK,{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:q6e(),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(Eu,{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 Fp={bed_levelling:!0,flow_cali:!1,vibration_cali:!0,layer_inspect:!1,timelapse:!1},a$e={scheduleType:"asap",scheduledTime:"",requirePreviousSuccess:!1,autoOffAfter:!1};function ch({mode:t,archiveId:e,libraryFileId:n,archiveName:r,queueItem:i,onClose:a,onSuccess:o}){const l=on(),{showToast:c}=qn(),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??Fp.bed_levelling,flow_cali:i.flow_cali??Fp.flow_cali,vibration_cali:i.vibration_cali??Fp.vibration_cali,layer_inspect:i.layer_inspect??Fp.layer_inspect,timelapse:i.timelapse??Fp.timelapse}:Fp),[x,v]=w.useState(()=>{if(t==="edit-queue-item"&&i){let $="asap";i.manual_start?$="manual":i.scheduled_time&&!w9(i.scheduled_time)&&($="scheduled");let j="";return i.scheduled_time&&!w9(i.scheduled_time)&&(j=new Date(i.scheduled_time).toISOString().slice(0,16)),{scheduleType:$,scheduledTime:j,requirePreviousSuccess:i.require_previous_success,autoOffAfter:i.auto_off_after}}return a$e}),[S,M]=w.useState(()=>{if(t==="edit-queue-item"&&i?.ams_mapping&&Array.isArray(i.ams_mapping)){const $={};return i.ams_mapping.forEach((j,Y)=>{j!==-1&&($[Y+1]=j)}),$}return{}}),[A,T]=w.useState({}),[k]=w.useState(()=>t==="edit-queue-item"&&i?.printer_id?[i.printer_id]:[]),[E]=w.useState(()=>t==="edit-queue-item"&&i?i.plate_id:null),[O,C]=w.useState(!1),[D,U]=w.useState({current:0,total:0}),[L,q]=w.useState(new Set),P=d.length,W=d.length>0?d[0]:null,{data:K}=ut({queryKey:["settings"],queryFn:he.getSettings}),{data:V,isLoading:Q}=ut({queryKey:["printers"],queryFn:he.getPrinters}),{data:re,isError:J}=ut({queryKey:["archive-plates",e],queryFn:()=>he.getArchivePlates(e),enabled:!!e&&!u,retry:!1}),{data:z}=ut({queryKey:["library-file-plates",n],queryFn:()=>he.getLibraryFilePlates(n),enabled:u&&!!n}),G=u?z:re,{data:ne,isError:ae}=ut({queryKey:["archive-filaments",e,m],queryFn:()=>he.getArchiveFilamentRequirements(e,m??void 0),enabled:!!e&&!u&&(m!==null||!G?.is_multi_plate),retry:!1}),{data:de}=ut({queryKey:["library-file-filaments",n,m],queryFn:()=>he.getLibraryFileFilamentRequirements(n,m??void 0),enabled:u&&!!n&&(m!==null||!G?.is_multi_plate)}),fe=!u&&(J||ae),ie=u?de:ne,{data:Ae}=ut({queryKey:["printer-status",W],queryFn:()=>he.getPrinterStatus(W),enabled:!!W}),{amsMapping:me}=Mte(ie,Ae,S),Ne=Z6e(d,V,ie,S,A,T);w.useEffect(()=>{G?.plates?.length===1&&!m&&p(G.plates[0].index)},[G,m]),w.useEffect(()=>{if(t==="edit-queue-item")return;const $=V?.filter(j=>j.is_active)||[];$.length===1&&d.length===0&&f([$[0].id])},[t,V,d.length]),w.useEffect(()=>{t==="edit-queue-item"?(JSON.stringify(d.sort())!==JSON.stringify(k.sort())||m!==E)&&(M({}),T({}),q(new Set)):(M({}),T({}),q(new Set))},[t,d,m,k,E]),w.useEffect(()=>{if(!K?.per_printer_mapping_expanded||d.length<=1)return;const $=d.filter(j=>{if(L.has(j))return!1;const Y=Ne.printerResults.find(ge=>ge.printerId===j);return Y&&Y.status&&!Y.isLoading});$.length>0&&(q(j=>{const Y=new Set(j);return $.forEach(ge=>Y.add(ge)),Y}),$.forEach(j=>{Ne.autoConfigurePrinter(j)}))},[K?.per_printer_mapping_expanded,d,L,Ne]),w.useEffect(()=>{const $=j=>{j.key==="Escape"&&!O&&a()};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[a,O]);const ye=G?.is_multi_plate??!1,le=G?.plates??[],$e=mt({mutationFn:$=>he.addToQueue($)}),H=mt({mutationFn:$=>he.updateQueueItem(i.id,$),onSuccess:()=>{l.invalidateQueries({queryKey:["queue"]}),c("Queue item updated"),o?.(),a()},onError:$=>{c($.message||"Failed to update queue item","error")}}),ee=async $=>{if($?.preventDefault(),d.length===0){c("Please select at least one printer","error");return}C(!0),U({current:0,total:d.length});const j={success:0,failed:0,errors:[]},Y=we=>{if(d.length>1){const ve=A[we];if(ve&&!ve.useDefault)return Ne.getFinalMapping(we)}return me},ge=we=>({printer_id:we,archive_id:u?void 0:e,library_file_id:u?n:void 0,require_previous_success:x.requirePreviousSuccess,auto_off_after:x.autoOffAfter,manual_start:x.scheduleType==="manual",ams_mapping:Y(we),plate_id:m,scheduled_time:x.scheduleType==="scheduled"&&x.scheduledTime?new Date(x.scheduledTime).toISOString():void 0,...b});for(let we=0;we<d.length;we++){const ve=d[we];U({current:we+1,total:d.length});try{if(t==="reprint"){const Ze=Y(ve);u?await he.printLibraryFile(n,ve,{ams_mapping:Ze,...b}):await he.reprintArchive(e,ve,{plate_id:m??void 0,ams_mapping:Ze,...b})}else if(t==="edit-queue-item"&&we===0){const Ze=Y(ve),Ie={printer_id:ve,require_previous_success:x.requirePreviousSuccess,auto_off_after:x.autoOffAfter,manual_start:x.scheduleType==="manual",ams_mapping:Ze,plate_id:m,scheduled_time:x.scheduleType==="scheduled"&&x.scheduledTime?new Date(x.scheduledTime).toISOString():null,...b};await H.mutateAsync(Ie)}else await $e.mutateAsync(ge(ve));j.success++}catch(Ze){j.failed++;const Ie=V?.find(qe=>qe.id===ve)?.name||`Printer ${ve}`;j.errors.push(`${Ie}: ${Ze.message}`)}}if(C(!1),j.failed===0){const we=t==="reprint"?"sent to":t==="edit-queue-item"?"updated/queued for":"queued for";j.success===1?c(t==="edit-queue-item"?"Queue item updated":`Print ${we} printer`):c(`Print ${we} ${j.success} printers`),l.invalidateQueries({queryKey:["queue"]}),o?.(),a()}else j.success===0?c(`Failed: ${j.errors[0]}`,"error"):(c(`${j.success} succeeded, ${j.failed} failed`,"error"),l.invalidateQueries({queryKey:["queue"]}))},X=O||H.isPending,B=w.useMemo(()=>!(X||d.length===0||!u&&ye&&!m),[d.length,ye,m,X,u]),ce=(()=>{const $=d.length;return t==="reprint"?{title:u?"Print":"Re-print",icon:qr,submitText:$>1?`Print to ${$} Printers`:"Print",submitIcon:qr,loadingText:D.total>1?`Sending ${D.current}/${D.total}...`:"Sending..."}:t==="add-to-queue"?{title:"Schedule Print",icon:oi,submitText:$>1?`Queue to ${$} Printers`:"Add to Queue",submitIcon:oi,loadingText:D.total>1?`Adding ${D.current}/${D.total}...`:"Adding..."}:{title:"Edit Queue Item",icon:la,submitText:"Save",submitIcon:la,loadingText:D.total>1?`Saving ${D.current}/${D.total}...`:"Saving..."}})(),Te=ce.icon,Le=ce.submitIcon,Ee=W&&(u||(ye?m!==null:!0));return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:O?void 0:a,children:s.jsx(St,{className:"w-full max-w-lg max-h-[90vh] overflow-y-auto",onClick:$=>$.stopPropagation(),children:s.jsxs(Nt,{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(Te,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:ce.title})]}),s.jsx(Se,{variant:"ghost",size:"sm",onClick:a,disabled:O,children:s.jsx(Vt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:ee,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(e$e,{plates:le,isMultiPlate:ye,selectedPlate:m,onSelect:p}),s.jsx(J6e,{printers:V||[],selectedPrinterIds:d,onMultiSelect:f,isLoading:Q,allowMultiple:!0,showInactive:t==="edit-queue-item",printerMappingResults:Ne.printerResults,filamentReqs:ie,onAutoConfigurePrinter:Ne.autoConfigurePrinter,onUpdatePrinterConfig:Ne.updatePrinterConfig}),fe&&s.jsxs("div",{className:"flex items-start gap-2 p-3 mb-2 bg-orange-500/10 border border-orange-500/30 rounded-lg text-sm",children:[s.jsx(oa,{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."})]}),Ee&&!fe&&d.length===1&&s.jsx(t$e,{printerId:W,filamentReqs:ie,manualMappings:S,onManualMappingChange:M,defaultExpanded:K?.per_printer_mapping_expanded??!1}),(t==="reprint"||P>0)&&s.jsx(r$e,{options:b,onChange:y}),t!=="reprint"&&s.jsx(i$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(Se,{type:"button",variant:"secondary",onClick:a,className:"flex-1",disabled:O,children:"Cancel"}),s.jsx(Se,{type:"submit",disabled:!B,className:"flex-1",children:X?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 animate-spin"}),ce.loadingText]}):s.jsxs(s.Fragment,{children:[s.jsx(Le,{className:"w-4 h-4"}),ce.submitText]})})]})]})]})})})}function s$e({onClose:t,initialFiles:e}){const n=on(),{showToast:r}=qn(),i=w.useRef(null),[a,o]=w.useState(()=>e?.filter(E=>E.name.endsWith(".3mf")).map(E=>({file:E,status:"pending"}))||[]),[l,c]=w.useState(!1),[u,d]=w.useState(),[f,m]=w.useState(null);w.useEffect(()=>{const E=O=>{O.key==="Escape"&&t()};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[t]);const{data:p}=ut({queryKey:["printers"],queryFn:he.getPrinters}),b=mt({mutationFn:E=>he.uploadArchivesBulk(E,u),onSuccess:E=>{m(E),n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["archiveStats"]}),o(O=>O.map(C=>{const D=E.results.find(L=>L.filename===C.file.name),U=E.errors.find(L=>L.filename===C.file.name);return D?{...C,status:"success",archiveId:D.id}:U?{...C,status:"error",error:U.error}:C})),E.failed===0?r(`${E.uploaded} file${E.uploaded!==1?"s":""} uploaded`):E.uploaded===0?r(`Failed to upload ${E.failed} file${E.failed!==1?"s":""}`,"error"):r(`${E.uploaded} uploaded, ${E.failed} failed`,"warning")},onError:()=>{o(E=>E.map(O=>({...O,status:"error",error:"Upload failed"}))),r("Upload failed","error")}}),y=w.useCallback(E=>{E.preventDefault(),c(!0)},[]),x=w.useCallback(E=>{E.preventDefault(),c(!1)},[]),v=w.useCallback(E=>{E.preventDefault(),c(!1);const O=Array.from(E.dataTransfer.files).filter(C=>C.name.endsWith(".3mf"));O.length>0&&o(C=>[...C,...O.map(D=>({file:D,status:"pending"}))])},[]),S=w.useCallback(E=>{const O=Array.from(E.target.files||[]).filter(C=>C.name.endsWith(".3mf"));O.length>0&&o(C=>[...C,...O.map(D=>({file:D,status:"pending"}))]),i.current&&(i.current.value="")},[]),M=w.useCallback(E=>{o(O=>O.filter((C,D)=>D!==E))},[]),A=()=>{if(a.length===0)return;const E=a.filter(O=>O.status==="pending");E.length!==0&&(o(O=>O.map(C=>C.status==="pending"?{...C,status:"uploading"}:C)),b.mutate(E.map(O=>O.file)))},T=a.filter(E=>E.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(St,{className:"w-full max-w-2xl max-h-[90vh] flex flex-col",children:s.jsxs(Nt,{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(Vt,{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(pi,{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(Se,{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:E=>d(E.target.value?Number(E.target.value):void 0),disabled:k,children:[s.jsx("option",{value:"",children:"No printer"}),p?.map(E=>s.jsx("option",{value:E.id,children:E.name},E.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((E,O)=>s.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[s.jsx(aN,{className:"w-5 h-5 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"flex-1 text-white text-sm truncate",children:E.file.name}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:[(E.file.size/(1024*1024)).toFixed(1)," MB"]}),E.status==="pending"&&s.jsx("button",{onClick:()=>M(O),className:"text-bambu-gray hover:text-red-400 transition-colors",disabled:k,children:s.jsx(Vt,{className:"w-4 h-4"})}),E.status==="uploading"&&s.jsx(dt,{className:"w-4 h-4 text-bambu-green animate-spin"}),E.status==="success"&&s.jsx(Un,{className:"w-4 h-4 text-bambu-green"}),E.status==="error"&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-xs text-red-400",children:E.error}),s.jsx(oa,{className:"w-4 h-4 text-red-400"})]})]},`${E.file.name}-${O}`))})}),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(Se,{variant:"secondary",onClick:t,className:"flex-1",children:f?"Close":"Cancel"}),!f&&s.jsx(Se,{onClick:A,disabled:T===0||k,className:"flex-1",children:k?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 animate-spin"}),"Uploading..."]}):s.jsxs(s.Fragment,{children:[s.jsx(pi,{className:"w-4 h-4"}),"Upload ",T>0&&`(${T})`]})})]})]})})})}const o$e=["Adhesion failure","Spaghetti / Detached","Layer shift","Clogged nozzle","Filament runout","Warping","Stringing","Under-extrusion","Power failure","User cancelled","Other"],l$e=[{value:"completed",label:"Completed"},{value:"failed",label:"Failed"},{value:"aborted",label:"Cancelled"},{value:"printing",label:"Printing"}];function Nte({archive:t,onClose:e,existingTags:n=[]}){w.useEffect(()=>{const ie=Ae=>{Ae.key==="Escape"&&e()};return window.addEventListener("keydown",ie),()=>window.removeEventListener("keydown",ie)},[e]);const r=on(),[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),[A,T]=w.useState(t.photos||[]),[k,E]=w.useState(t.external_url||""),[O,C]=w.useState(!1),[D,U]=w.useState(!1),L=w.useRef(null),q=w.useRef(null),P=w.useRef(null),{data:W}=ut({queryKey:["printers"],queryFn:he.getPrinters}),{data:K}=ut({queryKey:["projects"],queryFn:()=>he.getProjects()}),{data:V}=ut({queryKey:["archives"],queryFn:()=>he.getArchives(void 0,1e3,0),enabled:n.length===0}),Q=n.length>0?n:[...new Set(V?.flatMap(ie=>ie.tags?.split(",").map(Ae=>Ae.trim())||[]).filter(Boolean)||[])].sort(),re=m.split(",").map(ie=>ie.trim()).filter(Boolean),J=Q.filter(ie=>!re.includes(ie)),z=ie=>{if(!re.includes(ie)){const Ae=[...re,ie].join(", ");p(Ae)}P.current!==null&&clearTimeout(P.current),L.current?.focus()},G=ie=>{const Ae=re.filter(me=>me!==ie).join(", ");p(Ae)},ne=mt({mutationFn:ie=>he.updateArchive(t.id,ie),onSuccess:()=>{r.invalidateQueries({queryKey:["archives"]}),r.invalidateQueries({queryKey:["projects"]}),e()}}),ae=async ie=>{const Ae=ie.target.files?.[0];if(Ae){C(!0);try{const me=await he.uploadArchivePhoto(t.id,Ae);T(me.photos),r.invalidateQueries({queryKey:["archives"]})}catch(me){console.error("Failed to upload photo:",me)}finally{C(!1),q.current&&(q.current.value="")}}},de=async ie=>{try{const Ae=await he.deleteArchivePhoto(t.id,ie);T(Ae.photos||[]),r.invalidateQueries({queryKey:["archives"]})}catch(Ae){console.error("Failed to delete photo:",Ae)}},fe=ie=>{ie.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:ie=>ie.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(Vt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:fe,className:"p-6 space-y-4 overflow-y-auto flex-1",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),s.jsx("input",{type:"text",value:i,onChange:ie=>a(ie.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"Print name"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),s.jsxs("select",{value:o??"",onChange:ie=>l(ie.target.value?Number(ie.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"",children:"No printer"}),W?.map(ie=>s.jsx("option",{value:ie.id,children:ie.name},ie.id))]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(Ta,{className:"w-4 h-4 inline mr-1"}),"Project"]}),s.jsxs("select",{value:c??"",onChange:ie=>u(ie.target.value?Number(ie.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"",children:"No project"}),K?.map(ie=>s.jsx("option",{value:ie.id,children:ie.name},ie.id))]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(_he,{className:"w-4 h-4 inline mr-1"}),"Items Printed"]}),s.jsx("input",{type:"number",min:1,value:S,onChange:ie=>M(Math.max(1,parseInt(ie.target.value)||1)),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"1"}),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:ie=>f(ie.target.value),rows:3,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none resize-none",placeholder:"Add notes about this print..."})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(Jg,{className:"w-4 h-4 inline mr-1"}),"External Link"]}),s.jsx("input",{type:"url",value:k,onChange:ie=>E(ie.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"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"}),re.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:re.map(ie=>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(vg,{className:"w-3 h-3"}),ie,s.jsx("button",{type:"button",onClick:()=>G(ie),className:"ml-0.5 text-bambu-gray hover:text-white",children:s.jsx(Vt,{className:"w-3 h-3"})})]},ie))}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{ref:L,type:"text",value:m,onChange:ie=>p(ie.target.value),onFocus:()=>{P.current!==null&&clearTimeout(P.current),U(!0)},onBlur:()=>{P.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:re.length>0?"Add more tags...":"Add tags..."}),D&&J.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:J.map(ie=>s.jsx("button",{type:"button",onClick:()=>z(ie),className:"px-2 py-0.5 bg-bambu-dark-tertiary hover:bg-bambu-green/20 rounded text-sm text-bambu-gray hover:text-white transition-colors",children:ie},ie))})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Status"}),s.jsx("select",{value:x,onChange:ie=>{v(ie.target.value),ie.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:l$e.map(ie=>s.jsx("option",{value:ie.value,children:ie.label},ie.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:ie=>y(ie.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"",children:"Select reason..."}),o$e.map(ie=>s.jsx("option",{value:ie,children:ie},ie))]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(Hf,{className:"w-4 h-4 inline mr-1"}),"Photos of Printed Result"]}),s.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[A.map(ie=>s.jsxs("div",{className:"relative group",children:[s.jsx("img",{src:he.getArchivePhotoUrl(t.id,ie),alt:"Print result",className:"w-20 h-20 object-cover rounded-lg border border-bambu-dark-tertiary"}),s.jsx("button",{type:"button",onClick:()=>de(ie),className:"absolute -top-1 -right-1 p-1 bg-red-500 rounded-full opacity-0 group-hover:opacity-100 transition-opacity",children:s.jsx(dn,{className:"w-3 h-3 text-white"})})]},ie)),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:ae,className:"hidden",disabled:O}),O?s.jsx(dt,{className:"w-6 h-6 text-bambu-gray animate-spin"}):s.jsx(nr,{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(Se,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(Se,{type:"submit",disabled:ne.isPending,className:"flex-1",children:[s.jsx(_s,{className:"w-4 h-4"}),ne.isPending?"Saving...":"Save"]})]})]})]})})}function Ete({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 A=t,T=e;t+x.width>v-M&&(A=Math.max(M,v-x.width-M)),A<M&&(A=M),e+x.height>S-M&&(T=Math.max(M,S-x.height-M)),T<M&&(T=M);const k=180,E=v-A-x.width,O=A;f(E<k&&O>k),u({x:A,y:T,visible:!0})}},[t,e]);const b=(x,v)=>{l.current&&(clearTimeout(l.current),l.current=null);const S=v.getBoundingClientRect(),M=window.innerHeight,A=300,E=M-S.top-8<A&&S.top>A;p(O=>({...O,[x]:E?"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(Js,{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,A)=>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]},A))})]},v)})})}function c$e({selectedIds:t,existingTags:e,onClose:n}){const r=on(),{showToast:i}=qn(),[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=mt({mutationFn:async()=>{const y=Array.from(l);let x=0;for(const v of t)try{const S=await he.getArchive(v),M=S.tags?S.tags.split(",").map(T=>T.trim()).filter(Boolean):[];let A;u==="add"?A=[...new Set([...M,...y])]:A=M.filter(T=>!l.has(T)),await he.updateArchive(v,{tags:A.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(St,{className:"w-full max-w-md",children:s.jsxs(Nt,{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(vg,{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(Vt,{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(Se,{size:"sm",variant:u==="add"?"primary":"secondary",onClick:()=>d("add"),children:"Add Tags"}),s.jsx(Se,{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(Se,{size:"sm",variant:"secondary",onClick:p,disabled:!a.trim(),children:s.jsx(nr,{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(Vt,{className:"w-3 h-3"})})]},y))})]})]}),s.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(Se,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),s.jsx(Se,{onClick:()=>f.mutate(),disabled:l.size===0||f.isPending,className:"flex-1",children:f.isPending?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):s.jsxs(s.Fragment,{children:[s.jsx(vg,{className:"w-4 h-4"}),u==="add"?"Add Tags":"Remove Tags"]})})]})]})})})}function u$e({selectedIds:t,onClose:e}){const n=on(),{showToast:r}=qn(),{data:i,isLoading:a}=ut({queryKey:["projects"],queryFn:()=>he.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=mt({mutationFn:async d=>(await he.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=mt({mutationFn:async()=>{for(const d of t)await he.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(St,{className:"w-full max-w-md max-h-[80vh] flex flex-col",children:s.jsxs(Nt,{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(Ta,{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(Vt,{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(dt,{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(ia,{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(dt,{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(Ta,{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(dt,{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(Se,{variant:"secondary",onClick:e,className:"flex-1",disabled:u,children:"Cancel"})})]})})})}function d$e(t,e){return new Date(t,e+1,0).getDate()}function h$e(t,e){return new Date(t,e,1).getDay()}const f$e=["January","February","March","April","May","June","July","August","September","October","November","December"],m$e=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function p$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 T=new Map;return t.forEach(k=>{const E=Ni(k.completed_at||k.created_at)||new Date,O=`${E.getFullYear()}-${String(E.getMonth()+1).padStart(2,"0")}-${String(E.getDate()).padStart(2,"0")}`,C=T.get(O)||[];C.push(k),T.set(O,C)}),T},[t]),p=d$e(o,i),b=h$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 T=0;T<b;T++)S.push(null);for(let T=1;T<=p;T++)S.push(T);const M=c?m.get(c)||[]:[],A=T=>{T!==c&&f(null),u(T)};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(Vf,{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:[f$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(Js,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:m$e.map(T=>s.jsx("div",{className:"text-center text-xs text-bambu-gray py-2",children:T},T))}),s.jsx("div",{className:"grid grid-cols-7 gap-1",children:S.map((T,k)=>{if(T===null)return s.jsx("div",{className:"aspect-square"},`empty-${k}`);const E=`${o}-${String(i+1).padStart(2,"0")}-${String(T).padStart(2,"0")}`,O=m.get(E)||[],C=O.length>0,D=T===r.getDate()&&i===r.getMonth()&&o===r.getFullYear(),U=E===c,L=O.filter(P=>P.status==="completed").length,q=O.filter(P=>P.status==="failed").length;return s.jsxs("button",{onClick:()=>A(U?null:E),className:`aspect-square rounded-lg p-1 flex flex-col items-center justify-center transition-colors relative ${U?"bg-bambu-green text-white":D?"bg-bambu-green/20 text-white ring-2 ring-bambu-green":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 ${D&&!U?"text-bambu-green":""}`,children:T}),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&&L===0?"bg-red-400":q>0?"bg-yellow-400":"bg-green-400"}`}),s.jsx("span",{className:"text-xs font-medium",children:O.length})]})]},T)})}),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(T=>{const k=new Date(T.completed_at||T.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(T=>{const k=new Date(T.completed_at||T.created_at);return k.getMonth()===i&&k.getFullYear()===o&&T.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(T=>{const k=new Date(T.completed_at||T.created_at);return k.getMonth()===i&&k.getFullYear()===o&&T.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(T=>{const k=T.id===d||T.id===n;return s.jsxs("button",{onClick:()=>{f(T.id),e?.(T)},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:[T.thumbnail_path?s.jsx("img",{src:he.getArchiveThumbnail(T.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:T.print_name||T.filename}),s.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[s.jsx("span",{className:T.status==="failed"?"text-red-400":"text-green-400",children:T.status==="failed"?"Failed":"Completed"}),T.filament_color&&s.jsx("div",{className:"flex gap-0.5",children:T.filament_color.split(",").map((E,O)=>s.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:E}},O))})]})]})]},T.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 Ate({archiveId:t,archiveName:e,onClose:n}){const r=he.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(Vt,{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(Se,{onClick:i,className:"w-full",children:[s.jsx(Hr,{className:"w-4 h-4"}),"Download QR Code"]})]})]})})}function Tte({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=he.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(Se,{variant:"secondary",size:"sm",onClick:f,children:[s.jsx(Hr,{className:"w-4 h-4"}),"Download"]}),i&&s.jsx(Se,{variant:"secondary",size:"sm",onClick:m,className:"text-red-400 hover:text-red-300",children:s.jsx(dn,{className:"w-4 h-4"})}),s.jsx("button",{onClick:r,className:"p-2 text-bambu-gray hover:text-white transition-colors",children:s.jsx(Vt,{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(Vf,{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(Js,{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:he.getArchivePhotoUrl(t,p),alt:`Thumbnail ${b+1}`,className:"w-full h-full object-cover"})},p))})]}),l&&s.jsx(Hn,{title:"Delete Photo",message:"Delete this photo? This cannot be undone.",confirmText:"Delete",variant:"danger",onConfirm:()=>{i?.(u),c(!1)},onCancel:()=>c(!1)})]})}function ya(t){this.content=t}ya.prototype={constructor:ya,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 ya(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 ya(n)},addToStart:function(t,e){return new ya([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new ya(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 ya(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=ya.from(t),t.size?new ya(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=ya.from(t),t.size?new ya(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=ya.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}};ya.from=function(t){if(t instanceof ya)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new ya(e)};function Cte(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=Cte(i.content,a.content,n+1);if(o!=null)return o}n+=i.nodeSize}}function kte(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=kte(o.content,l.content,n-1,r-1);if(u)return u}n-=c,r-=c}}class Et{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 Et(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 Et(r,i)}cutByIndex(e,n){return e==n?Et.empty:e==0&&n==this.content.length?this:new Et(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 Et(i,a)}addToStart(e){return new Et([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new Et(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 Cte(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return kte(this,e,n,r)}findIndex(e){if(e==0)return Iw(0,e);if(e==this.size)return Iw(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?Iw(n+1,a):Iw(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 Et.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new Et(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return Et.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 Et(n||e,r)}static from(e){if(!e)return Et.empty;if(e instanceof Et)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new Et([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}Et.empty=new Et([],0);const gj={index:0,offset:0};function Iw(t,e){return gj.index=t,gj.offset=e,gj}function rM(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(!rM(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!rM(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let _r=class FR{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&&rM(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 FR.none;if(e instanceof FR)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};_r.none=[];class iM extends Error{}class Ht{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=Pte(this.content,e+this.openStart,n);return r&&new Ht(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Ht(jte(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 Ht.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 Ht(Et.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 Ht(e,r,i)}}Ht.empty=new Ht(Et.empty,0,0);function jte(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(jte(a.content,e-i-1,n-i-1)))}function Pte(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=Pte(o.content,e-a-1,n,o);return l&&t.replaceChild(i,o.copy(l))}function g$e(t,e,n){if(n.openStart>t.depth)throw new iM("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new iM("Inconsistent open depths");return Rte(t,e,n,0)}function Rte(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=Rte(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 Lf(o,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=x$e(n,t);return Lf(a,Ote(t,o,l,e,r))}else return Lf(a,aM(t,e,r))}function Dte(t,e){if(!e.type.compatibleContent(t.type))throw new iM("Cannot join "+e.type.name+" onto "+t.type.name)}function UR(t,e,n){let r=t.node(n);return Dte(r,e.node(n)),r}function Of(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 h0(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&&(Of(t.nodeAfter,r),a++));for(let l=a;l<o;l++)Of(i.child(l),r);e&&e.depth==n&&e.textOffset&&Of(e.nodeBefore,r)}function Lf(t,e){return t.type.checkContent(e),t.copy(e)}function Ote(t,e,n,r,i){let a=t.depth>i&&UR(t,e,i+1),o=r.depth>i&&UR(n,r,i+1),l=[];return h0(null,t,i,l),a&&o&&e.index(i)==n.index(i)?(Dte(a,o),Of(Lf(a,Ote(t,e,n,r,i+1)),l)):(a&&Of(Lf(a,aM(t,e,i+1)),l),h0(e,n,i,l),o&&Of(Lf(o,aM(n,r,i+1)),l)),h0(r,null,i,l),new Et(l)}function aM(t,e,n){let r=[];if(h0(null,t,n,r),t.depth>n){let i=UR(t,e,n+1);Of(Lf(i,aM(t,e,n+1)),r)}return h0(e,null,n,r),new Et(r)}function x$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(Et.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class oy{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 _r.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 sM(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 oy(n,r,a)}static resolveCached(e,n){let r=N9.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 N9.set(e,r=new b$e);let i=r.elts[r.i]=oy.resolve(e,n);return r.i=(r.i+1)%y$e,i}}class b$e{constructor(){this.elts=[],this.i=0}}const y$e=12,N9=new WeakMap;class sM{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 v$e=Object.create(null);let Kd=class zR{constructor(e,n,r,i=_r.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||Et.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&&rM(this.attrs,n||e.defaultAttrs||v$e)&&_r.sameSet(this.marks,r||_r.none)}copy(e=null){return e==this.content?this:new zR(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new zR(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 Ht.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 Ht(u,i.depth-o,a.depth-o)}replace(e,n,r){return g$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 oy.resolveCached(this,e)}resolveNoCache(e){return oy.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()+")"),Lte(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=Et.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=_r.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(!_r.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=Et.fromJSON(e,n.content),a=e.nodeType(n.type).create(n.attrs,i,r);return a.type.checkAttrs(a.attrs),a}};Kd.prototype.text=void 0;class oM extends Kd{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):Lte(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 oM(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new oM(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 Lte(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class lm{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new _$e(e,n);if(r.next==null)return lm.empty;let i=Ite(r);r.next&&r.err("Unexpected trailing text");let a=T$e(A$e(i));return C$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 Et.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(`
- `)}}lm.empty=new lm(!0);class _$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 Ite(t){let e=[];do e.push(w$e(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function w$e(t){let e=[];do e.push(S$e(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function S$e(t){let e=E$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=M$e(t,e);else break;return e}function E9(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function M$e(t,e){let n=E9(t),r=n;return t.eat(",")&&(t.next!="}"?r=E9(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function N$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 E$e(t){if(t.eat("(")){let e=Ite(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=N$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 A$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 Fte(t,e){return e-t}function A9(t,e){let n=[];return r(e),n.sort(Fte);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 T$e(t){let e=Object.create(null);return n(A9(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]);A9(t,c).forEach(d=>{u||i.push([l,u=[]]),u.indexOf(d)==-1&&u.push(d)})})});let a=e[r.join(",")]=new lm(r.indexOf(t.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(Fte);a.next.push({type:i[o][0],next:e[l.join(",")]||n(l)})}return a}}function C$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 Ute(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 zte(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 Bte(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 $te(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new j$e(t,r,e[r]);return n}let T9=class Hte{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=$te(e,r.attrs),this.defaultAttrs=Ute(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==lm.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:zte(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Kd(this,this.computeAttrs(e),Et.from(n),_r.setFrom(r))}createChecked(e=null,n,r){return n=Et.from(n),this.checkContent(n),new Kd(this,this.computeAttrs(e),n,_r.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=Et.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(Et.empty,!0);return a?new Kd(this,e,n.append(a),_r.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){Bte(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:_r.none:e}static compile(e,n){let r=Object.create(null);e.forEach((a,o)=>r[a]=new Hte(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 k$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 j$e{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?k$e(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class _E{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=$te(e,i.attrs),this.excluded=null;let a=Ute(this.attrs);this.instance=a?new _r(this,a):null}create(e=null){return!e&&this.instance?this.instance:new _r(this,zte(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((a,o)=>r[a]=new _E(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){Bte(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Vte{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=ya.from(e.nodes),n.marks=ya.from(e.marks||{}),this.nodes=T9.compile(this.spec.nodes,this),this.marks=_E.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]=lm.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?C9(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==""?[]:C9(this,o.split(" "))}this.nodeFromJSON=i=>Kd.fromJSON(this,i),this.markFromJSON=i=>_r.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 T9){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 oM(r,r.defaultAttrs,e,_r.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 C9(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 P$e(t){return t.tag!=null}function R$e(t){return t.style!=null}let f0=class BR{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(P$e(i))this.tags.push(i);else if(R$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 j9(this,n,!1);return r.addAll(e,_r.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new j9(this,n,!0);return r.addAll(e,_r.none,n.from,n.to),Ht.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(L$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=P9(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=P9(o)),o.node||o.ignore||o.mark||(o.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new BR(e,BR.schemaRules(e)))}};const Gte={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},D$e={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Wte={ol:!0,ul:!0},ly=1,$R=2,m0=4;function k9(t,e,n){return e!=null?(e?ly:0)|(e==="full"?$R:0):t&&t.whitespace=="pre"?ly|$R:n&~m0}class Fw{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=_r.none,this.match=a||(o&m0?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(Et.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&ly)){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=Et.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(Et.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&&!Gte.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class j9{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=k9(null,n.preserveWhitespace,0)|(r?m0:0);i?a=new Fw(i.type,i.attrs,_r.none,!0,n.topMatch||i.type.contentMatch,o):r?a=new Fw(null,null,_r.none,!0,null,o):a=new Fw(e.schema.topNodeType,null,_r.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&$R?"full":this.localPreserveWS||(i.options&ly)>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;Wte.hasOwnProperty(o)&&this.parser.normalizeLists&&O$e(e);let c=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(c?c.ignore:D$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(Gte.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=_r.none;for(let l of i.concat(e.marks))(a.type?a.type.allowsMarkType(l.type):R9(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=k9(e,a,o.options);o.options&m0&&o.content.length==0&&(l|=m0);let c=_r.none;return r=r.filter(u=>(o.type?o.type.allowsMarkType(u.type):R9(u.type,e))?(c=u.addToSet(c),!1):!0),this.nodes.push(new Fw(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|=ly)}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 O$e(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Wte.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function L$e(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function P9(t){let e={};for(let n in t)e[n]=t[n];return e}function R9(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 ym{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=xj(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}=S1(xj(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&&S1(xj(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return S1(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new ym(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=D9(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return D9(e.marks)}}function D9(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function xj(t){return t.document||window.document}const O9=new WeakMap;function I$e(t){let e=O9.get(t);return e===void 0&&O9.set(t,e=F$e(t)),e}function F$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 S1(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=I$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}=S1(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 qte=65535,Kte=Math.pow(2,16);function U$e(t,e){return t+e*Kte}function L9(t){return t&qte}function z$e(t){return(t-(t&qte))/Kte}const Xte=1,Yte=2,M1=4,Zte=8;class HR{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Zte)>0}get deletedBefore(){return(this.delInfo&(Xte|M1))>0}get deletedAfter(){return(this.delInfo&(Yte|M1))>0}get deletedAcross(){return(this.delInfo&M1)>0}}class Ws{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Ws.empty)return Ws.empty}recover(e){let n=0,r=L9(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+z$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:U$e(l/3,e-c),y=e==c?Yte:e==f?Xte:M1;return(n<0?e!=c:e!=f)&&(y|=Zte),new HR(p,y,b)}i+=d-u}return r?e+i:new HR(e+i,0,null)}touches(e,n){let r=0,i=L9(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 Ws(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Ws.empty:new Ws(e<0?[0,-e,0]:[0,0,e])}}Ws.empty=new Ws([]);class cy{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 cy(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 cy;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 HR(e,i,null)}}const bj=Object.create(null);class Ga{getMap(){return Ws.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=bj[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 bj)throw new RangeError("Duplicate use of step JSON ID "+e);return bj[e]=n,n.prototype.jsonID=e,n}}class Ti{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new Ti(e,null)}static fail(e){return new Ti(null,e)}static fromReplace(e,n,r,i){try{return Ti.ok(e.replace(n,r,i))}catch(a){if(a instanceof iM)return Ti.fail(a.message);throw a}}}function CL(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let a=t.child(i);a.content.size&&(a=a.copy(CL(a.content,e,a))),a.isInline&&(a=e(a,n,i)),r.push(a)}return Et.fromArray(r)}class Ld extends Ga{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 Ht(CL(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 Ti.fromReplace(e,this.from,this.to,a)}invert(){return new sl(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Ld(n.pos,r.pos,this.mark)}merge(e){return e instanceof Ld&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ld(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Ld(n.from,n.to,e.markFromJSON(n.mark))}}Ga.jsonID("addMark",Ld);class sl extends Ga{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 Ht(CL(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return Ti.fromReplace(e,this.from,this.to,r)}invert(){return new Ld(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new sl(n.pos,r.pos,this.mark)}merge(e){return e instanceof sl&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new sl(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 sl(n.from,n.to,e.markFromJSON(n.mark))}}Ga.jsonID("removeMark",sl);class Id extends Ga{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Ti.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Ti.fromReplace(e,this.pos,this.pos+1,new Ht(Et.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let i=0;i<n.marks.length;i++)if(!n.marks[i].isInSet(r))return new Id(this.pos,n.marks[i]);return new Id(this.pos,this.mark)}}return new cm(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Id(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Id(n.pos,e.markFromJSON(n.mark))}}Ga.jsonID("addNodeMark",Id);class cm extends Ga{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Ti.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return Ti.fromReplace(e,this.pos,this.pos+1,new Ht(Et.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Id(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new cm(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 cm(n.pos,e.markFromJSON(n.mark))}}Ga.jsonID("removeNodeMark",cm);class ea extends Ga{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&VR(e,this.from,this.to)?Ti.fail("Structure replace would overwrite content"):Ti.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Ws([this.from,this.to-this.from,this.slice.size])}invert(e){return new ea(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 ea(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof ea)||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?Ht.empty:new Ht(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new ea(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?Ht.empty:new Ht(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new ea(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 ea(n.from,n.to,Ht.fromJSON(e,n.slice),!!n.structure)}}Ga.jsonID("replace",ea);class aa extends Ga{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&&(VR(e,this.from,this.gapFrom)||VR(e,this.gapTo,this.to)))return Ti.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return Ti.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?Ti.fromReplace(e,this.from,this.to,r):Ti.fail("Content does not fit in gap")}getMap(){return new Ws([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 aa(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 aa(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 aa(n.from,n.to,n.gapFrom,n.gapTo,Ht.fromJSON(e,n.slice),n.insert,!!n.structure)}}Ga.jsonID("replaceAround",aa);function VR(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 B$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 sl(m,p,f[y])));l&&l.to==m?l.to=p:a.push(l=new Ld(m,p,r))}}),i.forEach(c=>t.step(c)),a.forEach(c=>t.step(c))}function $$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 _E){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 sl(o.from,o.to,o.style)))}function kL(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 ea(l,d,Ht.empty));else{r=f;for(let m=0;m<u.marks.length;m++)n.allowsMarkType(u.marks[m].type)||t.step(new sl(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 Ht(Et.from(n.schema.text(" ",n.allowedMarks(u.marks))),0,0)),o.push(new ea(l+m.index,l+m.index+m[0].length,b))}}l=d}if(!r.validEnd){let c=r.fillBefore(Et.empty,!0);t.replace(l,l,new Ht(c,0,0))}for(let c=o.length-1;c>=0;c--)t.step(o[c])}function H$e(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function gx(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||!H$e(o,l,c))break;l&&(i=1),c<o.childCount&&(a=1)}return null}function V$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=Et.empty,f=0;for(let b=a,y=!1;b>n;b--)y||r.index(b)>0?(y=!0,d=Et.from(r.node(b).copy(d)),f++):c--;let m=Et.empty,p=0;for(let b=a,y=!1;b>n;b--)y||i.after(b+1)<i.end(b)?(y=!0,m=Et.from(i.node(b).copy(m)),p++):u++;t.step(new aa(c,u,o,l,new Ht(d.append(m),f,p),d.size-f,!0))}function jL(t,e,n=null,r=t){let i=G$e(t,e),a=i&&W$e(r,e);return a?i.map(I9).concat({type:e,attrs:n}).concat(a.map(I9)):null}function I9(t){return{type:t,attrs:null}}function G$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 W$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 q$e(t,e,n){let r=Et.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=Et.from(n[o].type.create(n[o].attrs,r))}let i=e.start,a=e.end;t.step(new aa(i,a,i,a,new Ht(r,0,0),n.length,!0))}function K$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)&&X$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&&Jte(t,o,l,a),kL(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 aa(f,m,f+1,m-1,new Ht(Et.from(r.create(c,null,o.marks)),0,0),1,!0)),u===!0&&Qte(t,o,l,a),!1}})}function Qte(t,e,n,r){e.forEach((i,a)=>{if(i.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(i.text);){let c=t.mapping.slice(r).map(n+1+a+o.index);t.replaceWith(c,c+1,e.type.schema.linebreakReplacement.create())}}})}function Jte(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 X$e(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function Y$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 aa(e,e+a.nodeSize,e+1,e+a.nodeSize-1,new Ht(Et.from(o),0,0),1,!0))}function hu(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 Z$e(t,e,n=1,r){let i=t.doc.resolve(e),a=Et.empty,o=Et.empty;for(let l=i.depth,c=i.depth-n,u=n-1;l>c;l--,u--){a=Et.from(i.node(l).copy(a));let d=r&&r[u];o=Et.from(d?d.type.create(d.attrs,o):i.node(l).copy(o))}t.step(new ea(e,e,new Ht(a.append(o),n,n),!0))}function vh(t,e){let n=t.resolve(e),r=n.index();return ene(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Q$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 ene(t,e){return!!(t&&e&&!t.isLeaf&&Q$e(t,e))}function wE(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&&ene(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 J$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);Jte(t,d.node(),d.before(),l)}o.inlineContent&&kL(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 ea(u,c.map(e+n,-1),Ht.empty,!0)),r===!0){let d=t.doc.resolve(u);Qte(t,d.node(),d.before(),t.steps.length)}return t}function eHe(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 tne(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 SE(t,e,n=e,r=Ht.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),a=t.resolve(n);return nne(i,a,r)?new ea(e,n,r):new tHe(i,a,r).fit()}function nne(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class tHe{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=Et.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=Et.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 Ht(a,o,l);return e>-1?new aa(r.pos,e,this.$to.pos,this.$to.end(),c,n):c.size||r.pos!=this.$to.pos?new ea(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=yj(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(Et.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=yj(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new Ht(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=yj(e,n);if(i.childCount<=1&&n>0){let a=e.size-n<=n+i.size;this.unplaced=new Ht(Yb(e,n-1,1),n-1,a?n-1:r)}else this.unplaced=new Ht(Yb(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(rne(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=Zb(this.placed,n,Et.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?Ht.empty:new Ht(Yb(o.content,e-1,1),e-1,p<0?o.openEnd:e-1):new Ht(Yb(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||!vj(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=vj(e,n,i,r,a);if(o){for(let l=n-1;l>=0;l--){let{match:c,type:u}=this.frontier[l],d=vj(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=Zb(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=Zb(this.placed,this.depth,Et.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(Et.empty,!0);n.childCount&&(this.placed=Zb(this.placed,this.frontier.length,n))}}function Yb(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Yb(t.firstChild.content,e-1,n)))}function Zb(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Zb(t.lastChild.content,e-1,n)))}function yj(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function rne(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,rne(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(Et.empty,!0)))),t.copy(r)}function vj(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&&!nHe(n,a.content,o)?l:null}function nHe(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function rHe(t){return t.spec.defining||t.spec.definingForContent}function iHe(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),a=t.doc.resolve(n);if(nne(i,a,r))return t.step(new ea(e,n,r));let o=ane(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=rHe(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 Ht(ine(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 ine(t,e,n,r,i){if(e<n){let a=t.firstChild;t=t.replaceChild(0,a.copy(ine(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(Et.empty,!0))}return t}function aHe(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=eHe(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new Ht(Et.from(r),0,0))}function sHe(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),a=ane(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 ane(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 pg extends Ga{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 Ti.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 Ti.fromReplace(e,this.pos,this.pos+1,new Ht(Et.from(i),0,n.isLeaf?0:1))}getMap(){return Ws.empty}invert(e){return new pg(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 pg(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 pg(n.pos,n.attr,n.value)}}Ga.jsonID("attr",pg);class uy extends Ga{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 Ti.ok(r)}getMap(){return Ws.empty}invert(e){return new uy(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 uy(n.attr,n.value)}}Ga.jsonID("docAttr",uy);let zg=class extends Error{};zg=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};zg.prototype=Object.create(Error.prototype);zg.prototype.constructor=zg;zg.prototype.name="TransformError";class sne{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new cy}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new zg(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=Ht.empty){let i=SE(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new Ht(Et.from(r),0,0))}delete(e,n){return this.replace(e,n,Ht.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return iHe(this,e,n,r),this}replaceRangeWith(e,n,r){return aHe(this,e,n,r),this}deleteRange(e,n){return sHe(this,e,n),this}lift(e,n){return V$e(this,e,n),this}join(e,n=1){return J$e(this,e,n),this}wrap(e,n){return q$e(this,e,n),this}setBlockType(e,n=e,r,i=null){return K$e(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return Y$e(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new pg(e,n,r)),this}setDocAttribute(e,n){return this.step(new uy(e,n)),this}addNodeMark(e,n){return this.step(new Id(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof _r)n.isInSet(r.marks)&&this.step(new cm(e,n));else{let i=r.marks,a,o=[];for(;a=n.isInSet(i);)o.push(new cm(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 Z$e(this,e,n,r),this}addMark(e,n,r){return B$e(this,e,n,r),this}removeMark(e,n,r){return $$e(this,e,n,r),this}clearIncompatible(e,n,r){return kL(this,e,n,r),this}}const _j=Object.create(null);class En{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new oHe(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=Ht.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?Ht.empty:n),l==0&&z9(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),z9(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new fn(e):qp(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?qp(e.node(0),e.node(a),e.before(a+1),e.index(a),n,r):qp(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 Qs(e.node(0))}static atStart(e){return qp(e,e,0,0,1)||new Qs(e)}static atEnd(e){return qp(e,e,e.content.size,e.childCount,-1)||new Qs(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=_j[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 _j)throw new RangeError("Duplicate use of selection JSON ID "+e);return _j[e]=n,n.prototype.jsonID=e,n}getBookmark(){return fn.between(this.$anchor,this.$head).getBookmark()}}En.prototype.visible=!0;class oHe{constructor(e,n){this.$from=e,this.$to=n}}let F9=!1;function U9(t){!F9&&!t.parent.inlineContent&&(F9=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class fn extends En{constructor(e,n=e){U9(e),U9(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return En.near(r);let i=e.resolve(n.map(this.anchor));return new fn(i.parent.inlineContent?i:r,r)}replace(e,n=Ht.empty){if(super.replace(e,n),n==Ht.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 ME(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new fn(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let i=e.resolve(n);return new this(i,r==n?i:e.resolve(r))}static between(e,n,r){let i=e.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let a=En.findFrom(n,r,!0)||En.findFrom(n,-r,!0);if(a)n=a.$head;else return En.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(En.findFrom(e,-r,!0)||En.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new fn(e,n)}}En.jsonID("text",fn);class ME{constructor(e,n){this.anchor=e,this.head=n}map(e){return new ME(e.map(this.anchor),e.map(this.head))}resolve(e){return fn.between(e.resolve(this.anchor),e.resolve(this.head))}}class nn extends En{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),a=e.resolve(i);return r?En.near(a):new nn(a)}content(){return new Ht(Et.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 PL(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new nn(e.resolve(n.anchor))}static create(e,n){return new nn(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}nn.prototype.visible=!1;En.jsonID("node",nn);class PL{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new ME(r,r):new PL(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&nn.isSelectable(r)?new nn(n):En.near(n)}}class Qs extends En{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=Ht.empty){if(n==Ht.empty){e.delete(0,e.doc.content.size);let r=En.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new Qs(e)}map(e){return new Qs(e)}eq(e){return e instanceof Qs}getBookmark(){return lHe}}En.jsonID("all",Qs);const lHe={map(){return this},resolve(t){return new Qs(t)}};function qp(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=qp(t,l,n+i,i<0?l.childCount:0,i,a);if(c)return c}n+=l.nodeSize*i}return null}function z9(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof ea||i instanceof aa))return;let a=t.mapping.maps[r],o;a.forEach((l,c,u,d)=>{o==null&&(o=d)}),t.setSelection(En.near(t.doc.resolve(o),n))}const B9=1,Uw=2,$9=4;class cHe extends sne{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|B9)&~Uw,this.storedMarks=null,this}get selectionSet(){return(this.updated&B9)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Uw,this}ensureMarks(e){return _r.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&Uw)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Uw,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)||_r.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let i=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let a=this.storedMarks;if(!a){let o=this.doc.resolve(n);a=r==n?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,i.text(e,a)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(En.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=$9,this}get scrolledIntoView(){return(this.updated&$9)>0}}function H9(t,e){return!e||!t?t:t.bind(e)}class Qb{constructor(e,n,r){this.name=e,this.init=H9(n.init,r),this.apply=H9(n.apply,r)}}const uHe=[new Qb("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Qb("selection",{init(t,e){return t.selection||En.atStart(e.doc)},apply(t){return t.selection}}),new Qb("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Qb("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class wj{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=uHe.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 Qb(r.key,r.spec.state,r))})}}class ng{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 ng(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 cHe(this)}static create(e){let n=new wj(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new ng(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 wj(this.schema,e.plugins),r=n.fields,i=new ng(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 wj(e.schema,e.plugins),a=new ng(i);return i.fields.forEach(o=>{if(o.name=="doc")a.doc=Kd.fromJSON(e.schema,n.doc);else if(o.name=="selection")a.selection=En.fromJSON(a.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(a.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let c=r[l],u=c.spec.state;if(c.key==o.name&&u&&u.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){a[o.name]=u.fromJSON.call(c,e,n[l],a);return}}a[o.name]=o.init(e,a)}}),a}}function one(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=one(i,e,{})),n[r]=i}return n}class Zr{constructor(e){this.spec=e,this.props={},e.props&&one(e.props,this,this.props),this.key=e.key?e.key.key:lne("plugin")}getState(e){return e[this.key]}}const Sj=Object.create(null);function lne(t){return t in Sj?t+"$"+ ++Sj[t]:(Sj[t]=0,t+"$")}class Vi{constructor(e="key"){this.key=lne(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const RL=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function cne(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const une=(t,e,n)=>{let r=cne(t,n);if(!r)return!1;let i=DL(r);if(!i){let o=r.blockRange(),l=o&&gx(o);return l==null?!1:(e&&e(t.tr.lift(o,l).scrollIntoView()),!0)}let a=i.nodeBefore;if(yne(t,i,e,-1))return!0;if(r.parent.content.size==0&&(Bg(a,"end")||nn.isSelectable(a)))for(let o=r.depth;;o--){let l=SE(t.doc,r.before(o),r.after(o),Ht.empty);if(l&&l.slice.size<l.to-l.from){if(e){let c=t.tr.step(l);c.setSelection(Bg(a,"end")?En.findFrom(c.doc.resolve(c.mapping.map(i.pos,-1)),-1):nn.create(c.doc,i.pos-a.nodeSize)),e(c.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return a.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos-a.nodeSize,i.pos).scrollIntoView()),!0):!1},dHe=(t,e,n)=>{let r=cne(t,n);if(!r)return!1;let i=DL(r);return i?dne(t,i,e):!1},hHe=(t,e,n)=>{let r=fne(t,n);if(!r)return!1;let i=OL(r);return i?dne(t,i,e):!1};function dne(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=SE(t.doc,a,c,Ht.empty);if(!u||u.from!=a||u instanceof ea&&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 Bg(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 hne=(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=DL(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 DL(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 fne(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const mne=(t,e,n)=>{let r=fne(t,n);if(!r)return!1;let i=OL(r);if(!i)return!1;let a=i.nodeAfter;if(yne(t,i,e,1))return!0;if(r.parent.content.size==0&&(Bg(a,"start")||nn.isSelectable(a))){let o=SE(t.doc,r.before(),r.after(),Ht.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(Bg(a,"start")?En.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):nn.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return a.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos,i.pos+a.nodeSize).scrollIntoView()),!0):!1},pne=(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=OL(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 OL(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 fHe=(t,e)=>{let n=t.selection,r=n instanceof nn,i;if(r){if(n.node.isTextblock||!vh(t.doc,n.from))return!1;i=n.from}else if(i=wE(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},mHe=(t,e)=>{let n=t.selection,r;if(n instanceof nn){if(n.node.isTextblock||!vh(t.doc,n.to))return!1;r=n.to}else if(r=wE(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},pHe=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),a=i&&gx(i);return a==null?!1:(e&&e(t.tr.lift(i,a).scrollIntoView()),!0)},gne=(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 LL(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 gHe=(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=LL(i.contentMatchAt(a));if(!o||!i.canReplaceWith(a,a,o))return!1;if(e){let l=n.after(),c=t.tr.replaceWith(l,l,o.createAndFill());c.setSelection(En.near(c.doc.resolve(l),1)),e(c.scrollIntoView())}return!0},xne=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof Qs||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=LL(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},bne=(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(hu(t.doc,a))return e&&e(t.tr.split(a).scrollIntoView()),!0}let r=n.blockRange(),i=r&&gx(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function xHe(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof nn&&e.selection.node.isBlock)return!r.parentOffset||!hu(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=LL(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 Qs)&&d.deleteSelection();let f=d.mapping.map(r.pos),m=hu(d.doc,f,a.length,a);if(m||(a[0]=l?{type:l}:null,m=hu(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 bHe=xHe(),yHe=(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 vHe(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||vh(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function yne(t,e,n,r){let i=e.nodeBefore,a=e.nodeAfter,o,l,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&vHe(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=Et.empty;for(let v=o.length-1;v>=0;v--)b=Et.from(o[v].create(null,b));b=Et.from(i.copy(b));let y=t.tr.step(new aa(e.pos-1,p,e.pos,p,new Ht(b,1,0),o.length,!0)),x=y.doc.resolve(p+2*o.length);x.nodeAfter&&x.nodeAfter.type==i.type&&vh(y.doc,x.pos)&&y.join(x.pos),n(y.scrollIntoView())}return!0}let d=a.type.spec.isolating||r>0&&c?null:En.findFrom(e,1),f=d&&d.$from.blockRange(d.$to),m=f&&gx(f);if(m!=null&&m>=e.depth)return n&&n(t.tr.lift(f,m).scrollIntoView()),!0;if(u&&Bg(a,"start",!0)&&Bg(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=Et.empty;for(let M=b.length-1;M>=0;M--)v=Et.from(b[M].copy(v));let S=t.tr.step(new aa(e.pos-b.length,e.pos+a.nodeSize,e.pos+x,e.pos+a.nodeSize-x,new Ht(v,b.length,0),0,!0));n(S.scrollIntoView())}return!0}}return!1}function vne(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 _He=vne(-1),wHe=vne(1);function SHe(t,e=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),l=o&&jL(o,t,e);return l?(r&&r(n.tr.wrap(o,l).scrollIntoView()),!0):!1}}function V9(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 IL(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}IL(RL,une,hne);IL(RL,mne,pne);IL(gne,xne,bne,bHe);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function MHe(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 NHe(l,o,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function NHe(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 sM(c,c,e.depth),e.endIndex<e.parent.childCount&&(e=new sM(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=jL(a,n,r,e);return l?(t&&EHe(t,e,l,i,n),!0):!1}function EHe(t,e,n,r,i){let a=Et.empty;for(let d=n.length-1;d>=0;d--)a=Et.from(n[d].type.create(n[d].attrs,a));t.step(new aa(e.start-(r?2:0),e.end,e.start,e.end,new Ht(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&&hu(t.doc,c,l)&&(t.split(c,l),c+=2*l),c+=u.child(d).nodeSize;return t}function AHe(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?THe(e,n,t,a):CHe(e,n,a):!0:!1}}function THe(t,e,n,r){let i=t.tr,a=r.end,o=r.$to.end(r.depth);a<o&&(i.step(new aa(a-1,o,a,o,new Ht(Et.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new sM(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));const l=gx(r);if(l==null)return!1;i.lift(r,l);let c=i.doc.resolve(i.mapping.map(a,-1)-1);return vh(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos),e(i.scrollIntoView()),!0}function CHe(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?Et.empty:Et.from(i))))return!1;let f=a.pos,m=f+o.nodeSize;return r.step(new aa(f-(l?1:0),m+(c?1:0),f+1,m-1,new Ht((l?Et.empty:Et.from(i.copy(Et.empty))).append(c?Et.empty:Et.from(i.copy(Et.empty))),l?0:1,c?0:1),l?0:1)),e(r.scrollIntoView()),!0}function kHe(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=Et.from(u?t.create():null),f=new Ht(Et.from(t.create(null,Et.from(l.type.create(null,d)))),u?3:1,0),m=a.start,p=a.end;n(e.tr.step(new aa(m-(u?3:1),p,m,p,f,1,!0)).scrollIntoView())}return!0}}const Ma=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},$g=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let GR=null;const Kc=function(t,e,n){let r=GR||(GR=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},jHe=function(){GR=null},um=function(t,e,n,r){return n&&(G9(t,e,n,r,-1)||G9(t,e,n,r,1))},PHe=/^(img|br|input|textarea|hr)$/i;function G9(t,e,n,r,i){for(var a;;){if(t==n&&e==r)return!0;if(e==(i<0?0:To(t))){let o=t.parentNode;if(!o||o.nodeType!=1||ev(t)||PHe.test(t.nodeName)||t.contentEditable=="false")return!1;e=Ma(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?To(t):0}else return!1}}function To(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function RHe(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=To(t)}else if(t.parentNode&&!ev(t))e=Ma(t),t=t.parentNode;else return null}}function DHe(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&&!ev(t))e=Ma(t)+1,t=t.parentNode;else return null}}function OHe(t,e,n){for(let r=e==0,i=e==To(t);r||i;){if(t==n)return!0;let a=Ma(t);if(t=t.parentNode,!t)return!1;r=r&&a==0,i=i&&a==To(t)}}function ev(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 NE=function(t){return t.focusNode&&um(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function df(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function LHe(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function IHe(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(To(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(To(r.startContainer),r.startOffset)}}}const sc=typeof navigator<"u"?navigator:null,W9=typeof document<"u"?document:null,_h=sc&&sc.userAgent||"",WR=/Edge\/(\d+)/.exec(_h),_ne=/MSIE \d/.exec(_h),qR=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(_h),As=!!(_ne||qR||WR),Xd=_ne?document.documentMode:qR?+qR[1]:WR?+WR[1]:0,Po=!As&&/gecko\/(\d+)/i.test(_h);Po&&+(/Firefox\/(\d+)/.exec(_h)||[0,0])[1];const KR=!As&&/Chrome\/(\d+)/.exec(_h),ra=!!KR,wne=KR?+KR[1]:0,ka=!As&&!!sc&&/Apple Computer/.test(sc.vendor),Hg=ka&&(/Mobile\/\w+/.test(_h)||!!sc&&sc.maxTouchPoints>2),wo=Hg||(sc?/Mac/.test(sc.platform):!1),Sne=sc?/Win/.test(sc.platform):!1,iu=/Android \d/.test(_h),tv=!!W9&&"webkitFontSmoothing"in W9.documentElement.style,FHe=tv?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function UHe(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 $c(t,e){return typeof t=="number"?t:t[e]}function zHe(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 q9(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=$g(o);continue}let l=o,c=l==a.body,u=c?UHe(a):zHe(l),d=0,f=0;if(e.top<u.top+$c(r,"top")?f=-(u.top-e.top+$c(i,"top")):e.bottom>u.bottom-$c(r,"bottom")&&(f=e.bottom-e.top>u.bottom-u.top?e.top+$c(i,"top")-u.top:e.bottom-u.bottom+$c(i,"bottom")),e.left<u.left+$c(r,"left")?d=-(u.left-e.left+$c(i,"left")):e.right>u.right-$c(r,"right")&&(d=e.right-u.right+$c(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:$g(o)}}function BHe(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:Mne(t.dom)}}function Mne(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=$g(r));return e}function $He({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Nne(n,r==0?0:r-e)}function Nne(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 Up=null;function HHe(t){if(t.setActive)return t.setActive();if(Up)return t.focus(Up);let e=Mne(t);t.focus(Up==null?{get preventScroll(){return Up={preventScroll:!0},!0}}:void 0),Up||(Up=!1,Nne(e,0))}function Ene(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=Kc(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?VHe(n,i):!n||r&&n.nodeType==1?{node:t,offset:a}:Ene(n,i)}function VHe(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=bd(r,1);if(o.top!=o.bottom&&FL(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 FL(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function GHe(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function WHe(t,e,n){let{node:r,offset:i}=Ene(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 qHe(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 Ane(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(FL(e,u))return Ane(o,e,u)}}if((a=(a+1)%r)==i)break}return t}function KHe(t,e){let n=t.dom.ownerDocument,r,i=0,a=IHe(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(!FL(e,u)||(o=Ane(t.dom,e,u),!o))return null}if(ka)for(let u=o;r&&u;u=$g(u))u.draggable&&(r=void 0);if(o=GHe(o,e),r){if(Po&&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;tv&&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=qHe(t,r,i,e))}l==null&&(l=WHe(t,o,e));let c=t.docView.nearestDesc(o,!0);return{pos:l,inside:c?c.posAtStart-c.border:-1}}function K9(t){return t.top<t.bottom||t.left<t.right}function bd(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(K9(r))return r}return Array.prototype.find.call(n,K9)||t.getBoundingClientRect()}const XHe=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Tne(t,e,n){let{node:r,offset:i,atom:a}=t.docView.domFromPos(e,n<0?-1:1),o=tv||Po;if(r.nodeType==3)if(o&&(XHe.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let c=bd(Kc(r,i,i),n);if(Po&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let u=bd(Kc(r,i-1,i-1),-1);if(u.top==c.top){let d=bd(Kc(r,i,i+1),-1);if(d.top!=c.top)return Ob(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++,Ob(bd(Kc(r,c,u),d),d<0)}if(!t.state.doc.resolve(e-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==To(r))){let c=r.childNodes[i-1];if(c.nodeType==1)return Mj(c.getBoundingClientRect(),!1)}if(a==null&&i<To(r)){let c=r.childNodes[i];if(c.nodeType==1)return Mj(c.getBoundingClientRect(),!0)}return Mj(r.getBoundingClientRect(),n>=0)}if(a==null&&i&&(n<0||i==To(r))){let c=r.childNodes[i-1],u=c.nodeType==3?Kc(c,To(c)-(o?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(u)return Ob(bd(u,1),!1)}if(a==null&&i<To(r)){let c=r.childNodes[i];for(;c.pmViewDesc&&c.pmViewDesc.ignoreForCoords;)c=c.nextSibling;let u=c?c.nodeType==3?Kc(c,0,o?0:1):c.nodeType==1?c:null:null;if(u)return Ob(bd(u,-1),!0)}return Ob(bd(r.nodeType==3?Kc(r):r,-n),n>=0)}function Ob(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 Mj(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 Cne(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 YHe(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return Cne(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=Tne(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=Kc(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 ZHe=/[\u0590-\u08ac]/;function QHe(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?!ZHe.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?a:o:Cne(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 X9=null,Y9=null,Z9=!1;function JHe(t,e,n){return X9==e&&Y9==n?Z9:(X9=e,Y9=n,Z9=n=="up"||n=="down"?YHe(t,e,n):QHe(t,e,n))}const Ro=0,Q9=1,wf=2,oc=3;class nv{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=Ro,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>Ma(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 jne){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 kne&&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?Ma(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?Ma(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=Ma(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=Ma(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((Po||ka)&&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:Ma(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(Po&&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&&ka)&&um(l.node,l.offset,d.anchorNode,d.anchorOffset)&&um(c.node,c.offset,d.focusNode,d.focusOffset))return;let m=!1;if((u.extend||e==n)&&!(f&&Po)){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?wf:Q9,e==l&&n==c&&(a.contentLost||a.dom.parentNode!=this.contentDOM)?a.dirty=oc:a.markDirty(e-l,n-l);return}else a.dirty=a.dom==a.contentDOM&&a.dom.parentNode==this.contentDOM&&!a.children.length?wf:oc}r=o}this.dirty=wf}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?wf:Q9;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class kne extends nv{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==Ro&&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 eVe extends nv{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 dm extends nv{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=ym.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new dm(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&oc||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=oc&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=Ro){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Ro}}slice(e,n,r){let i=dm.create(this.parent,this.mark,!0,r),a=this.children,o=this.size;n<o&&(a=YR(a,n,o,r)),e>0&&(a=YR(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 Yd extends nv{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}=ym.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=Dne(d,r,n),u?c=new tVe(e,n,r,i,d,f||null,m,u,a,o+1):n.isText?new EE(e,n,r,i,d,m,a):new Yd(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=()=>Et.empty)}return e}matchesNode(e,n,r){return this.dirty==Ro&&e.eq(this.node)&&lM(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 rVe(this,o&&o.node,e);sVe(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?_r.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==wf)&&(o&&this.protectLocalComposition(e,o),Pne(this.contentDOM,this.children,e),Hg&&oVe(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=lVe(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 eVe(this,a,n,i);e.input.compositionNodes.push(o),this.children=YR(this.children,r,r+i.length,e,o)}update(e,n,r,i){return this.dirty==oc||!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=Ro}updateOuterDeco(e){if(lM(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Rne(this.dom,this.nodeDOM,XR(this.outerDeco,this.node,n),XR(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 J9(t,e,n,r,i){Dne(r,e,t);let a=new Yd(void 0,t,e,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}class EE extends Yd{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==oc||this.dirty!=Ro&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Ro||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=Ro,!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 EE(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=oc)}get domAtom(){return!1}isText(e){return this.node.text==e}}class jne extends nv{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Ro&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class tVe extends Yd{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==oc)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 Pne(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=eW(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(l,r);if(o instanceof dm){let c=r?r.previousSibling:t.lastChild;Pne(o.contentDOM,o.children,n),r=c?c.nextSibling:t.firstChild}}for(;r;)r=eW(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const p0=function(t){t&&(this.nodeName=t)};p0.prototype=Object.create(null);const Sf=[new p0];function XR(t,e,n){if(t.length==0)return Sf;let r=n?Sf[0]:new p0,i=[r];for(let a=0;a<t.length;a++){let o=t[a].type.attrs;if(o){o.nodeName&&i.push(r=new p0(o.nodeName));for(let l in o){let c=o[l];c!=null&&(n&&i.length==1&&i.push(r=new p0(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 Rne(t,e,n,r){if(n==Sf&&r==Sf)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=Sf[0]),i=c}nVe(i,l||Sf[0],o)}return i}function nVe(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 Dne(t,e,n){return Rne(t,t,Sf,XR(e,n,t.nodeType!=1))}function lM(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 eW(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class rVe{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=iVe(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=Ro,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=dm.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==oc&&o.dom==o.contentDOM&&(o.dirty=wf),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 Yd){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!=oc&&lM(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=wf,f.updateChildren(i,o+1),f.dirty=Ro),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)||!lM(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=Yd.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=Yd.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 kne(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 dm;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof EE)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ka||ra)&&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 jne(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 iVe(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 dm)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 aVe(t,e){return t.type.side-e.type.side}function sVe(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(aVe);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 oVe(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 lVe(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 YR(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 UL(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(NE(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&&OHe(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=zL(t,d,l,f)}return u}function One(t){return t.editable?t.hasFocus():Ine(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function fu(t,e=!1){let n=t.state.selection;if(Lne(t,n),!!One(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&ra){let r=t.domSelectionRange(),i=t.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&um(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)uVe(t);else{let{anchor:r,head:i}=n,a,o;tW&&!(n instanceof fn)&&(n.$from.parent.inlineContent||(a=nW(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=nW(t,n.to))),t.docView.setSelection(r,i,t,e),tW&&(a&&rW(a),o&&rW(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&cVe(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const tW=ka||ra&&wne<63;function nW(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(ka&&i&&i.contentEditable=="false")return Nj(i);if((!i||i.contentEditable=="false")&&(!a||a.contentEditable=="false")){if(i)return Nj(i);if(a)return Nj(a)}}function Nj(t){return t.contentEditable="true",ka&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function rW(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function cVe(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(()=>{(!One(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function uVe(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,Ma(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&As&&Xd<=11&&(n.disabled=!0,n.disabled=!1)}function Lne(t,e){if(e instanceof nn){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(iW(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else iW(t)}function iW(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function zL(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||fn.between(e,n,r)}function aW(t){return t.editable&&!t.hasFocus()?!1:Ine(t)}function Ine(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 dVe(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return um(e.node,e.offset,n.anchorNode,n.anchorOffset)}function ZR(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),a=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return a&&En.findFrom(a,e)}function Sd(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function sW(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 Sd(t,new fn(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=ZR(t.state,e);return i&&i instanceof nn?Sd(t,i):!1}else if(!(wo&&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)?Sd(t,new nn(e<0?t.state.doc.resolve(i.pos-a.nodeSize):i)):tv?Sd(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 Sd(t,new fn(e>0?r.$to:r.$from));{let i=ZR(t.state,e);return i?Sd(t,i):!1}}}function cM(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function g0(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function zp(t,e){return e<0?hVe(t):fVe(t)}function hVe(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,a,o=!1;for(Po&&n.nodeType==1&&r<cM(n)&&g0(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(g0(l,-1))i=n,a=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(Fne(n))break;{let l=n.previousSibling;for(;l&&g0(l,-1);)i=n.parentNode,a=Ma(l),l=l.previousSibling;if(l)n=l,r=cM(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?QR(t,n,r):i&&QR(t,i,a)}function fVe(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=cM(n),a,o;for(;;)if(r<i){if(n.nodeType!=1)break;let l=n.childNodes[r];if(g0(l,1))a=n,o=++r;else break}else{if(Fne(n))break;{let l=n.nextSibling;for(;l&&g0(l,1);)a=l.parentNode,o=Ma(l)+1,l=l.nextSibling;if(l)n=l,r=0,i=cM(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}a&&QR(t,a,o)}function Fne(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function mVe(t,e){for(;t&&e==t.childNodes.length&&!ev(t);)e=Ma(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 pVe(t,e){for(;t&&!e&&!ev(t);)e=Ma(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function QR(t,e,n){if(e.nodeType!=3){let a,o;(o=mVe(e,n))?(e=o,n=0):(a=pVe(e,n))&&(e=a,n=a.nodeValue.length)}let r=t.domSelection();if(!r)return;if(NE(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&&fu(t)},50)}function oW(t,e){let n=t.state.doc.resolve(e);if(!(ra||Sne)&&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 lW(t,e,n){let r=t.state.selection;if(r instanceof fn&&!r.empty||n.indexOf("s")>-1||wo&&n.indexOf("m")>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=ZR(t.state,e);if(o&&o instanceof nn)return Sd(t,o)}if(!i.parent.inlineContent){let o=e<0?i:a,l=r instanceof Qs?En.near(o,e):En.findFrom(o,e);return l?Sd(t,l):!1}return!1}function cW(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 uW(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function gVe(t){if(!ka||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;uW(t,r,"true"),setTimeout(()=>uW(t,r,"false"),20)}return!1}function xVe(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function bVe(t,e){let n=e.keyCode,r=xVe(e);if(n==8||wo&&n==72&&r=="c")return cW(t,-1)||zp(t,-1);if(n==46&&!e.shiftKey||wo&&n==68&&r=="c")return cW(t,1)||zp(t,1);if(n==13||n==27)return!0;if(n==37||wo&&n==66&&r=="c"){let i=n==37?oW(t,t.state.selection.from)=="ltr"?-1:1:-1;return sW(t,i,r)||zp(t,i)}else if(n==39||wo&&n==70&&r=="c"){let i=n==39?oW(t,t.state.selection.from)=="ltr"?1:-1:1;return sW(t,i,r)||zp(t,i)}else{if(n==38||wo&&n==80&&r=="c")return lW(t,-1,r)||zp(t,-1);if(n==40||wo&&n==78&&r=="c")return gVe(t)||lW(t,1,r)||zp(t,1);if(r==(wo?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function BL(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")||ym.fromSchema(t.state.schema),l=Vne(),c=l.createElement("div");c.appendChild(o.serializeFragment(r,{document:l}));let u=c.firstChild,d,f=0;for(;u&&u.nodeType==1&&(d=Hne[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 Une(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 Ht(Et.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=ym.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=wVe(n),tv&&SVe(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")||f0.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||d),context:i,ruleFromNode(m){return m.nodeName=="BR"&&!m.nextSibling&&m.parentNode&&!yVe.test(m.parentNode.nodeName)?{ignore:!0}:null}})),d)l=MVe(dW(l,+d[1],+d[2]),d[4]);else if(l=Ht.maxOpen(vVe(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=dW(l,f,m)}return t.someProp("transformPasted",f=>{l=f(l,t,c)}),l}const yVe=/^(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 vVe(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&&Bne(c,a,l,o[o.length-1],0))o[o.length-1]=u;else{o.length&&(o[o.length-1]=$ne(o[o.length-1],a.length));let d=zne(l,c);o.push(d),i=i.matchType(d.type),a=c}}),o)return Et.from(o)}return t}function zne(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,Et.from(t));return t}function Bne(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let a=Bne(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(Et.from(zne(n,t,i+1))))}}function $ne(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,$ne(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(Et.empty,!0);return t.copy(n.append(r))}function JR(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=JR(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(Et.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function dW(t,e,n){return e<t.openStart&&(t=new Ht(JR(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new Ht(JR(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const Hne={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 hW=null;function Vne(){return hW||(hW=document.implementation.createHTMLDocument("title"))}let Ej=null;function _Ve(t){let e=window.trustedTypes;return e?(Ej||(Ej=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),Ej.createHTML(t)):t}function wVe(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=Vne().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&Hne[r[1].toLowerCase()])&&(t=i.map(a=>"<"+a+">").join("")+t+i.map(a=>"</"+a+">").reverse().join("")),n.innerHTML=_Ve(t),i)for(let a=0;a<i.length;a++)n=n.querySelector(i[a])||n;return n}function SVe(t){let e=t.querySelectorAll(ra?"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 MVe(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=Et.from(c.create(r[l+1],i)),a++,o++}return new Ht(i,a,o)}const as={},ss={},NVe={touchstart:!0,touchmove:!0};class EVe{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 AVe(t){for(let e in as){let n=as[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{CVe(t,r)&&!$L(t,r)&&(t.editable||!(r.type in ss))&&n(t,r)},NVe[e]?{passive:!0}:void 0)}ka&&t.dom.addEventListener("input",()=>null),eD(t)}function Fd(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function TVe(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 eD(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>$L(t,r))})}function $L(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function CVe(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 kVe(t,e){!$L(t,e)&&as[e.type]&&(t.editable||!(e.type in ss))&&as[e.type](t,e)}ss.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Wne(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(iu&&ra&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Hg&&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,df(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||bVe(t,n)?n.preventDefault():Fd(t,"key")};ss.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};ss.keypress=(t,e)=>{let n=e;if(Wne(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||wo&&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 AE(t){return{left:t.clientX,top:t.clientY}}function jVe(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function HL(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 gg(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 PVe(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&nn.isSelectable(r)?(gg(t,new nn(n)),!0):!1}function RVe(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?(gg(t,nn.create(t.state.doc,i)),!0):!1}function DVe(t,e,n,r,i){return HL(t,"handleClickOn",e,n,r)||t.someProp("handleClick",a=>a(t,e,r))||(i?RVe(t,n):PVe(t,n))}function OVe(t,e,n,r){return HL(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function LVe(t,e,n,r){return HL(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||IVe(t,n,r)}function IVe(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(gg(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)gg(t,fn.create(r,l+1,l+1+o.content.size));else if(nn.isSelectable(o))gg(t,nn.create(r,l));else continue;return!0}}function VL(t){return uM(t)}const Gne=wo?"metaKey":"ctrlKey";as.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=VL(t),i=Date.now(),a="singleClick";i-t.input.lastClick.time<500&&jVe(n,t.input.lastClick)&&!n[Gne]&&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(AE(n));o&&(a=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new FVe(t,o,n,!!r)):(a=="doubleClick"?OVe:LVe)(t,o.pos,o.inside,n)?n.preventDefault():Fd(t,"pointer"))};class FVe{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[Gne],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&&Po&&!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)),Fd(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(()=>fu(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(AE(e))),this.updateAllowDefault(e),this.allowDefault||!n?Fd(this.view,"pointer"):DVe(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ka&&this.mightDrag&&!this.mightDrag.node.isAtom||ra&&!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)?(gg(this.view,En.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Fd(this.view,"pointer")}move(e){this.updateAllowDefault(e),Fd(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)}}as.touchstart=t=>{t.input.lastTouch=Date.now(),VL(t),Fd(t,"pointer")};as.touchmove=t=>{t.input.lastTouch=Date.now(),Fd(t,"pointer")};as.contextmenu=t=>VL(t);function Wne(t,e){return t.composing?!0:ka&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const UVe=iu?5e3:-1;ss.compositionstart=ss.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)||ra&&Sne&&zVe(t)))t.markCursor=t.state.storedMarks||n.marks(),uM(t,!0),t.markCursor=null;else if(uM(t,!e.selection.empty),Po&&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}qne(t,UVe)};function zVe(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"}ss.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++,qne(t,20))};function qne(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>uM(t),e))}function Kne(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=$Ve());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function BVe(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=RHe(e.focusNode,e.focusOffset),r=DHe(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 $Ve(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function uM(t,e=!1){if(!(iu&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Kne(t),e||t.docView&&t.docView.dirty){let n=UL(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 HVe(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 dy=As&&Xd<15||Hg&&FHe<604;as.copy=ss.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let a=dy?null:n.clipboardData,o=r.content(),{dom:l,text:c}=BL(t,o);a?(n.preventDefault(),a.clearData(),a.setData("text/html",l.innerHTML),a.setData("text/plain",c)):HVe(t,l),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function VVe(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function GVe(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?hy(t,r.value,null,i,e):hy(t,r.textContent,r.innerHTML,i,e)},50)}function hy(t,e,n,r,i){let a=Une(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",c=>c(t,i,a||Ht.empty)))return!0;if(!a)return!1;let o=VVe(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 Xne(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," "):""}ss.paste=(t,e)=>{let n=e;if(t.composing&&!iu)return;let r=dy?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&hy(t,Xne(r),r.getData("text/html"),i,n)?n.preventDefault():GVe(t,n)};class Yne{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const WVe=wo?"altKey":"ctrlKey";function Zne(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[WVe]}as.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(AE(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}=BL(t,l);(!n.dataTransfer.files.length||!ra||wne>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(dy?"Text":"text/html",c.innerHTML),n.dataTransfer.effectAllowed="copyMove",dy||n.dataTransfer.setData("text/plain",u),t.dragging=new Yne(d,Zne(t,n),o)};as.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};ss.dragover=ss.dragenter=(t,e)=>e.preventDefault();ss.drop=(t,e)=>{try{qVe(t,e,t.dragging)}finally{t.dragging=null}};function qVe(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(AE(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=Une(t,Xne(e.dataTransfer),dy?null:e.dataTransfer.getData("text/html"),!1,i);let o=!!(n&&Zne(t,e));if(t.someProp("handleDrop",p=>p(t,e,a||Ht.empty,o))){e.preventDefault();return}if(!a)return;e.preventDefault();let l=a?tne(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(zL(t,m,c.doc.resolve(p)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))}as.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())&&fu(t)},20))};as.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)};as.beforeinput=(t,e)=>{if(ra&&iu&&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,df(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 ss)as[t]=ss[t];function fy(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 dM{constructor(e,n){this.toDOM=e,this.spec=n||If,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 Ja(a-r,a-r,this)}valid(){return!0}eq(e){return this==e||e instanceof dM&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&fy(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Zd{constructor(e,n){this.attrs=e,this.spec=n||If}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 Ja(a,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Zd&&fy(this.attrs,e.attrs)&&fy(this.spec,e.spec)}static is(e){return e.type instanceof Zd}destroy(){}}class GL{constructor(e,n){this.attrs=e,this.spec=n||If}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 Ja(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 GL&&fy(this.attrs,e.attrs)&&fy(this.spec,e.spec)}destroy(){}}class Ja{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Ja(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 Ja(e,e,new dM(n,r))}static inline(e,n,r,i){return new Ja(e,n,new Zd(r,i))}static node(e,n,r,i){return new Ja(e,n,new GL(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Zd}get widget(){return this.type instanceof dM}}const Kp=[],If={};class Wr{constructor(e,n){this.local=e.length?e:Kp,this.children=n.length?n:Kp}static create(e,n){return n.length?hM(n,e,0,If):Fa}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==Fa||e.maps.length==0?this:this.mapInner(e,n,0,0,r||If)}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?KVe(this.children,o||[],e,n,r,i,a):o?new Wr(o.sort(Ff),Kp):Fa}add(e,n){return n.length?this==Fa?Wr.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=Jne(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,hM(d,l,u+1,If)),a+=3}});let o=Qne(a?ere(n):n,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new Wr(o.length?this.local.concat(o).sort(Ff):this.local,i||this.children)}remove(e){return e.length==0||this==Fa?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!=Fa?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 Wr(i,r):Fa}forChild(e,n){if(this==Fa)return this;if(n.isLeaf)return Wr.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 Zd){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 Wr(i.sort(Ff),Kp);return r?new Cd([l,r]):l}return r||Fa}eq(e){if(this==e)return!0;if(!(e instanceof Wr)||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 WL(this.localsInner(e))}localsInner(e){if(this==Fa)return Kp;if(e.inlineContent||!this.local.some(Zd.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Zd||n.push(this.local[r]);return n}forEachSet(e){e(this)}}Wr.empty=new Wr([],[]);Wr.removeOverlap=WL;const Fa=Wr.empty;class Cd{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,If));return Cd.from(r)}forChild(e,n){if(n.isLeaf)return Wr.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(e,n);a!=Fa&&(a instanceof Cd?r=r.concat(a.members):r.push(a))}return Cd.from(r)}eq(e){if(!(e instanceof Cd)||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?WL(r?n:n.sort(Ff)):Kp}static from(e){switch(e.length){case 0:return Fa;case 1:return e[0];default:return new Cd(e.every(n=>n instanceof Wr)?e:e.reduce((n,r)=>n.concat(r instanceof Wr?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function KVe(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!=Fa?(l[u]=f,l[u+1]=p,l[u+2]=v):(l[u+1]=-2,c=!0)}else c=!0}if(c){let u=XVe(l,t,e,n,i,a,o),d=hM(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 Wr(e.sort(Ff),l)}function Qne(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let i=t[r];n.push(new Ja(i.from+e,i.to+e,i.type))}return n}function XVe(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 Jne(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 ere(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function hM(t,e,n,r){let i=[],a=!1;e.forEach((l,c)=>{let u=Jne(t,l,c+n);if(u){a=!0;let d=hM(u,l,n+c+1,r);d!=Fa&&i.push(c,c+l.nodeSize,d)}});let o=Qne(a?ere(t):t,-n).sort(Ff);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 Wr(o,i):Fa}function Ff(t,e){return t.from-e.from||t.to-e.to}function WL(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),fW(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),fW(e,i,r.copy(a.from,r.to)));break}}}return e}function fW(t,e,n){for(;e<t.length&&Ff(n,t[e])>0;)e++;t.splice(e,0,n)}function Aj(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=Fa&&e.push(r)}),t.cursorWrapper&&e.push(Wr.create(t.state.doc,[t.cursorWrapper.deco])),Cd.from(e)}const YVe={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},ZVe=As&&Xd<=11;class QVe{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 JVe{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new QVe,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;i<r.length;i++)this.queue.push(r[i]);As&&Xd<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():ka&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),ZVe&&(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,YVe)),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(aW(this.view)){if(this.suppressingSelectionUpdates)return fu(this.view);if(As&&Xd<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&um(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=$g(a))n.add(a);for(let a=e.anchorNode;a;a=$g(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)&&aW(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(Po&&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||nGe(e,f)!=p)&&m.remove()}}}else if((ra||ka)&&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&&NE(r)&&(u=UL(e))&&u.eq(En.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,fu(e),this.currentSelection.set(r),e.scrollToSelection()):(a>-1||i)&&(a>-1&&(e.docView.markDirty(a,o),eGe(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,rGe(e,c)),this.handleDOMChange(a,o,l,c),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||fu(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let f=e.addedNodes[d];n.push(f),f.nodeType==3&&(this.lastChangedTextNode=f)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,a=e.nextSibling;if(As&&Xd<=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?Ma(i)+1:0,l=r.localPosFromDOM(e.target,o,-1),c=a&&a.parentNode==e.target?Ma(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 mW=new WeakMap,pW=!1;function eGe(t){if(!mW.has(t)&&(mW.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=Po,pW)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."),pW=!0}}function gW(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,a=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return um(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function tGe(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return gW(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?gW(t,n):null}function nGe(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 rGe(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 iGe(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}],NE(c)||u.push({node:c.focusNode,offset:c.focusOffset})),ra&&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")||f0.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:aGe,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 aGe(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(ka&&/^(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||ka&&/^(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 sGe=/^(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 oGe(t,e,n,r,i){let a=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let E=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,O=UL(t,E);if(O&&!t.state.selection.eq(O)){if(ra&&iu&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",D=>D(t,df(13,"Enter"))))return;let C=t.state.tr.setSelection(O);E=="pointer"?C.setMeta("pointer",!0):E=="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=iGe(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=uGe(f.content,u.doc.content,u.from,m,p);if(b&&t.input.domChangeCount++,(Hg&&t.input.lastIOSEnter>Date.now()-225||iu)&&i.some(E=>E.nodeType==1&&!sGe.test(E.nodeName))&&(!b||b.endA>=b.endB)&&t.someProp("handleKeyDown",E=>E(t,df(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 E=xW(t,t.state.doc,u.sel);if(E&&!E.eq(t.state.selection)){let O=t.state.tr.setSelection(E);a&&O.setMeta("composition",a),t.dispatch(O)}}return}t.state.selection.from<t.state.selection.to&&b.start==b.endB&&t.state.selection instanceof 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)),As&&Xd<=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((Hg&&t.input.lastIOSEnter>Date.now()-225&&(!S||i.some(E=>E.nodeName=="DIV"||E.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",E=>E(t,df(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>b.start&&cGe(d,b.start,b.endA,y,x)&&t.someProp("handleKeyDown",E=>E(t,df(8,"Backspace")))){iu&&ra&&t.domObserver.suppressSelectionUpdates();return}ra&&b.endB==b.start&&(t.input.lastChromeDelete=Date.now()),iu&&!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(E){return E(t,df(13,"Enter"))})},20));let M=b.start,A=b.endA,T=E=>{let O=E||t.state.tr.replace(M,A,u.doc.slice(b.start-u.from,b.endB-u.from));if(u.sel){let C=xW(t,O.doc,u.sel);C&&!(ra&&t.composing&&C.empty&&(b.start!=b.endB||t.input.lastChromeDelete<Date.now()-100)&&(C.head==M||C.head==O.mapping.map(A)-1)||As&&C.empty&&C.head==M)&&O.setSelection(C)}return a&&O.setMeta("composition",a),O.scrollIntoView()},k;if(S)if(y.pos==x.pos){As&&Xd<=11&&y.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>fu(t),20));let E=T(t.state.tr.delete(M,A)),O=d.resolve(b.start).marksAcross(d.resolve(b.endA));O&&E.ensureMarks(O),t.dispatch(E)}else if(b.endA==b.endB&&(k=lGe(y.parent.content.cut(y.parentOffset,x.parentOffset),v.parent.content.cut(v.parentOffset,b.endA-v.start())))){let E=T(t.state.tr);k.type=="add"?E.addMark(M,A,k.mark):E.removeMark(M,A,k.mark),t.dispatch(E)}else if(y.parent.child(y.index()).isText&&y.index()==x.index()-(x.textOffset?0:1)){let E=y.parent.textBetween(y.parentOffset,x.parentOffset),O=()=>T(t.state.tr.insertText(E,M,A));t.someProp("handleTextInput",C=>C(t,M,A,E,O))||t.dispatch(O())}else t.dispatch(T());else t.dispatch(T())}function xW(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:zL(t,e.resolve(n.anchor),e.resolve(n.head))}function lGe(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(Et.from(u).eq(t))return{mark:l,type:o}}function cGe(t,e,n,r,i){if(n-e<=i.pos-r.pos||Tj(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(Tj(a,!0,!0));return!o.parent.isTextblock||o.pos>n||Tj(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Tj(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 uGe(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&&bW(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&&bW(t.textBetween(a-1,a+1))&&(a+=c?1:-1),o=a+(o-l),l=a}return{start:a,endA:o,endB:l}}function bW(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 tre{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 EVe,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(SW),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=_W(this),vW(this),this.nodeViews=wW(this),this.docView=J9(this.state.doc,yW(this),Aj(this),this.dom,this),this.domObserver=new JVe(this,(r,i,a,o)=>oGe(this,r,i,a,o)),this.domObserver.start(),AVe(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&&eD(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(SW),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&&(Kne(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=wW(this);hGe(p,this.nodeViews)&&(this.nodeViews=p,a=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&eD(this),this.editable=_W(this),vW(this);let c=Aj(this),u=yW(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&&BHe(this);if(o){this.domObserver.stop();let p=f&&(As||ra)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&dGe(i.selection,e.selection);if(f){let b=ra?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=BVe(this)),(a||!this.docView.update(e.doc,u,c,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=J9(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())&&dVe(this))?fu(this,p):(Lne(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&&$He(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&&q9(this,n.getBoundingClientRect(),e)}else q9(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 Yne(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(As){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&HHe(this.dom),fu(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 KHe(this,e)}coordsAtPos(e,n=1){return Tne(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 JHe(this,n||this.state,e)}pasteHTML(e,n){return hy(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return hy(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return BL(this,e)}destroy(){this.docView&&(TVe(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Aj(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,jHe())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return kVe(this,e)}domSelectionRange(){let e=this.domSelection();return e?ka&&this.root.nodeType===11&&LHe(this.dom.ownerDocument)==this.dom&&tGe(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}tre.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function yW(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"),[Ja.node(0,t.state.doc.content.size,e)]}function vW(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:Ja.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function _W(t){return!t.someProp("editable",e=>e(t.state)===!1)}function dGe(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 wW(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 hGe(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 SW(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 uh={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:"'"},fM={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},fGe=typeof navigator<"u"&&/Mac/.test(navigator.platform),mGe=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Na=0;Na<10;Na++)uh[48+Na]=uh[96+Na]=String(Na);for(var Na=1;Na<=24;Na++)uh[Na+111]="F"+Na;for(var Na=65;Na<=90;Na++)uh[Na]=String.fromCharCode(Na+32),fM[Na]=String.fromCharCode(Na);for(var Cj in uh)fM.hasOwnProperty(Cj)||(fM[Cj]=uh[Cj]);function pGe(t){var e=fGe&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||mGe&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?fM:uh)[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 gGe=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),xGe=typeof navigator<"u"&&/Win/.test(navigator.platform);function bGe(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))gGe?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 yGe(t){let e=Object.create(null);for(let n in t)e[bGe(n)]=t[n];return e}function kj(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 vGe(t){return new Zr({props:{handleKeyDown:nre(t)}})}function nre(t){let e=yGe(t);return function(n,r){let i=pGe(r),a,o=e[kj(i,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[kj(i,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(xGe&&r.ctrlKey&&r.altKey)&&(a=uh[r.keyCode])&&a!=i){let l=e[kj(a,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var _Ge=Object.defineProperty,qL=(t,e)=>{for(var n in e)_Ge(t,n,{get:e[n],enumerable:!0})};function TE(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 CE=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:TE({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}},rre={};qL(rre,{blur:()=>wGe,clearContent:()=>SGe,clearNodes:()=>MGe,command:()=>NGe,createParagraphNear:()=>EGe,cut:()=>AGe,deleteCurrentNode:()=>TGe,deleteNode:()=>CGe,deleteRange:()=>kGe,deleteSelection:()=>jGe,enter:()=>PGe,exitCode:()=>RGe,extendMarkRange:()=>DGe,first:()=>OGe,focus:()=>IGe,forEach:()=>FGe,insertContent:()=>UGe,insertContentAt:()=>$Ge,joinBackward:()=>GGe,joinDown:()=>VGe,joinForward:()=>WGe,joinItemBackward:()=>qGe,joinItemForward:()=>KGe,joinTextblockBackward:()=>XGe,joinTextblockForward:()=>YGe,joinUp:()=>HGe,keyboardShortcut:()=>QGe,lift:()=>JGe,liftEmptyBlock:()=>e7e,liftListItem:()=>t7e,newlineInCode:()=>n7e,resetAttributes:()=>r7e,scrollIntoView:()=>i7e,selectAll:()=>a7e,selectNodeBackward:()=>s7e,selectNodeForward:()=>o7e,selectParentNode:()=>l7e,selectTextblockEnd:()=>c7e,selectTextblockStart:()=>u7e,setContent:()=>d7e,setMark:()=>j7e,setMeta:()=>P7e,setNode:()=>R7e,setNodeSelection:()=>D7e,setTextDirection:()=>O7e,setTextSelection:()=>L7e,sinkListItem:()=>I7e,splitBlock:()=>F7e,splitListItem:()=>U7e,toggleList:()=>z7e,toggleMark:()=>B7e,toggleNode:()=>$7e,toggleWrap:()=>H7e,undoInputRule:()=>V7e,unsetAllMarks:()=>G7e,unsetMark:()=>W7e,unsetTextDirection:()=>q7e,updateAttributes:()=>K7e,wrapIn:()=>X7e,wrapInList:()=>Y7e});var wGe=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),SGe=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),MGe=()=>({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=gx(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},NGe=t=>e=>t(e),EGe=()=>({state:t,dispatch:e})=>xne(t,e),AGe=(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},TGe=()=>({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 ki(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 CGe=t=>({tr:e,state:n,dispatch:r})=>{const i=ki(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},kGe=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},jGe=()=>({state:t,dispatch:e})=>RL(t,e),PGe=()=>({commands:t})=>t.keyboardShortcut("Enter"),RGe=()=>({state:t,dispatch:e})=>gHe(t,e);function KL(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function mM(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:KL(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function ire(t,e,n={}){return t.find(r=>r.type===e&&mM(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function MW(t,e,n={}){return!!ire(t,e,n)}function XL(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),!ire([...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&&MW([...t.parent.child(o-1).marks],e,n);)o-=1,l-=t.parent.child(o).nodeSize;for(;c<t.parent.childCount&&MW([...t.parent.child(c).marks],e,n);)u+=t.parent.child(c).nodeSize,c+=1;return{from:l,to:u}}function Pu(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 DGe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const a=Pu(t,r.schema),{doc:o,selection:l}=n,{$from:c,from:u,to:d}=l;if(i){const f=XL(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},OGe=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 are(t){return t instanceof fn}function Mf(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function sre(t,e=null){if(!e)return null;const n=En.atStart(t),r=En.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,a=r.to;return e==="all"?fn.create(t,Mf(0,i,a),Mf(t.content.size,i,a)):fn.create(t,Mf(e,i,a),Mf(e,i,a))}function NW(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function pM(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function LGe(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var IGe=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:a})=>{e={scrollIntoView:!0,...e};const o=()=>{(pM()||NW())&&r.dom.focus(),LGe()&&!pM()&&!NW()&&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&&!are(n.state.selection))return o(),!0;const l=sre(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},FGe=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),UGe=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),ore=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&&ore(r)}return t};function zw(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 ore(n)}function my(t,e,n){if(t instanceof Kd||t instanceof Et)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 Et.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),my("",e,n)}if(i){if(n.errorOnInvalidContent){let o=!1,l="";const c=new Vte({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?f0.fromSchema(c).parseSlice(zw(t),n.parseOptions):f0.fromSchema(c).parse(zw(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const a=f0.fromSchema(e);return n.slice?a.parseSlice(zw(t),n.parseOptions).content:a.parse(zw(t),n.parseOptions)}return my("",e,n)}function zGe(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof ea||i instanceof aa))return;const a=t.mapping.maps[r];let o=0;a.forEach((l,c,u,d)=>{o===0&&(o=d)}),t.setSelection(En.near(t.doc.resolve(o),n))}var BGe=t=>!("type"in t),$Ge=(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{my(e,a.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(x){c(x)}try{l=my(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((BGe(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 Et){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,A=v.content.size>0;S&&M&&A&&(d=Math.max(0,d-1)),r.replaceWith(d,f,y)}n.updateSelection&&zGe(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},HGe=()=>({state:t,dispatch:e})=>fHe(t,e),VGe=()=>({state:t,dispatch:e})=>mHe(t,e),GGe=()=>({state:t,dispatch:e})=>une(t,e),WGe=()=>({state:t,dispatch:e})=>mne(t,e),qGe=()=>({state:t,dispatch:e,tr:n})=>{try{const r=wE(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},KGe=()=>({state:t,dispatch:e,tr:n})=>{try{const r=wE(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},XGe=()=>({state:t,dispatch:e})=>dHe(t,e),YGe=()=>({state:t,dispatch:e})=>hHe(t,e);function lre(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function ZGe(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))pM()||lre()?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 QGe=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const a=ZGe(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 dh(t,e,n={}){const{from:r,to:i,empty:a}=t.selection,o=e?ki(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=>mM(f.node.attrs,n,{strict:!1}));return a?!!u.length:u.reduce((f,m)=>f+m.to-m.from,0)>=c}var JGe=(t,e={})=>({state:n,dispatch:r})=>{const i=ki(t,n.schema);return dh(n,i,e)?pHe(n,r):!1},e7e=()=>({state:t,dispatch:e})=>bne(t,e),t7e=t=>({state:e,dispatch:n})=>{const r=ki(t,e.schema);return AHe(r)(e,n)},n7e=()=>({state:t,dispatch:e})=>gne(t,e);function kE(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function EW(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 r7e=(t,e)=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null;const l=kE(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(a=ki(t,r.schema)),l==="mark"&&(o=Pu(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,EW(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(EW(m.attrs,e))))})})}),c},i7e=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),a7e=()=>({tr:t,dispatch:e})=>{if(e){const n=new Qs(t.doc);t.setSelection(n)}return!0},s7e=()=>({state:t,dispatch:e})=>hne(t,e),o7e=()=>({state:t,dispatch:e})=>pne(t,e),l7e=()=>({state:t,dispatch:e})=>yHe(t,e),c7e=()=>({state:t,dispatch:e})=>wHe(t,e),u7e=()=>({state:t,dispatch:e})=>_He(t,e);function tD(t,e,n={},r={}){return my(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var d7e=(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=tD(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 cre(t,e){const n=Pu(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 ure(t,e){const n=new sne(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function h7e(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 f7e(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,a)=>{n(i)&&r.push({node:i,pos:a})}),r}function m7e(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 jE(t){return e=>m7e(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 YL(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=en(e,"addExtensions",n);return r?[e,...YL(r())]:e}).flat(10)}function ZL(t,e){const n=ym.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function dre(t){return typeof t=="function"}function sr(t,e=void 0,...n){return dre(t)?e?t.bind(e)(...n):t(...n):t}function p7e(t={}){return Object.keys(t).length===0&&t.constructor===Object}function Vg(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 hre(t){const e=[],{nodeExtensions:n,markExtensions:r}=Vg(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 ci(...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 py(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)=>ci(n,r),{})}function g7e(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function AW(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):g7e(n.getAttribute(o.name));return l==null?a:{...a,[o.name]:l}},{});return{...r,...i}}}}function TW(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&p7e(n)?!1:n!=null))}function CW(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 x7e(t,e){var n;const r=hre(t),{nodeExtensions:i,markExtensions:a}=Vg(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=TW({...m,content:sr(en(u,"content",f)),marks:sr(en(u,"marks",f)),group:sr(en(u,"group",f)),inline:sr(en(u,"inline",f)),atom:sr(en(u,"atom",f)),selectable:sr(en(u,"selectable",f)),draggable:sr(en(u,"draggable",f)),code:sr(en(u,"code",f)),whitespace:sr(en(u,"whitespace",f)),linebreakReplacement:sr(en(u,"linebreakReplacement",f)),defining:sr(en(u,"defining",f)),isolating:sr(en(u,"isolating",f)),attrs:Object.fromEntries(d.map(CW))}),b=sr(en(u,"parseHTML",f));b&&(p.parseDOM=b.map(v=>AW(v,d)));const y=en(u,"renderHTML",f);y&&(p.toDOM=v=>y({node:v,HTMLAttributes:py(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=TW({...m,inclusive:sr(en(u,"inclusive",f)),excludes:sr(en(u,"excludes",f)),group:sr(en(u,"group",f)),spanning:sr(en(u,"spanning",f)),code:sr(en(u,"code",f)),attrs:Object.fromEntries(d.map(CW))}),b=sr(en(u,"parseHTML",f));b&&(p.parseDOM=b.map(x=>AW(x,d)));const y=en(u,"renderHTML",f);return y&&(p.toDOM=x=>y({mark:x,HTMLAttributes:py(x,d)})),[u.name,p]}));return new Vte({topNode:o,nodes:l,marks:c})}function b7e(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function gM(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 fre(t){const e=gM(YL(t)),n=b7e(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 mre(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 y7e(t,e){const n={from:0,to:t.content.size};return mre(t,n,e)}function pre(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function v7e(t,e){const n=ki(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 gre(t,e){const n=kE(typeof e=="string"?e:e.name,t.schema);return n==="node"?v7e(t,e):n==="mark"?cre(t,e):{}}function _7e(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 w7e(t){const e=_7e(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 xre(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}})})}),w7e(r)}function QL(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const a=n.resolve(t),o=XL(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 S7e=(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 Bw(t,e){return e.nodes[t]||e.marks[t]||null}function N1(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 M7e=(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 nD(t,e,n={}){const{empty:r,ranges:i}=t.selection,a=e?Pu(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(f=>a?a.name===f.type.name:!0).find(f=>mM(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(A=>({mark:A,from:v,to:S})))})}),o===0)return!1;const c=l.filter(f=>a?a.name===f.mark.type.name:!0).filter(f=>mM(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 N7e(t,e,n={}){if(!e)return dh(t,null,n)||nD(t,null,n);const r=kE(e,t.schema);return r==="node"?dh(t,e,n):r==="mark"?nD(t,e,n):!1}var E7e=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const a=jE(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)},A7e=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function kW(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function jW(t,e){const{nodeExtensions:n}=Vg(e),r=n.find(o=>o.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},a=sr(en(r,"group",i));return typeof a!="string"?!1:a.split(" ").includes("list")}function PE(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&&(PE(a,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function bre(t){return t instanceof nn}var yre=class vre{constructor(e){this.position=e}static fromJSON(e){return new vre(e.position)}toJSON(){return{position:this.position}}};function T7e(t,e){const n=e.mapping.mapResult(t.position);return{position:new yre(n.pos),mapResult:n}}function C7e(t){return new yre(t)}function k7e(t,e,n){var r;const{selection:i}=e;let a=null;if(are(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 j7e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:a}=n,{empty:o,ranges:l}=a,c=Pu(t,r.schema);if(i)if(o){const u=cre(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 k7e(r,n,c)},P7e=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),R7e=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const a=ki(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})=>V9(a,{...o,...e})(n)?!0:l.clearNodes()).command(({state:l})=>V9(a,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},D7e=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=Mf(t,0,r.content.size),a=nn.create(r,i);e.setSelection(a)}return!0},O7e=(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},L7e=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=Mf(i,o,l),u=Mf(a,o,l),d=fn.create(r,c,u);e.setSelection(d)}return!0},I7e=t=>({state:e,dispatch:n})=>{const r=ki(t,e.schema);return kHe(r)(e,n)};function PW(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 F7e=({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=N1(u,l.node().type.name,l.node().attrs);if(a instanceof nn&&a.node.isBlock)return!l.parentOffset||!hu(o,l.pos)?!1:(r&&(t&&PW(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:h7e(l.node(-1).contentMatchAt(l.indexAfter(-1)));let p=f&&m?[{type:m,attrs:d}]:void 0,b=hu(e.doc,e.mapping.map(l.pos),1,p);if(!p&&!b&&hu(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&&PW(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return b},U7e=(t,e={})=>({tr:n,state:r,dispatch:i,editor:a})=>{var o;const l=ki(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=Et.empty;const S=c.index(-1)?1:c.index(-2)?2:3;for(let O=c.depth-S;O>=c.depth-3;O-=1)v=Et.from(c.node(O).copy(v));const M=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,A={...N1(m,c.node().type.name,c.node().attrs),...e},T=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(A))||void 0;v=v.append(Et.from(l.createAndFill(null,T)||void 0));const k=c.before(c.depth-(S-1));n.replace(k,c.after(-M),new Ht(v,4-S,0));let E=-1;n.doc.nodesBetween(k,n.doc.content.size,(O,C)=>{if(E>-1)return!1;O.isTextblock&&O.content.size===0&&(E=C+1)}),E>-1&&n.setSelection(fn.near(n.doc.resolve(E))),n.scrollIntoView()}return!0}const p=u.pos===c.end()?f.contentMatchAt(0).defaultType:null,b={...N1(m,f.type.name,f.attrs),...e},y={...N1(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(!hu(n.doc,c.pos,2))return!1;if(i){const{selection:v,storedMarks:S}=r,{splittableMarks:M}=a.extensionManager,A=S||v.$to.parentOffset&&v.$from.marks();if(n.split(c.pos,2,x).scrollIntoView(),!A||!i)return!0;const T=A.filter(k=>M.includes(k.type.name));n.ensureMarks(T)}return!0},jj=(t,e)=>{const n=jE(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&&vh(t.doc,n.pos)&&t.join(n.pos),!0},Pj=(t,e)=>{const n=jE(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&&vh(t.doc,r)&&t.join(r),!0},z7e=(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=ki(t,o.schema),b=ki(e,o.schema),{selection:y,storedMarks:x}=o,{$from:v,$to:S}=y,M=v.blockRange(S),A=x||y.$to.parentOffset&&y.$from.marks();if(!M)return!1;const T=jE(k=>jW(k.type.name,f))(y);if(M.depth>=1&&T&&M.depth-T.depth<=1){if(T.node.type===p)return u.liftListItem(b);if(jW(T.node.type.name,f)&&p.validContent(T.node.content)&&l)return c().command(()=>(a.setNodeMarkup(T.pos,p),!0)).command(()=>jj(a,p)).command(()=>Pj(a,p)).run()}return!n||!A||!l?c().command(()=>d().wrapInList(p,r)?!0:u.clearNodes()).wrapInList(p,r).command(()=>jj(a,p)).command(()=>Pj(a,p)).run():c().command(()=>{const k=d().wrapInList(p,r),E=A.filter(O=>m.includes(O.type.name));return a.ensureMarks(E),k?!0:u.clearNodes()}).wrapInList(p,r).command(()=>jj(a,p)).command(()=>Pj(a,p)).run()},B7e=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:a=!1}=n,o=Pu(t,r.schema);return nD(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:a}):i.setMark(o,e)},$7e=(t,e,n={})=>({state:r,commands:i})=>{const a=ki(t,r.schema),o=ki(e,r.schema),l=dh(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})},H7e=(t,e={})=>({state:n,commands:r})=>{const i=ki(t,n.schema);return dh(n,i,e)?r.lift(i):r.wrapIn(i,e)},V7e=()=>({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},G7e=()=>({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},W7e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var a;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=n,c=Pu(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=XL(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},q7e=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},K7e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null;const l=kE(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(a=ki(t,r.schema)),l==="mark"&&(o=Pu(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),A=Math.min(v+x.nodeSize,f);n.addMark(M,A,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},X7e=(t,e={})=>({state:n,dispatch:r})=>{const i=ki(t,n.schema);return SHe(i,e)(n,r)},Y7e=(t,e={})=>({state:n,dispatch:r})=>{const i=ki(t,n.schema);return MHe(i,e)(n,r)},Z7e=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={}}},RE=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},Q7e=(t,e)=>{if(KL(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 $w(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=M7e(u)+a;return o.forEach(m=>{if(d)return;const p=Q7e(f,m.find);if(!p)return;const b=c.state.tr,y=TE({state:c.state,transaction:b}),x={from:r-(p[0].length-a.length),to:i},{commands:v,chain:S,can:M}=new CE({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 J7e(t){const{editor:e,rules:n}=t,r=new Zr({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=ZL(Et.from(d),o.schema);const{from:f}=c,m=f+d.length;$w({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 $w({editor:e,from:a,to:o,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:a}=i.state.selection;a&&$w({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?$w({editor:e,from:o.pos,to:o.pos,text:`
- `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function e9e(t){return Object.prototype.toString.call(t).slice(8,-1)}function Hw(t){return e9e(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function _re(t,e){const n={...t};return Hw(t)&&Hw(e)&&Object.keys(e).forEach(r=>{Hw(e[r])&&Hw(t[r])?n[r]=_re(t[r],e[r]):n[r]=e[r]}),n}var JL=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{...sr(en(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...sr(en(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>_re(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}},wh=class wre extends JL{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new wre(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 t9e(t){return typeof t=="number"}var n9e=class{constructor(t){this.find=t.find,this.handler=t.handler}},r9e=(t,e,n)=>{if(KL(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 i9e(t){const{editor:e,state:n,from:r,to:i,rule:a,pasteEvent:o,dropEvent:l}=t,{commands:c,chain:u,can:d}=new CE({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 A=(M=(S=(v=p.content)==null?void 0:v.size)!=null?S:p.nodeSize)!=null?M:0,T=Math.max(r,b),k=Math.min(i,b+A);if(T>=k)return;const E=p.isText?p.text||"":p.textBetween(T-b,k-b,void 0,"");r9e(E,a.find,o).forEach(C=>{if(C.index===void 0)return;const D=T+C.index+1,U=D+C[0].length,L={from:n.tr.mapping.map(D),to:n.tr.mapping.map(U)},q=a.handler({state:n,range:L,match:C,commands:c,chain:u,can:d,pasteEvent:o,dropEvent:l});f.push(q)})}),f.every(p=>p!==null)}var Vw=null,a9e=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function s9e(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=TE({state:d,transaction:y});if(!(!i9e({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 Zr({view(f){const m=b=>{var y;r=(y=f.dom.parentElement)!=null&&y.contains(b.target)?f.dom.parentElement:null,r&&(Vw=e)},p=()=>{Vw&&(Vw=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=Vw;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:T}=v;typeof T=="string"?T=T:T=ZL(Et.from(T),p.schema);const{from:k}=v,E=k+T.length,O=a9e(T);return c({rule:d,state:p,from:k,to:{b:E},pasteEvt:O})}const M=m.doc.content.findDiffStart(p.doc.content),A=m.doc.content.findDiffEnd(p.doc.content);if(!(!t9e(M)||!A||M===A.b))return c({rule:d,state:p,from:M,to:A,pasteEvt:o})}}))}var DE=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=fre(t),this.schema=x7e(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:Bw(e.name,this.schema)},r=en(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return gM([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:Bw(r.name,this.schema)},a=[],o=en(r,"addKeyboardShortcuts",i);let l={};if(r.type==="mark"&&en(r,"exitable",i)&&(l.ArrowRight=()=>wh.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=vGe(l);a.push(c);const u=en(r,"addInputRules",i);if(kW(r,t.options.enableInputRules)&&u){const m=u();if(m&&m.length){const p=J7e({editor:t,rules:m}),b=Array.isArray(p)?p:[p];a.push(...b)}}const d=en(r,"addPasteRules",i);if(kW(r,t.options.enablePasteRules)&&d){const m=d();if(m&&m.length){const p=s9e({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 hre(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=Vg(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:ki(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=py(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 gM([...this.extensions].reverse()).reduceRight((r,i)=>{const a={name:i.name,options:i.options,storage:this.editor.extensionStorage[i.name],editor:e,type:Bw(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}=Vg(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:Pu(n.name,this.schema)},a=en(n,"addMarkView",i);if(!a)return[];const o=(l,c,u)=>{const d=py(l,r);return a()({mark:l,view:c,inline:u,editor:t,extension:n,HTMLAttributes:d,updateAttributes:f=>{_9e(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:Bw(e.name,this.schema)};e.type==="mark"&&((n=sr(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)})}};DE.resolve=fre;DE.sort=gM;DE.flatten=YL;var o9e={};qL(o9e,{ClipboardTextSerializer:()=>Mre,Commands:()=>Nre,Delete:()=>Ere,Drop:()=>Are,Editable:()=>Tre,FocusEvents:()=>kre,Keymap:()=>jre,Paste:()=>Pre,Tabindex:()=>Rre,TextDirection:()=>Dre,focusEventsPluginKey:()=>Cre});var br=class Sre extends JL{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new Sre(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},Mre=br.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Zr({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=pre(n);return mre(r,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),Nre=br.create({name:"commands",addCommands(){return{...rre}}}),Ere=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=ure(t.before,[t,...e]);xre(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 sl){const v=m.slice(b).map(p.from,-1),S=m.slice(b).map(p.to),M=m.invert().map(v,-1),A=m.invert().map(S),T=(y=d.doc.nodeAt(v-1))==null?void 0:y.marks.some(E=>E.eq(p.mark)),k=(x=d.doc.nodeAt(S))==null?void 0:x.marks.some(E=>E.eq(p.mark));this.editor.emit("delete",{type:"mark",mark:p.mark,from:p.from,to:p.to,deletedRange:{from:M,to:A},newRange:{from:v,to:S},partial:!!(k||T),editor:this.editor,transaction:t,combinedTransform:d})}})};(i=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||i?setTimeout(a,0):a()}}),Are=br.create({name:"drop",addProseMirrorPlugins(){return[new Zr({key:new Vi("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),Tre=br.create({name:"editable",addProseMirrorPlugins(){return[new Zr({key:new Vi("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Cre=new Vi("focusEvents"),kre=br.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Zr({key:Cre,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}}}})]}}),jre=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:En.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 pM()||lre()?a:i},addProseMirrorPlugins(){return[new Zr({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=En.atStart(e.doc).from,u=En.atEnd(e.doc).to;if(a||!(o===c&&l===u)||!PE(n.doc))return;const m=n.tr,p=TE({state:n,transaction:m}),{commands:b}=new CE({editor:this.editor,state:p});if(b.clearNodes(),!!m.steps.length)return m}})]}}),Pre=br.create({name:"paste",addProseMirrorPlugins(){return[new Zr({key:new Vi("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),Rre=br.create({name:"tabindex",addProseMirrorPlugins(){return[new Zr({key:new Vi("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),Dre=br.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=Vg(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 Zr({key:new Vi("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),l9e=class Jb{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 Jb(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 Jb(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 Jb(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 Jb(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)}},c9e=`.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 u9e(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 d9e=class extends Z7e{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:T7e,createMappablePosition:C7e},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=sre(e,this.options.autofocus);this.editorState=ng.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=u9e(c9e,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=dre(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?[Tre,Mre.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),Nre,kre,jre,Rre,Are,Pre,Ere,Dre.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 DE(r,this)}createCommandManager(){this.commandManager=new CE({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=tD(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=tD(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 tre(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 gre(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return N7e(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return ZL(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
- `,textSerializers:n={}}=t||{};return y7e(this.state.doc,{blockSeparator:e,textSerializers:{...pre(this.schema),...n}})}get isEmpty(){return PE(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 l9e(e,this)}get $doc(){return this.$pos(0)}};function Gg(t){return new RE({find:t.find,handler:({state:e,range:n,match:r})=>{const i=sr(t.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:a}=e,o=r[r.length-1],l=r[0];if(o){const c=l.search(/\S/),u=n.from+l.indexOf(o),d=u+o.length;if(QL(n.from,n.to,e.doc).filter(p=>p.mark.type.excluded.find(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 Ore(t){return new RE({find:t.find,handler:({state:e,range:n,match:r})=>{const i=sr(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 rD(t){return new RE({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),a=sr(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 Wg(t){return new RE({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const a=sr(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),c=o.doc.resolve(n.from).blockRange(),u=c&&jL(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&&vh(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,d))&&o.join(n.from-1)},undoable:t.undoable})}var h9e=t=>"touches"in t,f9e=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,h9e(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 m9e(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 p9e={};qL(p9e,{createAtomBlockMarkdownSpec:()=>g9e,createBlockMarkdownSpec:()=>x9e,createInlineMarkdownSpec:()=>v9e,parseAttributes:()=>eI,parseIndentedBlocks:()=>iD,renderNestedMarkdownContent:()=>nI,serializeAttributes:()=>tI});function eI(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 tI(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 g9e(t){const{nodeName:e,name:n,parseAttributes:r=eI,serializeAttributes:i=tI,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 x9e(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=eI,serializeAttributes:a=tI,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 A=1;const T=v.length;let k="";const E=/^:::([\w-]*)(\s.*)?/gm,O=f.slice(T);for(E.lastIndex=0;;){const C=E.exec(O);if(C===null)break;const D=C.index,U=C[1];if(!((b=C[2])!=null&&b.endsWith(":::"))){if(U)A+=1;else if(A-=1,A===0){const L=O.slice(0,D);k=L.trim();const q=f.slice(0,T+D+C[0].length);let P=[];if(k)if(l==="block")for(P=p.blockTokens(L),P.forEach(W=>{W.text&&(!W.tokens||W.tokens.length===0)&&(W.tokens=p.inlineTokens(W.text))});P.length>0;){const W=P[P.length-1];if(W.type==="paragraph"&&(!W.text||W.text.trim()===""))P.pop();else break}else P=p.inlineTokens(k);return{type:e,raw:q,attributes:M,content:k,tokens:P}}}}}},renderMarkdown:(f,m)=>{const p=d(f.attrs||{}),b=a(p),y=b?` {${b}}`:"",x=m.renderChildren(f.content||[],`
- `);return`:::${u}${y}
- ${x}
- :::`}}}function b9e(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 y9e(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function v9e(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=b9e,serializeAttributes:a=y9e,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[,A]=x;S=A}else{const[,A,T]=x;S=A,v=T||""}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 iD(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 T=l[d];if(T.trim()===""){const E=l.slice(d+1).findIndex(D=>D.trim()!=="");if(E===-1)break;if((((i=(r=l[d+1+E].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:i.length)||0)>y){v.push(T),u=`${u}${T}
- `,d+=1;continue}else break}if((((o=(a=T.match(/^(\s*)/))==null?void 0:a[1])==null?void 0:o.length)||0)>y)v.push(T),u=`${u}${T}
- `,d+=1;else break}let S;const M=v.slice(1);if(M.length>0){const T=M.map(k=>k.slice(y+f)).join(`
- `);T.trim()&&(e.customNestedParser?S=e.customNestedParser(T):S=n.blockTokens(T))}const A=e.createToken(b,S);c.push(A)}if(c.length!==0)return{items:c,raw:u}}function nI(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 _9e(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 Cs=class Lre extends JL{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new Lre(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function hm(t){return new n9e({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const a=sr(t.getAttributes,void 0,r,i);if(a===!1||a===null)return null;const{tr:o}=e,l=r[r.length-1],c=r[0];let u=n.to;if(l){const d=c.search(/\S/),f=n.from+c.indexOf(l),m=f+l.length;if(QL(n.from,n.to,e.doc).filter(b=>b.mark.type.excluded.find(x=>x===t.type&&x!==b.mark.type)).filter(b=>b.to>f).length)return null;m<n.to&&o.delete(m,n.to),f>n.from&&o.delete(n.from+d,f),u=n.from+d+l.length,o.addMark(n.from+d,u,t.type.create(a||{})),o.removeStoredMark(t.type)}}})}const{getOwnPropertyNames:w9e,getOwnPropertySymbols:S9e}=Object,{hasOwnProperty:M9e}=Object.prototype;function Rj(t,e){return function(r,i,a){return t(r,i,a)&&e(r,i,a)}}function Gw(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 N9e(t){return t?.[Symbol.toStringTag]}function RW(t){return w9e(t).concat(S9e(t))}const E9e=Object.hasOwn||((t,e)=>M9e.call(t,e));function vm(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const A9e="__v",T9e="__o",C9e="_owner",{getOwnPropertyDescriptor:DW,keys:OW}=Object;function k9e(t,e){return t.byteLength===e.byteLength&&xM(new Uint8Array(t),new Uint8Array(e))}function j9e(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 P9e(t,e){return t.byteLength===e.byteLength&&xM(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function R9e(t,e){return vm(t.getTime(),e.getTime())}function D9e(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function O9e(t,e){return t===e}function LW(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 L9e=vm;function I9e(t,e,n){const r=OW(t);let i=r.length;if(OW(e).length!==i)return!1;for(;i-- >0;)if(!Ire(t,e,n,r[i]))return!1;return!0}function Lb(t,e,n){const r=RW(t);let i=r.length;if(RW(e).length!==i)return!1;let a,o,l;for(;i-- >0;)if(a=r[i],!Ire(t,e,n,a)||(o=DW(t,a),l=DW(e,a),(o||l)&&(!o||!l||o.configurable!==l.configurable||o.enumerable!==l.enumerable||o.writable!==l.writable)))return!1;return!0}function F9e(t,e){return vm(t.valueOf(),e.valueOf())}function U9e(t,e){return t.source===e.source&&t.flags===e.flags}function IW(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 xM(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 z9e(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 Ire(t,e,n,r){return(r===C9e||r===T9e||r===A9e)&&(t.$$typeof||e.$$typeof)?!0:E9e(e,r)&&n.equals(t[r],e[r],r,r,t,e,n)}const B9e="[object ArrayBuffer]",$9e="[object Arguments]",H9e="[object Boolean]",V9e="[object DataView]",G9e="[object Date]",W9e="[object Error]",q9e="[object Map]",K9e="[object Number]",X9e="[object Object]",Y9e="[object RegExp]",Z9e="[object Set]",Q9e="[object String]",J9e={"[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},eWe="[object URL]",tWe=Object.prototype.toString;function nWe({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 A=x.constructor;if(A!==v.constructor)return!1;if(A===Object)return c(x,v,S);if(Array.isArray(x))return e(x,v,S);if(A===Date)return r(x,v,S);if(A===RegExp)return d(x,v,S);if(A===Map)return o(x,v,S);if(A===Set)return f(x,v,S);const T=tWe.call(x);if(T===G9e)return r(x,v,S);if(T===Y9e)return d(x,v,S);if(T===q9e)return o(x,v,S);if(T===Z9e)return f(x,v,S);if(T===X9e)return typeof x.then!="function"&&typeof v.then!="function"&&c(x,v,S);if(T===eWe)return p(x,v,S);if(T===W9e)return i(x,v,S);if(T===$9e)return c(x,v,S);if(J9e[T])return m(x,v,S);if(T===B9e)return t(x,v,S);if(T===V9e)return n(x,v,S);if(T===H9e||T===K9e||T===Q9e)return u(x,v,S);if(b){let k=b[T];if(!k){const E=N9e(x);E&&(k=b[E])}if(k)return k(x,v,S)}return!1}}function rWe({circular:t,createCustomConfig:e,strict:n}){let r={areArrayBuffersEqual:k9e,areArraysEqual:n?Lb:j9e,areDataViewsEqual:P9e,areDatesEqual:R9e,areErrorsEqual:D9e,areFunctionsEqual:O9e,areMapsEqual:n?Rj(LW,Lb):LW,areNumbersEqual:L9e,areObjectsEqual:n?Lb:I9e,arePrimitiveWrappersEqual:F9e,areRegExpsEqual:U9e,areSetsEqual:n?Rj(IW,Lb):IW,areTypedArraysEqual:n?Rj(xM,Lb):xM,areUrlsEqual:z9e,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),t){const i=Gw(r.areArraysEqual),a=Gw(r.areMapsEqual),o=Gw(r.areObjectsEqual),l=Gw(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:i,areMapsEqual:a,areObjectsEqual:o,areSetsEqual:l})}return r}function iWe(t){return function(e,n,r,i,a,o,l){return t(e,n,l)}}function aWe({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 sWe=Sh();Sh({strict:!0});Sh({circular:!0});Sh({circular:!0,strict:!0});Sh({createInternalComparator:()=>vm});Sh({strict:!0,createInternalComparator:()=>vm});Sh({circular:!0,createInternalComparator:()=>vm});Sh({circular:!0,createInternalComparator:()=>vm,strict:!0});function Sh(t={}){const{circular:e=!1,createInternalComparator:n,createState:r,strict:i=!1}=t,a=rWe(t),o=nWe(a),l=n?n(o):iWe(o);return aWe({circular:e,comparator:o,createState:r,equals:l,strict:i})}var oWe=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},lWe=({contentComponent:t})=>{const e=ND.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return s.jsx(s.Fragment,{children:Object.values(e)})};function cWe(){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]:Vce.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 uWe=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=cWe(),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:oWe(e,this.editorContentRef),...n}),t?.contentComponent&&s.jsx(lWe,{contentComponent:t.contentComponent})]})}},dWe=w.forwardRef((t,e)=>{const n=Ur.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return Ur.createElement(uWe,{key:n,innerRef:e,...t})}),hWe=Ur.memo(dWe),fWe=typeof window<"u"?w.useLayoutEffect:w.useEffect,mWe=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 pWe(t){var e;const[n]=w.useState(()=>new mWe(t.editor)),r=xX.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:sWe);return fWe(()=>n.watch(t.editor),[t.editor,n]),w.useDebugValue(r),r}var gWe=!1,aD=typeof window>"u",xWe=aD||!!(typeof window<"u"&&window.next),bWe=class Fre{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?aD||xWe?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 d9e(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?Fre.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 yWe(t={},e=[]){const n=w.useRef(t);n.current=t;const[r]=w.useState(()=>new bWe(n)),i=ND.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return w.useDebugValue(i),w.useEffect(r.onRender(e)),pWe({editor:i,selector:({transactionNumber:a})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&a===0?0:a+1}),i}var vWe=w.createContext({editor:null});vWe.Consumer;var _We=w.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),wWe=()=>w.useContext(_We);Ur.forwardRef((t,e)=>{const{onDragStart:n}=wWe(),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 bM=(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]},SWe=/^\s*>\s$/,MWe=Cs.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return bM("blockquote",{...ci(this.options.HTMLAttributes,t),children:bM("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[Wg({find:SWe,type:this.type})]}}),NWe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,EWe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,AWe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,TWe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,CWe=wh.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 bM("strong",{...ci(this.options.HTMLAttributes,t),children:bM("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[Gg({find:NWe,type:this.type}),Gg({find:AWe,type:this.type})]},addPasteRules(){return[hm({find:EWe,type:this.type}),hm({find:TWe,type:this.type})]}}),kWe=/(^|[^`])`([^`]+)`(?!`)$/,jWe=/(^|[^`])`([^`]+)`(?!`)/g,PWe=wh.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",ci(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[Gg({find:kWe,type:this.type})]},addPasteRules(){return[hm({find:jWe,type:this.type})]}}),Dj=4,RWe=/^```([a-z]+)?[\s\n]$/,DWe=/^~~~([a-z]+)?[\s\n]$/,OWe=Cs.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Dj,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",ci(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:Dj,{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:Dj,{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 A=d;for(let k=0;k<b;k+=1)A+=p[k].length+1;return l.delete(A,A+M),u-A<=M&&l.setSelection(fn.create(l.doc,A)),!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(En.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[rD({find:RWe,type:this.type,getAttributes:t=>({language:t[1]})}),rD({find:DWe,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Zr({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}}})]}}),LWe=Cs.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):""}),IWe=Cs.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",ci(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()}}}),FWe=Cs.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,ci(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=>rD({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),UWe=Cs.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",ci(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!m9e(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return bre(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[Ore({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),zWe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,BWe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,$We=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,HWe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,VWe=wh.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",ci(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[Gg({find:zWe,type:this.type}),Gg({find:$We,type:this.type})]},addPasteRules(){return[hm({find:BWe,type:this.type}),hm({find:HWe,type:this.type})]}});const GWe="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",WWe="ελ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",sD="numeric",oD="ascii",lD="alpha",x0="asciinumeric",e0="alphanumeric",cD="domain",Ure="emoji",qWe="scheme",KWe="slashscheme",Oj="whitespace";function XWe(t,e){return t in e||(e[t]=[]),e[t]}function Nf(t,e,n){e[sD]&&(e[x0]=!0,e[e0]=!0),e[oD]&&(e[x0]=!0,e[lD]=!0),e[x0]&&(e[e0]=!0),e[lD]&&(e[e0]=!0),e[e0]&&(e[cD]=!0),e[Ure]&&(e[cD]=!0);for(const r in e){const i=XWe(r,n);i.indexOf(t)<0&&i.push(t)}}function YWe(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function vs(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}vs.groups={};vs.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||vs.groups;let i;return e&&e.j?i=e:(i=new vs(e),n&&r&&Nf(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||vs.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 vs,Object.assign(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new vs,a){if(r)if(o.t&&typeof o.t=="string"){const c=Object.assign(YWe(o.t,r),n);Nf(a,c,r)}else n&&Nf(a,n,r);o.t=a}return i.j[t]=o,o}};const wn=(t,e,n,r,i)=>t.ta(e,n,r,i),ei=(t,e,n,r,i)=>t.tr(e,n,r,i),FW=(t,e,n,r,i)=>t.ts(e,n,r,i),Ct=(t,e,n,r,i)=>t.tt(e,n,r,i),qc="WORD",uD="UWORD",zre="ASCIINUMERICAL",Bre="ALPHANUMERICAL",gy="LOCALHOST",dD="TLD",hD="UTLD",E1="SCHEME",Xp="SLASH_SCHEME",rI="NUM",fD="WS",iI="NL",b0="OPENBRACE",y0="CLOSEBRACE",yM="OPENBRACKET",vM="CLOSEBRACKET",_M="OPENPAREN",wM="CLOSEPAREN",SM="OPENANGLEBRACKET",MM="CLOSEANGLEBRACKET",NM="FULLWIDTHLEFTPAREN",EM="FULLWIDTHRIGHTPAREN",AM="LEFTCORNERBRACKET",TM="RIGHTCORNERBRACKET",CM="LEFTWHITECORNERBRACKET",kM="RIGHTWHITECORNERBRACKET",jM="FULLWIDTHLESSTHAN",PM="FULLWIDTHGREATERTHAN",RM="AMPERSAND",DM="APOSTROPHE",OM="ASTERISK",Md="AT",LM="BACKSLASH",IM="BACKTICK",FM="CARET",kd="COLON",aI="COMMA",UM="DOLLAR",Rl="DOT",zM="EQUALS",sI="EXCLAMATION",yo="HYPHEN",v0="PERCENT",BM="PIPE",$M="PLUS",HM="POUND",_0="QUERY",oI="QUOTE",$re="FULLWIDTHMIDDLEDOT",lI="SEMI",Dl="SLASH",w0="TILDE",VM="UNDERSCORE",Hre="EMOJI",GM="SYM";var Vre=Object.freeze({__proto__:null,ALPHANUMERICAL:Bre,AMPERSAND:RM,APOSTROPHE:DM,ASCIINUMERICAL:zre,ASTERISK:OM,AT:Md,BACKSLASH:LM,BACKTICK:IM,CARET:FM,CLOSEANGLEBRACKET:MM,CLOSEBRACE:y0,CLOSEBRACKET:vM,CLOSEPAREN:wM,COLON:kd,COMMA:aI,DOLLAR:UM,DOT:Rl,EMOJI:Hre,EQUALS:zM,EXCLAMATION:sI,FULLWIDTHGREATERTHAN:PM,FULLWIDTHLEFTPAREN:NM,FULLWIDTHLESSTHAN:jM,FULLWIDTHMIDDLEDOT:$re,FULLWIDTHRIGHTPAREN:EM,HYPHEN:yo,LEFTCORNERBRACKET:AM,LEFTWHITECORNERBRACKET:CM,LOCALHOST:gy,NL:iI,NUM:rI,OPENANGLEBRACKET:SM,OPENBRACE:b0,OPENBRACKET:yM,OPENPAREN:_M,PERCENT:v0,PIPE:BM,PLUS:$M,POUND:HM,QUERY:_0,QUOTE:oI,RIGHTCORNERBRACKET:TM,RIGHTWHITECORNERBRACKET:kM,SCHEME:E1,SEMI:lI,SLASH:Dl,SLASH_SCHEME:Xp,SYM:GM,TILDE:w0,TLD:dD,UNDERSCORE:VM,UTLD:hD,UWORD:uD,WORD:qc,WS:fD});const Hc=/[a-z]/,Ib=new RegExp("\\p{L}","u"),Lj=new RegExp("\\p{Emoji}","u"),Vc=/\d/,Ij=/\s/,UW="\r",Fj=`
- `,ZWe="️",QWe="",Uj="";let Ww=null,qw=null;function JWe(t=[]){const e={};vs.groups=e;const n=new vs;Ww==null&&(Ww=zW(GWe)),qw==null&&(qw=zW(WWe)),Ct(n,"'",DM),Ct(n,"{",b0),Ct(n,"}",y0),Ct(n,"[",yM),Ct(n,"]",vM),Ct(n,"(",_M),Ct(n,")",wM),Ct(n,"<",SM),Ct(n,">",MM),Ct(n,"(",NM),Ct(n,")",EM),Ct(n,"「",AM),Ct(n,"」",TM),Ct(n,"『",CM),Ct(n,"』",kM),Ct(n,"<",jM),Ct(n,">",PM),Ct(n,"&",RM),Ct(n,"*",OM),Ct(n,"@",Md),Ct(n,"`",IM),Ct(n,"^",FM),Ct(n,":",kd),Ct(n,",",aI),Ct(n,"$",UM),Ct(n,".",Rl),Ct(n,"=",zM),Ct(n,"!",sI),Ct(n,"-",yo),Ct(n,"%",v0),Ct(n,"|",BM),Ct(n,"+",$M),Ct(n,"#",HM),Ct(n,"?",_0),Ct(n,'"',oI),Ct(n,"/",Dl),Ct(n,";",lI),Ct(n,"~",w0),Ct(n,"_",VM),Ct(n,"\\",LM),Ct(n,"・",$re);const r=ei(n,Vc,rI,{[sD]:!0});ei(r,Vc,r);const i=ei(r,Hc,zre,{[x0]:!0}),a=ei(r,Ib,Bre,{[e0]:!0}),o=ei(n,Hc,qc,{[oD]:!0});ei(o,Vc,i),ei(o,Hc,o),ei(i,Vc,i),ei(i,Hc,i);const l=ei(n,Ib,uD,{[lD]:!0});ei(l,Hc),ei(l,Vc,a),ei(l,Ib,l),ei(a,Vc,a),ei(a,Hc),ei(a,Ib,a);const c=Ct(n,Fj,iI,{[Oj]:!0}),u=Ct(n,UW,fD,{[Oj]:!0}),d=ei(n,Ij,fD,{[Oj]:!0});Ct(n,Uj,d),Ct(u,Fj,c),Ct(u,Uj,d),ei(u,Ij,d),Ct(d,UW),Ct(d,Fj),ei(d,Ij,d),Ct(d,Uj,d);const f=ei(n,Lj,Hre,{[Ure]:!0});Ct(f,"#"),ei(f,Lj,f),Ct(f,ZWe,f);const m=Ct(f,QWe);Ct(m,"#"),ei(m,Lj,f);const p=[[Hc,o],[Vc,i]],b=[[Hc,null],[Ib,l],[Vc,a]];for(let y=0;y<Ww.length;y++)gd(n,Ww[y],dD,qc,p);for(let y=0;y<qw.length;y++)gd(n,qw[y],hD,uD,b);Nf(dD,{tld:!0,ascii:!0},e),Nf(hD,{utld:!0,alpha:!0},e),gd(n,"file",E1,qc,p),gd(n,"mailto",E1,qc,p),gd(n,"http",Xp,qc,p),gd(n,"https",Xp,qc,p),gd(n,"ftp",Xp,qc,p),gd(n,"ftps",Xp,qc,p),Nf(E1,{scheme:!0,ascii:!0},e),Nf(Xp,{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]?{[qWe]:!0}:{[KWe]:!0};x.indexOf("-")>=0?S[cD]=!0:Hc.test(x)?Vc.test(x)?S[x0]=!0:S[oD]=!0:S[sD]=!0,FW(n,x,x,S)}return FW(n,"localhost",gy,{ascii:!0}),n.jd=new vs(GM),{start:n,tokens:Object.assign({groups:e},Vre)}}function Gre(t,e){const n=eqe(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 eqe(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 gd(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 vs(r),a.jr=i.slice(),t.j[c]=a),t=a}return a=new vs(n),a.jr=i.slice(),t.j[e[o-1]]=a,a}function zW(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 xy={defaultProtocol:"http",events:null,format:BW,formatHref:BW,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function cI(t,e=null){let n=Object.assign({},xy);t&&(n=Object.assign(n,t instanceof cI?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}cI.prototype={o:xy,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]:xy[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 BW(t){return t}function Wre(t,e){this.t="token",this.v=t,this.tk=e}Wre.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=xy.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 OE(t,e){class n extends Wre{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 $W=OE("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),HW=OE("text"),tqe=OE("nl"),Kw=OE("url",{isLink:!0,toHref(t=xy.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==gy&&t[1].t===kd}}),go=t=>new vs(t);function nqe({groups:t}){const e=t.domain.concat([RM,OM,Md,LM,IM,FM,UM,zM,yo,rI,v0,BM,$M,HM,Dl,GM,w0,VM]),n=[DM,kd,aI,Rl,sI,v0,_0,oI,lI,SM,MM,b0,y0,vM,yM,_M,wM,NM,EM,AM,TM,CM,kM,jM,PM],r=[RM,DM,OM,LM,IM,FM,UM,zM,yo,b0,y0,v0,BM,$M,HM,_0,Dl,GM,w0,VM],i=go(),a=Ct(i,w0);wn(a,r,a),wn(a,t.domain,a);const o=go(),l=go(),c=go();wn(i,t.domain,o),wn(i,t.scheme,l),wn(i,t.slashscheme,c),wn(o,r,a),wn(o,t.domain,o);const u=Ct(o,Md);Ct(a,Md,u),Ct(l,Md,u),Ct(c,Md,u);const d=Ct(a,Rl);wn(d,r,a),wn(d,t.domain,a);const f=go();wn(u,t.domain,f),wn(f,t.domain,f);const m=Ct(f,Rl);wn(m,t.domain,f);const p=go($W);wn(m,t.tld,p),wn(m,t.utld,p),Ct(u,gy,p);const b=Ct(f,yo);Ct(b,yo,b),wn(b,t.domain,f),wn(p,t.domain,f),Ct(p,Rl,m),Ct(p,yo,b);const y=Ct(p,kd);wn(y,t.numeric,$W);const x=Ct(o,yo),v=Ct(o,Rl);Ct(x,yo,x),wn(x,t.domain,o),wn(v,r,a),wn(v,t.domain,o);const S=go(Kw);wn(v,t.tld,S),wn(v,t.utld,S),wn(S,t.domain,o),wn(S,r,a),Ct(S,Rl,v),Ct(S,yo,x),Ct(S,Md,u);const M=Ct(S,kd),A=go(Kw);wn(M,t.numeric,A);const T=go(Kw),k=go();wn(T,e,T),wn(T,n,k),wn(k,e,T),wn(k,n,k),Ct(S,Dl,T),Ct(A,Dl,T);const E=Ct(l,kd),O=Ct(c,kd),C=Ct(O,Dl),D=Ct(C,Dl);wn(l,t.domain,o),Ct(l,Rl,v),Ct(l,yo,x),wn(c,t.domain,o),Ct(c,Rl,v),Ct(c,yo,x),wn(E,t.domain,T),Ct(E,Dl,T),Ct(E,_0,T),wn(D,t.domain,T),wn(D,e,T),Ct(D,Dl,T);const U=[[b0,y0],[yM,vM],[_M,wM],[SM,MM],[NM,EM],[AM,TM],[CM,kM],[jM,PM]];for(let L=0;L<U.length;L++){const[q,P]=U[L],W=Ct(T,q);Ct(k,q,W),Ct(W,P,T);const K=go(Kw);wn(W,e,K);const V=go();wn(W,n),wn(K,e,K),wn(K,n,V),wn(V,e,K),wn(V,n,V),Ct(K,P,T),Ct(V,P,T)}return Ct(i,gy,S),Ct(i,iI,tqe),{start:i,tokens:Vre}}function rqe(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(zj(HW,e,o)),o=[]),i-=m,d-=m;const p=f.t,b=n.slice(i-d,i);a.push(zj(p,e,b))}}return o.length>0&&a.push(zj(HW,e,o)),a}function zj(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 iqe=typeof console<"u"&&console&&console.warn||(()=>{}),aqe="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",kr={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function sqe(){return vs.groups={},kr.scanner=null,kr.parser=null,kr.tokenQueue=[],kr.pluginQueue=[],kr.customSchemes=[],kr.initialized=!1,kr}function VW(t,e=!1){if(kr.initialized&&iqe(`linkifyjs: already initialized - will not register custom scheme "${t}" ${aqe}`),!/^[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`);kr.customSchemes.push([t,e])}function oqe(){kr.scanner=JWe(kr.customSchemes);for(let t=0;t<kr.tokenQueue.length;t++)kr.tokenQueue[t][1]({scanner:kr.scanner});kr.parser=nqe(kr.scanner.tokens);for(let t=0;t<kr.pluginQueue.length;t++)kr.pluginQueue[t][1]({scanner:kr.scanner,parser:kr.parser});return kr.initialized=!0,kr}function uI(t){return kr.initialized||oqe(),rqe(kr.parser.start,t,Gre(kr.scanner.start,t))}uI.scan=Gre;function qre(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 cI(n),i=uI(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 dI="[\0- -\u2029 ]",lqe=new RegExp(dI),cqe=new RegExp(`${dI}$`),uqe=new RegExp(dI,"g");function dqe(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function hqe(t){return new Zr({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=ure(n.doc,[...e]);if(xre(l).forEach(({newRange:u})=>{const d=f7e(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(!cqe.test(p))return;f=d[0],m=r.doc.textBetween(f.pos,u.to,void 0," ")}if(f&&m){const p=m.split(lqe).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=uI(b).map(v=>v.toObject(t.defaultProtocol));if(!dqe(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=>{QL(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 fqe(t){return new Zr({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=gre(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 mqe(t){return new Zr({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=qre(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 Jh(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(uqe,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var Kre=wh.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"){VW(t);return}VW(t.scheme,t.optionalSlashes)})},onDestroy(){sqe()},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)=>!!Jh(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=>!!Jh(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=>!!Jh(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",ci(this.options.HTMLAttributes,t),0]:["a",ci(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=>!!Jh(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=>!!Jh(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[hm({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=qre(t).filter(a=>a.isLink&&this.options.isAllowedUri(a.value,{defaultValidate:o=>!!Jh(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(hqe({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!Jh(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(fqe({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(mqe({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),pqe=Kre,gqe=Object.defineProperty,xqe=(t,e)=>{for(var n in e)gqe(t,n,{get:e[n],enumerable:!0})},bqe="listItem",GW="textStyle",WW=/^\s*([-+*])\s$/,Xre=Cs.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",ci(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(bqe,this.editor.getAttributes(GW)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Wg({find:WW,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Wg({find:WW,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(GW),editor:this.editor})),[t]}}),Yre=Cs.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",ci(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)=>nI(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)}}}),yqe={};xqe(yqe,{findListItemPos:()=>rv,getNextListDepth:()=>hI,handleBackspace:()=>mD,handleDelete:()=>pD,hasListBefore:()=>Zre,hasListItemAfter:()=>vqe,hasListItemBefore:()=>Qre,listItemHasSubList:()=>Jre,nextListIsDeeper:()=>eie,nextListIsHigher:()=>tie});var rv=(t,e)=>{const{$from:n}=e.selection,r=ki(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}},hI=(t,e)=>{const n=rv(t,e);if(!n)return!1;const[,r]=S7e(e,t,n.$pos.pos+4);return r},Zre=(t,e,n)=>{const{$anchor:r}=t.selection,i=Math.max(0,r.pos-2),a=t.doc.resolve(i).node();return!(!a||!n.includes(a.type.name))},Qre=(t,e)=>{var n;const{$anchor:r}=e.selection,i=e.doc.resolve(r.pos-2);return!(i.index()===0||((n=i.nodeBefore)==null?void 0:n.type.name)!==t)},Jre=(t,e,n)=>{if(!n)return!1;const r=ki(t,e.schema);let i=!1;return n.descendants(a=>{a.type===r&&(i=!0)}),i},mD=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!dh(t.state,e)&&Zre(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(!dh(t.state,e)||!A7e(t.state))return!1;const r=rv(e,t.state);if(!r)return!1;const a=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=Jre(e,t.state,a);return Qre(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},eie=(t,e)=>{const n=hI(t,e),r=rv(t,e);return!r||!n?!1:n>r.depth},tie=(t,e)=>{const n=hI(t,e),r=rv(t,e);return!r||!n?!1:n<r.depth},pD=(t,e)=>{if(!dh(t.state,e)||!E7e(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:eie(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():tie(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},vqe=(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)},nie=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&&pD(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&&pD(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&&mD(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&&mD(t,n,r)&&(e=!0)}),e}}}}),qW=/^(\s*)(\d+)\.\s+(.*)$/,_qe=/^\s/;function wqe(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n],a=i.match(qW);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(qW))break;if(p.trim()==="")m.push(p),d+=`
- `,f+=1;else if(p.match(_qe))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 rie(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=rie(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 Sqe(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 Mqe="listItem",KW="textStyle",XW=/^(\d+)\.\s$/,iie=Cs.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",ci(this.options.HTMLAttributes,n),0]:["ol",ci(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?Sqe(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]=wqe(i);if(a.length===0)return;const l=rie(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(Mqe,this.editor.getAttributes(KW)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Wg({find:XW,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=Wg({find:XW,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(KW)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),Nqe=/^\s*(\[([( |x])?\])\s$/,Eqe=Cs.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{const e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",ci(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 nI(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=py(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[Wg({find:Nqe,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),Aqe=Cs.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",ci(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=iD(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=iD(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(Xre.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(Yre.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(nie.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(iie.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(Eqe.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(Aqe.configure(this.options.taskList)),t}});var YW=" ",Tqe=" ",Cqe=Cs.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",ci(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===YW||r[0].text===Tqe)?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?YW:e.renderChildren(n)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),kqe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,jqe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Pqe=wh.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",ci(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[Gg({find:kqe,type:this.type})]},addPasteRules(){return[hm({find:jqe,type:this.type})]}}),Rqe=Cs.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),aie=wh.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",ci(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()}}}),Dqe=aie;function Oqe(t={}){return new Zr({view(e){return new Lqe(e,t)}})}class Lqe{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=tne(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 ai extends En{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return ai.valid(r)?new ai(r):En.near(r)}content(){return Ht.empty}eq(e){return e instanceof ai&&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 ai(e.resolve(n.pos))}getBookmark(){return new fI(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!Iqe(e)||!Fqe(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&&ai.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(ai.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(ai.valid(l))return l}return null}}}ai.prototype.visible=!1;ai.findFrom=ai.findGapCursorFrom;En.jsonID("gapcursor",ai);class fI{constructor(e){this.pos=e}map(e){return new fI(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return ai.valid(n)?new ai(n):En.near(n)}}function sie(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function Iqe(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||sie(i.type))return!0;if(i.inlineContent)return!1}}return!0}function Fqe(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||sie(i.type))return!0;if(i.inlineContent)return!1}}return!0}function Uqe(){return new Zr({props:{decorations:Hqe,createSelectionBetween(t,e,n){return e.pos==n.pos&&ai.valid(n)?new ai(n):null},handleClick:Bqe,handleKeyDown:zqe,handleDOMEvents:{beforeinput:$qe}}})}const zqe=nre({ArrowLeft:Xw("horiz",-1),ArrowRight:Xw("horiz",1),ArrowUp:Xw("vert",-1),ArrowDown:Xw("vert",1)});function Xw(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=ai.findGapCursorFrom(l,e,c);return u?(i&&i(r.tr.setSelection(new ai(u))),!0):!1}}function Bqe(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!ai.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 ai(r))),!0)}function $qe(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof ai))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=Et.empty;for(let o=r.length-1;o>=0;o--)i=Et.from(r[o].createAndFill(null,i));let a=t.state.tr.replace(n.pos,n.pos,new Ht(i,0,0));return a.setSelection(fn.near(a.doc.resolve(n.pos+1))),t.dispatch(a),!1}function Hqe(t){if(!(t.selection instanceof ai))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Wr.create(t.doc,[Ja.widget(t.selection.head,e,{key:"gapcursor"})])}var WM=200,sa=function(){};sa.prototype.append=function(e){return e.length?(e=sa.from(e),!this.length&&e||e.length<WM&&this.leafAppend(e)||this.length<WM&&e.leafPrepend(this)||this.appendInner(e)):this};sa.prototype.prepend=function(e){return e.length?sa.from(e).append(this):this};sa.prototype.appendInner=function(e){return new Vqe(this,e)};sa.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?sa.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};sa.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};sa.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)};sa.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};sa.from=function(e){return e instanceof sa?e:e&&e.length?new oie(e):sa.empty};var oie=(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<=WM)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=WM)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})(sa);sa.empty=new oie([]);var Vqe=(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})(sa);const Gqe=500;class rl{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 Ol(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 Ol(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 rl(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 Ol(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>qqe&&(l=Wqe(l,u),o-=u),new rl(l.append(a),o)}remapping(e,n){let r=new cy;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 rl(this.items.append(e.map(n=>new Ol(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 Ol(b,y,x))}else r.push(new Ol(b))},i);let u=[];for(let m=n;m<o;m++)u.push(new Ol(a.maps[m]));let d=this.items.slice(0,i).append(u).append(r),f=new rl(d,l);return f.emptyItemCount()>Gqe&&(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 Ol(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 rl(sa.from(i.reverse()),a)}}rl.empty=new rl(sa.empty,0);function Wqe(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class Ol{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 Ol(n.getMap().invert(),n,this.selection)}}}class Nd{constructor(e,n,r,i,a){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=a}}const qqe=20;function Kqe(t,e,n,r){let i=n.getMeta(Uf),a;if(i)return i.historyState;n.getMeta(Zqe)&&(t=new Nd(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(Uf))return o.getMeta(Uf).redo?new Nd(t.done.addTransform(n,void 0,r,A1(e)),t.undone,ZW(n.mapping.maps),t.prevTime,t.prevComposition):new Nd(t.done,t.undone.addTransform(n,void 0,r,A1(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||!Xqe(n,t.prevRanges)),u=o?Bj(t.prevRanges,n.mapping):ZW(n.mapping.maps);return new Nd(t.done.addTransform(n,c?e.selection.getBookmark():void 0,r,A1(e)),rl.empty,u,n.time,l??t.prevComposition)}else return(a=n.getMeta("rebased"))?new Nd(t.done.rebased(n,a),t.undone.rebased(n,a),Bj(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Nd(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Bj(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function Xqe(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 ZW(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 Bj(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 Yqe(t,e,n){let r=A1(e),i=Uf.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 Nd(n?l:a.remaining,n?a.remaining:l,null,0,-1);return a.transform.setSelection(o).setMeta(Uf,{redo:n,historyState:c})}let $j=!1,QW=null;function A1(t){let e=t.plugins;if(QW!=e){$j=!1,QW=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){$j=!0;break}}return $j}const Uf=new Vi("history"),Zqe=new Vi("closeHistory");function Qqe(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Zr({key:Uf,state:{init(){return new Nd(rl.empty,rl.empty,null,0,-1)},apply(e,n,r){return Kqe(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?cie:r=="historyRedo"?uie:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function lie(t,e){return(n,r)=>{let i=Uf.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let a=Yqe(i,n,t);a&&r(e?a.scrollIntoView():a)}return!0}}const cie=lie(!1,!0),uie=lie(!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 Zr({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 Jqe=br.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Oqe(this.options)]}});br.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Zr({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 Wr.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(Ja.node(u,u+c.nodeSize,{class:this.options.className}))}),Wr.create(t,a)}}})]}});var eKe=br.create({name:"gapCursor",addProseMirrorPlugins(){return[Uqe()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=sr(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 Zr({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&&PE(o);if((c||!this.options.showOnlyCurrent)&&u){const d=[this.options.emptyNodeClass];a&&d.push(this.options.emptyEditorClass);const f=Ja.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}),Wr.create(t,i)}}})]}});br.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new Zr({key:new Vi("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||bre(n.selection)||t.view.dragging?null:Wr.create(n.doc,[Ja.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function JW({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var tKe=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 Zr({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!JW({node:o,types:r})},apply:(i,a)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return a;const o=i.doc.lastChild;return!JW({node:o,types:r})}}})]}}),nKe=br.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>cie(t,e),redo:()=>({state:t,dispatch:e})=>uie(t,e)}},addProseMirrorPlugins(){return[Qqe(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()}}}),rKe=br.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push(CWe.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(MWe.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(Xre.configure(this.options.bulletList)),this.options.code!==!1&&i.push(PWe.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(OWe.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(LWe.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(Jqe.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(eKe.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(IWe.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(FWe.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(nKe.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(UWe.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(VWe.configure(this.options.italic)),this.options.listItem!==!1&&i.push(Yre.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(nie.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(Kre.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(iie.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(Cqe.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(Pqe.configure(this.options.strike)),this.options.text!==!1&&i.push(Rqe.configure(this.options.text)),this.options.underline!==!1&&i.push(aie.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(tKe.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),iKe=rKe,aKe=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")}}}),sKe=aKe,oKe=20,die=(t,e=0)=>{const n=[];return!t.children.length||e>oKe||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...die(r,e+1))}),n},lKe=t=>{if(!t.children.length)return;const e=die(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}`)})},hie=wh.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&lKe(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",ci(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}}}}),cKe=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()}}}),fie=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()}}}),uKe=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()}}}),dKe=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()}}}),hKe=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(cKe.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(fie.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(uKe.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(dKe.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(hKe.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(hie.configure(this.options.textStyle)),t}});var fKe=fie,mKe=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,pKe=Cs.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",ci(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 f9e({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[Ore({find:mKe,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),gKe=pKe;function gD({content:t,onChange:e,placeholder:n}){const r=yWe({extensions:[iKe.configure({heading:!1,codeBlock:!1,code:!1}),Dqe,pqe.configure({openOnClick:!1,HTMLAttributes:{target:"_blank",rel:"noopener noreferrer"}}),sKe.configure({types:["paragraph"]}),hie,fKe,gKe.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(zue,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().toggleItalic().run(),isActive:r.isActive("italic"),title:"Italic",children:s.jsx(jhe,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().toggleUnderline().run(),isActive:r.isActive("underline"),title:"Underline",children:s.jsx(vme,{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(dN,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().toggleOrderedList().run(),isActive:r.isActive("orderedList"),title:"Numbered List",children:s.jsx(vK,{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(hme,{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(lme,{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(ume,{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(Jg,{className:"w-4 h-4"})}),r.isActive("link")&&s.jsx(i,{onClick:()=>r.chain().focus().unsetLink().run(),title:"Remove Link",children:s.jsx(WD,{className:"w-4 h-4"})})]}),s.jsx(hWe,{editor:r})]})}function mie({archiveId:t,archiveName:e,onClose:n}){const r=on(),[i,a]=w.useState(!1),[o,l]=w.useState(null),[c,u]=w.useState({}),{data:d,isLoading:f,error:m}=ut({queryKey:["archive-project-page",t],queryFn:()=>he.getArchiveProjectPage(t)}),p=mt({mutationFn:T=>he.updateArchiveProjectPage(t,T),onSuccess:()=>{r.invalidateQueries({queryKey:["archive-project-page",t]}),a(!1),u({})}});w.useEffect(()=>{const T=k=>{k.key==="Escape"&&(o!==null?l(null):i?v():n())};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[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=T=>{const k=["p","br","b","strong","i","em","u","a","ul","ol","li","figure","img"],E=new DOMParser().parseFromString(T,"text/html"),O=C=>{if(C.nodeType===Node.TEXT_NODE)return C.textContent||"";if(C.nodeType===Node.ELEMENT_NODE){const D=C,U=D.tagName.toLowerCase();if(!k.includes(U))return Array.from(D.childNodes).map(O).join("");let L="";if(U==="a"&&D.getAttribute("href")){const P=D.getAttribute("href");P?.toLowerCase().startsWith("http")&&(L=` href="${P}" target="_blank" rel="noopener noreferrer"`)}if(U==="img"){const P=D.getAttribute("src");if(!P?.toLowerCase().startsWith("http"))return"";L=` src="${P}" style="max-width: 100%; height: auto;"`}const q=Array.from(D.childNodes).map(O).join("");return["br","img"].includes(U)?`<${U}${L} />`:`<${U}${L}>${q}</${U}>`}return""};return Array.from(E.body.childNodes).map(O).join("")},M=d&&(d.title||d.description||d.designer||d.profile_title||b.length>0),A=T=>{T.target===T.currentTarget&&n()};return s.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:A,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(Za,{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(Se,{variant:"ghost",size:"sm",onClick:y,children:[s.jsx(Gf,{className:"w-4 h-4 mr-1"}),"Edit"]}),i&&s.jsxs(s.Fragment,{children:[s.jsx(Se,{variant:"ghost",size:"sm",onClick:v,children:"Cancel"}),s.jsxs(Se,{variant:"primary",size:"sm",onClick:x,disabled:p.isPending,children:[s.jsx(_s,{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(Vt,{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(Za,{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:T=>u({...c,title:T.target.value}),placeholder:"Title",className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded-lg px-4 py-2 text-white text-xl font-semibold"}):d.title&&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(EP,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:c.designer||"",onChange:T=>u({...c,designer:T.target.value}),placeholder:"Designer",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):d.designer&&s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[s.jsx(EP,{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(zr,{className:"w-3 h-3"})})]}),d.creation_date&&s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[s.jsx(oi,{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(Za,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:c.license||"",onChange:T=>u({...c,license:T.target.value}),placeholder:"License",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):d.license&&s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[s.jsx(Za,{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(gD,{content:c.description||"",onChange:T=>u({...c,description:T}),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:T=>u({...c,profile_title:T.target.value}),placeholder:"Profile Title",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-white"}),s.jsx(gD,{content:c.profile_description||"",onChange:T=>u({...c,profile_description:T}),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(Ny,{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((T,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:T.url,alt:T.name,className:"w-full h-full object-cover"})},T.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(zr,{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:T=>{T.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(Vf,{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:T=>T.stopPropagation()}),s.jsx("button",{onClick:T=>{T.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(Js,{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(Vt,{className:"w-6 h-6 text-white"})}),s.jsxs("div",{className:"absolute bottom-4 text-white text-sm",children:[o+1," / ",b.length]})]})]})}const xKe=[.25,.5,.75,1,1.5,2,3,4];function Bp(t){const e=Math.floor(t/60),n=Math.floor(t%60);return`${e}:${n.toString().padStart(2,"0")}`}function bKe({archiveId:t,timelapseSrc:e,onClose:n,onSave:r}){const{showToast:i}=qn(),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,A]=w.useState(null),[T,k]=w.useState(null),[E,O]=w.useState(.8),[C,D]=w.useState(!1),{data:U,isLoading:L}=ut({queryKey:["timelapse-info",t],queryFn:()=>he.getTimelapseInfo(t)}),{data:q}=ut({queryKey:["timelapse-thumbnails",t],queryFn:()=>he.getTimelapseThumbnails(t,15)}),P=mt({mutationFn:()=>he.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=G=>{G.key==="Escape"&&n()};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[n]),w.useEffect(()=>{const z=a.current;if(!z)return;const G=()=>{const fe=z.currentTime;d(fe),fe>=y&&(z.currentTime=p)},ne=()=>{m(z.duration),y===0&&x(z.duration)},ae=()=>c(!0),de=()=>c(!1);return z.addEventListener("timeupdate",G),z.addEventListener("durationchange",ne),z.addEventListener("play",ae),z.addEventListener("pause",de),()=>{z.removeEventListener("timeupdate",G),z.removeEventListener("durationchange",ne),z.removeEventListener("play",ae),z.removeEventListener("pause",de)}},[p,y]),w.useEffect(()=>{const z=o.current,G=a.current;!z||!G||!T||(z.currentTime=G.currentTime,z.playbackRate=G.playbackRate,l&&!C?z.play().catch(()=>{}):z.pause())},[l,T,C]),w.useEffect(()=>{o.current&&(o.current.volume=C?0:E)},[E,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]),K=z=>{const G=a.current;G&&(G.currentTime=Math.max(p,Math.min(y,z)))},V=z=>{const G=z.target.files?.[0];G&&(T&&URL.revokeObjectURL(T),A(G),k(URL.createObjectURL(G)))},Q=()=>{T&&URL.revokeObjectURL(T),A(null),k(null)};w.useEffect(()=>()=>{T&&URL.revokeObjectURL(T)},[T]);const re=y-p,J=re/v;return L?s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:s.jsxs("div",{className:"flex items-center gap-3 text-white",children:[s.jsx(dt,{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(Bd,{className:"w-5 h-5 text-bambu-green"}),"Edit Timelapse"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Se,{variant:"primary",size:"sm",onClick:()=>P.mutate(),disabled:P.isPending,children:P.isPending?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):s.jsxs(s.Fragment,{children:[s.jsx(_s,{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(Vt,{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:!!T}),!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(Oo,{className:"w-8 h-8 text-white"})})}),T&&s.jsx("audio",{ref:o,src:T,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(Lfe,{className:"w-4 h-4"}),s.jsx("span",{children:"Trim"}),s.jsxs("span",{className:"ml-auto",children:[Bp(p)," - ",Bp(y)," (",Bp(re),")"]})]}),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,G)=>s.jsx("div",{className:"flex-1 bg-cover bg-center",style:{backgroundImage:`url(data:image/jpeg;base64,${z})`}},G))}),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 G=parseFloat(z.target.value);G<y-1&&(b(G),a.current&&a.current.currentTime<G&&(a.current.currentTime=G))},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 G=parseFloat(z.target.value);G>p+1&&x(G)},className:"absolute inset-0 w-full opacity-0 cursor-ew-resize",style:{clipPath:"inset(0 0 0 50%)"}})]}),s.jsx("input",{type:"range",min:0,max:f,step:.1,value:u,onChange:z=>K(parseFloat(z.target.value)),className:`w-full h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
- [&::-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(VD,{className:"w-5 h-5 text-white"}):s.jsx(Oo,{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(oN,{className:"w-4 h-4"}),s.jsx("span",{children:"Speed"}),s.jsxs("span",{className:"ml-auto",children:[v,"x (output: ",Bp(J),")"]})]}),s.jsx("div",{className:"flex gap-1",children:xKe.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(SP,{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(SP,{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:()=>D(!C),className:"p-2 hover:bg-bambu-dark-tertiary rounded transition-colors",children:C?s.jsx(Cme,{className:"w-4 h-4 text-bambu-gray"}):s.jsx(Ame,{className:"w-4 h-4 text-bambu-green"})}),s.jsx("input",{type:"range",min:0,max:1,step:.1,value:E,onChange:z=>O(parseFloat(z.target.value)),className:`w-20 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
- [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
- [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full`}),s.jsx("button",{onClick:Q,className:"p-2 hover:bg-red-500/20 rounded transition-colors",children:s.jsx(dn,{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(pi,{className:"w-8 h-8 text-bambu-gray"}),s.jsx("span",{className:"text-sm text-bambu-gray",children:"Drop audio file or click to upload"}),s.jsx("span",{className:"text-xs text-bambu-gray/60",children:"MP3, WAV, M4A, AAC, OGG"}),s.jsx("input",{type:"file",accept:".mp3,.wav,.m4a,.aac,.ogg,audio/*",onChange:V,className:"hidden"})]})]}),s.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg text-sm space-y-1",children:[s.jsxs("p",{className:"text-bambu-gray",children:[s.jsx("span",{className:"text-white",children:"Original:"})," ",Bp(f)," @ ",U?.width,"x",U?.height]}),s.jsxs("p",{className:"text-bambu-gray",children:[s.jsx("span",{className:"text-white",children:"Output:"})," ",Bp(J)," @ ",v,"x speed",M&&" + music overlay"]})]})]}),P.isPending&&s.jsxs("div",{className:"absolute inset-0 bg-black/80 flex flex-col items-center justify-center gap-4",children:[s.jsx(dt,{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 yKe=[.25,.5,.75,1,1.5,2,3,4];function pie({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 E=o.current;E&&(E.playbackRate=u)},[u]),w.useEffect(()=>{const E=O=>{O.key==="Escape"&&i()};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[i]),w.useEffect(()=>{const E=o.current;if(!E)return;const O=()=>m(E.currentTime),C=()=>b(E.duration),D=()=>c(!0),U=()=>c(!1);return E.addEventListener("timeupdate",O),E.addEventListener("durationchange",C),E.addEventListener("play",D),E.addEventListener("pause",U),()=>{E.removeEventListener("timeupdate",O),E.removeEventListener("durationchange",C),E.removeEventListener("play",D),E.removeEventListener("pause",U)}},[]);const v=()=>{const E=o.current;E&&(l?E.pause():E.play())},S=E=>{const O=o.current;O&&(O.currentTime=parseFloat(E.target.value))},M=()=>{const E=o.current;E&&(E.currentTime=Math.max(0,E.currentTime-5))},A=()=>{const E=o.current;E&&(E.currentTime=Math.min(p,E.currentTime+5))},T=E=>{const O=Math.floor(E/60),C=Math.floor(E%60);return`${O}:${C.toString().padStart(2,"0")}`},k=()=>{const E=document.createElement("a");E.href=t,E.download=n,E.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(Bd,{className:"w-5 h-5 text-bambu-green"}),e]}),s.jsxs("div",{className:"flex items-center gap-2",children:[r&&s.jsxs(Se,{variant:"secondary",size:"sm",onClick:()=>x(!0),children:[s.jsx(la,{className:"w-4 h-4"}),"Edit"]}),s.jsxs(Se,{variant:"secondary",size:"sm",onClick:k,children:[s.jsx(Hr,{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(Vt,{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:T(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:T(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(qfe,{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(VD,{className:"w-5 h-5 text-white"}):s.jsx(Oo,{className:"w-5 h-5 text-white"})}),s.jsx("button",{onClick:A,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip forward 5s",children:s.jsx(R0,{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:yKe.map(E=>s.jsxs("button",{onClick:()=>d(E),className:`px-2 py-1 text-xs rounded transition-colors ${u===E?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:bg-bambu-dark-tertiary/80"}`,children:[E,"x"]},E))})]})]})]})]})]}),y&&r&&s.jsx(bKe,{archiveId:r,timelapseSrc:t,onClose:()=>x(!1),onSave:a})]})}function vKe({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}=ut({queryKey:["archive-comparison",t],queryFn:()=>he.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(Vt,{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(dt,{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(kn,{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(_Ke,{comparison:n}):null}),s.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:s.jsx(Se,{variant:"secondary",onClick:e,className:"w-full",children:"Close"})})]})})}function _Ke({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(kn,{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(kn,{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(ns,{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 wKe(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function SKe(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 MKe({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(St,{children:s.jsxs(Nt,{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(Af,{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:wKe(t.file_size)}),s.jsx("span",{children:"·"}),s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(Zn,{className:"w-3 h-3"}),SKe(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(pu,{className:"w-5 h-5"}):s.jsx(Oi,{className:"w-5 h-5"})}),s.jsx(Se,{variant:"primary",size:"sm",onClick:()=>n(t.id,{tags:c,notes:d,project_id:m||void 0}),disabled:i,children:i?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx(es,{className:"w-4 h-4"}),"Archive"]})}),s.jsx(Se,{variant:"secondary",size:"sm",onClick:()=>y(!0),disabled:a,children:a?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(dn,{className:"w-4 h-4 text-red-400"})})]})]}),b&&s.jsx(Hn,{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 NKe(){const t=on(),{showToast:e}=qn(),[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}=ut({queryKey:["pending-uploads"],queryFn:Vp.list,refetchInterval:1e4}),{data:m}=ut({queryKey:["projects"],queryFn:()=>he.getProjects()}),p=mt({mutationFn:({id:v,data:S})=>Vp.archive(v,S),onMutate:({id:v})=>{l(S=>new Set(S).add(v))},onSettled:(v,S,{id:M})=>{l(A=>{const T=new Set(A);return T.delete(M),T})},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=mt({mutationFn:v=>Vp.discard(v),onMutate:v=>{u(S=>new Set(S).add(v))},onSettled:(v,S,M)=>{u(A=>{const T=new Set(A);return T.delete(M),T})},onSuccess:()=>{t.invalidateQueries({queryKey:["pending-uploads"]}),e("Upload discarded")},onError:v=>{e(v.message||"Failed to discard","error")}}),y=mt({mutationFn:Vp.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=mt({mutationFn:Vp.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(St,{children:s.jsx(Nt,{className:"py-8 flex justify-center",children:s.jsx(dt,{className:"w-6 h-6 animate-spin text-bambu-green"})})}):!d||d.length===0?null:s.jsxs("div",{className:"mb-6",children:[s.jsxs(St,{className:"border-l-4 border-l-yellow-500",children:[s.jsx(er,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(pi,{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(Se,{variant:"primary",size:"sm",onClick:()=>r(!0),disabled:y.isPending,children:y.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx(es,{className:"w-4 h-4"}),"Archive All"]})}),s.jsx(Se,{variant:"secondary",size:"sm",onClick:()=>a(!0),disabled:x.isPending,children:x.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx(dn,{className:"w-4 h-4"}),"Discard All"]})})]})]})}),s.jsxs(Nt,{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(MKe,{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(Hn,{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(Hn,{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 qM(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Fb(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function hf(t){if(!t)return!1;const e=t.toLowerCase();return e.endsWith(".gcode")||e.includes(".gcode.")}function EKe({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=on(),{showToast:u}=qn(),d=RK(),[f,m]=w.useState(!1),[p,b]=w.useState(!1),[y,x]=w.useState(!1),[v,S]=w.useState(!1),[M,A]=w.useState(!1),[T,k]=w.useState(!1),[E,O]=w.useState([]),[C,D]=w.useState(!1),[U,L]=w.useState(!1),[q,P]=w.useState(!1),[W,K]=w.useState(!1),[V,Q]=w.useState(!1),[re,J]=w.useState(!1),[z,G]=w.useState(null),ne=w.useRef(null),ae=w.useRef(null),de=mt({mutationFn:I=>he.uploadSource3mf(t.id,I),onSuccess:I=>{c.invalidateQueries({queryKey:["archives"]}),u(`Source 3MF attached: ${I.filename}`)},onError:I=>{u(I.message||"Failed to upload source 3MF","error")}}),fe=mt({mutationFn:()=>he.deleteSource3mf(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u("Source 3MF removed")},onError:I=>{u(I.message||"Failed to remove source 3MF","error")}}),ie=mt({mutationFn:I=>he.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=mt({mutationFn:()=>he.deleteF3d(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u("F3D removed")},onError:I=>{u(I.message||"Failed to remove F3D","error")}}),me=mt({mutationFn:()=>he.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?(O(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=mt({mutationFn:I=>he.selectArchiveTimelapse(t.id,I),onSuccess:I=>{c.invalidateQueries({queryKey:["archives"]}),u(`Timelapse attached: ${I.filename}`),k(!1),O([])},onError:I=>{u(I.message||"Failed to attach timelapse","error")}}),ye=mt({mutationFn:()=>he.deleteArchive(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u("Archive deleted")},onError:()=>{u("Failed to delete archive","error")}}),le=mt({mutationFn:()=>he.toggleFavorite(t.id),onSuccess:I=>{c.invalidateQueries({queryKey:["archives"]}),u(I.is_favorite?"Added to favorites":"Removed from favorites")}}),{data:$e}=ut({queryKey:["archive-folders",t.id],queryFn:()=>he.getLibraryFoldersByArchive(t.id)}),H=mt({mutationFn:I=>he.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")}}),ee=I=>{I.preventDefault(),G({x:I.clientX,y:I.clientY})},B=[...hf(t.filename)?[{label:"Print",icon:s.jsx(qr,{className:"w-4 h-4"}),onClick:()=>b(!0)},{label:"Schedule",icon:s.jsx(oi,{className:"w-4 h-4"}),onClick:()=>K(!0)},{label:"Open in Bambu Studio",icon:s.jsx(zr,{className:"w-4 h-4"}),onClick:()=>{const I=t.print_name||t.filename||"model",ce=`${window.location.origin}${he.getArchiveForSlicer(t.id,I)}`;Zc(ce)}}]:[{label:"Slice",icon:s.jsx(zr,{className:"w-4 h-4"}),onClick:()=>{const I=t.print_name||t.filename||"model",ce=`${window.location.origin}${he.getArchiveForSlicer(t.id,I)}`;Zc(ce)}}],{label:t.external_url?"External Link":"View on MakerWorld",icon:s.jsx($d,{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(Hs,{className:"w-4 h-4"}),onClick:()=>m(!0)},{label:"View Timelapse",icon:s.jsx(Bd,{className:"w-4 h-4"}),onClick:()=>A(!0),disabled:!t.timelapse_path},{label:"Scan for Timelapse",icon:s.jsx(U1,{className:"w-4 h-4"}),onClick:()=>me.mutate(),disabled:!t.printer_id||!!t.timelapse_path||me.isPending},{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?"Download Source 3MF":"Upload Source 3MF",icon:s.jsx(L1,{className:"w-4 h-4"}),onClick:()=>{if(t.source_3mf_path){const I=document.createElement("a");I.href=he.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(pi,{className:"w-4 h-4"}),onClick:()=>ne.current?.click()},{label:"Remove Source 3MF",icon:s.jsx(dn,{className:"w-4 h-4"}),onClick:()=>Q(!0),danger:!0}]:[],{label:t.f3d_path?"Replace F3D":"Upload F3D",icon:s.jsx(Hs,{className:"w-4 h-4"}),onClick:()=>ae.current?.click()},...t.f3d_path?[{label:"Download F3D",icon:s.jsx(Hr,{className:"w-4 h-4"}),onClick:()=>{const I=document.createElement("a");I.href=he.getF3dDownloadUrl(t.id),I.download=`${t.print_name||t.filename}.f3d`,I.click()}},{label:"Remove F3D",icon:s.jsx(dn,{className:"w-4 h-4"}),onClick:()=>J(!0),danger:!0}]:[],{label:"",divider:!0,onClick:()=>{}},{label:"Download",icon:s.jsx(Hr,{className:"w-4 h-4"}),onClick:()=>{const I=document.createElement("a");I.href=he.getArchiveDownload(t.id),I.download=`${t.print_name||t.filename}.3mf`,I.click()}},{label:"Copy Download Link",icon:s.jsx(ll,{className:"w-4 h-4"}),onClick:()=>{const I=`${window.location.origin}${he.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(MK,{className:"w-4 h-4"}),onClick:()=>D(!0)},{label:`View Photos${t.photos?.length?` (${t.photos.length})`:""}`,icon:s.jsx(Hf,{className:"w-4 h-4"}),onClick:()=>L(!0),disabled:!t.photos?.length},{label:"Project Page",icon:s.jsx(Za,{className:"w-4 h-4"}),onClick:()=>P(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?"Remove from Favorites":"Add to Favorites",icon:s.jsx(Wf,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>le.mutate()},{label:"Edit",icon:s.jsx(la,{className:"w-4 h-4"}),onClick:()=>S(!0)},...t.project_id&&t.project_name?[{label:`Go to Project: ${t.project_name}`,icon:s.jsx(Ta,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:"Add to Project",icon:s.jsx(Ta,{className:"w-4 h-4"}),onClick:()=>{},submenu:(()=>{const I=[];if(t.project_id&&I.push({label:"Remove from Project",icon:s.jsx(Vt,{className:"w-4 h-4"}),onClick:()=>H.mutate(null)}),!a)I.push({label:"Loading...",icon:s.jsx(dt,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const ce=a.filter(Te=>Te.status==="active");ce.length===0?I.push({label:"No projects available",icon:s.jsx(Ta,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):ce.forEach(Te=>{I.push({label:Te.name,icon:s.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:Te.color||"#888"}}),onClick:()=>H.mutate(Te.id),disabled:t.project_id===Te.id})})}return I})()},{label:n?"Deselect":"Select",icon:n?s.jsx(Lo,{className:"w-4 h-4"}):s.jsx(Io,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:"Delete",icon:s.jsx(dn,{className:"w-4 h-4"}),onClick:()=>x(!0),danger:!0}];return s.jsxs(St,{"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:ee,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(Lo,{className:"w-5 h-5 text-bambu-green"}):s.jsx(Io,{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:he.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(Ny,{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();G({x:ce.left,y:ce.bottom+4})},title:"Right-click for more options",children:s.jsx(zd,{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(Wf,{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(ll,{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",Te=`${window.location.origin}${he.getSource3mfForSlicer(t.id,ce)}`;Zc(Te)},title:"Open source 3MF in Bambu Studio (right-click for more options)",children:s.jsx(L1,{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=he.getF3dDownloadUrl(t.id)},title:"Download Fusion 360 design file",children:s.jsx(Hs,{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(),A(!0)},title:"View timelapse",children:s.jsx(Bd,{className:"w-4 h-4 text-bambu-green"})}),t.photos&&t.photos.length>0&&s.jsxs("button",{className:`absolute bottom-2 ${t.timelapse_path?"right-12":"right-2"} p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors`,onClick:I=>{I.stopPropagation(),L(!0)},title:`View ${t.photos.length} photo${t.photos.length>1?"s":""}`,children:[s.jsx(Hf,{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})]}),$e&&$e.length>0&&s.jsx(bs,{to:`/files?folder=${$e[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: ${$e[0].name}`,style:{left:t.source_3mf_path?t.f3d_path?"5.5rem":"3rem":t.f3d_path?"3rem":"0.5rem"},children:s.jsx(cl,{className:"w-4 h-4 text-yellow-400"})})]}),s.jsxs(Nt,{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 ${hf(t.filename)?"bg-bambu-green/20 text-bambu-green":"bg-orange-500/20 text-orange-400"}`,title:hf(t.filename)?"Sliced file - ready to print":"Source file only - no AMS mapping available",children:hf(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: ${Fb(t.print_time_seconds||0)}
- Actual: ${Fb(t.actual_time_seconds||0)}
- Accuracy: ${t.time_accuracy.toFixed(0)}%`:t.actual_time_seconds?`Actual: ${Fb(t.actual_time_seconds)}`:`Estimated: ${Fb(t.print_time_seconds||0)}`,children:[s.jsx(Zn,{className:"w-3 h-3"}),Fb(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(Jl,{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(ul,{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(Hs,{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(EK,{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:wg(t.created_at,l)}),s.jsx("span",{children:qM(t.file_size)})]}),s.jsxs("div",{className:"flex gap-1 mt-3",children:[hf(t.filename)?s.jsxs(s.Fragment,{children:[s.jsxs(Se,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>b(!0),children:[s.jsx(qr,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{className:"hidden sm:inline",children:"Reprint"})]}),s.jsx(Se,{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}${he.getArchiveForSlicer(t.id,I)}`;Zc(ce)},title:"Open in Bambu Studio",children:s.jsx(zr,{className:"w-3 h-3 sm:w-4 sm:h-4"})})]}):s.jsxs(Se,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>{const I=t.print_name||t.filename||"model",ce=`${window.location.origin}${he.getArchiveForSlicer(t.id,I)}`;Zc(ce)},title:"Open in Bambu Studio to slice",children:[s.jsx(zr,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{className:"hidden sm:inline",children:"Slice"})]}),s.jsx(Se,{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($d,{className:`w-3 h-3 sm:w-4 sm:h-4 ${!t.external_url&&!t.makerworld_url?"opacity-20":""}`})}),s.jsx(Se,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>m(!0),title:"3D Preview",children:s.jsx(Hs,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),s.jsx(Se,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const I=document.createElement("a");I.href=he.getArchiveDownload(t.id),I.download=`${t.print_name||t.filename}.3mf`,I.click()},title:"Download",children:s.jsx(Hr,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),s.jsx(Se,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>S(!0),title:"Edit",children:s.jsx(la,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),s.jsx(Se,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>x(!0),title:"Delete",children:s.jsx(dn,{className:"w-3 h-3 sm:w-4 sm:h-4 text-red-400"})})]})]}),v&&s.jsx(Nte,{archive:t,onClose:()=>S(!1)}),f&&s.jsx(_te,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>m(!1)}),p&&s.jsx(ch,{mode:"reprint",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>b(!1)}),y&&s.jsx(Hn,{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:()=>{ye.mutate(),x(!1)},onCancel:()=>x(!1)}),V&&s.jsx(Hn,{title:"Remove Source 3MF",message:`Are you sure you want to remove the source 3MF file from "${t.print_name||t.filename}"? This will delete the original slicer project file.`,confirmText:"Remove",variant:"danger",onConfirm:()=>{fe.mutate(),Q(!1)},onCancel:()=>Q(!1)}),re&&s.jsx(Hn,{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(),J(!1)},onCancel:()=>J(!1)}),z&&s.jsx(Ete,{x:z.x,y:z.y,items:B,onClose:()=>G(null)}),M&&t.timelapse_path&&s.jsx(pie,{src:he.getArchiveTimelapse(t.id),title:`${t.print_name||t.filename} - Timelapse`,downloadFilename:`${t.print_name||t.filename}_timelapse.mp4`,archiveId:t.id,onClose:()=>A(!1),onEdit:()=>{c.invalidateQueries({queryKey:["archives"]}),A(!1)}}),T&&E.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),O([])},className:"text-gray-400 hover:text-white p-1",children:s.jsx(Vt,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:E.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(Bd,{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:[qM(I.size),I.mtime&&` • ${wg(I.mtime,l)}`]})]})]},I.name))}),s.jsx("div",{className:"p-4 border-t border-gray-700",children:s.jsx(Se,{variant:"secondary",onClick:()=>{k(!1),O([])},className:"w-full",children:"Cancel"})})]})}),C&&s.jsx(Ate,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>D(!1)}),U&&t.photos&&t.photos.length>0&&s.jsx(Tte,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>L(!1),onDelete:async I=>{try{await he.deleteArchivePhoto(t.id,I),c.invalidateQueries({queryKey:["archives"]}),u("Photo deleted")}catch{u("Failed to delete photo","error")}}}),q&&s.jsx(mie,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>P(!1)}),W&&s.jsx(ch,{mode:"add-to-queue",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>K(!1)}),s.jsx("input",{ref:ne,type:"file",accept:".3mf",className:"hidden",onChange:I=>{const ce=I.target.files?.[0];ce&&de.mutate(ce),I.target.value=""}}),s.jsx("input",{ref:ae,type:"file",accept:".f3d",className:"hidden",onChange:I=>{const ce=I.target.files?.[0];ce&&ie.mutate(ce),I.target.value=""}})]})}function AKe({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i,projects:a,isHighlighted:o}){const l=on(),{showToast:c}=qn(),[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,A]=w.useState(!1),[T,k]=w.useState(!1),[E,O]=w.useState([]),[C,D]=w.useState(!1),[U,L]=w.useState(!1),[q,P]=w.useState(!1),[W,K]=w.useState(!1),[V,Q]=w.useState(!1),[re,J]=w.useState(null),z=w.useRef(null),G=w.useRef(null),ne=mt({mutationFn:X=>he.uploadSource3mf(t.id,X),onSuccess:X=>{l.invalidateQueries({queryKey:["archives"]}),c(`Source 3MF attached: ${X.filename}`)},onError:X=>{c(X.message||"Failed to upload source 3MF","error")}}),ae=mt({mutationFn:()=>he.deleteSource3mf(t.id),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),c("Source 3MF removed")},onError:X=>{c(X.message||"Failed to remove source 3MF","error")}}),de=mt({mutationFn:X=>he.uploadF3d(t.id,X),onSuccess:X=>{l.invalidateQueries({queryKey:["archives"]}),c(`F3D attached: ${X.filename}`)},onError:X=>{c(X.message||"Failed to upload F3D","error")}}),fe=mt({mutationFn:()=>he.deleteF3d(t.id),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),c("F3D removed")},onError:X=>{c(X.message||"Failed to remove F3D","error")}}),ie=mt({mutationFn:()=>he.scanArchiveTimelapse(t.id),onSuccess:X=>{X.status==="attached"?(l.invalidateQueries({queryKey:["archives"]}),c(`Timelapse attached: ${X.filename}`)):X.status==="exists"?c("Timelapse already attached"):X.status==="not_found"&&X.available_files&&X.available_files.length>0?(O(X.available_files),k(!0)):c(X.message||"No matching timelapse found","warning")},onError:X=>{c(X.message||"Failed to scan for timelapse","error")}}),Ae=mt({mutationFn:X=>he.selectArchiveTimelapse(t.id,X),onSuccess:X=>{l.invalidateQueries({queryKey:["archives"]}),c(`Timelapse attached: ${X.filename}`),k(!1),O([])},onError:X=>{c(X.message||"Failed to attach timelapse","error")}}),me=mt({mutationFn:()=>he.deleteArchive(t.id),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),c("Archive deleted")},onError:()=>{c("Failed to delete archive","error")}}),Ne=mt({mutationFn:()=>he.toggleFavorite(t.id),onSuccess:X=>{l.invalidateQueries({queryKey:["archives"]}),c(X.is_favorite?"Added to favorites":"Removed from favorites")}}),{data:ye}=ut({queryKey:["archive-folders",t.id],queryFn:()=>he.getLibraryFoldersByArchive(t.id)}),le=mt({mutationFn:X=>he.updateArchive(t.id,{project_id:X}),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),l.invalidateQueries({queryKey:["projects"]}),c("Project updated")},onError:()=>{c("Failed to update project","error")}}),$e=X=>{X.preventDefault(),J({x:X.clientX,y:X.clientY})},ee=[...hf(t.filename)?[{label:"Print",icon:s.jsx(qr,{className:"w-4 h-4"}),onClick:()=>b(!0)},{label:"Schedule",icon:s.jsx(oi,{className:"w-4 h-4"}),onClick:()=>x(!0)},{label:"Open in Bambu Studio",icon:s.jsx(zr,{className:"w-4 h-4"}),onClick:()=>{const X=t.print_name||t.filename||"model",B=`${window.location.origin}${he.getArchiveForSlicer(t.id,X)}`;Zc(B)}}]:[{label:"Slice",icon:s.jsx(zr,{className:"w-4 h-4"}),onClick:()=>{const X=t.print_name||t.filename||"model",B=`${window.location.origin}${he.getArchiveForSlicer(t.id,X)}`;Zc(B)}}],{label:t.external_url?"External Link":"View on MakerWorld",icon:s.jsx($d,{className:"w-4 h-4"}),onClick:()=>{const X=t.external_url||t.makerworld_url;X&&window.open(X,"_blank")},disabled:!t.external_url&&!t.makerworld_url},{label:"",divider:!0,onClick:()=>{}},{label:"3D Preview",icon:s.jsx(Hs,{className:"w-4 h-4"}),onClick:()=>S(!0)},{label:"View Timelapse",icon:s.jsx(Bd,{className:"w-4 h-4"}),onClick:()=>A(!0),disabled:!t.timelapse_path},{label:"Scan for Timelapse",icon:s.jsx(U1,{className:"w-4 h-4"}),onClick:()=>ie.mutate(),disabled:!t.printer_id||!!t.timelapse_path||ie.isPending},{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?"Download Source 3MF":"Upload Source 3MF",icon:s.jsx(L1,{className:"w-4 h-4"}),onClick:()=>{if(t.source_3mf_path){const X=document.createElement("a");X.href=he.getSource3mfDownloadUrl(t.id),X.download=`${t.print_name||t.filename}_source.3mf`,X.click()}else z.current?.click()}},...t.source_3mf_path?[{label:"Replace Source 3MF",icon:s.jsx(pi,{className:"w-4 h-4"}),onClick:()=>z.current?.click()},{label:"Remove Source 3MF",icon:s.jsx(dn,{className:"w-4 h-4"}),onClick:()=>K(!0),danger:!0}]:[],{label:t.f3d_path?"Replace F3D":"Upload F3D",icon:s.jsx(Hs,{className:"w-4 h-4"}),onClick:()=>G.current?.click()},...t.f3d_path?[{label:"Download F3D",icon:s.jsx(Hr,{className:"w-4 h-4"}),onClick:()=>{const X=document.createElement("a");X.href=he.getF3dDownloadUrl(t.id),X.download=`${t.print_name||t.filename}.f3d`,X.click()}},{label:"Remove F3D",icon:s.jsx(dn,{className:"w-4 h-4"}),onClick:()=>Q(!0),danger:!0}]:[],{label:"",divider:!0,onClick:()=>{}},{label:"Download",icon:s.jsx(Hr,{className:"w-4 h-4"}),onClick:()=>{const X=document.createElement("a");X.href=he.getArchiveDownload(t.id),X.download=`${t.print_name||t.filename}.3mf`,X.click()}},{label:"Copy Download Link",icon:s.jsx(ll,{className:"w-4 h-4"}),onClick:()=>{const X=`${window.location.origin}${he.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(X).then(()=>{c("Link copied to clipboard")}).catch(()=>{c("Failed to copy link","error")})}},{label:"QR Code",icon:s.jsx(MK,{className:"w-4 h-4"}),onClick:()=>D(!0)},{label:`View Photos${t.photos?.length?` (${t.photos.length})`:""}`,icon:s.jsx(Hf,{className:"w-4 h-4"}),onClick:()=>L(!0),disabled:!t.photos?.length},{label:"Project Page",icon:s.jsx(Za,{className:"w-4 h-4"}),onClick:()=>P(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?"Remove from Favorites":"Add to Favorites",icon:s.jsx(Wf,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>Ne.mutate()},{label:"Edit",icon:s.jsx(la,{className:"w-4 h-4"}),onClick:()=>d(!0)},...t.project_id&&t.project_name?[{label:`Go to Project: ${t.project_name}`,icon:s.jsx(Ta,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:"Add to Project",icon:s.jsx(Ta,{className:"w-4 h-4"}),onClick:()=>{},submenu:(()=>{const X=[];if(t.project_id&&X.push({label:"Remove from Project",icon:s.jsx(Vt,{className:"w-4 h-4"}),onClick:()=>le.mutate(null)}),!a)X.push({label:"Loading...",icon:s.jsx(dt,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const B=a.filter(I=>I.status==="active");B.length===0?X.push({label:"No projects available",icon:s.jsx(Ta,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):B.forEach(I=>{X.push({label:I.name,icon:s.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:I.color||"#888"}}),onClick:()=>le.mutate(I.id),disabled:t.project_id===I.id})})}return X})()},{label:n?"Deselect":"Select",icon:n?s.jsx(Lo,{className:"w-4 h-4"}):s.jsx(Io,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:"Delete",icon:s.jsx(dn,{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:$e,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(Lo,{className:"w-4 h-4 text-bambu-green"}):s.jsx(Io,{className:"w-4 h-4 text-bambu-gray"})}),t.thumbnail_path?s.jsx("img",{src:he.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(Ny,{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(Bd,{className:"w-3.5 h-3.5 text-bambu-green flex-shrink-0"})}),ye&&ye.length>0&&s.jsx(bs,{to:`/files?folder=${ye[0].id}`,className:"flex-shrink-0",title:`Open folder: ${ye[0].name}`,onClick:X=>X.stopPropagation(),children:s.jsx(cl,{className:"w-3.5 h-3.5 text-yellow-400"})})]}),t.filament_type&&s.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:t.filament_type}),t.filament_color&&s.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:t.filament_color.split(",").map((X,B)=>s.jsx("div",{className:"w-2.5 h-2.5 rounded-full border border-white/20",style:{backgroundColor:X},title:X},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:_g(t.created_at)}),s.jsx("div",{className:"col-span-1 text-sm text-bambu-gray",children:qM(t.file_size)}),s.jsxs("div",{className:"col-span-2 flex justify-end gap-1",children:[s.jsx(Se,{variant:"ghost",size:"sm",onClick:()=>{const X=t.print_name||t.filename||"model",B=`${window.location.origin}${he.getArchiveForSlicer(t.id,X)}`;Zc(B)},title:"Open in Bambu Studio",children:s.jsx(zr,{className:"w-4 h-4"})}),(t.external_url||t.makerworld_url)&&s.jsx(Se,{variant:"ghost",size:"sm",onClick:()=>window.open(t.external_url||t.makerworld_url,"_blank"),title:t.external_url?"External Link":"MakerWorld",children:s.jsx($d,{className:"w-4 h-4"})}),s.jsx(Se,{variant:"ghost",size:"sm",onClick:()=>{const X=document.createElement("a");X.href=he.getArchiveDownload(t.id),X.download=`${t.print_name||t.filename}.3mf`,X.click()},title:"Download",children:s.jsx(Hr,{className:"w-4 h-4"})}),s.jsx(Se,{variant:"ghost",size:"sm",onClick:()=>d(!0),title:"Edit",children:s.jsx(la,{className:"w-4 h-4"})}),s.jsx(Se,{variant:"ghost",size:"sm",onClick:()=>m(!0),title:"Delete",children:s.jsx(dn,{className:"w-4 h-4 text-red-400"})}),s.jsx(Se,{variant:"ghost",size:"sm",onClick:X=>{const B=X.currentTarget.getBoundingClientRect();J({x:B.left,y:B.bottom+4})},title:"More options",children:s.jsx(zd,{className:"w-4 h-4"})})]})]}),u&&s.jsx(Nte,{archive:t,onClose:()=>d(!1)}),v&&s.jsx(_te,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>S(!1)}),p&&s.jsx(ch,{mode:"reprint",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>b(!1)}),f&&s.jsx(Hn,{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:()=>{me.mutate(),m(!1)},onCancel:()=>m(!1)}),W&&s.jsx(Hn,{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:()=>{ae.mutate(),K(!1)},onCancel:()=>K(!1)}),V&&s.jsx(Hn,{title:"Remove F3D",message:`Are you sure you want to remove the Fusion 360 design file from "${t.print_name||t.filename}"?`,confirmText:"Remove",variant:"danger",onConfirm:()=>{fe.mutate(),Q(!1)},onCancel:()=>Q(!1)}),re&&s.jsx(Ete,{x:re.x,y:re.y,items:ee,onClose:()=>J(null)}),M&&t.timelapse_path&&s.jsx(pie,{src:he.getArchiveTimelapse(t.id),title:`${t.print_name||t.filename} - Timelapse`,downloadFilename:`${t.print_name||t.filename}_timelapse.mp4`,archiveId:t.id,onClose:()=>A(!1),onEdit:()=>{l.invalidateQueries({queryKey:["archives"]}),A(!1)}}),T&&E.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),O([])},className:"text-gray-400 hover:text-white p-1",children:s.jsx(Vt,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:E.map(X=>s.jsxs("button",{onClick:()=>Ae.mutate(X.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:X.name}),s.jsxs("div",{className:"text-sm text-gray-400 flex gap-3",children:[s.jsx("span",{children:qM(X.size)}),X.mtime&&s.jsx("span",{children:_g(X.mtime)})]})]},X.name))})]})}),C&&s.jsx(Ate,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>D(!1)}),U&&t.photos&&s.jsx(Tte,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>L(!1),onDelete:async X=>{try{await he.deleteArchivePhoto(t.id,X),l.invalidateQueries({queryKey:["archives"]}),c("Photo deleted")}catch{c("Failed to delete photo","error")}}}),q&&s.jsx(mie,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>P(!1)}),y&&s.jsx(ch,{mode:"add-to-queue",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>x(!1)}),s.jsx("input",{ref:z,type:"file",accept:".3mf",className:"hidden",onChange:X=>{const B=X.target.files?.[0];B&&ne.mutate(B),X.target.value=""}}),s.jsx("input",{ref:G,type:"file",accept:".f3d",className:"hidden",onChange:X=>{const B=X.target.files?.[0];B&&de.mutate(B),X.target.value=""}})]})}const TKe=[{id:"all",label:"All Archives",icon:s.jsx(cl,{className:"w-4 h-4"})},{id:"recent",label:"Last 24 Hours",icon:s.jsx(Zn,{className:"w-4 h-4"})},{id:"this-week",label:"This Week",icon:s.jsx(oi,{className:"w-4 h-4"})},{id:"this-month",label:"This Month",icon:s.jsx(oi,{className:"w-4 h-4"})},{id:"favorites",label:"Favorites",icon:s.jsx(Wf,{className:"w-4 h-4"})},{id:"failed",label:"Failed Prints",icon:s.jsx(oa,{className:"w-4 h-4"})},{id:"duplicates",label:"Duplicates",icon:s.jsx(ll,{className:"w-4 h-4"})}];function CKe(){const t=on(),{showToast:e}=qn(),n=w.useRef(null),[r,i]=w.useState(""),[a,o]=w.useState(()=>{const se=localStorage.getItem("archiveFilterPrinter");return se?Number(se):null}),[l,c]=w.useState(()=>localStorage.getItem("archiveFilterMaterial")),[u,d]=w.useState(()=>{const se=localStorage.getItem("archiveFilterColors");return se?new Set(JSON.parse(se)):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,A]=w.useState(()=>localStorage.getItem("archiveFilterFileType")||"all"),[T,k]=w.useState(!1),[E,O]=w.useState([]),[C,D]=w.useState(!1),[U,L]=w.useState(new Set),[q,P]=w.useState(!1),[W,K]=w.useState(!1),[V,Q]=w.useState(!1),[re,J]=w.useState(!1),[z,G]=w.useState(()=>localStorage.getItem("archiveViewMode")||"grid"),[ne,ae]=w.useState(()=>localStorage.getItem("archiveSortBy")||"date-desc"),[de,fe]=w.useState(()=>localStorage.getItem("archiveCollection")||"all"),[ie,Ae]=w.useState(!1),[me,Ne]=w.useState(!1),[ye,le]=w.useState(!1),[$e,H]=w.useState(null);w.useEffect(()=>{if($e){const se=setTimeout(()=>{const xe=document.querySelector(`[data-archive-id="${$e}"]`);xe&&xe.scrollIntoView({behavior:"smooth",block:"center"})},100),je=setTimeout(()=>H(null),5e3);return()=>{clearTimeout(se),clearTimeout(je)}}},[$e]);const{data:ee,isLoading:X}=ut({queryKey:["archives",a],queryFn:()=>he.getArchives(a||void 0)}),{data:B}=ut({queryKey:["printers"],queryFn:he.getPrinters}),{data:I}=ut({queryKey:["projects"],queryFn:()=>he.getProjects()}),{data:ce}=ut({queryKey:["settings"],queryFn:he.getSettings}),Te=ce?.time_format||"system",Le=mt({mutationFn:async se=>(await Promise.all(se.map(je=>he.deleteArchive(je))),se.length),onSuccess:se=>{t.invalidateQueries({queryKey:["archives"]}),L(new Set),e(`${se} archive${se!==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",de)},[de]);const Ee=new Map(B?.map(se=>[se.id,se.name])||[]),$=[...new Set(ee?.flatMap(se=>se.filament_type?.split(", ")||[]).filter(Boolean)||[])].sort(),j=[...new Set(ee?.flatMap(se=>se.filament_color?.split(",")||[]).filter(Boolean)||[])],Y=[...new Set(ee?.flatMap(se=>se.tags?.split(",").map(je=>je.trim())||[]).filter(Boolean)||[])].sort(),ge=ee?.filter(se=>{const je=new Date,xe=Ni(se.created_at)||new Date(0);let Oe=!0;switch(de){case"recent":Oe=je.getTime()-xe.getTime()<1440*60*1e3;break;case"this-week":Oe=je.getTime()-xe.getTime()<10080*60*1e3;break;case"this-month":Oe=xe.getMonth()===je.getMonth()&&xe.getFullYear()===je.getFullYear();break;case"favorites":Oe=se.is_favorite===!0;break;case"failed":Oe=se.status==="failed"||se.status==="aborted";break;case"duplicates":Oe=se.duplicate_count>0;break}const Ue=(se.print_name||se.filename).toLowerCase().includes(r.toLowerCase()),Ce=!l||se.filament_type?.split(", ").includes(l),We=se.filament_color?.split(",")||[],pt=u.size===0||(f==="or"?We.some(Kt=>u.has(Kt)):[...u].every(Kt=>We.includes(Kt))),kt=de==="favorites"||!p||se.is_favorite,Lt=de==="failed"||!y||se.status!=="failed"&&se.status!=="aborted",ln=se.tags?.split(",").map(Kt=>Kt.trim())||[],Gt=!v||ln.includes(v),_n=hf(se.filename);return Oe&&Ue&&Ce&&pt&&kt&&Lt&&Gt&&(M==="all"||M==="gcode"&&_n||M==="source"&&!_n)}).sort((se,je)=>{switch(ne){case"date-desc":return(Ni(je.created_at)?.getTime()||0)-(Ni(se.created_at)?.getTime()||0);case"date-asc":return(Ni(se.created_at)?.getTime()||0)-(Ni(je.created_at)?.getTime()||0);case"name-asc":return(se.print_name||se.filename).localeCompare(je.print_name||je.filename);case"name-desc":return(je.print_name||je.filename).localeCompare(se.print_name||se.filename);case"size-desc":return je.file_size-se.file_size;case"size-asc":return se.file_size-je.file_size;default:return 0}}),we=q||U.size>0,ve=se=>{L(je=>{const xe=new Set(je);return xe.has(se)?xe.delete(se):xe.add(se),xe})},Ze=()=>{ge&&L(new Set(ge.map(se=>se.id)))},Ie=()=>{L(new Set),P(!1)},qe=se=>{d(je=>{const xe=new Set(je);return xe.has(se)?xe.delete(se):xe.add(se),xe})},Je=()=>{d(new Set)},Qe=()=>{i(""),o(null),c(null),b(!1),x(!1),S(null),A("all")},oe=r||a||l||p||y||v||M!=="all",te=w.useCallback(se=>{se.preventDefault(),se.dataTransfer.types.includes("Files")&&D(!0)},[]),Me=w.useCallback(se=>{se.preventDefault(),se.currentTarget===se.target&&D(!1)},[]),Fe=w.useCallback(se=>{se.preventDefault(),D(!1);const je=Array.from(se.dataTransfer.files).filter(xe=>xe.name.endsWith(".3mf"));je.length>0?(O(je),k(!0)):se.dataTransfer.files.length>0&&e("Only .3mf files are supported","warning")},[e]),ot=w.useCallback(se=>{const je=se.target;if(je.tagName==="INPUT"||je.tagName==="TEXTAREA"||je.isContentEditable){se.key==="Escape"&&je.blur();return}switch(se.key){case"/":se.preventDefault(),n.current?.focus();break;case"u":case"U":!se.metaKey&&!se.ctrlKey&&(se.preventDefault(),k(!0));break;case"Escape":we&&Ie();break}},[we]);return w.useEffect(()=>(document.addEventListener("keydown",ot),()=>document.removeEventListener("keydown",ot)),[ot]),s.jsxs("div",{className:"p-4 md:p-8 relative min-h-full",onDragOver:te,onDragLeave:Me,onDrop:Fe,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(pi,{className:"w-16 h-16 mx-auto mb-4 text-bambu-green"}),s.jsx("p",{className:"text-2xl font-semibold text-white mb-2",children:"Drop .3mf files here"}),s.jsx("p",{className:"text-bambu-gray",children:"Release to upload"})]})}),we&&s.jsxs("div",{className:"fixed bottom-6 left-1/2 -translate-x-1/2 z-40 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl px-4 py-3 flex items-center gap-4",children:[s.jsxs(Se,{variant:"secondary",size:"sm",onClick:Ie,children:[s.jsx(Vt,{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(Se,{variant:"secondary",size:"sm",onClick:Ze,children:"Select All"}),s.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),s.jsxs(Se,{variant:"secondary",size:"sm",onClick:()=>Q(!0),children:[s.jsx(vg,{className:"w-4 h-4"}),"Tags"]}),s.jsxs(Se,{variant:"secondary",size:"sm",onClick:()=>J(!0),children:[s.jsx(Ta,{className:"w-4 h-4"}),"Project"]}),s.jsxs(Se,{variant:"secondary",size:"sm",onClick:()=>{const se=Array.from(U);Promise.all(se.map(je=>he.toggleFavorite(je))).then(()=>{t.invalidateQueries({queryKey:["archives"]}),e(`Toggled favorites for ${se.length} archive${se.length!==1?"s":""}`)}).catch(()=>{e("Failed to update favorites","error")})},children:[s.jsx(Wf,{className:"w-4 h-4"}),"Favorite"]}),s.jsxs(Se,{size:"sm",className:"bg-red-500 hover:bg-red-600",onClick:()=>K(!0),children:[s.jsx(dn,{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:de,onChange:se=>fe(se.target.value),children:TKe.map(se=>s.jsx("option",{value:se.id,children:se.label},se.id))})]}),s.jsxs("p",{className:"text-bambu-gray",children:[ge?.length||0," of ",ee?.length||0," prints"]})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"relative",children:[s.jsxs(Se,{variant:"secondary",onClick:()=>Ae(!ie),disabled:me,children:[me?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(I1,{className:"w-4 h-4"}),"Export"]}),ie&&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:se,filename:je}=await he.exportArchives({format:"csv",printerId:a||void 0,status:de==="failed"?"failed":void 0,search:r||void 0}),xe=URL.createObjectURL(se),Oe=document.createElement("a");Oe.href=xe,Oe.download=je,Oe.click(),URL.revokeObjectURL(xe),e("Export downloaded")}catch{e("Export failed","error")}finally{Ne(!1)}},children:[s.jsx(Za,{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:se,filename:je}=await he.exportArchives({format:"xlsx",printerId:a||void 0,status:de==="failed"?"failed":void 0,search:r||void 0}),xe=URL.createObjectURL(se),Oe=document.createElement("a");Oe.href=xe,Oe.download=je,Oe.click(),URL.revokeObjectURL(xe),e("Export downloaded")}catch{e("Export failed","error")}finally{Ne(!1)}},children:[s.jsx(I1,{className:"w-4 h-4"}),"Export as Excel"]})]})]}),U.size>=2&&U.size<=5&&s.jsxs(Se,{variant:"secondary",onClick:()=>le(!0),children:[s.jsx(rg,{className:"w-4 h-4"}),"Compare (",U.size,")"]}),!we&&s.jsxs(Se,{variant:"secondary",onClick:()=>P(!0),children:[s.jsx(Lo,{className:"w-4 h-4"}),"Select"]}),s.jsxs(Se,{onClick:()=>k(!0),children:[s.jsx(pi,{className:"w-4 h-4"}),"Upload 3MF"]})]})]}),s.jsx(St,{className:"mb-6",children:s.jsxs(Nt,{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(Ea,{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:se=>i(se.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(sN,{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:se=>o(se.target.value?Number(se.target.value):null),children:[s.jsx("option",{value:"",children:"All Printers"}),B?.map(se=>s.jsx("option",{value:se.id,children:se.name},se.id))]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(Jl,{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:se=>c(se.target.value||null),children:[s.jsx("option",{value:"",children:"All Materials"}),$.map(se=>s.jsx("option",{value:se,children:se},se))]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(L1,{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:se=>A(se.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(Wf,{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(oa,{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(vg,{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:se=>S(se.target.value||null),children:[s.jsx("option",{value:"",children:"All Tags"}),Y.map(se=>s.jsx("option",{value:se,children:se},se))]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(mK,{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:se=>ae(se.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:()=>G("grid"),title:"Grid view",children:s.jsx(uN,{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:()=>G("list"),title:"List view",children:s.jsx(dN,{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:()=>G("calendar"),title:"Calendar view",children:s.jsx(Jue,{className:"w-4 h-4"})})]})]}),oe&&s.jsxs(Se,{variant:"ghost",size:"sm",onClick:Qe,className:"text-bambu-gray hover:text-white",children:[s.jsx(Vt,{className:"w-4 h-4"}),"Reset"]})]}),j.length>0&&s.jsxs("div",{className:"flex items-center gap-3 mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Colors:"}),u.size>1&&s.jsx("button",{onClick:()=>m(se=>se==="or"?"and":"or"),className:`px-2 py-0.5 text-xs rounded transition-colors ${f==="and"?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:f==="or"?"Match ANY selected color":"Match ALL selected colors",children:f.toUpperCase()}),s.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:j.map(se=>s.jsx("button",{onClick:()=>qe(se),className:`w-6 h-6 rounded-full border-2 transition-all ${u.has(se)?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:se},title:se},se))}),u.size>0&&s.jsxs("button",{onClick:Je,className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1",children:[s.jsx(Vt,{className:"w-3 h-3"}),"Clear"]})]})]})}),s.jsx(NKe,{}),X?s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading archives..."}):ge?.length===0?s.jsx(St,{children:s.jsxs(Nt,{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(St,{className:"p-6",children:s.jsx(p$e,{archives:ge||[],onArchiveClick:se=>{i(""),G("grid"),H(se.id)},highlightedArchiveId:$e})}):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:ge?.map(se=>s.jsx(EKe,{archive:se,printerName:se.printer_id?Ee.get(se.printer_id)||"Unknown":"No Printer",isSelected:U.has(se.id),onSelect:ve,selectionMode:we,projects:I,isHighlighted:se.id===$e,timeFormat:Te},se.id))}):z==="list"?s.jsx(St,{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"})]}),ge?.map(se=>s.jsx(AKe,{archive:se,printerName:se.printer_id?Ee.get(se.printer_id)||"Unknown":"No Printer",isSelected:U.has(se.id),onSelect:ve,selectionMode:we,projects:I,isHighlighted:se.id===$e},se.id))]})}):null,T&&s.jsx(s$e,{onClose:()=>{k(!1),O([])},initialFiles:E}),W&&s.jsx(Hn,{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:()=>{Le.mutate(Array.from(U)),K(!1)},onCancel:()=>K(!1)}),V&&s.jsx(c$e,{selectedIds:Array.from(U),existingTags:Y,onClose:()=>Q(!1)}),re&&s.jsx(u$e,{selectedIds:Array.from(U),onClose:()=>J(!1)}),ye&&U.size>=2&&U.size<=5&&s.jsx(vKe,{archiveIds:Array.from(U),onClose:()=>{le(!1),L(new Set),P(!1)}})]})}function kKe(){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 LE=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function xx(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function mI(t){return"nodeType"in t}function ks(t){var e,n;return t?xx(t)?t:mI(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function pI(t){const{Document:e}=ks(t);return t instanceof e}function iv(t){return xx(t)?!1:t instanceof ks(t).HTMLElement}function gie(t){return t instanceof ks(t).SVGElement}function bx(t){return t?xx(t)?t.document:mI(t)?pI(t)?t:iv(t)||gie(t)?t.ownerDocument:document:document:document}const lc=LE?w.useLayoutEffect:w.useEffect;function gI(t){const e=w.useRef(t);return lc(()=>{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 jKe(){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 by(t,e){e===void 0&&(e=[t]);const n=w.useRef(t);return lc(()=>{n.current!==t&&(n.current=t)},e),n}function av(t,e){const n=w.useRef();return w.useMemo(()=>{const r=t(n.current);return n.current=r,r},[...e])}function KM(t){const e=gI(t),n=w.useRef(null),r=w.useCallback(i=>{i!==n.current&&e?.(i,n.current),n.current=i},[]);return[n,r]}function xD(t){const e=w.useRef();return w.useEffect(()=>{e.current=t},[t]),e.current}let Hj={};function sv(t,e){return w.useMemo(()=>{if(e)return e;const n=Hj[t]==null?0:Hj[t]+1;return Hj[t]=n,t+"-"+n},[t,e])}function xie(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 xg=xie(1),yy=xie(-1);function PKe(t){return"clientX"in t&&"clientY"in t}function xI(t){if(!t)return!1;const{KeyboardEvent:e}=ks(t.target);return e&&t instanceof e}function RKe(t){if(!t)return!1;const{TouchEvent:e}=ks(t.target);return e&&t instanceof e}function bD(t){if(RKe(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 PKe(t)?{x:t.clientX,y:t.clientY}:null}const qg=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[qg.Translate.toString(t),qg.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:r}=t;return e+" "+n+"ms "+r}}}),eq="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function DKe(t){return t.matches(eq)?t:t.querySelector(eq)}const OKe={display:"none"};function LKe(t){let{id:e,value:n}=t;return Ur.createElement("div",{id:e,style:OKe},n)}function IKe(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 FKe(){const[t,e]=w.useState("");return{announce:w.useCallback(r=>{r!=null&&e(r)},[]),announcement:t}}const bie=w.createContext(null);function UKe(t){const e=w.useContext(bie);w.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function zKe(){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 BKe={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.
- `},$Ke={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 HKe(t){let{announcements:e=$Ke,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=BKe}=t;const{announce:a,announcement:o}=FKe(),l=sv("DndLiveRegion"),[c,u]=w.useState(!1);if(w.useEffect(()=>{u(!0)},[]),UKe(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(LKe,{id:r,value:i.draggable}),Ur.createElement(IKe,{id:l,announcement:o}));return n?Jc.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 XM(){}function YM(t,e){return w.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function yie(){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 ml=Object.freeze({x:0,y:0});function vie(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function _ie(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return n-r}function VKe(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return r-n}function tq(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 wie(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function nq(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 Sie=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=nq(e,e.left,e.top),a=[];for(const o of r){const{id:l}=o,c=n.get(l);if(c){const u=vie(nq(c),i);a.push({id:l,data:{droppableContainer:o,value:u}})}}return a.sort(_ie)},GKe=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=tq(e),a=[];for(const o of r){const{id:l}=o,c=n.get(l);if(c){const u=tq(c),d=i.reduce((m,p,b)=>m+vie(u[b],p),0),f=Number((d/4).toFixed(4));a.push({id:l,data:{droppableContainer:o,value:f}})}}return a.sort(_ie)};function WKe(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 qKe=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=WKe(l,e);c>0&&i.push({id:o,data:{droppableContainer:a,value:c}})}}return i.sort(VKe)};function KKe(t,e,n){return{...t,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function Mie(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:ml}function XKe(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 YKe=XKe(1);function ZKe(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 QKe(t,e,n){const r=ZKe(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 JKe={ignoreTransform:!1};function yx(t,e){e===void 0&&(e=JKe);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:u,transformOrigin:d}=ks(t).getComputedStyle(t);u&&(n=QKe(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 rq(t){return yx(t,{ignoreTransform:!0})}function eXe(t){const e=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function tXe(t,e){return e===void 0&&(e=ks(t).getComputedStyle(t)),e.position==="fixed"}function nXe(t,e){e===void 0&&(e=ks(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 IE(t,e){const n=[];function r(i){if(e!=null&&n.length>=e||!i)return n;if(pI(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!iv(i)||gie(i)||n.includes(i))return n;const a=ks(t).getComputedStyle(i);return i!==t&&nXe(i,a)&&n.push(i),tXe(i,a)?n:r(i.parentNode)}return t?r(t):n}function Nie(t){const[e]=IE(t,1);return e??null}function Vj(t){return!LE||!t?null:xx(t)?t:mI(t)?pI(t)||t===bx(t).scrollingElement?window:iv(t)?t:null:null}function Eie(t){return xx(t)?t.scrollX:t.scrollLeft}function Aie(t){return xx(t)?t.scrollY:t.scrollTop}function yD(t){return{x:Eie(t),y:Aie(t)}}var Ji;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Ji||(Ji={}));function Tie(t){return!LE||!t?!1:t===document.scrollingElement}function Cie(t){const e={x:0,y:0},n=Tie(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 rXe={x:.2,y:.2};function iXe(t,e,n,r,i){let{top:a,left:o,right:l,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=rXe);const{isTop:u,isBottom:d,isLeft:f,isRight:m}=Cie(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=Ji.Backward,b.y=r*Math.abs((e.top+y.height-a)/y.height)):!d&&c>=e.bottom-y.height&&(p.y=Ji.Forward,b.y=r*Math.abs((e.bottom-y.height-c)/y.height)),!m&&l>=e.right-y.width?(p.x=Ji.Forward,b.x=r*Math.abs((e.right-y.width-l)/y.width)):!f&&o<=e.left+y.width&&(p.x=Ji.Backward,b.x=r*Math.abs((e.left+y.width-o)/y.width)),{direction:p,speed:b}}function aXe(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 kie(t){return t.reduce((e,n)=>xg(e,yD(n)),ml)}function sXe(t){return t.reduce((e,n)=>e+Eie(n),0)}function oXe(t){return t.reduce((e,n)=>e+Aie(n),0)}function lXe(t,e){if(e===void 0&&(e=yx),!t)return;const{top:n,left:r,bottom:i,right:a}=e(t);Nie(t)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const cXe=[["x",["left","right"],sXe],["y",["top","bottom"],oXe]];class bI{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=IE(n),i=kie(r);this.rect={...e},this.width=e.width,this.height=e.height;for(const[a,o,l]of cXe)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 S0{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 uXe(t){const{EventTarget:e}=ks(t);return t instanceof e?t:bx(t)}function Gj(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 So;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(So||(So={}));function iq(t){t.preventDefault()}function dXe(t){t.stopPropagation()}var Bn;(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"})(Bn||(Bn={}));const jie={start:[Bn.Space,Bn.Enter],cancel:[Bn.Esc],end:[Bn.Space,Bn.Enter,Bn.Tab]},hXe=(t,e)=>{let{currentCoordinates:n}=e;switch(t.code){case Bn.Right:return{...n,x:n.x+25};case Bn.Left:return{...n,x:n.x-25};case Bn.Down:return{...n,y:n.y+25};case Bn.Up:return{...n,y:n.y-25}}};class FE{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 S0(bx(n)),this.windowListeners=new S0(ks(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(So.Resize,this.handleCancel),this.windowListeners.add(So.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(So.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,r=e.node.current;r&&lXe(r),n(ml)}handleKeyDown(e){if(xI(e)){const{active:n,context:r,options:i}=this.props,{keyboardCodes:a=jie,coordinateGetter:o=hXe,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}:ml;this.referenceCoordinates||(this.referenceCoordinates=d);const f=o(e,{active:n,context:r.current,currentCoordinates:d});if(f){const m=yy(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:A,maxScroll:T,minScroll:k}=Cie(y),E=aXe(y),O={x:Math.min(x===Bn.Right?E.right-E.width/2:E.right,Math.max(x===Bn.Right?E.left:E.left+E.width/2,f.x)),y:Math.min(x===Bn.Down?E.bottom-E.height/2:E.bottom,Math.max(x===Bn.Down?E.top:E.top+E.height/2,f.y))},C=x===Bn.Right&&!S||x===Bn.Left&&!M,D=x===Bn.Down&&!A||x===Bn.Up&&!v;if(C&&O.x!==f.x){const U=y.scrollLeft+m.x,L=x===Bn.Right&&U<=T.x||x===Bn.Left&&U>=k.x;if(L&&!m.y){y.scrollTo({left:U,behavior:l});return}L?p.x=y.scrollLeft-U:p.x=x===Bn.Right?y.scrollLeft-T.x:y.scrollLeft-k.x,p.x&&y.scrollBy({left:-p.x,behavior:l});break}else if(D&&O.y!==f.y){const U=y.scrollTop+m.y,L=x===Bn.Down&&U<=T.y||x===Bn.Up&&U>=k.y;if(L&&!m.x){y.scrollTo({top:U,behavior:l});return}L?p.y=y.scrollTop-U:p.y=x===Bn.Down?y.scrollTop-T.y:y.scrollTop-k.y,p.y&&y.scrollBy({top:-p.y,behavior:l});break}}this.handleMove(e,xg(yy(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()}}FE.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:r=jie,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 aq(t){return!!(t&&"distance"in t)}function sq(t){return!!(t&&"delay"in t)}class yI{constructor(e,n,r){var i;r===void 0&&(r=uXe(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=bx(o),this.documentListeners=new S0(this.document),this.listeners=new S0(r),this.windowListeners=new S0(ks(o)),this.initialCoordinates=(i=bD(a))!=null?i:ml,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(So.Resize,this.handleCancel),this.windowListeners.add(So.DragStart,iq),this.windowListeners.add(So.VisibilityChange,this.handleCancel),this.windowListeners.add(So.ContextMenu,iq),this.documentListeners.add(So.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(sq(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(aq(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(So.Click,dXe,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(So.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=bD(e))!=null?n:ml,u=yy(i,c);if(!r&&l){if(aq(l)){if(l.tolerance!=null&&Gj(u,l.tolerance))return this.handleCancel();if(Gj(u,l.distance))return this.handleStart()}if(sq(l)&&Gj(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===Bn.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const fXe={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class UE extends yI{constructor(e){const{event:n}=e,r=bx(n.target);super(e,fXe,r)}}UE.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 mXe={move:{name:"mousemove"},end:{name:"mouseup"}};var vD;(function(t){t[t.RightClick=2]="RightClick"})(vD||(vD={}));class pXe extends yI{constructor(e){super(e,mXe,bx(e.event.target))}}pXe.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return n.button===vD.RightClick?!1:(r?.({event:n}),!0)}}];const Wj={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class gXe extends yI{constructor(e){super(e,Wj)}static setup(){return window.addEventListener(Wj.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Wj.move.name,e)};function e(){}}}gXe.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 M0;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(M0||(M0={}));var ZM;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(ZM||(ZM={}));function xXe(t){let{acceleration:e,activator:n=M0.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:l=ZM.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:d,delta:f,threshold:m}=t;const p=yXe({delta:f,disabled:!a}),[b,y]=jKe(),x=w.useRef({x:0,y:0}),v=w.useRef({x:0,y:0}),S=w.useMemo(()=>{switch(n){case M0.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case M0.DraggableRect:return i}},[n,i,c]),M=w.useRef(null),A=w.useCallback(()=>{const k=M.current;if(!k)return;const E=x.current.x*v.current.x,O=x.current.y*v.current.y;k.scrollBy(E,O)},[]),T=w.useMemo(()=>l===ZM.TreeOrder?[...u].reverse():u,[l,u]);w.useEffect(()=>{if(!a||!u.length||!S){y();return}for(const k of T){if(r?.(k)===!1)continue;const E=u.indexOf(k),O=d[E];if(!O)continue;const{direction:C,speed:D}=iXe(k,O,S,e,m);for(const U of["x","y"])p[U][C[U]]||(D[U]=0,C[U]=0);if(D.x>0||D.y>0){y(),M.current=k,b(A,o),x.current=D,v.current=C;return}}x.current={x:0,y:0},v.current={x:0,y:0},y()},[e,A,r,y,a,o,JSON.stringify(S),JSON.stringify(p),b,u,T,d,JSON.stringify(m)])}const bXe={x:{[Ji.Backward]:!1,[Ji.Forward]:!1},y:{[Ji.Backward]:!1,[Ji.Forward]:!1}};function yXe(t){let{delta:e,disabled:n}=t;const r=xD(e);return av(i=>{if(n||!r||!i)return bXe;const a={x:Math.sign(e.x-r.x),y:Math.sign(e.y-r.y)};return{x:{[Ji.Backward]:i.x[Ji.Backward]||a.x===-1,[Ji.Forward]:i.x[Ji.Forward]||a.x===1},y:{[Ji.Backward]:i.y[Ji.Backward]||a.y===-1,[Ji.Forward]:i.y[Ji.Forward]||a.y===1}}},[n,e,r])}function vXe(t,e){const n=e!=null?t.get(e):void 0,r=n?n.node.current:null;return av(i=>{var a;return e==null?null:(a=r??i)!=null?a:null},[r,e])}function _Xe(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 vy;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(vy||(vy={}));var _D;(function(t){t.Optimized="optimized"})(_D||(_D={}));const oq=new Map;function wXe(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=by(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=av(v=>{if(f&&!n)return oq;if(!v||v===oq||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 A=M.node.current,T=A?new bI(c(A),A):null;M.rect.current=T,T&&S.set(M.id,T)}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 vy.Always:return!1;case vy.BeforeDragging:return n;default:return!n}}}function Pie(t,e){return av(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function SXe(t,e){return Pie(t,e)}function MXe(t){let{callback:e,disabled:n}=t;const r=gI(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 zE(t){let{callback:e,disabled:n}=t;const r=gI(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 NXe(t){return new bI(yx(t),t)}function lq(t,e,n){e===void 0&&(e=NXe);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=MXe({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=zE({callback:a});return lc(()=>{a(),t?(l?.observe(t),o?.observe(document.body,{childList:!0,subtree:!0})):(l?.disconnect(),o?.disconnect())},[t]),r}function EXe(t){const e=Pie(t);return Mie(t,e)}const cq=[];function AXe(t){const e=w.useRef(t),n=av(r=>t?r&&r!==cq&&t&&e.current&&t.parentNode===e.current.parentNode?r:IE(t):cq,[t]);return w.useEffect(()=>{e.current=t},[t]),n}function TXe(t){const[e,n]=w.useState(null),r=w.useRef(t),i=w.useCallback(a=>{const o=Vj(a.target);o&&n(l=>l?(l.set(o,yD(o)),new Map(l)):null)},[]);return w.useEffect(()=>{const a=r.current;if(t!==a){o(a);const l=t.map(c=>{const u=Vj(c);return u?(u.addEventListener("scroll",i,{passive:!0}),[u,yD(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=Vj(c);u?.removeEventListener("scroll",i)})}},[i,t]),w.useMemo(()=>t.length?e?Array.from(e.values()).reduce((a,o)=>xg(a,o),ml):kie(t):ml,[t,e])}function uq(t,e){e===void 0&&(e=[]);const n=w.useRef(null);return w.useEffect(()=>{n.current=null},e),w.useEffect(()=>{const r=t!==ml;r&&!n.current&&(n.current=t),!r&&n.current&&(n.current=null)},[t]),n.current?yy(t,n.current):ml}function CXe(t){w.useEffect(()=>{if(!LE)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 kXe(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 Rie(t){return w.useMemo(()=>t?eXe(t):null,[t])}const dq=[];function jXe(t,e){e===void 0&&(e=yx);const[n]=t,r=Rie(n?ks(n):null),[i,a]=w.useState(dq);function o(){a(()=>t.length?t.map(c=>Tie(c)?r:new bI(e(c),c)):dq)}const l=zE({callback:o});return lc(()=>{l?.disconnect(),o(),t.forEach(c=>l?.observe(c))},[t]),i}function PXe(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return iv(e)?e:t}function RXe(t){let{measure:e}=t;const[n,r]=w.useState(null),i=w.useCallback(u=>{for(const{target:d}of u)if(iv(d)){r(f=>{const m=e(d);return f?{...f,width:m.width,height:m.height}:m});break}},[e]),a=zE({callback:i}),o=w.useCallback(u=>{const d=PXe(u);a?.disconnect(),d&&a?.observe(d),r(d?e(d):null)},[e,a]),[l,c]=KM(o);return w.useMemo(()=>({nodeRef:l,rect:n,setRef:c}),[n,l,c])}const DXe=[{sensor:UE,options:{}},{sensor:FE,options:{}}],OXe={current:{}},T1={draggable:{measure:rq},droppable:{measure:rq,strategy:vy.WhileDragging,frequency:_D.Optimized},dragOverlay:{measure:yx}};class N0 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 LXe={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new N0,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:XM},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:T1,measureDroppableContainers:XM,windowRect:null,measuringScheduled:!1},IXe={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:XM,draggableNodes:new Map,over:null,measureDroppableContainers:XM},BE=w.createContext(IXe),Die=w.createContext(LXe);function FXe(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new N0}}}function UXe(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 N0(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 N0(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 N0(t.droppable.containers);return a.delete(n),{...t,droppable:{...t.droppable,containers:a}}}default:return t}}function zXe(t){let{disabled:e}=t;const{active:n,activatorEvent:r,draggableNodes:i}=w.useContext(BE),a=xD(r),o=xD(n?.id);return w.useEffect(()=>{if(!e&&!r&&a&&o!=null){if(!xI(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=DKe(d);if(f){f.focus();break}}})}},[r,e,i,o,a]),null}function BXe(t,e){let{transform:n,...r}=e;return t!=null&&t.length?t.reduce((i,a)=>a({transform:i,...r}),n):n}function $Xe(t){return w.useMemo(()=>({draggable:{...T1.draggable,...t?.draggable},droppable:{...T1.droppable,...t?.droppable},dragOverlay:{...T1.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function HXe(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;lc(()=>{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=Mie(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=Nie(u);m&&m.scrollBy({top:f.y,left:f.x})}},[e,o,l,r,n])}const Oie=w.createContext({...ml,scaleX:1,scaleY:1});var Ed;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(Ed||(Ed={}));const Lie=w.memo(function(e){var n,r,i,a;let{id:o,accessibility:l,autoScroll:c=!0,children:u,sensors:d=DXe,collisionDetection:f=qKe,measuring:m,modifiers:p,...b}=e;const y=w.useReducer(UXe,void 0,FXe),[x,v]=y,[S,M]=zKe(),[A,T]=w.useState(Ed.Uninitialized),k=A===Ed.Initialized,{draggable:{active:E,nodes:O,translate:C},droppable:{containers:D}}=x,U=E!=null?O.get(E):null,L=w.useRef({initial:null,translated:null}),q=w.useMemo(()=>{var Oe;return E!=null?{id:E,data:(Oe=U?.data)!=null?Oe:OXe,rect:L}:null},[E,U]),P=w.useRef(null),[W,K]=w.useState(null),[V,Q]=w.useState(null),re=by(b,Object.values(b)),J=sv("DndDescribedBy",o),z=w.useMemo(()=>D.getEnabled(),[D]),G=$Xe(m),{droppableRects:ne,measureDroppableContainers:ae,measuringScheduled:de}=wXe(z,{dragging:k,dependencies:[C.x,C.y],config:G.droppable}),fe=vXe(O,E),ie=w.useMemo(()=>V?bD(V):null,[V]),Ae=xe(),me=SXe(fe,G.draggable.measure);HXe({activeNode:E!=null?O.get(E):null,config:Ae.layoutShiftCompensation,initialRect:me,measure:G.draggable.measure});const Ne=lq(fe,G.draggable.measure,me),ye=lq(fe?fe.parentElement:null),le=w.useRef({activatorEvent:null,active:null,activeNode:fe,collisionRect:null,collisions:null,droppableRects:ne,draggableNodes:O,draggingNode:null,draggingNodeRect:null,droppableContainers:D,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),$e=D.getNodeFor((n=le.current.over)==null?void 0:n.id),H=RXe({measure:G.dragOverlay.measure}),ee=(r=H.nodeRef.current)!=null?r:fe,X=k?(i=H.rect)!=null?i:Ne:null,B=!!(H.nodeRef.current&&H.rect),I=EXe(B?null:Ne),ce=Rie(ee?ks(ee):null),Te=AXe(k?$e??fe:null),Le=jXe(Te),Ee=BXe(p,{transform:{x:C.x-I.x,y:C.y-I.y,scaleX:1,scaleY:1},activatorEvent:V,active:q,activeNodeRect:Ne,containerNodeRect:ye,draggingNodeRect:X,over:le.current.over,overlayNodeRect:H.rect,scrollableAncestors:Te,scrollableAncestorRects:Le,windowRect:ce}),$=ie?xg(ie,C):null,j=TXe(Te),Y=uq(j),ge=uq(j,[Ne]),we=xg(Ee,Y),ve=X?YKe(X,Ee):null,Ze=q&&ve?f({active:q,collisionRect:ve,droppableRects:ne,droppableContainers:z,pointerCoordinates:$}):null,Ie=wie(Ze,"id"),[qe,Je]=w.useState(null),Qe=B?Ee:xg(Ee,ge),oe=KKe(Qe,(a=qe?.rect)!=null?a:null,Ne),te=w.useRef(null),Me=w.useCallback((Oe,Ue)=>{let{sensor:Ce,options:We}=Ue;if(P.current==null)return;const pt=O.get(P.current);if(!pt)return;const kt=Oe.nativeEvent,Lt=new Ce({active:P.current,activeNode:pt,event:kt,options:We,context:le,onAbort(Gt){if(!O.get(Gt))return;const{onDragAbort:gt}=re.current,Kt={id:Gt};gt?.(Kt),S({type:"onDragAbort",event:Kt})},onPending(Gt,_n,gt,Kt){if(!O.get(Gt))return;const{onDragPending:At}=re.current,Pr={id:Gt,constraint:_n,initialCoordinates:gt,offset:Kt};At?.(Pr),S({type:"onDragPending",event:Pr})},onStart(Gt){const _n=P.current;if(_n==null)return;const gt=O.get(_n);if(!gt)return;const{onDragStart:Kt}=re.current,bn={activatorEvent:kt,active:{id:_n,data:gt.data,rect:L}};Jc.unstable_batchedUpdates(()=>{Kt?.(bn),T(Ed.Initializing),v({type:Di.DragStart,initialCoordinates:Gt,active:_n}),S({type:"onDragStart",event:bn}),K(te.current),Q(kt)})},onMove(Gt){v({type:Di.DragMove,coordinates:Gt})},onEnd:ln(Di.DragEnd),onCancel:ln(Di.DragCancel)});te.current=Lt;function ln(Gt){return async function(){const{active:gt,collisions:Kt,over:bn,scrollAdjustedTranslate:At}=le.current;let Pr=null;if(gt&&At){const{cancelDrop:yr}=re.current;Pr={activatorEvent:kt,active:gt,collisions:Kt,delta:At,over:bn},Gt===Di.DragEnd&&typeof yr=="function"&&await Promise.resolve(yr(Pr))&&(Gt=Di.DragCancel)}P.current=null,Jc.unstable_batchedUpdates(()=>{v({type:Gt}),T(Ed.Uninitialized),Je(null),K(null),Q(null),te.current=null;const yr=Gt===Di.DragEnd?"onDragEnd":"onDragCancel";if(Pr){const jn=re.current[yr];jn?.(Pr),S({type:yr,event:Pr})}})}}},[O]),Fe=w.useCallback((Oe,Ue)=>(Ce,We)=>{const pt=Ce.nativeEvent,kt=O.get(We);if(P.current!==null||!kt||pt.dndKit||pt.defaultPrevented)return;const Lt={active:kt};Oe(Ce,Ue.options,Lt)===!0&&(pt.dndKit={capturedBy:Ue.sensor},P.current=We,Me(Ce,Ue))},[O,Me]),ot=_Xe(d,Fe);CXe(d),lc(()=>{Ne&&A===Ed.Initializing&&T(Ed.Initialized)},[Ne,A]),w.useEffect(()=>{const{onDragMove:Oe}=re.current,{active:Ue,activatorEvent:Ce,collisions:We,over:pt}=le.current;if(!Ue||!Ce)return;const kt={active:Ue,activatorEvent:Ce,collisions:We,delta:{x:we.x,y:we.y},over:pt};Jc.unstable_batchedUpdates(()=>{Oe?.(kt),S({type:"onDragMove",event:kt})})},[we.x,we.y]),w.useEffect(()=>{const{active:Oe,activatorEvent:Ue,collisions:Ce,droppableContainers:We,scrollAdjustedTranslate:pt}=le.current;if(!Oe||P.current==null||!Ue||!pt)return;const{onDragOver:kt}=re.current,Lt=We.get(Ie),ln=Lt&&Lt.rect.current?{id:Lt.id,rect:Lt.rect.current,data:Lt.data,disabled:Lt.disabled}:null,Gt={active:Oe,activatorEvent:Ue,collisions:Ce,delta:{x:pt.x,y:pt.y},over:ln};Jc.unstable_batchedUpdates(()=>{Je(ln),kt?.(Gt),S({type:"onDragOver",event:Gt})})},[Ie]),lc(()=>{le.current={activatorEvent:V,active:q,activeNode:fe,collisionRect:ve,collisions:Ze,droppableRects:ne,draggableNodes:O,draggingNode:ee,draggingNodeRect:X,droppableContainers:D,over:qe,scrollableAncestors:Te,scrollAdjustedTranslate:we},L.current={initial:X,translated:ve}},[q,fe,Ze,ve,O,ee,X,ne,D,qe,Te,we]),xXe({...Ae,delta:C,draggingRect:ve,pointerCoordinates:$,scrollableAncestors:Te,scrollableAncestorRects:Le});const se=w.useMemo(()=>({active:q,activeNode:fe,activeNodeRect:Ne,activatorEvent:V,collisions:Ze,containerNodeRect:ye,dragOverlay:H,draggableNodes:O,droppableContainers:D,droppableRects:ne,over:qe,measureDroppableContainers:ae,scrollableAncestors:Te,scrollableAncestorRects:Le,measuringConfiguration:G,measuringScheduled:de,windowRect:ce}),[q,fe,Ne,V,Ze,ye,H,O,D,ne,qe,ae,Te,Le,G,de,ce]),je=w.useMemo(()=>({activatorEvent:V,activators:ot,active:q,activeNodeRect:Ne,ariaDescribedById:{draggable:J},dispatch:v,draggableNodes:O,over:qe,measureDroppableContainers:ae}),[V,ot,q,Ne,v,J,O,qe,ae]);return Ur.createElement(bie.Provider,{value:M},Ur.createElement(BE.Provider,{value:je},Ur.createElement(Die.Provider,{value:se},Ur.createElement(Oie.Provider,{value:oe},u)),Ur.createElement(zXe,{disabled:l?.restoreFocus===!1})),Ur.createElement(HKe,{...l,hiddenTextDescribedById:J}));function xe(){const Oe=W?.autoScrollEnabled===!1,Ue=typeof c=="object"?c.enabled===!1:c===!1,Ce=k&&!Oe&&!Ue;return typeof c=="object"?{...c,enabled:Ce}:{enabled:Ce}}}),VXe=w.createContext(null),hq="button",GXe="Draggable";function WXe(t){let{id:e,data:n,disabled:r=!1,attributes:i}=t;const a=sv(GXe),{activators:o,activatorEvent:l,active:c,activeNodeRect:u,ariaDescribedById:d,draggableNodes:f,over:m}=w.useContext(BE),{role:p=hq,roleDescription:b="draggable",tabIndex:y=0}=i??{},x=c?.id===e,v=w.useContext(x?Oie:VXe),[S,M]=KM(),[A,T]=KM(),k=kXe(o,e),E=by(n);lc(()=>(f.set(e,{id:e,key:a,node:S,activatorNode:A,data:E}),()=>{const C=f.get(e);C&&C.key===a&&f.delete(e)}),[f,e]);const O=w.useMemo(()=>({role:p,tabIndex:y,"aria-disabled":r,"aria-pressed":x&&p===hq?!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:O,isDragging:x,listeners:r?void 0:k,node:S,over:m,setNodeRef:M,setActivatorNodeRef:T,transform:v}}function qXe(){return w.useContext(Die)}const KXe="Droppable",XXe={timeout:25};function YXe(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:i}=t;const a=sv(KXe),{active:o,dispatch:l,over:c,measureDroppableContainers:u}=w.useContext(BE),d=w.useRef({disabled:n}),f=w.useRef(!1),m=w.useRef(null),p=w.useRef(null),{disabled:b,updateMeasurementsFor:y,timeout:x}={...XXe,...i},v=by(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=zE({callback:S,disabled:b||!o}),A=w.useCallback((O,C)=>{M&&(C&&(M.unobserve(C),f.current=!1),O&&M.observe(O))},[M]),[T,k]=KM(A),E=by(e);return w.useEffect(()=>{!M||!T.current||(M.disconnect(),f.current=!1,M.observe(T.current))},[T,M]),w.useEffect(()=>(l({type:Di.RegisterDroppable,element:{id:r,key:a,disabled:n,node:T,rect:m,data:E}}),()=>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:T,over:c,setNodeRef:k}}function $E(t,e,n){const r=t.slice();return r.splice(n<0?r.length+n:n,0,r.splice(e,1)[0]),r}function ZXe(t,e){return t.reduce((n,r,i)=>{const a=e.get(r);return a&&(n[i]=a),n},Array(t.length))}function Yw(t){return t!==null&&t>=0}function QXe(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 JXe(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const vI=t=>{let{rects:e,activeIndex:n,overIndex:r,index:i}=t;const a=$E(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}},Zw={scaleX:1,scaleY:1},eYe=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,...Zw}:null}const c=tYe(a,i,n);return i>n&&i<=o?{x:0,y:-l.height-c,...Zw}:i<n&&i>=o?{x:0,y:l.height+c,...Zw}:{x:0,y:0,...Zw}};function tYe(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 Iie="Sortable",Fie=Ur.createContext({activeIndex:-1,containerId:Iie,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:vI,disabled:{draggable:!1,droppable:!1}});function Uie(t){let{children:e,id:n,items:r,strategy:i=vI,disabled:a=!1}=t;const{active:o,dragOverlay:l,droppableRects:c,over:u,measureDroppableContainers:d}=qXe(),f=sv(Iie,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=!QXe(p,v.current),M=x!==-1&&y===-1||S,A=JXe(a);lc(()=>{S&&b&&d(p)},[S,p,b,d]),w.useEffect(()=>{v.current=p},[p]);const T=w.useMemo(()=>({activeIndex:y,containerId:f,disabled:A,disableTransforms:M,items:p,overIndex:x,useDragOverlay:m,sortedRects:ZXe(p,c),strategy:i}),[y,f,A.draggable,A.droppable,M,p,x,c,m,i]);return Ur.createElement(Fie.Provider,{value:T},e)}const nYe=t=>{let{id:e,items:n,activeIndex:r,overIndex:i}=t;return $E(n,r,i).indexOf(e)},rYe=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},iYe={duration:200,easing:"ease"},zie="transform",aYe=qg.Transition.toString({property:zie,duration:0,easing:"linear"}),sYe={roleDescription:"sortable"};function oYe(t){let{disabled:e,index:n,node:r,rect:i}=t;const[a,o]=w.useState(null),l=w.useRef(n);return lc(()=>{if(!e&&n!==l.current&&r.current){const c=i.current;if(c){const u=yx(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 Bie(t){let{animateLayoutChanges:e=rYe,attributes:n,disabled:r,data:i,getNewIndex:a=nYe,id:o,strategy:l,resizeObserverConfig:c,transition:u=iYe}=t;const{items:d,containerId:f,activeIndex:m,disabled:p,disableTransforms:b,sortedRects:y,overIndex:x,useDragOverlay:v,strategy:S}=w.useContext(Fie),M=lYe(r,p),A=d.indexOf(o),T=w.useMemo(()=>({sortable:{containerId:f,index:A,items:d},...i}),[f,i,A,d]),k=w.useMemo(()=>d.slice(d.indexOf(o)),[d,o]),{rect:E,node:O,isOver:C,setNodeRef:D}=YXe({id:o,data:T,disabled:M.droppable,resizeObserverConfig:{updateMeasurementsFor:k,...c}}),{active:U,activatorEvent:L,activeNodeRect:q,attributes:P,setNodeRef:W,listeners:K,isDragging:V,over:Q,setActivatorNodeRef:re,transform:J}=WXe({id:o,data:T,attributes:{...sYe,...n},disabled:M.draggable}),z=kKe(D,W),G=!!U,ne=G&&!b&&Yw(m)&&Yw(x),ae=!v&&V,de=ae&&ne?J:null,ie=ne?de??(l??S)({rects:y,activeNodeRect:q,activeIndex:m,overIndex:x,index:A}):null,Ae=Yw(m)&&Yw(x)?a({id:o,items:d,activeIndex:m,overIndex:x}):A,me=U?.id,Ne=w.useRef({activeId:me,items:d,newIndex:Ae,containerId:f}),ye=d!==Ne.current.items,le=e({active:U,containerId:f,isDragging:V,isSorting:G,id:o,index:A,items:d,newIndex:Ne.current.newIndex,previousItems:Ne.current.items,previousContainerId:Ne.current.containerId,transition:u,wasDragging:Ne.current.activeId!=null}),$e=oYe({disabled:!le,index:A,node:O,rect:E});return w.useEffect(()=>{G&&Ne.current.newIndex!==Ae&&(Ne.current.newIndex=Ae),f!==Ne.current.containerId&&(Ne.current.containerId=f),d!==Ne.current.items&&(Ne.current.items=d)},[G,Ae,f,d]),w.useEffect(()=>{if(me===Ne.current.activeId)return;if(me!=null&&Ne.current.activeId==null){Ne.current.activeId=me;return}const ee=setTimeout(()=>{Ne.current.activeId=me},50);return()=>clearTimeout(ee)},[me]),{active:U,activeIndex:m,attributes:P,data:T,rect:E,index:A,newIndex:Ae,items:d,isOver:C,isSorting:G,isDragging:V,listeners:K,node:O,overIndex:x,over:Q,setNodeRef:z,setActivatorNodeRef:re,setDroppableNodeRef:D,setDraggableNodeRef:W,transform:$e??ie,transition:H()};function H(){if($e||ye&&Ne.current.newIndex===A)return aYe;if(!(ae&&!xI(L)||!u)&&(G||le))return qg.Transition.toString({...u,property:zie})}}function lYe(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 QM(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 cYe=[Bn.Down,Bn.Right,Bn.Up,Bn.Left],$ie=(t,e)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:a,over:o,scrollableAncestors:l}}=e;if(cYe.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 Bn.Down:r.top<m.top&&c.push(f);break;case Bn.Up:r.top>m.top&&c.push(f);break;case Bn.Left:r.left>m.left&&c.push(f);break;case Bn.Right:r.left<m.left&&c.push(f);break}});const u=GKe({collisionRect:r,droppableRects:i,droppableContainers:c});let d=wie(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=IE(b).some((k,E)=>l[E]!==k),v=Hie(f,m),S=uYe(f,m),M=x||!v?{x:0,y:0}:{x:S?r.width-p.width:0,y:S?r.height-p.height:0},A={x:p.left,y:p.top};return M.x&&M.y?A:yy(A,M)}}}};function Hie(t,e){return!QM(t)||!QM(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function uYe(t,e){return!QM(t)||!QM(e)||!Hie(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}function Vie(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 dYe(t,e="system"){if(!t)return"ASAP";const n=Ni(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`:wg(t,e)}function hYe({status:t}){const e={pending:{icon:Zn,color:"text-status-warning bg-status-warning/10 border-status-warning/20",label:"Pending"},printing:{icon:Oo,color:"text-blue-400 bg-blue-400/10 border-blue-400/20",label:"Printing"},completed:{icon:Un,color:"text-status-ok bg-status-ok/10 border-status-ok/20",label:"Completed"},failed:{icon:ia,color:"text-status-error bg-status-error/10 border-status-error/20",label:"Failed"},skipped:{icon:R0,color:"text-orange-400 bg-orange-400/10 border-orange-400/20",label:"Skipped"},cancelled:{icon:Vt,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 fYe({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,A]=w.useState("unchanged"),[T,k]=w.useState("unchanged"),[E,O]=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),T!=="unchanged"&&(U.timelapse=T),E!=="unchanged"&&(U.use_ams=E),n(U)},D=a!=="unchanged"||l!=="unchanged"||u!=="unchanged"||f!=="unchanged"||p!=="unchanged"||y!=="unchanged"||v!=="unchanged"||M!=="unchanged"||T!=="unchanged"||E!=="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(Vt,{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 L=U.target.value;o(L==="unchanged"?"unchanged":L==="null"?null:Number(L))},className:"w-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(Gc,{label:"Staged (manual start)",value:l,onChange:c}),s.jsx(Gc,{label:"Auto power off after print",value:u,onChange:d}),s.jsx(Gc,{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(Gc,{label:"Bed levelling",value:p,onChange:b}),s.jsx(Gc,{label:"Flow calibration",value:y,onChange:x}),s.jsx(Gc,{label:"Vibration calibration",value:v,onChange:S}),s.jsx(Gc,{label:"First layer inspection",value:M,onChange:A}),s.jsx(Gc,{label:"Timelapse",value:T,onChange:k}),s.jsx(Gc,{label:"Use AMS",value:E,onChange:O})]})]})]}),s.jsxs("div",{className:"flex justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(Se,{variant:"secondary",onClick:r,children:"Cancel"}),s.jsx(Se,{onClick:C,disabled:!D||i,children:i?"Saving...":"Apply Changes"})]})]})})}function Gc({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 qj({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}=Bie({id:t.id,disabled:t.status!=="pending"}),v={transform:qg.Transform.toString(b),transition:y},S=t.status==="printing",M=t.status==="pending",A=["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:T=>{T.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(ns,{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(yg,{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:he.getArchiveThumbnail(t.archive_id),alt:"",className:"w-full h-full object-cover"}):t.library_file_thumbnail?s.jsx("img",{src:he.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(ul,{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(bs,{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(zr,{className:"w-3.5 h-3.5"})}):t.library_file_id?s.jsx(bs,{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(zr,{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(qr,{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(jd,{className:"w-3.5 h-3.5"}),Vie(t.print_time_seconds)]}),M&&!t.manual_start&&s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx(Zn,{className:"w-3.5 h-3.5"}),dYe(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(yK,{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(Eu,{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(oa,{className:"w-3 h-3"}),t.error_message]})]}),s.jsx(hYe,{status:t.status}),s.jsxs("div",{className:"flex items-center gap-1",children:[S&&s.jsx(Se,{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(gde,{className:"w-4 h-4"})}),M&&s.jsxs(s.Fragment,{children:[t.manual_start&&s.jsx(Se,{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(Oo,{className:"w-4 h-4"})}),s.jsx(Se,{variant:"ghost",size:"sm",onClick:n,title:"Edit",children:s.jsx(la,{className:"w-4 h-4"})}),s.jsx(Se,{variant:"ghost",size:"sm",onClick:r,title:"Cancel",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:s.jsx(Vt,{className:"w-4 h-4"})})]}),A&&s.jsxs(s.Fragment,{children:[s.jsx(Se,{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(xr,{className:"w-4 h-4"})}),s.jsx(Se,{variant:"ghost",size:"sm",onClick:i,title:"Remove",children:s.jsx(dn,{className:"w-4 h-4"})})]})]})]})})}function mYe(){const t=on(),{showToast:e}=qn(),[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"),[A,T]=w.useState(()=>{const ye=localStorage.getItem("queue.historySortAsc");return ye!==null?ye==="true":!1}),[k,E]=w.useState(()=>localStorage.getItem("queue.pendingSortBy")||"position"),[O,C]=w.useState(()=>{const ye=localStorage.getItem("queue.pendingSortAsc");return ye!==null?ye==="true":!0});w.useEffect(()=>{localStorage.setItem("queue.historySortBy",S)},[S]),w.useEffect(()=>{localStorage.setItem("queue.historySortAsc",String(A))},[A]),w.useEffect(()=>{localStorage.setItem("queue.pendingSortBy",k)},[k]),w.useEffect(()=>{localStorage.setItem("queue.pendingSortAsc",String(O))},[O]);const D=yie(YM(UE,{activationConstraint:{distance:8}}),YM(FE,{coordinateGetter:$ie})),{data:U}=ut({queryKey:["settings"],queryFn:he.getSettings}),L=U?.time_format||"system",{data:q,isLoading:P}=ut({queryKey:["queue",n,i],queryFn:()=>he.getQueue(n||void 0,i||void 0),refetchInterval:5e3}),{data:W}=ut({queryKey:["printers"],queryFn:()=>he.getPrinters()}),K=mt({mutationFn:ye=>he.cancelQueueItem(ye),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item cancelled")},onError:()=>e("Failed to cancel item","error")}),V=mt({mutationFn:ye=>he.removeFromQueue(ye),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item removed")},onError:()=>e("Failed to remove item","error")}),Q=mt({mutationFn:ye=>he.stopQueueItem(ye),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Print stopped")},onError:()=>e("Failed to stop print","error")}),re=mt({mutationFn:ye=>he.startQueueItem(ye),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Print released to queue")},onError:()=>e("Failed to start print","error")}),J=mt({mutationFn:ye=>he.reorderQueue(ye),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]})},onError:()=>e("Failed to reorder queue","error")}),z=mt({mutationFn:async()=>{const ye=q?.filter(le=>["completed","failed","skipped","cancelled"].includes(le.status))||[];for(const le of ye)await he.removeFromQueue(le.id);return ye.length},onSuccess:ye=>{t.invalidateQueries({queryKey:["queue"]}),e(`Cleared ${ye} history item${ye!==1?"s":""}`)},onError:()=>e("Failed to clear history","error")}),G=mt({mutationFn:ye=>he.bulkUpdateQueue(ye),onSuccess:ye=>{t.invalidateQueries({queryKey:["queue"]}),y([]),v(!1),e(ye.message)},onError:()=>e("Failed to update items","error")}),ne=mt({mutationFn:async ye=>{for(const le of ye)await he.cancelQueueItem(le);return ye.length},onSuccess:ye=>{t.invalidateQueries({queryKey:["queue"]}),y([]),e(`Cancelled ${ye} item${ye!==1?"s":""}`)},onError:()=>e("Failed to cancel items","error")}),ae=ye=>{y(le=>le.includes(ye)?le.filter($e=>$e!==ye):[...le,ye])},de=w.useMemo(()=>{const ye=q?.filter($e=>$e.status==="pending")||[],le=$e=>{if(!$e.scheduled_time)return 0;const H=new Date($e.scheduled_time).getTime(),ee=Date.now()+4320*60*60*1e3;return H>ee?0:H};return[...ye].sort(($e,H)=>{let ee;if(k==="name"){const X=$e.archive_name||$e.library_file_name||"",B=H.archive_name||H.library_file_name||"";ee=X.localeCompare(B)}else k==="printer"?ee=($e.printer_name||"").localeCompare(H.printer_name||""):k==="time"?ee=le($e)-le(H):ee=$e.position-H.position;return O?ee:-ee})},[q,k,O]),fe=()=>{const ye=de.map(le=>le.id);b.length===ye.length?y([]):y(ye)},ie=q?.filter(ye=>ye.status==="printing")||[],Ae=w.useMemo(()=>[...q?.filter(le=>["completed","failed","skipped","cancelled"].includes(le.status))||[]].sort((le,$e)=>{let H;if(S==="name"){const ee=le.archive_name||le.library_file_name||"",X=$e.archive_name||$e.library_file_name||"";H=ee.localeCompare(X)}else S==="printer"?H=(le.printer_name||"").localeCompare($e.printer_name||""):H=new Date($e.completed_at||$e.created_at).getTime()-new Date(le.completed_at||le.created_at).getTime();return A?-H:H}),[q,S,A]),me=w.useMemo(()=>de.reduce((ye,le)=>ye+(le.print_time_seconds||0),0),[de]),Ne=ye=>{const{active:le,over:$e}=ye;if(!$e||le.id===$e.id)return;const H=de.findIndex(X=>X.id===le.id),ee=de.findIndex(X=>X.id===$e.id);if(H!==-1&&ee!==-1){const B=$E(de,H,ee).map((I,ce)=>({id:I.id,position:ce+1}));J.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(vK,{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(St,{className:"bg-gradient-to-br from-blue-500/10 to-transparent border-blue-500/20",children:s.jsx(Nt,{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(Oo,{className:"w-5 h-5 text-blue-400"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:ie.length}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Printing"})]})]})})}),s.jsx(St,{className:"bg-gradient-to-br from-yellow-500/10 to-transparent border-yellow-500/20",children:s.jsx(Nt,{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(Zn,{className:"w-5 h-5 text-yellow-400"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:de.length}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Queued"})]})]})})}),s.jsx(St,{className:"bg-gradient-to-br from-bambu-green/10 to-transparent border-bambu-green/20",children:s.jsx(Nt,{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(jd,{className:"w-5 h-5 text-bambu-green"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:Vie(me)}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Total Queue Time"})]})]})})}),s.jsx(St,{className:"bg-gradient-to-br from-gray-500/10 to-transparent border-gray-500/20",children:s.jsx(Nt,{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(Un,{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:ye=>{const le=ye.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(ye=>s.jsx("option",{value:ye.id,children:ye.name},ye.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:ye=>a(ye.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(Se,{variant:"secondary",size:"sm",onClick:()=>l(!0),children:[s.jsx(dn,{className:"w-4 h-4"}),"Clear History"]})]}),P?s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading..."}):q?.length===0?s.jsxs(St,{className:"p-12 text-center border-dashed",children:[s.jsx(oi,{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:[ie.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:ie.map(ye=>s.jsx(qj,{item:ye,onEdit:()=>{},onCancel:()=>{},onRemove:()=>{},onStop:()=>p({type:"stop",item:ye}),onRequeue:()=>{},onStart:()=>{},timeFormat:L},ye.id))})]}),de.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(Zn,{className:"w-5 h-5 text-yellow-400"}),"Queued",s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",de.length," item",de.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:ye=>E(ye.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(Se,{variant:"ghost",size:"sm",onClick:()=>C(!O),title:O?"Ascending":"Descending",className:"px-2",children:O?s.jsx(bg,{className:"w-4 h-4"}):s.jsx(j0,{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(Se,{variant:"ghost",size:"sm",onClick:fe,className:"flex items-center gap-2",children:[b.length===de.length&&de.length>0?s.jsx(Lo,{className:"w-4 h-4 text-bambu-green"}):s.jsx(Io,{className:"w-4 h-4"}),b.length===de.length&&de.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(Se,{variant:"ghost",size:"sm",onClick:()=>v(!0),className:"flex items-center gap-2 text-bambu-green hover:text-bambu-green-light",children:[s.jsx(la,{className:"w-4 h-4"}),"Edit Selected"]}),s.jsxs(Se,{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(Vt,{className:"w-4 h-4"}),"Cancel Selected"]})]})]}),s.jsx(Lie,{sensors:D,collisionDetection:Sie,onDragEnd:Ne,children:s.jsx(Uie,{items:de.map(ye=>ye.id),strategy:eYe,children:s.jsx("div",{className:"space-y-3",children:de.map((ye,le)=>s.jsx(qj,{item:ye,position:le+1,onEdit:()=>u(ye),onCancel:()=>p({type:"cancel",item:ye}),onRemove:()=>{},onStop:()=>{},onRequeue:()=>{},onStart:()=>re.mutate(ye.id),timeFormat:L,isSelected:b.includes(ye.id),onToggleSelect:()=>ae(ye.id)},ye.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(Un,{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:ye=>M(ye.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(Se,{variant:"ghost",size:"sm",onClick:()=>T(!A),title:A?"Ascending (oldest first)":"Descending (newest first)",className:"px-2",children:A?s.jsx(bg,{className:"w-4 h-4"}):s.jsx(j0,{className:"w-4 h-4"})})]})]}),s.jsx("div",{className:"space-y-3",children:Ae.slice(0,20).map((ye,le)=>s.jsx(qj,{item:ye,position:le+1,onEdit:()=>{},onCancel:()=>{},onRemove:()=>p({type:"remove",item:ye}),onStop:()=>{},onRequeue:()=>f(ye),onStart:()=>{},timeFormat:L},ye.id))})]})]}),c&&s.jsx(ch,{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(ch,{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(Hn,{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"?K.mutate(m.item.id):m.type==="stop"?Q.mutate(m.item.id):V.mutate(m.item.id),p(null)},onCancel:()=>p(null)}),o&&s.jsx(Hn,{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(fYe,{selectedCount:b.length,printers:W?.map(ye=>({id:ye.id,name:ye.name}))||[],onSave:ye=>{Object.keys(ye).length>0&&G.mutate({item_ids:b,...ye})},onClose:()=>v(!1),isSaving:G.isPending})]})}function pYe({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(A=>{const T=A[0]?.contentRect.width||0;i(T)});return M.observe(S),()=>M.disconnect()},[]);const{weeks:a,monthLabels:o,printCounts:l}=w.useMemo(()=>{const S={};t.forEach(U=>{const L=U.split("T")[0];S[L]=(S[L]||0)+1});const M=new Date,A=new Date(M);A.setMonth(A.getMonth()-e),A.setDate(A.getDate()-A.getDay());const T=[],k=[];let E=[],O=-1;const C=new Date(A);let D=0;for(;C<=M;)C.getDay()===0&&E.length>0&&(T.push(E),E=[],D++),C.getMonth()!==O&&(k.push({month:C.toLocaleDateString("en-US",{month:"short"}),weekIndex:D}),O=C.getMonth()),E.push(new Date(C)),C.setDate(C.getDate()+1);return E.length>0&&T.push(E),{weeks:T,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},A)=>s.jsx("div",{className:"text-bambu-gray",style:{fontSize:v,marginLeft:A===0?0:`${(M-(o[A-1]?.weekIndex||0))*(x+p)-24}px`},children:S},A))}),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(A=>{const T=S.find(C=>C.getDay()===A);if(!T)return s.jsx("div",{style:{width:x,height:x}},A);const k=T.toISOString().split("T")[0],E=l[k]||0,O=k===new Date().toISOString().split("T")[0];return s.jsx("div",{className:`rounded-sm ${u(E)} ${O?"ring-1 ring-white":""}`,style:{width:x,height:x},title:`${T.toLocaleDateString()}: ${E} print${E!==1?"s":""}`},A)})},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 Qw=["#00ae42","#3b82f6","#f59e0b","#ef4444","#8b5cf6","#ec4899","#14b8a6","#f97316"];function gYe(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 xYe({archives:t,currency:e="$"}){const[n,r]=w.useState("30d"),i=w.useMemo(()=>{const m=gYe(n);return t.filter(p=>(Ni(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=Ni(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=Ni(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 A=Ni(M.completed_at||M.created_at)||new Date(0);return A>=y&&A<=x});p.push({month:v,filament:Math.round(S.reduce((M,A)=>M+(A.filament_used_grams||0),0)),cost:S.reduce((M,A)=>M+(A.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(l1,{width:"100%",height:250,children:s.jsxs(NPe,{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(OS,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),s.jsx(US,{dataKey:"dateLabel",stroke:"#9ca3af",tick:{fontSize:12},interval:"preserveStartEnd"}),s.jsx(zS,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:m=>`${m}g`}),s.jsx(u1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},labelStyle:{color:"#fff"},formatter:m=>[`${Number(m??0).toFixed(0)}g`,"Filament"]}),s.jsx(CJ,{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(l1,{width:160,height:160,children:s.jsxs(SPe,{children:[s.jsx(tJ,{data:l,cx:"50%",cy:"50%",innerRadius:40,outerRadius:70,paddingAngle:2,dataKey:"value",children:l.map((m,p)=>s.jsx(qy,{fill:Qw[p%Qw.length]},`cell-${p}`))}),s.jsx(u1,{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:Qw[p%Qw.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(l1,{width:"100%",height:200,children:s.jsxs(dPe,{data:c,children:[s.jsx(OS,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),s.jsx(US,{dataKey:"month",stroke:"#9ca3af",tick:{fontSize:12}}),s.jsx(zS,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:m=>`${m}g`}),s.jsx(u1,{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(SO,{}),s.jsx(DJ,{dataKey:"filament",name:"Filament (g)",fill:"#00ae42",radius:[4,4,0,0]})]})})]})]})]})}function bYe({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}=Bie({id:t}),p={transform:qg.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(yg,{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(wK,{className:"w-4 h-4 text-bambu-gray hover:text-white"}):s.jsx(_K,{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(My,{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 yYe({widgets:t,storageKey:e,columns:n=4,hideControls:r=!1,onResetLayout:i,renderControls:a}){const o=()=>{const A={};return t.forEach(T=>{A[T.id]=T.defaultSize||4}),A},[l,c]=w.useState(()=>{const A=localStorage.getItem(e);if(A)try{const T=JSON.parse(A);return T.sizes||(T.sizes=o()),T}catch{}return{order:t.map(T=>T.id),hidden:t.filter(T=>T.defaultVisible===!1).map(T=>T.id),sizes:o()}}),[u,d]=w.useState(!1);w.useEffect(()=>{const A=()=>d(T=>!T);return window.addEventListener("toggle-hidden-panel",A),()=>window.removeEventListener("toggle-hidden-panel",A)},[]),w.useEffect(()=>{localStorage.setItem(e,JSON.stringify(l))},[l,e]),w.useEffect(()=>{const T=t.map(k=>k.id).filter(k=>!l.order.includes(k));T.length>0&&c(k=>({...k,order:[...k.order,...T]}))},[t,l.order]);const f=yie(YM(UE,{activationConstraint:{distance:8}}),YM(FE,{coordinateGetter:$ie})),m=A=>{const{active:T,over:k}=A;k&&T.id!==k.id&&c(E=>{const O=E.order.indexOf(T.id),C=E.order.indexOf(k.id);return{...E,order:$E(E.order,O,C)}})},p=A=>{c(T=>({...T,hidden:T.hidden.includes(A)?T.hidden.filter(k=>k!==A):[...T.hidden,A]}))},b=A=>{c(T=>{const k=T.sizes[A]||4,E=k===1?2:k===2?4:1;return{...T,sizes:{...T.sizes,[A]:E}}})},y=()=>{const A={order:t.map(T=>T.id),hidden:t.filter(T=>T.defaultVisible===!1).map(T=>T.id),sizes:o()};c(A),i?.()},x=l.order.map(A=>t.find(T=>T.id===A)).filter(Boolean),v=x.filter(A=>!l.hidden.includes(A.id)),S=x.filter(A=>l.hidden.includes(A.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(Se,{variant:"secondary",size:"sm",onClick:y,children:[s.jsx(mm,{className:"w-4 h-4"}),"Reset Layout"]}),S.length>0&&s.jsxs(Se,{variant:"secondary",size:"sm",onClick:()=>d(!u),children:[s.jsx(Qd,{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(A=>s.jsxs("button",{onClick:()=>p(A.id),className:"px-3 py-1.5 bg-bambu-dark-tertiary hover:bg-bambu-green/20 rounded-lg text-sm text-white transition-colors flex items-center gap-2",children:[s.jsx(Qd,{className:"w-3 h-3"}),A.title]},A.id))})]}),s.jsx(Lie,{sensors:f,collisionDetection:Sie,onDragEnd:m,children:s.jsx(Uie,{items:v.map(A=>A.id),strategy:vI,children:s.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:v.map(A=>s.jsx(bYe,{id:A.id,title:A.title,component:A.component,isHidden:l.hidden.includes(A.id),size:l.sizes[A.id]||2,onToggleVisibility:()=>p(A.id),onToggleSize:()=>b(A.id)},A.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(Se,{className:"mt-4",onClick:y,children:"Reset Layout"})]})]})}function vYe({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(Jl,{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(Zn,{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(Jl,{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(xP,{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(qf,{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(xP,{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 _Ye({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(Un,{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(ia,{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 wYe({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(AK,{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 SYe({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 MYe({printDates:t,size:e=2}){const n=e===1?3:e===2?6:12;return s.jsx(pYe,{printDates:t,months:n})}function NYe({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(qr,{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 EYe({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(xYe,{archives:t,currency:e})}function AYe({size:t=1}){const{data:e,isLoading:n}=ut({queryKey:["failureAnalysis"],queryFn:()=>he.getFailureAnalysis({days:30})});if(n)return s.jsx("div",{className:"flex justify-center py-4",children:s.jsx(dt,{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(kn,{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(CK,{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 TYe(){const{showToast:t}=qn(),[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 E=()=>{try{const C=localStorage.getItem("bambusy-dashboard-layout");if(C){const D=JSON.parse(C);c(D.hidden?.length||0)}}catch{c(0)}};E(),window.addEventListener("storage",E);const O=setInterval(E,500);return()=>{window.removeEventListener("storage",E),clearInterval(O)}},[a]);const{data:f,isLoading:m,refetch:p}=ut({queryKey:["archiveStats"],queryFn:he.getArchiveStats}),{data:b}=ut({queryKey:["printers"],queryFn:he.getPrinters}),{data:y}=ut({queryKey:["archives"],queryFn:()=>he.getArchives(void 0,void 0,1e3,0)}),{data:x}=ut({queryKey:["settings"],queryFn:he.getSettings}),v=async E=>{i(!1),n(!0);try{const{blob:O,filename:C}=await he.exportStats({format:E,days:90}),D=URL.createObjectURL(O),U=document.createElement("a");U.href=D,U.download=C,U.click(),URL.revokeObjectURL(D),t("Export downloaded")}catch{t("Export failed","error")}finally{n(!1)}},S=async()=>{d(!0);try{const E=await he.recalculateCosts();await p(),t(`Recalculated costs for ${E.updated} archives`)}catch{t("Failed to recalculate costs","error")}finally{d(!1)}},M=x?.currency||"$",A=new Map(b?.map(E=>[String(E.id),E.name])||[]),T=y?.map(E=>E.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(vYe,{stats:f,currency:M}),defaultSize:2},{id:"success-rate",title:"Success Rate",component:E=>s.jsx(_Ye,{stats:f,printerMap:A,size:E}),defaultSize:1},{id:"time-accuracy",title:"Time Accuracy",component:E=>s.jsx(wYe,{stats:f,printerMap:A,size:E}),defaultSize:1},{id:"filament-types",title:"Filament Types",component:E=>s.jsx(SYe,{stats:f,size:E}),defaultSize:1},{id:"failure-analysis",title:"Failure Analysis (30 days)",component:E=>s.jsx(AYe,{size:E}),defaultSize:1},{id:"print-activity",title:"Print Activity",component:E=>s.jsx(MYe,{printDates:T,size:E}),defaultSize:2},{id:"prints-by-printer",title:"Prints by Printer",component:s.jsx(NYe,{stats:f,printerMap:A}),defaultSize:2},{id:"filament-trends",title:"Filament Usage Trends",component:s.jsx(EYe,{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(Se,{variant:"secondary",onClick:()=>{window.dispatchEvent(new CustomEvent("toggle-hidden-panel"))},children:[s.jsx(Qd,{className:"w-4 h-4"}),l," Hidden"]}),s.jsxs(Se,{variant:"secondary",onClick:()=>{localStorage.removeItem("bambusy-dashboard-layout"),o(E=>E+1),t("Layout reset")},children:[s.jsx(mm,{className:"w-4 h-4"}),"Reset Layout"]}),s.jsxs(Se,{variant:"secondary",onClick:S,disabled:u,title:"Recalculate all archive costs using current filament prices",children:[u?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(Zue,{className:"w-4 h-4"}),"Recalculate Costs"]}),s.jsxs("div",{className:"relative",children:[s.jsxs(Se,{variant:"secondary",onClick:()=>i(!r),disabled:e,children:[e?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(I1,{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(Za,{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(I1,{className:"w-4 h-4"}),"Export as Excel"]})]})]})]})]}),s.jsx(yYe,{widgets:k,storageKey:"bambusy-dashboard-layout",hideControls:!0},a)]})}function CYe({plug:t,onEdit:e}){const n=on(),{showToast:r}=qn(),[i,a]=w.useState(!1),[o,l]=w.useState(!1),[c,u]=w.useState(!1),[d,f]=w.useState(!1),{data:m,isLoading:p}=ut({queryKey:["smart-plug-status",t.id],queryFn:()=>he.getSmartPlugStatus(t.id),refetchInterval:3e4}),{data:b}=ut({queryKey:["printers"],queryFn:he.getPrinters}),y=b?.find(O=>O.id===t.printer_id),x=mt({mutationFn:O=>he.controlSmartPlug(t.id,O),onMutate:async O=>{await n.cancelQueries({queryKey:["smart-plug-status",t.id]});const C=n.getQueryData(["smart-plug-status",t.id]),D=O==="on"?"ON":O==="off"||m?.state==="ON"?"OFF":"ON";return n.setQueryData(["smart-plug-status",t.id],U=>({...U,state:D})),{previousStatus:C}},onError:(O,C,D)=>{D?.previousStatus&&n.setQueryData(["smart-plug-status",t.id],D.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=mt({mutationFn:O=>he.updateSmartPlug(t.id,O),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&n.invalidateQueries({queryKey:["smartPlugByPrinter",t.printer_id]})}}),S=mt({mutationFn:()=>he.deleteSmartPlug(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]})}}),M=m?.state==="ON",A=m?.reachable??!1,T=x.isPending,E=(()=>{if(t.plug_type!=="tasmota"||!t.ip_address)return null;const O=t.ip_address;return t.username&&t.password?`http://${encodeURIComponent(t.username)}:${encodeURIComponent(t.password)}@${O}/`:`http://${O}/`})();return s.jsxs(s.Fragment,{children:[s.jsx(St,{className:"relative",children:s.jsxs(Nt,{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 ${A?M?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:t.plug_type==="homeassistant"?s.jsx(cN,{className:`w-5 h-5 ${A?M?"text-bambu-green":"text-bambu-gray":"text-red-400"}`}):s.jsx(Ks,{className:`w-5 h-5 ${A?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(dt,{className:"w-4 h-4 text-bambu-gray animate-spin"}):A?s.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[s.jsx(ig,{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(ex,{className:"w-4 h-4"}),s.jsx("span",{children:"Offline"})]}),E&&s.jsxs("a",{href:E,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(zr,{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(Ef,{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(oi,{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(Se,{size:"sm",variant:M?"primary":"secondary",disabled:!A||T,onClick:()=>l(!0),className:"flex-1",children:[T?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(Eu,{className:"w-4 h-4"}),"On"]}),s.jsxs(Se,{size:"sm",variant:M?"secondary":"primary",disabled:!A||T,onClick:()=>u(!0),className:"flex-1",children:[T?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(fN,{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(Jd,{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(uN,{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:O=>v.mutate({show_in_switchbar:O.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:O=>v.mutate({enabled:O.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:O=>v.mutate({auto_on:O.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:O=>v.mutate({auto_off:O.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(Zn,{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(pN,{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:O=>v.mutate({off_delay_minutes:parseInt(O.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:O=>v.mutate({off_temp_threshold:parseInt(O.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(Se,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[s.jsx(hN,{className:"w-4 h-4"}),"Edit"]}),s.jsx(Se,{size:"sm",variant:"secondary",onClick:()=>a(!0),className:"text-red-400 hover:text-red-300",children:s.jsx(dn,{className:"w-4 h-4"})})]})]})]})}),i&&s.jsx(Hn,{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(Hn,{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(Hn,{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 kYe({plug:t,onClose:e}){const n=on(),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||""),[A,T]=w.useState(t?.ha_energy_total_entity||""),[k,E]=w.useState(""),[O,C]=w.useState(""),[D,U]=w.useState(!1),L=w.useRef(null),[q,P]=w.useState(""),[W,K]=w.useState(!1),V=w.useRef(null),[Q,re]=w.useState(""),[J,z]=w.useState(!1),G=w.useRef(null),[ne,ae]=w.useState(""),[de,fe]=w.useState(!1),ie=w.useRef(null),[Ae,me]=w.useState(t?.printer_id||null),[Ne,ye]=w.useState(null),[le,$e]=w.useState(null),[H,ee]=w.useState(t?.power_alert_enabled||!1),[X,B]=w.useState(t?.power_alert_high?.toString()||""),[I,ce]=w.useState(t?.power_alert_low?.toString()||""),[Te,Le]=w.useState(t?.schedule_enabled||!1),[Ee,$]=w.useState(t?.schedule_on_time||""),[j,Y]=w.useState(t?.schedule_off_time||""),[ge,we]=w.useState(t?.show_in_switchbar||!1),[ve,Ze]=w.useState(!1),[Ie,qe]=w.useState({scanned:0,total:0}),[Je,Qe]=w.useState([]),oe=w.useRef(null),{data:te}=ut({queryKey:["printers"],queryFn:he.getPrinters}),{data:Me}=ut({queryKey:["smart-plugs"],queryFn:he.getSmartPlugs}),{data:Fe}=ut({queryKey:["settings"],queryFn:he.getSettings}),ot=!!(Fe?.ha_enabled&&Fe?.ha_url&&Fe?.ha_token);w.useEffect(()=>{const gt=setTimeout(()=>{C(k)},300);return()=>clearTimeout(gt)},[k]),w.useEffect(()=>{const gt=Kt=>{L.current&&!L.current.contains(Kt.target)&&U(!1),V.current&&!V.current.contains(Kt.target)&&K(!1),G.current&&!G.current.contains(Kt.target)&&z(!1),ie.current&&!ie.current.contains(Kt.target)&&fe(!1)};return document.addEventListener("mousedown",gt),()=>document.removeEventListener("mousedown",gt)},[]);const{data:se,isLoading:je,error:xe}=ut({queryKey:["ha-entities",O],queryFn:()=>he.getHAEntities(O||void 0),enabled:i==="homeassistant"&&ot,retry:!1,staleTime:0}),{data:Oe}=ut({queryKey:["ha-sensor-entities"],queryFn:he.getHASensorEntities,enabled:i==="homeassistant"&&ot,retry:!1,staleTime:0});w.useEffect(()=>{const gt=Kt=>{Kt.key==="Escape"&&e()};return window.addEventListener("keydown",gt),()=>{window.removeEventListener("keydown",gt),oe.current&&clearInterval(oe.current)}},[e]);const Ue=async()=>{Ze(!0),Qe([]),qe({scanned:0,total:0}),$e(null);try{await he.startTasmotaScan();const gt=async()=>{try{const Kt=await he.getTasmotaScanStatus();qe({scanned:Kt.scanned,total:Kt.total});const bn=await he.getDiscoveredTasmotaDevices();Qe(bn),Kt.running||(Ze(!1),oe.current&&(clearInterval(oe.current),oe.current=null))}catch(Kt){console.error("Polling error:",Kt)}};await gt(),oe.current=setInterval(gt,500)}catch(gt){Ze(!1);const Kt=gt instanceof Error?gt.message:typeof gt=="string"?gt:JSON.stringify(gt);$e(Kt||"Failed to start scan")}},Ce=async()=>{try{await he.stopTasmotaScan()}catch{}Ze(!1),oe.current&&(clearInterval(oe.current),oe.current=null)},We=gt=>{u(gt.ip_address),l(gt.name),ye(null)},pt=mt({mutationFn:()=>he.testSmartPlugConnection(c,d||null,m||null),onSuccess:gt=>{ye(gt),$e(null),!o&>.device_name&&l(gt.device_name)},onError:gt=>{ye(null),$e(gt.message)}}),kt=mt({mutationFn:gt=>he.createSmartPlug(gt),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:gt=>{$e(gt.message)}}),Lt=mt({mutationFn:gt=>he.updateSmartPlug(t.id,gt),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:gt=>{$e(gt.message)}}),ln=te?.filter(gt=>!Me?.some(bn=>bn.printer_id===gt.id&&bn.id!==t?.id)),Gt=gt=>{if(gt.preventDefault(),$e(null),!o.trim()){$e("Name is required");return}if(i==="tasmota"&&!c.trim()){$e("IP address is required for Tasmota plugs");return}if(i==="homeassistant"&&!b){$e("Entity is required for Home Assistant plugs");return}const Kt={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"&&A||null,username:i==="tasmota"&&d.trim()||null,password:i==="tasmota"&&m.trim()||null,printer_id:Ae,power_alert_enabled:H,power_alert_high:X?parseFloat(X):null,power_alert_low:I?parseFloat(I):null,schedule_enabled:Te,schedule_on_time:Ee||null,schedule_off_time:j||null,show_in_switchbar:ge};r?Lt.mutate(Kt):kt.mutate(Kt)},_n=kt.isPending||Lt.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:gt=>gt.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(Vt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:Gt,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"),ye(null),$e(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(Ks,{className:"w-4 h-4"}),"Tasmota"]}),s.jsxs("button",{type:"button",onClick:()=>{a("homeassistant"),ye(null),$e(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(cN,{className:"w-4 h-4"}),"Home Assistant"]})]}),!r&&i==="tasmota"&&s.jsxs("div",{className:"space-y-3",children:[ve?s.jsxs(Se,{type:"button",variant:"secondary",onClick:Ce,className:"w-full",children:[s.jsx(Vt,{className:"w-4 h-4"}),"Stop Scanning"]}):s.jsxs(Se,{type:"button",variant:"primary",onClick:Ue,className:"w-full",children:[s.jsx(Ea,{className:"w-4 h-4"}),"Discover Tasmota Devices"]}),ve&&Ie.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:[Ie.scanned," / ",Ie.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:`${Ie.scanned/Ie.total*100}%`}})})]}),Je.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("p",{className:"text-xs text-bambu-gray",children:["Found ",Je.length," device(s) - click to select:"]}),s.jsx("div",{className:"max-h-40 overflow-y-auto space-y-1",children:Je.map(gt=>s.jsxs("button",{type:"button",onClick:()=>We(gt),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(Ks,{className:"w-4 h-4 text-bambu-green"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:gt.name}),s.jsx("p",{className:"text-xs text-bambu-gray",children:gt.ip_address})]})]}),gt.state&&s.jsxs("span",{className:`flex items-center gap-1 text-xs ${gt.state==="ON"?"text-bambu-green":"text-bambu-gray"}`,children:[s.jsx(Eu,{className:"w-3 h-3"}),gt.state]})]},gt.ip_address))})]}),!ve&&Je.length===0&&Ie.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:[!ot&&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..."})})]})]}),ot&&s.jsxs(s.Fragment,{children:[je&&s.jsxs("div",{className:"flex items-center justify-center py-4 text-bambu-gray",children:[s.jsx(dt,{className:"w-5 h-5 animate-spin mr-2"}),"Loading entities..."]}),xe&&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: ",xe.message]}),(()=>{const gt=Me?.filter(At=>At.ha_entity_id&&At.id!==t?.id).map(At=>At.ha_entity_id)||[],Kt=(se||[]).filter(At=>!gt.includes(At.entity_id)),bn=se?.find(At=>At.entity_id===b);return s.jsxs("div",{ref:L,className:"relative",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Select Entity *"}),s.jsxs("div",{className:"relative",children:[s.jsx(Ea,{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:D?k:bn?`${bn.friendly_name} (${bn.entity_id})`:"",onChange:At=>{E(At.target.value),D||U(!0)},onFocus:()=>{U(!0),E("")},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&&!D&&s.jsx("button",{type:"button",onClick:()=>{y(""),E("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Vt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),je&&s.jsx(dt,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray animate-spin"})]}),D&&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:[je&&s.jsxs("div",{className:"px-3 py-2 text-sm text-bambu-gray flex items-center gap-2",children:[s.jsx(dt,{className:"w-4 h-4 animate-spin"}),"Loading..."]}),!je&&Kt.length===0&&s.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:O?`No entities found matching "${O}"`:"No entities available"}),!je&&Kt.map(At=>s.jsxs("button",{type:"button",onClick:()=>{y(At.entity_id),U(!1),E(""),o||l(At.friendly_name)},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary transition-colors ${At.entity_id===b?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[s.jsx("div",{className:"font-medium",children:At.friendly_name}),s.jsxs("div",{className:"text-xs text-bambu-gray flex items-center justify-between",children:[s.jsx("span",{children:At.entity_id}),s.jsx("span",{className:At.state==="on"?"text-bambu-green":"",children:At.state})]})]},At.entity_id))]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:O?`Searching all entities (${Kt.length} found)`:`Showing switch, light, input_boolean (${Kt.length} available)`})]})})(),b&&Oe&&Oe.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 gt=Oe.filter(At=>At.unit_of_measurement==="W"||At.unit_of_measurement==="kW"||At.unit_of_measurement==="mW"),Kt=q?gt.filter(At=>At.entity_id.toLowerCase().includes(q.toLowerCase())||At.friendly_name.toLowerCase().includes(q.toLowerCase())):gt,bn=Oe.find(At=>At.entity_id===x);return s.jsxs("div",{ref:V,className:"relative",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Power Sensor (W)"}),s.jsxs("div",{className:"relative",children:[s.jsx(Ea,{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:bn?`${bn.friendly_name} (${bn.state} ${bn.unit_of_measurement})`:"",onChange:At=>{P(At.target.value),W||K(!0)},onFocus:()=>{K(!0),P("")},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(""),P("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Vt,{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(""),K(!1),P("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),Kt.map(At=>s.jsxs("button",{type:"button",onClick:()=>{v(At.entity_id),K(!1),P("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${At.entity_id===x?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[s.jsx("div",{className:"font-medium",children:At.friendly_name}),s.jsxs("div",{className:"text-xs text-bambu-gray",children:[At.entity_id," • ",At.state," ",At.unit_of_measurement]})]},At.entity_id)),Kt.length===0&&s.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})(),(()=>{const gt=Oe.filter(At=>At.unit_of_measurement==="kWh"||At.unit_of_measurement==="Wh"||At.unit_of_measurement==="MWh"),Kt=Q?gt.filter(At=>At.entity_id.toLowerCase().includes(Q.toLowerCase())||At.friendly_name.toLowerCase().includes(Q.toLowerCase())):gt,bn=Oe.find(At=>At.entity_id===S);return s.jsxs("div",{ref:G,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(Ea,{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:J?Q:bn?`${bn.friendly_name} (${bn.state} ${bn.unit_of_measurement})`:"",onChange:At=>{re(At.target.value),J||z(!0)},onFocus:()=>{z(!0),re("")},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&&!J&&s.jsx("button",{type:"button",onClick:()=>{M(""),re("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Vt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),J&&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),re("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),Kt.map(At=>s.jsxs("button",{type:"button",onClick:()=>{M(At.entity_id),z(!1),re("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${At.entity_id===S?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[s.jsx("div",{className:"font-medium",children:At.friendly_name}),s.jsxs("div",{className:"text-xs text-bambu-gray",children:[At.entity_id," • ",At.state," ",At.unit_of_measurement]})]},At.entity_id)),Kt.length===0&&s.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})(),(()=>{const gt=Oe.filter(At=>At.unit_of_measurement==="kWh"||At.unit_of_measurement==="Wh"||At.unit_of_measurement==="MWh"),Kt=ne?gt.filter(At=>At.entity_id.toLowerCase().includes(ne.toLowerCase())||At.friendly_name.toLowerCase().includes(ne.toLowerCase())):gt,bn=Oe.find(At=>At.entity_id===A);return s.jsxs("div",{ref:ie,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(Ea,{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:de?ne:bn?`${bn.friendly_name} (${bn.state} ${bn.unit_of_measurement})`:"",onChange:At=>{ae(At.target.value),de||fe(!0)},onFocus:()=>{fe(!0),ae("")},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"}),A&&!de&&s.jsx("button",{type:"button",onClick:()=>{T(""),ae("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Vt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),de&&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:()=>{T(""),fe(!1),ae("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),Kt.map(At=>s.jsxs("button",{type:"button",onClick:()=>{T(At.entity_id),fe(!1),ae("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${At.entity_id===A?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[s.jsx("div",{className:"font-medium",children:At.friendly_name}),s.jsxs("div",{className:"text-xs text-bambu-gray",children:[At.entity_id," • ",At.state," ",At.unit_of_measurement]})]},At.entity_id)),Kt.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:gt=>{u(gt.target.value),ye(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(Se,{type:"button",variant:"secondary",onClick:()=>pt.mutate(),disabled:!c.trim()||pt.isPending,children:[pt.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(ig,{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(Un,{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(ex,{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:gt=>l(gt.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:gt=>f(gt.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:gt=>p(gt.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:gt=>me(gt.target.value?Number(gt.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)"}),ln?.map(gt=>s.jsx("option",{value:gt.id,children:gt.name},gt.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(Ef,{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:gt=>ee(gt.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:X,onChange:gt=>B(gt.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:gt=>ce(gt.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(Zn,{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:Te,onChange:gt=>Le(gt.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"})]})]}),Te&&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:Ee,onChange:gt=>$(gt.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:j,onChange:gt=>Y(gt.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(uN,{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:ge,onChange:gt=>we(gt.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(Se,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(Se,{type:"submit",disabled:_n,className:"flex-1",children:[_n?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(_s,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function Gn({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 jYe={callmebot:"CallMeBot/WhatsApp",ntfy:"ntfy",pushover:"Pushover",telegram:"Telegram",email:"Email",discord:"Discord",webhook:"Webhook"};function PYe({provider:t,onEdit:e}){const n=on(),[r,i]=w.useState(!1),[a,o]=w.useState(!1),[l,c]=w.useState(null),{data:u}=ut({queryKey:["printers"],queryFn:he.getPrinters}),d=u?.find(y=>y.id===t.printer_id),f=mt({mutationFn:y=>he.updateNotificationProvider(t.id,y),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),m=mt({mutationFn:()=>he.deleteNotificationProvider(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),p=mt({mutationFn:()=>he.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(St,{className:"relative",children:s.jsxs(Nt,{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(Ef,{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:jYe[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: ",_g(t.last_success)]}),t.last_error&&t.last_error_at&&(!t.last_success||(Ni(t.last_error_at)?.getTime()||0)>(Ni(t.last_success)?.getTime()||0))&&s.jsx("span",{className:"text-xs text-status-error",title:t.last_error,children:"Error"}),s.jsx(Gn,{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(F1,{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(oi,{className:"w-3 h-3"}),"Digest ",t.daily_digest_time]})]}),s.jsx("div",{className:"mb-3",children:s.jsxs(Se,{size:"sm",variant:"secondary",disabled:p.isPending,onClick:()=>{c(null),p.mutate()},className:"w-full",children:[p.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(GD,{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(Un,{className:"w-4 h-4"}):s.jsx(ia,{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(Jd,{className:"w-4 h-4"}),"Event Settings"]}),a?s.jsx(pu,{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(Gn,{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(Gn,{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(Gn,{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(Gn,{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(Gn,{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(Gn,{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(Gn,{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(Gn,{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(Gn,{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(Gn,{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(Gn,{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(Gn,{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(Gn,{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(Gn,{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(Gn,{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(F1,{className:"w-4 h-4 text-purple-400"}),s.jsx("p",{className:"text-sm text-white",children:"Quiet Hours"})]}),s.jsx(Gn,{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(Zn,{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(oi,{className:"w-4 h-4 text-emerald-400"}),s.jsx("p",{className:"text-sm text-white",children:"Daily Digest"})]}),s.jsx(Gn,{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(Zn,{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(Se,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[s.jsx(hN,{className:"w-4 h-4"}),"Edit"]}),s.jsx(Se,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:s.jsx(dn,{className:"w-4 h-4"})})]})]})]})}),r&&s.jsx(Hn,{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 fq=[{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 RYe({provider:t,onClose:e}){const n=on(),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"),[A,T]=w.useState(t?.on_print_start??!1),[k,E]=w.useState(t?.on_print_complete??!0),[O,C]=w.useState(t?.on_print_failed??!0),[D,U]=w.useState(t?.on_print_stopped??!0),[L,q]=w.useState(t?.on_print_progress??!1),[P,W]=w.useState(t?.on_printer_offline??!1),[K,V]=w.useState(t?.on_printer_error??!1),[Q,re]=w.useState(t?.on_filament_low??!1),[J,z]=w.useState(t?.on_maintenance_due??!1),[G,ne]=w.useState(t?.config?Object.fromEntries(Object.entries(t.config).map(([B,I])=>[B,String(I)])):{}),[ae,de]=w.useState(null),[fe,ie]=w.useState(null),{data:Ae}=ut({queryKey:["printers"],queryFn:he.getPrinters});w.useEffect(()=>{const B=I=>{I.key==="Escape"&&e()};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[e]);const me=mt({mutationFn:()=>he.testNotificationConfig({provider_type:o,config:G}),onSuccess:B=>{de(B),ie(null)},onError:B=>{de({success:!1,message:B.message})}}),Ne=mt({mutationFn:B=>he.createNotificationProvider(B),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:B=>{ie(B.message)}}),ye=mt({mutationFn:B=>he.updateNotificationProvider(t.id,B),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:B=>{ie(B.message)}}),le=B=>{if(B.preventDefault(),ie(null),!i.trim()){ie("Name is required");return}const I=ee(o);for(const Te of I)if(!G[Te.key]?.trim()){ie(`${Te.label} is required`);return}const ce={name:i.trim(),provider_type:o,config:G,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:A,on_print_complete:k,on_print_failed:O,on_print_stopped:D,on_print_progress:L,on_printer_offline:P,on_printer_error:K,on_filament_low:Q,on_maintenance_due:J};r?ye.mutate(ce):Ne.mutate(ce)},$e=Ne.isPending||ye.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[]}},ee=B=>H(B).filter(I=>I.required),X=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(Vt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:le,className:"p-6 space-y-4",children:[fe&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:fe}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),s.jsx("input",{type:"text",value:i,onChange: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({}),de(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:fq.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:fq.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"}),X.filter(B=>!("showIf"in B)||B.showIf?.(G)!==!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:G[B.key]||B.options[0]?.value||"",onChange:I=>{ne({...G,[B.key]:I.target.value}),de(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:G[B.key]||"",onChange:I=>{ne({...G,[B.key]:I.target.value}),de(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(Se,{type:"button",variant:"secondary",onClick:()=>{de(null),me.mutate()},disabled:me.isPending||!G[ee(o)[0]?.key],className:"flex-1",children:[me.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(GD,{className:"w-4 h-4"}),"Test Configuration"]})}),ae&&s.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${ae.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:ae.success?s.jsxs(s.Fragment,{children:[s.jsx(Un,{className:"w-5 h-5"}),s.jsx("span",{children:ae.message})]}):s.jsxs(s.Fragment,{children:[s.jsx(ia,{className:"w-5 h-5"}),s.jsx("span",{children:ae.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(Gn,{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(Gn,{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(Gn,{checked:A,onChange:T})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Complete"}),s.jsx(Gn,{checked:k,onChange:E})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Failed"}),s.jsx(Gn,{checked:O,onChange:C})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Stopped"}),s.jsx(Gn,{checked:D,onChange:U})]}),s.jsxs("div",{className:"flex items-center justify-between col-span-2",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-sm text-white",children:"Progress"}),s.jsx("span",{className:"text-xs text-bambu-gray ml-1",children:"(25%, 50%, 75%)"})]}),s.jsx(Gn,{checked:L,onChange:q})]})]})]}),s.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Printer Status"}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Offline"}),s.jsx(Gn,{checked:P,onChange:W})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Error"}),s.jsx(Gn,{checked:K,onChange:V})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Low Filament"}),s.jsx(Gn,{checked:Q,onChange:re})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Maintenance"}),s.jsx(Gn,{checked:J,onChange:z})]})]})]})]}),s.jsxs("div",{className:"flex gap-3 pt-2",children:[s.jsx(Se,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(Se,{type:"submit",disabled:$e,className:"flex-1",children:[$e?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(_s,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function DYe({template:t,onClose:e}){const n=on(),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}=ut({queryKey:["template-variables"],queryFn:he.getTemplateVariables}),p=m?.find(T=>T.event_type===t.event_type),{data:b,isLoading:y}=ut({queryKey:["template-preview",t.event_type,i,o],queryFn:()=>he.previewTemplate({event_type:t.event_type,title_template:i,body_template:o}),enabled:d&&i.length>0&&o.length>0});w.useEffect(()=>{const T=k=>{k.key==="Escape"&&e()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[e]);const x=mt({mutationFn:T=>he.updateNotificationTemplate(t.id,T),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-templates"]}),e()},onError:T=>{u(T.message)}}),v=mt({mutationFn:()=>he.resetNotificationTemplate(t.id),onSuccess:T=>{a(T.title_template),l(T.body_template),n.invalidateQueries({queryKey:["notification-templates"]})},onError:T=>{u(T.message)}}),S=T=>{if(T.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=T=>{const k=r.current;if(!k)return;const E=k.selectionStart,O=k.selectionEnd,C=o,D=C.substring(0,E),U=C.substring(O),L=D+`{${T}}`+U;l(L),setTimeout(()=>{k.focus();const q=E+T.length+2;k.setSelectionRange(q,q)},0)},A=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(Vt,{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:T=>a(T.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green",placeholder:"Notification title..."})]}),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:T=>l(T.target.value),rows:4,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green font-mono text-sm resize-none",placeholder:"Notification body..."})]}),p&&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(T=>s.jsxs("button",{type:"button",onClick:()=>M(T),className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-xs text-bambu-gray hover:text-white transition-colors",children:[s.jsx(nr,{className:"w-3 h-3"}),T]},T))}),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(Qd,{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(dt,{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(Se,{type:"button",variant:"ghost",onClick:()=>v.mutate(),disabled:v.isPending,className:"text-orange-400 hover:text-orange-300",children:[v.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin mr-2"}):s.jsx(mm,{className:"w-4 h-4 mr-2"}),"Reset to Default"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Se,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),s.jsxs(Se,{onClick:S,disabled:x.isPending||!A,children:[x.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin mr-2"}):s.jsx(_s,{className:"w-4 h-4 mr-2"}),"Save"]})]})]})]})})}const OYe={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"},LYe={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 IYe({onClose:t}){const e=on(),{showToast:n}=qn(),[r,i]=w.useState(7),[a,o]=w.useState(null),[l,c]=w.useState(!1),{data:u}=ut({queryKey:["settings"],queryFn:he.getSettings}),d=u?.time_format||"system",{data:f,isLoading:m,refetch:p,isRefetching:b}=ut({queryKey:["notification-logs",r,l],queryFn:()=>he.getNotificationLogs({days:r,limit:100,success:l?!1:void 0})}),{data:y}=ut({queryKey:["notification-log-stats",r],queryFn:()=>he.getNotificationLogStats(r)}),x=mt({mutationFn:()=>he.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=Ni(S);if(!M)return"";const T=new Date().getTime()-M.getTime();return T<6e4?"Just now":T<36e5?`${Math.floor(T/6e4)}m ago`:T<864e5?`${Math.floor(T/36e5)}h ago`:M.toLocaleDateString()+" "+Yme(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(P0,{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(Un,{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(ia,{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(Se,{size:"sm",variant:"secondary",onClick:()=>p(),disabled:b,children:[b?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(xr,{className:"w-4 h-4"}),"Refresh"]}),s.jsxs(Se,{size:"sm",variant:"secondary",onClick:()=>x.mutate(),disabled:x.isPending,className:"text-red-400 hover:text-red-300",children:[x.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(dn,{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(dt,{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(FYe,{log:S,isExpanded:a===S.id,onToggle:()=>o(a===S.id?null:S.id),formatDate:v,formatFullDate:M=>wg(M,d)},S.id))}):s.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[s.jsx(P0,{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 FYe({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(Un,{className:"w-4 h-4 text-bambu-green shrink-0"}):s.jsx(ia,{className:"w-4 h-4 text-red-400 shrink-0"}),s.jsx("span",{className:`text-xs font-medium ${LYe[t.event_type]||"text-bambu-gray"}`,children:OYe[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(pu,{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)]})]})]})]})}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=on(),[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}=ut({queryKey:["spoolman-settings"],queryFn:UYe}),{data:v,isLoading:S,refetch:M}=ut({queryKey:["spoolman-status"],queryFn:he.getSpoolmanStatus,refetchInterval:3e4}),{data:A}=ut({queryKey:["printers"],queryFn:he.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(()=>{T.mutate()},500);return()=>clearTimeout(W)}},[e,r,a,f]);const T=mt({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=mt({mutationFn:he.connectSpoolman,onSuccess:()=>{M()}}),E=mt({mutationFn:he.disconnectSpoolman,onSuccess:()=>{M()}}),O=mt({mutationFn:he.syncAllPrintersAms,onSuccess:P=>{P.success}}),C=mt({mutationFn:P=>he.syncPrinterAms(P),onSuccess:P=>{P.success}}),D=()=>{u==="all"?O.mutate():C.mutate(u)},U=O.isPending||C.isPending,L=u==="all"?O.data:C.data,q=u==="all"?O.isSuccess:C.isSuccess;return x?s.jsxs(St,{children:[s.jsx(er,{children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(su,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]})}),s.jsx(Nt,{children:s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(dt,{className:"w-6 h-6 text-bambu-green animate-spin"})})})]}):s.jsxs(St,{children:[s.jsx(er,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(su,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]}),T.isPending&&s.jsx(dt,{className:"w-4 h-4 text-bambu-green animate-spin"}),l&&s.jsx(ns,{className:"w-4 h-4 text-bambu-green"})]})}),s.jsxs(Nt,{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:P=>n(P.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:P=>i(P.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:P=>o(P.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(dt,{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(ns,{className:"w-4 h-4"}),"Connected"]}):s.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-500",children:[s.jsx(Vt,{className:"w-4 h-4"}),"Disconnected"]})]}),s.jsx("div",{className:"flex gap-2",children:v?.connected?s.jsxs(Se,{variant:"secondary",size:"sm",onClick:()=>E.mutate(),disabled:E.isPending,children:[E.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(Ihe,{className:"w-4 h-4"}),"Disconnect"]}):s.jsxs(Se,{size:"sm",onClick:()=>k.mutate(),disabled:k.isPending||!r,children:[k.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(Wl,{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:P=>d(P.target.value==="all"?"all":Number(P.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"}),A?.map(P=>s.jsx("option",{value:P.id,children:P.name},P.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(Se,{variant:"secondary",size:"sm",onClick:D,disabled:U,children:[U?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(xr,{className:"w-4 h-4"}),"Sync"]})]})]}),q&&L&&s.jsxs("div",{className:"mt-3 space-y-2",children:[s.jsx("div",{className:`p-2 rounded text-sm ${L.success?"bg-green-500/20 border border-green-500/50 text-green-400":"bg-yellow-500/20 border border-yellow-500/50 text-yellow-400"}`,children:L.success?`Synced ${L.synced_count} spool${L.synced_count!==1?"s":""} successfully`:`Synced ${L.synced_count} spool${L.synced_count!==1?"s":""} with ${L.errors.length} error${L.errors.length!==1?"s":""}`}),L.skipped_count>0&&s.jsxs("div",{className:"p-2 bg-amber-500/10 border border-amber-500/30 rounded text-sm",children:[s.jsxs("div",{className:"flex items-center justify-between text-amber-400 mb-1",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(kn,{className:"w-3.5 h-3.5"}),s.jsxs("span",{className:"font-medium",children:[L.skipped_count," spool",L.skipped_count!==1?"s":""," skipped"]})]}),L.skipped_count>5&&s.jsx("button",{onClick:()=>b(!p),className:"text-xs text-amber-400 hover:text-amber-300 underline",children:p?"Show less":"Show all"})]}),s.jsxs("ul",{className:"text-xs text-amber-300/80 space-y-0.5",children:[(p?L.skipped:L.skipped.slice(0,5)).map((P,W)=>s.jsxs("li",{className:"flex items-center gap-2",children:[P.color&&s.jsx("span",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:`#${P.color}`}}),s.jsx("span",{children:P.location}),s.jsxs("span",{className:"text-amber-300/60",children:["- ",P.reason]})]},W)),!p&&L.skipped_count>5&&s.jsxs("li",{className:"text-amber-300/60 italic",children:["...and ",L.skipped_count-5," more"]})]})]}),L.errors.length>0&&s.jsxs("div",{className:"p-2 bg-red-500/10 border border-red-500/30 rounded text-sm",children:[s.jsx("div",{className:"text-red-400 font-medium mb-1",children:"Errors:"}),s.jsx("ul",{className:"text-xs text-red-300/80 space-y-0.5",children:L.errors.map((P,W)=>s.jsx("li",{children:P},W))})]})]})]})]})]})}function $Ye({link:t,onClose:e}){const n=on(),{mode:r}=hh(),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?he.getExternalLinkIconUrl(t.id):null),[x,v]=w.useState(null),[S,M]=w.useState(null);w.useEffect(()=>{const U=L=>{L.key==="Escape"&&e()};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[e]);const A=mt({mutationFn:async U=>{const L=await he.createExternalLink(U);return x?await he.uploadExternalLinkIcon(L.id,x):L},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:U=>{M(U.message)}}),T=mt({mutationFn:async U=>{let L=await he.updateExternalLink(t.id,U);return x?L=await he.uploadExternalLinkIcon(t.id,x):!m&&t?.custom_icon&&(L=await he.deleteExternalLinkIcon(t.id)),L},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:U=>{M(U.message)}}),k=U=>{const L=U.target.files?.[0];if(L){if(!["image/png","image/jpeg","image/gif","image/svg+xml","image/webp","image/x-icon"].includes(L.type)){M("Please select a valid image file (PNG, JPG, GIF, SVG, WebP, or ICO)");return}if(L.size>1024*1024){M("Image file must be less than 1MB");return}v(L),p(!0);const P=new FileReader;P.onload=W=>{y(W.target?.result)},P.readAsDataURL(L)}},E=()=>{v(null),y(null),p(!1),a.current&&(a.current.value="")},O=U=>{if(U.preventDefault(),M(null),!o.trim()){M("Name is required");return}if(!c.trim()){M("URL is required");return}if(!c.startsWith("http://")&&!c.startsWith("https://")){M("URL must start with http:// or https://");return}const L={name:o.trim(),url:c.trim(),icon:d};i?T.mutate(L):A.mutate(L)},C=A.isPending||T.isPending,D=gN(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(D,{className:"w-5 h-5"})}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:i?"Edit Link":"Add External Link"})]}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Vt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:O,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:E,className:"p-1 text-red-400 hover:text-red-300 transition-colors",title:"Remove custom icon",children:s.jsx(dn,{className:"w-4 h-4"})})]}):s.jsxs(Se,{type:"button",variant:"secondary",size:"sm",onClick:()=>a.current?.click(),children:[s.jsx(pi,{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(Vme,{value:d,onChange:f})]})]}),s.jsxs("div",{className:"flex gap-3 pt-2",children:[s.jsx(Se,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(Se,{type:"submit",disabled:C,className:"flex-1",children:[C?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(_s,{className:"w-4 h-4"}),i?"Save":"Add"]})]})]})]})})}function HYe(){const t=on(),[e,n]=w.useState(!1),[r,i]=w.useState(null),[a,o]=w.useState(null),[l,c]=w.useState(null),{data:u,isLoading:d}=ut({queryKey:["external-links"],queryFn:he.getExternalLinks}),f=mt({mutationFn:S=>he.deleteExternalLink(S),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),m=mt({mutationFn:S=>he.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 A=u.map(O=>O.id),T=A.indexOf(l),k=A.indexOf(M);if(T===-1||k===-1)return;const E=[...A];E.splice(T,1),E.splice(k,0,l),m.mutate(E),c(null)},x=S=>{o(S)},v=()=>{a&&(f.mutate(a.id),o(null))};return s.jsxs(s.Fragment,{children:[s.jsxs(St,{children:[s.jsx(er,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Wl,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Sidebar Links"})]}),s.jsxs(Se,{size:"sm",onClick:()=>n(!0),children:[s.jsx(nr,{className:"w-4 h-4"}),"Add Link"]})]})}),s.jsxs(Nt,{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(dt,{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=gN(S.icon);return s.jsxs("div",{draggable:!0,onDragStart:A=>p(A,S.id),onDragOver:b,onDrop:A=>y(A,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(yg,{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(zr,{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(la,{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(dn,{className:"w-4 h-4"})})]})]},S.id)})}):s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx(Wl,{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(Hn,{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=on(),{showToast:e}=qn(),[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}=ut({queryKey:["virtual-printer-settings"],queryFn:r1.getSettings,refetchInterval:1e4}),{data:x}=ut({queryKey:["virtual-printer-models"],queryFn:r1.getModels});w.useEffect(()=>{if(b){r(b.enabled);let O=b.mode==="queue"?"review":b.mode;O!=="immediate"&&O!=="review"&&O!=="print_queue"&&(O="immediate"),l(O),u(b.model)}},[b]);const v=mt({mutationFn:O=>r1.updateSettings(O),onSuccess:()=>{t.invalidateQueries({queryKey:["virtual-printer-settings"]}),e("Virtual printer settings updated"),p(null)},onError:O=>{if(e(O.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 O=!n;if(O&&!i&&!b?.access_code_set){e("Please set an access code first","error");return}r(O),p("toggle"),v.mutate({enabled:O,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("")},A=O=>{l(O),p("mode"),v.mutate({mode:O})},T=O=>{u(O),p("model"),v.mutate({model:O})};if(y)return s.jsx(St,{children:s.jsx(Nt,{className:"py-8 flex justify-center",children:s.jsx(dt,{className:"w-6 h-6 animate-spin text-bambu-green"})})});const k=b?.status,E=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(St,{children:[s.jsx(er,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(qr,{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 ${E?"text-green-400":"text-bambu-gray"}`,children:[s.jsx("span",{className:`w-2 h-2 rounded-full ${E?"bg-green-400 animate-pulse":"bg-gray-500"}`}),E?"Running":"Stopped"]})]})}),s.jsxs(Nt,{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:E?'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:O=>T(O.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(([,O],[,C])=>O.localeCompare(C)).map(([O,C])=>s.jsx("option",{value:O,children:C},O))}),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&&E&&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(ns,{className:"w-4 h-4"}),"Access code is set"]}):s.jsxs("span",{className:"flex items-center gap-1 text-yellow-400",children:[s.jsx(kn,{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:O=>a(O.target.value),placeholder:b?.access_code_set?"Enter new code to change":"Enter 8-char code",maxLength:8,className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white placeholder-bambu-gray pr-10 font-mono"}),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(My,{className:"w-4 h-4"}):s.jsx(Qd,{className:"w-4 h-4"})})]}),s.jsx(Se,{onClick:M,disabled:!i||m==="accessCode",variant:"primary",children:m==="accessCode"?s.jsx(dt,{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:()=>A("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:()=>A("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:()=>A("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(St,{className:"border-l-4 border-l-yellow-500",children:s.jsx(Nt,{className:"py-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(kn,{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(zr,{className:"w-4 h-4"}),"Read the setup guide before enabling"]})]})]})})}),s.jsx(St,{children:s.jsx(Nt,{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&&E&&s.jsxs(St,{children:[s.jsx(er,{children:s.jsx("h3",{className:"text-md font-semibold text-white",children:"Status Details"})}),s.jsx(Nt,{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 Jw=[{id:"settings",labelKey:"backup.categories.settings",defaultLabel:"App Settings",icon:s.jsx(mN,{className:"w-4 h-4"}),default:!0,description:"Language, theme, update preferences"},{id:"notifications",labelKey:"backup.categories.notifications",defaultLabel:"Notification Providers",icon:s.jsx(Ef,{className:"w-4 h-4"}),default:!0,description:"ntfy, Pushover, Discord, etc."},{id:"templates",labelKey:"backup.categories.templates",defaultLabel:"Notification Templates",icon:s.jsx(Za,{className:"w-4 h-4"}),default:!0,description:"Custom message templates"},{id:"smart_plugs",labelKey:"backup.categories.smartPlugs",defaultLabel:"Smart Plugs",icon:s.jsx(Ks,{className:"w-4 h-4"}),default:!0,description:"Tasmota plug configurations"},{id:"external_links",labelKey:"backup.categories.externalLinks",defaultLabel:"External Links",icon:s.jsx(Jg,{className:"w-4 h-4"}),default:!0,description:"Sidebar links to external services"},{id:"printers",labelKey:"backup.categories.printers",defaultLabel:"Printers",icon:s.jsx(qr,{className:"w-4 h-4"}),default:!1,description:"Printer info (access codes excluded)"},{id:"plate_calibration",labelKey:"backup.categories.plateCalibration",defaultLabel:"Plate Detection",icon:s.jsx(Hf,{className:"w-4 h-4"}),default:!1,description:"Empty plate reference images",requiresPrinters:!0},{id:"filaments",labelKey:"backup.categories.filaments",defaultLabel:"Filament Inventory",icon:s.jsx(HD,{className:"w-4 h-4"}),default:!1,description:"Filament types and costs"},{id:"maintenance",labelKey:"backup.categories.maintenance",defaultLabel:"Maintenance Types",icon:s.jsx(eh,{className:"w-4 h-4"}),default:!1,description:"Custom maintenance schedules"},{id:"archives",labelKey:"backup.categories.archives",defaultLabel:"Print Archives",icon:s.jsx(es,{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(Ta,{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(pi,{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(mf,{className:"w-4 h-4"}),default:!1,description:"Webhook API keys (new keys generated on import)"}];function GYe({onClose:t,onExport:e}){const{t:n}=Xg(),[r,i]=w.useState(()=>{const b={};return Jw.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={};Jw.forEach(y=>{b[y.id]=!0}),i(b)},f=()=>{const b={};Jw.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(St,{className:"w-full max-w-lg",onClick:b=>b.stopPropagation(),children:s.jsxs(Nt,{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(Hr,{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(Vt,{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:Jw.map(b=>{const y=l||b.requiresPrinters&&!r.printers;return s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg transition-colors ${y?"cursor-not-allowed opacity-50":"cursor-pointer"} ${r[b.id]&&!y?"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]&&!y,onChange:()=>u(b.id),disabled:y,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]&&!y?"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.requiresPrinters&&!r.printers?"Requires Printers to be selected":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(es,{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(mf,{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(Gn,{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(kn,{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(Se,{variant:"secondary",onClick:t,disabled:l,children:n("common.cancel",{defaultValue:"Cancel"})}),s.jsx(Se,{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(dt,{className:"w-4 h-4 mr-2 animate-spin"}),n("backup.exporting",{defaultValue:"Exporting..."})]}):s.jsxs(s.Fragment,{children:[s.jsx(Hr,{className:"w-4 h-4 mr-2"}),n("backup.export",{defaultValue:"Export"})]})})]})]})]})})})}const mq={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 WYe({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 A=T=>{T.key==="Escape"&&r!=="restoring"&&(r==="result"&&u?.success&&n(),t())};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[t,n,r,u]);const b=A=>{const T=A.target.files?.[0];T&&c(T)},y=async()=>{if(l){i("restoring");try{const A=await e(l,a);d(A),i("result")}catch{d({success:!1,message:"Failed to restore backup. Please check the file format."}),i("result")}}},x=()=>{u?.success&&n(),t()},v=A=>{m(T=>{const k=new Set(T);return k.has(A)?k.delete(A):k.add(A),k})},S=u?.restored?Object.values(u.restored).reduce((A,T)=>A+T,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:A=>{A.target===A.currentTarget&&r!=="restoring"&&t()},children:s.jsx(St,{className:"w-full max-w-lg",children:s.jsxs(Nt,{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(Un,{className:"w-5 h-5"}):r==="result"&&!u?.success?s.jsx(kn,{className:"w-5 h-5"}):s.jsx(pi,{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(Vt,{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(Un,{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(pi,{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(kn,{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(xr,{className:"w-4 h-4 text-orange-400"}):s.jsx(R0,{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(Gn,{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(kn,{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(Se,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),s.jsxs(Se,{type:"button",onClick:y,disabled:!l,className:"bg-bambu-green hover:bg-bambu-green-dark disabled:opacity-50",children:[s.jsx(pi,{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(dt,{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(([,A])=>A>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(Un,{className:"w-4 h-4 text-bambu-green"}),"Restored"]}),s.jsxs("div",{className:"space-y-1",children:[Object.entries(u.restored).filter(([,A])=>A>0).map(([A,T])=>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:mq[A]||A}),s.jsx("span",{className:"text-bambu-green font-medium",children:T})]},A)),(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(([,A])=>A>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(R0,{className:"w-4 h-4 text-yellow-500"}),"Skipped (already exist)"]}),s.jsx("div",{className:"space-y-1",children:Object.entries(u.skipped).filter(([,A])=>A>0).map(([A,T])=>{const k=u.skipped_details?.[A]||[],E=f.has(A);return s.jsxs("div",{children:[s.jsxs("button",{onClick:()=>k.length>0&&v(A),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:[mq[A]||A,k.length>0&&(E?s.jsx(pu,{className:"w-3 h-3"}):s.jsx(Oi,{className:"w-3 h-3"}))]}),s.jsx("span",{className:"text-yellow-500 font-medium",children:T})]}),E&&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((O,C)=>s.jsx("div",{children:O},C)),k.length>10&&s.jsxs("div",{className:"text-bambu-gray/60",children:["...and ",k.length-10," more"]})]})]},A)})})]}),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(kn,{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((A,T)=>s.jsxs("div",{className:"p-2 rounded bg-bambu-dark",children:[s.jsx("div",{className:"text-sm text-white font-medium mb-1",children:A.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:A.key}),s.jsx("button",{onClick:()=>navigator.clipboard.writeText(A.key),className:"text-xs text-bambu-gray hover:text-white px-2 py-1 rounded bg-bambu-dark-tertiary",children:"Copy"})]})]},T))})]})]}),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(Se,{onClick:x,children:"Close"})})]})]})})})}function pq({status:t}){if(!t)return null;const e={success:"bg-green-500/20 text-green-400",failed:"bg-red-500/20 text-red-400",skipped:"bg-yellow-500/20 text-yellow-400",running:"bg-blue-500/20 text-blue-400"},n={success:s.jsx(Un,{className:"w-3 h-3"}),failed:s.jsx(ia,{className:"w-3 h-3"}),skipped:s.jsx(R0,{className:"w-3 h-3"}),running:s.jsx(dt,{className:"w-3 h-3 animate-spin"})};return s.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-medium ${e[t]||"bg-gray-500/20 text-gray-400"}`,children:[n[t],t.charAt(0).toUpperCase()+t.slice(1)]})}function qYe(t){return t?new Date(t).toLocaleString():"-"}function gq(t){if(!t)return"-";const e=new Date(t),n=new Date,r=e.getTime()-n.getTime(),i=Math.round(r/6e4);if(i<0){const a=Math.abs(i);if(a<60)return`${a}m ago`;const o=Math.floor(a/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}else{if(i<60)return`in ${i}m`;const a=Math.floor(i/60);return a<24?`in ${a}h`:`in ${Math.floor(a/24)}d`}}function KYe(){const t=on(),{showToast:e}=qn(),[n,r]=w.useState(""),[i,a]=w.useState(""),[o,l]=w.useState("main"),[c,u]=w.useState(!1),[d,f]=w.useState(!1),[m,p]=w.useState("daily"),[b,y]=w.useState(!0),[x,v]=w.useState(!0),[S,M]=w.useState(!1),[A,T]=w.useState(!0),[k,E]=w.useState(!1),[O,C]=w.useState(!1),[D,U]=w.useState(!1),[L,q]=w.useState(null),P=w.useRef(null),W=w.useRef(!1),{data:K,isLoading:V}=ut({queryKey:["github-backup-config"],queryFn:he.getGitHubBackupConfig}),{data:Q}=ut({queryKey:["github-backup-status"],queryFn:he.getGitHubBackupStatus,refetchInterval:ie=>ie.state.data?.is_running?500:1e4}),{data:re}=ut({queryKey:["github-backup-logs"],queryFn:()=>he.getGitHubBackupLogs(20)}),{data:J}=ut({queryKey:["cloud-status"],queryFn:he.getCloudStatus});w.useEffect(()=>{K&&(r(K.repository_url),l(K.branch),f(K.schedule_enabled),p(K.schedule_type),y(K.backup_kprofiles),v(K.backup_cloud_profiles),M(K.backup_settings),T(K.enabled),a(""),setTimeout(()=>{W.current=!0},100))},[K]);const z=w.useCallback(async(ie=!1)=>{if(K?.has_token)try{ie&&i?(await he.saveGitHubBackupConfig({repository_url:n,access_token:i,branch:o,schedule_enabled:d,schedule_type:m,backup_kprofiles:b,backup_cloud_profiles:x,backup_settings:S,enabled:A}),a(""),e("Token updated")):(await he.updateGitHubBackupConfig({repository_url:n,branch:o,schedule_enabled:d,schedule_type:m,backup_kprofiles:b,backup_cloud_profiles:x,backup_settings:S,enabled:A}),e("Settings saved")),t.invalidateQueries({queryKey:["github-backup-config"]}),t.invalidateQueries({queryKey:["github-backup-status"]})}catch(Ae){e(`Failed to save: ${Ae.message}`,"error")}},[K?.has_token,n,i,o,d,m,b,x,S,A,t,e]);w.useEffect(()=>{if(!(!W.current||!K?.has_token))return P.current&&clearTimeout(P.current),P.current=setTimeout(()=>{z(!1)},500),()=>{P.current&&clearTimeout(P.current)}},[n,o,d,m,b,x,S,A,z,K?.has_token]),w.useEffect(()=>{if(!(!W.current||!K?.has_token||!i))return P.current&&clearTimeout(P.current),P.current=setTimeout(()=>{z(!0)},1e3),()=>{P.current&&clearTimeout(P.current)}},[i,z,K?.has_token]);const G=mt({mutationFn:ie=>he.saveGitHubBackupConfig(ie),onSuccess:()=>{t.invalidateQueries({queryKey:["github-backup-config"]}),t.invalidateQueries({queryKey:["github-backup-status"]}),e("GitHub backup enabled"),a(""),W.current=!0},onError:ie=>{e(`Failed to save: ${ie.message}`,"error")}}),ne=mt({mutationFn:he.triggerGitHubBackup,onSuccess:ie=>{t.invalidateQueries({queryKey:["github-backup-status"]}),t.invalidateQueries({queryKey:["github-backup-logs"]}),ie.success?ie.files_changed>0?e(`Backup complete - ${ie.files_changed} files updated`):e("Backup skipped - no changes"):e(`Backup failed: ${ie.message}`,"error")},onError:ie=>{e(`Backup failed: ${ie.message}`,"error")}}),ae=mt({mutationFn:()=>he.clearGitHubBackupLogs(10),onSuccess:ie=>{t.invalidateQueries({queryKey:["github-backup-logs"]}),e(`Cleared ${ie.deleted} logs`)},onError:ie=>{e(`Failed to clear logs: ${ie.message}`,"error")}}),de=async()=>{U(!0),q(null);try{let ie;if(i){if(!n){e("Enter repository URL","error"),U(!1);return}ie=await he.testGitHubConnection(n,i)}else if(K?.has_token)ie=await he.testGitHubStoredConnection();else{e("Enter repository URL and access token","error"),U(!1);return}q({success:ie.success,message:ie.message})}catch(ie){q({success:!1,message:ie.message})}finally{U(!1)}},fe=()=>{if(!n){e("Repository URL is required","error");return}if(!i){e("Access token is required","error");return}G.mutate({repository_url:n,access_token:i,branch:o,schedule_enabled:d,schedule_type:m,backup_kprofiles:b,backup_cloud_profiles:x,backup_settings:S,enabled:A})};return V?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(dt,{className:"w-8 h-8 animate-spin text-bambu-green"})}):s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[s.jsxs("div",{className:"space-y-6",children:[s.jsxs(St,{children:[s.jsx(er,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(bP,{className:"w-5 h-5 text-gray-400"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"GitHub Backup"})]}),K&&J?.is_authenticated&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:"Enabled"}),s.jsx(Gn,{checked:A,onChange:T})]})]})}),s.jsx(Nt,{className:"space-y-4",children:J?.is_authenticated?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically sync your profiles to a private GitHub repository for backup and version history."}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Repository URL"}),s.jsx("input",{type:"text",value:n,onChange:ie=>{r(ie.target.value),q(null)},placeholder:"https://github.com/username/bambuddy-backup",className:"w-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.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:["Personal Access Token ",K?.has_token&&s.jsx("span",{className:"text-green-400",children:"(saved)"})]}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:c?"text":"password",value:i,onChange:ie=>{a(ie.target.value),q(null)},placeholder:K?.has_token?"Enter new token to update":"ghp_xxxxxxxxxxxx",className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsx("button",{type:"button",onClick:()=>u(!c),className:"absolute right-3 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:c?s.jsx(My,{className:"w-4 h-4"}):s.jsx(Qd,{className:"w-4 h-4"})})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Fine-grained token with Contents read/write permission"})]}),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:"Branch"}),s.jsx("input",{type:"text",value:o,onChange:ie=>l(ie.target.value),placeholder:"main",className:"w-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:"Auto-backup"}),s.jsxs("select",{value:d?m:"disabled",onChange:ie=>{ie.target.value==="disabled"?f(!1):(f(!0),p(ie.target.value))},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"disabled",children:"Manual only"}),s.jsx("option",{value:"hourly",children:"Hourly"}),s.jsx("option",{value:"daily",children:"Daily"}),s.jsx("option",{value:"weekly",children:"Weekly"})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Include in backup"}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:b,onChange:ie=>y(ie.target.checked),className:"w-4 h-4 mt-0.5 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-white text-sm",children:"K-Profiles"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Pressure advance calibration from connected printers"})]})]}),s.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:x,onChange:ie=>v(ie.target.checked),className:"w-4 h-4 mt-0.5 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green",disabled:!J?.is_authenticated}),s.jsxs("div",{children:[s.jsx("span",{className:`text-sm ${J?.is_authenticated?"text-white":"text-bambu-gray"}`,children:"Cloud Profiles"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament, printer, and process presets from Bambu Cloud"})]})]}),s.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:S,onChange:ie=>M(ie.target.checked),className:"w-4 h-4 mt-0.5 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-white text-sm",children:"App Settings"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Bambuddy configuration (excludes sensitive data)"})]})]})]})]}),s.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4 space-y-3",children:[Q?.configured&&s.jsxs("div",{className:"flex items-center justify-between text-sm",children:[s.jsx("div",{className:"flex items-center gap-2 text-bambu-gray",children:Q.last_backup_at?s.jsxs(s.Fragment,{children:[s.jsxs("span",{children:["Last backup: ",gq(Q.last_backup_at)]}),s.jsx(pq,{status:Q.last_backup_status})]}):s.jsx("span",{children:"No backups yet"})}),Q.next_scheduled_run&&s.jsxs("span",{className:"text-bambu-gray",children:[s.jsx(Zn,{className:"w-3 h-3 inline mr-1"}),"Next: ",gq(Q.next_scheduled_run)]})]}),L&&s.jsxs("div",{className:`text-sm flex items-center gap-1 ${L.success?"text-green-400":"text-red-400"}`,children:[L.success?s.jsx(Un,{className:"w-4 h-4"}):s.jsx(ia,{className:"w-4 h-4"}),L.message]}),s.jsx("div",{className:"flex flex-wrap items-center gap-2",children:Q?.configured?s.jsx(s.Fragment,{children:ne.isPending||Q.is_running?s.jsxs("div",{className:"flex items-center gap-2 text-bambu-green",children:[s.jsx(dt,{className:"w-4 h-4 animate-spin"}),s.jsx("span",{className:"text-sm",children:Q.progress||"Starting backup..."})]}):s.jsxs(s.Fragment,{children:[s.jsxs(Se,{variant:"primary",size:"sm",onClick:()=>ne.mutate(),disabled:!K?.enabled,children:[s.jsx(Oo,{className:"w-4 h-4"}),"Backup Now"]}),s.jsxs(Se,{variant:"secondary",size:"sm",onClick:de,disabled:D,children:[D?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(xr,{className:"w-4 h-4"}),"Test"]})]})}):s.jsxs(s.Fragment,{children:[s.jsxs(Se,{variant:"primary",size:"sm",onClick:fe,disabled:G.isPending||!n||!i,children:[G.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(Un,{className:"w-4 h-4"}),"Enable Backup"]}),s.jsxs(Se,{variant:"secondary",size:"sm",onClick:de,disabled:D||!n||!i,children:[D?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(xr,{className:"w-4 h-4"}),"Test Connection"]})]})})]})]}):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(kn,{className:"w-4 h-4 text-yellow-400 mt-0.5 flex-shrink-0"}),s.jsx("p",{className:"text-sm text-yellow-400",children:"Bambu Cloud login required. Sign in under Profiles → Cloud Profiles to enable GitHub backup."})]})})]}),re&&re.length>0&&s.jsxs(St,{children:[s.jsx(er,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(P0,{className:"w-5 h-5 text-gray-400"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"History"})]}),s.jsxs(Se,{variant:"ghost",size:"sm",onClick:()=>ae.mutate(),disabled:ae.isPending,children:[s.jsx(dn,{className:"w-4 h-4"}),"Clear"]})]})}),s.jsx(Nt,{children:s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"text-bambu-gray border-b border-bambu-dark-tertiary",children:[s.jsx("th",{className:"text-left py-2 px-2",children:"Date"}),s.jsx("th",{className:"text-left py-2 px-2",children:"Status"}),s.jsx("th",{className:"text-left py-2 px-2",children:"Commit"})]})}),s.jsx("tbody",{children:re.slice(0,10).map(ie=>s.jsxs("tr",{className:"border-b border-bambu-dark-tertiary/50 hover:bg-bambu-dark-secondary",children:[s.jsx("td",{className:"py-2 px-2 text-white",children:qYe(ie.started_at)}),s.jsx("td",{className:"py-2 px-2",children:s.jsx(pq,{status:ie.status})}),s.jsx("td",{className:"py-2 px-2",children:ie.commit_sha?s.jsxs("a",{href:`${K?.repository_url}/commit/${ie.commit_sha}`,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-green hover:underline inline-flex items-center gap-1",children:[ie.commit_sha.substring(0,7),s.jsx(zr,{className:"w-3 h-3"})]}):s.jsx("span",{className:"text-bambu-gray",children:"-"})})]},ie.id))})]})})})]})]}),s.jsx("div",{className:"space-y-6",children:s.jsxs(St,{children:[s.jsx(er,{children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(su,{className:"w-5 h-5 text-gray-400"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Local Backup"})]})}),s.jsxs(Nt,{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Export or import your Bambuddy data as a local file for manual backup or migration."}),s.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Export Data"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Download all settings, printers, and profiles"})]}),s.jsxs(Se,{variant:"secondary",size:"sm",onClick:()=>E(!0),children:[s.jsx(Hr,{className:"w-4 h-4"}),"Export"]})]}),s.jsxs("div",{className:"flex items-center justify-between py-3",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Import Backup"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Restore from a previous export file"})]}),s.jsxs(Se,{variant:"secondary",size:"sm",onClick:()=>C(!0),children:[s.jsx(pi,{className:"w-4 h-4"}),"Import"]})]})]})]})}),k&&s.jsx(GYe,{onClose:()=>E(!1),onExport:async ie=>{E(!1);try{const{blob:Ae,filename:me}=await he.exportBackup(ie),Ne=URL.createObjectURL(Ae),ye=document.createElement("a");ye.href=Ne,ye.download=me,ye.click(),URL.revokeObjectURL(Ne),e("Backup downloaded successfully")}catch{e("Failed to create backup","error")}}}),O&&s.jsx(WYe,{onClose:()=>C(!1),onRestore:async(ie,Ae)=>await he.importBackup(ie,Ae),onSuccess:()=>{C(!1),e("Backup restored successfully"),t.invalidateQueries()}})]})}const XYe={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 YYe(t,e){const n=e.replace("#/","").split("/");let r=t;for(const i of n)r=r[i];return r}function t0(t,e,n=0){if(n>5)return"...";if(e.$ref)return t0(t,YYe(t,e.$ref),n+1);if(e.allOf){const r={};for(const i of e.allOf){const a=t0(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?[t0(t,e.items,n+1)]:[];case"object":if(e.properties){const r={};for(const[i,a]of Object.entries(e.properties))r[i]=t0(t,a,n+1);return r}return{};default:return null}}function ZYe({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 O={};for(const C of n.parameters)C.schema?.default!==void 0&&(O[C.name]=String(C.schema.default));c(C=>({...O,...C}))}},[a,n.parameters]),w.useEffect(()=>{if(a&&n.requestBody?.content?.["application/json"]?.schema&&!u){const O=n.requestBody.content["application/json"].schema,C=t0(r,O);d(JSON.stringify(C,null,2))}},[a,n.requestBody,r,u]);const S=(()=>{const O=[];for(const C of n.parameters||[])if(C.in==="path"||C.required){const D=l[C.name];(D===void 0||D==="")&&O.push(C.name)}return O})(),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 O=t;const C=new URLSearchParams;for(const J of n.parameters||[]){const z=l[J.name];z!==void 0&&z!==""&&(J.in==="path"?O=O.replace(`{${J.name}}`,encodeURIComponent(z)):J.in==="query"&&C.append(J.name,z))}const D=C.toString(),U=`${O}${D?`?${D}`:""}`,L={"Content-Type":"application/json"};i&&(L["X-API-Key"]=i);const q={method:e.toUpperCase(),headers:L};["post","put","patch"].includes(e)&&u&&(q.body=u);const P=performance.now(),W=await fetch(U,q),K=Math.round(performance.now()-P),V={};W.headers.forEach((J,z)=>{V[z]=J});let Q;W.headers.get("content-type")?.includes("application/json")?Q=await W.json():Q=await W.text(),m({status:W.status,statusText:W.statusText,headers:V,body:Q,duration:K})}catch(O){m({status:0,statusText:"Network Error",headers:{},body:O instanceof Error?O.message:"Unknown error",duration:0})}finally{b(!1)}},A=async()=>{if(f){const O=typeof f.body=="string"?f.body:JSON.stringify(f.body,null,2);try{await navigator.clipboard.writeText(O),x(!0),setTimeout(()=>x(!1),2e3)}catch{const C=document.createElement("textarea");C.value=O,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)}}},T=(n.parameters||[]).filter(O=>O.in==="path"),k=(n.parameters||[]).filter(O=>O.in==="query"),E=["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(Js,{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 ${XYe[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}),T.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:T.map(O=>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:[O.name,O.required&&s.jsx("span",{className:"text-red-400 ml-1",children:"*"})]}),s.jsx("input",{type:"text",value:l[O.name]||"",onChange:C=>c(D=>({...D,[O.name]:C.target.value})),placeholder:O.description||O.schema?.type||"value",className:"flex-1 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm font-mono focus:border-bambu-green focus:outline-none"})]},O.name))})]}),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(O=>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:[O.name,O.required&&s.jsx("span",{className:"text-red-400 ml-1",children:"*"})]}),O.schema?.enum?s.jsxs("select",{value:l[O.name]||"",onChange:C=>c(D=>({...D,[O.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 --"}),O.schema.enum.map(C=>s.jsx("option",{value:C,children:C},C))]}):s.jsx("input",{type:"text",value:l[O.name]||"",onChange:C=>c(D=>({...D,[O.name]:C.target.value})),placeholder:O.description||O.schema?.type||"value",className:"flex-1 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm font-mono focus:border-bambu-green focus:outline-none"})]},O.name))})]}),E&&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:O=>d(O.target.value),rows:8,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm font-mono focus:border-bambu-green focus:outline-none resize-y",placeholder:"JSON request body..."})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Se,{onClick:M,disabled:p,children:[p?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(Oo,{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(oa,{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(Se,{variant:"secondary",size:"sm",onClick:A,children:y?s.jsx(Un,{className:"w-3 h-3 text-green-400"}):s.jsx(ll,{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 QYe({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(dt,{className:"w-8 h-8 text-bambu-green animate-spin"})});if(a||!e)return s.jsx(St,{children:s.jsx(Nt,{className:"py-8",children:s.jsxs("div",{className:"text-center text-red-400",children:[s.jsx(oa,{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 A=M.tags||["Other"];for(const T of A)f[T]||(f[T]=[]),f[T].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:A,spec:T})=>{const k=u.toLowerCase();return M.toLowerCase().includes(k)||A.toLowerCase().includes(k)||(T.summary?.toLowerCase()||"").includes(k)||(T.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(Se,{variant:"secondary",size:"sm",onClick:b,children:"Expand All"}),s.jsx(Se,{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(zr,{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(St,{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(Js,{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(Nt,{className:"pt-0 space-y-2",children:v.map(({path:S,method:M,spec:A})=>s.jsx(ZYe,{path:S,method:M,spec:A,schema:e,apiKey:t},`${M}-${S}`))})]},x))})]})}const JYe=["general","network","plugs","notifications","filament","apikeys","virtual-printer","users","backup"];function eZe(){const t=on(),e=gl(),[n,r]=Xq(),{t:i,i18n:a}=Xg(),{showToast:o}=qn(),{authEnabled:l,user:c,refreshAuth:u}=fh(),{mode:d,darkStyle:f,darkBackground:m,darkAccent:p,lightStyle:b,lightBackground:y,lightAccent:x,setDarkStyle:v,setDarkBackground:S,setDarkAccent:M,setLightStyle:A,setLightBackground:T,setLightAccent:k}=hh(),[E,O]=w.useState(null),[C,D]=w.useState(!1),[U,L]=w.useState(null),[q,P]=w.useState(!1),[W,K]=w.useState(null),[V,Q]=w.useState(null),[re,J]=w.useState(!1),[z,G]=w.useState(OK()),ne=n.get("tab"),ae=ne&&JYe.includes(ne)?ne:"general",[de,fe]=w.useState(ae),ie=be=>{fe(be),be==="general"?n.delete("tab"):n.set("tab",be),r(n,{replace:!0})},[Ae,me]=w.useState(!1),[Ne,ye]=w.useState(""),[le,$e]=w.useState({can_queue:!0,can_control_printer:!1,can_read_status:!0}),[H,ee]=w.useState(null),[X,B]=w.useState(null),[I,ce]=w.useState(""),[Te,Le]=w.useState(!1),[Ee,$]=w.useState(!1),[j,Y]=w.useState(null),[ge,we]=w.useState(!1),[ve,Ze]=w.useState(!1),[Ie,qe]=w.useState(null),[Je,Qe]=w.useState(!1),[oe,te]=w.useState({}),[Me,Fe]=w.useState({}),ot=be=>{G(be),Kme(be)},se=()=>{localStorage.removeItem("sidebarOrder"),window.location.reload()},{data:je,isLoading:xe}=ut({queryKey:["settings"],queryFn:he.getSettings}),{data:Oe,isLoading:Ue}=ut({queryKey:["smart-plugs"],queryFn:he.getSmartPlugs}),{data:Ce,isLoading:We}=ut({queryKey:["smart-plugs-energy",Oe?.map(be=>be.id)],queryFn:async()=>{if(!Oe||Oe.length===0)return null;const be=await Promise.all(Oe.filter(Rt=>Rt.enabled).map(async Rt=>{try{const $t=await he.getSmartPlugStatus(Rt.id);return{plug:Rt,status:$t}}catch{return{plug:Rt,status:null}}}));let Pe=0,wt=0,Mt=0,lt=0,Tt=0;for(const{status:Rt}of be)Rt?.reachable&&Rt.energy&&(Tt++,Rt.energy.power!=null&&(Pe+=Rt.energy.power),Rt.energy.today!=null&&(wt+=Rt.energy.today),Rt.energy.yesterday!=null&&(Mt+=Rt.energy.yesterday),Rt.energy.total!=null&&(lt+=Rt.energy.total));return{totalPower:Pe,totalToday:wt,totalYesterday:Mt,totalLifetime:lt,reachableCount:Tt,totalPlugs:Oe.filter(Rt=>Rt.enabled).length}},enabled:de==="plugs"&&!!Oe&&Oe.length>0,refetchInterval:de==="plugs"?1e4:!1}),{data:pt,isLoading:kt}=ut({queryKey:["notification-providers"],queryFn:he.getNotificationProviders}),{data:Lt,isLoading:ln}=ut({queryKey:["api-keys"],queryFn:he.getAPIKeys}),Gt=mt({mutationFn:be=>he.createAPIKey(be),onSuccess:be=>{ee(be.key||null),me(!1),ye(""),t.invalidateQueries({queryKey:["api-keys"]}),o("API key created")},onError:be=>{o(`Failed to create API key: ${be.message}`,"error")}}),_n=mt({mutationFn:be=>he.deleteAPIKey(be),onSuccess:()=>{t.invalidateQueries({queryKey:["api-keys"]}),o("API key deleted")},onError:be=>{o(`Failed to delete API key: ${be.message}`,"error")}}),{data:gt}=ut({queryKey:["printers"],queryFn:he.getPrinters}),{data:Kt,isLoading:bn}=ut({queryKey:["notification-templates"],queryFn:he.getNotificationTemplates}),{data:At}=ut({queryKey:["virtual-printer-settings"],queryFn:r1.getSettings,refetchInterval:1e4}),Pr=At?.status?.running??!1,{data:yr}=ut({queryKey:["ffmpeg-status"],queryFn:he.checkFfmpeg}),{data:jn}=ut({queryKey:["version"],queryFn:he.getVersion}),{data:sn,refetch:Rr,isRefetching:Gr}=ut({queryKey:["updateCheck"],queryFn:he.checkForUpdates,staleTime:300*1e3}),{data:Dr,refetch:_e}=ut({queryKey:["updateStatus"],queryFn:he.getUpdateStatus,refetchInterval:be=>{const Pe=be.state.data;return Pe?.status==="downloading"||Pe?.status==="installing"?1e3:!1}}),{data:Ve}=ut({queryKey:["mqtt-status"],queryFn:he.getMQTTStatus,refetchInterval:de==="network"?5e3:!1}),{data:at}=ut({queryKey:["github-backup-status"],queryFn:he.getGitHubBackupStatus}),{data:ct}=ut({queryKey:["cloud-status"],queryFn:he.getCloudStatus}),rt=mt({mutationFn:he.applyUpdate,onSuccess:be=>{be.is_docker?o(be.message,"error"):_e()}}),[jt,zt]=w.useState(null),Xt=mt({mutationFn:he.testAllNotificationProviders,onSuccess:be=>{zt(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")}}),Yt=mt({mutationFn:async be=>{if(!Oe)return{success:0,failed:0};const Pe=Oe.filter(Mt=>Mt.enabled),wt=await Promise.all(Pe.map(async Mt=>{try{return await he.controlSmartPlug(Mt.id,be),{success:!0}}catch{return{success:!1}}}));return{success:wt.filter(Mt=>Mt.success).length,failed:wt.filter(Mt=>!Mt.success).length}},onSuccess:(be,Pe)=>{t.invalidateQueries({queryKey:["smart-plugs"]}),t.invalidateQueries({queryKey:["smart-plugs-energy"]}),be.failed===0?o(`All ${be.success} plugs turned ${Pe}`,"success"):o(`${be.success} plugs turned ${Pe}, ${be.failed} failed`,"error")},onError:be=>{o(`Failed: ${be.message}`,"error")}}),ue=w.useRef(null),Re=w.useRef(!1),He=w.useRef(!0);w.useEffect(()=>{if(je&&!E){const be={...je,external_url:je.external_url||window.location.origin};O(be),setTimeout(()=>{He.current=!1},100)}},[je,E]);const Xe=mt({mutationFn:he.updateSettings,onSuccess:be=>{t.setQueryData(["settings"],be),O(be),t.invalidateQueries({queryKey:["archiveStats"]}),o("Settings saved","success")},onError:be=>{o(`Failed to save: ${be.message}`,"error")},onSettled:()=>{Re.current=!1}}),Ge=mt({mutationFn:({id:be,data:Pe})=>he.updatePrinter(be,Pe),onSuccess:()=>{t.invalidateQueries({queryKey:["printers"]}),o("Camera settings saved","success")},onError:be=>{o(`Failed to update printer: ${be.message}`,"error")}});w.useEffect(()=>{if(!(He.current||!E||!je||!(je.auto_archive!==E.auto_archive||je.save_thumbnails!==E.save_thumbnails||je.capture_finish_photo!==E.capture_finish_photo||je.default_filament_cost!==E.default_filament_cost||je.currency!==E.currency||je.energy_cost_per_kwh!==E.energy_cost_per_kwh||je.energy_tracking_mode!==E.energy_tracking_mode||je.check_updates!==E.check_updates||je.notification_language!==E.notification_language||je.ams_humidity_good!==E.ams_humidity_good||je.ams_humidity_fair!==E.ams_humidity_fair||je.ams_temp_good!==E.ams_temp_good||je.ams_temp_fair!==E.ams_temp_fair||je.ams_history_retention_days!==E.ams_history_retention_days||je.per_printer_mapping_expanded!==E.per_printer_mapping_expanded||je.date_format!==E.date_format||je.time_format!==E.time_format||je.default_printer_id!==E.default_printer_id||je.ftp_retry_enabled!==E.ftp_retry_enabled||je.ftp_retry_count!==E.ftp_retry_count||je.ftp_retry_delay!==E.ftp_retry_delay||je.ftp_timeout!==E.ftp_timeout||je.mqtt_enabled!==E.mqtt_enabled||je.mqtt_broker!==E.mqtt_broker||je.mqtt_port!==E.mqtt_port||je.mqtt_username!==E.mqtt_username||je.mqtt_password!==E.mqtt_password||je.mqtt_topic_prefix!==E.mqtt_topic_prefix||je.mqtt_use_tls!==E.mqtt_use_tls||je.external_url!==E.external_url||je.ha_enabled!==E.ha_enabled||je.ha_url!==E.ha_url||je.ha_token!==E.ha_token||(je.library_archive_mode??"ask")!==(E.library_archive_mode??"ask")||Number(je.library_disk_warning_gb??5)!==Number(E.library_disk_warning_gb??5)||(je.camera_view_mode??"window")!==(E.camera_view_mode??"window")||je.prometheus_enabled!==E.prometheus_enabled||je.prometheus_token!==E.prometheus_token))&&!Re.current)return ue.current&&clearTimeout(ue.current),ue.current=setTimeout(()=>{if(Re.current)return;Re.current=!0;const Pe={auto_archive:E.auto_archive,save_thumbnails:E.save_thumbnails,capture_finish_photo:E.capture_finish_photo,default_filament_cost:E.default_filament_cost,currency:E.currency,energy_cost_per_kwh:E.energy_cost_per_kwh,energy_tracking_mode:E.energy_tracking_mode,check_updates:E.check_updates,notification_language:E.notification_language,ams_humidity_good:E.ams_humidity_good,ams_humidity_fair:E.ams_humidity_fair,ams_temp_good:E.ams_temp_good,ams_temp_fair:E.ams_temp_fair,ams_history_retention_days:E.ams_history_retention_days,per_printer_mapping_expanded:E.per_printer_mapping_expanded,date_format:E.date_format,time_format:E.time_format,default_printer_id:E.default_printer_id,ftp_retry_enabled:E.ftp_retry_enabled,ftp_retry_count:E.ftp_retry_count,ftp_retry_delay:E.ftp_retry_delay,ftp_timeout:E.ftp_timeout,mqtt_enabled:E.mqtt_enabled,mqtt_broker:E.mqtt_broker,mqtt_port:E.mqtt_port,mqtt_username:E.mqtt_username,mqtt_password:E.mqtt_password,mqtt_topic_prefix:E.mqtt_topic_prefix,mqtt_use_tls:E.mqtt_use_tls,external_url:E.external_url,ha_enabled:E.ha_enabled,ha_url:E.ha_url,ha_token:E.ha_token,library_archive_mode:E.library_archive_mode,library_disk_warning_gb:E.library_disk_warning_gb,camera_view_mode:E.camera_view_mode,prometheus_enabled:E.prometheus_enabled,prometheus_token:E.prometheus_token};Xe.mutate(Pe)},500),()=>{ue.current&&clearTimeout(ue.current)}},[E,je,Xe]);const ht=w.useCallback((be,Pe)=>{O(wt=>wt?{...wt,[be]:Pe}:null)},[]),Pt=async(be,Pe,wt)=>{if(!Pe){o("Please enter a camera URL","error");return}Fe(Mt=>({...Mt,[be]:!0})),te(Mt=>({...Mt,[be]:null}));try{const Mt=await he.testExternalCamera(be,Pe,wt);te(lt=>({...lt,[be]:Mt})),Mt.success?o(`Camera connected${Mt.resolution?` (${Mt.resolution})`:""}`,"success"):o(Mt.error||"Connection failed","error")}catch(Mt){const lt=Mt instanceof Error?Mt.message:"Test failed";te(Tt=>({...Tt,[be]:{success:!1,error:lt}})),o(lt,"error")}finally{Fe(Mt=>({...Mt,[be]:!1}))}},[_t,yt]=w.useState({}),It=w.useRef({});w.useEffect(()=>{if(gt){const be={};gt.forEach(Pe=>{Pe.external_camera_url&&_t[Pe.id]===void 0&&(be[Pe.id]=Pe.external_camera_url)}),Object.keys(be).length>0&&yt(Pe=>({...Pe,...be}))}},[gt]);const Ot=(be,Pe)=>{yt(wt=>({...wt,[be]:Pe})),It.current[be]&&clearTimeout(It.current[be]),It.current[be]=setTimeout(()=>{Ge.mutate({id:be,data:{external_camera_url:Pe||null}})},800)},Ft=(be,Pe)=>{const wt={};Pe.type!==void 0&&(wt.external_camera_type=Pe.type||null),Pe.enabled!==void 0&&(wt.external_camera_enabled=Pe.enabled),Ge.mutate({id:be,data:wt})};return xe||!E?s.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:s.jsx(dt,{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:()=>ie("general"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${de==="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:()=>ie("plugs"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${de==="plugs"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Ks,{className:"w-4 h-4"}),"Smart Plugs",Oe&&Oe.length>0&&s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Oe.length})]}),s.jsxs("button",{onClick:()=>ie("notifications"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${de==="notifications"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Ef,{className:"w-4 h-4"}),"Notifications",pt&&pt.length>0&&s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:pt.length})]}),s.jsxs("button",{onClick:()=>ie("filament"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${de==="filament"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Rde,{className:"w-4 h-4"}),"Filament"]}),s.jsxs("button",{onClick:()=>ie("network"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${de==="network"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(ig,{className:"w-4 h-4"}),"Network",s.jsx("span",{className:`w-2 h-2 rounded-full ${Ve?.enabled?"bg-green-400":"bg-gray-500"}`})]}),s.jsxs("button",{onClick:()=>ie("apikeys"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${de==="apikeys"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(mf,{className:"w-4 h-4"}),"API Keys",Lt&&Lt.length>0&&s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Lt.length})]}),s.jsxs("button",{onClick:()=>ie("virtual-printer"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${de==="virtual-printer"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(qr,{className:"w-4 h-4"}),"Virtual Printer",s.jsx("span",{className:`w-2 h-2 rounded-full ${Pr?"bg-green-400":"bg-gray-500"}`})]}),s.jsxs("button",{onClick:()=>ie("users"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${de==="users"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(pf,{className:"w-4 h-4"}),"Users",l&&s.jsx("span",{className:`w-2 h-2 rounded-full ${l?"bg-green-400":"bg-gray-500"}`})]}),s.jsxs("button",{onClick:()=>ie("backup"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${de==="backup"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(su,{className:"w-4 h-4"}),"Backup",s.jsx("span",{className:`w-2 h-2 rounded-full ${ct?.is_authenticated&&at?.configured&&at?.enabled?"bg-green-400":"bg-gray-500"}`})]})]}),de==="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(St,{children:[s.jsx(er,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.general")})}),s.jsxs(Nt,{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx($d,{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:jz.map(be=>s.jsxs("option",{value:be.code,children:[be.nativeName," (",be.name,")"]},be.code))}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("settings.languageDescription")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:i("settings.defaultView")}),s.jsx("select",{value:z,onChange:be=>ot(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:O0.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:E.date_format||"system",onChange:be=>ht("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:E.time_format||"system",onChange:be=>ht("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:E.default_printer_id??"",onChange:be=>ht("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)"}),gt?.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(Se,{variant:"secondary",size:"sm",onClick:se,children:[s.jsx(mm,{className:"w-4 h-4"}),"Reset"]})]})]})]}),s.jsxs(St,{children:[s.jsx(er,{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"}),"Appearance"]})}),s.jsxs(Nt,{className:"space-y-6",children:[s.jsxs("div",{className:`space-y-3 p-4 rounded-lg border ${d==="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",d==="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:m,onChange:be=>{S(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: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:"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:f,onChange:be=>{v(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 ${d==="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",d==="light"&&s.jsx("span",{className:"text-xs text-bambu-green",children:"(active)"})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Background"}),s.jsxs("select",{value:y,onChange:be=>{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: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:"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:b,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:"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(St,{children:[s.jsx(er,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Archive Settings"})}),s.jsxs(Nt,{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:E.auto_archive,onChange:be=>ht("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:E.save_thumbnails,onChange:be=>ht("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:E.capture_finish_photo,onChange:be=>ht("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"})]})]}),E.capture_finish_photo&&yr&&!yr.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(kn,{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(St,{children:[s.jsx(er,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(qD,{className:"w-5 h-5 text-bambu-green"}),"Camera"]})}),s.jsxs(Nt,{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:E.camera_view_mode??"window",onChange:be=>ht("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:E.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."}),gt&>.length>0?s.jsx("div",{className:"space-y-3",children:gt.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:Pe=>Ft(be.id,{enabled:Pe.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:_t[be.id]??be.external_camera_url??"",onChange:Pe=>Ot(be.id,Pe.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:Pe=>Ft(be.id,{type:Pe.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(Se,{size:"sm",variant:"secondary",onClick:()=>Pt(be.id,_t[be.id]??be.external_camera_url??"",be.external_camera_type||"mjpeg"),disabled:Me[be.id]||!(_t[be.id]??be.external_camera_url),children:Me[be.id]?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):"Test"})]}),oe[be.id]&&s.jsx("div",{className:`text-xs flex items-center gap-1 ${oe[be.id]?.success?"text-green-500":"text-red-500"}`,children:oe[be.id]?.success?s.jsxs(s.Fragment,{children:[s.jsx(Un,{className:"w-3 h-3"}),"Connected",oe[be.id]?.resolution&&` (${oe[be.id]?.resolution})`]}):s.jsxs(s.Fragment,{children:[s.jsx(ia,{className:"w-3 h-3"}),oe[be.id]?.error||"Connection failed"]})})]})]},be.id))}):s.jsx("p",{className:"text-xs text-bambu-gray italic",children:"No printers configured"})]})]})]}),s.jsxs(St,{children:[s.jsx(er,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Cost Tracking"})}),s.jsxs(Nt,{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:E.default_filament_cost,onChange:be=>ht("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:E.currency,onChange:be=>ht("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:E.energy_cost_per_kwh,onChange:be=>ht("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:E.energy_tracking_mode||"total",onChange:be=>ht("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:E.energy_tracking_mode==="print"?"Dashboard shows sum of energy used during prints":"Dashboard shows lifetime energy from smart plugs"})]})]})]}),s.jsxs(St,{children:[s.jsx(er,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Za,{className:"w-5 h-5 text-bambu-green"}),"File Manager"]})}),s.jsxs(Nt,{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:E.library_archive_mode??"ask",onChange:be=>ht("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:E.library_disk_warning_gb??5,onChange:be=>ht("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(St,{children:[s.jsx(er,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Updates"})}),s.jsxs(Nt,{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:E.check_updates,onChange:be=>ht("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",jn?.version||"..."]})]}),s.jsxs(Se,{variant:"secondary",size:"sm",onClick:()=>Rr(),disabled:Gr,children:[Gr?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(xr,{className:"w-4 h-4"}),"Check now"]})]}),sn?.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",sn.latest_version]}),sn.release_name&&sn.release_name!==sn.latest_version&&s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:sn.release_name})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[sn.release_notes&&s.jsx("button",{onClick:()=>we(!0),className:"text-bambu-gray hover:text-white transition-colors text-sm underline",children:"Release Notes"}),sn.release_url&&s.jsx("a",{href:sn.release_url,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-white transition-colors",title:"View release on GitHub",children:s.jsx(zr,{className:"w-4 h-4"})})]})]}),Dr?.status==="downloading"||Dr?.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(dt,{className:"w-4 h-4 animate-spin"}),s.jsx("span",{children:Dr.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:`${Dr.progress}%`}})})]}):Dr?.status==="complete"?s.jsx("div",{className:"mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green",children:Dr.message}):Dr?.status==="error"?s.jsx("div",{className:"mt-3 p-2 bg-red-500/20 rounded text-sm text-red-400",children:Dr.error||Dr.message}):sn?.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(Se,{className:"mt-3",onClick:()=>rt.mutate(),disabled:rt.isPending,children:[rt.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(Hr,{className:"w-4 h-4"}),"Install Update"]})]}):sn?.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: ",sn.error]}):sn&&!sn.update_available?s.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"You're running the latest version"}):null]})]})]}),s.jsxs(St,{children:[s.jsx(er,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Data Management"})}),s.jsxs(Nt,{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:"Clear Notification Logs"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Delete notification logs older than 30 days"})]}),s.jsxs(Se,{variant:"secondary",size:"sm",onClick:()=>Le(!0),children:[s.jsx(dn,{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(Se,{variant:"secondary",size:"sm",onClick:()=>$(!0),children:[s.jsx(dn,{className:"w-4 h-4"}),"Reset"]})]}),s.jsxs("div",{className:"flex items-center justify-between pt-4 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Backup & Restore"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Export/import settings and configure GitHub backup"})]}),s.jsxs(Se,{variant:"secondary",size:"sm",onClick:()=>ie("backup"),children:[s.jsx(su,{className:"w-4 h-4"}),"Go to Backup"]})]})]})]})]})]}),de==="network"&&E&&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(St,{children:[s.jsx(er,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx($d,{className:"w-5 h-5 text-blue-400"}),"External URL"]})}),s.jsxs(Nt,{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:E.external_url??"",onChange:be=>ht("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(St,{children:[s.jsx(er,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(xr,{className:"w-5 h-5 text-blue-400"}),"FTP Retry"]})}),s.jsxs(Nt,{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:E.ftp_retry_enabled??!0,onChange:be=>ht("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"})]})]}),E.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:E.ftp_retry_count??3,onChange:be=>ht("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:E.ftp_retry_delay??2,onChange:be=>ht("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:E.ftp_timeout??30,onChange:be=>ht("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(St,{children:[s.jsx(er,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(cN,{className:"w-5 h-5 text-bambu-green"}),"Home Assistant"]}),E.ha_enabled&&Ie&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${Ie.success?"bg-green-400":"bg-red-400"}`}),s.jsx("span",{className:`text-sm ${Ie.success?"text-green-400":"text-red-400"}`,children:Ie.success?"Connected":"Disconnected"})]})]})}),s.jsxs(Nt,{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:E.ha_enabled??!1,onChange:be=>ht("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"})]})]}),E.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:E.ha_url??"",onChange:be=>ht("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:E.ha_token??"",onChange:be=>ht("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"})]}),E.ha_url&&E.ha_token&&s.jsx("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:s.jsxs(Se,{variant:"secondary",size:"sm",disabled:Je,onClick:async()=>{Qe(!0),qe(null);try{const be=await he.testHAConnection(E.ha_url,E.ha_token);qe(be)}catch(be){qe({success:!1,message:null,error:be instanceof Error?be.message:"Unknown error"})}finally{Qe(!1)}},children:[Je?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(ig,{className:"w-4 h-4"}),"Test Connection"]})})]})]})]}),s.jsxs(St,{children:[s.jsx(er,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(ig,{className:"w-5 h-5 text-blue-400"}),"MQTT Publishing"]}),Ve?.enabled&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${Ve.connected?"bg-green-400":"bg-red-400"}`}),s.jsx("span",{className:`text-sm ${Ve.connected?"text-green-400":"text-red-400"}`,children:Ve.connected?"Connected":"Disconnected"})]})]})}),s.jsxs(Nt,{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:E.mqtt_enabled??!1,onChange:be=>ht("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"})]})]}),E.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:E.mqtt_broker??"",onChange:be=>ht("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:E.mqtt_port??1883,onChange:be=>ht("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:E.mqtt_use_tls??!1,onChange:be=>{const Pe=be.target.checked;ht("mqtt_use_tls",Pe);const wt=E.mqtt_port??1883;Pe&&wt===1883?ht("mqtt_port",8883):!Pe&&wt===8883&&ht("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:E.mqtt_username??"",onChange:be=>ht("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:E.mqtt_password??"",onChange:be=>ht("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:E.mqtt_topic_prefix??"bambuddy",onChange:be=>ht("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: ",E.mqtt_topic_prefix||"bambuddy","/printers/<serial>/status, etc."]})]}),Ve&&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 ${Ve.connected?"bg-green-400":"bg-red-400"}`}),s.jsx("span",{className:"text-bambu-gray",children:Ve.connected?s.jsxs(s.Fragment,{children:["Connected to ",s.jsxs("span",{className:"text-white",children:[Ve.broker,":",Ve.port]})]}):"Not connected"})]})})]})]})]})]}),s.jsx("div",{className:"flex-1 lg:max-w-md space-y-4",children:s.jsxs(St,{children:[s.jsx(er,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(NP,{className:"w-5 h-5 text-orange-400"}),"Prometheus Metrics"]})}),s.jsxs(Nt,{className:"space-y-4",children:[s.jsxs("p",{className:"text-sm text-bambu-gray",children:["Expose printer metrics at ",s.jsx("code",{className:"bg-bambu-dark px-1 rounded",children:"/api/v1/metrics"})," for Prometheus/Grafana monitoring."]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Enable Metrics Endpoint"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Expose printer data in Prometheus format"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:E.prometheus_enabled??!1,onChange:be=>ht("prometheus_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"})]})]}),E.prometheus_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:"Bearer Token (optional)"}),s.jsx("input",{type:"password",value:E.prometheus_token??"",onChange:be=>ht("prometheus_token",be.target.value),placeholder:"Leave empty for no authentication",className:"w-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:["If set, requests must include ",s.jsx("code",{className:"bg-bambu-dark px-1 rounded",children:"Authorization: Bearer <token>"})]})]}),s.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-sm text-white mb-2",children:"Available Metrics"}),s.jsxs("div",{className:"text-xs text-bambu-gray space-y-1",children:[s.jsxs("p",{children:[s.jsx("code",{className:"text-orange-400",children:"bambuddy_printer_connected"})," - Connection status"]}),s.jsxs("p",{children:[s.jsx("code",{className:"text-orange-400",children:"bambuddy_printer_state"})," - Printer state (idle/printing/etc)"]}),s.jsxs("p",{children:[s.jsx("code",{className:"text-orange-400",children:"bambuddy_print_progress"})," - Print progress 0-100%"]}),s.jsxs("p",{children:[s.jsx("code",{className:"text-orange-400",children:"bambuddy_bed_temp_celsius"})," - Bed temperature"]}),s.jsxs("p",{children:[s.jsx("code",{className:"text-orange-400",children:"bambuddy_nozzle_temp_celsius"})," - Nozzle temperature"]}),s.jsxs("p",{children:[s.jsx("code",{className:"text-orange-400",children:"bambuddy_prints_total"})," - Total prints by result"]}),s.jsx("p",{className:"text-bambu-gray/70 italic",children:"...and more (layers, fans, queue, filament usage)"})]})]})]})]})]})})]}),Ie&&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:[Ie.success?s.jsx(Un,{className:"w-8 h-8 text-green-400"}):s.jsx(ia,{className:"w-8 h-8 text-red-400"}),s.jsx("h3",{className:"text-lg font-medium text-white",children:Ie.success?"Connection Successful":"Connection Failed"})]}),s.jsx("p",{className:"text-bambu-gray mb-6",children:Ie.success?Ie.message||"Successfully connected to Home Assistant.":Ie.error||"Failed to connect to Home Assistant."}),s.jsx("div",{className:"flex justify-end",children:s.jsx(Se,{variant:"primary",onClick:()=>qe(null),children:"OK"})})]})}),de==="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(Ks,{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:[Oe&&Oe.filter(be=>be.enabled).length>1&&s.jsxs(s.Fragment,{children:[s.jsxs(Se,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>Y("on"),disabled:Yt.isPending,title:"Turn all plugs on",children:[Yt.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(Eu,{className:"w-4 h-4 text-bambu-green"}),"All On"]}),s.jsxs(Se,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>Y("off"),disabled:Yt.isPending,title:"Turn all plugs off",children:[Yt.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(fN,{className:"w-4 h-4 text-red-400"}),"All Off"]})]}),s.jsxs(Se,{className:"whitespace-nowrap",onClick:()=>{L(null),D(!0)},children:[s.jsx(nr,{className:"w-4 h-4"}),"Add Smart Plug"]})]})]}),Oe&&Oe.length>0&&s.jsxs(St,{className:"mb-6",children:[s.jsx(er,{children:s.jsxs("h3",{className:"text-base font-semibold text-white flex items-center gap-2",children:[s.jsx(qf,{className:"w-4 h-4 text-yellow-400"}),"Energy Summary",We&&s.jsx(dt,{className:"w-4 h-4 animate-spin text-bambu-gray ml-2"})]})}),s.jsx(Nt,{children:Ce?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(qf,{className:"w-3 h-3"}),"Current Power"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[Ce.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:[Ce.reachableCount,"/",Ce.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(oi,{className:"w-3 h-3"}),"Today"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[Ce.totalToday.toFixed(2),s.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),E&&E.energy_cost_per_kwh>0&&s.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(Ce.totalToday*E.energy_cost_per_kwh).toFixed(2)," ",E.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(NP,{className:"w-3 h-3"}),"Yesterday"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[Ce.totalYesterday.toFixed(2),s.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),E&&E.energy_cost_per_kwh>0&&s.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(Ce.totalYesterday*E.energy_cost_per_kwh).toFixed(2)," ",E.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(xP,{className:"w-3 h-3"}),"Total"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[Ce.totalLifetime.toFixed(1),s.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),E&&E.energy_cost_per_kwh>0&&s.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(Ce.totalLifetime*E.energy_cost_per_kwh).toFixed(2)," ",E.currency]})]})]}):We?null:s.jsx("p",{className:"text-sm text-bambu-gray",children:"Enable plugs to see energy summary"})})]}),Ue?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(dt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):Oe&&Oe.length>0?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Oe.map(be=>s.jsx(CYe,{plug:be,onEdit:Pe=>{L(Pe),D(!0)}},be.id))}):s.jsx(St,{children:s.jsx(Nt,{className:"py-12",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(Ks,{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(Se,{onClick:()=>{L(null),D(!0)},children:[s.jsx(nr,{className:"w-4 h-4"}),"Add Your First Smart Plug"]})]})})})]}),de==="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(Ef,{className:"w-5 h-5 text-bambu-green"}),"Providers"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Se,{size:"sm",variant:"secondary",onClick:()=>J(!0),children:[s.jsx(P0,{className:"w-4 h-4"}),"Log"]}),pt&&pt.length>0&&s.jsxs(Se,{size:"sm",variant:"secondary",onClick:()=>{zt(null),Xt.mutate()},disabled:Xt.isPending,children:[Xt.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(GD,{className:"w-4 h-4"}),"Test All"]}),s.jsxs(Se,{size:"sm",onClick:()=>{K(null),P(!0)},children:[s.jsx(nr,{className:"w-4 h-4"}),"Add"]})]})]}),s.jsx(St,{className:"mb-4",children:s.jsx(Nt,{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:E.notification_language||"en",onChange:be=>ht("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:jz.map(be=>s.jsx("option",{value:be.code,children:be.nativeName},be.code))})]})})}),jt&&s.jsx(St,{className:"mb-4",children:s.jsxs(Nt,{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:()=>zt(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(Un,{className:"w-4 h-4"}),jt.success," passed"]}),jt.failed>0&&s.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[s.jsx(ia,{className:"w-4 h-4"}),jt.failed," failed"]})]}),jt.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:jt.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))})]})}),kt?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(dt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):pt&&pt.length>0?s.jsx("div",{className:"space-y-3",children:pt.map(be=>s.jsx(PYe,{provider:be,onEdit:Pe=>{K(Pe),P(!0)}},be.id))}):s.jsx(St,{children:s.jsx(Nt,{className:"py-8",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(Ef,{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(Se,{size:"sm",onClick:()=>{K(null),P(!0)},children:[s.jsx(nr,{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(Za,{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."}),bn?s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(dt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):Kt&&Kt.length>0?s.jsx("div",{className:"space-y-2",children:Kt.map(be=>s.jsx(St,{className:"cursor-pointer hover:border-bambu-green/50 transition-colors",onClick:()=>Q(be),children:s.jsx(Nt,{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:Pe=>{Pe.stopPropagation(),Q(be)},children:s.jsx(hN,{className:"w-4 h-4 text-bambu-gray"})})]})})},be.id))}):s.jsx(St,{children:s.jsx(Nt,{className:"py-8",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(Za,{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."})]})})})]})]}),de==="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(mf,{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(Se,{size:"sm",onClick:()=>me(!0),className:"flex-shrink-0",children:[s.jsx(nr,{className:"w-4 h-4"}),"Create Key"]})]}),H&&s.jsx(St,{className:"mb-6 border-bambu-green",children:s.jsx(Nt,{className:"py-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Un,{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:H}),s.jsx(Se,{variant:"secondary",size:"sm",onClick:async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(H);else{const be=document.createElement("textarea");be.value=H,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(ll,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"flex gap-2 mt-3",children:[s.jsx(Se,{variant:"secondary",size:"sm",onClick:()=>{ce(H),o("Key added to API Browser")},children:"Use in API Browser"}),s.jsx(Se,{variant:"secondary",size:"sm",onClick:()=>ee(null),children:"Dismiss"})]})]})]})})}),Ae&&s.jsxs(St,{className:"mb-6",children:[s.jsx(er,{children:s.jsx("h3",{className:"text-base font-semibold text-white",children:"Create New API Key"})}),s.jsxs(Nt,{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:Ne,onChange:be=>ye(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:le.can_read_status,onChange:be=>$e(Pe=>({...Pe,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:le.can_queue,onChange:be=>$e(Pe=>({...Pe,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:le.can_control_printer,onChange:be=>$e(Pe=>({...Pe,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(Se,{onClick:()=>Gt.mutate({name:Ne||"Unnamed Key",...le}),disabled:Gt.isPending,children:[Gt.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(nr,{className:"w-4 h-4"}),"Create Key"]}),s.jsx(Se,{variant:"secondary",onClick:()=>me(!1),children:"Cancel"})]})]})]}),ln?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(dt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):Lt&&Lt.length>0?s.jsx("div",{className:"space-y-3",children:Lt.map(be=>s.jsx(St,{children:s.jsx(Nt,{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(mf,{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: ${_g(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(Se,{variant:"secondary",size:"sm",onClick:()=>B(be.id),children:s.jsx(dn,{className:"w-4 h-4 text-red-400"})})]})]})})},be.id))}):s.jsx(St,{children:s.jsx(Nt,{className:"py-12",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(mf,{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(Se,{onClick:()=>me(!0),children:[s.jsx(nr,{className:"w-4 h-4"}),"Create Your First Key"]})]})})}),s.jsxs(St,{className:"mt-6",children:[s.jsx(er,{children:s.jsx("h3",{className:"text-base font-semibold text-white",children:"Webhook Endpoints"})}),s.jsxs(Nt,{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($d,{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(St,{className:"mb-4",children:s.jsxs(Nt,{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:I,onChange:be=>ce(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(QYe,{apiKey:I})]})]}),de==="virtual-printer"&&s.jsx(VYe,{}),de==="filament"&&E&&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(St,{children:[s.jsx(er,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:"AMS Display Thresholds"})}),s.jsxs(Nt,{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($D,{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:E.ams_humidity_good??40,onChange:be=>ht("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:E.ams_humidity_fair??60,onChange:be=>ht("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(pN,{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:E.ams_temp_good??28,onChange:be=>ht("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:E.ams_temp_fair??35,onChange:be=>ht("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(su,{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:E.ams_history_retention_days??30,onChange:be=>ht("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(qr,{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:E.per_printer_mapping_expanded??!1,onChange:be=>ht("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,{})})]}),X!==null&&s.jsx(Hn,{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:()=>{_n.mutate(X),B(null)},onCancel:()=>B(null)}),C&&s.jsx(kYe,{plug:U,onClose:()=>{D(!1),L(null)}}),q&&s.jsx(RYe,{provider:W,onClose:()=>{P(!1),K(null)}}),V&&s.jsx(DYe,{template:V,onClose:()=>Q(null)}),re&&s.jsx(IYe,{onClose:()=>J(!1)}),Te&&s.jsx(Hn,{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()=>{Le(!1);try{const be=await he.clearNotificationLogs(30);o(be.message,"success")}catch{o("Failed to clear logs","error")}},onCancel:()=>Le(!1)}),Ee&&s.jsx(Hn,{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:()=>{$(!1),localStorage.clear(),o("UI preferences reset. Refreshing...","success"),setTimeout(()=>window.location.reload(),1e3)},onCancel:()=>$(!1)}),j&&s.jsx(Hn,{title:`Turn All Plugs ${j==="on"?"On":"Off"}`,message:`This will turn ${j==="on"?"ON":"OFF"} all ${Oe?.filter(be=>be.enabled).length||0} enabled smart plugs. ${j==="off"?"Any running printers may be affected!":""}`,confirmText:`Turn All ${j==="on"?"On":"Off"}`,variant:j==="off"?"danger":"warning",onConfirm:()=>{const be=j;Y(null),Yt.mutate(be)},onCancel:()=>Y(null)}),ge&&sn?.release_notes&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>we(!1),children:s.jsxs(St,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",onClick:be=>be.stopPropagation(),children:[s.jsxs(er,{className:"flex flex-row items-center justify-between shrink-0",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Release Notes - v",sn.latest_version]}),sn.release_name&&sn.release_name!==sn.latest_version&&s.jsx("p",{className:"text-sm text-bambu-gray",children:sn.release_name})]}),s.jsx("button",{onClick:()=>we(!1),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:s.jsx(Vt,{className:"w-5 h-5"})})]}),s.jsx(Nt,{className:"overflow-y-auto flex-1",children:s.jsx("pre",{className:"text-sm text-bambu-gray whitespace-pre-wrap font-sans",children:sn.release_notes})}),s.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary shrink-0 flex gap-2",children:[sn.release_url&&s.jsx("a",{href:sn.release_url,target:"_blank",rel:"noopener noreferrer",className:"flex-1",children:s.jsxs(Se,{variant:"secondary",className:"w-full",children:[s.jsx(zr,{className:"w-4 h-4"}),"View on GitHub"]})}),s.jsx(Se,{onClick:()=>we(!1),className:"flex-1",children:"Close"})]})]})}),de==="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(pf,{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(St,{children:s.jsx(Nt,{className:"py-6",children:l?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(lT,{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."})]})]}),c&&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:c.username}),s.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:["Role: ",s.jsx("span",{className:"capitalize",children:c.role})]})]}),s.jsx("div",{className:`px-3 py-1 rounded-full text-xs font-medium ${c.role==="admin"?"bg-purple-500/20 text-purple-300":"bg-blue-500/20 text-blue-300"}`,children:c.role==="admin"?"Admin":"User"})]})}),s.jsxs("div",{className:"pt-4 border-t border-bambu-dark-tertiary space-y-3",children:[s.jsxs(Se,{onClick:()=>e("/users"),className:"w-full",variant:"secondary",children:[s.jsx(pf,{className:"w-4 h-4"}),"Manage Users"]}),c?.role==="admin"&&s.jsxs(Se,{onClick:()=>Ze(!0),className:"w-full",variant:"secondary",children:[s.jsx(Yz,{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 ${l?"bg-green-500/20":"bg-gray-500/20"}`,children:l?s.jsx(lT,{className:"w-6 h-6 text-green-400"}):s.jsx(Yz,{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(Un,{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(Un,{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(Un,{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(Se,{type:"button",onClick:be=>{be.preventDefault(),e("/setup")},className:"w-full",children:[s.jsx(lT,{className:"w-4 h-4"}),"Activate Authentication"]})]})]})})})]}),l&&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(MP,{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(St,{children:[s.jsx(er,{children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-purple-500/20 flex items-center justify-center",children:s.jsx(MP,{className:"w-4 h-4 text-purple-300"})}),s.jsx("h3",{className:"text-white font-medium",children:"Admin"})]})}),s.jsx(Nt,{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(Un,{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(Un,{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(Un,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:"Access all system features"})]})]})})]}),s.jsxs(St,{children:[s.jsx(er,{children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-blue-500/20 flex items-center justify-center",children:s.jsx(pf,{className:"w-4 h-4 text-blue-300"})}),s.jsx("h3",{className:"text-white font-medium",children:"User"})]})}),s.jsx(Nt,{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(Un,{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(Un,{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(Un,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:"Manage filament"})]})]})})]})]})]})]}),de==="backup"&&s.jsx(KYe,{}),ve&&s.jsx(Hn,{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 he.disableAuth(),o("Authentication disabled successfully","success"),await u(),Ze(!1),window.location.href="/"}catch(be){const Pe=be instanceof Error?be.message:"Failed to disable authentication";o(Pe,"error")}},onCancel:()=>Ze(!1)})]})}const Gie=t=>{const e=parseFloat(t);return(Math.trunc(e*1e3)/1e3).toFixed(3)},tZe=t=>t.startsWith("HH")?"HF":"S",nZe=t=>{const e=t.match(/^([A-Z]{2}\d{2})/);return e?e[1]:"HH00"},wD=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 Kj({profile:t,onEdit:e,onCopy:n,selectionMode:r,isSelected:i,onToggleSelect:a,note:o}){const l=tZe(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(Lo,{className:"w-4 h-4 text-bambu-green"}):s.jsx(Io,{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:Gie(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(EK,{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(ll,{className:"w-4 h-4"})})]})}function Xj({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}=qn(),[f,m]=w.useState(t?.name||""),[p,b]=w.useState(t?.k_value?Gie(t.k_value):"0.020"),[y,x]=w.useState(t?.filament_id||""),[v,S]=w.useState(t?.nozzle_id?nZe(t.nozzle_id):"HH00"),[M,A]=w.useState(t?.nozzle_diameter||n),[T,k]=w.useState(t?[t.extruder_id]:i?[0,1]:[0]),[E,O]=w.useState(!1),[C,D]=w.useState({current:0,total:0}),[U,L]=w.useState(a),q=Ur.useMemo(()=>{const J=new Map;for(const z of r)if(z.filament_id&&!J.has(z.filament_id)){const G=wD(z.name||"");J.set(z.filament_id,{id:z.filament_id,name:G||z.filament_id})}return Array.from(J.values()).sort((z,G)=>z.name.localeCompare(G.name))},[r]),P=mt({mutationFn:J=>(console.log("[KProfile] Calling API..."),he.setKProfile(e,J)),onSuccess:J=>{if(console.log("[KProfile] Save success:",J),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)}O(!0),setTimeout(()=>{O(!1),c()},2500)},onError:J=>{console.error("[KProfile] Save error:",J),d(J.message,"error"),O(!1)}}),W=mt({mutationFn:J=>(console.log("[KProfile] Deleting profile..."),he.deleteKProfile(e,J)),onSuccess:J=>{console.log("[KProfile] Delete success:",J),d("K-profile deleted"),O(!0),setTimeout(()=>{O(!1),l()},4e3)},onError:J=>{console.error("[KProfile] Delete error:",J),d(J.message,"error"),O(!1)}}),[K,V]=w.useState(!1),Q=()=>{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})},re=async J=>{if(J.preventDefault(),i&&!t&&T.length===0){d("Please select at least one extruder","error");return}const z=parseFloat(p).toFixed(6),G=`${v}-${M}`;if(t||T.length===1){const ae={name:f,k_value:z,filament_id:y,nozzle_id:G,nozzle_diameter:M,extruder_id:t?t.extruder_id:T[0],setting_id:t?.setting_id,slot_id:t?.slot_id??0};console.log("[KProfile] Saving profile:",ae),P.mutate(ae);return}O(!0),D({current:1,total:T.length});const ne=T.map(ae=>({name:f,k_value:z,filament_id:y,nozzle_id:G,nozzle_diameter:M,extruder_id:ae,setting_id:void 0,slot_id:0}));console.log(`[KProfile] Saving ${ne.length} profiles in batch:`,ne);try{if(await he.setKProfilesBatch(e,ne),d(`K-profile saved to ${T.length} extruders`),u&&U){const ae=`name_${f}_${y}`;u(ae,U)}}catch(ae){console.error("[KProfile] Failed to save batch:",ae),d("Failed to save K-profiles","error"),O(!1),D({current:0,total:0});return}D({current:T.length,total:T.length}),setTimeout(()=>{O(!1),D({current:0,total:0}),c()},3e3)};return s.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:[s.jsxs(St,{className:"w-full max-w-md relative",children:[E&&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(dt,{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(Nt,{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:E,children:s.jsx(Vt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:re,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:J=>m(J.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:J=>{const z=J.target.value;(z===""||/^\d*\.?\d*$/.test(z))&&b(z)},onBlur:J=>{const z=parseFloat(J.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:J=>{const z=J.target.value;if(x(z),!t&&z&&!f){const G=q.find(ne=>ne.id===z);G&&m(`${v==="HH00"?"HF":"S"} ${G.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(J=>J.id===t.filament_id)?.name||t.filament_id},t.filament_id),!t&&q.map(J=>s.jsx("option",{value:J.id,children:J.name},J.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:J=>{const z=J.target.value;if(S(z),!t&&y&&!f){const G=q.find(ne=>ne.id===y);G&&m(`${z==="HS00"?"HF":"S"} ${G.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:J=>A(J.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:T.includes(1),onChange:J=>{J.target.checked?k([...T,1]):k(T.filter(z=>z!==1))},className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green"}),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:T.includes(0),onChange:J=>{J.target.checked?k([...T,0]):k(T.filter(z=>z!==0))},className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green"}),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:J=>L(J.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(Se,{type:"button",variant:"secondary",onClick:()=>V(!0),disabled:W.isPending||E,className:"text-red-500 hover:bg-red-500/10",children:W.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(dn,{className:"w-4 h-4"})}),s.jsx(Se,{type:"button",variant:"secondary",onClick:l,disabled:E,className:"flex-1",children:"Cancel"}),s.jsxs(Se,{type:"submit",disabled:P.isPending||E,className:"flex-1",children:[P.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(oN,{className:"w-4 h-4"}),"Save"]})]})]})]})]}),K&&s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[60]",children:s.jsx(St,{className:"w-full max-w-sm",children:s.jsxs(Nt,{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(dn,{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(Se,{variant:"secondary",onClick:()=>V(!1),className:"flex-1",children:"Cancel"}),s.jsxs(Se,{onClick:()=>{V(!1),Q()},disabled:W.isPending,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[W.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(dn,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}const e1={NOZZLE_DIAMETER:"bambusy_kprofiles_nozzle",SORT_OPTION:"bambusy_kprofiles_sort"};function rZe(){const{showToast:t}=qn(),[e,n]=w.useState(null),[r,i]=w.useState(()=>localStorage.getItem(e1.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(e1.SORT_OPTION)||"name"),[M,A]=w.useState(!1),[T,k]=w.useState(new Set),[E,O]=w.useState(!1),[C,D]=w.useState(!1),U=w.useCallback(B=>`${B.slot_id}_${B.extruder_id}`,[]);w.useEffect(()=>{localStorage.setItem(e1.NOZZLE_DIAMETER,r)},[r]),w.useEffect(()=>{localStorage.setItem(e1.SORT_OPTION,v)},[v]);const{data:L,isLoading:q}=ut({queryKey:["printers"],queryFn:he.getPrinters}),{data:P,isLoading:W,isFetching:K,error:V,refetch:Q}=ut({queryKey:["kprofiles",e,r],queryFn:async()=>{console.log("[KProfiles] Fetching profiles for printer",e,"nozzle",r);const B=await he.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:re}=ut({queryKey:["kprofiles",e,"0.4"],queryFn:()=>he.getKProfiles(e,"0.4"),enabled:!!e,staleTime:6e4}),{data:J,refetch:z}=ut({queryKey:["kprofile-notes",e],queryFn:()=>he.getKProfileNotes(e),enabled:!!e,staleTime:3e4}),G=V?.message?.includes("not connected");w.useEffect(()=>{if(!e&&L&&L.length>0){const B=L.find(I=>I.is_active);B&&n(B.id)}},[e,L]),w.useEffect(()=>{if(e){const B=setTimeout(()=>{Q()},150);return()=>clearTimeout(B)}},[e,r]);const ne=L?.filter(B=>B.is_active)||[],ae=Ur.useMemo(()=>P?.profiles?P.profiles.filter(I=>{const ce=f.toLowerCase(),Te=!ce||I.name.toLowerCase().includes(ce)||I.filament_id.toLowerCase().includes(ce),Le=p==="all"||p==="left"&&I.extruder_id===1||p==="right"&&I.extruder_id===0,Ee=y==="all"||y==="hf"&&I.nozzle_id.startsWith("HH")||y==="s"&&I.nozzle_id.startsWith("HS");return Te&&Le&&Ee}).sort((I,ce)=>{switch(v){case"k_value":return parseFloat(I.k_value)-parseFloat(ce.k_value);case"filament":return wD(I.name).localeCompare(wD(ce.name));default:return I.name.localeCompare(ce.name)}}):[],[P?.profiles,f,p,y,v]),de=L?.find(B=>B.id===e),fe=de?.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(),Q()):I.key==="n"||I.key==="N"?(I.preventDefault(),c(!0)):I.key==="Escape"&&M&&(I.preventDefault(),A(!1),k(new Set)))};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[a,l,u,M,Q]);const ie=w.useCallback(()=>{if(!P?.profiles||P.profiles.length===0){t("No profiles to export","error");return}const B={version:1,exported_at:new Date().toISOString(),printer:de?.name||"Unknown",nozzle_diameter:r,profiles:P.profiles.map(Le=>({name:Le.name,k_value:Le.k_value,filament_id:Le.filament_id,nozzle_id:Le.nozzle_id,nozzle_diameter:Le.nozzle_diameter,extruder_id:Le.extruder_id}))},I=new Blob([JSON.stringify(B,null,2)],{type:"application/json"}),ce=URL.createObjectURL(I),Te=document.createElement("a");Te.href=ce,Te.download=`kprofiles_${de?.name||"printer"}_${r}mm_${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(Te),Te.click(),document.body.removeChild(Te),URL.revokeObjectURL(ce),t(`Exported ${P.profiles.length} profiles`)},[P?.profiles,de,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 Te=await ce.text(),Le=JSON.parse(Te);if(!Le.profiles||!Array.isArray(Le.profiles)){t("Invalid file format","error");return}let Ee=0;for(const $ of Le.profiles)if(!(!$.name||!$.k_value||!$.filament_id))try{await he.setKProfile(e,{name:$.name,k_value:parseFloat($.k_value).toFixed(6),filament_id:$.filament_id,nozzle_id:$.nozzle_id||`HH00-${r}`,nozzle_diameter:$.nozzle_diameter||r,extruder_id:$.extruder_id??0,slot_id:0}),Ee++,await new Promise(j=>setTimeout(j,500))}catch(j){console.error("Failed to import profile:",$.name,j)}t(`Imported ${Ee} of ${Le.profiles.length} profiles`),Q()}catch(Te){console.error("Import error:",Te),t("Failed to parse import file","error")}},B.click()},[e,r,t,Q]),me=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(ae.map(B=>U(B))))},[ae,U]),ye=w.useCallback(()=>{T.size!==0&&O(!0)},[T.size]),le=w.useCallback(async()=>{const B=ae.filter(ce=>T.has(U(ce)));D(!0);let I=0;for(const ce of B)try{await he.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(Te=>setTimeout(Te,300))}catch(Te){console.error("Failed to delete profile:",ce.name,Te)}t(`Deleted ${I} profiles`),D(!1),O(!1),A(!1),k(new Set),Q()},[e,T,ae,t,Q,U]),$e=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 he.setKProfileNote(e,B,I),z()}catch(ce){console.error("Failed to save note:",ce),t("Failed to save note","error")}},[e,z,t]),ee=w.useCallback(B=>{if(!J?.notes)return{note:"",key:null};const I=$e(B);for(const ce of I)if(J.notes[ce])return{note:J.notes[ce],key:ce};return{note:"",key:null}},[J,$e]),X=w.useCallback(B=>ee(B).note,[ee]);return q?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(dt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):!L||L.length===0?s.jsx(St,{children:s.jsxs(Nt,{className:"py-12 text-center",children:[s.jsx(oa,{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(St,{children:s.jsxs(Nt,{className:"py-12 text-center",children:[s.jsx(qr,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Active Printers"}),s.jsx("p",{className:"text-bambu-gray",children:"Enable a printer connection to view its K-profiles"})]})}):s.jsxs(s.Fragment,{children:[K&&!W&&s.jsxs("div",{className:"fixed inset-0 bg-black/50 flex flex-col items-center justify-center z-40",children:[s.jsx(dt,{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(Se,{variant:"secondary",onClick:()=>Q(),disabled:K,children:[s.jsx(xr,{className:`w-4 h-4 ${K?"animate-spin":""}`}),"Refresh"]}),s.jsxs(Se,{onClick:()=>c(!0),children:[s.jsx(nr,{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(Ea,{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"})]}),fe&&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(Se,{variant:"secondary",onClick:ie,disabled:!P?.profiles?.length,title:"Export profiles to JSON",children:[s.jsx(Hr,{className:"w-4 h-4"}),"Export"]}),s.jsxs(Se,{variant:"secondary",onClick:Ae,title:"Import profiles from JSON",children:[s.jsx(pi,{className:"w-4 h-4"}),"Import"]}),s.jsx("div",{className:"flex-1"}),M?s.jsxs(s.Fragment,{children:[s.jsxs(Se,{variant:"secondary",onClick:Ne,title:"Select all visible profiles",children:[s.jsx(Lo,{className:"w-4 h-4"}),"Select All"]}),s.jsxs(Se,{variant:"secondary",onClick:ye,disabled:T.size===0,className:"text-red-500 hover:bg-red-500/10",title:`Delete ${T.size} selected profiles`,children:[s.jsx(dn,{className:"w-4 h-4"}),"Delete (",T.size,")"]}),s.jsxs(Se,{variant:"secondary",onClick:()=>{A(!1),k(new Set)},children:[s.jsx(Vt,{className:"w-4 h-4"}),"Cancel"]})]}):s.jsxs(Se,{variant:"secondary",onClick:()=>A(!0),disabled:!ae.length,title:"Enter selection mode for bulk delete",children:[s.jsx(Lo,{className:"w-4 h-4"}),"Select"]})]}),W?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(dt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):G?s.jsx(St,{children:s.jsxs(Nt,{className:"py-12 text-center",children:[s.jsx(ex,{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(Se,{variant:"secondary",onClick:()=>Q(),children:[s.jsx(xr,{className:"w-4 h-4"}),"Retry"]})]})}):ae.length>0?fe?s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Left Extruder"}),s.jsx("div",{className:"space-y-1",children:ae.filter(B=>B.extruder_id===1).map(B=>s.jsx(Kj,{profile:B,onEdit:()=>o(B),onCopy:()=>d(B),selectionMode:M,isSelected:T.has(U(B)),onToggleSelect:()=>me(U(B)),note:X(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:ae.filter(B=>B.extruder_id===0).map(B=>s.jsx(Kj,{profile:B,onEdit:()=>o(B),onCopy:()=>d(B),selectionMode:M,isSelected:T.has(U(B)),onToggleSelect:()=>me(U(B)),note:X(B)},U(B)))})]})]}):s.jsx("div",{className:"space-y-1",children:ae.map(B=>s.jsx(Kj,{profile:B,onEdit:()=>o(B),onCopy:()=>d(B),selectionMode:M,isSelected:T.has(U(B)),onToggleSelect:()=>me(U(B)),note:X(B)},U(B)))}):f||p!=="all"||y!=="all"?s.jsx(St,{children:s.jsxs(Nt,{className:"py-12 text-center",children:[s.jsx(Ea,{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(St,{children:s.jsxs(Nt,{className:"py-12 text-center",children:[s.jsx(oN,{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(Se,{onClick:()=>c(!0),children:[s.jsx(nr,{className:"w-4 h-4"}),"Create First Profile"]})]})}),a&&e&&(()=>{const{note:B,key:I}=ee(a);return s.jsx(Xj,{profile:a,printerId:e,nozzleDiameter:r,existingProfiles:re?.profiles||P?.profiles,isDualNozzle:fe,initialNote:B,initialNoteKey:I,onSaveNote:H,onClose:()=>{console.log("[KProfiles] Edit modal onClose - refetching profiles..."),o(null),Q()},onSave:()=>{o(null),Q()}})})(),l&&e&&s.jsx(Xj,{printerId:e,nozzleDiameter:r,existingProfiles:re?.profiles||P?.profiles,isDualNozzle:fe,onSaveNote:H,onClose:()=>{c(!1),Q()},onSave:()=>{c(!1),Q()}}),u&&e&&s.jsx(Xj,{printerId:e,nozzleDiameter:r,existingProfiles:re?.profiles||P?.profiles,isDualNozzle:fe,onSaveNote:H,profile:{...u,slot_id:0,name:`${u.name} (Copy)`},onClose:()=>{d(null),Q()},onSave:()=>{d(null),Q()}}),E&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(St,{className:"w-full max-w-sm",children:s.jsxs(Nt,{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(dn,{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:T.size})," selected profiles from the printer?"]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx(Se,{variant:"secondary",onClick:()=>O(!1),disabled:C,className:"flex-1",children:"Cancel"}),s.jsxs(Se,{onClick:le,disabled:C,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[C?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(dn,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}function _I(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 _y(t){return/^(P[FPM]US|PF\d|PP\d)/.test(t)}function iZe(t){const e=Ni(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 aZe({onSuccess:t}){const{showToast:e}=qn(),[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=mt({mutationFn:()=>he.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=mt({mutationFn:()=>he.cloudVerify(i,c),onSuccess:M=>{M.success?(e("Logged in successfully"),t()):e(M.message,"error")},onError:M=>e(M.message,"error")}),x=mt({mutationFn:()=>he.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(St,{className:"max-w-md mx-auto",children:s.jsxs(Nt,{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(iN,{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(Se,{type:"button",variant:"secondary",onClick:()=>r("email"),className:"flex-1",children:"Back"}),s.jsxs(Se,{type:"submit",disabled:S,className:"flex-1",children:[S?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(Zz,{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(mf,{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(Zz,{className:"w-4 h-4"}),"Login with email instead"]})})]})]})})}function $p({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 sZe(){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(bg,{className:"w-5 h-5"})}):null}function Yj({setting:t,onClick:e,onDuplicate:n,compareMode:r,isCompareSelected:i,compareIndex:a,compareDisabled:o}){const l=_I(t.name),c=_y(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(ll,{className:"w-4 h-4"})})]})}function SD(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+" "+SD(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)+": "+SD(o,e+1)).join(`,
- `)+`
- `+n+"}"}return String(t)}function oZe({setting:t,onClose:e,onDeleted:n,onDuplicate:r,onEdit:i}){const{showToast:a}=qn(),o=on(),[l,c]=w.useState(!1),{data:u,isLoading:d}=ut({queryKey:["cloudSettingDetail",t.setting_id],queryFn:()=>he.getCloudSettingDetail(t.setting_id)}),f=mt({mutationFn:()=>he.deleteCloudSetting(t.setting_id),onSuccess:()=>{a("Preset deleted"),o.invalidateQueries({queryKey:["cloudSettings"]}),n()},onError:b=>a(b.message,"error")}),m=_y(t.setting_id),p=_I(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(St,{className:"w-full max-w-3xl max-h-[90vh] flex flex-col overflow-hidden",children:s.jsxs(Nt,{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(Vt,{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(dt,{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:SD(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(kn,{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(Se,{variant:"secondary",onClick:()=>c(!1),disabled:f.isPending,className:"flex-1",children:"Cancel"}),s.jsxs(Se,{variant:"danger",onClick:()=>f.mutate(),disabled:f.isPending,className:"flex-1",children:[f.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(dn,{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(Se,{variant:"secondary",onClick:e,className:"flex-1",children:"Close"}),s.jsxs(Se,{variant:"secondary",onClick:r,children:[s.jsx(ll,{className:"w-4 h-4"}),"Duplicate"]}),m&&s.jsxs(s.Fragment,{children:[s.jsxs(Se,{variant:"secondary",onClick:i,disabled:d||!u,children:[s.jsx(la,{className:"w-4 h-4"}),"Edit"]}),s.jsx(Se,{variant:"danger",onClick:()=>c(!0),children:s.jsx(dn,{className:"w-4 h-4"})})]})]})})]})})})}function Wie(){try{const t=localStorage.getItem("bambusy_preset_templates");return t?JSON.parse(t):[]}catch{return[]}}function qie(t){localStorage.setItem("bambusy_preset_templates",JSON.stringify(t))}function lZe({onClose:t,onApply:e}){const{showToast:n}=qn(),[r,i]=w.useState(Wie),[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(L=>L.type===a),A=L=>{i(L),qie(L)},T=L=>{const q=r.filter(P=>P.id!==L);A(q),S(null),n("Template deleted")},k=L=>{c(L.id),d(L.name),m(L.description),b(JSON.stringify(L.settings,null,2)),x(null)},E=()=>{if(!(!l||!u.trim()))try{const L=JSON.parse(p),q=r.map(P=>P.id===l?{...P,name:u.trim(),description:f.trim(),settings:L}:P);A(q),c(null),n("Template updated")}catch(L){x(L.message)}},O=()=>{c(null),d(""),m(""),b("{}"),x(null)},C=L=>{const q=r.map(P=>P.id===L?{...P,showInModal:!P.showInModal}:P);A(q)},D={filament:{label:"Filament",icon:BD,color:"text-amber-400"},print:{label:"Process",icon:Jd,color:"text-blue-400"},printer:{label:"Printer",icon:qr,color:"text-purple-400"}},U=v?r.find(L=>L.id===v):null;return w.useEffect(()=>{const L=q=>{q.key==="Escape"&&(v?S(null):l?O():t())};return window.addEventListener("keydown",L),()=>window.removeEventListener("keydown",L)},[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(St,{className:"w-full max-w-md",children:s.jsxs(Nt,{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(kn,{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(Se,{variant:"secondary",onClick:()=>S(null),className:"flex-1",children:"Cancel"}),s.jsxs(Se,{onClick:()=>T(v),className:"flex-1 bg-red-500 hover:bg-red-600",children:[s.jsx(dn,{className:"w-4 h-4"}),"Delete"]})]})]})})}),s.jsx(St,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",children:s.jsxs(Nt,{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(D0,{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(Vt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"flex items-center gap-2 p-4 border-b border-bambu-dark-tertiary",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:"Type:"}),["all","filament","print","printer"].map(L=>s.jsx("button",{onClick:()=>o(L),className:`px-3 py-1 text-sm rounded-lg transition-colors ${a===L?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:L==="all"?"All":D[L].label},L))]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:M.length===0?s.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[s.jsx(D0,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),s.jsx("p",{children:"No templates yet"}),s.jsx("p",{className:"text-sm mt-1",children:"Create templates from the preset editor"})]}):s.jsx("div",{className:"space-y-2",children:M.map(L=>{const q=D[L.type],P=q.icon;return l===L.id?s.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg border border-bambu-green",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-3",children:[s.jsx("input",{type:"text",value:u,onChange:W=>d(W.target.value),placeholder:"Template name",className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",autoFocus:!0}),s.jsx("input",{type:"text",value:f,onChange:W=>m(W.target.value),placeholder:"Description",className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{className:"mb-3",children:[s.jsx("label",{className:"text-xs text-bambu-gray mb-1 block",children:"Settings (JSON)"}),s.jsx("textarea",{value:p,onChange:W=>{b(W.target.value),x(null)},rows:6,className:`w-full px-3 py-2 bg-bambu-dark-secondary border rounded text-white text-sm font-mono focus:outline-none ${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(Se,{size:"sm",onClick:E,disabled:!u.trim(),children:[s.jsx(_s,{className:"w-4 h-4"}),"Save"]}),s.jsx(Se,{size:"sm",variant:"secondary",onClick:O,children:"Cancel"})]})]},L.id):s.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary hover:border-bambu-gray-dark transition-colors",children:[s.jsx(P,{className:`w-5 h-5 ${q.color} flex-shrink-0`}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm font-medium text-white",children:L.name}),s.jsx("p",{className:"text-xs text-bambu-gray truncate",children:L.description})]}),s.jsxs("span",{className:"text-xs text-bambu-gray-dark px-2 py-1 bg-bambu-dark-secondary rounded",children:[Object.keys(L.settings).length," fields"]}),s.jsx("button",{onClick:()=>C(L.id),className:`p-1 transition-colors ${L.showInModal?"text-bambu-green hover:text-bambu-green/70":"text-bambu-gray hover:text-white"}`,title:L.showInModal?"Shown in modals":"Hidden in modals",children:L.showInModal?s.jsx(Qd,{className:"w-4 h-4"}):s.jsx(My,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>e(L),className:"px-3 py-1 text-xs bg-bambu-green/20 text-bambu-green rounded hover:bg-bambu-green/30 transition-colors",children:"Apply"}),s.jsx("button",{onClick:()=>k(L),className:"p-1 text-bambu-gray hover:text-white",title:"Edit",children:s.jsx(la,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>S(L.id),className:"p-1 text-bambu-gray hover:text-red-400",title:"Delete",children:s.jsx(dn,{className:"w-4 h-4"})})]},L.id)})})})]})})]})}function Kie({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 A;!S&&M?A="added":S&&!M?A="removed":JSON.stringify(x)!==JSON.stringify(v)?A="changed":A="same",b.push({key:y,left:x,right:v,status:A})}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(St,{className:"w-full max-w-4xl max-h-[85vh] flex flex-col overflow-hidden",children:s.jsxs(Nt,{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(rg,{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(Vt,{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(nr,{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(wP,{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(pP,{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(oT,{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(Ea,{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(oT,{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(nr,{className:"w-3.5 h-3.5 text-green-400"}),removed:s.jsx(wP,{className:"w-3.5 h-3.5 text-red-400"}),changed:s.jsx(pP,{className:"w-3.5 h-3.5 text-amber-400"}),same:s.jsx(oT,{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 cZe({onClose:t,initialData:e,allPresets:n}){const{showToast:r}=qn(),i=on(),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)),[A,T]=w.useState(null),[k,E]=w.useState(""),[O,C]=w.useState(!1),[D,U]=w.useState(""),[L,q]=w.useState(!1),[P,W]=w.useState(Wie),[K,V]=w.useState(!1),[Q,re]=w.useState(""),[J,z]=w.useState(""),[G,ne]=w.useState(!0),[ae,de]=w.useState(null),[fe,ie]=w.useState(!1),Ae=w.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer})[c]||[],[n,c]),me=w.useMemo(()=>Ae.filter(oe=>_y(oe.setting_id)),[Ae]),{data:Ne}=ut({queryKey:["cloudFields",c],queryFn:()=>he.getCloudFields(c==="print"?"process":c),staleTime:1e3*60*60}),{data:ye}=ut({queryKey:["allPresetDetails",c,me.map(oe=>oe.setting_id).join(",")],queryFn:async()=>{const oe={};for(let Me=0;Me<me.length;Me+=5){const Fe=me.slice(Me,Me+5);(await Promise.all(Fe.map(async se=>{try{const je=await he.getCloudSettingDetail(se.setting_id);return{id:se.setting_id,detail:je}}catch{return null}}))).forEach(se=>{se&&(oe[se.id]=se.detail)})}return oe},enabled:me.length>0,staleTime:1e3*60*10}),{data:le,isLoading:$e}=ut({queryKey:["cloudSettingDetail",m],queryFn:()=>he.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(te=>!_y(te.setting_id)).sort((te,Me)=>te.name.localeCompare(Me.name)),[n,c]);w.useEffect(()=>{if(!m)return;const oe=H.find(te=>te.setting_id===m);oe&&(y(oe.name),a||(v({inherits:oe.name}),M(JSON.stringify({inherits:oe.name},null,2))))},[m,H,a]);const ee=w.useMemo(()=>{const oe=Ne?.fields||[],te=new Set(oe.map(se=>se.key)),Me=new Set,Fe=new Set(["inherits","updated_time","compatible_printers","compatible_prints"]);ye&&Object.values(ye).forEach(se=>{se?.setting&&Object.keys(se.setting).forEach(je=>{!te.has(je)&&!Fe.has(je)&&Me.add(je)})}),Object.keys(x).forEach(se=>{!te.has(se)&&!Fe.has(se)&&Me.add(se)});const ot=Array.from(Me).sort().map(se=>({key:se,label:se.replace(/_/g," ").replace(/\b\w/g,je=>je.toUpperCase()),type:"text",category:"discovered",description:"Discovered from presets"}));return[...oe,...ot]},[Ne,ye,x]),X=ee.filter(oe=>oe.label.toLowerCase().includes(k.toLowerCase())||oe.key.toLowerCase().includes(k.toLowerCase())),B=()=>{if(D.trim()){const oe=D.trim().toLowerCase().replace(/\s+/g,"_");I(oe,""),U(""),q(!1),r(`Field "${oe}" added`)}},I=(oe,te)=>{v(Me=>{const Fe={...Me};return te===""||te===void 0?delete Fe[oe]:Fe[oe]=te,Fe})},ce=oe=>{v(te=>({...te,...oe.settings})),de(oe.name),r("Template applied")},Te=()=>{if(!Q.trim())return;const oe={...x};if(delete oe.inherits,Object.keys(oe).length===0){r("No overrides to save","error");return}const te={id:Date.now().toString(),name:Q.trim(),description:J.trim()||"Custom template",type:c,settings:oe,showInModal:G},Me=[...P,te];W(Me),qie(Me),V(!1),re(""),z(""),ne(!0),r("Template saved")},Le=w.useMemo(()=>P.filter(oe=>oe.type===c&&oe.showInModal),[c,P]),Ee=oe=>{M(oe);try{const te=JSON.parse(oe);v(te),T(null)}catch(te){T(te.message)}},$=oe=>{oe.preventDefault(),C(!1);const te=oe.dataTransfer.files[0];if(te&&te.name.endsWith(".json")){const Me=new FileReader;Me.onload=Fe=>{try{const ot=Fe.target?.result,se=JSON.parse(ot),je=se.setting||se;v(xe=>({...xe,...je})),M(JSON.stringify({...x,...je},null,2)),r("File imported successfully")}catch{r("Invalid JSON file","error")}},Me.readAsText(te)}},j=mt({mutationFn:()=>{const oe={...x},te=c==="filament"?"filament_settings_id":c==="print"?"print_settings_id":"printer_settings_id";oe[te]=`"${d}"`;const Me={type:c,name:d,base_id:m,setting:oe};return he.createCloudSetting(Me)},onSuccess:async()=>{r("Preset created successfully"),await i.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:oe=>r(oe.message,"error")}),Y=mt({mutationFn:()=>{if(!e?.setting_id)throw new Error("No setting ID for update");return he.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:oe=>r(oe.message,"error")}),ge=a?Y:j,we=le?.setting?.inherits,ve=we?H.find(oe=>oe.name===we):void 0,{data:Ze}=ut({queryKey:["cloudSettingDetail",ve?.setting_id],queryFn:()=>he.getCloudSettingDetail(ve.setting_id),enabled:!!ve?.setting_id}),Ie=w.useMemo(()=>{const oe=Ze?.setting||{},te=le?.setting||{},Me=m&&ye?.[m]?.setting?ye[m].setting:{};return{...oe,...te,...Me}},[m,le,Ze,ye]),qe=oe=>{if(oe==null)return"";if(Array.isArray(oe)){const te=[...new Set(oe.map(Me=>String(Me)))];return te.length===1?te[0]:oe.join(", ")}return String(oe)},Je=oe=>{const te=x[oe.key],Me=Ie[oe.key],Fe=qe(Me),ot=$e?"Loading...":Fe||"",se="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(oe.type==="boolean"){const je=te==="1"||te===void 0&&Me==="1";return s.jsx("button",{type:"button",onClick:()=>I(oe.key,te==="1"?"0":"1"),className:`w-8 h-5 rounded-full transition-colors ${je?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:s.jsx("div",{className:`w-4 h-4 rounded-full bg-white shadow transition-transform ${je?"translate-x-3.5":"translate-x-0.5"}`})})}return oe.type==="select"?s.jsxs("select",{value:te||"",onChange:je=>I(oe.key,je.target.value),className:se,children:[s.jsx("option",{value:"",children:ot}),oe.options?.map(je=>s.jsx("option",{value:je.value,children:je.label},je.value))]}):s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:oe.type==="number"?"number":"text",value:te!==void 0?String(te):"",onChange:je=>I(oe.key,je.target.value),step:oe.step,min:oe.min,max:oe.max,placeholder:ot,className:se}),oe.unit&&s.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:oe.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:oe=>{oe.preventDefault(),C(!0)},onDragLeave:()=>C(!1),onDrop:$,children:[fe&&m&&s.jsx(Kie,{onClose:()=>ie(!1),leftPreset:Qe,rightPreset:x,leftLabel:`Base: ${b||m}`,rightLabel:`Current: ${d||"New Preset"}`}),s.jsx(St,{className:"w-full max-w-6xl max-h-[90vh] flex flex-col",children:s.jsxs(Nt,{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:()=>ie(!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(rg,{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(Vt,{className:"w-5 h-5"})})]})]}),O&&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(pi,{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:oe=>{u(oe.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:oe=>p(oe.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(oe=>s.jsx("option",{value:oe.setting_id,children:oe.name},oe.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:oe=>f(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:"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(ns,{className:"w-3 h-3 text-bambu-green"}),"Inherits from: ",s.jsx("span",{className:"text-white",children:b}),$e&&s.jsx(dt,{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(Qz,{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(dN,{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(gK,{className:"w-4 h-4"}),"JSON",A&&s.jsx(oa,{className:"w-3 h-3 text-red-400"})]}),s.jsx("div",{className:"flex-1"}),s.jsxs("button",{onClick:()=>{const oe={name:d,type:c,base_id:m,setting:x},te=new Blob([JSON.stringify(oe,null,2)],{type:"application/json"}),Me=URL.createObjectURL(te),Fe=document.createElement("a");Fe.href=Me,Fe.download=`${d||"preset"}.json`,document.body.appendChild(Fe),Fe.click(),document.body.removeChild(Fe),URL.revokeObjectURL(Me),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(Hr,{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(pi,{className:"w-4 h-4"}),"Import"]}),s.jsx("input",{id:"file-import",type:"file",accept:".json",className:"hidden",onChange:oe=>{const te=oe.target.files?.[0];if(te){const Me=new FileReader;Me.onload=Fe=>{try{const ot=JSON.parse(Fe.target?.result),se=ot.setting||ot;v(je=>({...je,...se})),r("File imported")}catch{r("Invalid JSON","error")}},Me.readAsText(te)}}})]}),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(D0,{className:"w-4 h-4 text-amber-400"}),"Quick Templates"]}),Object.keys(x).filter(oe=>oe!=="inherits").length>0&&s.jsxs("button",{onClick:()=>V(!K),className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1 transition-colors",children:[s.jsx(_s,{className:"w-3 h-3"}),"Save as template"]})]}),K&&s.jsxs("div",{className:"mb-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-2",children:[s.jsx("input",{type:"text",value:Q,onChange:oe=>re(oe.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:J,onChange:oe=>z(oe.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(Se,{size:"sm",onClick:Te,disabled:!Q.trim(),children:[s.jsx(_s,{className:"w-3 h-3"}),"Save"]}),s.jsx(Se,{size:"sm",variant:"secondary",onClick:()=>V(!1),children:"Cancel"})]}),s.jsxs("button",{onClick:()=>ne(!G),className:`flex items-center gap-1.5 text-xs transition-colors ${G?"text-bambu-green":"text-bambu-gray hover:text-white"}`,children:[G?s.jsx(Qd,{className:"w-3.5 h-3.5"}):s.jsx(My,{className:"w-3.5 h-3.5"}),G?"Show in modals":"Hidden in modals"]})]})]}),ae&&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(ns,{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:ae})]}),s.jsx("button",{onClick:()=>de(null),className:"ml-auto text-bambu-green/70 hover:text-bambu-green",children:s.jsx(Vt,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[Le.map(oe=>s.jsxs("button",{onClick:()=>ce(oe),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:oe.name}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:oe.description})]},oe.id)),Le.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:ee.slice(0,10).map(oe=>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:oe.label}),s.jsx("div",{className:"w-48",children:Je(oe)})]},oe.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(([oe])=>oe!=="inherits").map(([oe,te])=>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:[oe,": ",String(te).slice(0,20),s.jsx("button",{onClick:()=>I(oe,void 0),className:"hover:text-white",children:s.jsx(Vt,{className:"w-3 h-3"})})]},oe))})]})]}),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:ye?`${ee.length} fields`:"Loading..."})]}),s.jsxs("div",{className:"relative mb-3 flex-shrink-0",children:[s.jsx(Ea,{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:oe=>E(oe.target.value),placeholder:"Search fields...",className:"w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto space-y-1 pr-2 min-h-0",children:[X.filter(oe=>!(oe.key in x)).map(oe=>{const te=Ie[oe.key],Me=qe(te);return s.jsxs("div",{onClick:()=>{v(Fe=>({...Fe,[oe.key]:Me||""}))},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:oe.label}),s.jsx("p",{className:"text-xs text-bambu-gray-dark truncate",children:oe.key})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[Me&&s.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark px-2 py-0.5 rounded max-w-32 truncate",title:Me,children:[Me.slice(0,20),Me.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(nr,{className:"w-4 h-4 text-bambu-gray group-hover:text-bambu-green transition-colors"})})]})]},oe.key)}),X.filter(oe=>!(oe.key in x)).length===0&&s.jsx("p",{className:"text-center text-bambu-gray py-4 text-sm",children:k?"No matching fields":"All fields added"})]}),s.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:L?s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",value:D,onChange:oe=>U(oe.target.value),onKeyDown:oe=>oe.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(Se,{size:"sm",onClick:B,disabled:!D.trim(),children:s.jsx(nr,{className:"w-4 h-4"})}),s.jsx(Se,{size:"sm",variant:"secondary",onClick:()=>{q(!1),U("")},children:s.jsx(Vt,{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(nr,{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(oe=>oe!=="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(([oe])=>oe!=="inherits").map(([oe,te])=>{const Me=ee.find(Fe=>Fe.key===oe);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:Me?.label||oe}),s.jsx("p",{className:"text-xs text-bambu-gray-dark",children:oe})]}),s.jsx("button",{onClick:()=>I(oe,void 0),className:"p-1 text-bambu-gray hover:text-red-400 transition-colors",children:s.jsx(Vt,{className:"w-4 h-4"})})]}),Me?Je(Me):s.jsx("input",{type:"text",value:String(te),onChange:Fe=>I(oe,Fe.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"})]},oe)}),Object.keys(x).filter(oe=>oe!=="inherits").length===0&&s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx(Qz,{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(oe=>oe!=="inherits").length>0&&s.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:s.jsxs("button",{onClick:()=>{V(!0),l("common")},className:"w-full flex items-center justify-center gap-2 p-2 text-sm text-bambu-gray hover:text-white border border-dashed border-bambu-dark-tertiary hover:border-bambu-gray-dark rounded-lg transition-colors",children:[s.jsx(_s,{className:"w-4 h-4"}),"Save as template"]})})]})]}),o==="json"&&s.jsxs("div",{className:"space-y-2",children:[A&&s.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[s.jsx(oa,{className:"w-4 h-4"}),A]}),s.jsx("textarea",{value:S,onChange:oe=>Ee(oe.target.value),className:`w-full h-80 px-3 py-2 bg-bambu-dark border rounded-lg text-white text-xs font-mono focus:outline-none resize-none ${A?"border-red-500 focus:border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`,spellCheck:!1}),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(Se,{variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),s.jsxs(Se,{onClick:()=>ge.mutate(),disabled:ge.isPending||!d.trim()||!a&&!m||!!A,className:"flex-1",children:[ge.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):a?s.jsx(_s,{className:"w-4 h-4"}):s.jsx(nr,{className:"w-4 h-4"}),a?"Save":e?"Duplicate":"Create"]})]})]})})]})}function uZe({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,A]=w.useState(null),[T,k]=w.useState(!1),[E,O]=w.useState(!1),[C,D]=w.useState(null),[U,L]=w.useState(null),[q,P]=w.useState(null),[W,K]=w.useState(!1),[V,Q]=w.useState([null,null]),[re,J]=w.useState(!1),[z,G]=w.useState(null),ne=on(),ae=w.useMemo(()=>[...t.filament.map(X=>({...X,type:"filament"})),...t.printer.map(X=>({...X,type:"printer"})),...t.process.map(X=>({...X,type:"process"}))].map(X=>({...X,meta:_I(X.name)})),[t]),de=w.useMemo(()=>{const ee=new Set,X=new Set,B=new Set;return ae.forEach(I=>{I.meta.nozzle&&ee.add(I.meta.nozzle),I.meta.filamentType&&X.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(ee).sort((I,ce)=>parseFloat(I)-parseFloat(ce)),filaments:Array.from(X).sort(),layerHeights:Array.from(B).sort((I,ce)=>parseFloat(I)-parseFloat(ce))}},[ae,i]),fe=w.useMemo(()=>f==="all"?null:i.find(X=>X.id.toString()===f)?.model||null,[f,i]),ie=w.useMemo(()=>ae.filter(ee=>l==="all"||ee.type===l).filter(ee=>{if(u==="all")return!0;const X=_y(ee.setting_id);return u==="custom"?X:!X}).filter(ee=>{if(f==="all"||!fe)return!0;const X=ee.meta.printer?.toLowerCase()||"",B=fe.toLowerCase();return X.includes(B)||B.includes(X)}).filter(ee=>p==="all"||ee.meta.nozzle===p).filter(ee=>y==="all"||ee.meta.filamentType===y).filter(ee=>v==="all"||ee.meta.layerHeight===v).filter(ee=>a===""||ee.name.toLowerCase().includes(a.toLowerCase())).sort((ee,X)=>ee.name.localeCompare(X.name)),[ae,l,u,f,fe,p,y,v,a]),Ae=ee=>{if(W){const X=V[0]?.setting_id===ee.setting_id,B=V[1]?.setting_id===ee.setting_id;if(X)Q([V[1],null]);else if(B)Q([V[0],null]);else if(!V[0])Q([ee,null]);else if(V[1]){if(V[0].type!==ee.type)return;Q([V[0],ee])}else{if(V[0].type!==ee.type)return;Q([V[0],ee])}}else A(ee)},me=ee=>{if(V[0]?.setting_id===ee.setting_id)return 0;if(V[1]?.setting_id===ee.setting_id)return 1},Ne=async ee=>{try{const X=await he.getCloudSettingDetail(ee.setting_id),B=ee.type==="process"?"print":ee.type;D({type:B,name:ee.name,base_id:X.base_id||"GFSA00",setting:X.setting||{}}),A(null)}catch(X){console.error("Failed to fetch preset details for duplication:",X)}},ye=async ee=>{try{ne.removeQueries({queryKey:["cloudSettingDetail",ee.setting_id]});const X=await he.getCloudSettingDetail(ee.setting_id),B=ee.type==="process"?"print":ee.type;L({type:B,name:ee.name,base_id:X.base_id||"GFSA00",setting:X.setting||{},setting_id:ee.setting_id}),A(null)}catch(X){console.error("Failed to fetch preset details for editing:",X)}},le=()=>{c("all"),d("all"),m("all"),b("all"),x("all"),S("all"),o("")},$e=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(Ea,{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:ee=>o(ee.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(Se,{variant:W?"primary":"secondary",onClick:()=>{W?(K(!1),Q([null,null])):K(!0)},children:[s.jsx(rg,{className:"w-4 h-4"}),W?"Cancel":"Compare"]}),s.jsxs(Se,{variant:"secondary",onClick:()=>O(!0),children:[s.jsx(D0,{className:"w-4 h-4"}),"Templates"]}),s.jsxs(Se,{variant:"secondary",onClick:n,disabled:r,children:[s.jsx(xr,{className:`w-4 h-4 ${r?"animate-spin":""}`}),"Refresh"]}),s.jsxs(Se,{onClick:()=>k(!0),children:[s.jsx(nr,{className:"w-4 h-4"}),"New Preset"]})]})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(sN,{className:"w-4 h-4 text-bambu-gray"}),s.jsx($p,{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:ee=>c(ee)}),s.jsx($p,{label:"Owner",value:u,options:[{value:"all",label:"All"},{value:"custom",label:"My Presets"},{value:"builtin",label:"Built-in"}],onChange:ee=>d(ee)}),de.printers.length>0&&s.jsx($p,{label:"Printer",value:f,options:[{value:"all",label:"All"},...de.printers.map(ee=>({value:ee.id,label:ee.name}))],onChange:m}),de.nozzles.length>0&&s.jsx($p,{label:"Nozzle",value:p,options:[{value:"all",label:"All"},...de.nozzles.map(ee=>({value:ee,label:ee}))],onChange:b}),de.filaments.length>0&&(l==="all"||l==="filament")&&s.jsx($p,{label:"Filament",value:y,options:[{value:"all",label:"All"},...de.filaments.map(ee=>({value:ee,label:ee}))],onChange:x}),de.layerHeights.length>0&&(l==="all"||l==="process")&&s.jsx($p,{label:"Layer",value:v,options:[{value:"all",label:"All"},...de.layerHeights.map(ee=>({value:ee,label:ee}))],onChange:S}),$e&&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(rg,{className:"w-5 h-5 text-blue-400"}),s.jsx("span",{className:"text-white font-medium",children:"Compare Mode"}),s.jsx("span",{className:"text-bambu-gray",children:V[0]?`Select another ${V[0].type} preset`:"Click two presets of the same type to compare"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${V[0]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:V[0]?V[0].name:"1. Select first"}),s.jsx(pP,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${V[1]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:V[1]?V[1].name:"2. Select second"})]}),V[0]&&V[1]&&s.jsxs(Se,{size:"sm",onClick:async()=>{try{const[ee,X]=await Promise.all([he.getCloudSettingDetail(V[0].setting_id),he.getCloudSettingDetail(V[1].setting_id)]);G([ee.setting||{},X.setting||{}]),J(!0)}catch{}},children:[s.jsx(rg,{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(Zn,{className:"w-3 h-3"}),"Last synced: ",iZe(e.toISOString())]}),s.jsxs("span",{children:["Showing ",ie.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)"})]})]}),ie.length===0?s.jsxs("div",{className:"text-center py-16",children:[s.jsx(ul,{className:"w-12 h-12 text-bambu-gray-dark mx-auto mb-4"}),s.jsx("p",{className:"text-bambu-gray",children:"No presets found"}),$e&&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(BD,{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:["(",ie.filter(ee=>ee.type==="filament").length,")"]})]}),s.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[ie.filter(ee=>ee.type==="filament").map(ee=>s.jsx(Yj,{setting:ee,onClick:()=>Ae(ee),onDuplicate:()=>Ne(ee),compareMode:W,isCompareSelected:me(ee)!==void 0,compareIndex:me(ee),compareDisabled:W&&!!V[0]&&V[0].type!==ee.type},ee.setting_id)),ie.filter(ee=>ee.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(Jd,{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:["(",ie.filter(ee=>ee.type==="process").length,")"]})]}),s.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[ie.filter(ee=>ee.type==="process").map(ee=>s.jsx(Yj,{setting:ee,onClick:()=>Ae(ee),onDuplicate:()=>Ne(ee),compareMode:W,isCompareSelected:me(ee)!==void 0,compareIndex:me(ee),compareDisabled:W&&!!V[0]&&V[0].type!==ee.type},ee.setting_id)),ie.filter(ee=>ee.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(qr,{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:["(",ie.filter(ee=>ee.type==="printer").length,")"]})]}),s.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[ie.filter(ee=>ee.type==="printer").map(ee=>s.jsx(Yj,{setting:ee,onClick:()=>Ae(ee),onDuplicate:()=>Ne(ee),compareMode:W,isCompareSelected:me(ee)!==void 0,compareIndex:me(ee),compareDisabled:W&&!!V[0]&&V[0].type!==ee.type},ee.setting_id)),ie.filter(ee=>ee.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(oZe,{setting:M,onClose:()=>A(null),onDeleted:()=>A(null),onDuplicate:()=>Ne(M),onEdit:()=>ye(M)}),(T||C||U||q)&&s.jsx(cZe,{onClose:()=>{k(!1),D(null),L(null),P(null)},initialData:U||C||(q?{type:q.type,name:"",base_id:"",setting:q.setting}:void 0),allPresets:t}),E&&s.jsx(lZe,{onClose:()=>O(!1),onApply:ee=>{P({type:ee.type,setting:ee.settings}),O(!1)}}),re&&z&&V[0]&&V[1]&&s.jsx(Kie,{onClose:()=>{J(!1),G(null)},leftPreset:z[0],rightPreset:z[1],leftLabel:V[0].name,rightLabel:V[1].name})]})}function dZe(){const t=on(),{showToast:e}=qn(),[n,r]=w.useState("cloud"),[i,a]=w.useState(),{data:o,isLoading:l}=ut({queryKey:["cloudStatus"],queryFn:he.getCloudStatus}),{data:c=[]}=ut({queryKey:["printers"],queryFn:he.getPrinters}),{data:u,isLoading:d,refetch:f,dataUpdatedAt:m}=ut({queryKey:["cloudSettings"],queryFn:()=>he.getCloudSettings(),enabled:!!o?.is_authenticated,retry:!1,staleTime:1e3*60*5});w.useEffect(()=>{m&&a(new Date(m))},[m]);const p=mt({mutationFn:he.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(dt,{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(iN,{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(oN,{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(Se,{variant:"secondary",size:"sm",onClick:()=>p.mutate(),disabled:p.isPending,children:[s.jsx(_P,{className:"w-4 h-4"}),"Logout"]})]}),o?.is_authenticated?d?s.jsx("div",{className:"flex items-center justify-center py-16",children:s.jsx(dt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):u?s.jsx(uZe,{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(Se,{onClick:()=>f(),children:"Retry"})]}):s.jsx(aZe,{onSuccess:b})]}),n==="kprofiles"&&s.jsx(rZe,{}),s.jsx(sZe,{})]})}const n0={Droplet:BD,Flame:ehe,Ruler:Pfe,Sparkles:D0,Square:Io,Cable:Xue,Wrench:eh,Calendar:oi,Timer:jd,Cog:Ade,Fan:xK,Zap:qf,Wind:kK,Thermometer:pN,Layers:ul,Box:Hs,Target:AK,RefreshCw:xr,Settings:mN,Filter:sN,CircleDot:mde};function E0(t){return t&&n0[t]||eh}function Hp(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 Zj(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 hZe(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 fZe({item:t,onPerform:e,onToggle:n}){const r=E0(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 ${Hp(Math.abs(f),"days")}`:t.is_warning?`Due in ${Hp(f,"days")}`:`${Hp(f,"days")} left`}else return t.is_due?`Overdue by ${Hp(Math.abs(t.hours_until_due),"hours")}`:t.is_warning?`Due in ${Hp(t.hours_until_due,"hours")}`:`${Hp(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(oi,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"})}),(()=>{const f=t.maintenance_type_wiki_url||hZe(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(zr,{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(kn,{className:"w-3 h-3"}),t.is_warning&&!t.is_due&&s.jsx(Zn,{className:"w-3 h-3"}),!t.is_due&&!t.is_warning&&t.enabled&&s.jsx(ns,{className:"w-3 h-3"}),d()]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx(Gn,{checked:t.enabled,onChange:f=>n(t.id,f)}),s.jsxs(Se,{size:"sm",variant:t.is_due?"primary":"secondary",onClick:()=>e(t.id),disabled:!t.enabled,className:"!px-3",children:[s.jsx(mm,{className:"w-3.5 h-3.5"}),"Reset"]})]})]})})}function mZe({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(St,{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(kn,{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(Zn,{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(ns,{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(pu,{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(jd,{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(Se,{size:"sm",onClick:m,children:"Save"}),s.jsx(Se,{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(Gf,{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=E0(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(Nt,{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(fZe,{item:p,onPerform:e,onToggle:n},p.id))})})]})}function pZe({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"),[A,T]=w.useState("hours"),[k,E]=w.useState("Wrench"),[O,C]=w.useState(""),[D,U]=w.useState(new Set),[L,q]=w.useState(null),P=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})):[],K=B=>{if(!t)return[];const I=new Set(W(B).map(ce=>ce.printerId));return P.filter(ce=>!I.has(ce.id))},[V,Q]=w.useState(null),[re,J]=w.useState(""),[z,G]=w.useState(""),[ne,ae]=w.useState("hours"),[de,fe]=w.useState("Wrench"),[ie,Ae]=w.useState(""),me=B=>{Q(B),J(B.name),G(B.default_interval_hours.toString()),ae(B.interval_type||"hours"),fe(B.icon||"Wrench"),Ae(B.wiki_url||"")},Ne=()=>{V&&re.trim()&&parseFloat(z)>0&&(i(V.id,{name:re.trim(),default_interval_hours:parseFloat(z),interval_type:ne,icon:de,wiki_url:ie.trim()||null}),Q(null))},ye=(B,I,ce)=>{const Te=parseFloat(d);if(!isNaN(Te)&&Te>0){const Le=Math.abs(Te-I)<.01?null:Te;n(B,{custom_interval_hours:Le,custom_interval_type:m!==ce?m:null})}u(null)},le=B=>{B.preventDefault(),x.trim()&&parseFloat(S)>0&&D.size>0&&(r({name:x.trim(),default_interval_hours:parseFloat(S),interval_type:A,icon:k,wiki_url:O.trim()||null},Array.from(D)),v(""),M("100"),T("hours"),C(""),U(new Set),y(!1))},$e=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))||[],ee=e.filter(B=>B.is_system),X=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(Se,{onClick:()=>y(!b),children:[s.jsx(nr,{className:"w-4 h-4"}),"Add Custom Type"]})]}),b&&s.jsx(St,{className:"mb-6",children:s.jsx(Nt,{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:A,onChange:B=>{T(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 (",A==="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(n0).map(B=>{const I=n0[B];return s.jsx("button",{type:"button",onClick:()=>E(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:O,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:P.map(B=>s.jsx("button",{type:"button",onClick:()=>$e(B.id),className:`px-3 py-1.5 rounded-lg text-sm transition-colors ${D.has(B.id)?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:B.name},B.id))}),D.size===0&&s.jsx("p",{className:"text-xs text-orange-400 mt-1",children:"Select at least one printer"})]}),s.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[s.jsx(Se,{type:"button",variant:"secondary",onClick:()=>{y(!1),U(new Set)},children:"Cancel"}),s.jsx(Se,{type:"submit",disabled:!x.trim()||D.size===0,children:"Add Type"})]})]})})}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[ee.map(B=>{const I=E0(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(oi,{className:"w-3 h-3"}):s.jsx(jd,{className:"w-3 h-3"}),Zj(B.default_interval_hours,ce)]})]})]})},B.id)}),X.map(B=>{const I=E0(B.icon),ce=B.interval_type||"hours";if(V?.id===B.id)return s.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green",children:s.jsxs("div",{className:"space-y-3",children:[s.jsx("input",{type:"text",value:re,onChange:j=>J(j.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:"Name",autoFocus:!0}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("select",{value:ne,onChange:j=>ae(j.target.value),className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"hours",children:"Print Hours"}),s.jsx("option",{value:"days",children:"Calendar Days"})]}),s.jsx("input",{type:"number",value:z,onChange:j=>G(j.target.value),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",min:"1"})]}),s.jsx("div",{className:"flex flex-wrap gap-1",children:Object.keys(n0).map(j=>{const Y=n0[j];return s.jsx("button",{type:"button",onClick:()=>fe(j),className:`p-1.5 rounded transition-colors ${de===j?"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"})},j)})}),s.jsx("input",{type:"url",value:ie,onChange:j=>Ae(j.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:"Documentation link (optional)"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Se,{size:"sm",onClick:Ne,disabled:!re.trim(),children:"Save"}),s.jsx(Se,{size:"sm",variant:"secondary",onClick:()=>Q(null),children:"Cancel"})]})]})},B.id);const Le=W(B.id),Ee=K(B.id),$=L===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(oi,{className:"w-3 h-3"}):s.jsx(jd,{className:"w-3 h-3"}),Zj(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 ${Le.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:`${Le.length} printer(s) assigned - click to manage`,children:[s.jsx(qr,{className:"w-3 h-3"}),s.jsx("span",{className:"text-xs font-medium",children:Le.length}),s.jsx(Oi,{className:`w-3 h-3 transition-transform ${$?"rotate-180":""}`})]}),s.jsx("button",{onClick:()=>me(B),className:"p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",children:s.jsx(Gf,{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(dn,{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:"}),Le.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:Le.map(j=>s.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark rounded text-xs text-white",children:[j.printerName,s.jsx("button",{onClick:()=>j.itemId&&l(j.itemId),className:"hover:text-red-400 ml-1",title:"Remove from this printer",children:"×"})]},j.printerId))}),Ee.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-1",children:[s.jsx("span",{className:"text-xs text-bambu-gray mr-1",children:"Add:"}),Ee.map(j=>s.jsxs("button",{onClick:()=>o(j.id,B.id),className:"px-2 py-1 bg-bambu-dark hover:bg-bambu-green/20 rounded text-xs text-bambu-gray hover:text-bambu-green transition-colors",children:["+ ",j.name]},j.id))]})]})]},B.id)})]})]}),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(St,{children:s.jsxs(Nt,{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=E0(I.maintenance_type_icon),Te=e.find(Y=>Y.id===I.maintenance_type_id),Le=Te?.default_interval_hours||I.interval_hours,Ee=Te?.interval_type||"hours",$=I.interval_type||"hours",j=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}),j?s.jsxs("div",{className:"flex items-center gap-1",children:[m==="days"?s.jsx(oi,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}):s.jsx(jd,{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"&&ye(I.id,Le,Ee),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(Se,{size:"sm",onClick:()=>ye(I.id,Le,Ee),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(oi,{className:"w-3 h-3"}):s.jsx(jd,{className:"w-3 h-3"}),Zj(I.interval_hours,$),s.jsx(Gf,{className:"w-3 h-3 text-bambu-gray"})]})]},I.id)})})]})},B.printerId))})]}),H.length===0&&s.jsx(St,{children:s.jsxs(Nt,{className:"text-center py-12",children:[s.jsx(Zn,{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 gZe(){const t=on(),{showToast:e}=qn(),[n,r]=w.useState("status"),{data:i,isLoading:a}=ut({queryKey:["maintenanceOverview"],queryFn:he.getMaintenanceOverview}),{data:o}=ut({queryKey:["maintenanceTypes"],queryFn:he.getMaintenanceTypes}),l=mt({mutationFn:({id:M,notes:A})=>he.performMaintenance(M,A),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Maintenance marked as complete")},onError:M=>{e(M.message,"error")}}),c=mt({mutationFn:({id:M,data:A})=>he.updateMaintenanceItem(M,A),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:M=>{e(M.message,"error")}}),u=mt({mutationFn:({id:M,data:A})=>he.updateMaintenanceType(M,A),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type updated")},onError:M=>{e(M.message,"error")}}),d=mt({mutationFn:he.deleteMaintenanceType,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type deleted")},onError:M=>{e(M.message,"error")}}),f=mt({mutationFn:({printerId:M,hours:A})=>he.setPrinterHours(M,A),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Print hours updated")},onError:M=>{e(M.message,"error")}}),m=mt({mutationFn:({printerId:M,typeId:A})=>he.assignMaintenanceType(M,A),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Printer assigned")},onError:M=>{e(M.message,"error")}}),p=mt({mutationFn:he.removeMaintenanceItem,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Printer removed")},onError:M=>{e(M.message,"error")}}),b=M=>{l.mutate({id:M})},y=(M,A)=>{c.mutate({id:M,data:{enabled:A}})},x=(M,A)=>{f.mutate({printerId:M,hours:A})};if(a)return s.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:s.jsx(dt,{className:"w-8 h-8 text-bambu-green animate-spin"})});const v=i?.reduce((M,A)=>M+A.due_count,0)||0,S=i?.reduce((M,A)=>M+A.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,A)=>{const T=M.due_count*10+M.warning_count,k=A.due_count*10+A.warning_count;return T!==k?k-T:M.printer_name.localeCompare(A.printer_name)}).map(M=>s.jsx(mZe,{overview:M,onPerform:b,onToggle:y,onSetHours:x},M.printer_id)):s.jsx(St,{children:s.jsxs(Nt,{className:"text-center py-16",children:[s.jsx(eh,{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(pZe,{overview:i,types:o||[],onUpdateInterval:(M,A)=>c.mutate({id:M,data:A}),onAddType:async(M,A)=>{const T=await he.createMaintenanceType(M);for(const k of A)await he.assignMaintenanceType(k,T.id);t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type added")},onUpdateType:(M,A)=>u.mutate({id:M,data:A}),onDeleteType:M=>d.mutate(M),onAssignType:(M,A)=>m.mutate({printerId:M,typeId:A}),onRemoveItem:M=>p.mutate(M)})]})}const xq=["#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#6b7280"];function Xie({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||xq[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]||""),[A,T]=w.useState(t?.priority||"normal"),k=E=>{E.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:A,...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:E=>a(E.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:E=>l(E.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:xq.map(E=>s.jsx("button",{type:"button",onClick:()=>u(E),className:`w-8 h-8 rounded-full transition-transform ${c===E?"ring-2 ring-white ring-offset-2 ring-offset-bambu-dark-secondary scale-110":""}`,style:{backgroundColor:E}},E))})]}),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:E=>f(E.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:E=>p(E.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:E=>v(E.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:E=>M(E.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:A,onChange:E=>T(E.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:E=>y(E.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(Se,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(Se,{type:"submit",disabled:!i.trim()||r,children:r?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):t?"Save":"Create"})]})]})]})})}function xZe({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:rN,color:"text-bambu-green",bg:"bg-bambu-green/10"}:l?{icon:es,color:"text-bambu-gray",bg:"bg-bambu-gray/10"}:t.queue_count>0?{icon:Zn,color:"text-blue-400",bg:"bg-blue-400/10"}:{icon:Ta,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(zd,{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(Gf,{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(dn,{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(es,{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(kn,{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(Zn,{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:he.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(Jl,{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(kn,{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(ul,{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(Jl,{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(kn,{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(vP,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:t.queue_count})]})]}),s.jsx(Js,{className:"w-4 h-4 text-bambu-gray/50 group-hover:text-bambu-gray transition-colors"})]})]})]})}function bZe(){const t=gl(),e=on(),{showToast:n}=qn(),[r,i]=w.useState(!1),[a,o]=w.useState(),[l,c]=w.useState("active"),[u,d]=w.useState(null),{data:f,isLoading:m}=ut({queryKey:["projects",l==="all"?void 0:l],queryFn:()=>he.getProjects(l==="all"?void 0:l)}),p=mt({mutationFn:U=>he.createProject(U),onSuccess:()=>{e.invalidateQueries({queryKey:["projects"]}),i(!1),n("Project created","success")},onError:U=>{n(U.message,"error")}}),b=mt({mutationFn:({id:U,data:L})=>he.updateProject(U,L),onSuccess:()=>{e.invalidateQueries({queryKey:["projects"]}),i(!1),o(void 0),n("Project updated","success")},onError:U=>{n(U.message,"error")}}),y=mt({mutationFn:U=>he.deleteProject(U),onSuccess:()=>{d(null),n("Project deleted","success"),setTimeout(()=>window.location.reload(),100)},onError:U=>{d(null),n(U.message,"error")}}),x=mt({mutationFn:U=>he.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 he.getProjects(),L=await Promise.all(U.map(async K=>await he.exportProjectJson(K.id))),q=new Blob([JSON.stringify(L,null,2)],{type:"application/json"}),P=URL.createObjectURL(q),W=document.createElement("a");W.href=P,W.download=`bambuddy_projects_${new Date().toISOString().split("T")[0]}.json`,W.click(),URL.revokeObjectURL(P),n("Projects exported (metadata only)","success")}catch(U){n(U.message,"error")}},M=()=>{v.current?.click()},A=async U=>{const L=U.target.files?.[0];if(L){try{if(L.name.toLowerCase().endsWith(".zip")){const P=new FormData;P.append("file",L);const W=await fetch("/api/v1/projects/import/file",{method:"POST",body:P});if(!W.ok){const K=await W.json();throw new Error(K.detail||"Import failed")}e.invalidateQueries({queryKey:["projects"]}),n("Project imported","success")}else{const P=await L.text(),W=JSON.parse(P),K=Array.isArray(W)?W:[W];for(const V of K)await x.mutateAsync(V);K.length>1&&n(`${K.length} projects imported`,"success")}}catch(q){n(`Import failed: ${q.message}`,"error")}U.target.value=""}},T=U=>{a?b.mutate({id:a.id,data:U}):p.mutate(U)},k=U=>{o(U),i(!0)},E=U=>{t(`/projects/${U.id}`)},O=U=>{d(U)},C=()=>{u!==null&&y.mutate(u)},D=f?.reduce((U,L)=>(U[L.status]=(U[L.status]||0)+1,U.all=(U.all||0)+1,U),{})||{};return s.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[s.jsx("input",{ref:v,type:"file",accept:".json,.zip",onChange:A,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(Ta,{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(Se,{variant:"secondary",onClick:M,title:"Import project",children:[s.jsx(pi,{className:"w-4 h-4 mr-2"}),"Import"]}),s.jsxs(Se,{variant:"secondary",onClick:S,title:"Export all projects",children:[s.jsx(Hr,{className:"w-4 h-4 mr-2"}),"Export"]}),s.jsxs(Se,{onClick:()=>i(!0),className:"sm:w-auto w-full",children:[s.jsx(nr,{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:Zn},{key:"completed",label:"Completed",icon:rN},{key:"archived",label:"Archived",icon:es},{key:"all",label:"All",icon:Ta}].map(({key:U,label:L,icon:q})=>s.jsxs("button",{onClick:()=>c(U),className:`flex items-center gap-2 px-4 py-2 text-sm rounded-lg transition-all ${l===U?"bg-bambu-card text-white shadow-sm":"text-bambu-gray hover:text-white"}`,children:[s.jsx(q,{className:"w-4 h-4"}),s.jsx("span",{children:L}),D[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:D[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(dt,{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(Ta,{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(Se,{onClick:()=>i(!0),children:[s.jsx(nr,{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(xZe,{project:U,onClick:()=>E(U),onEdit:()=>k(U),onDelete:()=>O(U.id)},U.id))}),u!==null&&s.jsx(Hn,{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(Xie,{project:a,onClose:()=>{i(!1),o(void 0)},onSave:T,isLoading:p.isPending||b.isPending})]})}function yZe(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 vZe(t){return t>=1e3?`${(t/1e3).toFixed(2)}kg`:`${Math.round(t)}g`}function _Ze({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 bq({icon:t,label:e,value:n,subValue:r,hint:i,color:a="text-bambu-gray"}){return s.jsx(St,{children:s.jsx(Nt,{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 wZe({archives:t}){return t.length===0?s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx(Jl,{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(bs,{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:he.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(Jl,{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(ia,{className:"w-8 h-8 text-white"})}),e.status==="completed"&&s.jsx("div",{className:"absolute top-1 right-1",children:s.jsx(Un,{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 SZe({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(kn,{className:"w-3 h-3"}),r]})}function MZe(t){return t?_g(t,{year:"numeric",month:"short",day:"numeric"}):""}function Qj(t){if(!t)return null;const e=Ni(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 NZe(){const{id:t}=CD(),e=gl(),n=on(),{showToast:r}=qn(),[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}=ut({queryKey:["project",d],queryFn:()=>he.getProject(d),enabled:d>0}),{data:b,isLoading:y}=ut({queryKey:["project-archives",d],queryFn:()=>he.getProjectArchives(d),enabled:d>0}),{data:x,isLoading:v}=ut({queryKey:["project-bom",d],queryFn:()=>he.getProjectBOM(d),enabled:d>0}),{data:S,isLoading:M}=ut({queryKey:["project-timeline",d],queryFn:()=>he.getProjectTimeline(d,20),enabled:d>0}),{data:A}=ut({queryKey:["settings"],queryFn:he.getSettings}),{data:T}=ut({queryKey:["project-folders",d],queryFn:()=>he.getLibraryFoldersByProject(d),enabled:d>0}),k=A?.currency||"$",E=A?.time_format||"system",O=mt({mutationFn:te=>he.updateProject(d,te),onSuccess:()=>{n.invalidateQueries({queryKey:["project",d]}),n.invalidateQueries({queryKey:["projects"]}),a(!1),l(!1),r("Project updated","success")},onError:te=>{r(te.message,"error")}}),C=()=>{u(f?.notes||""),l(!0)},D=()=>{O.mutate({notes:c})},U=()=>{l(!1),u("")},[L,q]=w.useState(""),[P,W]=w.useState(1),[K,V]=w.useState(""),[Q,re]=w.useState(""),[J,z]=w.useState(""),[G,ne]=w.useState(!1),[ae,de]=w.useState(!1),[fe,ie]=w.useState(null),[Ae,me]=w.useState(""),[Ne,ye]=w.useState(1),[le,$e]=w.useState(""),[H,ee]=w.useState(""),[X,B]=w.useState(""),[I,ce]=w.useState({isOpen:!1,title:"",message:"",onConfirm:()=>{}}),Te=mt({mutationFn:te=>he.createBOMItem(d,te),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",d]}),n.invalidateQueries({queryKey:["project",d]}),q(""),W(1),V(""),re(""),z(""),ne(!1),r("Part added","success")},onError:te=>r(te.message,"error")}),Le=mt({mutationFn:({itemId:te,data:Me})=>he.updateBOMItem(d,te,Me),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",d]}),n.invalidateQueries({queryKey:["project",d]}),ie(null)},onError:te=>r(te.message,"error")}),Ee=mt({mutationFn:te=>he.deleteBOMItem(d,te),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",d]}),n.invalidateQueries({queryKey:["project",d]}),r("Part removed","success")},onError:te=>r(te.message,"error")}),$=te=>{te.preventDefault(),L.trim()&&Te.mutate({name:L.trim(),quantity_needed:P,unit_price:K?parseFloat(K):void 0,sourcing_url:Q.trim()||void 0,remarks:J.trim()||void 0})},j=te=>{const Me=te.is_complete?0:te.quantity_needed;Le.mutate({itemId:te.id,data:{quantity_acquired:Me}})},Y=(te,Me)=>{ce({isOpen:!0,title:"Delete Part",message:`Are you sure you want to delete "${Me}"?`,onConfirm:()=>{ce(Fe=>({...Fe,isOpen:!1})),Ee.mutate(te)}})},ge=te=>{ie(te),me(te.name),ye(te.quantity_needed),$e(te.unit_price?.toString()||""),ee(te.sourcing_url||""),B(te.remarks||"")},we=te=>{te.preventDefault(),!(!fe||!Ae.trim())&&Le.mutate({itemId:fe.id,data:{name:Ae.trim(),quantity_needed:Ne,unit_price:le?parseFloat(le):void 0,sourcing_url:H.trim()||void 0,remarks:X.trim()||void 0}})},ve=()=>{ie(null)},Ze=async()=>{try{const te=await fetch(`/api/v1/projects/${d}/export`);if(!te.ok)throw new Error("Export failed");const Me=await te.blob(),Fe=URL.createObjectURL(Me),ot=document.createElement("a");ot.href=Fe;const je=te.headers.get("Content-Disposition")?.match(/filename="(.+)"/);ot.download=je?.[1]||`${f?.name||"project"}_${new Date().toISOString().split("T")[0]}.zip`,ot.click(),URL.revokeObjectURL(Fe),r("Project exported","success")}catch(te){r(te.message,"error")}},Ie=mt({mutationFn:()=>he.createTemplateFromProject(d),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),r("Template created","success")},onError:te=>r(te.message,"error")}),qe=te=>wg(te,E,{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(dt,{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(Se,{variant:"secondary",className:"mt-4",onClick:()=>e("/projects"),children:"Back to Projects"})]});const Je=f.stats,Qe=Je?.progress_percent??0,oe=Je?.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(bs,{to:"/projects",className:"hover:text-white transition-colors",children:"Projects"}),s.jsx(Js,{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(fK,{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(_Ze,{status:f.status})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Se,{variant:"secondary",onClick:Ze,title:"Export project",children:[s.jsx(Hr,{className:"w-4 h-4 mr-2"}),"Export"]}),s.jsxs(Se,{onClick:()=>a(!0),children:[s.jsx(Gf,{className:"w-4 h-4 mr-2"}),"Edit"]})]})]}),(f.target_count||f.target_parts_count)&&s.jsx(St,{children:s.jsxs(Nt,{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:[Je?.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"]}),Je?.remaining_prints!=null&&Je.remaining_prints>0&&s.jsxs("span",{className:"text-xs text-bambu-gray/70",children:[Je.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:[Je?.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(oe,100)}%`,backgroundColor:oe>=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:[oe.toFixed(0),"% complete"]}),Je?.remaining_parts!=null&&Je.remaining_parts>0&&s.jsxs("span",{className:"text-xs text-bambu-gray/70",children:[Je.remaining_parts," remaining"]})]})]})]})}),Je&&s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsx(St,{children:s.jsx(Nt,{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(Jl,{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:[Je.total_archives," ",s.jsx("span",{className:"text-sm font-normal text-bambu-gray",children:"total"})]}),Je.failed_prints>0&&s.jsxs("p",{className:"text-sm text-status-error",children:[Je.failed_prints," failed"]}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:[Je.completed_prints," parts printed"]})]})]})})}),s.jsx(bq,{icon:Zn,label:"Print Time",value:yZe(Je.total_print_time_hours),color:"text-yellow-400"}),s.jsx(bq,{icon:qr,label:"Filament Used",value:vZe(Je.total_filament_grams),color:"text-purple-400"})]}),Je&&(Je.estimated_cost>0||f.budget)&&s.jsx(St,{children:s.jsxs(Nt,{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,Je.estimated_cost.toFixed(2)]})]}),Je.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:[Je.total_energy_kwh.toFixed(2)," kWh",Je.total_energy_cost>0&&s.jsxs("span",{className:"text-sm text-bambu-gray ml-1",children:["(",k,Je.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-Je.estimated_cost>=0?"text-bambu-green":"text-red-400"}`,children:[k,(f.budget-Je.estimated_cost).toFixed(2)]})]})]})]})]})}),f.children&&f.children.length>0&&s.jsx(St,{children:s.jsxs(Nt,{className:"p-4",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-3",children:[s.jsx(she,{className:"w-5 h-5"}),"Sub-projects (",f.children.length,")"]}),s.jsx("div",{className:"space-y-2",children:f.children.map(te=>s.jsxs(bs,{to:`/projects/${te.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:te.color||"#6b7280"}}),s.jsx("span",{className:"text-white",children:te.name}),s.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${te.status==="completed"?"bg-status-ok/20 text-status-ok":te.status==="archived"?"bg-bambu-gray/20 text-bambu-gray":"bg-blue-500/20 text-blue-400"}`,children:te.status})]}),te.progress_percent!==null&&s.jsxs("span",{className:"text-sm text-bambu-gray",children:[te.progress_percent.toFixed(0),"%"]})]},te.id))})]})}),f.parent_id&&f.parent_name&&s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(ul,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("span",{className:"text-bambu-gray",children:"Part of:"}),s.jsx(bs,{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(SZe,{priority:f.priority})]}),f.due_date&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(oi,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("span",{className:"text-sm text-white",children:MZe(f.due_date)}),Qj(f.due_date)&&s.jsxs("span",{className:`text-xs ${Qj(f.due_date).color}`,children:["(",Qj(f.due_date).label,")"]})]}),f.tags&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(vg,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("div",{className:"flex flex-wrap gap-1",children:f.tags.split(",").map((te,Me)=>s.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark-tertiary text-bambu-gray text-xs rounded",children:te.trim()},Me))})]})]}),s.jsx(St,{children:s.jsxs(Nt,{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(Za,{className:"w-5 h-5"}),"Notes"]}),o?s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Se,{variant:"secondary",size:"sm",onClick:U,disabled:O.isPending,children:[s.jsx(Vt,{className:"w-4 h-4 mr-1"}),"Cancel"]}),s.jsxs(Se,{size:"sm",onClick:D,disabled:O.isPending,children:[O.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin mr-1"}):s.jsx(_s,{className:"w-4 h-4 mr-1"}),"Save"]})]}):s.jsxs(Se,{variant:"secondary",size:"sm",onClick:C,children:[s.jsx(Gf,{className:"w-4 h-4 mr-1"}),"Edit"]})]}),o?s.jsx(gD,{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(St,{children:s.jsxs(Nt,{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(cl,{className:"w-5 h-5"}),"Files"]})}),s.jsxs("p",{className:"text-xs text-bambu-gray mb-3",children:[s.jsx(bs,{to:"/files",className:"text-bambu-green hover:underline",children:"Link folders from the File Manager"})," ","to this project for quick access."]}),T&&T.length>0?s.jsx("div",{className:"space-y-2",children:T.map(te=>s.jsxs(bs,{to:`/files?folder=${te.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(cl,{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:te.name}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[te.file_count," file",te.file_count!==1?"s":""]})]})]}),s.jsx(Js,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"})]},te.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(St,{children:s.jsxs(Nt,{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(NK,{className:"w-5 h-5"}),"Bill of Materials",Je&&Je.bom_total_items>0&&s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",Je.bom_completed_items,"/",Je.bom_total_items," acquired)"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[x&&x.some(te=>te.is_complete)&&s.jsx("button",{onClick:()=>de(!ae),className:`text-xs px-2 py-1 rounded transition-colors ${ae?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:ae?"Show all":"Hide done"}),!G&&s.jsxs(Se,{variant:"secondary",size:"sm",onClick:()=>ne(!0),children:[s.jsx(nr,{className:"w-4 h-4 mr-1"}),"Add Part"]})]})]}),G&&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:L,onChange:te=>q(te.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:P,onChange:te=>W(parseInt(te.target.value)||1),className:"w-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white focus:outline-none focus:border-bambu-green",min:"1",placeholder:"Qty"}),s.jsx("input",{type:"number",step:"0.01",value:K,onChange:te=>V(te.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:Q,onChange:te=>re(te.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:J,onChange:te=>z(te.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(Se,{type:"button",variant:"secondary",size:"sm",onClick:()=>ne(!1),children:"Cancel"}),s.jsx(Se,{type:"submit",size:"sm",disabled:!L.trim()||Te.isPending,children:Te.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):"Add Part"})]})]}),v?s.jsx("div",{className:"flex items-center justify-center py-4",children:s.jsx(dt,{className:"w-6 h-6 animate-spin text-bambu-green"})}):x&&x.length>0?s.jsxs("div",{className:"space-y-2",children:[x.filter(te=>!ae||!te.is_complete).map(te=>s.jsx("div",{className:`p-3 rounded-lg transition-colors ${te.is_complete?"bg-status-ok/10":"bg-bambu-dark"}`,children:fe?.id===te.id?s.jsxs("form",{onSubmit:we,className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[s.jsx("input",{type:"text",value:Ae,onChange:Me=>me(Me.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:Me=>ye(parseInt(Me.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:Me=>$e(Me.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:Me=>ee(Me.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"Sourcing URL (optional)"}),s.jsx("input",{type:"text",value:X,onChange:Me=>B(Me.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(Se,{type:"button",variant:"secondary",size:"sm",onClick:ve,children:"Cancel"}),s.jsx(Se,{type:"submit",size:"sm",disabled:!Ae.trim()||Le.isPending,children:Le.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):"Save"})]})]}):s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("button",{onClick:()=>j(te),disabled:Le.isPending,className:`w-5 h-5 mt-0.5 rounded border-2 flex items-center justify-center transition-colors flex-shrink-0 ${te.is_complete?"bg-status-ok border-status-ok text-white":"border-bambu-gray hover:border-bambu-green"}`,children:te.is_complete&&s.jsx(Un,{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 ${te.is_complete?"text-bambu-gray line-through":"text-white"}`,children:[te.name,s.jsxs("span",{className:"text-bambu-gray font-normal ml-2",children:["x",te.quantity_needed]})]}),te.unit_price!==null&&s.jsxs("span",{className:"text-xs text-bambu-green whitespace-nowrap",children:[k,(te.unit_price*te.quantity_needed).toFixed(2)]})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:()=>ge(te),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(la,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>Y(te.id,te.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(dn,{className:"w-4 h-4"})})]})]}),te.sourcing_url&&s.jsxs("a",{href:te.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:Me=>Me.stopPropagation(),children:[s.jsx(zr,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:(()=>{try{return new URL(te.sourcing_url).hostname.replace("www.","")}catch{return te.sourcing_url}})()})]}),te.remarks&&s.jsx("p",{className:"mt-1 text-xs text-bambu-gray/80 italic",children:te.remarks})]})]})},te.id)),x.some(te=>te.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((te,Me)=>te+(Me.unit_price||0)*Me.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(St,{children:s.jsxs(Nt,{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(P0,{className:"w-5 h-5"}),"Activity Timeline"]})}),M?s.jsx("div",{className:"flex items-center justify-center py-4",children:s.jsx(dt,{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((te,Me)=>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 ${te.event_type==="print_completed"?"bg-status-ok/20 text-status-ok":te.event_type==="print_failed"?"bg-status-error/20 text-status-error":te.event_type==="print_started"?"bg-yellow-500/20 text-yellow-400":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:[te.event_type==="print_completed"&&s.jsx(Un,{className:"w-4 h-4"}),te.event_type==="print_failed"&&s.jsx(ia,{className:"w-4 h-4"}),te.event_type==="print_started"&&s.jsx(qr,{className:"w-4 h-4"}),te.event_type==="queued"&&s.jsx(vP,{className:"w-4 h-4"}),te.event_type==="project_created"&&s.jsx(nr,{className:"w-4 h-4"})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm text-white",children:te.title}),te.description&&s.jsx("p",{className:"text-xs text-bambu-gray truncate",children:te.description}),s.jsx("p",{className:"text-xs text-bambu-gray/70",children:qe(te.timestamp)})]})]},Me))}):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(Se,{variant:"secondary",size:"sm",onClick:()=>Ie.mutate(),disabled:Ie.isPending,children:[Ie.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin mr-2"}):s.jsx(ll,{className:"w-4 h-4 mr-2"}),"Save as Template"]})}),Je&&(Je.queued_prints>0||Je.in_progress_prints>0)&&s.jsx(St,{children:s.jsxs(Nt,{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(vP,{className:"w-5 h-5"}),"Queue"]}),s.jsx(bs,{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:[Je.in_progress_prints>0&&s.jsxs("span",{className:"text-yellow-400",children:[Je.in_progress_prints," printing"]}),Je.queued_prints>0&&s.jsxs("span",{className:"text-bambu-gray",children:[Je.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(Jl,{className:"w-5 h-5"}),"Prints (",b?.length||0,")"]})}),y?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(dt,{className:"w-6 h-6 animate-spin text-bambu-green"})}):s.jsx(wZe,{archives:b||[]})]}),i&&s.jsx(Xie,{project:{...f,archive_count:Je?.total_archives||0,total_items:Je?.total_items||0,completed_count:Je?.completed_prints||0,failed_count:Je?.failed_prints||0,queue_count:Je?.queued_prints||0,progress_percent:Je?.progress_percent||null,archives:[]},onClose:()=>a(!1),onSave:te=>O.mutate(te),isLoading:O.isPending}),I.isOpen&&s.jsx(Hn,{title:I.title,message:I.message,confirmText:"Delete",variant:"danger",onConfirm:I.onConfirm,onCancel:()=>ce(te=>({...te,isOpen:!1}))})]})}function Yp(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 EZe(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 AZe({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(Se,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(Se,{type:"submit",disabled:!i.trim()||r,children:r?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):"Create"})]})]})]})})}function TZe({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(Se,{type:"button",variant:"secondary",onClick:n,children:"Cancel"}),s.jsx(Se,{type:"submit",disabled:!a.trim()||a.trim()===e||i,children:i?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):"Rename"})]})]})]})})}function CZe({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(cl,{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(Se,{type:"button",variant:"secondary",onClick:r,children:"Cancel"}),s.jsx(Se,{onClick:()=>i(o),disabled:a,children:a?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):"Move"})]})]})]})})}function kZe({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}=ut({queryKey:["projects"],queryFn:()=>he.getProjects()}),{data:u}=ut({queryKey:["archives-for-link"],queryFn:()=>he.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(Wl,{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(Vt,{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(pK,{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(es,{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(Af,{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(Se,{variant:"danger",onClick:f,disabled:r,children:[s.jsx(WD,{className:"w-4 h-4 mr-2"}),"Unlink"]}),s.jsxs("div",{className:`flex gap-2 ${m?"":"ml-auto"}`,children:[s.jsx(Se,{variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(Se,{onClick:d,disabled:!o||r,children:r?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):"Link"})]})]})]})})}function jZe({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=D=>{D.preventDefault(),o(!0)},y=D=>{D.preventDefault(),o(!1)},x=D=>{D.preventDefault(),o(!1);const U=Array.from(D.dataTransfer.files);S(U)},v=D=>{D.target.files&&S(Array.from(D.target.files))},S=D=>{const U=D.map(L=>({file:L,status:"pending",isZip:L.name.toLowerCase().endsWith(".zip")}));i(L=>[...L,...U])},M=D=>{i(U=>U.filter((L,q)=>q!==D))},A=r.some(D=>D.isZip&&D.status==="pending"),T=async()=>{if(r.length!==0){c(!0);for(let D=0;D<r.length;D++)if(r[D].status==="pending"){i(U=>U.map((L,q)=>q===D?{...L,status:"uploading"}:L));try{if(r[D].isZip){const U=await he.extractZipFile(r[D].file,t,u,f);i(L=>L.map((q,P)=>P===D?{...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 he.uploadLibraryFile(r[D].file,t),i(U=>U.map((L,q)=>q===D?{...L,status:"success"}:L))}catch(U){i(L=>L.map((q,P)=>P===D?{...q,status:"error",error:U instanceof Error?U.message:"Upload failed"}:q))}}c(!1),n(),e()}},k=r.filter(D=>D.status==="pending").length,E=r.filter(D=>D.status==="success").length,O=r.filter(D=>D.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(Vt,{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(pi,{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}),A&&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(es,{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:D=>d(D.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:D=>m(D.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((D,U)=>s.jsxs("div",{className:"flex items-center gap-3 p-2 bg-bambu-dark rounded-lg",children:[D.isZip?s.jsx(es,{className:"w-4 h-4 text-blue-400 flex-shrink-0"}):s.jsx(aN,{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:D.file.name}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[(D.file.size/1024/1024).toFixed(2)," MB",D.isZip&&D.status==="pending"&&s.jsx("span",{className:"text-blue-400 ml-2",children:"• Will be extracted"}),D.extractedCount!==void 0&&s.jsxs("span",{className:"text-green-400 ml-2",children:["• ",D.extractedCount," files extracted"]})]})]}),D.status==="pending"&&s.jsx("button",{onClick:()=>M(U),className:"p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Vt,{className:"w-4 h-4 text-bambu-gray"})}),D.status==="uploading"&&s.jsx(dt,{className:"w-4 h-4 text-bambu-green animate-spin"}),D.status==="success"&&s.jsx(Un,{className:"w-4 h-4 text-green-500"}),D.status==="error"&&s.jsx("span",{title:D.error,children:s.jsx(ia,{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: ",E," succeeded",O>0&&s.jsxs("span",{className:"text-red-400",children:[", ",O," failed"]})]})})]}),s.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex justify-end gap-2",children:[s.jsx(Se,{variant:"secondary",onClick:e,children:C?"Close":"Cancel"}),!C&&s.jsx(Se,{onClick:T,disabled:k===0||l,children:l?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 mr-2 animate-spin"}),"Uploading..."]}):s.jsxs(s.Fragment,{children:[s.jsx(pi,{className:"w-4 h-4 mr-2"}),"Upload ",k>0?`(${k})`:""]})})]})]})})}function Yie({folder:t,selectedFolderId:e,onSelect:n,onDelete:r,onLink:i,onRename:a,depth:o=0,wrapNames:l=!1}){const[c,u]=w.useState(!0),[d,f]=w.useState(!1),m=t.children.length>0,p=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:[m?s.jsx("button",{onClick:b=>{b.stopPropagation(),u(!c)},className:"p-0.5 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Js,{className:`w-3.5 h-3.5 transition-transform ${c?"rotate-90":""}`})}):s.jsx("div",{className:"w-4.5"}),s.jsx(cl,{className:"w-4 h-4 text-bambu-green flex-shrink-0"}),s.jsx("span",{className:`text-sm flex-1 min-w-0 ${l?"break-all":"truncate"}`,title:t.name,children:t.name}),p&&s.jsxs("button",{onClick:b=>{b.stopPropagation(),i(t)},className:"flex-shrink-0 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(Wl,{className:"w-3 h-3"}),t.project_name?s.jsx(pK,{className:"w-3 h-3"}):s.jsx(es,{className:"w-3 h-3"})]}),t.file_count>0&&s.jsx("span",{className:"flex-shrink-0 text-xs text-bambu-gray",children:t.file_count}),!p&&s.jsx("button",{onClick:b=>{b.stopPropagation(),i(t)},className:"flex-shrink-0 p-1 rounded hover:bg-bambu-dark-tertiary",title:"Link to project or archive",children:s.jsx(Wl,{className:"w-3.5 h-3.5 text-bambu-gray hover:text-bambu-green"})}),s.jsx("div",{className:`flex-shrink-0 flex items-center gap-0.5 transition-opacity ${l?"":"opacity-0 group-hover:opacity-100"}`,onClick:b=>b.stopPropagation(),children:s.jsxs("div",{className:"relative",children:[s.jsx("button",{onClick:()=>f(!d),className:"p-1 rounded hover:bg-bambu-dark-tertiary",children:s.jsx(zd,{className:"w-3.5 h-3.5 text-bambu-gray"})}),d&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>f(!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),f(!1)},children:[s.jsx(la,{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),f(!1)},children:[s.jsx(Wl,{className:"w-3.5 h-3.5"}),p?"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),f(!1)},children:[s.jsx(dn,{className:"w-3.5 h-3.5"}),"Delete"]})]})]})]})})]}),m&&c&&s.jsx("div",{children:t.children.map(b=>s.jsx(Yie,{folder:b,selectedFolderId:e,onSelect:n,onDelete:r,onLink:i,onRename:a,depth:o+1,wrapNames:l},b.id))})]})}function MD(t){const e=t.toLowerCase();return e.endsWith(".gcode")||e.includes(".gcode.")}function PZe({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:he.getLibraryFileThumbnailUrl(t.id),alt:t.filename,className:"w-full h-full object-cover"}):s.jsx(Af,{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:Yp(t.file_size)}),t.print_time_seconds&&s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(Zn,{className:"w-3 h-3"}),EZe(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(zd,{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&&MD(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(qr,{className:"w-3.5 h-3.5"}),"Print"]}),a&&MD(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(Zn,{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(Hr,{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(la,{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(dn,{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 RZe(){const t=on(),{showToast:e}=qn(),[n]=Xq(),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,A]=w.useState(null),[T,k]=w.useState(null),[E,O]=w.useState(null),[C,D]=w.useState(()=>localStorage.getItem("library-view-mode")||"grid"),[U,L]=w.useState(()=>localStorage.getItem("library-wrap-folders")==="true"),[q,P]=w.useState(()=>{const te=localStorage.getItem("library-sidebar-width");return te?parseInt(te,10):256}),[W,K]=w.useState(!1),V=w.useRef(null);w.useEffect(()=>{if(!W)return;document.body.style.userSelect="none",document.body.style.cursor="col-resize";const te=Fe=>{if(!V.current)return;const ot=V.current.parentElement?.getBoundingClientRect();if(!ot)return;const se=Fe.clientX-ot.left,je=Math.min(500,Math.max(200,se));P(je)},Me=()=>{K(!1),document.body.style.userSelect="",document.body.style.cursor="",localStorage.setItem("library-sidebar-width",String(q))};return document.addEventListener("mousemove",te),document.addEventListener("mouseup",Me),()=>{document.removeEventListener("mousemove",te),document.removeEventListener("mouseup",Me),document.body.style.userSelect="",document.body.style.cursor=""}},[W,q]);const[Q,re]=w.useState(""),[J,z]=w.useState("all"),[G,ne]=w.useState("date"),[ae,de]=w.useState("desc");w.useEffect(()=>{const te=n.get("folder");if(te){const Me=parseInt(te,10);o(Me)}},[n]);const{data:fe}=ut({queryKey:["settings"],queryFn:()=>he.getSettings()}),{data:ie,isLoading:Ae}=ut({queryKey:["library-folders"],queryFn:()=>he.getLibraryFolders()}),{data:me,isLoading:Ne}=ut({queryKey:["library-files",a],queryFn:()=>he.getLibraryFiles(a,a===null)}),{data:ye}=ut({queryKey:["library-stats"],queryFn:()=>he.getLibraryStats()}),le=w.useMemo(()=>{if(!me)return[];const te=new Set(me.map(Me=>Me.file_type));return Array.from(te).sort()},[me]),$e=w.useMemo(()=>{if(!me)return[];let te=[...me];if(Q.trim()){const Me=Q.toLowerCase();te=te.filter(Fe=>Fe.filename.toLowerCase().includes(Me)||Fe.print_name&&Fe.print_name.toLowerCase().includes(Me))}return J!=="all"&&(te=te.filter(Me=>Me.file_type===J)),te.sort((Me,Fe)=>{let ot=0;switch(G){case"name":ot=(Me.print_name||Me.filename).localeCompare(Fe.print_name||Fe.filename);break;case"date":ot=new Date(Me.created_at).getTime()-new Date(Fe.created_at).getTime();break;case"size":ot=Me.file_size-Fe.file_size;break;case"type":ot=Me.file_type.localeCompare(Fe.file_type);break;case"prints":ot=Me.print_count-Fe.print_count;break}return ae==="asc"?ot:-ot}),te},[me,Q,J,G,ae]),H=w.useMemo(()=>{if(!ye||!fe)return!1;const te=(fe.library_disk_warning_gb||5)*1024*1024*1024;return ye.disk_free_bytes<te},[ye,fe]),ee=mt({mutationFn:te=>he.createLibraryFolder(te),onSuccess:()=>{t.invalidateQueries({queryKey:["library-folders"]}),d(!1),e("Folder created","success")},onError:te=>e(te.message,"error")}),X=mt({mutationFn:te=>he.deleteLibraryFolder(te),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:te=>{S(null),e(te.message,"error")}}),B=mt({mutationFn:te=>he.deleteLibraryFile(te),onSuccess:()=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-stats"]}),c(te=>te.filter(Me=>Me!==v?.id)),S(null),e("File deleted","success")},onError:te=>{S(null),e(te.message,"error")}}),I=mt({mutationFn:te=>he.bulkDeleteLibrary(te,[]),onSuccess:(te,Me)=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-stats"]}),e(`Deleted ${Me.length} files`,"success"),c([]),S(null)},onError:te=>{S(null),e(te.message,"error")}}),ce=mt({mutationFn:({fileIds:te,folderId:Me})=>he.moveLibraryFiles(te,Me),onSuccess:()=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-folders"]}),c([]),m(!1),e("Files moved","success")},onError:te=>e(te.message,"error")}),Te=mt({mutationFn:({id:te,data:Me})=>he.updateLibraryFolder(te,Me),onSuccess:(te,Me)=>{t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["project-folders"]}),t.invalidateQueries({queryKey:["archive-folders"]}),x(null);const Fe=Me.data.project_id===0&&Me.data.archive_id===0;e(Fe?"Folder unlinked":"Folder linked","success")},onError:te=>e(te.message,"error")}),Le=mt({mutationFn:te=>he.addLibraryFilesToQueue(te),onSuccess:te=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["queue"]}),t.invalidateQueries({queryKey:["archives"]}),c([]),te.added.length>0&&te.errors.length===0?e(`Added ${te.added.length} file${te.added.length>1?"s":""} to queue`,"success"):te.added.length>0&&te.errors.length>0?e(`Added ${te.added.length} file${te.added.length>1?"s":""}, ${te.errors.length} failed`,"success"):e(`Failed to add files: ${te.errors[0]?.error||"Unknown error"}`,"error")},onError:te=>e(te.message,"error")}),Ee=mt({mutationFn:({id:te,filename:Me})=>he.updateLibraryFile(te,{filename:Me}),onSuccess:()=>{t.invalidateQueries({queryKey:["library-files"]}),O(null),e("File renamed","success")},onError:te=>{O(null),e(te.message,"error")}}),$=mt({mutationFn:({id:te,name:Me})=>he.updateLibraryFolder(te,{name:Me}),onSuccess:()=>{t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-files"]}),O(null),e("Folder renamed","success")},onError:te=>{O(null),e(te.message,"error")}}),j=w.useCallback(te=>{const Me=te.toLowerCase();return Me.endsWith(".gcode")||Me.includes(".gcode.")},[]),Y=w.useMemo(()=>me?me.filter(te=>l.includes(te.id)&&j(te.filename)):[],[me,l,j]),ge=w.useCallback(te=>{c(Me=>Me.includes(te)?Me.filter(Fe=>Fe!==te):[...Me,te])},[]),we=w.useCallback(()=>{$e.length>0&&c($e.map(te=>te.id))},[$e]),ve=w.useCallback(()=>{c([])},[]),Ze=()=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-stats"]})},Ie=te=>{window.open(he.getLibraryFileDownloadUrl(te),"_blank")},qe=()=>{v&&(v.type==="file"?B.mutate(v.id):v.type==="folder"?X.mutate(v.id):v.type==="bulk"&&I.mutate(l))},Je=X.isPending||B.isPending||I.isPending,Qe=te=>{D(te),localStorage.setItem("library-view-mode",te)},oe=Ae||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(cl,{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:()=>Qe("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(uN,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>Qe("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(dN,{className:"w-4 h-4"})})]}),s.jsxs(Se,{variant:"secondary",onClick:()=>d(!0),children:[s.jsx(ihe,{className:"w-4 h-4 mr-2"}),"New Folder"]}),s.jsxs(Se,{onClick:()=>b(!0),children:[s.jsx(pi,{className:"w-4 h-4 mr-2"}),"Upload"]})]})]}),H&&ye&&fe&&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(kn,{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 ",Yp(ye.disk_free_bytes)," free of ",Yp(ye.disk_total_bytes)," total. Threshold is set to ",fe.library_disk_warning_gb," GB in settings."]})]})]}),ye&&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(aN,{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:ye.total_files})]}),s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(cl,{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:ye.total_folders})]}),s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(lN,{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:Yp(ye.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 ${H?"text-amber-500":"text-white"}`,children:Yp(ye.disk_free_bytes)})]})]}),s.jsxs("div",{className:"flex-1 flex gap-6 min-h-0",children:[s.jsxs("div",{ref:V,className:"flex-shrink-0 bg-bambu-card rounded-lg border border-bambu-dark-tertiary overflow-hidden flex flex-col relative",style:{width:`${q}px`},children:[s.jsx("div",{className:`absolute right-0 top-0 bottom-0 w-1.5 cursor-col-resize z-10 group/resize flex items-center justify-center transition-colors ${W?"bg-bambu-green":"hover:bg-bambu-green/50"}`,onMouseDown:te=>{te.preventDefault(),K(!0)},onDoubleClick:()=>{P(256),localStorage.setItem("library-sidebar-width","256")},title:"Drag to resize, double-click to reset",children:s.jsxs("div",{className:`flex flex-col gap-1 opacity-0 group-hover/resize:opacity-100 transition-opacity ${W?"opacity-100":""}`,children:[s.jsx("div",{className:"w-0.5 h-0.5 rounded-full bg-white/70"}),s.jsx("div",{className:"w-0.5 h-0.5 rounded-full bg-white/70"}),s.jsx("div",{className:"w-0.5 h-0.5 rounded-full bg-white/70"})]})}),s.jsxs("div",{className:"p-3 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[s.jsx("h2",{className:"text-sm font-medium text-white",children:"Folders"}),s.jsx("button",{onClick:()=>{const te=!U;L(te),localStorage.setItem("library-wrap-folders",String(te))},className:`text-xs px-1.5 py-0.5 rounded transition-colors ${U?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:text-white hover:bg-bambu-dark"}`,title:U?"Disable text wrapping":"Enable text wrapping",children:"Wrap"})]}),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(Af,{className:"w-4 h-4"}),s.jsx("span",{className:"text-sm",children:"All Files"})]}),ie?.map(te=>s.jsx(Yie,{folder:te,selectedFolderId:a,onSelect:o,onDelete:Me=>S({type:"folder",id:Me}),onLink:x,onRename:Me=>O({type:"folder",id:Me.id,name:Me.name}),wrapNames:U},te.id))]})]}),s.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[me&&me.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(Ea,{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:Q,onChange:te=>re(te.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(sN,{className:"w-4 h-4 text-bambu-gray"}),s.jsxs("select",{value:J,onChange:te=>z(te.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"}),le.map(te=>s.jsx("option",{value:te,children:te.toUpperCase()},te))]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("select",{value:G,onChange:te=>ne(te.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:()=>de(te=>te==="asc"?"desc":"asc"),className:"p-1.5 rounded bg-bambu-dark border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",title:ae==="asc"?"Ascending":"Descending",children:ae==="asc"?s.jsx(Lue,{className:"w-4 h-4 text-white"}):s.jsx(kue,{className:"w-4 h-4 text-white"})})]}),(Q||J!=="all")&&s.jsxs("span",{className:"text-sm text-bambu-gray",children:[$e.length," of ",me.length," files"]})]}),$e.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===$e.length&&l.length>0?s.jsxs(Se,{variant:"secondary",size:"sm",onClick:ve,children:[s.jsx(Io,{className:"w-4 h-4 mr-1"}),"Deselect All"]}):s.jsxs(Se,{variant:"secondary",size:"sm",onClick:we,children:[s.jsx(Lo,{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"}),Y.length===1&&s.jsxs(Se,{variant:"primary",size:"sm",onClick:()=>k(Y[0]),children:[s.jsx(Oo,{className:"w-4 h-4 mr-1"}),"Print"]}),Y.length>0&&s.jsxs(Se,{variant:Y.length===1?"secondary":"primary",size:"sm",onClick:()=>Le.mutate(Y.map(te=>te.id)),disabled:Le.isPending,children:[s.jsx(Zn,{className:"w-4 h-4 mr-1"}),Le.isPending?"Adding...":`Add to Queue${Y.length<l.length?` (${Y.length})`:""}`]}),s.jsxs(Se,{variant:"secondary",size:"sm",onClick:()=>m(!0),children:[s.jsx(hfe,{className:"w-4 h-4 mr-1"}),"Move"]}),s.jsxs(Se,{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(dn,{className:"w-4 h-4 mr-1"}),"Delete"]}),s.jsx(Se,{variant:"secondary",size:"sm",onClick:ve,children:"Clear"})]})]}),oe?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(dt,{className:"w-8 h-8 animate-spin text-bambu-green"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Loading 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(Af,{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(Se,{onClick:()=>b(!0),children:[s.jsx(nr,{className:"w-4 h-4 mr-2"}),"Upload Files"]})]}):$e.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(Ea,{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(Se,{variant:"secondary",onClick:()=>{re(""),z("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:$e.map(te=>s.jsx(PZe,{file:te,isSelected:l.includes(te.id),onSelect:ge,onDelete:Me=>S({type:"file",id:Me}),onDownload:Ie,onAddToQueue:Me=>Le.mutate([Me]),onPrint:A,onRename:Me=>O({type:"file",id:Me.id,name:Me.filename})},te.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",{})]}),$e.map(te=>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(te.id)?"bg-bambu-green/10":""}`,onClick:()=>ge(te.id),children:[s.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center ${l.includes(te.id)?"bg-bambu-green border-bambu-green":"border-bambu-gray/50"}`,children:l.includes(te.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:te.thumbnail_path?s.jsx("img",{src:he.getLibraryFileThumbnailUrl(te.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(Af,{className:"w-5 h-5 text-bambu-gray/50"})})}),te.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:he.getLibraryFileThumbnailUrl(te.id),alt:te.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:te.print_name||te.filename})})]}),s.jsx("div",{children:s.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${te.file_type==="3mf"?"bg-bambu-green/20 text-bambu-green":te.file_type==="gcode"?"bg-blue-500/20 text-blue-400":te.file_type==="stl"?"bg-purple-500/20 text-purple-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:te.file_type.toUpperCase()})}),s.jsx("div",{className:"text-sm text-bambu-gray",children:Yp(te.file_size)}),s.jsx("div",{className:"text-sm text-bambu-gray",children:te.print_count>0?`${te.print_count}x`:"-"}),s.jsxs("div",{className:"flex items-center gap-1",onClick:Me=>Me.stopPropagation(),children:[MD(te.filename)&&s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>A(te),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green transition-colors",title:"Print",children:s.jsx(qr,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>Le.mutate([te.id]),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",title:"Add to Queue",disabled:Le.isPending,children:s.jsx(Zn,{className:"w-4 h-4"})})]}),s.jsx("button",{onClick:()=>Ie(te.id),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",title:"Download",children:s.jsx(Hr,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>O({type:"file",id:te.id,name:te.filename}),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",title:"Rename",children:s.jsx(la,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>S({type:"file",id:te.id}),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors",title:"Delete",children:s.jsx(dn,{className:"w-4 h-4"})})]})]},te.id))]})})]})]}),u&&s.jsx(AZe,{parentId:a,onClose:()=>d(!1),onSave:te=>ee.mutate(te),isLoading:ee.isPending}),f&&ie&&s.jsx(CZe,{folders:ie,selectedFiles:l,currentFolderId:a,onClose:()=>m(!1),onMove:te=>ce.mutate({fileIds:l,folderId:te}),isLoading:ce.isPending}),p&&s.jsx(jZe,{folderId:a,onClose:()=>b(!1),onUploadComplete:Ze}),y&&s.jsx(kZe,{folder:y,onClose:()=>x(null),onLink:te=>Te.mutate({id:y.id,data:te}),isLoading:Te.isPending}),v&&s.jsx(Hn,{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:Je,loadingText:"Deleting...",onConfirm:qe,onCancel:()=>S(null)}),M&&s.jsx(ch,{mode:"reprint",libraryFileId:M.id,archiveName:M.print_name||M.filename,onClose:()=>A(null),onSuccess:()=>{A(null),t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["archives"]})}}),T&&s.jsx(ch,{mode:"reprint",libraryFileId:T.id,archiveName:T.print_name||T.filename,onClose:()=>k(null),onSuccess:()=>{k(null),c([]),t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["archives"]})}}),E&&s.jsx(TZe,{type:E.type,currentName:E.name,onClose:()=>O(null),onSave:te=>{E.type==="file"?Ee.mutate({id:E.id,filename:te}):$.mutate({id:E.id,name:te})},isLoading:Ee.isPending||$.isPending})]})}const Jj=5,DZe=2e3,OZe=3e4,LZe=5e3;function IZe(){const{printerId:t}=CD(),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),[A,T]=w.useState(1),[k,E]=w.useState({x:0,y:0}),[O,C]=w.useState(!1),[D,U]=w.useState({x:0,y:0}),[L,q]=w.useState(null),[P,W]=w.useState(null),K=w.useRef(null),V=w.useRef(null),Q=w.useRef(null),re=w.useRef(null),J=w.useRef(null),{data:z}=ut({queryKey:["printer",e],queryFn:()=>he.getPrinter(e),enabled:e>0});w.useEffect(()=>(z&&(document.title=`${z.name} - Camera`),()=>{document.title="Bambuddy"}),[z]);const G=w.useRef(!1);w.useEffect(()=>{const Y=`/api/v1/printers/${e}/camera/stop`;G.current=!1;const ge=()=>{e>0&&!G.current&&(G.current=!0,navigator.sendBeacon(Y))},we=()=>{ge()};window.addEventListener("beforeunload",we);const ve=K.current;return()=>{window.removeEventListener("beforeunload",we),ve&&(ve.src=""),ge()}},[e]),w.useEffect(()=>{if(o&&!d){const ge=setTimeout(()=>{l(!1)},n==="stream"?3e3:2e4);return()=>clearTimeout(ge)}},[n,o,c,d]),w.useEffect(()=>{const Y=()=>{const ge=!!document.fullscreenElement;p(ge),T(1),E({x:0,y:0}),n==="stream"&&!d&&(K.current&&(K.current.src=""),setTimeout(()=>{l(!0),u(Date.now())},200))};return document.addEventListener("fullscreenchange",Y),()=>document.removeEventListener("fullscreenchange",Y)},[n,d]),w.useEffect(()=>{let Y;const ge=()=>{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",ge),()=>{clearTimeout(Y),window.removeEventListener("resize",ge)}},[]),w.useEffect(()=>()=>{Q.current&&clearTimeout(Q.current),re.current&&clearInterval(re.current),J.current&&clearInterval(J.current)},[]);const ne=w.useCallback(()=>{if(b>=Jj){v(!1),a(!0);return}const Y=Math.min(DZe*Math.pow(2,b),OZe);v(!0),M(Math.ceil(Y/1e3)),re.current=setInterval(()=>{M(ge=>ge<=1?(re.current&&clearInterval(re.current),0):ge-1)},1e3),Q.current=setTimeout(()=>{y(ge=>ge+1),v(!1),l(!0),a(!1),K.current&&(K.current.src=""),u(Date.now())},Y)},[b]);w.useEffect(()=>{if(n!=="stream"||o||x||d){J.current&&(clearInterval(J.current),J.current=null);return}return J.current=setInterval(async()=>{try{const Y=await fetch(`/api/v1/printers/${e}/camera/status`);if(Y.ok){const ge=await Y.json();(ge.stalled||!ge.active&&!i)&&(console.log(`Stream issue detected: stalled=${ge.stalled}, active=${ge.active}, reconnecting...`),J.current&&(clearInterval(J.current),J.current=null),l(!1),ne())}}catch{}},LZe),()=>{J.current&&(clearInterval(J.current),J.current=null)}},[n,o,i,x,d,e,ne]);const ae=()=>{l(!1),n==="stream"&&b<Jj?ne():a(!0)},de=()=>{if(l(!1),a(!1),y(0),v(!1),Q.current&&clearTimeout(Q.current),re.current&&clearInterval(re.current),K.current&&!localStorage.getItem("cameraWindowState")){const Y=K.current,ge=Y.naturalWidth,we=Y.naturalHeight;if(ge>0&&we>0){const Ie=window.outerWidth-window.innerWidth,qe=window.outerHeight-window.innerHeight,Je=ge+16+Ie,Qe=we+45+16+qe;try{window.resizeTo(Je,Qe)}catch{}}}},fe=()=>{e>0&&fetch(`/api/v1/printers/${e}/camera/stop`).catch(()=>{})},ie=Y=>{n===Y||d||(f(!0),l(!0),a(!1),y(0),v(!1),T(1),E({x:0,y:0}),Q.current&&clearTimeout(Q.current),re.current&&clearInterval(re.current),K.current&&(K.current.src=""),n==="stream"&&fe(),setTimeout(()=>{r(Y),u(Date.now()),f(!1)},100))},Ae=()=>{d||(f(!0),l(!0),a(!1),y(0),v(!1),Q.current&&clearTimeout(Q.current),re.current&&clearInterval(re.current),K.current&&(K.current.src=""),n==="stream"&&fe(),setTimeout(()=>{u(Date.now()),f(!1)},100))},me=()=>{V.current&&(document.fullscreenElement?document.exitFullscreen():V.current.requestFullscreen())},Ne=()=>{T(Y=>Math.min(Y+.5,4))},ye=()=>{T(Y=>{const ge=Math.max(Y-.5,1);return ge===1&&E({x:0,y:0}),ge})},le=Y=>{Y.preventDefault(),Y.deltaY<0?Ne():ye()},$e=Y=>{A>1&&(Y.preventDefault(),C(!0),U({x:Y.clientX-k.x,y:Y.clientY-k.y}))},H=w.useCallback(()=>{if(!V.current)return{x:300,y:200};const Y=V.current.getBoundingClientRect(),ge=Y.width*(A-1)/2,we=Y.height*(A-1)/2;return{x:Math.max(50,ge),y:Math.max(50,we)}},[A]),ee=Y=>{if(O&&A>1){const ge=Y.clientX-D.x,we=Y.clientY-D.y,ve=H();E({x:Math.max(-ve.x,Math.min(ve.x,ge)),y:Math.max(-ve.y,Math.min(ve.y,we))})}},X=()=>{C(!1)},B=Y=>{if(Y.length<2)return 0;const ge=Y[0].clientX-Y[1].clientX,we=Y[0].clientY-Y[1].clientY;return Math.sqrt(ge*ge+we*we)},I=Y=>Y.length<2?{x:Y[0].clientX,y:Y[0].clientY}:{x:(Y[0].clientX+Y[1].clientX)/2,y:(Y[0].clientY+Y[1].clientY)/2},ce=Y=>{Y.touches.length===2?(Y.preventDefault(),q(B(Y.touches)),W(I(Y.touches))):Y.touches.length===1&&A>1&&(Y.preventDefault(),C(!0),U({x:Y.touches[0].clientX-k.x,y:Y.touches[0].clientY-k.y}))},Te=Y=>{if(Y.touches.length===2&&L!==null){Y.preventDefault();const ge=B(Y.touches),we=ge/L;T(Ze=>{const Ie=Math.max(1,Math.min(4,Ze*we));return Ie===1&&E({x:0,y:0}),Ie}),q(ge);const ve=I(Y.touches);if(P){const Ze=H();E(Ie=>({x:Math.max(-Ze.x,Math.min(Ze.x,Ie.x+(ve.x-P.x))),y:Math.max(-Ze.y,Math.min(Ze.y,Ie.y+(ve.y-P.y)))}))}W(ve)}else if(Y.touches.length===1&&O&&A>1){Y.preventDefault();const ge=Y.touches[0].clientX-D.x,we=Y.touches[0].clientY-D.y,ve=H();E({x:Math.max(-ve.x,Math.min(ve.x,ge)),y:Math.max(-ve.y,Math.min(ve.y,we))})}},Le=Y=>{Y.touches.length<2&&(q(null),W(null)),Y.touches.length===0&&C(!1)},Ee=()=>{T(1),E({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}`,j=o||d||x;return e?s.jsxs("div",{ref:V,className:"min-h-screen bg-black flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary",children:[s.jsxs("h1",{className:"text-sm font-medium text-white flex items-center gap-2",children:[s.jsx(Hf,{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:()=>ie("stream"),disabled:j,className:`px-3 py-1 text-xs rounded transition-colors ${n==="stream"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:"Live"}),s.jsx("button",{onClick:()=>ie("snapshot"),disabled:j,className:`px-3 py-1 text-xs rounded transition-colors ${n==="snapshot"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:"Snapshot"})]}),s.jsx("button",{onClick:Ae,disabled:j,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:n==="stream"?"Restart stream":"Refresh snapshot",children:s.jsx(xr,{className:`w-4 h-4 text-bambu-gray ${j?"animate-spin":""}`})}),s.jsx("button",{onClick:me,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded",title:m?"Exit fullscreen":"Fullscreen",children:m?s.jsx(SK,{className:"w-4 h-4 text-bambu-gray"}):s.jsx(efe,{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:ee,onMouseUp:X,onMouseLeave:X,onTouchStart:ce,onTouchMove:Te,onTouchEnd:Le,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(xr,{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(ex,{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,"/",Jj,")"]}),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(kn,{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:K,src:$,alt:"Camera stream",className:"max-w-full max-h-full object-contain select-none",style:{transform:`scale(${A}) translate(${k.x/A}px, ${k.y/A}px)`,cursor:A>1?O?"grabbing":"grab":"default"},onError:$?ae:void 0,onLoad:$?de:void 0,onMouseDown:$e,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:ye,disabled:A<=1,className:"p-1.5 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom out",children:s.jsx(XD,{className:"w-4 h-4 text-white"})}),s.jsxs("button",{onClick:Ee,className:"px-2 py-1 text-sm text-white hover:bg-white/10 rounded min-w-[48px]",title:"Reset zoom",children:[Math.round(A*100),"%"]}),s.jsx("button",{onClick:Ne,disabled:A>=4,className:"p-1.5 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom in",children:s.jsx(KD,{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 FZe(){const{id:t}=CD(),{mode:e}=hh(),{data:n,isLoading:r,error:i}=ut({queryKey:["external-link",t],queryFn:()=>he.getExternalLink(Number(t)),enabled:!!t});return r?s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx(dt,{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(kn,{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 yq=["DEBUG","INFO","WARNING","ERROR"],eP={DEBUG:"text-gray-400",INFO:"text-blue-400",WARNING:"text-yellow-400",ERROR:"text-red-400"},UZe={DEBUG:nN,INFO:Ql,WARNING:kn,ERROR:oa};function zZe(){const t=on(),[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}=ut({queryKey:["application-logs",l,a],queryFn:()=>ag.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=mt({mutationFn:()=>ag.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=E=>{i(O=>{const C=new Set(O);return C.has(E)?C.delete(E):C.add(E),C})},M=E=>{const O=E.split(" ");return O.length>=2?O[1]:E},A=w.useMemo(()=>b?.entries??[],[b?.entries]),T=w.useMemo(()=>[...A].reverse(),[A]),k=({level:E})=>{const O=UZe[E]||Ql;return s.jsx(O,{className:`w-3.5 h-3.5 ${eP[E]||"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(nN,{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(pu,{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:E=>{E.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(Io,{className:"w-4 h-4"}),"Stop"]}):s.jsxs("button",{onClick:E=>{E.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(Oo,{className:"w-4 h-4"}),"Start"]}),s.jsxs("button",{onClick:()=>v.mutate(),disabled:v.isPending||A.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(dn,{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(xr,{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:E=>n(E.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(Ea,{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:E=>o(E.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(Vt,{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"}),yq.map((E,O)=>s.jsx("button",{onClick:()=>c(E),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${O===yq.length-1?"rounded-r":""} ${l===E?`${eP[E]} bg-bambu-dark-tertiary`:"text-bambu-gray hover:text-white"}`,children:E},E))]})]})]}),s.jsx("div",{ref:p,className:"overflow-auto font-mono text-xs bg-black min-h-[300px] max-h-[500px]",children:A.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:T.map((E,O)=>{const C=r.has(O),D=E.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:()=>D&&S(O),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(E.timestamp)}),s.jsx("span",{className:"shrink-0",children:s.jsx(k,{level:E.level})}),s.jsxs("span",{className:"text-purple-400/80 shrink-0 max-w-[200px] truncate",title:E.logger_name,children:["[",E.logger_name,"]"]}),s.jsx("span",{className:`flex-1 ${eP[E.level]||"text-white/80"} ${!C&&D?"truncate":""}`,children:C?s.jsx("pre",{className:"whitespace-pre-wrap break-all",children:E.message}):E.message.split(`
- `)[0]}),D&&s.jsx("span",{className:"text-bambu-gray/50 shrink-0",children:C?s.jsx(pu,{className:"w-3.5 h-3.5"}):s.jsx(Oi,{className:"w-3.5 h-3.5"})})]})},O)})})}),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 BZe(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 ti({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 vq({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 xd({title:t,icon:e,children:n}){return s.jsxs(St,{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 $Ze(){const{t}=Xg(),e=on(),[n,r]=w.useState(null),[i,a]=w.useState(!1),[o,l]=w.useState(!1),{data:c,isLoading:u,refetch:d,isFetching:f}=ut({queryKey:["systemInfo"],queryFn:he.getSystemInfo,refetchInterval:3e4}),{data:m}=ut({queryKey:["debugLogging"],queryFn:ag.getDebugLoggingState,staleTime:10*1e3,refetchInterval:10*1e3}),{data:p}=ut({queryKey:["settings"],queryFn:he.getSettings}),{data:b}=ut({queryKey:["library-stats"],queryFn:he.getLibraryStats}),y=p?.time_format||"system",x=async()=>{l(!0);try{const A=await ag.setDebugLogging(!m?.enabled);e.setQueryData(["debugLogging"],A)}catch(A){console.error("Failed to toggle debug logging:",A)}finally{l(!1)}},v=async()=>{r(null),a(!0);try{await ag.downloadSupportBundle()}catch(A){r(A instanceof Error?A.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(dt,{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(xr,{className:`w-4 h-4 ${f?"animate-spin":""}`}),t("common.refresh","Refresh")]})]}),s.jsx(xd,{title:t("system.application","Application"),icon:ef,children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[s.jsx(ti,{icon:ef,label:t("system.version","Version"),value:`v${c.app.version}`}),s.jsx(ti,{icon:Zn,label:t("system.uptime","System Uptime"),value:c.system.uptime_formatted}),s.jsx(ti,{icon:ef,label:t("system.hostname","Hostname"),value:c.system.hostname})]})}),s.jsx(xd,{title:t("support.title","Support & Troubleshooting"),icon:She,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(nN,{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(dt,{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(Hr,{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(dt,{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(zZe,{})]})}),s.jsxs(xd,{title:t("system.database","Database"),icon:su,children:[s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-4",children:[s.jsx(ti,{icon:es,label:t("system.totalArchives","Total Archives"),value:c.database.archives}),s.jsx(ti,{icon:rN,label:t("system.completed","Completed"),value:c.database.archives_completed,color:"text-green-500"}),s.jsx(ti,{icon:ia,label:t("system.failed","Failed"),value:c.database.archives_failed,color:"text-red-500"}),s.jsx(ti,{icon:dt,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(ti,{icon:qr,label:t("system.printers","Printers"),value:c.database.printers}),s.jsx(ti,{icon:HD,label:t("system.filaments","Filaments"),value:c.database.filaments}),s.jsx(ti,{icon:Ta,label:t("system.projects","Projects"),value:c.database.projects}),s.jsx(ti,{icon:Ks,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(ti,{icon:Zn,label:t("system.totalPrintTime","Total Print Time"),value:c.database.total_print_time_formatted}),s.jsx(ti,{icon:es,label:t("system.totalFilament","Total Filament Used"),value:`${c.database.total_filament_kg} kg`,subValue:`${c.database.total_filament_grams.toLocaleString()} g`})]})]}),s.jsxs(xd,{title:t("system.connectedPrinters","Connected Printers"),icon:qr,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(A=>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:A.name})]}),s.jsxs("div",{className:"flex items-center gap-4 text-sm text-bambu-gray",children:[s.jsx("span",{children:A.model}),s.jsx("span",{className:`px-2 py-0.5 rounded ${A.state==="RUNNING"?"bg-bambu-green/20 text-bambu-green":A.state==="IDLE"?"bg-blue-500/20 text-blue-400":"bg-bambu-dark-tertiary"}`,children:A.state})]})]},A.id))}):s.jsx("p",{className:"text-bambu-gray",children:t("system.noPrintersConnected","No printers connected")})]}),s.jsx(xd,{title:t("system.storage","Storage"),icon:lN,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(vq,{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(ti,{icon:es,label:t("system.archiveStorage","Archive Storage"),value:c.storage.archive_size_formatted}),s.jsx(ti,{icon:su,label:t("system.databaseSize","Database Size"),value:c.storage.database_size_formatted}),b&&s.jsx(ti,{icon:cl,label:t("system.fileManagerStorage","File Manager"),value:BZe(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(xd,{title:t("system.memory","Memory"),icon:nfe,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(vq,{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(xd,{title:t("system.cpu","CPU"),icon:y_,children:s.jsx("div",{className:"space-y-4",children:s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsx(ti,{icon:y_,label:t("system.cores","Cores"),value:c.cpu.count,subValue:`${c.cpu.count_logical} logical`}),s.jsx(ti,{icon:y_,label:t("system.usage","Usage"),value:`${c.cpu.percent}%`})]})})})]}),s.jsx(xd,{title:t("system.systemDetails","System Details"),icon:ef,children:s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsx(ti,{icon:ef,label:t("system.os","Operating System"),value:c.system.platform,subValue:c.system.platform_release}),s.jsx(ti,{icon:y_,label:t("system.architecture","Architecture"),value:c.system.architecture}),s.jsx(ti,{icon:ef,label:t("system.python","Python"),value:c.system.python_version}),s.jsx(ti,{icon:Zn,label:t("system.bootTime","Boot Time"),value:wg(c.system.boot_time,y)})]})})]})}function HZe(){const t=gl(),{login:e}=fh(),{showToast:n}=qn(),{mode:r}=hh(),[i,a]=w.useState(""),[o,l]=w.useState(""),c=mt({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 VZe(){const t=gl(),{showToast:e}=qn(),{mode:n}=hh(),{refreshAuth:r}=fh(),[i,a]=w.useState(!1),[o,l]=w.useState(""),[c,u]=w.useState(""),[d,f]=w.useState(""),m=mt({mutationFn:()=>he.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 GZe(){const t=gl(),{user:e}=fh(),{showToast:n}=qn(),r=on(),[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 T=k=>{k.key==="Escape"&&i&&(a(!1),f({username:"",password:"",role:"user"}))};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[i]);const{data:m=[],isLoading:p}=ut({queryKey:["users"],queryFn:()=>he.getUsers()}),b=mt({mutationFn:T=>he.createUser(T),onSuccess:()=>{r.invalidateQueries({queryKey:["users"]}),a(!1),f({username:"",password:"",role:"user"}),n("User created successfully")},onError:T=>{n(T.message,"error")}}),y=mt({mutationFn:({id:T,data:k})=>he.updateUser(T,k),onSuccess:()=>{r.invalidateQueries({queryKey:["users"]}),l(null),f({username:"",password:"",role:"user"}),n("User updated successfully")},onError:T=>{n(T.message,"error")}}),x=mt({mutationFn:T=>he.deleteUser(T),onSuccess:()=>{r.invalidateQueries({queryKey:["users"]}),n("User deleted successfully")},onError:T=>{n(T.message,"error")}}),v=()=>{if(!d.username||!d.password){n("Please fill in all required fields","error");return}b.mutate(d)},S=T=>{const k={username:d.username||void 0,password:d.password||void 0,role:d.role};k.password||delete k.password,y.mutate({id:T,data:k})},M=T=>{u(T)},A=T=>{l(T.id),f({username:T.username,password:"",role:T.role})};return e?.role!=="admin"?s.jsx("div",{className:"p-6",children:s.jsx(St,{children:s.jsx(Nt,{className:"py-6",children:s.jsxs("div",{className:"flex items-center gap-3 text-red-400",children:[s.jsx(MP,{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(fK,{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(pf,{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(Se,{onClick:()=>{a(!0),f({username:"",password:"",role:"user"})},children:[s.jsx(nr,{className:"w-4 h-4"}),"Create User"]})]}),p?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(dt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):s.jsx(St,{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(T=>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===T.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"}):T.username}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm",children:o===T.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 ${T.role==="admin"?"bg-purple-500/20 text-purple-300":"bg-blue-500/20 text-blue-300"}`,children:T.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 ${T.is_active?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:T.is_active?"Active":"Inactive"})}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium",children:o===T.id?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Se,{size:"sm",onClick:()=>S(T.id),disabled:y.isPending,children:[y.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(_s,{className:"w-4 h-4"}),"Save"]}),s.jsx(Se,{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(Se,{size:"sm",variant:"ghost",onClick:()=>A(T),children:[s.jsx(hN,{className:"w-4 h-4"}),"Edit"]}),T.id!==e?.id&&s.jsxs(Se,{size:"sm",variant:"ghost",onClick:()=>M(T.id),children:[s.jsx(dn,{className:"w-4 h-4"}),"Delete"]})]})})]},T.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(St,{className:"w-full max-w-md",onClick:T=>T.stopPropagation(),children:[s.jsx(er,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(pf,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Create User"})]}),s.jsx(Se,{variant:"ghost",size:"sm",onClick:()=>{a(!1),f({username:"",password:"",role:"user"})},children:s.jsx(Vt,{className:"w-5 h-5"})})]})}),s.jsxs(Nt,{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:T=>f({...d,username:T.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:T=>f({...d,password:T.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:T=>f({...d,role:T.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(Se,{variant:"secondary",onClick:()=>{a(!1),f({username:"",password:"",role:"user"})},children:"Cancel"}),s.jsx(Se,{onClick:v,disabled:b.isPending||!d.username||!d.password,children:b.isPending?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 animate-spin"}),"Creating..."]}):s.jsxs(s.Fragment,{children:[s.jsx(nr,{className:"w-4 h-4"}),"Create User"]})})]})]})]})}),c!==null&&s.jsx(Hn,{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 WZe(){const t=w.useRef(null),e=w.useRef(null),n=on(),[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`,A=new WebSocket(M);let T=null;A.onopen=()=>{console.log("[WebSocket] Connected"),i(!0),T=window.setInterval(()=>{A.readyState===WebSocket.OPEN&&A.send(JSON.stringify({type:"ping"}))},3e4)},A.onmessage=k=>{try{const E=JSON.parse(k.data);E.type==="printer_status"&&E.printer_id!==void 0&&E.data?f.current(E):(u.current.push(E),m())}catch{}},A.onclose=k=>{console.log("[WebSocket] Closed",k.code,k.reason),T&&(clearInterval(T),T=null),i(!1),t.current=null,e.current=window.setTimeout(()=>{p()},3e3)},A.onerror=k=>{console.error("[WebSocket] Error",k),A.close()},t.current=A},[m]),b=w.useCallback((S,M)=>{const A=l.current.get(S)||{};l.current.set(S,{...A,...M}),c.current||(c.current=window.setTimeout(()=>{const T=new Map(l.current);l.current.clear(),c.current=null,requestAnimationFrame(()=>{T.forEach((k,E)=>{n.setQueryData(["printerStatus",E],O=>{const C={...O,...k};return C.wifi_signal==null&&O?.wifi_signal!=null&&(C.wifi_signal=O.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 A=0;M.forEach(T=>{setTimeout(()=>{requestAnimationFrame(()=>{n.invalidateQueries({queryKey:[T]})})},A),A+=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 qZe=new pue({defaultOptions:{queries:{staleTime:1e3*60,retry:1}}});function KZe({children:t}){return WZe(),s.jsx(s.Fragment,{children:t})}function XZe({children:t}){const{authEnabled:e,loading:n,user:r}=fh();return n?s.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e&&!r?s.jsx(R1,{to:"/login",replace:!0}):s.jsx(s.Fragment,{children:t})}function YZe({children:t}){const{authEnabled:e,loading:n,user:r}=fh();return n?s.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e?r?r.role!=="admin"?s.jsx(R1,{to:"/",replace:!0}):s.jsx(s.Fragment,{children:t}):s.jsx(R1,{to:"/login",replace:!0}):s.jsx(s.Fragment,{children:t})}function ZZe({children:t}){const{authEnabled:e,loading:n}=fh();return n?s.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e?s.jsx(R1,{to:"/login",replace:!0}):s.jsx(s.Fragment,{children:t})}function QZe(){return s.jsx(zme,{children:s.jsx(Jme,{children:s.jsx(gue,{client:qZe,children:s.jsx(Gme,{children:s.jsx(Oce,{children:s.jsxs(uce,{children:[s.jsx(Xi,{path:"/setup",element:s.jsx(ZZe,{children:s.jsx(VZe,{})})}),s.jsx(Xi,{path:"/login",element:s.jsx(HZe,{})}),s.jsx(Xi,{path:"/camera/:printerId",element:s.jsx(IZe,{})}),s.jsxs(Xi,{element:s.jsx(XZe,{children:s.jsx(KZe,{children:s.jsx(Xme,{})})}),children:[s.jsx(Xi,{index:!0,element:s.jsx(JPe,{})}),s.jsx(Xi,{path:"archives",element:s.jsx(CKe,{})}),s.jsx(Xi,{path:"queue",element:s.jsx(mYe,{})}),s.jsx(Xi,{path:"stats",element:s.jsx(TYe,{})}),s.jsx(Xi,{path:"profiles",element:s.jsx(dZe,{})}),s.jsx(Xi,{path:"maintenance",element:s.jsx(gZe,{})}),s.jsx(Xi,{path:"projects",element:s.jsx(bZe,{})}),s.jsx(Xi,{path:"projects/:id",element:s.jsx(NZe,{})}),s.jsx(Xi,{path:"files",element:s.jsx(RZe,{})}),s.jsx(Xi,{path:"settings",element:s.jsx(YZe,{children:s.jsx(eZe,{})})}),s.jsx(Xi,{path:"users",element:s.jsx(GZe,{})}),s.jsx(Xi,{path:"system",element:s.jsx($Ze,{})}),s.jsx(Xi,{path:"external/:id",element:s.jsx(FZe,{})})]})]})})})})})})}coe.createRoot(document.getElementById("root")).render(s.jsx(w.StrictMode,{children:s.jsx(QZe,{})}));
|